immune-brain 3.6.6 → 3.6.8

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 (30) hide show
  1. package/README.md +110 -51
  2. package/README.zh-CN.md +153 -49
  3. package/package.json +2 -1
  4. package/plugins/immune-brain/.claude-plugin/plugin.json +1 -1
  5. package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +29 -19
  6. package/plugins/immune-brain/.pi-extension/imm-unattended-batch.ts +932 -0
  7. package/plugins/immune-brain/.pi-extension/package.json +3 -2
  8. package/plugins/immune-brain/.pi-extension/pi-canary-interaction.ts +149 -4
  9. package/plugins/immune-brain/.pi-extension/runtime-stub.ts +200 -2
  10. package/plugins/immune-brain/dist/claude/mcp-server.mjs +3404 -227
  11. package/plugins/immune-brain/dist/imm-loop.md +25 -0
  12. package/plugins/immune-brain/dist/role-prompts/code-review.md +9 -1
  13. package/plugins/immune-brain/runtime/assurance/coordinator.ts +101 -3
  14. package/plugins/immune-brain/runtime/claude/interaction.ts +16 -3
  15. package/plugins/immune-brain/runtime/claude/kernel_ports.ts +840 -17
  16. package/plugins/immune-brain/runtime/claude/mcp_server.ts +72 -10
  17. package/plugins/immune-brain/runtime/kernel/canary_application.ts +9 -0
  18. package/plugins/immune-brain/runtime/kernel/completion.ts +19 -1
  19. package/plugins/immune-brain/runtime/kernel/reducer.ts +162 -11
  20. package/plugins/immune-brain/runtime/kernel/refutation.ts +82 -0
  21. package/plugins/immune-brain/runtime/kernel/types.ts +34 -1
  22. package/plugins/immune-brain/runtime/kernel/validation.ts +202 -9
  23. package/plugins/immune-brain/runtime/plugin_version.ts +1 -1
  24. package/plugins/immune-brain/runtime/prompts/code-review.md +9 -1
  25. package/plugins/immune-brain/runtime/unattended/batch_git.ts +775 -0
  26. package/plugins/immune-brain/runtime/unattended/batch_plan.ts +203 -0
  27. package/plugins/immune-brain/runtime/unattended/batch_runner.ts +1224 -0
  28. package/plugins/immune-brain/runtime/unattended/batch_state.ts +360 -0
  29. package/plugins/immune-brain/runtime/unattended/types.ts +60 -0
  30. package/plugins/immune-brain/skills/imm-loop/SKILL.md +1 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "immune-brain",
3
- "version": "3.6.6",
3
+ "version": "3.6.8",
4
4
  "description": "Immune-Brain Claude Code Host: native Enrollment, QA, Review, and Kernel settlement.",
5
5
  "author": {
6
6
  "name": "Immune-Brain Team"
@@ -71,6 +71,7 @@ import {
71
71
  } from "./pi-canary-interaction";
72
72
  import { isToolFailureState, throwToolFailure, type ToolFailureV1 } from "./pi-canary-tool-failure";
73
73
  import { taskDiffIdentity, taskRevisionIdentity, captureGitTaskSnapshot } from "../runtime/workspace_scope";
74
+ import { reviewReworkFindings } from "../runtime/assurance/coordinator";
74
75
  import {
75
76
  AssuranceProgression,
76
77
  buildReviewPrompt,
@@ -144,6 +145,7 @@ const KERNEL_OPERATIONS = [
144
145
  "freeze_artifacts",
145
146
  "record_finding",
146
147
  "resolve_finding",
148
+ "refute_finding",
147
149
  "revise_intent",
148
150
  "complete",
149
151
  ] as const;
@@ -307,11 +309,17 @@ export function createPiAssuranceProgressionPorts(
307
309
  } satisfies AssuranceProgressionPorts;
308
310
  }
309
311
 
312
+ const GLOBAL_PI_PROGRESSION_KEY = Symbol.for("immune_brain.pi_assurance_progression");
313
+
310
314
  export default function (
311
315
  pi: ExtensionAPI,
312
316
  dependencies: CanaryWorkExtensionDependencies = {},
313
317
  ) {
318
+ // One progression per extension load, published for the batch gate to reuse.
319
+ // Reusing whatever instance a previous load left behind would leak another
320
+ // session's Review reservations into this one, so the load always replaces it.
314
321
  const progression = new AssuranceProgression(createPiAssuranceProgressionPorts(dependencies));
322
+ (globalThis as any)[GLOBAL_PI_PROGRESSION_KEY] = progression;
315
323
 
316
324
  let railContext: ExtensionContext | undefined;
317
325
  const refreshTaskRail = async (ctx: ExtensionContext) => {
@@ -449,6 +457,11 @@ export default function (
449
457
  }),
450
458
  }),
