immune-brain 4.4.0 → 4.5.0

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 (36) hide show
  1. package/package.json +1 -1
  2. package/plugins/immune-brain/.claude-plugin/plugin.json +1 -1
  3. package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +19 -2
  4. package/plugins/immune-brain/.pi-extension/imm-unattended-batch.ts +10 -2
  5. package/plugins/immune-brain/.pi-extension/pi-canary-tool-failure.ts +6 -1
  6. package/plugins/immune-brain/.pi-extension/runtime-stub.ts +11 -6
  7. package/plugins/immune-brain/dist/BASELINE.md +18 -1
  8. package/plugins/immune-brain/dist/claude/mcp-server.mjs +1039 -465
  9. package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +30 -0
  10. package/plugins/immune-brain/dist/imm-brainstorm.md +21 -0
  11. package/plugins/immune-brain/dist/imm-loop.md +76 -4
  12. package/plugins/immune-brain/dist/imm-planner.md +65 -1
  13. package/plugins/immune-brain/dist/role-prompts/code-review.md +19 -0
  14. package/plugins/immune-brain/dist/role-prompts/executor.md +6 -0
  15. package/plugins/immune-brain/dist/role-prompts/qa.md +13 -1
  16. package/plugins/immune-brain/runtime/assurance/coordinator.ts +160 -12
  17. package/plugins/immune-brain/runtime/assurance/qa.ts +57 -42
  18. package/plugins/immune-brain/runtime/claude/kernel_ports.ts +20 -8
  19. package/plugins/immune-brain/runtime/github_issue_tracker.ts +321 -60
  20. package/plugins/immune-brain/runtime/kernel/storage.ts +8 -3
  21. package/plugins/immune-brain/runtime/plugin_version.ts +1 -1
  22. package/plugins/immune-brain/runtime/prompts/code-review.md +19 -0
  23. package/plugins/immune-brain/runtime/prompts/executor.md +6 -0
  24. package/plugins/immune-brain/runtime/prompts/qa.md +13 -1
  25. package/plugins/immune-brain/runtime/unattended/batch_plan.ts +1 -1
  26. package/plugins/immune-brain/runtime/unattended/batch_preflight.ts +73 -26
  27. package/plugins/immune-brain/runtime/unattended/batch_reasons.ts +6 -0
  28. package/plugins/immune-brain/runtime/unattended/batch_reconfirmation.ts +194 -0
  29. package/plugins/immune-brain/runtime/unattended/batch_runner.ts +126 -151
  30. package/plugins/immune-brain/runtime/unattended/batch_state.ts +34 -4
  31. package/plugins/immune-brain/runtime/v4_runtime.ts +54 -0
  32. package/plugins/immune-brain/runtime/workspace_scope.ts +31 -4
  33. package/plugins/immune-brain/skills/BASELINE.md +18 -1
  34. package/plugins/immune-brain/skills/imm-brainstorm/SKILL.md +5 -0
  35. package/plugins/immune-brain/skills/imm-loop/SKILL.md +4 -2
  36. package/plugins/immune-brain/skills/imm-planner/SKILL.md +10 -1
@@ -4,6 +4,18 @@
4
4
 
5
5
  ## Eligibility
6
6
 
7
+ Before any dispatch, state the bounded question and scope: the question being
8
+ investigated, the named paths the probe may read, the expected evidence, and the
9
+ stop condition that closes the probe. A probe without a stated stop condition is
10
+ an open-ended sweep, not a bounded one.
11
+
12
+ Read known paths directly first. Expand along proved callers, dependencies, and
13
+ state owners only when a concrete missing fact requires it, and stop once the
14
+ question is closed; do not continue reading because a path is nearby. Repository-wide
15
+ listings, unrelated directories, and other projects' session logs are out of
16
+ scope. Project-specific log or history searches stay inside the named project
17
+ paths; do not scan external session directories unless the user explicitly asks.
18
+
7
19
  派发前依次执行:
8
20
 
9
21
  1. 从任务摘要、changed paths 和显式请求分类为 `trivial`、`single_domain`、`multi_domain` 或 `high_risk`。
