immune-brain 3.6.9 → 4.0.1

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 (76) hide show
  1. package/package.json +3 -2
  2. package/plugins/immune-brain/.claude-plugin/plugin.json +1 -1
  3. package/plugins/immune-brain/.pi-extension/imm-canary-enroll.ts +18 -2
  4. package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +76 -121
  5. package/plugins/immune-brain/.pi-extension/imm-unattended-batch.ts +106 -600
  6. package/plugins/immune-brain/.pi-extension/pi-canary-assurance-progression.ts +1 -0
  7. package/plugins/immune-brain/.pi-extension/pi-canary-verification.ts +3 -3
  8. package/plugins/immune-brain/.pi-extension/runtime-stub.ts +17 -43
  9. package/plugins/immune-brain/dist/claude/mcp-server.mjs +7587 -5049
  10. package/plugins/immune-brain/dist/docs/reference/planning-artifact-retention.md +11 -12
  11. package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +1 -1
  12. package/plugins/immune-brain/dist/imm-loop.md +33 -25
  13. package/plugins/immune-brain/dist/imm-planner.md +41 -27
  14. package/plugins/immune-brain/dist/imm-review-retro.md +2 -2
  15. package/plugins/immune-brain/dist/role-prompts/code-review.md +11 -1
  16. package/plugins/immune-brain/dist/role-prompts/executor.md +4 -4
  17. package/plugins/immune-brain/runtime/assurance/coordinator.ts +183 -40
  18. package/plugins/immune-brain/runtime/assurance/delivery_workspace.ts +240 -0
  19. package/plugins/immune-brain/runtime/assurance/qa.ts +132 -58
  20. package/plugins/immune-brain/runtime/assurance/review_evidence.ts +15 -7
  21. package/plugins/immune-brain/runtime/assurance/verification.ts +246 -206
  22. package/plugins/immune-brain/runtime/authorization_operation.ts +20 -0
  23. package/plugins/immune-brain/runtime/claude/kernel_ports.ts +288 -721
  24. package/plugins/immune-brain/runtime/commands/kernel.ts +158 -67
  25. package/plugins/immune-brain/runtime/github_issue_tracker.ts +1 -1
  26. package/plugins/immune-brain/runtime/kernel/actor_identity.ts +33 -0
  27. package/plugins/immune-brain/runtime/kernel/application.ts +22 -6
  28. package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +94 -5
  29. package/plugins/immune-brain/runtime/kernel/authority_port.ts +27 -6
  30. package/plugins/immune-brain/runtime/kernel/backend_claim.ts +43 -16
  31. package/plugins/immune-brain/runtime/kernel/batch_authority.ts +10 -6
  32. package/plugins/immune-brain/runtime/kernel/canary_application.ts +50 -63
  33. package/plugins/immune-brain/runtime/kernel/canary_eligibility.ts +13 -4
  34. package/plugins/immune-brain/runtime/kernel/completion.ts +5 -14
  35. package/plugins/immune-brain/runtime/kernel/enrollment.ts +124 -34
  36. package/plugins/immune-brain/runtime/kernel/enrollment_authority.ts +13 -5
  37. package/plugins/immune-brain/runtime/kernel/index.ts +3 -1
  38. package/plugins/immune-brain/runtime/kernel/intent.ts +7 -11
  39. package/plugins/immune-brain/runtime/kernel/legacy_audit.ts +4 -1
  40. package/plugins/immune-brain/runtime/kernel/legacy_task_record.ts +323 -0
  41. package/plugins/immune-brain/runtime/kernel/pi_canary_prepare.ts +10 -1
  42. package/plugins/immune-brain/runtime/kernel/reducer.ts +32 -31
  43. package/plugins/immune-brain/runtime/kernel/run_identity.ts +121 -0
  44. package/plugins/immune-brain/runtime/kernel/spec_binding.ts +100 -0
  45. package/plugins/immune-brain/runtime/kernel/sqlite_migration.ts +950 -0
  46. package/plugins/immune-brain/runtime/kernel/sqlite_store.ts +1193 -0
  47. package/plugins/immune-brain/runtime/kernel/storage.ts +1254 -1206
  48. package/plugins/immune-brain/runtime/kernel/storage_layout_migration.ts +129 -755
  49. package/plugins/immune-brain/runtime/kernel/storage_paths.ts +419 -46
  50. package/plugins/immune-brain/runtime/kernel/types.ts +12 -43
  51. package/plugins/immune-brain/runtime/kernel/validation.ts +60 -274
  52. package/plugins/immune-brain/runtime/managed_task_routing_policy.ts +0 -1
  53. package/plugins/immune-brain/runtime/plan_core.ts +27 -65
  54. package/plugins/immune-brain/runtime/plugin_version.ts +1 -1
  55. package/plugins/immune-brain/runtime/prompts/code-review.md +11 -1
  56. package/plugins/immune-brain/runtime/prompts/executor.md +4 -4
  57. package/plugins/immune-brain/runtime/staged_intent.ts +58 -0
  58. package/plugins/immune-brain/runtime/unattended/batch_git.ts +37 -7
  59. package/plugins/immune-brain/runtime/unattended/batch_plan.ts +42 -2
  60. package/plugins/immune-brain/runtime/unattended/batch_preflight.ts +771 -0
  61. package/plugins/immune-brain/runtime/unattended/batch_reasons.ts +189 -0
  62. package/plugins/immune-brain/runtime/unattended/batch_runner.ts +35 -0
  63. package/plugins/immune-brain/runtime/unattended/confirmation_deadline.ts +33 -0
  64. package/plugins/immune-brain/runtime/unattended/types.ts +14 -1
  65. package/plugins/immune-brain/runtime/v4_runtime.ts +19 -23
  66. package/plugins/immune-brain/runtime/verification_descriptor.ts +92 -136
  67. package/plugins/immune-brain/runtime/workspace_scope.ts +98 -13
  68. package/plugins/immune-brain/skills/imm-planner/SKILL.md +3 -3
  69. package/plugins/immune-brain/bin/imm-retire-stale-wrapper +0 -4
  70. package/plugins/immune-brain/bin/imm-retired +0 -4
  71. package/plugins/immune-brain/runtime/authority_commit_receipts.ts +0 -716
  72. package/plugins/immune-brain/runtime/kernel/automatic_observations.ts +0 -451
  73. package/plugins/immune-brain/runtime/kernel/legacy.ts +0 -299
  74. package/plugins/immune-brain/runtime/kernel/observation.ts +0 -397
  75. package/plugins/immune-brain/runtime/kernel/readiness.ts +0 -282
  76. package/plugins/immune-brain/runtime/kernel/readiness_evidence.ts +0 -132
