immune-brain 3.2.1 → 3.3.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 (26) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/package.json +5 -3
  4. package/plugins/immune-brain/.claude-plugin/plugin.json +1 -1
  5. package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +19 -73
  6. package/plugins/immune-brain/.pi-extension/pi-canary-interaction.ts +1 -2
  7. package/plugins/immune-brain/.pi-extension/runtime-stub.ts +2 -2
  8. package/plugins/immune-brain/dist/claude/mcp-server.mjs +27 -85
  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 +28 -13
  11. package/plugins/immune-brain/dist/imm-loop.md +25 -16
  12. package/plugins/immune-brain/dist/imm-planner.md +1 -1
  13. package/plugins/immune-brain/runtime/assurance/coordinator.ts +0 -8
  14. package/plugins/immune-brain/runtime/claude/interaction.ts +0 -1
  15. package/plugins/immune-brain/runtime/claude/kernel_ports.ts +5 -24
  16. package/plugins/immune-brain/runtime/claude/mcp_server.ts +12 -8
  17. package/plugins/immune-brain/runtime/kernel/application.ts +0 -1
  18. package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +1 -7
  19. package/plugins/immune-brain/runtime/kernel/canary_application.ts +0 -7
  20. package/plugins/immune-brain/runtime/kernel/completion.ts +1 -3
  21. package/plugins/immune-brain/runtime/kernel/reducer.ts +0 -31
  22. package/plugins/immune-brain/runtime/kernel/types.ts +0 -2
  23. package/plugins/immune-brain/runtime/kernel/validation.ts +1 -3
  24. package/plugins/immune-brain/runtime/plugin_version.ts +2 -0
  25. package/plugins/immune-brain/skills/imm-loop/SKILL.md +3 -45
  26. package/plugins/immune-brain/skills/imm-planner/SKILL.md +3 -226
@@ -1,232 +1,9 @@
1
1
  ---
2
2
  name: imm-planner
3
- description: Use to create or revise a spec and iteration plan from requirements; owns scope and plan decomposition, not implementation or step activation.
3
+ description: Use to create or revise a spec and TaskIntent from requirements; owns scope and decomposition, not implementation or Enrollment.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: Planner
7
7
 