@@ -13,6 +25,23 @@
13
25
 
14
26
  常用 fallback reason:`cost_scope_mismatch`、`unavailable_environment`、`host_authorization_required`、`trigger_not_hit`、`unclear_boundary`。
15
27
 
28
+ ### Parallel Local Calls And Partial Results
29
+
30
+ Independent local calls may be issued together and their results inspected
31
+ together, `Promise.allSettled`-style, so one failure does not discard the other
32
+ results. Dependent actions stay ordered: an action that needs another's output
33
+ waits for it. Do not use a settled-all barrier for work that has a real sequence
34
+ dependency.
35
+
36
+ When output is truncated, continue in bounded pages only while the material is
37
+ still needed for the question; do not restart the read from the top or expand it
38
+ into a full-file sweep. Before retrying an operation that may have partially
39
+ succeeded, inspect what it already produced: a partial edit or partial write is
40
+ retried only for the part that is actually unfinished, never replayed wholesale.
41
+ Telemetry and tool-call counts are observational; they never justify omitting
42
+ evidence the question still requires, and they are not comparable to another
43
+ session's numbers unless the inputs and environment match.
44
+
16
45
  ## Authorization
17
46
 
18
47
  Canonical project grant:
@@ -103,6 +132,7 @@ Parent workflow role 必须:
103
132
  3. 保留 source lens 和 candidate attribution。
104
133
  4. 把 partial/error 标记为 `degraded`。
105
134
  5. 保留自身 baseline review,不把最终判断权交给 child。
135
+ 6. 报告 partial 结果时说明哪些部分已完成、哪些仍未完成,不把部分结果当作完整结果。
106
136
 
107
137
  普通 advisory/discovery 的每次启动都消耗一个 candidate budget slot;失败、取消、timeout 或 result_untrusted 均丢弃该输出且不得自动重试。Parent 仅在剩余候选仍独立有用且 evidence budget 仍需要时继续,否则转 solo/fail-closed fallback,并记录 `dispatch_failed` 或 `child_timeout`。Read-only eligibility 与 Pi 的 one-foreground-child 调度限制是两回事:只读调查可同时存在多个待派发候选,但实际执行仍逐个 foreground child 串行消费,不得把多个 foreground Agent 假定为并发 batch。该规则不改变 Kernel authority Review 的显式恢复协议。Child 永远不获得实现、Plan write、workflow mutation 或 QA closure authority。
108
138
 
@@ -65,6 +65,24 @@ delta and explain the new evidence. An explicit defer stops its subtree and is
65
65
  recorded as `BR-DEFER-*`; if the subtree still changes the current Result,
66
66
  interface, or compatibility, explain why it cannot be deferred.
67
67
 
68
+ Every sourced branch closes as resolved, explicitly excluded, explicitly
69
+ deferred, or dependent-blocked with its blocking prerequisite named. An excluded
70
+ or deferred branch is a recorded decision, not a silent omission; a
71
+ dependent-blocked branch blocks only its dependent commitment and is reported as
72
+ an open node. Coverage is complete when every sourced branch carries exactly one
73
+ of those four states, and no branch is dropped for being inconvenient, expensive,
74
+ or downstream. Exhaustive-interview mode changes interview breadth, never this
75
+ coverage. A clear zero-question request performs the same coverage check over
76
+ the request, repository evidence, and confirmed parent decisions before it hands
77
+ off.
78
+
79
+ Do not narrow a confirmed outcome into a smaller deliverable. "Do X fully" is
80
+ not satisfied by "do part of X", and a dependency ordering such as "prototype
81
+ first" is not a scope reduction such as "prototype only". A generalized
82
+ integration-to-CLI or prototype-first-to-prototype-only narrowing presented as
83
+ the complete result is a conservation failure; the handoff completeness check
84
+ rejects it instead of accepting the smaller deliverable.
85
+
68
86
  Brainstorm finishes when the material decision frontier is empty and no blocked
69
87
  fact prevents the current handoff. Independent framing may continue while a
70
88
  dependent subtree is blocked. If the user
@@ -97,6 +115,7 @@ empty, or report remaining blocked/open nodes if the user stops early.
97
115
 
