immune-brain 3.6.5 → 3.6.6

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 (31) hide show
  1. package/README.md +45 -0
  2. package/package.json +1 -1
  3. package/plugins/immune-brain/.claude-plugin/plugin.json +1 -1
  4. package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +31 -2
  5. package/plugins/immune-brain/.pi-extension/pi-canary-interaction.ts +38 -10
  6. package/plugins/immune-brain/dist/BASELINE.md +48 -15
  7. package/plugins/immune-brain/dist/claude/mcp-server.mjs +20 -10
  8. package/plugins/immune-brain/dist/docs/reference/planning-quality-gate.md +1 -1
  9. package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +1 -1
  10. package/plugins/immune-brain/dist/imm-agent-doc-maintain.md +9 -1
  11. package/plugins/immune-brain/dist/imm-brainstorm.md +49 -35
  12. package/plugins/immune-brain/dist/imm-doc-prune.md +7 -1
  13. package/plugins/immune-brain/dist/imm-loop.md +23 -11
  14. package/plugins/immune-brain/dist/imm-planner.md +65 -28
  15. package/plugins/immune-brain/dist/imm-pr-fix.md +6 -2
  16. package/plugins/immune-brain/dist/role-prompts/executor.md +18 -10
  17. package/plugins/immune-brain/dist/role-prompts/pr-fix.md +5 -2
  18. package/plugins/immune-brain/runtime/assurance/verification.ts +13 -2
  19. package/plugins/immune-brain/runtime/github_issue_tracker.ts +1018 -17
  20. package/plugins/immune-brain/runtime/kernel/canary_application.ts +7 -1
  21. package/plugins/immune-brain/runtime/kernel/reducer.ts +3 -1
  22. package/plugins/immune-brain/runtime/plugin_version.ts +1 -1
  23. package/plugins/immune-brain/runtime/prompts/executor.md +18 -10
  24. package/plugins/immune-brain/runtime/prompts/pr-fix.md +5 -2
  25. package/plugins/immune-brain/skills/BASELINE.md +48 -15
  26. package/plugins/immune-brain/skills/imm-agent-doc-maintain/SKILL.md +20 -4
  27. package/plugins/immune-brain/skills/imm-brainstorm/SKILL.md +24 -64
  28. package/plugins/immune-brain/skills/imm-doc-prune/SKILL.md +18 -3
  29. package/plugins/immune-brain/skills/imm-loop/SKILL.md +20 -6
  30. package/plugins/immune-brain/skills/imm-planner/SKILL.md +35 -8
  31. package/plugins/immune-brain/skills/imm-pr-fix/SKILL.md +17 -3
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: imm-doc-prune
3
- description: Use to prune stale current documentation from a Git repository after an explicit, hash-bound, user-approved manifest; never deletes Managed authority artifacts.
3
+ description: Use when the user explicitly requests Immune-Brain pruning of stale current documentation.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: Doc Prune
@@ -36,6 +36,8 @@ no persistent report, and no automatic commit.
36
36
 
37
37
  ## Ordered Pruning Protocol
38
38
 
39
+ ### Inventory and Manifest
40
+
39
41
  1. **Establish repository safety.** Mutation requires a Git worktree. A
40
42
  non-Git repository or an untracked candidate is audit-only. Record the
41
43
  candidate path, blob/content hash, tracked status, and candidate-local
@@ -91,6 +93,8 @@ no persistent report, and no automatic commit.
91
93
  "clean stale docs" is insufficient. Interruption starts a fresh scan; no
92
94
  manifest is persisted.
93
95
 
96
+ ### Approved Mutation
97
+
94
98
  9. **Revalidate and mutate minimally.** Re-read candidate bytes, Git status,
95
99
  inbound references, generated ownership, and active scope immediately
96
100
  before each approved change. Drift blocks that item. Delete a whole file
@@ -99,6 +103,8 @@ no persistent report, and no automatic commit.
99
103
  owner before deleting the obsolete source. Never renumber ADRs and never
100
104
  create a new ADR or Solution merely to complete pruning.
101
105
 
106
+ ### Verify and Report
107
+
102
108
  10. **Verify and report.** Re-scan residual names and paths, current local
103
109
  links on current documentation, source/generated parity, existing documentation contract tests,
