immune-brain 3.6.4 → 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 (42) 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 +76 -20
  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 +166 -57
  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 +31 -13
  14. package/plugins/immune-brain/dist/imm-planner.md +74 -32
  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/coordinator.ts +18 -0
  19. package/plugins/immune-brain/runtime/assurance/verification.ts +13 -2
  20. package/plugins/immune-brain/runtime/claude/kernel_ports.ts +31 -9
  21. package/plugins/immune-brain/runtime/claude/mcp_server.ts +14 -1
  22. package/plugins/immune-brain/runtime/commands/kernel.ts +15 -13
  23. package/plugins/immune-brain/runtime/github_issue_tracker.ts +1112 -20
  24. package/plugins/immune-brain/runtime/kernel/application.ts +1 -0
  25. package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +4 -1
  26. package/plugins/immune-brain/runtime/kernel/batch_authority.ts +407 -0
  27. package/plugins/immune-brain/runtime/kernel/canary_application.ts +24 -9
  28. package/plugins/immune-brain/runtime/kernel/enrollment.ts +72 -13
  29. package/plugins/immune-brain/runtime/kernel/intent.ts +67 -23
  30. package/plugins/immune-brain/runtime/kernel/reducer.ts +37 -9
  31. package/plugins/immune-brain/runtime/kernel/types.ts +1 -0
  32. package/plugins/immune-brain/runtime/kernel/validation.ts +10 -6
  33. package/plugins/immune-brain/runtime/plugin_version.ts +1 -1
  34. package/plugins/immune-brain/runtime/prompts/executor.md +18 -10
  35. package/plugins/immune-brain/runtime/prompts/pr-fix.md +5 -2
  36. package/plugins/immune-brain/skills/BASELINE.md +48 -15
  37. package/plugins/immune-brain/skills/imm-agent-doc-maintain/SKILL.md +20 -4
  38. package/plugins/immune-brain/skills/imm-brainstorm/SKILL.md +24 -64
  39. package/plugins/immune-brain/skills/imm-doc-prune/SKILL.md +18 -3
  40. package/plugins/immune-brain/skills/imm-loop/SKILL.md +20 -6
  41. package/plugins/immune-brain/skills/imm-planner/SKILL.md +35 -8
  42. package/plugins/immune-brain/skills/imm-pr-fix/SKILL.md +17 -3