98
116
  - **Trigger Shape**: Explicit Brainstorm entry permits proportionate clarification, including a zero-question handoff for a clear request. Read the exhaustive protocol only on an explicit request for thorough interrogation. Do not add a second confirmation for an unchanged final summary.
99
117
  - **Decision Provenance**: Investigate evidenced current-goal uncertainty. A concrete scenario is relevant when the request, repository, or a settled parent decision makes it material; do not invent speculative future needs.
118
+ - **Relevant Coverage**: Traverse every sourced branch — from the user request, repository evidence, or a settled parent decision — to one closing state: resolved, explicitly excluded, explicitly deferred, or dependent-blocked with the blocking node named. Ask only on the currently unblocked frontier, so a dependent-blocked branch stays open instead of being asked early or silently omitted. Coverage is a property of the traversal, not of the question count: a zero-question fast path and a bulk approval close the same branches the exhaustive traversal would.
100
119
  - **Dependency-Aware Rounds**: Ask every independent question on the complete currently unblocked frontier together. Ask fewer questions only because dependencies keep downstream branches blocked, never because of an arbitrary question budget.
101
120
  - **Read-only by default**: Inspect context and summarize the problem. do not implement inside this skill.
102
121
  - **Handoff**: Write concise design notes under `docs/brainstorms/` only if explicitly requested.
@@ -111,6 +130,8 @@ empty, or report remaining blocked/open nodes if the user stops early.
111
130
 
112
131
  Follow [`docs/reference/subagent-dispatch-protocol.md`](docs/reference/subagent-dispatch-protocol.md) for the full dispatch lifecycle. This section defines brainstorm-specific optional research dispatch.
113
132
 
133
+ Before any research path that leaves the repository — an external model or provider call, a fetch of non-project content, or sending project data off-host — check the project's existing research channel and data scope. Documentation, mocks, and local read-only reads are not real-channel evidence, and a public article does not select or authorize a provider. Consume the existing channel; a genuinely new channel or data scope is a material delta that needs its own authorization. Report documentation, mock, real-channel, and model-quality evidence as distinct claims rather than one undifferentiated "verified".
134
+
114
135
  Runtime helpers: `imm_core.buildBrainstormEnsembleRequest`, `imm_core.buildBrainstormEnsembleDispatchEnvelopes`, `imm_core.normalizePiBrainstormAgentResults`, and `imm_core.normalizeBrainstormEnsemblePacket`.
115
136
 
116
137
  ### Brainstorm Ensemble Advisory
@@ -74,8 +74,12 @@ Continue while the current projection has a valid action:
74
74
  4. Follow the returned Kernel obligation. Fresh QA suffices for routine work;
75
75
  material and critical work additionally require fresh independent Review.
76
76
  Normal completion does not require a second user confirmation.
77
- 5. For rework, follow the projected artifact state before editing. Resolve
78
- findings only after fixing and verifying their cause. Changed snapshots
77
+ 5. For rework, follow the projected artifact state before editing. Submit the
78
+ rework verdict first, then edit: staging an in-scope change while the
79
+ artifacts are frozen invalidates the snapshot and discards that verdict,
80
+ forcing a fresh QA round. After the Kernel returns the artifacts to active,
81
+ make the fix, resolve findings only after fixing and verifying their cause,
82
+ then run the newly required obligations. Changed snapshots
79
83
  invalidate old evidence; run the newly required obligations. On the second
80
84
  rework of one acceptance id or anchor, the fix response must either state why
81
85
  it covers every known trigger class of the violated invariant — the shared
@@ -116,6 +120,23 @@ batch state transition: the shared `startBatch` driver in
116
120
  `runtime/unattended/` owns every batch transition, and each child is still
117
121
  enrolled, assured, and settled by the Kernel under an ordinary TaskRecord.
118
122
 