104
110
  and `git diff --check`. This Skill does not execute arbitrary documented
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: imm-loop
3
- description: Use to run an enrolled TaskIntent to completion through Kernel-governed execution, QA, and Review.
3
+ description: Use when the user explicitly requests execution or resumption of an Immune-Brain task.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: Loop
@@ -16,7 +16,12 @@ claim, TaskIntent, and TaskRecord. Invalid or contradictory projections fail
16
16
  closed. A candidate TaskIntent is not Enrollment authority.
17
17
 
18
18
  Before the first Enrollment of a candidate TaskIntent, confirm the Planner
19
- returned `tracker_associated` for its Initiative. `tracker_projection_failed` or
19
+ returned `tracker_associated` but only when the candidate belongs to an
20
+ identified GitHub-carried Initiative. Standalone TaskIntents and Local
21
+ Initiatives carry no tracker prerequisite: their Enrollment needs only the
22
+ validated candidate. When membership is uncertain, resolve it against the
23
+ Planner's carrier decision before treating the candidate as exempt; do not
24
+ assume either way. For a GitHub-carried Initiative, `tracker_projection_failed` or
20
25
  `awaiting_user_initiative_confirmation` blocks that Enrollment until the same
21
26
  complete carrier batch succeeds; report the stable carrier reason and its exact
22
27
  retry action instead of enrolling. A carrier command the Host refused, cancelled,
@@ -36,7 +41,7 @@ At every internal role boundary call the read-only `imm_loop_action` Tool. Use
36
41
  exploration, advisory review, Compounder, Kernel ownership, or scope expansion.
37
42
  Use Kernel ownership for an enrolled task. This Tool projects authority; it does
38
43
  not record execution evidence, mutate task state, or replace Kernel operations.