@@ -73,18 +73,17 @@ Non-terminal artifacts remain durable at their existing paths by default.
73
73
 
74
74
  ## Authority-Owned Lifecycle
75
75
 
76
- An enrolled TaskIntent and the one exact active Spec bound by its `scope_hint`
77
- remain under `docs/plans/` and `docs/specs/` while the task is `working`. Before
78
- QA, the Kernel freezes both artifacts through one recoverable transaction: bytes
79
- move to their `archive/` paths and `TaskRecord.intent_ref.path` changes to the
80
- archived sidecar. Every later Kernel action rereads that recorded path.
81
-
82
- Authorized Review rework restores both artifacts before returning to `working`.
83
- Completion is valid only from the frozen location. Stop freezes an active pair
84
- before terminal settlement, so both terminal outcomes leave no active planning
85
- artifact. A relocation conflict or crash fails closed and converges only through
86
- the transaction marker; no background scanner or second status writer may infer
87
- or repair lifecycle state.
76
+ An enrolled TaskIntent remains under `docs/plans/` for the whole run. A complex
77
+ task may bind one active Spec under `docs/specs/` by content identity. Before QA,
78
+ the Kernel freezes those artifacts in place: Git objects are bound, source paths
79
+ do not move, and `TaskRecord.intent_ref.path` stays on the active sidecar.
80
+ Historical files already in `archive/` remain readable. A later edit of a bound
81
+ Spec changes the delivery identity, so prior assurance cannot be reused.
82
+
83
+ Authorized Review rework returns `artifact_state` to `active` without relocating
84
+ files. Completion and stop freeze in place; they do not archive planning
85
+ artifacts. A crash fails closed and converges only through the store transaction;
86
+ no background scanner or second status writer may infer or repair lifecycle state.
88
87
 
89
88
  Terminal cleanup outside that lifecycle remains a bounded TaskIntent with an
90
89
  explicit candidate list and a copy-paste verification command. It may accompany
@@ -80,7 +80,7 @@ Agent:
80
80
  schedule: ""