123
+ A successful child Enrollment returns a `running` report with `handoff.role`
124
+ `executor`; the child remains `enrolled`. The Parent implements that TaskIntent
125
+ in the current foreground conversation, stages only its scoped changes, and
126
+ runs focused diagnostics before Kernel Assurance. Re-entering the batch before
127
+ implementation returns the same handoff without QA or another confirmation.
128
+ The runtime owns no model invocation and adds no persisted execution lifecycle.
129
+
130
+ After diagnostics pass, the Parent advances Kernel QA and dispatches any reserved
131
+ foreground Review once using the exact returned `agent_params`, then submits its
132
+ structured verdict. An open Review reservation stays with that Host invocation;
133
+ batch re-entry waits for it rather than redispatching. On Kernel `done`, stage
134
+ only that child's generated terminal audit evidence and call
135
+ `start_unattended_batch` with the same slug. The driver reconciles settlement,
136
+ adopts or creates the one scope-bound commit, then enrolls the next ready child
137
+ under the still-valid authorization. Ordinary Executor handoff and below-limit
138
+ QA repair do not park the batch; genuine budget/authority stops remain fail-closed.
139
+
119
140
  Batch execution never pushes a ref, opens or updates a pull request, resolves a
120
141
  user decision, or creates, switches, or deletes a Git worktree. Its sole Git
121
142
  effect is the batch branch `imm/<initiative-slug>` plus one scope-bounded commit
@@ -123,6 +144,27 @@ per completed child.
123
144
 
124
145
  ## Decisions and Recovery
125
146
 
147
+ - Resume from authority facts, not prose. After an uncertain interruption, bind
148
+ the exact `task_id`, `run_id`, record revision, lifecycle, artifact state,
149
+ obligation, and claim from the Kernel projection before acting. A compaction
150
+ heading, a Handoff summary, an Issue state, or any other prose summary is not
151
+ authority and can be stale or wrong: when it conflicts with the projection,
152
+ correct the prose and resume the existing owner instead of trusting the summary.
153
+ - The workflow stages are distinct and never inferred from one another:
154
+ authored, validated, published, enrolled, assured, and completed each require
155
+ their own evidence. An open or closed Issue is not Enrollment or completion; a
156
+ published Issue is not Enrollment; a plan-only delivery is not execution
157
+ readiness.
158
+ - Consume a successful operation's fresh projection directly. Do not add a
159
+ status read after an operation that already returned the current projection, and
160
+ never repeat a mutation merely to re-observe its result. Kernel CAS and
161
+ freshness checks remain mandatory, and reducing Parent reads does not bypass
162
+ them.
163
+ - A falsely claimed later-Slice enrollment is a summary defect, not authority.
164
+ Retain the actual owner, and do not create or replay a mutation, gate, or
165
+ completion to match the prose. Summary production outside this repository is not
166
+ locally fixed; the consumer-side protection is these rules, and a producer bug
167
+ is recorded as a separate follow-up rather than resolved here.
126
168
  - Scope expansion returns to Planner's Enrolled Intent Revision route. Planner
127
169
  prepares the complete proposed revision without replacing the active owner;
128
170
  the current Loop submits it through Kernel revision authority. Collect all
@@ -130,6 +172,14 @@ per completed child.
130
172
  reasons in one request. Do not edit outside scope while waiting or widen it
131
173
  piecemeal without new evidence. Bounded test or PR repair stays inside the same
132
174
  TaskIntent.
175
+ - Effects are separate grants. A stage-only recovery restores staging and grants
176
+ no commit, push, or publication; an existing exact approval, including a valid
177
+ batch capability bounded to one child, stays usable without another chat gate.
178
+ Before a new outbound research call, check the project's existing channel and
179
+ data scope; a public article, a mock, or a local read-only database authorizes
180
+ no new provider or data effect.
181
+ - Text instructions are contracts, not a hard bash sandbox. They guide and are
182
+ reviewed; the Kernel authority gates remain the real boundary.
133
183
  - Invoke `approve_breaking_intent_revision` with the complete next intent
134
184
  directly; the native Host gate is the single user decision. Do not overwrite
135
185
  enrolled intent sidecars or ask for chat pre-confirmation.
@@ -147,8 +197,24 @@ per completed child.
147
197
  and exactly one same-Host recovery action. Never recommend another Host,
148
198
  worktree, Direct Path, unmanaged implementation, or automatic retry.
