immune-brain 2.8.2
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 +239 -0
- package/README.zh-CN.md +239 -0
- package/package.json +84 -0
- package/plugins/immune-brain/.pi-extension/imm-canary-enroll.ts +666 -0
- package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +1622 -0
- package/plugins/immune-brain/.pi-extension/package.json +11 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-assurance-progression.ts +711 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-assurance.ts +154 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-interaction.ts +349 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-invocations.ts +90 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-native-review.ts +214 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-qa-findings.ts +50 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-review-bundle.ts +262 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-tool-failure.ts +28 -0
- package/plugins/immune-brain/.pi-extension/pi-canary-verification.ts +237 -0
- package/plugins/immune-brain/.pi-extension/runtime-stub.ts +414 -0
- package/plugins/immune-brain/.pi-extension/tsconfig.json +20 -0
- package/plugins/immune-brain/bin/imm-kernel +4 -0
- package/plugins/immune-brain/bin/imm-plan +4 -0
- package/plugins/immune-brain/bin/imm-pr-diag +230 -0
- package/plugins/immune-brain/bin/imm-retire-stale-wrapper +4 -0
- package/plugins/immune-brain/bin/imm-retired +4 -0
- package/plugins/immune-brain/bin/imm-tracker +4 -0
- package/plugins/immune-brain/dist/BASELINE.md +138 -0
- package/plugins/immune-brain/dist/docs/reference/HANDOFF-template.md +122 -0
- package/plugins/immune-brain/dist/docs/reference/design-contract-audit-rubric.md +149 -0
- package/plugins/immune-brain/dist/docs/reference/design-contract-review-checklist.md +55 -0
- package/plugins/immune-brain/dist/docs/reference/i18n-review-checklist.md +110 -0
- package/plugins/immune-brain/dist/docs/reference/immune-brain-config.md +52 -0
- package/plugins/immune-brain/dist/docs/reference/planning-artifact-retention.md +94 -0
- package/plugins/immune-brain/dist/docs/reference/planning-quality-gate.md +44 -0
- package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +105 -0
- package/plugins/immune-brain/dist/docs/reference/ux-heuristic-checklist.md +131 -0
- package/plugins/immune-brain/dist/imm-brainstorm.md +140 -0
- package/plugins/immune-brain/dist/imm-doc-prune.md +137 -0
- package/plugins/immune-brain/dist/imm-loop.md +158 -0
- package/plugins/immune-brain/dist/imm-planner.md +387 -0
- package/plugins/immune-brain/dist/imm-pr-fix.md +71 -0
- package/plugins/immune-brain/dist/registry.yaml +49 -0
- package/plugins/immune-brain/dist/role-prompts/advisory-reviewer.md +16 -0
- package/plugins/immune-brain/dist/role-prompts/arch-explorer.md +14 -0
- package/plugins/immune-brain/dist/role-prompts/code-review.md +15 -0
- package/plugins/immune-brain/dist/role-prompts/compounder.md +20 -0
- package/plugins/immune-brain/dist/role-prompts/executor.md +13 -0
- package/plugins/immune-brain/dist/role-prompts/pr-fix.md +81 -0
- package/plugins/immune-brain/dist/role-prompts/qa.md +23 -0
- package/plugins/immune-brain/dist/role-prompts/test-fixer.md +3 -0
- package/plugins/immune-brain/dist/role-prompts/ui-review.md +14 -0
- package/plugins/immune-brain/runtime/authority_commit_receipts.ts +716 -0
- package/plugins/immune-brain/runtime/canonical_json.ts +19 -0
- package/plugins/immune-brain/runtime/commands/kernel.ts +1160 -0
- package/plugins/immune-brain/runtime/github_issue_tracker.ts +1009 -0
- package/plugins/immune-brain/runtime/kernel/application.ts +300 -0
- package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +284 -0
- package/plugins/immune-brain/runtime/kernel/authority_port.ts +208 -0
- package/plugins/immune-brain/runtime/kernel/automatic_observations.ts +451 -0
- package/plugins/immune-brain/runtime/kernel/backend_claim.ts +197 -0
- package/plugins/immune-brain/runtime/kernel/canary_application.ts +507 -0
- package/plugins/immune-brain/runtime/kernel/canary_eligibility.ts +73 -0
- package/plugins/immune-brain/runtime/kernel/completion.ts +160 -0
- package/plugins/immune-brain/runtime/kernel/enrollment.ts +194 -0
- package/plugins/immune-brain/runtime/kernel/enrollment_authority.ts +123 -0
- package/plugins/immune-brain/runtime/kernel/index.ts +29 -0
- package/plugins/immune-brain/runtime/kernel/intent.ts +563 -0
- package/plugins/immune-brain/runtime/kernel/intent_token_registry.ts +80 -0
- package/plugins/immune-brain/runtime/kernel/legacy.ts +299 -0
- package/plugins/immune-brain/runtime/kernel/legacy_audit.ts +153 -0
- package/plugins/immune-brain/runtime/kernel/observation.ts +395 -0
- package/plugins/immune-brain/runtime/kernel/pi_canary_prepare.ts +169 -0
- package/plugins/immune-brain/runtime/kernel/readiness.ts +282 -0
- package/plugins/immune-brain/runtime/kernel/readiness_evidence.ts +132 -0
- package/plugins/immune-brain/runtime/kernel/reducer.ts +624 -0
- package/plugins/immune-brain/runtime/kernel/storage.ts +1780 -0
- package/plugins/immune-brain/runtime/kernel/storage_layout_migration.ts +791 -0
- package/plugins/immune-brain/runtime/kernel/storage_paths.ts +492 -0
- package/plugins/immune-brain/runtime/kernel/types.ts +295 -0
- package/plugins/immune-brain/runtime/kernel/validation.ts +963 -0
- package/plugins/immune-brain/runtime/loop_contract.ts +362 -0
- package/plugins/immune-brain/runtime/managed_task_routing_policy.ts +462 -0
- package/plugins/immune-brain/runtime/plan_core.ts +1053 -0
- package/plugins/immune-brain/runtime/prompts/advisory-reviewer.md +16 -0
- package/plugins/immune-brain/runtime/prompts/arch-explorer.md +14 -0
- package/plugins/immune-brain/runtime/prompts/code-review.md +15 -0
- package/plugins/immune-brain/runtime/prompts/compounder.md +20 -0
- package/plugins/immune-brain/runtime/prompts/executor.md +13 -0
- package/plugins/immune-brain/runtime/prompts/pr-fix.md +81 -0
- package/plugins/immune-brain/runtime/prompts/qa.md +23 -0
- package/plugins/immune-brain/runtime/prompts/test-fixer.md +3 -0
- package/plugins/immune-brain/runtime/prompts/ui-review.md +14 -0
- package/plugins/immune-brain/runtime/role_prompt_bridge.ts +160 -0
- package/plugins/immune-brain/runtime/v4_runtime.ts +295 -0
- package/plugins/immune-brain/runtime/verification_descriptor.ts +162 -0
- package/plugins/immune-brain/runtime/workspace_scope.ts +623 -0
- package/plugins/immune-brain/skills/.ignore +1 -0
- package/plugins/immune-brain/skills/BASELINE.md +138 -0
- package/plugins/immune-brain/skills/imm-brainstorm/SKILL.md +66 -0
- package/plugins/immune-brain/skills/imm-doc-prune/SKILL.md +11 -0
- package/plugins/immune-brain/skills/imm-loop/SKILL.md +52 -0
- package/plugins/immune-brain/skills/imm-planner/SKILL.md +221 -0
- package/plugins/immune-brain/skills/imm-pr-fix/SKILL.md +10 -0
- package/plugins/immune-brain/skills/registry.yaml +49 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Shared verification_descriptor/v1 pure parser.
|
|
2
|
+
//
|
|
3
|
+
// The complete `acceptance[].verification` string of a TaskIntent is accepted
|
|
4
|
+
// only as strict canonical JSON for `assurance_kernel/verification_descriptor/v1`.
|
|
5
|
+
// Never execute free text, an executable path, a shell string, PATH lookup,
|
|
6
|
+
// environment overrides, or a cwd outside the repository. The production runner
|
|
7
|
+
// registry contains only the host-resolved `bun` runner.
|
|
8
|
+
//
|
|
9
|
+
// This module is the single parser implementation for the wire contract. Pi
|
|
10
|
+
// assurance (`.pi-extension/pi-canary-verification.ts`) re-exports it and keeps
|
|
11
|
+
// runner resolution/execution extension-owned. Kernel intent author/validate
|
|
12
|
+
// consume the same implementation, so the two consumers cannot drift.
|
|
13
|
+
//
|
|
14
|
+
// JSON whitespace and key ordering are NOT eligibility conditions: parsing is
|
|
15
|
+
// whitespace/order-insensitive. `canonicalDescriptorBytes` produces the
|
|
16
|
+
// deterministic bytes that Planner authoring binds.
|
|
17
|
+
|
|
18
|
+
import { isAbsolute, sep } from "node:path";
|
|
19
|
+
|
|
20
|
+
export const VERIFICATION_DESCRIPTOR_CONTRACT =
|
|
21
|
+
"assurance_kernel/verification_descriptor/v1" as const;
|
|
22
|
+
|
|
23
|
+
export interface VerificationDescriptor {
|
|
24
|
+
contract: typeof VERIFICATION_DESCRIPTOR_CONTRACT;
|
|
25
|
+
runner_id: "bun";
|
|
26
|
+
runner_version: string;
|
|
27
|
+
argv: string[];
|
|
28
|
+
cwd: string;
|
|
29
|
+
timeout_ms: number;
|
|
30
|
+
max_output_bytes: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DESCRIPTOR_FIELDS = [
|
|
34
|
+
"contract",
|
|
35
|
+
"runner_id",
|
|
36
|
+
"runner_version",
|
|
37
|
+
"argv",
|
|
38
|
+
"cwd",
|
|
39
|
+
"timeout_ms",
|
|
40
|
+
"max_output_bytes",
|
|
41
|
+
] as const;
|
|
42
|
+
|
|
43
|
+
const MAX_ARGV_TOKENS = 64;
|
|
44
|
+
const MAX_ARGV_TOKEN_BYTES = 512;
|
|
45
|
+
const MAX_CWD_DEPTH = 32;
|
|
46
|
+
const MAX_TIMEOUT_MS = 600_000;
|
|
47
|
+
const MAX_OUTPUT_BYTES = 262_144;
|
|
48
|
+
|
|
49
|
+
export class VerificationDescriptorError extends Error {
|
|
50
|
+
constructor(message: string) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = "VerificationDescriptorError";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Parse the complete verification string as strict canonical JSON. */
|
|
57
|
+
export function parseVerificationDescriptor(text: string): VerificationDescriptor {
|
|
58
|
+
const trimmed = text.trim();
|
|
59
|
+
if (!trimmed) throw new VerificationDescriptorError("verification string is empty");
|
|
60
|
+
let raw: Record<string, unknown>;
|
|
61
|
+
try {
|
|
62
|
+
raw = JSON.parse(trimmed) as Record<string, unknown>;
|
|
63
|
+
} catch {
|
|
64
|
+
throw new VerificationDescriptorError("verification string is not valid JSON");
|
|
65
|
+
}
|
|
66
|
+
const unknown = Object.keys(raw).filter((key) => !DESCRIPTOR_FIELDS.includes(key as never));
|
|
67
|
+
if (unknown.length > 0)
|
|
68
|
+
throw new VerificationDescriptorError(`verification descriptor has unknown field: ${unknown[0]}`);
|
|
69
|
+
if (raw.contract !== VERIFICATION_DESCRIPTOR_CONTRACT)
|
|
70
|
+
throw new VerificationDescriptorError("verification descriptor contract is invalid");
|
|
71
|
+
if (raw.runner_id !== "bun")
|
|
72
|
+
throw new VerificationDescriptorError(
|
|
73
|
+
`verification runner must be bun; got ${String(raw.runner_id)}`,
|
|
74
|
+
);
|
|
75
|
+
if (typeof raw.runner_version !== "string" || !raw.runner_version.trim())
|
|
76
|
+
throw new VerificationDescriptorError("verification runner_version is invalid");
|
|
77
|
+
if (!Array.isArray(raw.argv) || raw.argv.length === 0)
|
|
78
|
+
throw new VerificationDescriptorError("verification argv must be a non-empty array");
|
|
79
|
+
if (raw.argv.length > MAX_ARGV_TOKENS)
|
|
80
|
+
throw new VerificationDescriptorError("verification argv exceeds the token bound");
|
|
81
|
+
for (const token of raw.argv) {
|
|
82
|
+
if (typeof token !== "string" || !token.trim())
|
|
83
|
+
throw new VerificationDescriptorError("verification argv tokens must be non-empty strings");
|
|
84
|
+
if (Buffer.byteLength(token) > MAX_ARGV_TOKEN_BYTES)
|
|
85
|
+
throw new VerificationDescriptorError("verification argv token exceeds the byte bound");
|
|
86
|
+
if (/[\x00-\x1f\x7f]/.test(token))
|
|
87
|
+
throw new VerificationDescriptorError("verification argv token contains control characters");
|
|
88
|
+
if (
|
|
89
|
+
token.includes("..") ||
|
|
90
|
+
token.includes("\\") ||
|
|
91
|
+
token.startsWith("/") ||
|
|
92
|
+
token.startsWith("~") ||
|
|
93
|
+
token.includes("$") ||
|
|
94
|
+
token.includes(";") ||
|
|
95
|
+
token.includes("&") ||
|
|
96
|
+
token.includes("|") ||
|
|
97
|
+
token.includes(">") ||
|
|
98
|
+
token.includes("<") ||
|
|
99
|
+
token.includes("`") ||
|
|
100
|
+
token.includes("*") ||
|
|
101
|
+
token.includes("?") ||
|
|
102
|
+
token.includes("[") ||
|
|
103
|
+
token.includes("]") ||
|
|
104
|
+
token.includes("{") ||
|
|
105
|
+
token.includes("}") ||
|
|
106
|
+
token.includes("(") ||
|
|
107
|
+
token.includes(")") ||
|
|
108
|
+
token.includes(" ") ||
|
|
109
|
+
token.includes("\t")
|
|
110
|
+
)
|
|
111
|
+
throw new VerificationDescriptorError(
|
|
112
|
+
`verification argv token is not a safe literal: ${token}`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (typeof raw.cwd !== "string" || !raw.cwd.trim())
|
|
116
|
+
throw new VerificationDescriptorError("verification cwd is invalid");
|
|
117
|
+
if (isAbsolute(raw.cwd) || raw.cwd.includes("\\"))
|
|
118
|
+
throw new VerificationDescriptorError("verification cwd must be repository-relative");
|
|
119
|
+
if (raw.cwd === ".." || raw.cwd.startsWith(`..${sep}`) || raw.cwd.split(sep).includes(".."))
|
|
120
|
+
throw new VerificationDescriptorError("verification cwd escapes the repository");
|
|
121
|
+
if (raw.cwd.split(sep).filter(Boolean).length > MAX_CWD_DEPTH)
|
|
122
|
+
throw new VerificationDescriptorError("verification cwd exceeds the depth bound");
|
|
123
|
+
if (typeof raw.timeout_ms !== "number" || !Number.isFinite(raw.timeout_ms) || raw.timeout_ms < 1)
|
|
124
|
+
throw new VerificationDescriptorError("verification timeout_ms must be a finite positive integer");
|
|
125
|
+
if (!Number.isInteger(raw.timeout_ms) || raw.timeout_ms > MAX_TIMEOUT_MS)
|
|
126
|
+
throw new VerificationDescriptorError("verification timeout_ms exceeds the host ceiling");
|
|
127
|
+
if (
|
|
128
|
+
typeof raw.max_output_bytes !== "number" ||
|
|
129
|
+
!Number.isFinite(raw.max_output_bytes) ||
|
|
130
|
+
raw.max_output_bytes < 1
|
|
131
|
+
)
|
|
132
|
+
throw new VerificationDescriptorError(
|
|
133
|
+
"verification max_output_bytes must be a finite positive integer",
|
|
134
|
+
);
|
|
135
|
+
if (!Number.isInteger(raw.max_output_bytes) || raw.max_output_bytes > MAX_OUTPUT_BYTES)
|
|
136
|
+
throw new VerificationDescriptorError(
|
|
137
|
+
"verification max_output_bytes exceeds the host ceiling",
|
|
138
|
+
);
|
|
139
|
+
return {
|
|
140
|
+
contract: VERIFICATION_DESCRIPTOR_CONTRACT,
|
|
141
|
+
runner_id: "bun",
|
|
142
|
+
runner_version: raw.runner_version,
|
|
143
|
+
argv: raw.argv as string[],
|
|
144
|
+
cwd: raw.cwd,
|
|
145
|
+
timeout_ms: raw.timeout_ms,
|
|
146
|
+
max_output_bytes: raw.max_output_bytes,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Canonical bytes of the parsed descriptor (for digest binding). */
|
|
151
|
+
export function canonicalDescriptorBytes(descriptor: VerificationDescriptor): string {
|
|
152
|
+
return `${JSON.stringify(descriptor, null, 2)}\n`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Re-exported bounds for host-side consistency checks. */
|
|
156
|
+
export const VERIFICATION_DESCRIPTOR_BOUNDS = {
|
|
157
|
+
max_arg_tokens: MAX_ARGV_TOKENS,
|
|
158
|
+
max_arg_token_bytes: MAX_ARGV_TOKEN_BYTES,
|
|
159
|
+
max_cwd_depth: MAX_CWD_DEPTH,
|
|
160
|
+
max_timeout_ms: MAX_TIMEOUT_MS,
|
|
161
|
+
max_output_bytes: MAX_OUTPUT_BYTES,
|
|
162
|
+
} as const;
|