81
81
  ```
82
82
 
83
- Pi `Agent` has no `readonly` parameter; the empty tool policy, child type, and prompt contract enforce the read-only boundary. The Parent starts one foreground Agent at a time and consumes its direct result before deciding whether another child is needed. Advisory and discovery work does not call `get_subagent_result` or depend on completion notifications or host `followUp`. Kernel Review uses `subagent_type: "Review"`; its structured verdict is submitted by the Parent and validated against the current immutable snapshot. Loop `arch-explorer` uses `subagent_type: "Explore"`; other advisory/discovery and Loop internal roles use `general-purpose`.
83
+ Pi `Agent` has no `readonly` parameter; the empty tool policy, child type, and prompt contract enforce the read-only boundary. The Parent starts one foreground Agent at a time and consumes its direct result before deciding whether another child is needed. Advisory and discovery work does not poll for deferred results or depend on completion notifications or host `followUp`. Kernel Review uses `subagent_type: "Review"`; its structured verdict is submitted by the Parent and validated against the current immutable snapshot. Loop `arch-explorer` uses `subagent_type: "Explore"`; other advisory/discovery and Loop internal roles use `general-purpose`.
84
84
 
85
85
  ## Scheduling And Visibility
86
86
 
@@ -11,9 +11,9 @@ This skill adheres to the **[BASELINE.md](BASELINE.md)**.
11
11
 
12
12
  Only explicit `imm-loop` entry starts or resumes this loop. Ordinary host input
13
13
  stays host-native; it never resumes a Managed owner implicitly. Read the current
14
- Host's `imm_kernel_canary` `status` first and verify the exact active backend
15
- claim, TaskIntent, and TaskRecord. Invalid or contradictory projections fail
16
- closed. A candidate TaskIntent is not Enrollment authority.
14
+ Host's `status` projection first and verify the exact active backend claim,
15
+ TaskIntent, and TaskRecord. Invalid or contradictory projections fail closed. A
16
+ candidate TaskIntent is not Enrollment authority.
17
17
 
18
18
  Before the first Enrollment of a candidate TaskIntent, confirm the Planner
19
19
  returned `tracker_associated` — but only when the candidate belongs to an
@@ -36,11 +36,12 @@ Historical prose Plans and State Ledgers are read-only history, not execution
36
36
  instructions. Do not create Steps, workflow profiles, follow-up ledgers, or
37
37
  successor Plans to drive a Kernel task.
38
38
 
39
- At every internal role boundary call the read-only `imm_loop_action` Tool. Use
40
- `route` for current-context Executor work, bounded repair, architecture
41
- exploration, advisory review, Compounder, Kernel ownership, or scope expansion.
42
- Use Kernel ownership for an enrolled task. This Tool projects authority; it does
43
- not record execution evidence, mutate task state, or replace Kernel operations.
39
+ At every internal role boundary call the invoking Host's read-only role-boundary
40
+ route. Use `route` for current-context Executor work, bounded repair,
41
+ architecture exploration, advisory review, Compounder, Kernel ownership, or
42
+ scope expansion. Use Kernel ownership for an enrolled task. This route projects
43
+ authority; it does not record execution evidence, mutate task state, or replace
44
+ Kernel operations.
44
45
  Before a child dispatch, read the [Subagent Dispatch Protocol](docs/reference/subagent-dispatch-protocol.md#authorization-authority).
45
46
  Never load an internal role as a public Skill or spawn another loop process.
46
47
  The standalone `imm-pr-fix`, `imm-doc-prune`, and `imm-agent-doc-maintain` are host-native
@@ -51,26 +52,33 @@ and `pr-fix` repairs remain bounded by the enrolled TaskIntent.
51
52
 
52
53
  Continue while the current projection has a valid action:
53
54
 
54
- 1. For active artifacts, implement only the enrolled acceptance within
55
- `scope_hint` in the current conversation. Run focused checks. Executor checks
56
- are diagnostic evidence, not a QA or Review approval.
57
- 2. Before Assurance, call `freeze_artifacts` while TaskRecord is `active:active`.
58
- A bound active Spec and its archive path must both be inside `scope_hint`.
59
- The Kernel owns byte-preserving archival and the frozen snapshot.
60
- 3. Call `advance_assurance` in the foreground and consume its direct terminal
61
- result. Deterministic QA runs fixed acceptance descriptors atomically inside
62
- the Host integration. Do not dispatch a separate per-Step QA Agent.
63
- 4. On `review_ready`, invoke the returned `agent_params` as one exact foreground
55
+ 1. For active artifacts, implement only the enrolled acceptance within the
56
+ `scope_hint` envelope in the current conversation. New helpers or tests
57
+ inside an approved directory or glob do not require a revision. Run focused
58
+ checks. Executor checks are diagnostic evidence, not a QA or Review approval.
59
+ 2. Call `advance_assurance` in the foreground and consume its direct terminal
60
+ result. The Kernel freezes the artifacts itself before QA: it binds Git
61
+ content identity in place without relocating source paths. A simple task has
62
+ TaskIntent only; a complex task may bind one active Spec. Deterministic QA
63
+ runs all descriptors in a disposable delivery materialization, never against
64
+ unchecked live worktree source. Do not dispatch a separate per-Step QA Agent.
65
+ 3. On `review_ready`, invoke the returned `agent_params` as one exact foreground
64
66
  Agent call, then pass its structured verdict to `submit_review`. Do not
65
67
  replace this snapshot-bound reviewer with a generic role dispatch. The Parent
66
68
  cannot issue its own QA or Review pass.
67
- 5. Follow the returned Kernel obligation. Fresh QA suffices for routine work;
69
+ 4. Follow the returned Kernel obligation. Fresh QA suffices for routine work;
68
70
  material and critical work additionally require fresh independent Review.
69
71
  Normal completion does not require a second user confirmation.
70
- 6. For rework, follow the projected artifact state before editing. Resolve
72
+ 5. For rework, follow the projected artifact state before editing. Resolve
71
73
  findings only after fixing and verifying their cause. Changed snapshots
72
- invalidate old evidence; freeze and run the newly required obligations.
73
- 7. An unresolved decision pauses only dependent execution. On `awaiting_user`,
74
+ invalidate old evidence; run the newly required obligations. On the second
75
+ rework of one acceptance id or anchor, the fix response must either state why
76
+ it covers every known trigger class of the violated invariant — the shared
77
+ guard, not only the reported path — or declare the trigger outside the
78
+ accepted contract and answer with `refute_finding` bound to fresh QA evidence
79
+ for that acceptance. Escalating a local heuristic a third time instead of
80
+ choosing one of those two responses is the loop this step exists to break.
81
+ 6. An unresolved decision pauses only dependent execution. On `awaiting_user`,
74
82
  invoke `request_authorization` directly before ending the turn; use the
75
83
  Decisions and Recovery route for its native-gate handling. End the turn if
76
84
  the decision remains unresolved, is cancelled, or the gate fails. Otherwise
@@ -122,9 +130,9 @@ per completed child.
122
130
  enrolled intent sidecars or ask for chat pre-confirmation.
123
131
  - On `awaiting_user`, invoke `request_authorization` directly for a concrete
124
132
  unresolved decision or rework authorization, not risk tier alone.
125
- - When the user explicitly asks to stop a Pi task, invoke
126
- `imm_kernel_canary({ task_id, action: { op: "request_stop" } })` directly.
127
- Its single native confirmation authorizes existing Kernel stop settlement.
133
+ - When the user explicitly asks to stop an active task, invoke the Kernel stop
134
+ operation through the invoking Host directly. Its single native confirmation
135
+ authorizes existing Kernel stop settlement.
128
136
  Cancellation is not task termination. A busy invocation must finish or be
129
137
  cancelled through existing Host controls before requesting stop; never clear
130
138
  claims manually or use this operation to force-kill QA.
@@ -115,8 +115,9 @@ and clarification. It does not apply to Enrolled Intent Revision.
115
115
  Before authoring a TaskIntent, trace each expected behavior from its public or
116
116
  runtime entry point through existing imports and callers to the highest focused
117
117
  behavioral tests. Include generated or packaged mirrors and every owner of the
118
- same state machine. Record the concrete paths in the Spec's discovery evidence;
119
- do not author while a referenced sibling is unresolved. Use the smallest
118
+ same state machine. Record the concrete paths in the Spec's discovery evidence when the work is
119
+ complex; simple TaskIntent-only work records them in `scope_hint`.
120
+ Do not author while a referenced sibling is unresolved. Use the smallest
120
121
  coherent module directory for ordinary implementation scope. Keep Kernel,
121
122
  authority, migration, secret, and security-sensitive scope exact to the files
122
123
  proved necessary by the trace. Scope is closed by reference evidence, not by an
@@ -132,6 +133,13 @@ file creation; then it validates the created artifact with
132
133
  continue through Kernel `revise_intent` authority and are not a Planner
133
134
  overwrite path.
134
135
 
136
+ Before authoring a TaskIntent that adds a field or verdict branch to a state
137
+ machine, enumerate every consumer of that value and of the version gates around
138
+ it: the producing side, each branch or switch that reads it, and any migration or
139
+ replay path that carries historical copies. Name all of them in `scope_hint`. An
140
+ authoring pass that traces only the producer is the defect this enumeration
141
+ exists to prevent.
142
+
135
143
  ### Initiative Carrier Preference
136
144
 
137
145
  For a large proposal split across multiple TaskIntents, exactly one planning
@@ -249,19 +257,25 @@ and an exact retry action; the strict no-amendment default is unchanged.
249
257
  ### Verification Descriptor Discipline
250
258
 
251
259
  Every acceptance verification descriptor must be a focused, deterministic,
252
- repository-local check that exercises only its acceptance assertion. Prefer one
253
- small `bun test <focused-file>` or `bun run <focused-script>` per acceptance;
254
- never use the full test suite, a build, package installation, network access, or
255
- redundant heavyweight checks. Prefer the highest existing observable behavioral
256
- test seam and the fewest sufficient seams. Cite relevant test prior art and
257
- explain how the selected seam catches the intended regression. This is a
258
- planning heuristic: it must not weaken acceptance-specific focused verification
259
- descriptors or add a mandatory user confirmation. Use the smallest `timeout_ms` and
260
- `max_output_bytes` that cover deterministic post-implementation QA.
260
+ project-owned check that exercises only its acceptance assertion. Use
261
+ `assurance_kernel/verification_descriptor/v2` and reuse an existing project
262
+ script or host tool through its literal `command`; do not infer a language,
263
+ package manager, or runner. Add `environment.prepare` only when the check needs
264
+ explicit setup, and declare only the generated directories it needs in
265
+ `environment.writable_paths`. Never hide package installation inside an
266
+ acceptance command. Prefer the highest existing observable behavioral test seam
267
+ and the fewest sufficient seams; never use the full test suite, a build, network
268
+ access, or redundant heavyweight checks as acceptance. Cite relevant test prior
269
+ art and explain how the selected seam catches the intended regression. This is
270
+ a planning heuristic: it must not weaken acceptance-specific focused
271
+ verification descriptors or add a mandatory user confirmation. Use the smallest
272
+ `timeout_ms` and `max_output_bytes` that cover deterministic post-implementation
273
+ QA. A v1 descriptor is historical-only and requires explicit Intent revision
274
+ before execution.
261
275
 
262
276
  ## Core Responsibilities
263
277
 
264
- - **Decomposition**: Convert requirements into a concrete spec under `docs/specs/` and one or more TaskIntents. Treat Technical Design as one TaskIntent decomposition dimension alongside outcome, Verification, dependency, risk, rollback, compatibility, and authority.
278
+ - **Decomposition**: Convert requirements into one or more TaskIntents. Add a Spec under `docs/specs/` only for complex work. Treat Technical Design as one TaskIntent decomposition dimension alongside outcome, Verification, dependency, risk, rollback, compatibility, and authority.
265
279
  - **Outcome Focus**: Each TaskIntent owns one independently verifiable outcome. Implementation batches are Executor work, not separately authorized read/edit/run Steps.
266
280
  - **Planning granularity**: Keep a coherent outcome together when acceptance, risk, rollback, and authority can settle together. Use the TaskIntent decomposition rules below for independent outcomes. File count, tokens, compactions, elapsed time, and review rounds are evidence for judgment, not universal gates.
267
281
  - **Historical artifacts**: v3 prose Plan mutation is retired. `imm-plan` is a read-only validator for archived Plans; create no new Roadmap, Phase, successor Plan, or State Ledger.
@@ -273,9 +287,9 @@ descriptors or add a mandatory user confirmation. Use the smallest `timeout_ms`
273
287
  - **TaskIntent decomposition**: Use the selected design boundaries as one retain/split criterion for TaskIntent slices. Keep work in one TaskIntent when the selected views describe one coherent executable slice with shared acceptance, risk treatment, rollback, and authority. Split a successor TaskIntent when a service boundary, state-machine owner, migration/compatibility boundary, independently promotable layer, or sequence dependency needs independent verification, rollback, authorization, or settlement. Do not split merely because the design names several layers, files, or services. Treat trust-boundary changes as the same kind of decomposition evidence: a TaskIntent should normally change one primary trust-boundary invariant, while merely traversing several boundaries or updating both sides of one end-to-end authority chain does not require a split. Split separate trust invariants when they can be independently verified, rolled back, authorized, migrated, or settled. Keep multiple trust-boundary changes together only when they form one atomic security outcome and splitting would create an unsafe or unusable intermediate state; record that reason in the Spec. This is Planner judgment, not a TaskIntent schema field or an Enrollment counting rule. This does not revive prose Plan, Roadmap, or Phase authority.
274
288
  - **Mermaid Use**: Mermaid is required only when a medium/high-risk design contains structure, sequence, data flow, or state transition relationships that a diagram materially clarifies. Mermaid is not a universal gate; a diagram supplements adjacent prose and never becomes a second design authority. Medium/High risk Specs record `**Diagram decision**: required|not_required` and a non-empty `**Diagram reason**:`. A `required` decision must have a Mermaid block; `not_required` explains why prose is sufficient. Low-risk Specs omit the empty ceremony and record neither field.
275
289
  - **Verification**: Every acceptance assertion has a concrete focused descriptor that can fail on the intended regression. Hypothetical evidence is not execution-ready.
276
- - **Executable Scope**: `scope_hint` is the mutation envelope, not discovery context. Close references across callers, tests, generated mirrors, and state-machine owners before authoring. Include bound active and archive Spec paths needed for `freeze_artifacts`. Collect all known scope gaps in one revision request; ask again only when new evidence changes the boundary.
277
- - **Devil's Advocate Preplan Audit**: Medium/High risk work records a `Devil's Advocate Audit` in the Spec covering rollback resilience, verification vanity, and spec dilution detection. Explain recovery from partial implementation, why verification detects the regression, and how accepted requirements remain covered. Low-risk work omits the empty template; the Spec records outcome, boundary, and concrete verification only.
278
- - **Execution posture**: Record `test-first` or `characterization-first` in the Spec when explicitly requested or justified by fragile untested behavior. The Executor owns the local choreography; do not create prototype or RED/GREEN/REFACTOR authority Steps. Throwaway probes must have a cleanup condition and a durable decision output.
290
+ - **Executable Scope**: `scope_hint` is the mutation envelope, not discovery context. Close references across callers, tests, generated mirrors, and state-machine owners before authoring. Simple tasks are TaskIntent-only. A complex task binds at most one active Spec by content identity; do not add archive paths for freeze, and do not relocate artifacts. Collect all known scope gaps in one revision request; ask again only when new evidence changes the boundary.
291
+ - **Devil's Advocate Preplan Audit**: Medium/High risk work records a `Devil's Advocate Audit` in its Spec covering rollback resilience, verification vanity, and spec dilution detection. Explain recovery from partial implementation, why verification detects the regression, and how accepted requirements remain covered. Simple TaskIntent-only work records outcome, boundary, and concrete verification on the Intent. Low-risk work omits the empty template.
292
+ - **Execution posture**: Record `test-first` or `characterization-first` on the Spec when the work is complex, otherwise on the TaskIntent, when explicitly requested or justified by fragile untested behavior. The Executor owns the local choreography; do not create prototype or RED/GREEN/REFACTOR authority Steps. Throwaway probes must have a cleanup condition and a durable decision output.
279
293
 
280
294
  ## Settlement-Design Contract
281
295
 
@@ -364,21 +378,21 @@ preparation does not apply the revision or authorize expanded execution.
364
378
  planning heuristic: it must not weaken acceptance-specific focused
365
379
  verification descriptors or add a mandatory user confirmation.
366
380
  - **Review Mapping**: In-scope rework stays with the enrolled TaskIntent and explicit `imm-loop` entry. Cross-scope findings become a Planner decision delta with concrete missing paths and verification evidence; do not create a successor prose Plan.
367
- - **Brainstorm Manifest Mapping**: Record every upstream `BR-*` item in a Spec `Brainstorm Trace`, mapped to TaskIntent acceptance, a captured decision, or an explicit reason for deferral or exclusion. Resolve every `BR-Q-*` item before handoff. Do not silently narrow confirmed framing.
381
+ - **Brainstorm Manifest Mapping**: Record every upstream `BR-*` item in a Spec `Brainstorm Trace` when the work is complex, otherwise on the TaskIntent, mapped to acceptance, a captured decision, or an explicit reason for deferral or exclusion. Resolve every `BR-Q-*` item before handoff. Do not silently narrow confirmed framing.
368
382
  - **Session Lifecycle Ownership**: The user chooses the current or a new session. Tokens, compactions, tool counts, elapsed time, and review rounds never trigger automatic session creation or termination. Recovery uses TaskRecord and the fresh Kernel projection.
369
383
  - **Subagents**: Only when optional research is needed, read Research Dispatch and its shared dispatch reference. Default to inline evidence gathering. Plan conditional reviewers such as `security-reviewer` only if their trigger surfaces are explicit; do not manufacture them.
370
384
  - **Enrolled Intent**: Follow Enrolled Intent Revision for a Loop-requested scope or acceptance change; candidate preparation never changes the current owner or grants execution authority.
371
385
  - **CONTEXT.md Vocabulary**: Consult the relevant `CONTEXT.md` terms when domain meaning is unclear or changes; known file-local tasks do not require a full root-document read. `CONTEXT.md` is vocabulary and architecture navigation, not execution state.
372
- - **Discovery Protocol**: Read `CONTEXT.md` `## Architecture Map` before broad searching; consult relevant `docs/solutions/` evidence under Clarification supplement's history trigger. Record concrete file pointers and reasons in the Spec. Do not read or write a legacy Step discovery cache.
373
- - **Planning Quality Gate**: For elevated-risk work, verify contract surfaces, compatibility, interruption recovery, rollback, verification strength, and Brainstorm traceability in the Spec. Do not invoke retired Plan mutation or State Ledger synchronization.
386
+ - **Discovery Protocol**: Read `CONTEXT.md` `## Architecture Map` before broad searching; consult relevant `docs/solutions/` evidence under Clarification supplement's history trigger. Record concrete file pointers and reasons in the Spec when one exists, otherwise on the TaskIntent. Do not read or write a legacy Step discovery cache.
387
+ - **Planning Quality Gate**: For elevated-risk complex work, verify contract surfaces, compatibility, interruption recovery, rollback, verification strength, and Brainstorm traceability in the Spec. Simple TaskIntent-only work verifies those properties on the Intent. Do not invoke retired Plan mutation or State Ledger synchronization.
374
388
  - **Parallel Probes**: Optional read-only probes must have bounded non-overlapping scopes, expected evidence, and no file or authority writes. They are advisory discovery, not persisted Step annotations. Probe failure falls back to inline investigation with a recorded reason.
