immune-brain 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +239 -0
  2. package/README.zh-CN.md +239 -0
  3. package/package.json +84 -0
  4. package/plugins/immune-brain/.pi-extension/imm-canary-enroll.ts +666 -0
  5. package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +1622 -0
  6. package/plugins/immune-brain/.pi-extension/package.json +11 -0
  7. package/plugins/immune-brain/.pi-extension/pi-canary-assurance-progression.ts +711 -0
  8. package/plugins/immune-brain/.pi-extension/pi-canary-assurance.ts +154 -0
  9. package/plugins/immune-brain/.pi-extension/pi-canary-interaction.ts +349 -0
  10. package/plugins/immune-brain/.pi-extension/pi-canary-invocations.ts +90 -0
  11. package/plugins/immune-brain/.pi-extension/pi-canary-native-review.ts +214 -0
  12. package/plugins/immune-brain/.pi-extension/pi-canary-qa-findings.ts +50 -0
  13. package/plugins/immune-brain/.pi-extension/pi-canary-review-bundle.ts +262 -0
  14. package/plugins/immune-brain/.pi-extension/pi-canary-tool-failure.ts +28 -0
  15. package/plugins/immune-brain/.pi-extension/pi-canary-verification.ts +237 -0
  16. package/plugins/immune-brain/.pi-extension/runtime-stub.ts +414 -0
  17. package/plugins/immune-brain/.pi-extension/tsconfig.json +20 -0
  18. package/plugins/immune-brain/bin/imm-kernel +4 -0
  19. package/plugins/immune-brain/bin/imm-plan +4 -0
  20. package/plugins/immune-brain/bin/imm-pr-diag +230 -0
  21. package/plugins/immune-brain/bin/imm-retire-stale-wrapper +4 -0
  22. package/plugins/immune-brain/bin/imm-retired +4 -0
  23. package/plugins/immune-brain/bin/imm-tracker +4 -0
  24. package/plugins/immune-brain/dist/BASELINE.md +138 -0
  25. package/plugins/immune-brain/dist/docs/reference/HANDOFF-template.md +122 -0
  26. package/plugins/immune-brain/dist/docs/reference/design-contract-audit-rubric.md +149 -0
  27. package/plugins/immune-brain/dist/docs/reference/design-contract-review-checklist.md +55 -0
  28. package/plugins/immune-brain/dist/docs/reference/i18n-review-checklist.md +110 -0
  29. package/plugins/immune-brain/dist/docs/reference/immune-brain-config.md +52 -0
  30. package/plugins/immune-brain/dist/docs/reference/planning-artifact-retention.md +94 -0
  31. package/plugins/immune-brain/dist/docs/reference/planning-quality-gate.md +44 -0
  32. package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +105 -0
  33. package/plugins/immune-brain/dist/docs/reference/ux-heuristic-checklist.md +131 -0
  34. package/plugins/immune-brain/dist/imm-brainstorm.md +140 -0
  35. package/plugins/immune-brain/dist/imm-doc-prune.md +137 -0
  36. package/plugins/immune-brain/dist/imm-loop.md +158 -0
  37. package/plugins/immune-brain/dist/imm-planner.md +387 -0
  38. package/plugins/immune-brain/dist/imm-pr-fix.md +71 -0
  39. package/plugins/immune-brain/dist/registry.yaml +49 -0
  40. package/plugins/immune-brain/dist/role-prompts/advisory-reviewer.md +16 -0
  41. package/plugins/immune-brain/dist/role-prompts/arch-explorer.md +14 -0
  42. package/plugins/immune-brain/dist/role-prompts/code-review.md +15 -0
  43. package/plugins/immune-brain/dist/role-prompts/compounder.md +20 -0
  44. package/plugins/immune-brain/dist/role-prompts/executor.md +13 -0
  45. package/plugins/immune-brain/dist/role-prompts/pr-fix.md +81 -0
  46. package/plugins/immune-brain/dist/role-prompts/qa.md +23 -0
  47. package/plugins/immune-brain/dist/role-prompts/test-fixer.md +3 -0
  48. package/plugins/immune-brain/dist/role-prompts/ui-review.md +14 -0
  49. package/plugins/immune-brain/runtime/authority_commit_receipts.ts +716 -0
  50. package/plugins/immune-brain/runtime/canonical_json.ts +19 -0
  51. package/plugins/immune-brain/runtime/commands/kernel.ts +1160 -0
  52. package/plugins/immune-brain/runtime/github_issue_tracker.ts +1009 -0
  53. package/plugins/immune-brain/runtime/kernel/application.ts +300 -0
  54. package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +284 -0
  55. package/plugins/immune-brain/runtime/kernel/authority_port.ts +208 -0
  56. package/plugins/immune-brain/runtime/kernel/automatic_observations.ts +451 -0
  57. package/plugins/immune-brain/runtime/kernel/backend_claim.ts +197 -0
  58. package/plugins/immune-brain/runtime/kernel/canary_application.ts +507 -0
  59. package/plugins/immune-brain/runtime/kernel/canary_eligibility.ts +73 -0
  60. package/plugins/immune-brain/runtime/kernel/completion.ts +160 -0
  61. package/plugins/immune-brain/runtime/kernel/enrollment.ts +194 -0
  62. package/plugins/immune-brain/runtime/kernel/enrollment_authority.ts +123 -0
  63. package/plugins/immune-brain/runtime/kernel/index.ts +29 -0
  64. package/plugins/immune-brain/runtime/kernel/intent.ts +563 -0
  65. package/plugins/immune-brain/runtime/kernel/intent_token_registry.ts +80 -0
  66. package/plugins/immune-brain/runtime/kernel/legacy.ts +299 -0
  67. package/plugins/immune-brain/runtime/kernel/legacy_audit.ts +153 -0
  68. package/plugins/immune-brain/runtime/kernel/observation.ts +395 -0
  69. package/plugins/immune-brain/runtime/kernel/pi_canary_prepare.ts +169 -0
  70. package/plugins/immune-brain/runtime/kernel/readiness.ts +282 -0
  71. package/plugins/immune-brain/runtime/kernel/readiness_evidence.ts +132 -0
  72. package/plugins/immune-brain/runtime/kernel/reducer.ts +624 -0
  73. package/plugins/immune-brain/runtime/kernel/storage.ts +1780 -0
  74. package/plugins/immune-brain/runtime/kernel/storage_layout_migration.ts +791 -0
  75. package/plugins/immune-brain/runtime/kernel/storage_paths.ts +492 -0
  76. package/plugins/immune-brain/runtime/kernel/types.ts +295 -0
  77. package/plugins/immune-brain/runtime/kernel/validation.ts +963 -0
  78. package/plugins/immune-brain/runtime/loop_contract.ts +362 -0
  79. package/plugins/immune-brain/runtime/managed_task_routing_policy.ts +462 -0
  80. package/plugins/immune-brain/runtime/plan_core.ts +1053 -0
  81. package/plugins/immune-brain/runtime/prompts/advisory-reviewer.md +16 -0
  82. package/plugins/immune-brain/runtime/prompts/arch-explorer.md +14 -0
  83. package/plugins/immune-brain/runtime/prompts/code-review.md +15 -0
  84. package/plugins/immune-brain/runtime/prompts/compounder.md +20 -0
  85. package/plugins/immune-brain/runtime/prompts/executor.md +13 -0
  86. package/plugins/immune-brain/runtime/prompts/pr-fix.md +81 -0
  87. package/plugins/immune-brain/runtime/prompts/qa.md +23 -0
  88. package/plugins/immune-brain/runtime/prompts/test-fixer.md +3 -0
  89. package/plugins/immune-brain/runtime/prompts/ui-review.md +14 -0
  90. package/plugins/immune-brain/runtime/role_prompt_bridge.ts +160 -0
  91. package/plugins/immune-brain/runtime/v4_runtime.ts +295 -0
  92. package/plugins/immune-brain/runtime/verification_descriptor.ts +162 -0
  93. package/plugins/immune-brain/runtime/workspace_scope.ts +623 -0
  94. package/plugins/immune-brain/skills/.ignore +1 -0
  95. package/plugins/immune-brain/skills/BASELINE.md +138 -0
  96. package/plugins/immune-brain/skills/imm-brainstorm/SKILL.md +66 -0
  97. package/plugins/immune-brain/skills/imm-doc-prune/SKILL.md +11 -0
  98. package/plugins/immune-brain/skills/imm-loop/SKILL.md +52 -0
  99. package/plugins/immune-brain/skills/imm-planner/SKILL.md +221 -0
  100. package/plugins/immune-brain/skills/imm-pr-fix/SKILL.md +10 -0
  101. package/plugins/immune-brain/skills/registry.yaml +49 -0