149
199
  - After interruption, read a fresh projection and run only the pending obligation.
150
- A committed QA result is honored; an interrupted precommit QA run produces no
151
- approval. Do not rerun fresh QA simply because Review was interrupted.
200
+ `recovery` carries that task/run/record identity, affected acceptance/finding IDs
201
+ and one legal `next_action`; it is an observation, never execution readiness.
202
+ Own-claim technical rework goes to foreground Executor, not user authorization.
203
+ `review_preparation_failed` keeps the batch running/enrolled: repair the Review
204
+ evidence environment and resume `run_review`, retaining fresh QA without batch
205
+ re-confirmation.
206
+ Repair and verify the cause, then dispose each identified finding explicitly by
207
+ `resolve_finding` or evidence-bound `refute_finding`. Local green cannot close
208
+ findings or settle the task; obtain fresh Kernel QA and required Review.
209
+ Environment preparation/resolution/integrity failure is not an assertion finding.
210
+ Use its canonical descriptor reference/digest, phase/outcome, timing and byte
211
+ counts to diagnose; QA diagnostic metadata is capped at 16 KiB and contains no
212
+ stdout/stderr, argv, environment values or arbitrary executor error text.
213
+ A frozen child with `run_qa` pending returns to Parent; batch re-entry does not
214
+ blindly retry an unchanged failure. Fix the environment before a fresh attempt.
215
+ Scope/authority exceptions still use their existing native gates. A committed
216
+ QA result is honored; an interrupted precommit QA run produces no approval.
217
+ Do not rerun fresh QA simply because Review was interrupted.
152
218
  - Malformed or stale reviewer output is not a verdict. Keep the existing
153
219
  reservation only if the Host reports it valid; use its exact recovery action.
154
220
  Do not fabricate a pass or blindly redispatch Review.
@@ -207,6 +273,12 @@ Stop reason:
207
273
  Next action:
208
274
  ```
209
275
 
276
+ Every line reports authority evidence, not prose inference: name the exact
277
+ task/run identity and the observed lifecycle, artifact, obligation, and claim
278
+ facts that decided the exit. If a summary claimed more than the projection
279
+ proves — for example a later Slice as enrolled or the task as completed — report
280
+ the projection instead and correct the prose.
281
+
210
282
  ## Failure Output
211
283
 
212
284
  For `settlement_unknown`, call `advance_assurance` once to reconcile the Kernel
@@ -49,6 +49,25 @@ decisions. Resolve a local delta here. If the answer reopens multiple product
49
49
  branches or changes the overall goal or Scope, stop and return to
50
50
  `imm-brainstorm`.
51
51
 
52
+ Before handoff, run one handoff completeness check over the closed-world
53
+ manifest: map every upstream item and every required phase exactly once, report
54
+ each Slice's closable result plus the remaining gap, and confirm the complete
55
+ confirmed outcome and its phases are actually delivered. Upstream items close as
56
+ covered, decisioned, deferred, or out with a reason; a required phase is the
57
+ confirmed outcome itself, so it must be delivered rather than closed out with a
58
+ reason. A reason excuses an upstream item, never a still-required phase: dropping
59
+ one is exactly the silent narrowing this check exists to catch, and the genuine
60
+ reduction is a user decision that returns to `imm-brainstorm` and changes what
61
+ was required. The check fails, and the candidate is not handoff-ready, when a
62
+ required phase or upstream item has no mapping, or when the plan conserves a
63
+ smaller deliverable than the confirmed outcome. An outcome-narrowing
64
+ substitution is such a failure: a confirmed full integration presented as one
65
+ pairwise CLI, or a `prototype first` dependency presented as `prototype only`.
66
+ Both are conservation failures, not scope decisions, and the checker rejects
67
+ them instead of accepting the reduced deliverable. Coverage is independent of
68
+ question count, so a clear request and an already-confirmed decision still pass
69
+ the same check without acquiring an extra confirmation.
70
+
52
71
  Direct Planner entry remains valid for a clear request and does not require a
53
72
  Brainstorm pass. Resolve facts and derive technical design; if an unresolved
54
73
  user-owned product decision appears, return to `imm-brainstorm` rather than
@@ -327,9 +346,36 @@ before execution. Report `valid` and `enrollment_ready` only as structural and
327
346
  Enrollment readiness; only a completed deterministic QA result proves that a
328
347
  descriptor executed and passed.
329
348
 
349
+ **Acceptance-to-invariant mapping.** Trace each acceptance assertion to an
350
+ observable invariant at a real seam, then name the positive, negative, and bound
351
+ controls that exercise it. Name the controls explicitly instead of relying on
352
+ the happy path: a happy path alone never proves a guard. The six generalized
353
+ motivating classes to check for are: normalization precedes retrieval (an input
354
+ is normalized before it is used to retrieve); validation precedes merge (a
355
+ rejected input never enters the merged state); the deadline covers the whole
356
+ lifecycle including cleanup; ranking tolerates missing embeddings (an absent
357
+ signal is ranked, not silently skipped); the budget covers the complete
358
+ serialized request; and each success, failure, and timeout outcome carries its
359
+ own duration evidence. These are workflow-quality input patterns, not requests
360
+ to edit the original applications that motivated the audit.
361
+
362
+ **Environment and prerequisite discipline.** A descriptor that needs a
363
+ prerequisite states its provenance and how it is obtained. Preparation must not
364
+ hide a download, credential use, production write, or system change: authorize
365
+ it explicitly, or redesign the check to avoid it. Require cleanup on failure and
366
+ interruption, and restoration of any explicitly authorized setting. An absent
367
+ dependency, a missing simulator, or a preparation failure is a failed check, not
368
+ a pass. Zero matched checks and skipped required checks are failures: a required
369
+ check that selects no test, or that is skipped, must fail the acceptance rather
370
+ than silently succeed. Separate automated behavioral or geometry evidence from
371
+ human judgment of motion quality; a descriptor can assert only the automated
372
+ half. Textual presence in a contract string is not proof that a provider obeyed
373
+ it, and structural Enrollment readiness is not proof that a descriptor executed.
374
+
330
375
  ## Core Responsibilities
331
376
 
332
377
  - **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.
378
+ - **Outcome Conservation**: The plan conserves the complete confirmed outcome and its required phases. A required phase is delivered, not closed out with a reason; a genuine reduction changes what the user confirmed and returns to `imm-brainstorm`. A generalized substitution such as full integration becoming a pairwise CLI, or `prototype first` becoming `prototype only`, is a completeness-check failure rather than a valid plan. Each Slice reports its closable result and the remaining gap so an omitted phase is visible instead of implied.
333
379
  - **Outcome Focus**: Each TaskIntent owns one independently verifiable outcome. Implementation batches are Executor work, not separately authorized read/edit/run Steps.
334
380
  - **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.
335
381
  - **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.
@@ -340,7 +386,7 @@ descriptor executed and passed.
340
386
  - **Technical Design Authority**: The Spec is the single Technical Design baseline. TaskIntent acceptance and scope reference the applicable design decisions or invariants without copying Technical Design prose. If discovery invalidates the baseline, stop execution and return to Planner to update the Spec and decide whether `replan` is required. TaskIntent and Initiative text do not duplicate Technical Design prose or become a prose Plan substitute.
341
387
  - **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.
342
388
  - **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.
343
- - **Verification**: Every acceptance assertion has a concrete focused descriptor that can fail on the intended regression. Hypothetical evidence is not execution-ready.
389
+ - **Verification**: Every acceptance assertion has a concrete focused descriptor that can fail on the intended regression, and every named invariant has positive, negative, and bound controls at an observable seam. Hypothetical evidence is not execution-ready; a check that matches zero tests, is skipped, or lacks its prerequisite is a failure rather than a pass.
344
390
  - **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.
345
391
  - **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.
346
392
  - **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.
@@ -433,11 +479,23 @@ preparation does not apply the revision or authorize expanded execution.
433
479
  verification descriptors or add a mandatory user confirmation.
434
480
  - **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.
435
481
  - **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.
482
+ - **Handoff Completeness Check**: Before reporting a candidate as handoff-ready, confirm every upstream item and required phase is mapped exactly once, that required phases are delivered rather than excused by a reason, and that no confirmed outcome was conserved as a smaller deliverable. Reject a narrowed deliverable as a completeness failure; ask again only for a new material delta, never to reconfirm an unchanged clear request or an already-confirmed decision.
436
483
  - **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.
437
484
  - **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.
438
485
  - **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.
439
486
  - **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.
440
487
  - **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.
488
+
489
+ **Bounded discovery.** State the question, the named paths, the expected evidence,
490
+ and the stop condition before an investigation expands. Read known paths directly,
491
+ expand only along proved callers and state owners, and stop once the question is
492
+ closed instead of continuing into nearby unrelated paths. Keep project-specific
493
+ log or history searches inside the named project paths. Reads or investigation
494
+ output that is truncated continue in bounded pages only while still needed, and an
495
+ operation that may have partially succeeded is inspected before it is retried for
496
+ only its unfinished part. Telemetry and tool-call counts are observational: they
497
+ never justify dropping evidence the question requires, and they are not comparable
498
+ to another session's numbers unless the inputs and environment match.
441
499
  - **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.
442
500
  - **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.
443
501
 
@@ -445,6 +503,8 @@ preparation does not apply the revision or authorize expanded execution.
445
503
 
446
504
  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.
447
505
 
506
+ A discovery path that leaves the repository — an external model/provider call or sending project data off-host — first checks the project's existing research channel and data scope. Architecture exploration and local reads stay on the existing channel; a new channel or data scope is a material delta with its own authorization, and documentation, mock, or local read-only evidence never substitutes for real-channel evidence.
507
+
448
508
  Use the invoking Host's read-only role-boundary route for bounded
449
509
  `arch-explorer` and explicit-lens `advisory-reviewer` routing. Invoke the returned foreground Agent envelope
450
510
  exactly. The Parent owns Spec/TaskIntent synthesis, Brainstorm traceability,
@@ -492,14 +552,18 @@ a State Ledger. Keep historical Plan validation strictly read-only.
492
552
  | Split one outcome into read/edit/run micro-steps | One TaskIntent owns one closable outcome; Executor owns implementation batches. |
493
553
  | Append repair outside scope | Return the complete known scope delta for Kernel revision; do not widen execution. |
494
554
  | Drop a brainstorm-confirmed item as "out of scope" without saying so | Closed-world handoff: every `BR-*` ID must be covered, decisioned, deferred, scoped out with reason, or resolved as an assumption. |
555
+ | Conserve a narrower deliverable than the confirmed outcome | **Conservation failure**: a full integration is not a pairwise CLI and `prototype first` is not `prototype only`; the handoff completeness check rejects the reduced deliverable instead of accepting a reason for it. |
495
556
  | Finalize dependent planning while brainstorm questions are open | **Clarification Barrier**: Finalization and dependent commitments are blocked until required `BR-Q-*` items are answered. Independent investigation and explicitly unapproved alternative drafts may continue; silence is not consent. |
496
557
  | Skip adversarial self-review on Medium/High risk because the plan is small | **Devil's Advocate** audit still checks rollback resilience, verification vanity, and spec dilution before the plan is treated as execution-ready. |
497
558
 
498
559
  ## Red Flags
499
560
 
500
561
  - Acceptance verification names only hypothetical evidence with no runnable descriptor.
562
+ - An acceptance descriptor names no negative or bound control for its invariant, or its required prerequisite (dependency, simulator, preparation) is absent and still counted as a pass.
563
+ - A required check matches zero tests or is skipped and the run is reported as passing.
501
564
  - New work depends on a prose Plan validator, Step activation, or State Ledger.
502
565
  - A Brainstorm manifest lacks complete `BR-*` coverage on the Spec (complex) or TaskIntent (simple).
566
+ - The handoff completeness check passed while a required phase or upstream item is unmapped, or while the plan delivers only part of the confirmed outcome.
503
567
  - A Medium/High risk Spec lacks a `Devil's Advocate Audit` covering rollback resilience, verification vanity, and spec dilution detection.
