@holmes-lab/holmes-kit 0.35.25 → 0.36.1
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/CHANGELOG.md +346 -0
- package/README.md +3 -2
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-status.js +4 -1
- package/dist/holmes/cli/approve-watch.js +3 -1
- package/dist/holmes/cli/approve.d.ts +10 -0
- package/dist/holmes/cli/approve.js +31 -1
- package/dist/holmes/cli/claude-switches.d.ts +7 -1
- package/dist/holmes/cli/claude-switches.js +11 -7
- package/dist/holmes/cli/codex-toml.d.ts +3 -0
- package/dist/holmes/cli/codex-toml.js +2 -1
- package/dist/holmes/cli/doctor.d.ts +25 -1
- package/dist/holmes/cli/doctor.js +153 -7
- package/dist/holmes/cli/index.js +99 -4
- package/dist/holmes/cli/init.js +4 -3
- package/dist/holmes/cli/os-notify.d.ts +3 -1
- package/dist/holmes/cli/os-notify.js +10 -4
- package/dist/holmes/cli/review.d.ts +25 -0
- package/dist/holmes/cli/review.js +111 -0
- package/dist/holmes/cli/roles-readme.d.ts +11 -0
- package/dist/holmes/cli/roles-readme.js +38 -16
- package/dist/holmes/cli/roles.d.ts +12 -0
- package/dist/holmes/cli/roles.js +86 -0
- package/dist/holmes/cli/run.d.ts +65 -0
- package/dist/holmes/cli/run.js +308 -0
- package/dist/holmes/cli/runtime-binding.d.ts +30 -0
- package/dist/holmes/cli/runtime-binding.js +96 -7
- package/dist/holmes/cli/test-platform.d.ts +16 -0
- package/dist/holmes/cli/test-platform.js +31 -1
- package/dist/holmes/config/config.d.ts +49 -0
- package/dist/holmes/config/config.js +146 -3
- package/dist/holmes/config/project-caps.d.ts +21 -0
- package/dist/holmes/config/project-caps.js +114 -0
- package/dist/holmes/governance/approval-queue.d.ts +17 -3
- package/dist/holmes/governance/approval-queue.js +48 -6
- package/dist/holmes/governance/autonomy.d.ts +6 -0
- package/dist/holmes/governance/autonomy.js +21 -0
- package/dist/holmes/governance/push-gate-runner.d.ts +8 -0
- package/dist/holmes/governance/push-gate-runner.js +49 -1
- package/dist/holmes/governance/replica-id.d.ts +9 -0
- package/dist/holmes/governance/replica-id.js +44 -7
- package/dist/holmes/governance/role-policy.d.ts +41 -1
- package/dist/holmes/governance/role-policy.js +137 -20
- package/dist/holmes/governance/run-mode.d.ts +14 -0
- package/dist/holmes/governance/run-mode.js +120 -0
- package/dist/holmes/governance/tool-actions.d.ts +30 -0
- package/dist/holmes/governance/tool-actions.js +121 -0
- package/dist/holmes/guardrail/agent-launch-policy.d.ts +15 -0
- package/dist/holmes/guardrail/agent-launch-policy.js +177 -0
- package/dist/holmes/guardrail/classification-mode.d.ts +17 -0
- package/dist/holmes/guardrail/classification-mode.js +135 -0
- package/dist/holmes/guardrail/dynamic-write.d.ts +43 -0
- package/dist/holmes/guardrail/dynamic-write.js +304 -0
- package/dist/holmes/guardrail/phase.d.ts +2 -1
- package/dist/holmes/guardrail/phase.js +22 -8
- package/dist/holmes/guardrail/powershell-shell.d.ts +21 -0
- package/dist/holmes/guardrail/powershell-shell.js +801 -0
- package/dist/holmes/guardrail/refusal-codes.d.ts +24 -0
- package/dist/holmes/guardrail/refusal-codes.js +141 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +17 -0
- package/dist/holmes/guardrail/risk-classifier.js +242 -26
- package/dist/holmes/guardrail/risk-types.d.ts +15 -0
- package/dist/holmes/guardrail/run-plan-scope.d.ts +23 -0
- package/dist/holmes/guardrail/run-plan-scope.js +155 -0
- package/dist/holmes/guardrail/run-refusals.d.ts +116 -0
- package/dist/holmes/guardrail/run-refusals.js +348 -0
- package/dist/holmes/guardrail/run-stages.d.ts +67 -0
- package/dist/holmes/guardrail/run-stages.js +188 -0
- package/dist/holmes/guardrail/scope-judgment.d.ts +5 -1
- package/dist/holmes/guardrail/scope-judgment.js +8 -10
- package/dist/holmes/guardrail/scope-refusal-memory.d.ts +3 -0
- package/dist/holmes/guardrail/scope-refusal-memory.js +85 -0
- package/dist/holmes/guardrail/shell-words.js +7 -7
- package/dist/holmes/guardrail/write-target.d.ts +31 -2
- package/dist/holmes/guardrail/write-target.js +118 -16
- package/dist/holmes/hooks/adapters/antigravity.d.ts +1 -1
- package/dist/holmes/hooks/adapters/antigravity.js +6 -2
- package/dist/holmes/hooks/pre-tool-use.d.ts +55 -2
- package/dist/holmes/hooks/pre-tool-use.js +749 -89
- package/dist/holmes/hooks/session-start.js +5 -3
- package/dist/holmes/hooks/stop.d.ts +32 -0
- package/dist/holmes/hooks/stop.js +129 -4
- package/dist/holmes/mcp/handlers/graph-operations.js +5 -5
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +2 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -1
- package/dist/holmes/mcp/handlers/operator-inspection.js +3 -1
- package/dist/holmes/mcp/handlers/phase-queries.js +16 -1
- package/dist/holmes/mcp/handlers/requirement-triage.js +2 -2
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -3
- package/dist/holmes/mcp/handlers/spec-approval.js +54 -8
- package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +1 -0
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +3 -3
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +7 -0
- package/dist/holmes/mcp/handlers/spec-queries.js +5 -0
- package/dist/holmes/mcp/handlers/workspace-queries.js +2 -2
- package/dist/holmes/mcp/handlers.d.ts +2 -3
- package/dist/holmes/mcp/handlers.js +22 -2
- package/dist/holmes/mcp/harness-attestation.d.ts +2 -0
- package/dist/holmes/mcp/harness-attestation.js +3 -1
- package/dist/holmes/mcp/operator-recovery.d.ts +2 -0
- package/dist/holmes/mcp/operator-recovery.js +4 -3
- package/dist/holmes/mcp/server.js +9 -0
- package/dist/holmes/mcp/tool-schemas.js +6 -3
- package/dist/holmes/project/root.js +6 -1
- package/dist/holmes/project/run-records.d.ts +17 -0
- package/dist/holmes/project/run-records.js +126 -0
- package/dist/holmes/review/mrp.d.ts +35 -0
- package/dist/holmes/review/mrp.js +119 -0
- package/dist/holmes/review/verdicts.d.ts +117 -0
- package/dist/holmes/review/verdicts.js +345 -0
- package/dist/holmes/semantic/cloud-usage.d.ts +20 -0
- package/dist/holmes/semantic/cloud-usage.js +106 -0
- package/dist/holmes/semantic/embedder.d.ts +15 -6
- package/dist/holmes/semantic/embedder.js +84 -3
- package/dist/holmes/semantic/local-model.d.ts +21 -2
- package/dist/holmes/semantic/local-model.js +14 -3
- package/dist/holmes/semantic/tier.d.ts +25 -0
- package/dist/holmes/semantic/tier.js +86 -1
- package/dist/holmes/semantic/vector-cache.d.ts +1 -0
- package/dist/holmes/semantic/vector-cache.js +4 -1
- package/dist/holmes/spec/approval-blockers.d.ts +11 -1
- package/dist/holmes/spec/approval-blockers.js +70 -2
- package/dist/holmes/spec/renumber.d.ts +1 -1
- package/dist/holmes/spec/renumber.js +5 -2
- package/dist/holmes/spec/transition-policy.d.ts +5 -7
- package/dist/holmes/spec/transition-policy.js +17 -2
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createSpecLifecycleHandlers = createSpecLifecycleHandlers;
|
|
37
|
-
// @implements A-SPEC-628, A-SPEC-627.1, A-SPEC-621, A-SPEC-100.2, A-SPEC-128, A-SPEC-151, A-SPEC-222, A-SPEC-538.1, A-SPEC-255, A-SPEC-133, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245
|
|
37
|
+
// @implements A-SPEC-770.12, A-SPEC-628, A-SPEC-627.1, A-SPEC-621, A-SPEC-100.2, A-SPEC-128, A-SPEC-151, A-SPEC-222, A-SPEC-538.1, A-SPEC-255, A-SPEC-133, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245
|
|
38
38
|
// @implements A-SPEC-638
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
40
|
const spec_store_1 = require("../../spec/spec-store");
|
|
@@ -255,7 +255,7 @@ function createSpecLifecycleHandlers(context) {
|
|
|
255
255
|
reason: `${a.id}은(는) 봉인된 문서입니다 — 폐기는 이 행위를 덮는 유효한 대역외 HOLMES_APPROVAL 이 필요합니다.`
|
|
256
256
|
+ ' 코드 게이트를 막고 있는 approved T-SPEC 을 폐기하면 그 게이트가 열리므로, 폐기가 승인 우회 경로가 되지 않도록 fail-closed 로 막습니다.'
|
|
257
257
|
+ ' (범위를 쓰면 kind "spec-approve")'
|
|
258
|
-
+ context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '봉인된 스펙의 폐기' }),
|
|
258
|
+
+ context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '봉인된 스펙의 폐기', title: spec.title }),
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
// @implements A-SPEC-245 — a grant that authorized breaking a seal is spent by it.
|
|
@@ -484,7 +484,7 @@ function createSpecLifecycleHandlers(context) {
|
|
|
484
484
|
reason: `${a.id}은(는) 봉인된 문서입니다 — 봉인 해제는 이 행위를 덮는 유효한 대역외 HOLMES_APPROVAL 이 필요합니다.`
|
|
485
485
|
+ ' 봉인을 해제하면 코드 게이트가 요구하던 approved 스펙의 봉인이 사라지므로, 해제가 승인 우회 경로가 되지 않도록 fail-closed 로 막습니다.'
|
|
486
486
|
+ ' (범위를 쓰면 kind "spec-approve")'
|
|
487
|
-
+ context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '봉인된 스펙의 해제' }),
|
|
487
|
+
+ context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '봉인된 스펙의 해제', title: spec.title }),
|
|
488
488
|
};
|
|
489
489
|
}
|
|
490
490
|
// @implements A-SPEC-245 — a grant that authorized breaking a seal is spent by it.
|
|
@@ -3,6 +3,13 @@ export interface SpecQueryContext {
|
|
|
3
3
|
listSpecs(): Promise<Spec[]>;
|
|
4
4
|
assertStoreReachable(tool: string, root: unknown): void;
|
|
5
5
|
resolver(specs: Spec[]): (id: string) => Spec | null;
|
|
6
|
+
/** @implements A-SPEC-774.25 — the store the answer comes from; nulls for a store that is not a directory. */
|
|
7
|
+
storeIdentity(): {
|
|
8
|
+
projectRoot: string | null;
|
|
9
|
+
specsRoot: string | null;
|
|
10
|
+
};
|
|
11
|
+
foreignRootReason(root: string | undefined): string | null;
|
|
12
|
+
refusal(reason: string): Error;
|
|
6
13
|
}
|
|
7
14
|
type NextAction = {
|
|
8
15
|
id: string;
|
|
@@ -119,6 +119,10 @@ function createSpecQueryHandlers(context) {
|
|
|
119
119
|
const badLimit = (0, phase_queries_1.limitProblem)(a?.limit); // @implements A-SPEC-746 — refused before the corpus is read
|
|
120
120
|
if (badLimit)
|
|
121
121
|
return { ok: false, reason: badLimit };
|
|
122
|
+
// @implements A-SPEC-774.25 — a root naming another project is not answered from this store.
|
|
123
|
+
const foreign = context.foreignRootReason(typeof a?.root === 'string' ? a.root : undefined);
|
|
124
|
+
if (foreign)
|
|
125
|
+
throw context.refusal(foreign);
|
|
122
126
|
const specs = await context.listSpecs();
|
|
123
127
|
// @implements A-SPEC-186
|
|
124
128
|
// The parent travels with the id because a bare one cannot be read. Measured: a reader took
|
|
@@ -179,6 +183,7 @@ function createSpecQueryHandlers(context) {
|
|
|
179
183
|
note: 'More rows follow this page (total counts every matching row) — pass nextCursor as cursor to continue, or ask for specific specs with ids.',
|
|
180
184
|
} : {}),
|
|
181
185
|
...(page.unknownIds !== undefined ? { unknownIds: page.unknownIds, unknownIdsTotal: page.unknownIdsTotal } : {}),
|
|
186
|
+
store: context.storeIdentity(), // @implements A-SPEC-774.25
|
|
182
187
|
};
|
|
183
188
|
},
|
|
184
189
|
async spec_next(a) {
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createWorkspaceQueryHandlers = createWorkspaceQueryHandlers;
|
|
37
|
-
// @implements A-SPEC-610, A-SPEC-100.2, A-SPEC-121.2, A-SPEC-128, A-SPEC-131, A-SPEC-146, A-SPEC-189, A-SPEC-419, A-SPEC-461, A-SPEC-496, A-SPEC-506.1
|
|
37
|
+
// @implements A-SPEC-476.1, A-SPEC-610, A-SPEC-100.2, A-SPEC-121.2, A-SPEC-128, A-SPEC-131, A-SPEC-146, A-SPEC-189, A-SPEC-419, A-SPEC-461, A-SPEC-496, A-SPEC-506.1
|
|
38
38
|
const fs = __importStar(require("node:fs"));
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
40
|
const validator_1 = require("../../spec/validator");
|
|
@@ -177,7 +177,7 @@ function createWorkspaceQueryHandlers(context) {
|
|
|
177
177
|
try {
|
|
178
178
|
if (report.hits.length > 1
|
|
179
179
|
&& (0, localize_1.citationsIn)(a.issue, new Set(governed.map((s) => s.id))).cited.length === 0) {
|
|
180
|
-
const rt = (0, embedder_1.makeTierEmbedder)((0, tier_1.
|
|
180
|
+
const rt = (0, embedder_1.makeTierEmbedder)((0, tier_1.resolveProjectSemanticTier)(root), new vector_cache_1.VectorCache(root)); // A-SPEC-476.1
|
|
181
181
|
if (rt !== null) {
|
|
182
182
|
const qv = await rt.embedQuery(a.issue);
|
|
183
183
|
const docTextByFile = (0, vector_coverage_1.docTextIndex)(scanned);
|
|
@@ -1300,9 +1300,6 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
1300
1300
|
ok: false;
|
|
1301
1301
|
reason: string;
|
|
1302
1302
|
findings: import("../spec/validator").Finding[];
|
|
1303
|
-
candidate?: undefined;
|
|
1304
|
-
digest?: undefined;
|
|
1305
|
-
parentDigests?: undefined;
|
|
1306
1303
|
} | {
|
|
1307
1304
|
ok: boolean;
|
|
1308
1305
|
reason: string;
|
|
@@ -1328,6 +1325,8 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
1328
1325
|
blockers?: undefined;
|
|
1329
1326
|
approvalIntent?: undefined;
|
|
1330
1327
|
} | {
|
|
1328
|
+
ancestorWarning?: string | undefined;
|
|
1329
|
+
scaffoldWarning?: string | undefined;
|
|
1331
1330
|
dismissUnknown?: string[] | undefined;
|
|
1332
1331
|
advisoryHistory?: import("../rtm/advisory-outcomes").AdvisoryState[] | undefined;
|
|
1333
1332
|
advisoryIds?: Partial<Record<string, string>> | undefined;
|
|
@@ -39,7 +39,7 @@ exports.isHandlerRefusal = isHandlerRefusal;
|
|
|
39
39
|
exports.unreadableAmong = unreadableAmong;
|
|
40
40
|
exports.makeHandlers = makeHandlers;
|
|
41
41
|
exports.collectDecisions = collectDecisions;
|
|
42
|
-
// @implements A-SPEC-718.1, A-SPEC-718.2, A-SPEC-723, A-SPEC-723.1, A-SPEC-545.6, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627, A-SPEC-713, A-SPEC-732, A-SPEC-754
|
|
42
|
+
// @implements A-SPEC-774.25, A-SPEC-770.12, A-SPEC-718.1, A-SPEC-718.2, A-SPEC-723, A-SPEC-723.1, A-SPEC-545.6, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627, A-SPEC-713, A-SPEC-732, A-SPEC-754
|
|
43
43
|
const operator_recovery_1 = require("./operator-recovery");
|
|
44
44
|
// @implements A-SPEC-643
|
|
45
45
|
// @implements A-SPEC-642
|
|
@@ -230,7 +230,8 @@ function refusalQueueHint(rootArg, store, req, operation) {
|
|
|
230
230
|
if (base === undefined)
|
|
231
231
|
return '';
|
|
232
232
|
const root = projectRootOf(base);
|
|
233
|
-
|
|
233
|
+
// @implements A-SPEC-770.12 — the request's title rides into the queue and into the line the operator reads.
|
|
234
|
+
return (0, approval_queue_1.queueHint)(root, req, (0, operator_recovery_1.operatorRecovery)(root, req.target, operation, { label: (0, approval_queue_1.requestLabel)(req.kind, req.target, req.title) }));
|
|
234
235
|
}
|
|
235
236
|
catch {
|
|
236
237
|
return '';
|
|
@@ -239,6 +240,22 @@ function refusalQueueHint(rootArg, store, req, operation) {
|
|
|
239
240
|
function projectRootOf(root) {
|
|
240
241
|
return (0, root_1.resolveProjectRoot)(root).root;
|
|
241
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* @implements A-SPEC-774.25 — which store answered: its specs directory, and the project derived from it (null when
|
|
245
|
+
* that has no `.ax` marker). A store that is not a directory (an in-memory one) has neither.
|
|
246
|
+
*/
|
|
247
|
+
function specStoreIdentity(store) {
|
|
248
|
+
if (!(store instanceof spec_store_1.LocalMarkdownRepository))
|
|
249
|
+
return { projectRoot: null, specsRoot: null };
|
|
250
|
+
const specsRoot = path.resolve(store.specsRoot);
|
|
251
|
+
try {
|
|
252
|
+
const derived = projectRootOf(specsRoot);
|
|
253
|
+
return { projectRoot: fs.existsSync(path.join(derived, '.ax')) ? derived : null, specsRoot };
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return { projectRoot: null, specsRoot };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
242
259
|
// @implements A-SPEC-191 §10 — WHERE a single-use approval is spent must not be a caller's choice.
|
|
243
260
|
// r8 measured all three escapes at once: a second `root`, a `root` naming a subdirectory, and an
|
|
244
261
|
// omitted `root` (cwd-relative) each handed the same nonce a fresh, empty ledger — 'N-RISK' opened a
|
|
@@ -811,6 +828,9 @@ function makeRawHandlers(store, opts) {
|
|
|
811
828
|
listSpecs: () => store.list(),
|
|
812
829
|
assertStoreReachable: (tool, root) => assertSpecStoreReachable(tool, store, root),
|
|
813
830
|
resolver,
|
|
831
|
+
storeIdentity: () => specStoreIdentity(store), // @implements A-SPEC-774.25
|
|
832
|
+
foreignRootReason: root => foreignRootReason(store, root),
|
|
833
|
+
refusal: reason => new HandlerRefusal(reason),
|
|
814
834
|
});
|
|
815
835
|
// @implements A-SPEC-263.1
|
|
816
836
|
// The in-session approval channel: ask ONLY when (a) an elicitor was injected (the server wires
|
|
@@ -14,6 +14,8 @@ export interface HarnessAttestation {
|
|
|
14
14
|
harness?: string;
|
|
15
15
|
reason?: string;
|
|
16
16
|
}
|
|
17
|
+
/** Exported for A-SPEC-102.8 (review independence walks the same names). */
|
|
18
|
+
export declare function harnessOf(args: string, exe?: string): string | null;
|
|
17
19
|
/**
|
|
18
20
|
* @implements A-SPEC-751.3 — is `script` one of the operator runtime registry's own MCP dispatcher files, unchanged
|
|
19
21
|
* since its installation receipt. Measured 2026-10-04: A-SPEC-751 starts the server through
|
|
@@ -33,10 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.harnessOf = harnessOf;
|
|
36
37
|
exports.dispatcherVerifier = dispatcherVerifier;
|
|
37
38
|
exports.attestHarness = attestHarness;
|
|
38
39
|
exports.systemProcLookup = systemProcLookup;
|
|
39
|
-
// @implements A-SPEC-732, A-SPEC-751.3
|
|
40
|
+
// @implements A-SPEC-732, A-SPEC-751.3, A-SPEC-102.8
|
|
40
41
|
// In-session approval (a form, or the host-gated continuation) trusts the client that answers it. An
|
|
41
42
|
// agent can start its own copy of this server, name itself `claude-code` and answer for a person
|
|
42
43
|
// (measured, H7 round 1). So before offering either route, the server asks who launched it: the
|
|
@@ -78,6 +79,7 @@ const firstToken = (args) => {
|
|
|
78
79
|
return t.split(/\s+/)[0] ?? '';
|
|
79
80
|
};
|
|
80
81
|
const exeName = (args) => path.win32.basename(path.posix.basename(firstToken(args))).toLowerCase().replace(/\.exe$/, '');
|
|
82
|
+
/** Exported for A-SPEC-102.8 (review independence walks the same names). */
|
|
81
83
|
function harnessOf(args, exe) {
|
|
82
84
|
const name = exeName(args);
|
|
83
85
|
if (HARNESS_EXES.has(name))
|
|
@@ -3,6 +3,8 @@ export declare function operatorRecovery(root: string, target: string, operation
|
|
|
3
3
|
platform?: NodeJS.Platform;
|
|
4
4
|
executable?: string;
|
|
5
5
|
cli?: string;
|
|
6
|
+
/** @implements A-SPEC-770.12 — `requestLabel(kind, target, title)`, set inside the bracket after the id. */
|
|
7
|
+
label?: string;
|
|
6
8
|
}): {
|
|
7
9
|
reviewCommand: string;
|
|
8
10
|
pendingHint(id: string): string;
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.operatorRecovery = operatorRecovery;
|
|
37
|
-
// @implements A-SPEC-754, A-SPEC-532.3, A-SPEC-768
|
|
37
|
+
// @implements A-SPEC-754, A-SPEC-532.3, A-SPEC-768, A-SPEC-770.12
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
39
|
const unsafeDisplay = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/;
|
|
40
40
|
function literal(value, platform) {
|
|
@@ -42,6 +42,7 @@ function literal(value, platform) {
|
|
|
42
42
|
}
|
|
43
43
|
/** Formatting only: the caller must return pending text only after a successful enqueue. */
|
|
44
44
|
function operatorRecovery(root, target, operation, options) {
|
|
45
|
+
const label = options?.label ?? '';
|
|
45
46
|
const platform = options?.platform ?? process.platform;
|
|
46
47
|
const executable = options?.executable ?? process.execPath;
|
|
47
48
|
// Both src/holmes/mcp (tests) and dist/holmes/mcp (installed) have the same depth.
|
|
@@ -55,12 +56,12 @@ function operatorRecovery(root, target, operation, options) {
|
|
|
55
56
|
if (!/^req-[a-f0-9]{12}$/.test(id))
|
|
56
57
|
return '';
|
|
57
58
|
if (!command)
|
|
58
|
-
return `\n[승인 대기 ${id}] The request was recorded. Use the installed approval UI; a path exceeds the safe command display limit. No truncated command is provided.`;
|
|
59
|
+
return `\n[승인 대기 ${id}${label}] The request was recorded. Use the installed approval UI; a path exceeds the safe command display limit. No truncated command is provided.`;
|
|
59
60
|
// @implements A-SPEC-532.3 — the resident surface is offered beside the one-off command (owner, 2026-10-04:
|
|
60
61
|
// "why am I still pasting commands"): one key per arriving request.
|
|
61
62
|
// @implements A-SPEC-768 — the three lines above are the operator's; measured 2026-10-11 (HG arm) the agent read
|
|
62
63
|
// "keep the approval surface open" as its own instruction and polled a sealed spec 58 times. One line is the agent's.
|
|
63
|
-
return `\n[승인 대기 ${id}] 운영자: ${command} --grant ${literal(id, platform)}`
|
|
64
|
+
return `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${literal(id, platform)}`
|
|
64
65
|
+ `\nOr keep the approval surface open and decide each arriving request with one key: ${command} --watch`
|
|
65
66
|
+ `\nAfter official approval, retry ${operation ? display(operation) : 'the original MCP operation'} for target ${display(target)} in the same workspace. Do not retry until approval is available.`
|
|
66
67
|
+ '\nAgent: check approval_status for the target; sealed:true or request.state granted means retry now — polling a sealed spec is wasted; request.state held carries the operator\'s question.';
|
|
@@ -11,6 +11,8 @@ const tool_schemas_1 = require("./tool-schemas");
|
|
|
11
11
|
Object.defineProperty(exports, "HOOK_ENFORCED_TOOLS", { enumerable: true, get: function () { return tool_schemas_1.HOOK_ENFORCED_TOOLS; } });
|
|
12
12
|
const validate_args_1 = require("./validate-args");
|
|
13
13
|
const approval_adapters_1 = require("./approval-adapters");
|
|
14
|
+
const tool_actions_1 = require("../governance/tool-actions");
|
|
15
|
+
const identity_1 = require("../governance/identity");
|
|
14
16
|
// @implements A-SPEC-100.2
|
|
15
17
|
// @implements A-SPEC-652.2 — the store is opened at an ABSOLUTE path resolved against the project
|
|
16
18
|
// root (CLAUDE_PROJECT_DIR, then the nearest .mcp.json/.ax ancestor, then cwd), and the path is
|
|
@@ -175,11 +177,18 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (req) => {
|
|
|
175
177
|
// refusal is a plain `Error` thrown by a handler; a programming fault (TypeError, RangeError…)
|
|
176
178
|
// keeps failing loudly, because dressing a crash as an orderly refusal is how a bug becomes a
|
|
177
179
|
// policy decision in the caller's log.
|
|
180
|
+
// @implements A-SPEC-774 — the role is asked here, the one point all three harnesses share; a tool call carries
|
|
181
|
+
// no path field, so the hook let `spec_create` and `spec_remediate` through for a role that could only write tests.
|
|
182
|
+
const roleRefusal = fn && check.ok
|
|
183
|
+
? (0, tool_actions_1.toolRoleRefusal)(req.params.name, args, process.cwd(), new identity_1.EnvIdentityProvider().current())
|
|
184
|
+
: null;
|
|
178
185
|
let out;
|
|
179
186
|
if (!fn)
|
|
180
187
|
out = { error: 'unknown tool' };
|
|
181
188
|
else if (!check.ok)
|
|
182
189
|
out = check;
|
|
190
|
+
else if (roleRefusal)
|
|
191
|
+
out = { ok: false, reason: `${req.params.name}: ${roleRefusal}` };
|
|
183
192
|
else {
|
|
184
193
|
try {
|
|
185
194
|
out = await fn(args);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TOOL_SCHEMAS = exports.HOOK_ENFORCED_TOOLS = void 0;
|
|
4
|
-
// @implements A-SPEC-743, A-SPEC-736, A-SPEC-735, A-SPEC-729, A-SPEC-719, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-623, A-SPEC-277, A-SPEC-624, A-SPEC-627, A-SPEC-713
|
|
4
|
+
// @implements A-SPEC-743, A-SPEC-736, A-SPEC-735, A-SPEC-729, A-SPEC-719, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-623, A-SPEC-277, A-SPEC-624, A-SPEC-627, A-SPEC-713, A-SPEC-774.25, A-SPEC-255.1
|
|
5
5
|
// @implements A-SPEC-495 — the maintenance_analyze description carries the semantic-evidence
|
|
6
6
|
// consumer contract (sem-verify / semCos / semanticAlternates) beside the anti-prediction warning.
|
|
7
7
|
// @implements A-SPEC-642
|
|
@@ -176,7 +176,7 @@ exports.TOOL_SCHEMAS = {
|
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
spec_renumber: {
|
|
179
|
-
description: "Move a whole spec FAMILY (REQ/H-SPEC/A-SPEC/T-SPEC sharing one base, dot-suffixed members included) from one number to another, and report what a machine must not touch. The tool rewrites only places with a definite grammar: filenames, frontmatter `id`, every `depends_on` in the store, `slice` tags, and source `@implements` anchors. Prose — comments, test titles, CHANGELOG entries, `source.ref` citations — is REPORTED as candidates with file and line, never substituted: measured 2026-08-23, a bulk regex doing exactly that turned REQ-253's own source citation into a reference to itself, while a hand renumber left seven prose sites behind including a comment in the shipped install.ps1. Re-sealing is NOT performed here; `spec_approve` remains the only sealer. Instead the plan returns two orders, which are opposites because the two acts refuse in opposite directions: `unsealOrder` is child-first (spec_unseal refuses while an approved child depends on the target) and `approveOrder` is parent-first (spec_approve refuses while a parent is unsealed). A spec whose `depends_on` is
|
|
179
|
+
description: "Move a whole spec FAMILY (REQ/H-SPEC/A-SPEC/T-SPEC sharing one base, dot-suffixed members included) from one number to another, and report what a machine must not touch. The tool rewrites only places with a definite grammar: filenames, frontmatter `id`, every `depends_on` in the store, `slice` tags, and source `@implements` anchors. Prose — comments, test titles, CHANGELOG entries, `source.ref` citations — is REPORTED as candidates with file and line, never substituted: measured 2026-08-23, a bulk regex doing exactly that turned REQ-253's own source citation into a reference to itself, while a hand renumber left seven prose sites behind including a comment in the shipped install.ps1. Re-sealing is NOT performed here; `spec_approve` remains the only sealer. Instead the plan returns two orders, which are opposites because the two acts refuse in opposite directions: `unsealOrder` is child-first (spec_unseal refuses while an approved child depends on the target) and `approveOrder` is parent-first (spec_approve refuses while a parent is unsealed). A moved spec whose seal survives (specDigest does not hash `id`, so e.g. the family REQ with an empty `depends_on`) is never in `unsealOrder` but IS in `approveOrder`: the ledger records the approving act by id, and until it is re-approved under the new id the Stop hook refuses it (ART-5). Refuses outright when the destination base is already claimed or the source base does not exist, emptying every list so a partial plan cannot become a partial move. `dryRun` defaults to TRUE.",
|
|
180
180
|
inputSchema: {
|
|
181
181
|
type: 'object',
|
|
182
182
|
properties: {
|
|
@@ -272,10 +272,13 @@ exports.TOOL_SCHEMAS = {
|
|
|
272
272
|
description: `List specs (id, type, status; plus parent when depends_on names one, and legacy: true when the status is outside the canonical ${spec_types_1.SPEC_STATUSES.join('|')} union — absence of legacy speaks only to the STATUS being canonical, not to governance). `
|
|
273
273
|
+ 'Answers with `summary` { total, counts[type][status] }, `pending` (first 100 specs that are not approved — what needs action) with `pendingTotal`, '
|
|
274
274
|
+ 'and one page of `specs` in id order (default 100, `limit` 1..500) with `total` and `nextCursor` while rows remain — pass it back as `cursor`. '
|
|
275
|
-
+ 'To ask whether a spec exists, pass `ids`: only those rows come back, and missing ids are named in `unknownIds`.'
|
|
275
|
+
+ 'To ask whether a spec exists, pass `ids`: only those rows come back, and missing ids are named in `unknownIds`. '
|
|
276
|
+
// @implements A-SPEC-774.25
|
|
277
|
+
+ '`store` { projectRoot, specsRoot } names the store that answered.',
|
|
276
278
|
inputSchema: {
|
|
277
279
|
type: 'object',
|
|
278
280
|
properties: {
|
|
281
|
+
root: str('Optional when the server is bound to a file store; if supplied it must resolve to the SAME project.'),
|
|
279
282
|
type: str('Optional spec kind to filter by (e.g. A-SPEC).'),
|
|
280
283
|
ids: strArray('Only these spec ids; ids that do not exist are listed in `unknownIds`.'),
|
|
281
284
|
status: str('Only this status, e.g. draft | approved | outdated.'),
|
|
@@ -51,7 +51,12 @@ function cleanSubprocessEnv(env = process.env) {
|
|
|
51
51
|
const cleaned = { ...env };
|
|
52
52
|
// @implements A-SPEC-477 — the semantic key is egress consent; a child process that inherits
|
|
53
53
|
// it could exfiltrate without the gate ever seeing a command mention the name.
|
|
54
|
-
|
|
54
|
+
// @implements A-SPEC-774.2 — the gate bypass and the autonomy switch are authority too: a child that
|
|
55
|
+
// inherits them runs ungated or self-approving. Only cleanTestEnv removed them; every other child kept them.
|
|
56
|
+
const SCRUB_KEYS = new Set(['HOLMES_APPROVAL', 'HOLMES_LEDGER_KEY', 'HOLMES_ROLE', 'HOLMES_ENV_CHANNEL', 'HOLMES_SEMANTIC_API_KEY', 'GEMINI_API_KEY', 'GOOGLE_API_KEY',
|
|
57
|
+
'HOLMES_GATE_BYPASS', 'HOLMES_AUTONOMOUS_APPROVAL',
|
|
58
|
+
// @implements A-SPEC-774.9 §4 — a child never inherits run mode by accident; the orchestrator's adapter sets it.
|
|
59
|
+
'HOLMES_RUN_ID']);
|
|
55
60
|
for (const k of Object.keys(cleaned)) {
|
|
56
61
|
if (SCRUB_KEYS.has(k.toUpperCase())) {
|
|
57
62
|
delete cleaned[k];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface RunRecord {
|
|
2
|
+
run_id: string;
|
|
3
|
+
worktree: string;
|
|
4
|
+
sessions: string[];
|
|
5
|
+
engine: string;
|
|
6
|
+
started: string;
|
|
7
|
+
stop_key_sha256: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const runsDir: (main: string) => string;
|
|
10
|
+
/** The main checkout behind `dir`: a linked worktree's `.git` pointer leads to the common git directory's parent. */
|
|
11
|
+
export declare function mainCheckoutOf(dir: string): string;
|
|
12
|
+
export declare const newRunId: (now: Date, rand: () => string) => string;
|
|
13
|
+
export declare const keyHash: (key: string) => string;
|
|
14
|
+
export declare function writeRun(main: string, rec: RunRecord): string;
|
|
15
|
+
export declare function listRuns(main: string): RunRecord[];
|
|
16
|
+
/** Removes the named run's own record file, and only when the key hashes to what start stored. */
|
|
17
|
+
export declare function removeRun(main: string, id: string, key: string | undefined): 'removed' | 'no-run' | 'bad-key';
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.keyHash = exports.newRunId = exports.runsDir = void 0;
|
|
37
|
+
exports.mainCheckoutOf = mainCheckoutOf;
|
|
38
|
+
exports.writeRun = writeRun;
|
|
39
|
+
exports.listRuns = listRuns;
|
|
40
|
+
exports.removeRun = removeRun;
|
|
41
|
+
// @implements A-SPEC-774.17
|
|
42
|
+
// The run records A-SPEC-774.9's runMode reads: `.ax/state/runs/<run_id>.json` in the main checkout. Written by
|
|
43
|
+
// `holmes-kit run start`, removed by `run stop` with the stop key — a session inside the run never sees the key.
|
|
44
|
+
const crypto = __importStar(require("node:crypto"));
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const RUN_ID_RE = /^run-\d{14}-[0-9a-f]{8}$/;
|
|
48
|
+
const runsDir = (main) => path.join(main, '.ax', 'state', 'runs');
|
|
49
|
+
exports.runsDir = runsDir;
|
|
50
|
+
/** The main checkout behind `dir`: a linked worktree's `.git` pointer leads to the common git directory's parent. */
|
|
51
|
+
function mainCheckoutOf(dir) {
|
|
52
|
+
let cur = path.resolve(dir);
|
|
53
|
+
for (;;) {
|
|
54
|
+
const dotGit = path.join(cur, '.git');
|
|
55
|
+
let st = null;
|
|
56
|
+
try {
|
|
57
|
+
st = fs.statSync(dotGit);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
st = null;
|
|
61
|
+
}
|
|
62
|
+
if (st?.isDirectory())
|
|
63
|
+
return cur;
|
|
64
|
+
if (st?.isFile()) {
|
|
65
|
+
const m = /^gitdir:\s*(.+)$/m.exec(fs.readFileSync(dotGit, 'utf8'));
|
|
66
|
+
if (!m)
|
|
67
|
+
return cur;
|
|
68
|
+
const gitdir = path.resolve(cur, m[1].trim());
|
|
69
|
+
let common = gitdir;
|
|
70
|
+
try {
|
|
71
|
+
common = path.resolve(gitdir, fs.readFileSync(path.join(gitdir, 'commondir'), 'utf8').trim());
|
|
72
|
+
}
|
|
73
|
+
catch { /* not a worktree gitdir */ }
|
|
74
|
+
return path.basename(common) === '.git' ? path.dirname(common) : cur;
|
|
75
|
+
}
|
|
76
|
+
const up = path.dirname(cur);
|
|
77
|
+
if (up === cur)
|
|
78
|
+
return path.resolve(dir);
|
|
79
|
+
cur = up;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const newRunId = (now, rand) => `run-${now.toISOString().replace(/[-:T]/g, '').slice(0, 14)}-${rand().slice(0, 8)}`;
|
|
83
|
+
exports.newRunId = newRunId;
|
|
84
|
+
const keyHash = (key) => crypto.createHash('sha256').update(key).digest('hex');
|
|
85
|
+
exports.keyHash = keyHash;
|
|
86
|
+
function writeRun(main, rec) {
|
|
87
|
+
const file = path.join((0, exports.runsDir)(main), `${rec.run_id}.json`);
|
|
88
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
89
|
+
fs.writeFileSync(file, `${JSON.stringify(rec, null, 2)}\n`, { flag: 'wx' });
|
|
90
|
+
return file;
|
|
91
|
+
}
|
|
92
|
+
function readRun(file) {
|
|
93
|
+
try {
|
|
94
|
+
const r = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
95
|
+
if (typeof r.run_id !== 'string' || !RUN_ID_RE.test(r.run_id) || typeof r.worktree !== 'string')
|
|
96
|
+
return null;
|
|
97
|
+
return r;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function listRuns(main) {
|
|
104
|
+
let names;
|
|
105
|
+
try {
|
|
106
|
+
names = fs.readdirSync((0, exports.runsDir)(main)).filter((n) => n.endsWith('.json')).sort();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
return names.map((n) => readRun(path.join((0, exports.runsDir)(main), n))).filter((r) => r !== null);
|
|
112
|
+
}
|
|
113
|
+
/** Removes the named run's own record file, and only when the key hashes to what start stored. */
|
|
114
|
+
function removeRun(main, id, key) {
|
|
115
|
+
if (!RUN_ID_RE.test(id))
|
|
116
|
+
return 'no-run';
|
|
117
|
+
const file = path.join((0, exports.runsDir)(main), `${id}.json`);
|
|
118
|
+
const rec = readRun(file);
|
|
119
|
+
if (rec === null || rec.run_id !== id)
|
|
120
|
+
return 'no-run';
|
|
121
|
+
if (typeof key !== 'string' || typeof rec.stop_key_sha256 !== 'string' || !/^[0-9a-f]{64}$/.test(rec.stop_key_sha256)
|
|
122
|
+
|| !crypto.timingSafeEqual(Buffer.from((0, exports.keyHash)(key)), Buffer.from(rec.stop_key_sha256)))
|
|
123
|
+
return 'bad-key';
|
|
124
|
+
fs.rmSync(file);
|
|
125
|
+
return 'removed';
|
|
126
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type Link = {
|
|
2
|
+
id: string;
|
|
3
|
+
status: string;
|
|
4
|
+
} | null;
|
|
5
|
+
export interface ChainEntry {
|
|
6
|
+
aspec: string;
|
|
7
|
+
status: string;
|
|
8
|
+
tspec: Link;
|
|
9
|
+
hspec: Link;
|
|
10
|
+
req: Link;
|
|
11
|
+
}
|
|
12
|
+
export interface Mrp {
|
|
13
|
+
base: string;
|
|
14
|
+
head: string;
|
|
15
|
+
files: string[];
|
|
16
|
+
chain: ChainEntry[];
|
|
17
|
+
evidence: {
|
|
18
|
+
head?: string;
|
|
19
|
+
fresh: boolean;
|
|
20
|
+
passed?: boolean;
|
|
21
|
+
executed?: number;
|
|
22
|
+
};
|
|
23
|
+
review: {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
reasons: string[];
|
|
26
|
+
};
|
|
27
|
+
coverage: 'unmeasured';
|
|
28
|
+
mutation: 'unmeasured';
|
|
29
|
+
ready: boolean;
|
|
30
|
+
missing: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare function buildMrp(root: string, base: string, head: string): Mrp | {
|
|
33
|
+
error: string;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildMrp = buildMrp;
|
|
37
|
+
// @implements A-SPEC-102.6, A-SPEC-102.7
|
|
38
|
+
/**
|
|
39
|
+
* @implements A-SPEC-102.6 — the merge-ready package: one artefact a person reads before approving a merge. It names
|
|
40
|
+
* the spec chain behind the changed files, the test evidence for the head, the review verdict, and — explicitly —
|
|
41
|
+
* what is missing. Coverage and mutation are not measured per range yet; they say so instead of guessing.
|
|
42
|
+
*/
|
|
43
|
+
const fs = __importStar(require("node:fs"));
|
|
44
|
+
const path = __importStar(require("node:path"));
|
|
45
|
+
const spec_parser_1 = require("../spec/spec-parser");
|
|
46
|
+
const test_evidence_1 = require("./test-evidence");
|
|
47
|
+
const verdicts_1 = require("./verdicts");
|
|
48
|
+
function loadSpecs(dir, out = new Map(), depth = 0) {
|
|
49
|
+
if (depth > 6)
|
|
50
|
+
return out;
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
for (const e of entries) {
|
|
59
|
+
const p = path.join(dir, e.name);
|
|
60
|
+
if (e.isDirectory())
|
|
61
|
+
loadSpecs(p, out, depth + 1);
|
|
62
|
+
else if (e.isFile() && e.name.endsWith('.md')) {
|
|
63
|
+
try {
|
|
64
|
+
const s = (0, spec_parser_1.parseSpec)(fs.readFileSync(p, 'utf8'));
|
|
65
|
+
if (s.id)
|
|
66
|
+
out.set(s.id, s);
|
|
67
|
+
}
|
|
68
|
+
catch { /* an unreadable spec is simply absent */ }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function buildMrp(root, base, head) {
|
|
74
|
+
const range = (0, verdicts_1.resolveRange)(root, base, head);
|
|
75
|
+
if ('error' in range)
|
|
76
|
+
return range;
|
|
77
|
+
const touched = (0, verdicts_1.rangeAnchors)(root, range.base, range.head);
|
|
78
|
+
if ('error' in touched)
|
|
79
|
+
return touched;
|
|
80
|
+
const files = touched.files;
|
|
81
|
+
const specs = loadSpecs(path.join(root, '.ax', 'specs'));
|
|
82
|
+
const aspecs = new Set(touched.aspecs);
|
|
83
|
+
const link = (id) => (id ? { id, status: specs.get(id)?.status ?? 'missing' } : null);
|
|
84
|
+
const chain = [...aspecs].sort().map((id) => {
|
|
85
|
+
const a = specs.get(id);
|
|
86
|
+
const tspec = [...specs.values()].find((s) => s.type === 'T-SPEC' && (s.dependsOn ?? []).includes(id));
|
|
87
|
+
const hId = a?.dependsOn?.find((d) => d.startsWith('H-SPEC-'));
|
|
88
|
+
const reqId = hId ? specs.get(hId)?.dependsOn?.find((d) => d.startsWith('REQ-')) : undefined;
|
|
89
|
+
return { aspec: id, status: a?.status ?? 'missing', tspec: tspec ? { id: tspec.id, status: tspec.status } : null, hspec: link(hId), req: link(reqId) };
|
|
90
|
+
});
|
|
91
|
+
const ev = (0, test_evidence_1.readTestEvidence)(root);
|
|
92
|
+
const evidence = ev
|
|
93
|
+
? { head: ev.head, fresh: ev.head === range.head, passed: ev.passed,
|
|
94
|
+
executed: [...aspecs].reduce((n, id) => n + (ev.executedByAspec[id] ?? 0), 0) }
|
|
95
|
+
: { fresh: false };
|
|
96
|
+
const review = (0, verdicts_1.gateRange)(root, range.base, range.head, {});
|
|
97
|
+
const missing = [];
|
|
98
|
+
for (const c of chain) {
|
|
99
|
+
if (c.status !== 'approved')
|
|
100
|
+
missing.push(`${c.aspec} is ${c.status}`);
|
|
101
|
+
if (!c.tspec)
|
|
102
|
+
missing.push(`${c.aspec} has no T-SPEC`);
|
|
103
|
+
else if (c.tspec.status !== 'approved')
|
|
104
|
+
missing.push(`${c.tspec.id} is ${c.tspec.status}`);
|
|
105
|
+
if (!c.hspec)
|
|
106
|
+
missing.push(`${c.aspec} has no H-SPEC parent`);
|
|
107
|
+
else if (c.hspec.status !== 'approved')
|
|
108
|
+
missing.push(`${c.hspec.id} is ${c.hspec.status}`);
|
|
109
|
+
if (!c.req)
|
|
110
|
+
missing.push(`${c.aspec} has no REQ ancestor`);
|
|
111
|
+
else if (c.req.status !== 'approved')
|
|
112
|
+
missing.push(`${c.req.id} is ${c.req.status}`);
|
|
113
|
+
}
|
|
114
|
+
if (!evidence.fresh || evidence.passed !== true)
|
|
115
|
+
missing.push(`test evidence is not fresh or not green for ${range.head}`);
|
|
116
|
+
missing.push(...review.reasons);
|
|
117
|
+
const unique = [...new Set(missing)];
|
|
118
|
+
return { base: range.base, head: range.head, files, chain, evidence, review, coverage: 'unmeasured', mutation: 'unmeasured', ready: unique.length === 0, missing: unique };
|
|
119
|
+
}
|