375
389
 
376
390
  ## Research Dispatch
377
391
 
378
392
  Follow [`docs/reference/subagent-dispatch-protocol.md`](docs/reference/subagent-dispatch-protocol.md) for the full dispatch lifecycle. This section defines planner-specific optional research dispatch.
379
393
 
380
- Use `imm_loop_action` for bounded `arch-explorer` and explicit-lens
381
- `advisory-reviewer` routing. Invoke the returned foreground Agent envelope
394
+ Use the invoking Host's read-only role-boundary route for bounded
395
+ `arch-explorer` and explicit-lens `advisory-reviewer` routing. Invoke the returned foreground Agent envelope
382
396
  exactly. The Parent owns Spec/TaskIntent synthesis, Brainstorm traceability,
383
397
  acceptance, and scope; children return evidence only. On Pi the `arch-explorer` envelope
384
398
  uses `subagent_type: "Explore"`; invoke the returned envelope rather than
@@ -396,19 +410,19 @@ optional advisory dispatch fails, continue inline and record the reason.
396
410
 
397
411
  ## Boundary
398
412
 
399
- - **Allowed**: Write candidate Specs and TaskIntents, Initiative planning carriers, and necessary domain vocabulary.
413
+ - **Allowed**: Write a TaskIntent. Add a Spec only for complex work. Initiative planning carriers and necessary domain vocabulary.
400
414
  - **Blocked**: Implementation edits, direct Kernel-store writes, enrolled intent overwrites, and QA/Review decisions.