@@ -0,0 +1,295 @@
1
+ export const TASK_PHASES = ["working", "review", "done", "stopped"] as const;
2
+ export type TaskPhase = (typeof TASK_PHASES)[number];
3
+
4
+ export const TASK_LIFECYCLES = ["active", "done", "stopped"] as const;
5
+ export type TaskLifecycle = (typeof TASK_LIFECYCLES)[number];
6
+ export const TASK_ARTIFACT_STATES = ["active", "frozen"] as const;
7
+ export type TaskArtifactState = (typeof TASK_ARTIFACT_STATES)[number];
8
+
9
+ export const TASK_RISKS = ["routine", "material", "critical"] as const;
10
+ export type TaskRisk = (typeof TASK_RISKS)[number];
11
+
12
+ export type EvidenceStatus = "passed" | "failed" | "blocked";
13
+
14
+ export type FindingKind =
15
+ | "blocking"
16
+ | "advisory"
17
+ | "unresolved_user_decision"
18
+ | "replan_required";
19
+ export type FindingStatus = "open" | "resolved";
20
+ export type FindingSource = "execution" | "review" | "kernel" | "migration";
21
+
22
+ export interface TaskFinding {
23
+ id: string;
24
+ kind: FindingKind;
25
+ status: FindingStatus;
26
+ acceptance_id: string | null;
27
+ source: FindingSource;
28
+ review_round: number | null;
29
+ summary: string;
30
+ }
31
+
32
+ export type ApprovalKind = "review" | "qa" | "user";
33
+ export type ApprovalAuthorityRole = "reviewer" | "qa" | "user";
34
+
35
+ export interface UserAuthorityAudit {
36
+ actor_id: string;
37
+ source: "literal_user";
38
+ confirmation_ref: string;
39
+ }
40
+
41
+ export interface CompletionDecision {
42
+ complete: boolean;
43
+ fresh_acceptance_ids: string[];
44
+ missing_acceptance_ids: string[];
45
+ stale_attestation_ids: string[];
46
+ missing_approval_kinds: ApprovalKind[];
47
+ blocking_finding_ids: string[];
48
+ unresolved_user_decision_ids: string[];
49
+ replan_required_ids: string[];
50
+ independence_violations: string[];
51
+ }
52
+
53
+ export type AssuranceObligation =
54
+ | "resolve_findings"
55
+ | "resolve_user_decision"
56
+ | "revise_intent"
57
+ | "submit_assurance"
58
+ | "run_qa"
59
+ | "run_review"
60
+ | "authorize_user"
61
+ | "complete"
62
+ | "none";
63
+
64
+ export interface LegacyMapping {
65
+ phase: TaskPhase | null;
66
+ reason: string;
67
+ ambiguous: boolean;
68
+ source_states: string[];
69
+ }
70
+
71
+ export interface V3CommitSourceEvent {
72
+ id: string;
73
+ action: string;
74
+ at: string | null;
75
+ }
76
+
77
+ export interface V3AuthorityObservation {
78
+ contract: "assurance_kernel/v3_authority_observation/v1";
79
+ observer_version: string;
80
+ observation_id: string;
81
+ commit_id: string;
82
+ ledger_revision: string;
83
+ committed_at: string;
84
+ plan_path: string | null;
85
+ plan_signature: string | null;
86
+ source_events: V3CommitSourceEvent[];
87
+ shadow: LegacyMapping;
88
+ divergence: {
89
+ detected: boolean;
90
+ fields: string[];
91
+ };
92
+ }
93
+
94
+ // ---------------------------------------------------------------------------
95
+ // P2C1 additive identity contracts (TaskIntent v1 / TaskRecord v2).
96
+ // Existing v1 contracts above remain byte-for-byte unchanged.
97
+ // ---------------------------------------------------------------------------
98
+
99
+ export const TASK_INTENT_CONTRACT_V1 = "assurance_kernel/task_intent/v1" as const;
100
+ export const TASK_RECORD_CONTRACT_V2 = "assurance_kernel/task_record/v2" as const;
101
+ export const TASK_RECORD_CONTRACT_V3 = "assurance_kernel/task_record/v3" as const;
102
+
103
+ export interface TaskIntentAcceptanceItemV1 {
104
+ id: string;
105
+ assertion: string;
106
+ verification: string;
107
+ }
108
+
109
+ export interface TaskIntentV1 {
110
+ contract: typeof TASK_INTENT_CONTRACT_V1;
111
+ task_id: string;
112
+ goal: string;
113
+ acceptance: TaskIntentAcceptanceItemV1[];
114
+ scope_hint: string[];
115
+ risk: TaskRisk;
116
+ revision: number;
117
+ owner: "user";
118
+ }
119
+
120
+ export interface TaskIntentRefV1 {
121
+ path: string;
122
+ revision: number;
123
+ content_hash: string;
124
+ }
125
+
126
+ export interface TaskIntentRefV3 {
127
+ path: string;
128
+ content_hash: string;
129
+ }
130
+
131
+ export interface TaskEvidenceV2 {
132
+ id: string;
133
+ acceptance_id: string;
134
+ task_revision: number;
135
+ intent_content_hash: string;
136
+ diff_hash: string;
137
+ status: EvidenceStatus;
138
+ actor_id: string;
139
+ summary: string;
140
+ }
141
+
142
+ export interface TaskApprovalV2 {
143
+ id: string;
144
+ kind: ApprovalKind;
145
+ authority_role: ApprovalAuthorityRole;
146
+ task_revision: number;
147
+ intent_content_hash: string;
148
+ diff_hash: string;
149
+ actor_id: string;
150
+ summary: string;
151
+ }
152
+
153
+ export interface TaskHistoryEntryV2 {
154
+ id: string;
155
+ at: string;
156
+ type: string;
157
+ from_phase: TaskPhase;
158
+ to_phase: TaskPhase;
159
+ reason: string;
160
+ authority?: AuthorityAuditDescriptor;
161
+ }
162
+
163
+ export interface TaskAttestationV3 extends TaskApprovalV2 {
164
+ acceptance_results: Array<{
165
+ acceptance_id: string;
166
+ status: EvidenceStatus;
167
+ summary: string;
168
+ }>;
169
+ }
170
+
171
+ export interface TaskHistoryEntryV3 {
172
+ id: string;
173
+ at: string;
174
+ type: string;
175
+ from_state: string;
176
+ to_state: string;
177
+ reason: string;
178
+ authority?: AuthorityAuditDescriptor;
179
+ }
180
+
181
+ export interface TaskRecordV2 {
182
+ contract: typeof TASK_RECORD_CONTRACT_V2;
183
+ task_id: string;
184
+ intent_revision: number;
185
+ intent_snapshot: TaskIntentV1;
186
+ intent_ref: TaskIntentRefV1;
187
+ artifact_ref?: { state: "active" | "frozen"; spec_path?: string };
188
+ phase: TaskPhase;
189
+ baseline: string;
190
+ evidence: TaskEvidenceV2[];
191
+ findings: TaskFinding[];
192
+ approvals: TaskApprovalV2[];
193
+ history: TaskHistoryEntryV2[];
194
+ }
195
+
196
+ export interface TaskRecordV3 {
197
+ contract: typeof TASK_RECORD_CONTRACT_V3;
198
+ task_id: string;
199
+ intent_snapshot: TaskIntentV1;
200
+ intent_ref: TaskIntentRefV3;
201
+ lifecycle: TaskLifecycle;
202
+ artifact_state: TaskArtifactState;
203
+ baseline: string;
204
+ attestations: TaskAttestationV3[];
205
+ findings: TaskFinding[];
206
+ history: TaskHistoryEntryV3[];
207
+ }
208
+
209
+ export interface TaskProjectionV3 extends CompletionDecision {
210
+ contract: "assurance_kernel/projection/v3";
211
+ task_id: string;
212
+ intent_revision: number;
213
+ lifecycle: TaskLifecycle;
214
+ artifact_state: TaskArtifactState;
215
+ blocked: boolean;
216
+ next_obligation: AssuranceObligation;
217
+ }
218
+
219
+ export type IntentRevisionClass =
220
+ | "unchanged"
221
+ | "compatible"
222
+ | "breaking";
223
+
224
+ export const TASK_ACTION_CONTRACT = "assurance_kernel/task_action/v2" as const;
225
+
226
+ export type MutationAuthorityKind = "review" | "qa" | "user";
227
+
228
+ export interface AuthorityAuditDescriptor {
229
+ authority_kind: MutationAuthorityKind;
230
+ actor_id: string;
231
+ confirmation_ref: string;
232
+ issued_at: string;
233
+ expires_at: string;
234
+ }
235
+
236
+ export interface TaskActionBase {
237
+ event_id: string;
238
+ at: string;
239
+ actor_id: string;
240
+ expected_record_hash: string;
241
+ expected_workspace_hash: string;
242
+ diff_hash: string;
243
+ }
244
+
245
+ export type TaskAction =
246
+ | (TaskActionBase & { type: "record_finding"; finding: TaskFinding })
247
+ | (TaskActionBase & { type: "resolve_finding"; finding_id: string })
248
+ | (TaskActionBase & { type: "record_approval"; approval: TaskApprovalV2 })
249
+ | (TaskActionBase & { type: "record_user_approval"; approval: TaskApprovalV2 })
250
+ | (TaskActionBase & {
251
+ type: "revise_intent";
252
+ next_intent: TaskIntentV1;
253
+ next_intent_ref: TaskIntentRefV3;
254
+ })
255
+ | (TaskActionBase & {
256
+ type: "approve_breaking_intent_revision";
257
+ next_intent: TaskIntentV1;
258
+ next_intent_ref: TaskIntentRefV3;
259
+ })
260
+ | (TaskActionBase & { type: "request_rework"; findings: TaskFinding[] })
261
+ | (TaskActionBase & { type: "complete" })
262
+ | (TaskActionBase & { type: "stop"; reason: string })
263
+ | (TaskActionBase & { type: "resolve_user_decision"; finding_id: string; resolution: string });
264
+
265
+
266
+ /** Branded, non-serializable reducer result. */
267
+ export const REDUCED_MUTATION_BRAND = Symbol("assurance-kernel-reduced-mutation-v2");
268
+
269
+ export interface ReducedTaskMutation {
270
+ readonly [REDUCED_MUTATION_BRAND]: true;
271
+ readonly record: TaskRecordV3;
272
+ readonly next_workspace_working: string | null;
273
+ }
274
+
275
+ export interface StoredTaskMutationV3 {
276
+ revision: string;
277
+ record: TaskRecordV3;
278
+ workspace: {
279
+ revision: string;
280
+ state: WorkspaceStateLike;
281
+ };
282
+ }
283
+
284
+ export interface WorkspaceStateLike {
285
+ contract: "assurance_kernel/workspace/v1";
286
+ current_working: string | null;
287
+ }
288
+
289
+ export const MUTATION_AUTHORITY_CAPABILITY_BRAND = Symbol(
290
+ "assurance-kernel-mutation-authority-capability",
291
+ );
292
+
293
+ export interface MutationAuthorityCapabilityV2 {
294
+ readonly [MUTATION_AUTHORITY_CAPABILITY_BRAND]: true;
295
+ }