immune-brain 3.6.8 → 4.0.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.
- package/README.md +11 -4
- package/README.zh-CN.md +10 -3
- package/package.json +3 -2
- package/plugins/immune-brain/.claude-plugin/plugin.json +1 -1
- package/plugins/immune-brain/.pi-extension/imm-canary-enroll.ts +18 -2
- package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +76 -121
- package/plugins/immune-brain/.pi-extension/imm-unattended-batch.ts +106 -600
- package/plugins/immune-brain/.pi-extension/pi-canary-assurance-progression.ts +1 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-verification.ts +3 -3
- package/plugins/immune-brain/.pi-extension/runtime-stub.ts +17 -43
- package/plugins/immune-brain/dist/claude/mcp-server.mjs +7581 -5042
- package/plugins/immune-brain/dist/docs/reference/planning-artifact-retention.md +11 -12
- package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +1 -1
- package/plugins/immune-brain/dist/imm-loop.md +27 -25
- package/plugins/immune-brain/dist/imm-planner.md +53 -32
- package/plugins/immune-brain/dist/imm-review-retro.md +123 -0
- package/plugins/immune-brain/dist/registry.yaml +9 -0
- package/plugins/immune-brain/dist/role-prompts/code-review.md +3 -1
- package/plugins/immune-brain/dist/role-prompts/executor.md +4 -4
- package/plugins/immune-brain/runtime/assurance/coordinator.ts +183 -40
- package/plugins/immune-brain/runtime/assurance/delivery_workspace.ts +240 -0
- package/plugins/immune-brain/runtime/assurance/qa.ts +132 -58
- package/plugins/immune-brain/runtime/assurance/review_evidence.ts +15 -7
- package/plugins/immune-brain/runtime/assurance/verification.ts +246 -206
- package/plugins/immune-brain/runtime/authorization_operation.ts +20 -0
- package/plugins/immune-brain/runtime/claude/kernel_ports.ts +288 -721
- package/plugins/immune-brain/runtime/commands/kernel.ts +158 -67
- package/plugins/immune-brain/runtime/github_issue_tracker.ts +254 -29
- package/plugins/immune-brain/runtime/kernel/actor_identity.ts +33 -0
- package/plugins/immune-brain/runtime/kernel/application.ts +22 -6
- package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +94 -5
- package/plugins/immune-brain/runtime/kernel/authority_port.ts +27 -6
- package/plugins/immune-brain/runtime/kernel/backend_claim.ts +43 -16
- package/plugins/immune-brain/runtime/kernel/batch_authority.ts +10 -6
- package/plugins/immune-brain/runtime/kernel/canary_application.ts +50 -63
- package/plugins/immune-brain/runtime/kernel/canary_eligibility.ts +13 -4
- package/plugins/immune-brain/runtime/kernel/completion.ts +5 -14
- package/plugins/immune-brain/runtime/kernel/enrollment.ts +124 -34
- package/plugins/immune-brain/runtime/kernel/enrollment_authority.ts +13 -5
- package/plugins/immune-brain/runtime/kernel/index.ts +3 -1
- package/plugins/immune-brain/runtime/kernel/intent.ts +7 -11
- package/plugins/immune-brain/runtime/kernel/legacy_audit.ts +4 -1
- package/plugins/immune-brain/runtime/kernel/legacy_task_record.ts +323 -0
- package/plugins/immune-brain/runtime/kernel/pi_canary_prepare.ts +10 -1
- package/plugins/immune-brain/runtime/kernel/reducer.ts +32 -31
- package/plugins/immune-brain/runtime/kernel/run_identity.ts +121 -0
- package/plugins/immune-brain/runtime/kernel/spec_binding.ts +100 -0
- package/plugins/immune-brain/runtime/kernel/sqlite_migration.ts +950 -0
- package/plugins/immune-brain/runtime/kernel/sqlite_store.ts +1193 -0
- package/plugins/immune-brain/runtime/kernel/storage.ts +1254 -1206
- package/plugins/immune-brain/runtime/kernel/storage_layout_migration.ts +129 -755
- package/plugins/immune-brain/runtime/kernel/storage_paths.ts +419 -46
- package/plugins/immune-brain/runtime/kernel/types.ts +12 -43
- package/plugins/immune-brain/runtime/kernel/validation.ts +60 -274
- package/plugins/immune-brain/runtime/managed_task_routing_policy.ts +0 -1
- package/plugins/immune-brain/runtime/plan_core.ts +27 -65
- package/plugins/immune-brain/runtime/plugin_version.ts +1 -1
- package/plugins/immune-brain/runtime/prompts/code-review.md +3 -1
- package/plugins/immune-brain/runtime/prompts/executor.md +4 -4
- package/plugins/immune-brain/runtime/staged_intent.ts +58 -0
- package/plugins/immune-brain/runtime/unattended/batch_git.ts +37 -7
- package/plugins/immune-brain/runtime/unattended/batch_plan.ts +42 -2
- package/plugins/immune-brain/runtime/unattended/batch_preflight.ts +771 -0
- package/plugins/immune-brain/runtime/unattended/batch_reasons.ts +189 -0
- package/plugins/immune-brain/runtime/unattended/batch_runner.ts +35 -0
- package/plugins/immune-brain/runtime/unattended/confirmation_deadline.ts +33 -0
- package/plugins/immune-brain/runtime/unattended/types.ts +14 -1
- package/plugins/immune-brain/runtime/v4_runtime.ts +19 -23
- package/plugins/immune-brain/runtime/verification_descriptor.ts +92 -136
- package/plugins/immune-brain/runtime/workspace_scope.ts +98 -13
- package/plugins/immune-brain/skills/imm-planner/SKILL.md +3 -3
- package/plugins/immune-brain/skills/imm-review-retro/SKILL.md +23 -0
- package/plugins/immune-brain/skills/imm-review-retro/scripts/review_retro.ts +355 -0
- package/plugins/immune-brain/skills/registry.yaml +9 -0
- package/plugins/immune-brain/bin/imm-retire-stale-wrapper +0 -4
- package/plugins/immune-brain/bin/imm-retired +0 -4
- package/plugins/immune-brain/runtime/authority_commit_receipts.ts +0 -716
- package/plugins/immune-brain/runtime/kernel/automatic_observations.ts +0 -451
- package/plugins/immune-brain/runtime/kernel/legacy.ts +0 -299
- package/plugins/immune-brain/runtime/kernel/observation.ts +0 -397
- package/plugins/immune-brain/runtime/kernel/readiness.ts +0 -282
- package/plugins/immune-brain/runtime/kernel/readiness_evidence.ts +0 -132
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Spec binding ownership. A simple TaskIntent binds no Spec. A complex
|
|
2
|
+
// TaskIntent binds at most one active Spec by path; freeze records Git
|
|
3
|
+
// content identity without relocating source files. Archive paths are
|
|
4
|
+
// historical evidence, not a freeze requirement.
|
|
5
|
+
|
|
6
|
+
import type { TaskIntentV1 } from "./types";
|
|
7
|
+
import { readSecureProjectFile } from "./storage";
|
|
8
|
+
import { KernelInvariantError } from "./validation";
|
|
9
|
+
|
|
10
|
+
const ACTIVE_SPEC_RE = /^docs\/specs\/(?!archive\/)[^/]+\.spec\.md$/;
|
|
11
|
+
const ARCHIVED_SPEC_RE = /^docs\/specs\/archive\/[^/]+\.spec\.md$/;
|
|
12
|
+
|
|
13
|
+
/** The archive counterpart of an active planning-artifact path. */
|
|
14
|
+
export function archivePath(path: string): string {
|
|
15
|
+
const matched = path.match(/^docs\/(plans|specs)\/([^/]+)$/);
|
|
16
|
+
if (!matched) throw new KernelInvariantError([`artifact path is not active: ${path}`]);
|
|
17
|
+
return `docs/${matched[1]}/archive/${matched[2]}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The inverse of `archivePath`, for an already-archived Spec path. */
|
|
21
|
+
export function activePath(path: string): string {
|
|
22
|
+
const matched = path.match(/^docs\/(plans|specs)\/archive\/([^/]+)$/);
|
|
23
|
+
if (!matched) throw new KernelInvariantError([`artifact path is not archived: ${path}`]);
|
|
24
|
+
return `docs/${matched[1]}/${matched[2]}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The active Spec the intent binds, or `undefined` when it binds none.
|
|
29
|
+
* Archive counterparts are not part of the binding predicate.
|
|
30
|
+
*/
|
|
31
|
+
export function boundSpecPath(intent: TaskIntentV1): string | undefined {
|
|
32
|
+
const candidates = intent.scope_hint.filter((path) => ACTIVE_SPEC_RE.test(path));
|
|
33
|
+
if (candidates.length > 1)
|
|
34
|
+
throw new KernelInvariantError([`artifact transition requires at most one scope-bound Spec; found ${candidates.length}`]);
|
|
35
|
+
return candidates[0];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Bound Spec bytes when the intent names one. Simple intents have none.
|
|
40
|
+
* `required` still fails closed for callers that demand a Spec.
|
|
41
|
+
*/
|
|
42
|
+
export function readBoundActiveSpec(
|
|
43
|
+
root: string,
|
|
44
|
+
intent: TaskIntentV1,
|
|
45
|
+
required = false,
|
|
46
|
+
): { path: string; content: string } | undefined {
|
|
47
|
+
const specPath = boundSpecPath(intent);
|
|
48
|
+
if (!specPath) {
|
|
49
|
+
if (required) throw new KernelInvariantError(["artifact freeze requires one scope-bound active Spec"]);
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return { path: specPath, content: readSecureProjectFile(root, specPath) };
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (error instanceof Error && error.message.startsWith("source_missing:") && !required) return undefined;
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface BoundSpec {
|
|
61
|
+
active: string;
|
|
62
|
+
archive: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type SpecBindingInspection =
|
|
66
|
+
| { ok: true; binding: BoundSpec | null }
|
|
67
|
+
| {
|
|
68
|
+
ok: false;
|
|
69
|
+
code: "binding_missing" | "binding_incomplete" | "binding_ambiguous";
|
|
70
|
+
missing: string[];
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Enrollment and validate caller: a missing Spec is a simple task; a
|
|
76
|
+
* malformed or incomplete complex binding is refused before any write.
|
|
77
|
+
*/
|
|
78
|
+
export function inspectSpecBinding(intent: TaskIntentV1): SpecBindingInspection {
|
|
79
|
+
const active = intent.scope_hint.filter((path) => ACTIVE_SPEC_RE.test(path));
|
|
80
|
+
const archived = intent.scope_hint.filter((path) => ARCHIVED_SPEC_RE.test(path));
|
|
81
|
+
if (active.length === 0 && archived.length === 0)
|
|
82
|
+
return { ok: true, binding: null };
|
|
83
|
+
if (active.length > 1)
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
code: "binding_ambiguous",
|
|
87
|
+
missing: [],
|
|
88
|
+
message: `enrollment requires at most one scope-bound Spec; found ${active.length}: ${active.join(", ")}`,
|
|
89
|
+
};
|
|
90
|
+
if (active.length === 0) {
|
|
91
|
+
const missing = archived.map((path) => activePath(path));
|
|
92
|
+
return {
|
|
93
|
+
ok: false,
|
|
94
|
+
code: "binding_incomplete",
|
|
95
|
+
missing,
|
|
96
|
+
message: `complex Spec binding is incomplete; add ${missing.join(", ")}`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { ok: true, binding: { active: active[0]!, archive: archivePath(active[0]!) } };
|
|
100
|
+
}
|