401
415
  - **Workflow guard**: Execution continues through native Enrollment and explicit `imm-loop`. Planner owns design and decomposition, not execution authority.
402
416
 
403
417
  ## Output artifact
404
418
 
405
- Spec under `docs/specs/` plus canonical candidate
406
- `docs/plans/<task-id>.intent.json`. The Spec records outcome, discovery evidence,
419
+ Canonical candidate `docs/plans/<task-id>.intent.json`. Simple future work does
420
+ not require a Spec. A complex task adds one Spec under `docs/specs/` bound by
421
+ immutable content identity, not by archive relocation. The Spec records outcome, discovery evidence,
407
422
  decisions, assumptions, Technical Design when required, output language,
408
423
  the Medium/High risk Devil's Advocate Audit, and acceptance/test mapping. Low
409
424
  risk records outcome, boundary, and concrete verification without the empty
410
- ceremony. Include a complete
411
- `Brainstorm Trace` when consuming a Brainstorm manifest. TaskIntent is authored
425
+ ceremony. Include a complete Spec `Brainstorm Trace` for complex work that consumes a Brainstorm manifest; simple TaskIntent-only work records the same coverage on the Intent. TaskIntent is authored
412
426
  and validated through `imm-kernel`; do not write a prose iteration Plan or sync