@@ -27,6 +27,7 @@ import {
27
27
  import {
28
28
  mintToken,
29
29
  type TaskIntentIdentityToken,
30
+ type TokenIdentity,
30
31
  } from "./intent_token_registry";
31
32
 
32
33
  export const INTENT_MAX_BYTES = 64 * 1024;
@@ -406,6 +407,26 @@ export interface ReadTaskIntentResult {
406
407
  token: TaskIntentIdentityToken;
407
408
  }
408
409
 
410
+ export interface ObservedTaskIntent {
411
+ intent: TaskIntentV1;
412
+ content_hash: string;
413
+ intent_ref: TaskIntentRefV1;
414
+ }
415
+
416
+ export class TaskIntentObservationError extends Error {
417
+ readonly code: "missing" | "invalid";
418
+
419
+ constructor(code: "missing" | "invalid", message: string) {
420
+ super(message);
421
+ this.name = "TaskIntentObservationError";
422
+ this.code = code;
423
+ }
424
+ }
425
+
426
+ interface TaskIntentReadSource extends ObservedTaskIntent {
427
+ identity: TokenIdentity;
428
+ }
429
+
409
430
  export function setIntentReaderTestHook(
410
431
  hook: { onBeforeDescriptorRead?: () => void } | null,
411
432
  ): void {
@@ -523,11 +544,11 @@ function assertIdentitiesUnchanged(
523
544
  }
524
545
  }
525
546
 
526
- export function readTaskIntent(
547
+ function readTaskIntentSource(
527
548
  root: string,
528
549
  taskId: string,
529
550
  requestedPath?: string,
530
- ): ReadTaskIntentResult {
551
+ ): TaskIntentReadSource {
531
552
  validateTaskId(taskId);
532
553
 
533
554
  const canonicalRoot = resolveCanonicalRoot(root);
@@ -545,7 +566,7 @@ export function readTaskIntent(
545
566
  if (!target.startsWith(canonicalRoot + sep))
546
567
  throw new Error("intent sidecar escapes project root");
547
568
  if (!sidecarPresent(canonicalRoot, sidecarPath))
548
- throw new Error(`TaskIntent sidecar is missing at ${sidecarPath}`);
569
+ throw new TaskIntentObservationError("missing", `TaskIntent sidecar is missing at ${sidecarPath}`);
549
570
 
550
571
  const pathIdentities = collectPathIdentities(canonicalRoot, sidecarPath);
551
572
  const fileIdentity = pathIdentities[pathIdentities.length - 1];
@@ -557,13 +578,19 @@ export function readTaskIntent(
557
578
  ["ls-files", "--error-unmatch", "--", sidecarPath],
558
579
  { cwd: canonicalRoot, stdio: ["ignore", "pipe", "pipe"] },
559
580
  );
560
- } catch {
561
- throw new Error("TaskIntent sidecar is not Git-tracked");
581
+ } catch (error) {
582
+ if (
583
+ typeof error === "object"
584
+ && error !== null
585
+ && "status" in error
586
+ && (error as { status?: unknown }).status === 1
587
+ ) throw new TaskIntentObservationError("invalid", "TaskIntent sidecar is not Git-tracked");
588
+ throw error;
562
589
  }
563
590
 
564
591
  const before = lstatSync(target);
565
592
  if (!before.isFile() || before.size > INTENT_MAX_BYTES)
566
- throw new Error("TaskIntent sidecar must be a regular file no larger than 64 KiB");
593
+ throw new TaskIntentObservationError("invalid", "TaskIntent sidecar must be a regular file no larger than 64 KiB");
567
594
 
568
595
  const fd = openSync(target, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
569
596
  let bytes: Buffer;
@@ -576,7 +603,7 @@ export function readTaskIntent(
576
603
  closeSync(fd);
577
604
  }
578
605
  if (bytes.byteLength > INTENT_MAX_BYTES)
579
- throw new Error("TaskIntent sidecar exceeds 64 KiB");
606
+ throw new TaskIntentObservationError("invalid", "TaskIntent sidecar exceeds 64 KiB");
580
607
 
581
608
  // Post-read identity re-verification without a second path read as the
582
609
  // source of bytes.
@@ -594,27 +621,15 @@ export function readTaskIntent(
594
621
  try {
595
622
  intent = parseTaskIntentV1(JSON.parse(bytes.toString("utf8")));
596
623
  } catch (error) {
597
- throw new Error(
624
+ throw new TaskIntentObservationError(
625
+ "invalid",
598
626
  `TaskIntent sidecar is invalid: ${error instanceof Error ? error.message : String(error)}`,
599
627
  );
600
628
  }
601
629
  if (intent.task_id !== taskId)
602
- throw new Error("intent.task_id does not match the sidecar filename task id");
630
+ throw new TaskIntentObservationError("invalid", "intent.task_id does not match the sidecar filename task id");
603
631
 
604
632
  const contentHash = canonicalIntentHash(intent);
605
- const token = mintToken({
606
- canonical_root: canonicalRoot,
607
- sidecar_path: sidecarPath,
608
- path_dev: fileIdentity.dev,
609
- path_ino: fileIdentity.ino,
610
- fd_dev: before.dev,
611
- fd_ino: before.ino,
612
- fd_size: before.size,
613
- fd_mtime_ms: before.mtimeMs,
614
- source_bytes_sha256: sourceBytesSha256,
615
- intent_content_hash: contentHash,
616
- });
617
-
618
633
  return {
619
634
  intent,
620
635
  content_hash: contentHash,
@@ -623,6 +638,35 @@ export function readTaskIntent(
623
638
  revision: intent.revision,
624
639
  content_hash: contentHash,
625
640
  },
626
- token,
641
+ identity: {
642
+ canonical_root: canonicalRoot,
643
+ sidecar_path: sidecarPath,
644
+ path_dev: fileIdentity.dev,
645
+ path_ino: fileIdentity.ino,
646
+ fd_dev: before.dev,
647
+ fd_ino: before.ino,
648
+ fd_size: before.size,
649
+ fd_mtime_ms: before.mtimeMs,
650
+ source_bytes_sha256: sourceBytesSha256,
651
+ intent_content_hash: contentHash,
652
+ },
627
653
  };
628
654
  }
655
+
656
+ export function observeTaskIntent(
657
+ root: string,
658
+ taskId: string,
659
+ requestedPath?: string,
660
+ ): ObservedTaskIntent {
661
+ const { identity: _identity, ...observed } = readTaskIntentSource(root, taskId, requestedPath);
662
+ return observed;
663
+ }
664
+
665
+ export function readTaskIntent(
666
+ root: string,
667
+ taskId: string,
668
+ requestedPath?: string,
669
+ ): ReadTaskIntentResult {
670
+ const { identity, ...observed } = readTaskIntentSource(root, taskId, requestedPath);
671
+ return { ...observed, token: mintToken(identity) };
672
+ }
@@ -167,8 +167,10 @@ function sha256Hex(value: string): string {
167
167
  }
168
168
 
169
169
  function intentRefMatches(intent: TaskIntentV1, ref: TaskIntentRefV3): boolean {
170
+ const activePath = `docs/plans/${intent.task_id}.intent.json`;
171
+ const archivedPath = `docs/plans/archive/${intent.task_id}.intent.json`;
170
172
  return (
171
- ref.path === `docs/plans/${intent.task_id}.intent.json` &&
173
+ (ref.path === activePath || ref.path === archivedPath) &&
172
174
  ref.content_hash === canonicalIntentHash(intent)
173
175
  );
174
176
  }
@@ -178,6 +180,7 @@ function hasPrivilegedKind(action: TaskAction): boolean {
178
180
  action.type === "record_approval" ||
179
181
  action.type === "approve_breaking_intent_revision" ||
180
182
  action.type === "request_rework" ||
183
+ action.type === "authorize_rework" ||
181
184
  action.type === "stop" ||
182
185
  action.type === "resolve_user_decision"
183
186
  );
@@ -449,13 +452,16 @@ export function reduceTask(
449
452
  "request_rework requires review, qa, or user authority",
450
453
  ]);
451
454
  const round = reviewRound(record);
452
- const reviewAuthorityReworks = record.history.filter(
453
- (entry) =>
454
- entry.type === "request_rework" &&
455
- entry.authority?.authority_kind === "review",
456
- ).length;
455
+ const hasPriorBlockingReviewRework = record.findings.some(
456
+ (finding) =>
457
+ finding.source === "review" &&
458
+ finding.kind === "blocking" &&
459
+ finding.review_round !== null,
460
+ );
457
461
  const parkForReplan =
458
- authorityAudit.authority_kind === "review" && reviewAuthorityReworks >= 1;
462
+ authorityAudit.authority_kind === "review" &&
463
+ hasPriorBlockingReviewRework &&
464
+ action.findings.some((finding) => finding.kind === "blocking");
459
465
  if (!parkForReplan) {
460
466
  record.artifact_state = "active";
461
467
  record.intent_ref.path = `docs/plans/${record.task_id}.intent.json`;
@@ -470,8 +476,8 @@ export function reduceTask(
470
476
  record.findings.push({
471
477
  ...finding,
472
478
  status: "open",
473
- source: "review",
474
- review_round: round,
479
+ source: authorityAudit.authority_kind === "review" ? "review" : "execution",
480
+ review_round: authorityAudit.authority_kind === "review" ? round : null,
475
481
  });
476
482
  }
477
483
  if (
@@ -502,6 +508,28 @@ export function reduceTask(
502
508
  appendHistory(record, action, from, `review_round_${round}`, authorityAudit);
503
509
  break;
504
510
  }
511
+ case "authorize_rework": {
512
+ if (record.lifecycle !== "active")
513
+ throw new KernelInvariantError([
514
+ `cannot authorize rework while lifecycle is ${record.lifecycle}`,
515
+ ]);
516
+ if (authorityAudit?.authority_kind !== "user")
517
+ throw new KernelInvariantError([
518
+ "authorize_rework requires literal-user authority",
519
+ ]);
520
+ const open = record.findings.filter(
521
+ (finding) => finding.kind === "replan_required" && finding.status === "open",
522
+ );
523
+ if (open.length === 0)
524
+ throw new KernelInvariantError([
525
+ "authorize_rework requires an open replan boundary",
526
+ ]);
527
+ for (const finding of open) finding.status = "resolved";
528
+ record.artifact_state = "active";
529
+ record.intent_ref.path = `docs/plans/${record.task_id}.intent.json`;
530
+ appendHistory(record, action, from, open.map((finding) => finding.id).join(","), authorityAudit);
531
+ break;
532
+ }
505
533
  case "complete": {
506
534
  if (record.lifecycle !== "active" || record.artifact_state !== "frozen")
507
535
  throw new KernelInvariantError([
@@ -297,6 +297,7 @@ export type TaskAction =
297
297
  | (TaskActionBase & { type: "request_rework"; findings: TaskFinding[] })
298
298
  | (TaskActionBase & { type: "complete" })
299
299
  | (TaskActionBase & { type: "stop"; reason: string })
300
+ | (TaskActionBase & { type: "authorize_rework" })
300
301
  | (TaskActionBase & { type: "resolve_user_decision"; finding_id: string; resolution: string });
301
302
 
302
303
 
@@ -735,6 +735,7 @@ const ACTION_V2_TYPES = [
735
735
  "request_rework",
736
736
  "complete",
737
737
  "stop",
738
+ "authorize_rework",
738
739
  "resolve_user_decision",
739
740
  ] as const;
740
741
 
@@ -897,7 +898,8 @@ export function parseTaskAction(raw: unknown): TaskAction {
897
898
  };
898
899
  break;
899
900
  }
900
- case "complete": {
901
+ case "complete":
902
+ case "authorize_rework": {
901
903
  rejectUnknown(value, [...ACTION_BASE_FIELDS], "action", violations);
902
904
  action = { ...base, type: base.type };
903
905
  break;
@@ -1002,6 +1004,7 @@ export function assertTaskRecordUpdateV3(
1002
1004
  if (
1003
1005
  next.intent_ref.path !== previous.intent_ref.path &&
1004
1006
  action.type !== "request_rework" &&
1007
+ action.type !== "authorize_rework" &&
1005
1008
  action.type !== "stop"
1006
1009
  )
1007
1010
  violations.push("only artifact transitions may change intent_ref path");
@@ -1023,11 +1026,12 @@ export function assertTaskRecordUpdateV3(
1023
1026
  ? [action.finding_id]
1024
1027
  : action.type === "resolve_user_decision"
1025
1028
  ? [action.finding_id]
1026
- : action.type === "approve_breaking_intent_revision"
1027
- ? previous.findings
1028
- .filter((item) => item.kind === "replan_required" && item.status === "open")
1029
- .map((item) => item.id)
1030
- : [];
1029
+ : action.type === "authorize_rework" ||
1030
+ action.type === "approve_breaking_intent_revision"
1031
+ ? previous.findings
1032
+ .filter((item) => item.kind === "replan_required" && item.status === "open")
1033
+ .map((item) => item.id)
1034
+ : [];
1031
1035
  const reworkFindingIds =
1032
1036
  action.type === "request_rework"
1033
1037
  ? new Set(action.findings.map((item) => item.id))
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/plugin_versioning.ts from the root package.json.
2
- export const PLUGIN_VERSION = "3.6.4" as const;
2
+ export const PLUGIN_VERSION = "3.6.6" as const;
@@ -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
 
@@ -2,15 +2,39 @@
2
2
 
3
3
  ## Shared Guards
4
4
 
5
- - Load detailed workflow text from `dist/` only on invocation.
6
- - Ask only when missing information changes outcome or risk.
7
- - Keep edits inside the user-requested Direct scope or the active Managed step boundary.
5
+ - On explicit invocation, read only common constraints and selected section routes
6
+ from `dist/`; nested modes, examples, recovery, and references load on demand.
7
+ - Ask only when missing information would change the goal, scope, observable behavior, compatibility, risk acceptance, a protected effect, or a fact only the user can supply. Resolve repository facts and delegated technical choices with bounded evidence instead of asking.
8
+ - Keep edits inside the user-requested Direct scope or the enrolled TaskIntent acceptance and `scope_hint`.
9
+ - Stage only explicit task-owned paths. Never use `git add .` or `git add -A` in a dirty worktree.
10
+ - Do not create, switch, or delete Git worktrees; operate only in the Host launch directory.
8
11
  - Record reproducible evidence before reporting closure.
9
- - Use shallow discovery first.
12
+ - Required verification must pass before reporting completion; disclosing a gap is not a substitute. Autonomously diagnose, repair, and rerun failing conventional local checks within the authorized scope; never delete, skip, or weaken a valid check to manufacture a pass. If a required check remains failing or cannot run, report the work as incomplete with the concrete blocker.
13
+ - Inspect unknown test scripts before execution. A script named `test` that
14
+ deploys, writes production data, or uses credentials is a protected effect,
15
+ not routine local verification; apply Host Confirmation Boundary before it runs.
16
+ - Unanswered questions block only dependent commitments or execution. Continue
17
+ independent read-only investigation and local alternative drafts; label drafts
18
+ unapproved and never treat silence as consent or finalize a dependent Spec.
19
+ - Disclose unrelated pre-existing failures without repairing them or widening
20
+ scope. If they prevent a required check from passing, report that blocker and
21
+ incomplete verification rather than claiming completion.
22
+ - Use bounded evidence to cover affected callers and state owners for shared-contract, security, migration, persistence, or authority changes; the category alone never requires full-directory reads. Stop expanding once the relevant behavior and verification are understood.
10
23
  - Lead with conclusion, evidence, and Next Action.
11
24
  - Advisory roles do not implement; Managed execution roles do not close QA.
12
25
  - An explicit Managed Skill entry stops host-native mutation and routes scope changes to `imm-planner`; Managed execution remains inside its accepted boundary.
13
26
 
27
+ Before local edits or checks, read Verification and Local Recovery below. Read-only
28
+ framing does not load that execution guidance.
29
+
30
+ ## Verification and Local Recovery
31
+
32
+ - Select required checks from the requested outcome, affected behavior, and project requirements before claiming completion. Documentation changes use relevant link, mirror, and contract checks; local logic uses focused tests; shared behavior, build configuration, cross-module changes, and release preparation widen regression coverage. Never reduce required checks merely because they fail.
33
+ - Reuse a recorded passing local result only while the relevant code, test inputs, command, dependencies, and environment remain unchanged. Changed or uncertain inputs require rerunning affected checks. Role handoff alone does not invalidate local evidence; local evidence never replaces Kernel-owned deterministic QA or fresh snapshot-bound Review.
34
+ - Recover routine local failures within the authorized scope: select an unused port, create temporary outputs, and remove only task-generated disposable files. Never overwrite user data or stop an unrelated process to free a port. Before dependency installation, inspect the existing project command, lifecycle scripts, network use, and credential effects; use it only within existing authorization, without dependency or lockfile changes. Unknown or protected effects follow Host Confirmation Boundary.
35
+ - Retry a failed ordinary operation only after new evidence or a relevant condition changes; do not repeat identical attempts indefinitely. This does not authorize retrying a failed native authority gate or an uncertain remote write.
36
+ - When changing a supported behavior or contract, update its existing tests, remove tests whose protected behavior has retired, merge redundant coverage, and remove orphaned fixtures/helpers within the affected scope. For each removal, identify the retired behavior or the remaining coverage and run the surviving related checks. Never delete by age, count, slowness, or flakiness alone. Temporary tests name their exit condition; no per-test registry or repository-wide audit is required.
37
+
14
38
  ## Workflow Activation
15
39
 
16
40
  Ordinary host input stays host-native and does not run natural-language Managed
@@ -46,11 +70,15 @@ returns to `imm-planner`; an enrolled task resumes through `imm-loop` from the
46
70
  current Assurance projection. Do not create or mutate workflow state while
47
71
  classifying a non-mutating request.
48
72
 
49
- Stage only explicit task-owned paths. Never use `git add .` or `git add -A` in a dirty worktree.
50
-
51
73
  ### Host Confirmation Boundary
52
74
 
53
- Require exact host confirmation only for privileged effects:
75
+ Require exact host confirmation only for privileged effects. For ordinary
76
+ non-Kernel operations, an explicit user approval already covering the same
77
+ operation, target, and impact is sufficient; ask again only for a material delta.
78
+ A generic continuation or configured preference is not blanket authorization.
79
+ Mandatory native gates and hash-bound manifest approvals still apply.
80
+
81
+ Privileged effects include:
54
82
 
55
83
  - publish, release, deployment, or remote-system mutation;
56
84
  - destructive or irreversible operations and Git history rewrite;
@@ -65,7 +93,10 @@ Routine Managed enrollment uses one current-Host native confirmation bound to th
65
93
 
66
94
  State mutations, step activations, QA decisions, and plan switches remain
67
95
  strictly sequential. Read-only work — repo exploration, advisory review,
68
- host probing, planner research — may be dispatched in parallel.
96
+ host probing, planner research — is eligible for parallel dispatch in
97
+ capability terms, but Pi schedules one foreground child at a time: launch one
98
+ child, consume its direct result, then decide whether another child is needed.
99
+ Do not assume multiple foreground Agents run as a concurrent batch.
69
100
 
70
101
  Parallel dispatch is restricted by capability, not by a closed Skill list. Every
71
102
  child delegation packet must enforce read-only advisory behavior: no file edits,
@@ -99,13 +130,15 @@ always run sequentially.
99
130
 
100
131
  ## Success Criteria
101
132
 
102
- - Direct work closes only under the Direct completion contract above.
103
- - A Managed Step is ready to execute only when the target result, boundary, and
133
+ - Direct work closes only when the requested result is delivered and the required verification passes: a failed or unavailable required check is reported as incomplete work with its concrete blocker, never as completion. Check breadth follows the request and established project requirements, not a universal full-repository rule. Apply Shared Guards and Verification and Local Recovery for in-scope repair and evidence reuse.
134
+ - A Managed task is ready to execute only when the target result, boundary, and
104
135
  verification path are clear enough to avoid speculative edits.
105
- - A Managed Step is closable only when execution evidence proves the recorded
106
- verification path and the active boundary still matches the Plan.
107
- - Managed scope changes, missing evidence, or structural mismatch return to
108
- `imm-planner` instead of being hidden inside execution or QA.
136
+ - A Managed task is closable only when execution evidence proves the recorded
137
+ verification path and the TaskRecord still matches the enrolled TaskIntent boundary.
138
+ - Collect missing in-scope evidence and continue under the current owner. Missing
139
+ evidence alone does not require replanning. Escalate only a demonstrated
140
+ scope/acceptance mismatch or protected decision through the current owner's
141
+ revision or authorization path; never silently expand execution or QA scope.
109
142
 
110
143
  ## Retirement Completion
111
144
 
@@ -135,4 +168,4 @@ Immune-Brain commands and `.imm` state.
135
168
 
136
169
  Prefer shallow discovery before full-file reads. Start with file lists,
137
170
  `rg` hits, symbol/signature scans, and targeted line ranges; read whole files
138
- only when the narrower evidence path cannot answer the active Step question.
171
+ only when the narrower evidence path cannot answer the active task question.
@@ -1,11 +1,27 @@
1
1
  ---
2
2
  name: imm-agent-doc-maintain
3
- description: Use to minimize tracked AGENTS.md, CLAUDE.md, and GEMINI.md files to necessary non-discoverable context after an explicit, hash-bound, user-approved manifest; never installs or validates project contracts.
3
+ description: Use when the user explicitly requests Immune-Brain minimization of tracked AGENTS.md, CLAUDE.md, or GEMINI.md.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: Agent Doc Maintain
7
7
 
8
- Load [`../../dist/imm-agent-doc-maintain.md`](../../dist/imm-agent-doc-maintain.md),
9
- then minimize tracked agent instruction files to necessary non-discoverable
10
- context. This is a standalone host-native maintenance entry, not a Managed Path
8
+ Use [`../../dist/imm-agent-doc-maintain.md`](../../dist/imm-agent-doc-maintain.md)
9
+ as the canonical contract index, not a whole-document read.
10
+ This is a standalone host-native maintenance entry, not a Managed Path
11
11
  continuation and not an `imm-loop` internal-role dispatch.
12
+
13
+ Mandatory constraints: audit is read-only. Mutation requires exact hash-bound
14
+ manifest approval and immediate revalidation. Preserve active Managed ownership;
15
+ never install project contracts, modify external files, or commit.
16
+ Interruption requires a fresh scan.
17
+
18
+ Section routes - load a section's instructions only when its branch applies.
19
+ Read each linked heading body up to the next heading; nested sections and
20
+ references load only under their own condition. Never read the whole contract
21
+ or all references as an entry prerequisite.
22
+
23
+ - common: [Authority Boundary](../../dist/imm-agent-doc-maintain.md#authority-boundary), [Invocation](../../dist/imm-agent-doc-maintain.md#invocation), [Non-goals](../../dist/imm-agent-doc-maintain.md#non-goals)
24
+ - audit or manifest preparation: [Inventory and Manifest](../../dist/imm-agent-doc-maintain.md#inventory-and-manifest), [Manifest Approval and Recovery](../../dist/imm-agent-doc-maintain.md#manifest-approval-and-recovery)
25
+ - approved mutation before any edit: [Mutation Envelope](../../dist/imm-agent-doc-maintain.md#mutation-envelope), [Approved Mutation](../../dist/imm-agent-doc-maintain.md#approved-mutation)
26
+ - completion: [Verify and Report](../../dist/imm-agent-doc-maintain.md#verify-and-report)
27
+ - interruption or changed candidate before resuming: [Manifest Approval and Recovery](../../dist/imm-agent-doc-maintain.md#manifest-approval-and-recovery); start a fresh scan
@@ -1,70 +1,30 @@
1
1
  ---
2
2
  name: imm-brainstorm
3
- description: Use to frame and clarify an ambiguous problem and its open questions before planning; framing only, no implementation or plan writing.
3
+ description: Use when the user explicitly requests Immune-Brain requirement clarification.
4
4
  ---
5
5
 
6
6
  # Immune-Brain: Brainstorm
7
7
 
8
- Load [`../../dist/imm-brainstorm.md`](../../dist/imm-brainstorm.md), then frame the
9
- task before planning. Do not edit project files. Return goal, constraints,
10
- unknowns, readiness, and Next Action.
11
-
12
- ## Default exhaustive decision tree
13
-
14
- Exhaustive clarification traverses every current-goal branch grounded in the
15
- user request, repository evidence, or a settled parent decision. Do not use a
16
- materiality or task-type judgment to decide whether a sourced user decision is
17
- worth asking. Seed the fixed framing roots: goal, beneficiary and scenario,
18
- current state, desired behavior, scope and non-goals, constraints, failure and
19
- edge behavior, compatibility and migration, success and Verification, and
20
- deferred items; then expand branches from each answer.
21
-
22
- Classify each unresolved node only as a repository fact or a user-owned decision.
23
- Resolve repository facts with bounded, on-demand read-only evidence. A blocked
24
- fact blocks only its dependent subtree and remains explicit; never convert it
25
- into a user preference. Place every sourced user decision on the complete
26
- currently unblocked frontier. Hold dependent questions until their parents are
27
- settled, but ask all independent questions together. Number each question,
28
- include grounded options and a recommended answer with a short reason, and
29
- accept bulk approval of all recommendations with explicit exceptions.
30
-
31
- Direct requirements and adopted recommendations settle only the current nodes;
32
- they never complete the Brainstorm session by themselves. Recompute the tree
33
- after every response and continue through newly unlocked downstream branches.
34
- Minimally clarify an ambiguous answer. If later evidence invalidates a settled
35
- choice, reopen only that decision delta. An explicit defer stops its subtree and
36
- becomes `BR-DEFER-*`, unless it still changes the current Result, interface, or
37
- compatibility and therefore cannot be deferred.
38
-
39
- Brainstorm is complete only when the frontier is empty and no blocked fact
40
- prevents traversal. A zero-question fast path is valid only when the complete
41
- seeded and dynamically expanded tree contains no unresolved user decision. If
42
- the user stops early, emit every open node as `BR-Q-*` and do not mark the frame
43
- planning-ready. Otherwise present a result-only summary as a non-blocking
44
- correction window and retain final decisions in the `BR-*` manifest rather than
45
- copying the question transcript. Do not ask the user to reconfirm decisions
46
- reflected without change. If the summary introduces or changes a decision, ask
47
- for explicit confirmation of only that decision delta and block Planner handoff
48
- until it is answered. Agent judgment alone never confirms a proposed direction
49
- or scope.
50
-
51
- Brainstorm supports `default`, `roundtable`, and `adversarial` modes. All use the
52
- same exhaustive frontier protocol; `roundtable` and `adversarial` add analysis
53
- lenses only when explicitly selected by the user. Required failure, rollback,
54
- compatibility, migration, and risk branches remain part of default traversal.
55
- Consult ADRs and on-demand rejected-decision evidence only when a live branch
56
- reaches that topic.
57
- Architecture mapping is a bounded, read-only `arch-explorer` role selected
58
- through the internal Loop bridge; it cannot write a Spec, Plan, or workflow
59
- state. Pi's adapter may consume `brainstorm_ensemble` dispatch JSON to prepare
60
- advisory Pi subagent envelopes, but envelope construction is not child execution
61
- and does not transfer framing authority. Pi itself may launch those subagents,
62
- collect completed child outputs, and feed them to
63
- `normalizePiBrainstormAgentResults`; runtime does not call any agent, poll
64
- background work, mutate state, or own final Spec/Plan authority.
65
- Agreement becomes framing evidence, Disagreement becomes decision criteria or
66
- `BR-Q-*`, and strong-model blockers become risks or verification requirements.
67
-
68
- When framing discusses later execution, describe Enrollment only as the current
69
- Host's native gate. Never recommend another Host, worktree, or unmanaged
70
- implementation as a fallback for a failed Managed authority interaction.
8
+ Use [`../../dist/imm-brainstorm.md`](../../dist/imm-brainstorm.md) as the
9
+ canonical contract index, not a whole-document read. Explicit entry only: ordinary host questions do not
10
+ start this workflow.
11
+
12
+ Mandatory constraints before any action: Brainstorm is read-only — no code,
13
+ test, or runtime edits; no Spec, Plan, or workflow-state writes. All modes
14
+ produce a `brainstorm_framing` result with goal, constraints, unknowns,
15
+ readiness, and Next Action.
16
+
17
+ Section routes - load a section's instructions only when its branch applies.
18
+ Read each linked heading body up to the next heading; nested sections and
19
+ references load only under their own condition. Never read the whole contract
20
+ or all references as an entry prerequisite.
21
+
22
+ - common: all modes read [Shared Guards](../../dist/BASELINE.md#shared-guards), [Workflow Activation](../../dist/BASELINE.md#workflow-activation), [Host Confirmation Boundary](../../dist/BASELINE.md#host-confirmation-boundary), [Boundary](../../dist/imm-brainstorm.md#boundary), [Invocation modes](../../dist/imm-brainstorm.md#invocation-modes), [Default clarification](../../dist/imm-brainstorm.md#default-clarification), [Workflow Rules](../../dist/imm-brainstorm.md#workflow-rules), [Output artifact](../../dist/imm-brainstorm.md#output-artifact), [Output style](../../dist/imm-brainstorm.md#output-style), [Next Action](../../dist/imm-brainstorm.md#next-action)
23
+ - explicit thorough interrogation: [Explicit exhaustive interrogation](../../dist/imm-brainstorm.md#explicit-exhaustive-interrogation)
24
+ - optional research, including explicitly selected `roundtable` or `adversarial` advisory: [Research Dispatch](../../dist/imm-brainstorm.md#research-dispatch), [Brainstorm Ensemble Advisory](../../dist/imm-brainstorm.md#brainstorm-ensemble-advisory)
25
+ - requested framing document: [Output Language Policy](../../dist/BASELINE.md#output-language-policy)
26
+
27
+ When framing discusses later execution, describe Enrollment only as the
28
+ current Host's native gate. A failed Managed authority interaction stays
29
+ fail-closed: report one same-Host recovery action, never another Host,
30
+ worktree, or unmanaged implementation.
@@ -1,11 +1,26 @@
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
7
7
 
8
- Load [`../../dist/imm-doc-prune.md`](../../dist/imm-doc-prune.md), then prune
9
- stale current documentation from the target Git repository. This is a
8
+ Use [`../../dist/imm-doc-prune.md`](../../dist/imm-doc-prune.md) as the canonical
9
+ contract index, not a whole-document read. This is a
10
10
  standalone host-native maintenance entry, not a Managed Path continuation
11
11
  and not an `imm-loop` internal-role dispatch.
12
+
13
+ Mandatory constraints: audit is read-only. Mutation requires exact hash-bound
14
+ manifest approval and immediate revalidation. Preserve active Managed ownership;
15
+ never delete authority artifacts or commit. Interruption requires a fresh scan.
16
+
17
+ Section routes - load a section's instructions only when its branch applies.
18
+ Read each linked heading body up to the next heading; nested sections and
19
+ references load only under their own condition. Never read the whole contract
20
+ or all references as an entry prerequisite.
21
+
22
+ - common: [Authority Boundary](../../dist/imm-doc-prune.md#authority-boundary), [Invocation](../../dist/imm-doc-prune.md#invocation), [Authority Artifacts Excluded](../../dist/imm-doc-prune.md#authority-artifacts-excluded)
23
+ - audit or manifest preparation: [Inventory and Manifest](../../dist/imm-doc-prune.md#inventory-and-manifest)
24
+ - approved mutation before any edit: [Mutation Envelope](../../dist/imm-doc-prune.md#mutation-envelope), [Approved Mutation](../../dist/imm-doc-prune.md#approved-mutation)
25
+ - completion: [Verify and Report](../../dist/imm-doc-prune.md#verify-and-report)
26
+ - recovery or deletion recoverability: [Recovery](../../dist/imm-doc-prune.md#recovery)