39
- Follow the [Subagent Dispatch Protocol](docs/reference/subagent-dispatch-protocol.md#authorization-authority).
44
+ Before a child dispatch, read the [Subagent Dispatch Protocol](docs/reference/subagent-dispatch-protocol.md#authorization-authority).
40
45
  Never load an internal role as a public Skill or spawn another loop process.
41
46
  The standalone `imm-pr-fix`, `imm-doc-prune`, and `imm-agent-doc-maintain` are host-native
42
47
  maintenance entries, never dispatched as the Loop role. Internal `test-fixer`
@@ -65,8 +70,12 @@ Continue while the current projection has a valid action:
65
70
  6. For rework, follow the projected artifact state before editing. Resolve
66
71
  findings only after fixing and verifying their cause. Changed snapshots
67
72
  invalidate old evidence; freeze and run the newly required obligations.
68
- 7. Stop on terminal `done` or `stopped`, unresolved user decisions, explicit
69
- cancellation, or a failure without a safe projected action.
73
+ 7. An unresolved decision pauses only dependent execution. On `awaiting_user`,
74
+ invoke `request_authorization` directly before ending the turn; use the
75
+ Decisions and Recovery route for its native-gate handling. End the turn if
76
+ the decision remains unresolved, is cancelled, or the gate fails. Otherwise
77
+ continue from the returned projection. Stop on terminal `done` or `stopped`,
78
+ explicit cancellation, or a failure without a safe projected action.
70
79
 
71
80
  Use the fresh projection returned by a successful operation when supplied. Read
72
81
  `status` after interruption, ambiguous mutation results, absent projections, or
@@ -76,10 +85,13 @@ not bypass them. Do not poll or create detached jobs.
76
85
 
77
86
  ## Decisions and Recovery
78
87
 
79
- - Scope expansion always returns to `imm-planner`. Collect all currently known missing
80
- paths, caller/test/generated mirrors, and verification reasons in one request.
81
- Do not edit outside scope while waiting or widen it piecemeal without new
82
- evidence. Bounded test or PR repair stays inside the same TaskIntent.
88
+ - Scope expansion returns to Planner's Enrolled Intent Revision route. Planner
89
+ prepares the complete proposed revision without replacing the active owner;
90
+ the current Loop submits it through Kernel revision authority. Collect all
91
+ currently known missing paths, caller/test/generated mirrors, and verification
92
+ reasons in one request. Do not edit outside scope while waiting or widen it
93
+ piecemeal without new evidence. Bounded test or PR repair stays inside the same
94
+ TaskIntent.
83
95
  - Invoke `approve_breaking_intent_revision` with the complete next intent
84
96
  directly; the native Host gate is the single user decision. Do not overwrite
85
97
  enrolled intent sidecars or ask for chat pre-confirmation.
@@ -123,8 +135,6 @@ The internal Compounder is optional: only closed work with structured evidence
123
135
  of a reusable Learning may route to it. Routine completion creates no Learning.
124
136
  It cannot approve successors or delay terminal settlement. A projection with
125
137
  `recommended_authority: user` must not dispatch successor work automatically.
126
- Do not create, switch,
127
- or delete Git worktrees; operate only in the Host launch directory.
128
138
 
129
139
  The Host may attach an opted-in GitHub projection after settlement. Only a fresh claimless
130
140
  `done`/`stopped` projection plus its exact terminal tombstone projects
@@ -151,6 +161,8 @@ Stop reason:
151
161
  Next action:
152
162
  ```
153
163
 
164
+ ## Failure Output
165
+
154
166
  For `settlement_unknown`, call `advance_assurance` once to reconcile the Kernel
155
167
  projection before resuming; never replay the uncertain write directly. The runtime
156
168
  retries only explicit `EINTR`/`EAGAIN` failures of its initial projection read, once,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: imm-planner
3
- description: Use to create or revise a spec and TaskIntent from requirements; owns scope and decomposition, not implementation or Enrollment.
3
+ description: Use when the user explicitly requests Immune-Brain Spec and TaskIntent planning.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: Planner
@@ -16,8 +16,8 @@ an explicit `imm-loop` entry; explicit Planner entry owns planning and the later
16
16
  native Enrollment gate.
17
17
 
18
18
  Plan-only output remains non-authoritative. Planner creates or validates a
19
- candidate Spec/TaskIntent, but it never enrolls a task or enrolls generated
20
- artifacts unconditionally. Explicit Plan-only requests stop after returning the
19
+ candidate Spec/TaskIntent. Planner may request the native Enrollment gate;
20
+ only that gate grants execution authority. Explicit Plan-only requests stop after returning the
21
21
  planning artifacts. A later literal-user request to start Enrollment is a
22
22
  non-authoritative execution trigger: invoke the native Enrollment gate directly,
23
23
  without asking for chat pre-confirmation. For a clear mutation request that
@@ -32,9 +32,10 @@ cannot bypass that boundary, QA, Review, authorization, or completion.
32
32
  ## Clarification supplement
33
33
 
34
34
  Planner consumes an upstream Brainstorm manifest as closed-world framing and
35
- must not repeat, reopen, or rewrite confirmed decisions. Direct Planner entry
36
- and Medium/High Design Risk work must inspect relevant ADRs and rejected
37
- Learnings. It resolves repository facts, performs reference closure, and owns
35
+ must not repeat, reopen, or rewrite confirmed decisions. Consult relevant ADRs
36
+ and rejected Learnings only when an architectural decision, known historical
37
+ constraint, or conflict with the existing design makes them relevant. Reuse
38
+ upstream evidence; absent relevant history is not a planning blocker. It resolves repository facts, performs reference closure, and owns
38
39
  ordinary technical choices:
39
40
  component boundaries, internal interfaces, failure behavior, compatibility,
40
41
  migration, recovery and rollback, Verification, execution slices, dependencies,
@@ -71,15 +72,16 @@ resolved wrapper and use the resolved `imm-kernel` wrapper for every Kernel
71
72
  command below. Do not assume either bare command is available on shell `PATH`.
72
73
  Then route deterministically:
73
74
 
74
- - an active Kernel claim routes to `imm-loop` for foreground Kernel Tool
75
- coordination, not new planning;
75
+ - an active Kernel claim remains with `imm-loop` for foreground Kernel Tool
76
+ coordination, except a Loop-requested revision follows Enrolled Intent Revision
77
+ below to prepare a non-authoritative proposal for that same owner;
76
78
  - an active or otherwise nonterminal v3 Plan remains on its existing v3 route;
77
79
  - no routing policy preserves the legacy v3 Planner behavior;
78
80
  - a valid `kernel_task_intent` retirement policy produces one TaskIntent draft
79
81
  through the current Host's explicit `imm-planner`;
80
82
  - an invalid, unreadable, untracked, or tracked-deleted policy rejects new
81
83
  planning authority with `routing_policy_invalid`;
82
- - no Planner path enrolls a task or falls back to v3 after retirement.
84
+ - no Planner path grants execution authority or falls back to v3 after retirement.
83
85
 
84
86
  Current owner, phase, completion, and authority facts are authoritative only
85
87
  when read from the Assurance projection and TaskRecord. `CONTEXT.md` is
@@ -105,6 +107,11 @@ workspace claim, and final authority preconditions without executing acceptance
105
107
  descriptors. A routine task proceeds from that single confirmation through
106
108
  enrollment, execution and QA without a second human stop.
107
109
 
110
+ ## Candidate Authoring
111
+
112
+ Read this section before creating new candidate artifacts, after request routing
113
+ and clarification. It does not apply to Enrolled Intent Revision.
114
+
108
115
  Before authoring a TaskIntent, trace each expected behavior from its public or
109
116
  runtime entry point through existing imports and callers to the highest focused
110
117
  behavioral tests. Include generated or packaged mirrors and every owner of the
@@ -212,6 +219,19 @@ TaskIntent or TaskRecord. Existing Issue markers grant permission only for
212
219
  idempotent retry of that same approved Initiative; they never grant execution
213
220
  authority.
214
221
 
222
+ For amending an already-published Initiative, the same
223
+ `imm-tracker publish-initiative --stdin --json` operation accepts an optional
224
+ `amendment` input after the literal user approves the changed pending frontier.
225
+ Provide the complete approved pending Tasks plus the complete read-only
226
+ historical Child list, each binding the observed `issue_number`, title, body,
227
+ and state at approval. The tracker verifies every bound Issue against that
228
+ baseline before any write, updates only approved pending briefs, converges the
229
+ exact approved pending `blocked_by` set, creates newly added pending Children,
230
+ and preserves historical Children byte-for-byte with their native Sub-issue
231
+ links and dependency relations. Omitted membership, baseline drift, or a
232
+ stopped historical prerequisite fails closed with zero or bounded mutations
233
+ and an exact retry action; the strict no-amendment default is unchanged.
234
+
215
235
  ### Verification Descriptor Discipline
216
236
 
217
237
  Every acceptance verification descriptor must be a focused, deterministic,
@@ -237,10 +257,10 @@ descriptors or add a mandatory user confirmation. Use the smallest `timeout_ms`
237
257
  - **Design-view selection**: For Medium and High risk, select every materially relevant technical-design view from architecture layers, service/component interfaces, data flow, state transitions, and temporal sequence. Record a short `Design views` statement naming the selected views and why any omitted view cannot affect the design. Do not write empty architecture, interface, data-flow, state, or sequence sections. Low risk remains concise and may omit Technical Design. When a selected view is recorded, also record its required decision content: architecture layers need layer responsibilities, dependency direction, ownership, and prohibited coupling; service/component interfaces need inputs, outputs, errors, compatibility/versioning, and caller/callee ownership; data flow needs source, transformations, validation, destination, and failure handling; state transitions need states, legal transitions, trigger, invariant, terminal ownership, and recovery; temporal sequence needs ordered interactions, authority at each point, interruption behavior, and idempotency.
238
258
  - **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.
239
259
  - **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.
240
- - **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. Every new or revised Spec records `**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.
260
+ - **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.
241
261
  - **Verification**: Every acceptance assertion has a concrete focused descriptor that can fail on the intended regression. Hypothetical evidence is not execution-ready.
242
262
  - **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.
243
- - **Devil's Advocate Preplan Audit**: Record 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.
263
+ - **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.
244
264
  - **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.
245
265
 
246
266
  ## Settlement-Design Contract
@@ -294,21 +314,36 @@ state coverage, and verification cues for desktop and mobile. Use `Standard` or
294
314
  The mode produces an
295
315
  implementation-ready contract and routes it to normal planning or execution.
296
316
 
317
+ ## Enrolled Intent Revision
318
+
319
+ Use this route instead of new-task planning when the current Loop requests a
320
+ scope or acceptance revision. Planner prepares the complete proposed revision
321
+ from the requested delta and concrete evidence without replacing the active
322
+ owner. Keep unaffected decisions; include all known scope, Spec, and acceptance
323
+ changes in the proposal. Preserve the prior on-disk sidecars until Kernel applies
324
+ the revision; do not overwrite the enrolled TaskIntent, invoke the new-intent
325
+ author command, or request a second Enrollment.
326
+
327
+ Return the proposal to the current Loop owner for Kernel `revise_intent` or,
328
+ when breaking, `approve_breaking_intent_revision` with the complete next intent.
329
+ The native gate is the single user decision for a breaking revision; candidate
330
+ preparation does not apply the revision or authorize expanded execution.
331
+
297
332
  ## Planning Rules
298
333
 
299
334
  - **Entry Contract**: Use when Spec/TaskIntent planning is needed. An already enrolled owner remains on its current Kernel authority and resumes only through explicit `imm-loop`; a validated candidate still needs native Enrollment.
300
335
  - **Output Language Gate**: Before writing or revising any Spec or Plan, read the project output language policy from `AGENTS.md`, `IMMUNE.md`, or Immune-Brain plugin config. Default Spec and Plan prose to English unless the current user request, project instructions, or host/user preference contains an explicit document-language instruction. A reply-language instruction does not change document language. Keep schema fields, CLI commands, file paths, code identifiers, enum values, JSON keys, and canonical terms such as `Step`, `Plan`, `Spec`, `Verification`, `Discovery cache`, and `Devil's Advocate Audit` literal.
301
336
  - **Clarification Supplement**: If an upstream `imm-brainstorm` manifest exists, verify that every `BR-Q-*` item is resolved and every confirmed framing decision is represented; must not repeat, reopen, or rewrite confirmed decisions. Ask only a focused omission, repository-conflict, or invalidated-assumption delta tied to concrete evidence. Resolve a local delta here; return to `imm-brainstorm` when it reopens multiple product branches or changes the overall goal or Scope. Finalization requires no unresolved supplement and no unconfirmed decision introduced by Planner.
302
337
  - **Planning Bootstrap**: When no upstream `imm-brainstorm` manifest exists, preserve Direct Planner entry by resolving repository facts and deriving ordinary technical choices. An already-clear request takes the zero-question fast path to a non-blocking correction summary. Discovery of an unresolved user-owned goal, user, scope, behavior, compatibility preference, risk acceptance, or success criterion returns to `imm-brainstorm`; Planner does not convert product uncertainty into a silent assumption or duplicate Brainstorm's interview.
303
- - **Small-scope budget discipline**: For small or fixture-sized planning tasks,
304
- read the named files and root orientation files first (`README.md`,
305
- `CONTEXT.md`, `IMMUNE.md`, `HANDOFF.md`, active tests/docs). Avoid broad
306
- `rg --files`, plugin `skills/`, plugin `dist/`, generated logs, and
307
- unrelated directories until a specific missing fact blocks plan validation.
308
- - **Decision History Discovery**: Direct Planner entry and Medium/High Design
309
- Risk work must inspect relevant ADRs and rejected Learnings. Reuse constraints
310
- already covered by an upstream Brainstorm manifest instead of repeating that
311
- discovery.
338
+ - **Small-scope budget discipline**: Read the named files first for small or
339
+ fixture-sized planning tasks. Read relevant orientation documents and follow
340
+ caller, test, or generated-reference links when a concrete missing fact requires
341
+ them; root documents are not a fixed preflight checklist. Before broad searching,
342
+ consult `CONTEXT.md`'s Architecture Map. Avoid repository-wide listings and
343
+ unrelated directories when targeted evidence resolves the task. Required
344
+ authority, security, and shared-contract reference closure still applies.
345
+ - **Decision History Discovery**: Apply Clarification supplement's conditional
346
+ history lookup; reuse upstream evidence rather than repeating discovery.
312
347
  - **Testing Seam Selection**: Prefer the highest existing observable behavioral
313
348
  test seam and the fewest sufficient seams. Cite relevant test prior art and
314
349
  explain how the selected seam catches the intended regression. This is a
@@ -317,10 +352,10 @@ implementation-ready contract and routes it to normal planning or execution.
317
352
  - **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.
318
353
  - **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.
319
354
  - **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.
320
- - **Subagents**: Follow the Adaptive Cache-First Route in `docs/reference/subagent-dispatch-protocol.md`: classify the task, use cache-first discovery evidence, and add subagent participation only when the Cost-Based Subagent Gate says the slice is multi-domain, high-risk, explicitly requested, or has concrete `parallel_probes`. Plan conditional reviewers such as `security-reviewer` only if their trigger surfaces are explicit; do not manufacture them.
321
- - **Enrolled Intent**: Planner never overwrites an enrolled TaskIntent. Scope or acceptance changes use Kernel revision authority; breaking revisions invoke the native gate directly with the complete next intent. Preserve the prior on-disk sidecars until Kernel applies the revision.
322
- - **CONTEXT.md Vocabulary**: Read `CONTEXT.md` at the repo root. Use canonical terms in Spec, acceptance, and scope descriptions. `CONTEXT.md` is vocabulary and architecture navigation, not execution state.
323
- - **Discovery Protocol**: Read `CONTEXT.md` `## Architecture Map` before broad searching and relevant `docs/solutions/` evidence. Record concrete file pointers and reasons in the Spec. Do not read or write a legacy Step discovery cache.
355
+ - **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.
356
+ - **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.
357
+ - **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.
358
+ - **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.
324
359
  - **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.
325
360
  - **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.
326
361
 
@@ -356,7 +391,9 @@ optional advisory dispatch fails, continue inline and record the reason.
356
391
  Spec under `docs/specs/` plus canonical candidate
357
392
  `docs/plans/<task-id>.intent.json`. The Spec records outcome, discovery evidence,
358
393
  decisions, assumptions, Technical Design when required, output language,
359
- `Devil's Advocate Audit`, and acceptance/test mapping. Include a complete
394
+ the Medium/High risk Devil's Advocate Audit, and acceptance/test mapping. Low
395
+ risk records outcome, boundary, and concrete verification without the empty
396
+ ceremony. Include a complete
360
397
  `Brainstorm Trace` when consuming a Brainstorm manifest. TaskIntent is authored
361
398
  and validated through `imm-kernel`; do not write a prose iteration Plan or sync
362
399
  a State Ledger. Keep historical Plan validation strictly read-only.
@@ -373,15 +410,15 @@ a State Ledger. Keep historical Plan validation strictly read-only.
373
410
  | Split one outcome into read/edit/run micro-steps | One TaskIntent owns one closable outcome; Executor owns implementation batches. |
374
411
  | Append repair outside scope | Return the complete known scope delta for Kernel revision; do not widen execution. |
375
412
  | 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. |
376
- | Start planning while brainstorm questions are open | **Clarification Barrier**: Planning is blocked until all `BR-Q-*` items are answered; do not speculate on missing product info. |
377
- | Skip adversarial self-review 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. |
413
+ | 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. |
414
+ | 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. |
378
415
 
379
416
  ## Red Flags
380
417
 
381
418
  - Acceptance verification names only hypothetical evidence with no runnable descriptor.
382
419
  - New work depends on a prose Plan validator, Step activation, or State Ledger.
383
420
  - A Brainstorm manifest lacks a complete Spec `Brainstorm Trace`.
384
- - A Spec lacks a `Devil's Advocate Audit` covering rollback resilience, verification vanity, and spec dilution detection.
421
+ - A Medium/High risk Spec lacks a `Devil's Advocate Audit` covering rollback resilience, verification vanity, and spec dilution detection.
385
422
  - New Spec prose ignores the document-language policy.
386
423
  - Candidate artifacts escape the approved planning scope.
387
424
 
@@ -1,10 +1,12 @@
1
1
  ---
2
2
  name: imm-pr-fix
3
- description: Use to repair GitHub PR review feedback, merge conflicts, or failing CI checks within the current PR scope.
3
+ description: Use when the user explicitly requests Immune-Brain repair of GitHub PR review feedback, merge conflicts, or failing checks.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: PR Fix
7
7
 
8
+ ## Authority Boundary
9
+
8
10
  Repair blockers on one GitHub pull request without creating or mutating
9
11
  TaskIntent, TaskRecord, Kernel, Spec, or Plan authority. An already active
10
12
  Managed task remains owned by `imm-loop`; stop and direct the user there when
@@ -66,7 +68,9 @@ not repair blockers.
66
68
 
67
69
  ### 4. Verify and close out
68
70
 
69
- Run the smallest checks that reproduce each blocker, then any repository check
71
+ Before any push or feedback mutation, apply the BASELINE Host Confirmation
72
+ Boundary to the exact remote effect; the repair request alone does not grant
73
+ unrequested publication authority. Run the smallest checks that reproduce each blocker, then any repository check
70
74
  required by the changed surface. Re-read remote PR status, verify local HEAD is
71
75
  the expected PR head, inspect the final diff, and push only the repair branch.
72
76
  Reply to or resolve handled feedback when GitHub permissions and thread state
@@ -1,13 +1,16 @@
1
1
  # Internal role: executor
2
2
 
3
- You are the Immune-Brain Executor role inside Loop. Implement exactly one
4
- active Step, or one accepted same-boundary follow-up, in the current Parent
5
- conversation. Use workspace tools only for the supplied target and keep every
6
- edit inside the authoritative Scope. Do not discover or load a Pi Skill.
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.
7
8
 
8
- Before handoff, verify the active Result with the supplied Verification
9
- commands and record structured execution evidence through the Loop runtime
10
- action. Preserve failed and blocked attempts. Do not perform QA,
9
+ Before handoff, run the permitted diagnostic checks and return commands and
10
+ outcomes to the Parent as structured diagnostic evidence. The read-only Loop
11
+ runtime action only constructs the dispatch envelope; it does not store
12
+ evidence or change task state. Preserve failed and blocked attempts. Do not
13
+ perform QA,
11
14
  review, plan mutation, successor approval, Compounder work, or authority
12
15
  writes. If the requested change needs scope expansion, stop and return an
13
16
  `imm-planner` route with the concrete missing scope and verification reason.
@@ -22,6 +25,11 @@ Do not weaken tests or hide an incomplete result to make Verification pass.
22
25
  Treat naming, function length, parameter count, nesting, and abstraction taste
23
26
  as contextual signals, never as automatic failure thresholds.
24
27
 
25
- Fix in-scope integrity defects before Verification. If fixing one requires
26
- behavior, scope, or authority beyond the active Step, stop and route the
27
- concrete reason to `imm-planner`.
28
+ Fix in-scope integrity defects before Verification. Autonomously diagnose,
29
+ repair, and rerun failing ordinary local checks within the authorized scope;
30
+ do not stop for a repair round that stays inside the TaskIntent boundary. If
31
+ fixing requires
32
+ behavior, scope, or authority beyond the enrolled TaskIntent, stop and route the
33
+ concrete reason to `imm-planner`. An unavailable or still-failing required
34
+ check is an explicit blocker: report it to the Parent; never present failed
35
+ verification as completion.
@@ -71,8 +71,11 @@ decision, stop and report it to the Parent.
71
71
 
72
72
  ## Boundary
73
73
 
74
- Work only inside the supplied Plan, `plan_id`, changed-file boundary, review
75
- feedback, and verification commands. Do not create a second Plan, silently
74
+ Work only inside the supplied repair boundary: the current TaskIntent
75
+ acceptance and `scope_hint` when operating under one, otherwise the legacy
76
+ supplied Plan, `plan_id`, changed-file boundary, review feedback, and
77
+ verification commands from the delegation context. Do not create a second
78
+ Plan or TaskIntent, silently
76
79
  widen scope, push to unrelated branches, merge, approve a successor, or invoke
77
80
  another role. Do not discover or load a Pi Skill.
78
81
 
@@ -5,7 +5,7 @@
5
5
  // runner, compatibility gate, fixed execution, and findings digest.
6
6
 
7
7
  import { createHash } from "node:crypto";
8
- import { execFileSync, spawn } from "node:child_process";
8
+ import { execFileSync, spawn, spawnSync } from "node:child_process";
9
9
  import { realpathSync, statSync } from "node:fs";
10
10
  import { isAbsolute, join, resolve, sep, relative } from "node:path";
11
11
 
@@ -43,7 +43,18 @@ export function resolveBunRunner(): FrozenRunner {
43
43
  }
44
44
  let real: string;
45
45
  try {
46
- real = realpathSync(executable);
46
+ // When which returns a version-manager shim (e.g. mise or asdf),
47
+ // realpathSync on the shim resolves to the version-manager binary rather
48
+ // than bun. Ask bun itself for its real process.execPath.
49
+ const execPath = spawnSync(executable, ["-e", "console.log(process.execPath)"], {
50
+ encoding: "utf8",
51
+ stdio: ["ignore", "pipe", "ignore"],
52
+ });
53
+ if (execPath.status === 0 && execPath.stdout.trim().length > 0) {
54
+ real = realpathSync(execPath.stdout.trim());
55
+ } else {
56
+ real = realpathSync(executable);
57
+ }
47
58
  } catch {
48
59
  throw new VerificationDescriptorError("bun runner realpath is unresolvable");
49
60
  }