413
427
  a State Ledger. Keep historical Plan validation strictly read-only.
414
428
 
@@ -431,7 +445,7 @@ a State Ledger. Keep historical Plan validation strictly read-only.
431
445
 
432
446
  - Acceptance verification names only hypothetical evidence with no runnable descriptor.
433
447
  - New work depends on a prose Plan validator, Step activation, or State Ledger.
434
- - A Brainstorm manifest lacks a complete Spec `Brainstorm Trace`.
448
+ - A Brainstorm manifest lacks complete `BR-*` coverage on the Spec (complex) or TaskIntent (simple).
435
449
  - A Medium/High risk Spec lacks a `Devil's Advocate Audit` covering rollback resilience, verification vanity, and spec dilution detection.
436
450
  - New Spec prose ignores the document-language policy.
437
451
  - Candidate artifacts escape the approved planning scope.
@@ -439,7 +453,7 @@ a State Ledger. Keep historical Plan validation strictly read-only.
439
453
  ## Verification
440
454
 
441
455
  - Validate every candidate through `imm-kernel intent validate <path> --json` after authoring and staging. Require `valid: true` and `enrollment_ready: true` before Enrollment.
442
- - Verify Spec design metadata, document language, reference closure, concrete descriptor paths, and complete Brainstorm traceability before handoff.
456
+ - For complex work, verify Spec design metadata, document language, reference closure, concrete descriptor paths, and complete Brainstorm traceability before handoff. Simple TaskIntent-only work verifies those properties on the Intent.
443
457
  - Enrollment validates descriptor structure only. Deterministic QA owns descriptor execution after implementation; planning does not run the acceptance suite.