8
- Load [`../../dist/imm-planner.md`](../../dist/imm-planner.md), then create or revise
9
- the executable plan. `mode: page_design` is the canonical pre-implementation
10
- design-contract mode formerly exposed as `imm-page-design`. Keep scope
11
- explicit, including the Devil's Advocate preplan audit and `Devil's Advocate Audit` output. Return plan path, decisions,
12
- first step, verification approach, and Next Action.
13
-
14
- ## Clarification supplement
15
-
16
- Planner consumes an upstream Brainstorm manifest as a closed-world input and
17
- must not repeat, reopen, or rewrite confirmed decisions. Direct Planner entry
18
- and Medium/High Design Risk work must inspect relevant ADRs and rejected
19
- Learnings. It resolves repository facts and owns ordinary technical choices: design and component boundaries, failure behavior, compatibility, migration, recovery and
20
- rollback, Verification, execution slices, dependencies, scope, and delivery
21
- risk. It then authors the candidate Spec, Plan, or TaskIntent.
22
-
23
- Planner may ask only when concrete new evidence exposes an omission, repository
24
- conflict, or invalidated assumption. Ask the focused decision delta, cite the
25
- upstream `BR-*` item and new evidence when available, and preserve every
26
- unaffected decision. Resolve a local delta here; if its answer reopens multiple
27
- product branches or changes the overall goal or Scope, stop and return to
28
- `imm-brainstorm`.
29
-
30
- Direct Planner entry remains valid for clear requests. Resolve facts and derive
31
- technical design without a Brainstorm pass; if an unresolved user-owned product
32
- decision appears, return to `imm-brainstorm` instead of silently choosing it or
33
- starting a second exhaustive interview. A zero-question fast path is valid when
34
- no supplement is required. Present an unchanged result summary as a
35
- non-blocking correction window and do not ask the user to reconfirm existing
36
- decisions. If the summary itself introduces or changes a user decision, confirm
37
- only that decision delta before finalizing.
38
-
39
- Settlement-class intents (terminal settlement, cancellation, timeout, race, or
40
- authority-lifecycle semantics) must embed the `Settlement-Design Contract`
41
- enumeration required by the loaded contract before they are execution-ready.
42
-
43
- ## Technical Design Views And Decomposition
44
-
45
- For Medium and High Design 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. The Spec is the single Technical Design baseline. Persist those decisions there; do not copy them into a TaskIntent or revive prose Plan authority. Low risk remains concise and is not forced to produce empty architecture, interface, data-flow, state, or sequence sections.
46
-
47
- Use the selected design boundaries as one TaskIntent decomposition dimension alongside outcome, Verification, dependency, risk, rollback, compatibility, and authority. Keep one TaskIntent when the selected views describe one coherent executable slice with shared acceptance, risk treatment, rollback, and authority. Split a successor TaskIntent only when a service, state-machine owner, migration, 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.
48
-
49
- Treat trust-boundary changes as the same kind of decomposition evidence. A TaskIntent should normally change one primary trust-boundary invariant; 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.
50
-
51
- ## Reference Closure Preflight
52
-
53
- Before authoring a TaskIntent, trace each expected behavior from its public or
54
- runtime entry point through existing imports and callers to the highest focused
55
- behavioral tests. Include generated or packaged mirrors and every owner of the
56
- same state machine. Record the concrete paths in the Spec's discovery evidence;
57
- do not author while a referenced sibling is unresolved. Use the smallest
58
- coherent module directory for ordinary implementation scope. Keep Kernel,
59
- authority, migration, secret, and security-sensitive scope exact to the files
60
- proved necessary by the trace. Scope is closed by reference evidence, not by an
61
- exhaustive filename guess.
62
-
63
- ## Managed Request Routing
64
-
65
- `imm-planner` is entered explicitly by the user for a clear repository mutation.
66
- Ordinary host input does not invoke this Skill through natural-language routing.
67
- An active Assurance projection remains authoritative and is resumed only through an explicit `imm-loop` entry; explicit Planner entry owns planning and the later native Enrollment gate:
68
- - an active Assurance projection remains on its current owner until the user explicitly enters `imm-loop`;
69
- - read-only, explanation, review-only, Plan-only, and explicit no-modification
70
- requests do not enroll;
71
- - materially ambiguous mutations go to `imm-brainstorm` before planning; and
72
- - clear new mutations reach this Planner phase.
73
-
74
- Plan-only output remains non-authoritative. Planner creates or validates a
75
- candidate Spec/TaskIntent, but it never enrolls a task or enrolls generated
76
- artifacts unconditionally. Explicit Plan-only requests stop after returning the
77
- planning artifacts. A later literal-user request to start Enrollment is a non-authoritative
78
- execution trigger: invoke the native Enrollment gate directly, without asking
79
- for chat pre-confirmation. For a clear mutation request that already includes
80
- execution, invoke that gate as soon as the candidate is validated and Git-tracked.
81
- Literal-user confirmation in the native gate remains the authority boundary.
82
- Fast-Track may compress the same phases but cannot bypass that boundary, QA,
83
- Review, authorization, or completion.
84
-
85
- ## Kernel TaskIntent Routing
86
-
87
- Before producing a new managed planning artifact, resolve the canonical wrappers
88
- from the declared Skill location: `../../bin/imm-plan` and
89
- `../../bin/imm-kernel`. Invoke `imm-plan --routing-status --json` through that
90
- resolved wrapper and use the resolved `imm-kernel` wrapper for every Kernel
91
- command below. Do not assume either bare command is available on shell `PATH`.
92
- Then route deterministically:
93
-
94
- - an active Kernel claim routes to `imm-loop` for foreground Kernel Tool
95
- coordination, not new planning;
96
- - an active or otherwise nonterminal v3 Plan remains on its existing v3 route;
97
- - no routing policy preserves the legacy v3 Planner behavior;
98
- - a valid `kernel_task_intent` retirement policy produces one TaskIntent draft
99
- through Pi `imm-planner`;
100
- - an invalid, unreadable, untracked, or tracked-deleted policy rejects new
101
- planning authority with `routing_policy_invalid`;
102
- - no Planner path enrolls a task or falls back to v3 after retirement.
103
-
104
- Current owner, phase, completion, and authority facts are authoritative only
105
- when read from the Assurance projection and TaskRecord. `CONTEXT.md` is
106
- non-authoritative vocabulary and architecture navigation, not a workflow-status
107
- source. If its prose conflicts with those authority facts, report stale
108
- documentation, preserve projection-based routing, and do not automatically
109
- synchronize either representation.
110
-
111
- Pi host identity is implicit and never a planning input. The production boundary
112
- that turns a Git-tracked TaskIntent draft into managed execution authority is the
113
- native host TUI: the Planner's final `ctx.ui.custom` gate (via the
114
- `imm_canary_enrollment` foreground Tool) provides one literal-user confirmation
115
- bound to the TaskIntent content hash. Invoke the Tool directly when the route is
116
- ready; do not ask for a chat pre-confirmation. Enrollment validates the intent,
117
- Git ownership, scope, workspace claim, and final authority preconditions without
118
- executing acceptance descriptors. A routine task proceeds from that single
119
- confirmation through enrollment, execution and QA without a second human stop.
120
-
121
- The Planner never writes the `docs/plans/<task-id>.intent.json` artifact
122
- directly and never overwrites an existing TaskIntent. Under an active
123
- `kernel_task_intent` policy it supplies one complete candidate to the canonical
124
- `imm-kernel intent author <path> --stdin --json` command, which owns strict
125
- parsing, verification-descriptor canonicalization, path binding, and exclusive
126
- file creation; then it validates the created artifact with
127
- `imm-kernel intent validate <path> --json`. Revisions of an enrolled intent
128
- continue through Kernel `revise_intent` authority and are not a Planner
129
- overwrite path.
130
-
131
- ### Initiative Carrier Preference
132
-
133
- For a large proposal split across multiple TaskIntents, exactly one planning
134
- carrier is chosen per Initiative: a Local Markdown file at
135
- `docs/initiatives/<slug>.md` or one GitHub Parent Issue. This preference applies
136
- only to Initiatives; ordinary TaskIntents remain tracked by Kernel TaskRecords.
137
- Resolve the carrier in this order:
138
-
139
- 1. a literal user instruction for the current request;
140
- 2. `Initiative carrier default: local` or `Initiative carrier default: github`
141
- in the repository root `AGENTS.md`;
142
- 3. the same directive in `~/.pi/agent/AGENTS.md`; or
143
- 4. ask the user when no valid directive exists.
144
-
145
- A repository directive overrides the global directive. Report an invalid value
146
- and ask instead of guessing. After resolving it, display one non-blocking line
147
- with the selected carrier and its source. A configured `github` default is
148
- standing opt-in for GitHub projection, but the literal user must still confirm
149
- the named Initiative, its immutable slug, and the complete Parent/Child
150
- decomposition before the first remote mutation. A prior bulk approval cannot
151
- confirm a name, slug, Child, or dependency that had not yet been shown.
152
-
153
- Once decomposition is complete, present one review table containing the Parent
154
- result and every Child's stable Slice ID, result, scope boundary, risk, blockers,
155
- and proposed execution order. Ask one focused question: whether the coverage,
156
- granularity, and dependencies are correct. Recommend the complete current
157
- frontier so the user can approve it in one response. Before that approval,
158
- perform zero GitHub mutations. A partial or progressively disclosed issue set is
159
- not eligible for publication.
160
-
161
- After approval, author, stage, and validate every TaskIntent in the decomposition
162
- with `valid: true` and `enrollment_ready: true`. Resolve `../../bin/imm-tracker` from this Skill location; do not assume a bare command is on `PATH`. Submit the entire approved set once through
163
- `imm-tracker publish-initiative --stdin --json`. Its input contains the confirmed
164
- Initiative slug and goal, Parent projection, and every Child's `slice_id`,
165
- canonical TaskIntent path, and public projection. The Parent projection requires
166
- `problem`, `result`, and `design`, and may include `decisions`,
167
- `testing_strategy`, and `out_of_scope`. `design` records Initiative-level
168
- invariants, Slice boundaries and ordering, shared interfaces or state flow, and
169
- material compatibility decisions. Every Parent Slice must correspond to one
170
- published Child; future checklist-only Slices are not allowed in the batch.
171
-
172
- Each Child projection may contain `result`, `current_behavior`,
173
- `desired_behavior`, `key_interfaces`, `verification`, `blocked_by` Task IDs,
174
- `out_of_scope`, and `agent_handoff`. The tracker rereads every canonical
175
- TaskIntent for identity, risk, and acceptance; projection fields never widen
176
- TaskIntent scope or authority. It validates the complete dependency graph before
177
- remote writes, creates the Parent once, creates all Children, attaches every
178
- Child as a native Sub-issue, creates native `blocked_by` relations, and rereads
179
- the complete topology. The Child Agent Brief includes a direct Parent Issue link.
180
- Internal role prompts, tool policies, review gates, model reservations, and
181
- prompt digests never belong in this external handoff. If
182
- `docs/initiatives/<slug>.md` exists, publication fails with a carrier conflict;
183
- Local mode performs zero GitHub operations.
184
-
185
- The batch result includes an execution recommendation: the first unblocked Task,
186
- a stable dependency order, and parallel groups. For a plan-only request, report
187
- that recommendation and stop. For a request that includes execution, invoke the
188
- native Enrollment gate for the recommended first TaskIntent after successful
189
- publication; do not ask for another chat confirmation. GitHub selection never
190
- bypasses Enrollment.
191
-
192
- Tracker output is observation, never authority. Before the Planner returns, its
193
- GitHub carrier outcome must be exactly one of: `tracker_associated` after the
194
- complete batch returns `created`, `updated`, or `already_current`;
195
- `awaiting_user_initiative_confirmation` with the single pending name, slug, and
196
- complete-decomposition decision; or `tracker_projection_failed` with the returned
197
- failure and exact retry action. A candidate Initiative or partial Issue set
198
- recorded only in the Spec or final summary is neither user confirmation nor a
199
- completed carrier outcome. Report `retryable_failure`, `permanent_failure`, or
200
- `ambiguous_remote_state` and the exact batch retry action. This does not invalidate
201
- already-authored planning files, but it blocks `tracker_associated` and every
202
- Enrollment or execution handoff for that Initiative until the same complete
203
- batch succeeds. Do not infer opt-in from tracker output or Issue state, auto-close the Parent,
204
- import Issue state, create a TaskIntent from an Issue, or store Issue identity in
205
- TaskIntent or TaskRecord. Existing Issue markers grant permission only for
206
- idempotent retry of that same approved Initiative; they never grant execution
207
- authority.
208
-
209
- ### Verification Descriptor Discipline
210
-
211
- Every acceptance verification descriptor must be a focused, deterministic,
212
- repository-local check that exercises only its acceptance assertion. Prefer one
213
- small `bun test <focused-file>` or `bun run <focused-script>` per acceptance;
214
- never use the full test suite, a build, package installation, network access, or
215
- redundant heavyweight checks. Prefer the highest existing observable behavioral
216
- test seam and the fewest sufficient seams. Cite relevant test prior art and
217
- explain how the selected seam catches the intended regression. This is a
218
- planning heuristic: it must not weaken acceptance-specific focused verification
219
- descriptors or add a mandatory user confirmation. Use the smallest `timeout_ms` and
220
- `max_output_bytes` that cover deterministic post-implementation QA.
221
-
222
- ## Retirement Completion Contract
223
-
224
- For retirement-class work, deletion of source and contract text is a completion condition. A retirement that routes the command to a retirement wall, pins the absence with test assertions, and leaves the source in the tree is not complete. A retirement is not complete until the source and its contract text are deleted.
225
-
226
- An absence test is transitional scaffolding proving an in-progress deletion rather than a substitute for one. An absence test is transitional evidence of an in-progress deletion and may not stand in place of one. It proves a deletion in progress, not a completed result. Distinguish an absence assertion that guards something already gone, which is durable and correct, from one that stands in for a deletion still owed, which is a promise recorded as if it were a result.
227
- Architecture exploration and advisory review use the internal Loop bridge's
228
- read-only `arch-explorer` and `advisory-reviewer` roles. They can supply
229
- candidates, evidence, and decision criteria, but cannot write this Spec/Plan or
230
- activate execution.
231
- Agreement becomes evidence, Disagreement becomes decision criteria, and
232
- strong-model blockers become risks or verification requirements.
8
+ Load [`../../dist/imm-planner.md`](../../dist/imm-planner.md), then follow that
9
+ canonical contract. `mode: page_design` selects its page-design branch.