504
568
  - New Spec prose ignores the document-language policy.
505
569
  - Candidate artifacts escape the approved planning scope.
@@ -34,6 +34,25 @@ about the fix's scope, not a new bug. A trigger the accepted contract explicitly
34
34
  excludes is reported as an advisory note against that boundary, never as blocking
35
35
  rework.
36
36
 
37
+ ## Invariant and Evidence Coverage
38
+
39
+ Judge whether the change actually closes the invariant its acceptance names,
40
+ not only the path the report mentions. A fix that covers one trigger but leaves
41
+ another trigger of the same invariant is a coverage gap in the same class, not a
42
+ new independent bug: say so and name the class. Check the negative and bound
43
+ behavior, not only the happy path. The six generalized classes worth checking
44
+ are: normalization precedes retrieval, validation precedes merge, the deadline
45
+ covers the whole lifecycle including cleanup, ranking tolerates missing
46
+ embeddings, the budget covers the complete serialized request, and each success,
47
+ failure, and timeout outcome carries its own duration evidence.
48
+
49
+ A required check that is skipped, that matches zero tests, or whose prerequisite
50
+ is absent does not prove the acceptance; do not accept it as evidence. Full
51
+ suite coverage reported at a coarse pass count is not per-invariant evidence.
52
+ Environment, preparation, and cleanup breakdowns are environment findings, not
53
+ assertion findings. Keep automated behavioral or geometry evidence separated
54
+ from a human quality judgment.
55
+
37
56
  Return exactly one JSON object with the fields required by the Loop review