444
458
  - Managed execution handoff is Git-tracked TaskIntent author/validate plus current-Host native Enrollment. Do not sync a v3 State Ledger or invoke a missing dispatcher.
445
459
 
@@ -52,8 +52,8 @@ aloud in the report so the 口径 stays visible.
52
52
  other.
53
53
  - `avgSc` / `pass%` parse `[SCORE: …]` and `[VERDICT: …]` tags from the
54
54
  matching Review `toolResult`. Untagged reviews show `-`.
55
- - `registr` counts `imm_kernel_canary` `submit_review`. It is the
56
- registration of the same review and is never added into `reviews`.
55
+ - `registr` counts the Kernel `submit_review` registration in the session log.
56
+ It is the registration of the same review and is never added into `reviews`.
57
57
  - `rounds/task` is registrations per distinct `(cwd, task_id)`. High values
58
58
  can be canary/QA harness re-registration, not human-visible rework.
59
59
  - Findings are `record_finding` calls, deduped per session. Summaries that
@@ -26,6 +26,14 @@ material task-local maintenance risks. Pure naming, length, complexity
26
26
  thresholds, formatting, and design preference are not findings and must not
27
27
  cause style-only rework.
28
28
 
29
+ When a finding repeats an acceptance id or anchor that already produced rework in
30
+ this task, do not file it as a fresh single-trigger defect. Name the invariant
31
+ class it belongs to and state in `evidence.trigger` why the previously accepted
32
+ fix does not cover that class: a second variant of the same trigger is a claim
33
+ about the fix's scope, not a new bug. A trigger the accepted contract explicitly
34
+ excludes is reported as an advisory note against that boundary, never as blocking
35
+ rework.
36
+
29
37
  Return exactly one JSON object with the fields required by the Loop review