451
459
  Type.Object({ op: Type.Literal("resolve_finding"), finding_id: Type.String() }),
460
+ Type.Object({
461
+ op: Type.Literal("refute_finding"),
462
+ finding_id: Type.String(),
463
+ attestation_id: Type.String(),
464
+ }),
452
465
  Type.Object({
453
466
  op: Type.Literal("revise_intent"),
454
467
  next_intent: TASK_INTENT_SCHEMA,
@@ -536,7 +549,7 @@ export default function (
536
549
  if ((action.op === "request_stop" || action.op === "request_authorization" || action.op === "approve_breaking_intent_revision") && ctx.mode !== "tui")
537
550
  return failCanaryTool(taskId, action.op, "blocked", "tui_required", "literal-user authorization is TUI-only", "invoke the TUI Tool");
538
551
  const result = action.op === "advance_assurance"
539
- ? await progression.advance(taskId, ctx, signal, (update) => {
552
+ ? await progression.advance(taskId, ctx, signal, (update: any) => {
540
553
  onUpdate?.(update);
541
554
  presentTaskRailResult(ctx, taskId, update.details as Record<string, unknown> | undefined);
542
555
  })
@@ -1070,7 +1083,11 @@ export function deriveAuthorizationOperation(input: {
1070
1083
  return { blocked: "no unique host-derived authorization operation" };
1071
1084
  }
1072
1085
 
1073
- function toCanaryOperation(action: { op: string }, actorId: string) {
1086
+ /**
1087
+ * Ordinary Kernel operation mapping, exported so the conformance suite can
1088
+ * prove the Tool schema and this projection cannot drift apart.
1089
+ */
1090
+ export function toCanaryOperation(action: { op: string }, actorId: string) {
1074
1091
  switch (action.op) {
1075
1092
  case "freeze_artifacts":
1076
1093
  return { op: "freeze_artifacts", actor_id: actorId };
@@ -1082,6 +1099,13 @@ function toCanaryOperation(action: { op: string }, actorId: string) {
1082
1099
  };
1083
1100
  case "resolve_finding":
1084
1101
  return { op: "resolve_finding", finding_id: (action as unknown as { finding_id: string }).finding_id, actor_id: actorId };
1102
+ case "refute_finding":
1103
+ return {
1104
+ op: "refute_finding",
1105
+ finding_id: (action as unknown as { finding_id: string }).finding_id,
1106
+ attestation_id: (action as unknown as { attestation_id: string }).attestation_id,
1107
+ actor_id: actorId,
1108
+ };
1085
1109
  case "revise_intent":
1086
1110
  return { op: "revise_intent", next_intent: (action as unknown as { next_intent: unknown }).next_intent, actor_id: actorId };
1087
1111
  case "complete":
@@ -1373,15 +1397,7 @@ async function applyAssuranceVerdict(
1373
1397
  return result;
1374
1398
  };
1375
1399
  if (verdict.decision === "rework") {
1376
- const findings = verdict.findings!.map((finding) => ({
1377
- id: finding.id,
1378
- kind: finding.kind,
1379
- status: "open",
1380
- acceptance_id: finding.acceptance_id,
1381
- source: "review",
1382
- review_round: null,
1383
- summary: finding.summary,
1384
- }));
1400
+ const findings = reviewReworkFindings(verdict);
1385
1401
  const now = new Date().toISOString();
1386
1402
  const capability = await mintCapability(registry, {
1387
1403
  authority_kind: authorityKind,
@@ -1650,14 +1666,7 @@ async function mintCapability(
1650
1666
  expires_at: new Date(Date.now() + 10 * 60 * 1000).toISOString(),
1651
1667
  findings_digest:
1652
1668
  input.action_kind === "request_rework"
1653
- ? await findingsDigestV2(
1654
- (input.findings as Array<{ id: string; kind: string; acceptance_id: string | null; summary: string }>).map((f) => ({
1655
- id: f.id,
1656
- kind: f.kind,
1657
- acceptance_id: f.acceptance_id,
1658
- summary: f.summary,
1659
- })),
1660
- )
1669
+ ? await findingsDigestV2(input.findings as never[])
1661
1670
  : null,
1662
1671
  };
1663
1672
  return registry.issue(binding);
@@ -1930,6 +1939,7 @@ export {
1930
1939
  classifyReviewWorkload,
1931
1940
  deriveQaJobTimeoutMs,
1932
1941
  parseAssuranceVerdict,
1942
+ reviewReworkFindings,
1933
1943
  snapshotDigest,
1934
1944
  QA_JOB_TIMEOUT_SECONDS,
1935
1945
  REVIEW_DISPATCH_TIMEOUT_MS,