38
57
  contract: `contract`, `role`, `task_id`, `snapshot_digest`, `decision` (`pass`
39
58
  or `rework`), and for `pass` include `approval` (`kind`, `authority_role`,
@@ -6,6 +6,12 @@ same-boundary follow-up) in the current Parent conversation. New helpers or
6
6
  tests inside an approved directory or glob do not require a revision. Keep
7
7
  every edit inside the authorized envelope; do not stage unrelated user files. Do not discover or load a Pi Skill.
8
8
 
9
+ On a batch `handoff.role=executor`, implement only its named enrolled child;
10
+ the batch stays `running` with that child `enrolled`. Return to the Parent after
11
+ scoped implementation, staging and focused diagnostics. Enrollment itself does
12
+ not start QA; the Parent owns the subsequent Kernel Assurance and foreground
13
+ Review handoff under the same still-valid batch authorization.
14
+
9
15
  Before handoff, run the permitted diagnostic checks and return commands and
10
16
  outcomes to the Parent as structured diagnostic evidence. The read-only Loop
11
17
  runtime action only constructs the dispatch envelope; it does not store
@@ -20,4 +20,16 @@ Plan remains a literal-user decision.
20
20
  For elevated-risk work, check the latest referenced Spec's Design Conformance
21
21
  against implementation evidence. A local implementation mismatch is `rework`;
22
22
  return `rework` with bounded repair evidence. A structural or intended design
23
- change is `replan`; return `replan` with the missing design fact. QA must not approve a changed design or silently accept a deviation. If the checkpoint is `awaiting_user_successor_decision`, stop without dispatch; only a literal user may invoke `--approve-successor`.
23
+ change is `replan`; return `replan` with the missing design fact. QA must not approve a changed design or silently accept a deviation.
24
+
25
+ Judge the recorded execution evidence, not the descriptor text. A required check
26
+ proves an acceptance invariant only when it actually executed and passed: an
27
+ absent dependency, a prerequisite preparation failure, a skipped required check,
28
+ or a check that matched zero tests is a failure, not a pass. Structural
29
+ "Enrollment ready" or "descriptor valid" is not execution evidence, and a
30
+ contract string proves nothing about provider behavior. Automated behavioral or
31
+ geometry evidence cannot stand in for a human motion-quality judgment, and vice
32
+ versa; keep the two claims separate. Environment, preparation, and cleanup
33
+ breakdowns are environment findings, not assertion findings: report them with
34
+ the descriptor reference and observed outcome rather than as a code defect.
35
+ If the checkpoint is `awaiting_user_successor_decision`, stop without dispatch; only a literal user may invoke `--approve-successor`.