30
38
  contract: `contract`, `role`, `task_id`, `snapshot_digest`, `decision` (`pass`
31
39
  or `rework`), and for `pass` include `approval` (`kind`, `authority_role`,
@@ -38,6 +46,8 @@ boundary name). Do not invent fields, and never send an anchor yourself: the
38
46
  Kernel derives it as the sha256 of the canonical `{violated.kind,
39
47
  violated.ref, caller_chain}`, so an identical claim keeps one stable identity
40
48
  across review rounds while a different call chain is a different claim. A
41
- passing review has no findings. If the
49
+ passing review carries no blocking findings; non-blocking notes may ride along as
50
+ `kind: "advisory"` findings, and every finding, advisory included, needs the
51
+ same machine-checkable evidence. If the
42
52
  checkpoint is `awaiting_user_successor_decision`, stop without dispatch; only
43
53
  a literal user may invoke `--approve-successor`.
@@ -1,10 +1,10 @@
1
1
  # Internal role: executor
2
2
 
3
3
  You are the Immune-Brain Executor role inside Loop. Implement exactly the
4
- enrolled TaskIntent acceptance and `scope_hint` (or one accepted
5
- same-boundary follow-up) in the current Parent conversation. Use workspace
6
- tools only for the supplied target and keep every edit inside the
7
- authoritative Scope. Do not discover or load a Pi Skill.
4
+ enrolled TaskIntent acceptance and `scope_hint` envelope (or one accepted
5
+ same-boundary follow-up) in the current Parent conversation. New helpers or
6
+ tests inside an approved directory or glob do not require a revision. Keep
7
+ every edit inside the authorized envelope; do not stage unrelated user files. Do not discover or load a Pi Skill.
8
8
 
9
9
  Before handoff, run the permitted diagnostic checks and return commands and
10
10
  outcomes to the Parent as structured diagnostic evidence. The read-only Loop