@holmes-lab/holmes-kit 0.35.16 → 0.35.18

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 (43) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +4 -2
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/cli/approve-watch.js +4 -0
  5. package/dist/holmes/cli/approve.d.ts +8 -1
  6. package/dist/holmes/cli/approve.js +27 -8
  7. package/dist/holmes/cli/doctor.js +14 -2
  8. package/dist/holmes/cli/index.js +9 -4
  9. package/dist/holmes/cli/init.js +3 -1
  10. package/dist/holmes/cli/interactive-prompt.d.ts +5 -0
  11. package/dist/holmes/cli/interactive-prompt.js +12 -4
  12. package/dist/holmes/cli/runtime-binding.d.ts +5 -0
  13. package/dist/holmes/cli/runtime-binding.js +42 -4
  14. package/dist/holmes/governance/approval-queue.d.ts +7 -1
  15. package/dist/holmes/governance/approval-queue.js +28 -3
  16. package/dist/holmes/governance/autonomy.js +13 -1
  17. package/dist/holmes/guardrail/write-target.d.ts +18 -0
  18. package/dist/holmes/guardrail/write-target.js +136 -35
  19. package/dist/holmes/hooks/pre-tool-use.js +15 -10
  20. package/dist/holmes/hooks/rtm-refresh-child.d.ts +12 -2
  21. package/dist/holmes/hooks/rtm-refresh-child.js +26 -4
  22. package/dist/holmes/hooks/stop-timing.d.ts +12 -0
  23. package/dist/holmes/hooks/stop-timing.js +22 -0
  24. package/dist/holmes/hooks/stop.js +28 -0
  25. package/dist/holmes/mcp/handlers/graph-operations.d.ts +1 -0
  26. package/dist/holmes/mcp/handlers/graph-operations.js +4 -4
  27. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +25 -0
  28. package/dist/holmes/mcp/handlers/operator-inspection.js +60 -1
  29. package/dist/holmes/mcp/handlers/test-execution.d.ts +7 -0
  30. package/dist/holmes/mcp/handlers/test-execution.js +9 -2
  31. package/dist/holmes/mcp/handlers.d.ts +9 -0
  32. package/dist/holmes/mcp/operator-recovery.js +5 -2
  33. package/dist/holmes/refresh/freshness-coordinator.d.ts +9 -0
  34. package/dist/holmes/refresh/freshness-coordinator.js +14 -4
  35. package/dist/holmes/rtm/anchor-ids.d.ts +15 -0
  36. package/dist/holmes/rtm/anchor-ids.js +45 -0
  37. package/dist/holmes/rtm/test-scope.d.ts +12 -0
  38. package/dist/holmes/rtm/test-scope.js +29 -4
  39. package/dist/holmes/runtime/dispatch.js +28 -3
  40. package/package.json +1 -1
  41. package/playbooks/publish/PLAYBOOK.md +29 -6
  42. package/dist/holmes/guardrail/write-verb-word.d.ts +0 -13
  43. package/dist/holmes/guardrail/write-verb-word.js +0 -55
@@ -33,10 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.approvalRequestOf = approvalRequestOf;
37
+ exports.nextActionOf = nextActionOf;
36
38
  exports.createOperatorInspectionHandlers = createOperatorInspectionHandlers;
37
39
  // @implements A-SPEC-605, A-SPEC-605.1
38
40
  // @implements A-SPEC-642
39
41
  // @implements A-SPEC-631
42
+ // @implements A-SPEC-768
40
43
  const fs = __importStar(require("node:fs"));
41
44
  const path = __importStar(require("node:path"));
42
45
  const spec_store_1 = require("../../spec/spec-store");
@@ -46,6 +49,58 @@ const ledger_timeline_1 = require("../../governance/ledger-timeline");
46
49
  const provenance_ledger_1 = require("../../governance/provenance-ledger");
47
50
  const provenance_chain_1 = require("../../governance/provenance-chain");
48
51
  const approval_grants_1 = require("../../governance/approval-grants");
52
+ const approval_queue_1 = require("../../governance/approval-queue");
53
+ /**
54
+ * @implements A-SPEC-768
55
+ * Measured 2026-10-11 (SWE-bench Sphinx 11510, H0 arm): the operator held one request twice with two different
56
+ * questions; the worker polled `approval_status` eleven times and never saw the second, because the response reported
57
+ * the spec's seal only. The queue fold already keeps the latest `held` question (`pending[].question`, `holds[id]`);
58
+ * this reads it. Read-only; an unreadable queue is no request.
59
+ */
60
+ function approvalRequestOf(root, specId) {
61
+ try {
62
+ const id = (0, approval_queue_1.approvalRequestId)('spec-approve', specId);
63
+ const q = (0, approval_queue_1.readQueue)(root);
64
+ const pending = q.pending.find((p) => p.id === id);
65
+ const hold = q.holds[id];
66
+ if (pending?.hold || hold) {
67
+ const question = (pending?.hold ? pending.question : undefined) ?? hold?.question;
68
+ return { id, state: 'held', ...(question !== undefined ? { question } : {}), ...(hold?.ts ? { ts: hold.ts } : pending ? { ts: pending.lastTs } : {}) };
69
+ }
70
+ if (pending)
71
+ return { id, state: 'pending', ts: pending.lastTs };
72
+ const d = q.decisions[id];
73
+ if (!d)
74
+ return undefined;
75
+ if (d.event === 'granted')
76
+ return { id, state: d.consumedTs ? 'consumed' : 'granted', ts: d.consumedTs ?? d.ts };
77
+ return { id, state: d.event, ...(d.reason ? { reason: d.reason } : {}), ts: d.ts };
78
+ }
79
+ catch {
80
+ return undefined;
81
+ }
82
+ }
83
+ /**
84
+ * @implements A-SPEC-768
85
+ * One sentence an agent can act on. Measured 2026-10-11 (HG arm): 58 `sealed: true` answers were read as "pending"
86
+ * because nothing in the response said what to do once the seal was there.
87
+ */
88
+ function nextActionOf(described, request) {
89
+ if (described.sealed)
90
+ return 'sealed — stop polling this id; call spec_slice_approve or spec_approve for the next unsealed spec of the chain (spec_next names it).';
91
+ switch (request?.state) {
92
+ case 'held': return `held — the operator asks: ${request.question ?? '(no question recorded)'}. Resolve it in the spec or tests, then call spec_approve again.`;
93
+ case 'denied': return `denied — ${request.reason ?? 'no reason recorded'}. Do not re-request the same act; report it to the user.`;
94
+ case 'revoked': return `revoked — ${request.reason ?? 'no reason recorded'}. Do not re-request the same act; report it to the user.`;
95
+ case 'granted': return 'granted — call spec_approve now; the grant seals it.';
96
+ case 'consumed': return 'the grant was consumed but this spec is not sealed — call spec_approve again, and report its refusal to the user if it refuses.';
97
+ case 'pending': return "pending the operator's decision — wait, then call approval_status again; when sealed is true, retry spec_approve immediately.";
98
+ default: break;
99
+ }
100
+ if (described.blockers.length > 0)
101
+ return 'fix the blockers listed, then call spec_approve; no request is filed while they stand.';
102
+ return 'no approval request on file — call spec_approve to file one.';
103
+ }
49
104
  function createOperatorInspectionHandlers(context) {
50
105
  return {
51
106
  /**
@@ -261,7 +316,11 @@ function createOperatorInspectionHandlers(context) {
261
316
  advisoryIds = undefined;
262
317
  advisoryHistory = undefined;
263
318
  }
264
- return { ok: true, ...(0, approval_status_1.describeApproval)(cur.spec, context.resolver(all)), ...(graphPreview ? { graphPreview } : {}),
319
+ // @implements A-SPEC-768 — the request's state and the next action ride beside the seal state.
320
+ const described = (0, approval_status_1.describeApproval)(cur.spec, context.resolver(all));
321
+ const request = typeof a.root === 'string' && a.root !== '' ? approvalRequestOf(a.root, a.id) : undefined;
322
+ const nextAction = nextActionOf(described, request);
323
+ return { ok: true, ...described, ...(request ? { request } : {}), nextAction, ...(graphPreview ? { graphPreview } : {}),
265
324
  ...(fttFulfilment ? { fttFulfilment } : {}), ...(killsAdvisory ? { killsAdvisory } : {}),
266
325
  ...(advisoryIds ? { advisoryIds } : {}), ...(advisoryHistory ? { advisoryHistory } : {}) };
267
326
  },
@@ -50,6 +50,13 @@ export declare function createTestExecutionHandlers(context: TestExecutionContex
50
50
  }[];
51
51
  };
52
52
  } | {
53
+ anchorDiagnostics?: {
54
+ hint: string;
55
+ file: string;
56
+ line: number;
57
+ separator: string;
58
+ dropped: string[];
59
+ }[] | undefined;
53
60
  calibrationClosed?: string[] | undefined;
54
61
  baselineRecorded?: string | undefined;
55
62
  scopeFallback?: "full" | undefined;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createTestExecutionHandlers = createTestExecutionHandlers;
37
- // @implements A-SPEC-616, A-SPEC-100.2, A-SPEC-102.1, A-SPEC-121.2, A-SPEC-121.3, A-SPEC-128, A-SPEC-130, A-SPEC-189, A-SPEC-233, A-SPEC-419, A-SPEC-433, A-SPEC-534.5, A-SPEC-534.8, A-SPEC-578.4, A-SPEC-614, A-SPEC-734
37
+ // @implements A-SPEC-616, A-SPEC-100.2, A-SPEC-102.1, A-SPEC-121.2, A-SPEC-121.3, A-SPEC-128, A-SPEC-130, A-SPEC-189, A-SPEC-233, A-SPEC-419, A-SPEC-433, A-SPEC-534.5, A-SPEC-534.8, A-SPEC-578.4, A-SPEC-614, A-SPEC-734, A-SPEC-768.1
38
38
  const fs = __importStar(require("node:fs"));
39
39
  const path = __importStar(require("node:path"));
40
40
  const node_child_process_1 = require("node:child_process");
@@ -55,6 +55,8 @@ const test_evidence_1 = require("../../review/test-evidence");
55
55
  const test_outcomes_1 = require("../../review/test-outcomes");
56
56
  const maintenance_evidence_1 = require("../maintenance-evidence");
57
57
  const bounded_io_1 = require("../../project/bounded-io");
58
+ // @implements A-SPEC-768.1 — the one sentence every anchor-separator diagnostic carries.
59
+ const ANCHOR_SEPARATOR_HINT = 'only a comma-separated list is an anchor list; ids after the separator are not attributed — write `@' + 'implements A, B` or one marker per line';
58
60
  // @implements A-SPEC-534.8
59
61
  // The governed source file a `kills` mutation targets: one that @implements the A-SPEC AND contains
60
62
  // the `where` literal. Bounded walk, skips vendored/test/hidden dirs. null when none qualifies.
@@ -168,6 +170,10 @@ function createTestExecutionHandlers(context) {
168
170
  const result = (0, test_runner_1.runTestScope)(testScope, root);
169
171
  const anchors = (0, test_scope_1.scanTestAnchors)(root);
170
172
  const executedByAspec = (0, test_evidence_1.computeExecutedByAspec)(result.executedByFile ?? {}, anchors);
173
+ // @implements A-SPEC-768.1 — an anchor list the grammar does not read is named beside the attribution it could
174
+ // not make (measured 2026-10-11: `A-SPEC-107; A-SPEC-122` counted A-SPEC-107 only, silently). Diagnosis only:
175
+ // `executedByAspec` is exactly what the grammar read.
176
+ const anchorDiagnostics = (0, test_scope_1.scanTestAnchorDiagnostics)(root).map((d) => ({ ...d, hint: ANCHOR_SEPARATOR_HINT }));
171
177
  let head = '';
172
178
  try {
173
179
  head = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'rev-parse', 'HEAD'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', env: (0, root_1.cleanSubprocessEnv)(), stdio: ['ignore', 'pipe', 'pipe'] }).trim();
@@ -218,7 +224,8 @@ function createTestExecutionHandlers(context) {
218
224
  // @implements A-SPEC-130 — the remediation rides in the answer: these are the files to anchor.
219
225
  unresolvedFiles: testScope.unresolvedFiles,
220
226
  changeSource, ...(scopeFallback ? { scopeFallback } : {}), ...(baseline ? { baselineRecorded: baseline } : {}),
221
- ...(calibrationClosed ? { calibrationClosed } : {}) };
227
+ ...(calibrationClosed ? { calibrationClosed } : {}),
228
+ ...(anchorDiagnostics.length > 0 ? { anchorDiagnostics } : {}) };
222
229
  },
223
230
  };
224
231
  }
@@ -1205,6 +1205,8 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
1205
1205
  };
1206
1206
  unavailable?: "empty" | "unreadable";
1207
1207
  } | undefined;
1208
+ nextAction: string;
1209
+ request?: import("./handlers/operator-inspection").ApprovalRequestState | undefined;
1208
1210
  id: string;
1209
1211
  type?: string;
1210
1212
  status: string;
@@ -1541,6 +1543,13 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
1541
1543
  }[];
1542
1544
  };
1543
1545
  } | {
1546
+ anchorDiagnostics?: {
1547
+ hint: string;
1548
+ file: string;
1549
+ line: number;
1550
+ separator: string;
1551
+ dropped: string[];
1552
+ }[] | undefined;
1544
1553
  calibrationClosed?: string[] | undefined;
1545
1554
  baselineRecorded?: string | undefined;
1546
1555
  scopeFallback?: "full" | undefined;
@@ -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
37
+ // @implements A-SPEC-754, A-SPEC-532.3, A-SPEC-768
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) {
@@ -58,9 +58,12 @@ function operatorRecovery(root, target, operation, options) {
58
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
59
  // @implements A-SPEC-532.3 — the resident surface is offered beside the one-off command (owner, 2026-10-04:
60
60
  // "why am I still pasting commands"): one key per arriving request.
61
+ // @implements A-SPEC-768 — the three lines above are the operator's; measured 2026-10-11 (HG arm) the agent read
62
+ // "keep the approval surface open" as its own instruction and polled a sealed spec 58 times. One line is the agent's.
61
63
  return `\n[승인 대기 ${id}] 운영자: ${command} --grant ${literal(id, platform)}`
62
64
  + `\nOr keep the approval surface open and decide each arriving request with one key: ${command} --watch`
63
- + `\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.`;
65
+ + `\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
+ + '\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.';
64
67
  },
65
68
  };
66
69
  }
@@ -1,4 +1,10 @@
1
1
  export type FreshnessLane = 'current' | 'refreshing' | 'retry-at' | 'failed' | 'suppressed' | 'not-adopted' | 'stale';
2
+ /** Why a lane failed, as the worker saw it: the stage that failed and the error's message, bounded to 300 characters. */
3
+ export interface RefreshFailure {
4
+ stage: 'graph' | 'source' | 'requirement' | 'child';
5
+ reason: string;
6
+ }
7
+ export declare const REFRESH_FAILURE_REASON_MAX = 300;
2
8
  export interface FreshnessReceipt {
3
9
  schema: 'fresh-evidence/1';
4
10
  workspaceId: string;
@@ -12,6 +18,8 @@ export interface FreshnessReceipt {
12
18
  graph: FreshnessLane;
13
19
  sourceSemantic: FreshnessLane;
14
20
  requirementSemantic: FreshnessLane;
21
+ /** @implements A-SPEC-768.4 — present only on a completion that failed; never carried into the next lease. */
22
+ failure?: RefreshFailure;
15
23
  }
16
24
  export interface RefreshRequest {
17
25
  workspaceId: string;
@@ -23,6 +31,7 @@ export interface RefreshCompletion {
23
31
  sourceSemantic: FreshnessLane;
24
32
  requirementSemantic: FreshnessLane;
25
33
  head: string | null;
34
+ failure?: RefreshFailure;
26
35
  }
27
36
  export declare const FRESHNESS_RECEIPT_FILE: string;
28
37
  export declare const FRESHNESS_LEASE_MS: number;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.FRESHNESS_REREFRESH_MS = exports.FRESHNESS_RETRY_MS = exports.FRESHNESS_LEASE_MS = exports.FRESHNESS_RECEIPT_FILE = void 0;
36
+ exports.FRESHNESS_REREFRESH_MS = exports.FRESHNESS_RETRY_MS = exports.FRESHNESS_LEASE_MS = exports.FRESHNESS_RECEIPT_FILE = exports.REFRESH_FAILURE_REASON_MAX = void 0;
37
37
  exports.intakeUsable = intakeUsable;
38
38
  exports.lexicalOnly = lexicalOnly;
39
39
  exports.readFreshnessReceipt = readFreshnessReceipt;
@@ -41,7 +41,7 @@ exports.requestRefresh = requestRefresh;
41
41
  exports.ownsLease = ownsLease;
42
42
  exports.completeRefresh = completeRefresh;
43
43
  exports.workspaceIdFor = workspaceIdFor;
44
- // @implements A-SPEC-719
44
+ // @implements A-SPEC-719, A-SPEC-768.4
45
45
  /**
46
46
  * The durable source of truth for refresh work. A receipt names the workspace and
47
47
  * commit it describes, so an old detached worker cannot make a newer tree look
@@ -51,6 +51,7 @@ const crypto = __importStar(require("node:crypto"));
51
51
  const fs = __importStar(require("node:fs"));
52
52
  const path = __importStar(require("node:path"));
53
53
  const workspace_identity_1 = require("../project/workspace-identity");
54
+ exports.REFRESH_FAILURE_REASON_MAX = 300;
54
55
  exports.FRESHNESS_RECEIPT_FILE = path.join('.ax', 'state', 'fresh-evidence.json');
55
56
  // A crashed detached child becomes eligible quickly. This is intentionally much
56
57
  // shorter than the former 30-minute marker window, while still bounding spawn bursts.
@@ -93,7 +94,9 @@ function isReceipt(value) {
93
94
  && typeof r.requirementSemantic === 'string' && lanes.has(r.requirementSemantic)
94
95
  && (r.startedAt === undefined || typeof r.startedAt === 'string')
95
96
  && (r.completedAt === undefined || typeof r.completedAt === 'string')
96
- && (r.retryAt === undefined || typeof r.retryAt === 'string');
97
+ && (r.retryAt === undefined || typeof r.retryAt === 'string')
98
+ // @implements A-SPEC-768.4 — a receipt without the field is still a receipt (older builds wrote none).
99
+ && (r.failure === undefined || (!!r.failure && typeof r.failure === 'object' && typeof r.failure.stage === 'string' && typeof r.failure.reason === 'string'));
97
100
  }
98
101
  function storedReceipt(root) {
99
102
  try {
@@ -202,9 +205,16 @@ function completeRefresh(root, generation, completion, now) {
202
205
  : judged.includes('suppressed') ? 'suppressed'
203
206
  : judged.includes('not-adopted') ? 'not-adopted'
204
207
  : retry ? 'retry-at' : 'failed';
208
+ // @implements A-SPEC-768.4 — `failure` comes from THIS completion only, bounded; a lease never inherits the last one.
209
+ const { failure: _previousFailure, ...base } = previous;
210
+ const failure = completion.failure
211
+ ? { stage: completion.failure.stage, reason: String(completion.failure.reason).slice(0, exports.REFRESH_FAILURE_REASON_MAX) }
212
+ : undefined;
213
+ const { failure: _completionFailure, ...completed } = completion;
205
214
  const receipt = {
206
- ...previous, ...completion, state, completedAt: now.toISOString(),
215
+ ...base, ...completed, state, completedAt: now.toISOString(),
207
216
  ...(retry ? { retryAt: new Date(now.getTime() + exports.FRESHNESS_RETRY_MS).toISOString() } : {}),
217
+ ...(failure ? { failure } : {}),
208
218
  };
209
219
  writeReceipt(root, receipt);
210
220
  return receipt;
@@ -34,3 +34,18 @@ export declare function anchorSpecSites(text: string): Array<{
34
34
  }>;
35
35
  /** Flattened wrong-kind ids (a governed id anchored where only A-SPEC belongs) — anywhere in a list. */
36
36
  export declare function wrongKindAnchorIds(text: string): string[];
37
+ /** A list the comma grammar does not read: the first non-comma joiner after a list, and every id the join drops. */
38
+ export interface AnchorListDiagnostic {
39
+ line: number;
40
+ separator: string;
41
+ dropped: string[];
42
+ }
43
+ /**
44
+ * @implements A-SPEC-768.1
45
+ * Measured 2026-10-11 (SWE-bench Sphinx 11510, HB arm): `# @implements A-SPEC-107; A-SPEC-122` attributed the file
46
+ * to A-SPEC-107 only and nothing said so — the C12 shape again, with a new separator. The grammar above stays the ONE
47
+ * grammar; this names what it does not read, per marker: the first `;`, `|`, `&`, `/` or `and` that follows the comma
48
+ * chain and is itself followed by a governed id, with every id of the chain after it. String literals are stripped the
49
+ * same way the anchor readers strip them, so a diagnostic never names text some code merely holds.
50
+ */
51
+ export declare function anchorListDiagnostics(text: string): AnchorListDiagnostic[];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  // @implements A-SPEC-503.1
3
+ // @implements A-SPEC-768.1
3
4
  /**
4
5
  * The ONE comma-list grammar for anchor lines — C12, dogfooded: four parsers each captured only
5
6
  * the first id of a comma-listed anchor (`… <marker> A-SPEC-…110, …219`), so every id after the
@@ -15,6 +16,7 @@ exports.implementsIdLists = implementsIdLists;
15
16
  exports.anchorSpecIds = anchorSpecIds;
16
17
  exports.anchorSpecSites = anchorSpecSites;
17
18
  exports.wrongKindAnchorIds = wrongKindAnchorIds;
19
+ exports.anchorListDiagnostics = anchorListDiagnostics;
18
20
  // @implements A-SPEC-504.1
19
21
  // The ONE string-literal preprocessing every anchor-judging surface shares. Measured 2026-09-01:
20
22
  // the coverage scanner stripped literals while the claim gate judged raw text, so a legitimate
@@ -123,3 +125,46 @@ function anchorSpecSites(text) {
123
125
  function wrongKindAnchorIds(text) {
124
126
  return [...new Set(implementsIdLists(text).flat().filter((id) => !id.startsWith('A-SPEC-')))];
125
127
  }
128
+ const ID_RE = new RegExp(ID, 'g');
129
+ const DROPPED_TAIL_RE = new RegExp(String.raw `^[ \t]*(?:([;|&/])[ \t]*|(and)[ \t]+)(${ID})`);
130
+ const DROPPED_COMMA_RE = new RegExp(String.raw `^(?:[ \t]*,[ \t]*${ID})+`);
131
+ /**
132
+ * @implements A-SPEC-768.1
133
+ * Measured 2026-10-11 (SWE-bench Sphinx 11510, HB arm): `# @implements A-SPEC-107; A-SPEC-122` attributed the file
134
+ * to A-SPEC-107 only and nothing said so — the C12 shape again, with a new separator. The grammar above stays the ONE
135
+ * grammar; this names what it does not read, per marker: the first `;`, `|`, `&`, `/` or `and` that follows the comma
136
+ * chain and is itself followed by a governed id, with every id of the chain after it. String literals are stripped the
137
+ * same way the anchor readers strip them, so a diagnostic never names text some code merely holds.
138
+ */
139
+ function anchorListDiagnostics(text) {
140
+ const stripped = stripStringLiterals(text);
141
+ const out = [];
142
+ let line = 1;
143
+ let lineAt = 0;
144
+ for (const m of stripped.matchAll(LIST_RE)) {
145
+ const at = m.index ?? 0;
146
+ for (; lineAt < at; lineAt++)
147
+ if (stripped.charCodeAt(lineAt) === 10)
148
+ line++;
149
+ let pos = at + m[0].length;
150
+ let separator = null;
151
+ const dropped = [];
152
+ for (;;) {
153
+ const tail = DROPPED_TAIL_RE.exec(stripped.slice(pos));
154
+ if (!tail)
155
+ break;
156
+ separator ??= tail[1] ?? tail[2];
157
+ dropped.push(tail[3]);
158
+ pos += tail[0].length;
159
+ const chain = DROPPED_COMMA_RE.exec(stripped.slice(pos));
160
+ if (chain) {
161
+ for (const id of chain[0].matchAll(ID_RE))
162
+ dropped.push(id[0]);
163
+ pos += chain[0].length;
164
+ }
165
+ }
166
+ if (separator !== null)
167
+ out.push({ line, separator, dropped });
168
+ }
169
+ return out;
170
+ }
@@ -135,4 +135,16 @@ export declare function extractAnchors(source: string): string[];
135
135
  * paths → the impacted-spec ids they anchor. Pure-ish (fs read only); resilient to unreadable files.
136
136
  */
137
137
  export declare function scanTestAnchors(root: string): Record<string, string[]>;
138
+ /**
139
+ * @implements A-SPEC-768.1
140
+ * The anchor lists in test files that the comma grammar does not read (`A; B`, `A | B`, `A and B`): the same files
141
+ * `scanTestAnchors` attributes, the same string stripping, and only lines that are anchor lines (a comment with the
142
+ * marker) — so a diagnostic names exactly an attribution the scan above could not make.
143
+ */
144
+ export declare function scanTestAnchorDiagnostics(root: string): Array<{
145
+ file: string;
146
+ line: number;
147
+ separator: string;
148
+ dropped: string[];
149
+ }>;
138
150
  export declare function computeTestScope(impactedSpecsRaw: string[], testAnchors: Record<string, string[]>, specs: Spec[], coverageGaps?: string[], cfg?: TestScopeThresholds, extras?: TestScopeExtras): TestScope;
@@ -40,8 +40,9 @@ exports.stripCode = stripCode;
40
40
  exports.countTestCases = countTestCases;
41
41
  exports.extractAnchors = extractAnchors;
42
42
  exports.scanTestAnchors = scanTestAnchors;
43
+ exports.scanTestAnchorDiagnostics = scanTestAnchorDiagnostics;
43
44
  exports.computeTestScope = computeTestScope;
44
- // @implements A-SPEC-121.2, A-SPEC-734, A-SPEC-750, A-SPEC-750.1
45
+ // @implements A-SPEC-121.2, A-SPEC-734, A-SPEC-750, A-SPEC-750.1, A-SPEC-768.1
45
46
  const anchor_ids_1 = require("./anchor-ids");
46
47
  const fs = __importStar(require("node:fs"));
47
48
  const path = __importStar(require("node:path"));
@@ -618,6 +619,15 @@ function describeUnresolved(entries) {
618
619
  */
619
620
  function scanTestAnchors(root) {
620
621
  const out = {};
622
+ forEachTestFile(root, (rel, text) => {
623
+ const ids = extractAnchors(text);
624
+ if (ids.length)
625
+ out[rel] = ids;
626
+ });
627
+ return out;
628
+ }
629
+ /** The one walk `scanTestAnchors` and `scanTestAnchorDiagnostics` share: every readable regular test file under `root`. */
630
+ function forEachTestFile(root, visit) {
621
631
  const walk = (dir) => {
622
632
  let entries;
623
633
  try {
@@ -647,12 +657,27 @@ function scanTestAnchors(root) {
647
657
  catch {
648
658
  continue;
649
659
  }
650
- const ids = extractAnchors(text);
651
- if (ids.length)
652
- out[rel] = ids;
660
+ visit(rel, text);
653
661
  }
654
662
  };
655
663
  walk(root);
664
+ }
665
+ /**
666
+ * @implements A-SPEC-768.1
667
+ * The anchor lists in test files that the comma grammar does not read (`A; B`, `A | B`, `A and B`): the same files
668
+ * `scanTestAnchors` attributes, the same string stripping, and only lines that are anchor lines (a comment with the
669
+ * marker) — so a diagnostic names exactly an attribution the scan above could not make.
670
+ */
671
+ function scanTestAnchorDiagnostics(root) {
672
+ const out = [];
673
+ forEachTestFile(root, (rel, text) => {
674
+ const lines = (0, anchor_ids_1.stripStringLiterals)(text).split('\n');
675
+ for (const d of (0, anchor_ids_1.anchorListDiagnostics)(text)) {
676
+ IMPL_LINE_RE.lastIndex = 0;
677
+ if (IMPL_LINE_RE.test(lines[d.line - 1] ?? ''))
678
+ out.push({ file: rel, ...d });
679
+ }
680
+ });
656
681
  return out;
657
682
  }
658
683
  function computeTestScope(impactedSpecsRaw, testAnchors, specs, coverageGaps = [], cfg, extras) {
@@ -121,16 +121,32 @@ async function runDispatch(opts) {
121
121
  process.exitCode = 0;
122
122
  return;
123
123
  }
124
+ // @implements A-SPEC-769.2 — where the budget went (X1, 2026-10-12: a Stop hook of 11.3 s at load 5 was refused with
125
+ // "deadline exceeded" and nothing said whether the input wait, the selection or the child used the 18 s). Each phase
126
+ // is closed when it ends, whether or not it succeeded, so the refusal can print it.
127
+ let phaseInput;
128
+ let phaseSelection;
129
+ let phaseChild;
130
+ const budgetText = String(opts.hookBudgetMs ?? hook_process_1.HOOK_BUDGET_MS);
124
131
  try {
125
132
  if (!['claude', 'codex', 'antigravity'].includes(opts.harness) || !['mcp', 'pre-tool-use', 'stop'].includes(opts.entry))
126
133
  throw new Error('Invalid runtime dispatcher entry or harness');
127
134
  const hookBudget = (0, hook_process_1.boundedHookBudget)(opts.hookBudgetMs, hook_process_1.HOOK_BUDGET_MS);
128
135
  const cleanupBudget = (0, hook_process_1.boundedHookBudget)(opts.cleanupBudgetMs, hook_process_1.HOOK_CLEANUP_MS);
129
- const input = opts.entry === 'mcp' ? undefined : await hookInput(hookBudget);
136
+ let input;
137
+ if (opts.entry !== 'mcp') {
138
+ try {
139
+ input = await hookInput(hookBudget);
140
+ }
141
+ finally {
142
+ phaseInput = Math.round(performance.now() - started);
143
+ }
144
+ }
130
145
  const hints = input ? hintsFromInput(input) : [];
131
146
  if (process.env.CLAUDE_PROJECT_DIR)
132
147
  hints.push(process.env.CLAUDE_PROJECT_DIR);
133
148
  const selection = (0, binding_1.selectRuntime)((0, binding_1.readRuntimeRegistry)(opts.registryPath), { cwd: process.cwd(), workspaceHints: hints, specsHint: process.env.HOLMES_SPECS });
149
+ phaseSelection = Math.round(performance.now() - started) - (phaseInput ?? 0);
134
150
  selectedBuild = selection.buildId;
135
151
  selectedPackage = selection.packageRoot;
136
152
  selectedWorkspace = selection.workspaceRoot;
@@ -157,7 +173,14 @@ async function runDispatch(opts) {
157
173
  detached: input !== undefined && process.platform !== 'win32', windowsHide: true,
158
174
  });
159
175
  if (input) {
160
- const result = await (0, hook_process_1.runHookChild)(child, input, remaining, cleanupBudget);
176
+ const childStarted = performance.now();
177
+ let result;
178
+ try {
179
+ result = await (0, hook_process_1.runHookChild)(child, input, remaining, cleanupBudget);
180
+ }
181
+ finally {
182
+ phaseChild = Math.round(performance.now() - childStarted);
183
+ }
161
184
  if (result.signal) {
162
185
  process.kill(process.pid, result.signal);
163
186
  return;
@@ -181,7 +204,9 @@ async function runDispatch(opts) {
181
204
  const shellWord = (word) => process.platform === 'win32' ? JSON.stringify(word) : `'${word.replace(/'/g, `'\\''`)}'`;
182
205
  const cli = selectedPackage ? `${shellWord(process.execPath)} ${shellWord(path.join(selectedPackage, 'bin/holmes-kit.js'))}` : 'holmes-kit';
183
206
  const recovery = opts.entry === 'mcp' ? '' : ` [${opts.harness}/${opts.entry}${selectedBuild ? ` build ${selectedBuild}` : ''}]. Diagnose with ${cli} runtime-binding status --workspace ${shellWord(selectedWorkspace)} --registry ${shellWord(opts.registryPath)} and ${cli} doctor --target ${shellWord(selectedWorkspace)} --registry ${shellWord(opts.registryPath)}. Repair the selected runtime through the approved installation workflow, then retry the original operation. Pending governance findings remain unresolved.`;
184
- const reason = `[Holmes-Kit] Runtime dispatch refused: ${error.message}${recovery}`;
207
+ const phases = opts.entry === 'mcp' ? ''
208
+ : `; phases (ms of ${budgetText}): input ${phaseInput ?? '-'}, selection ${phaseSelection ?? '-'}, hook child ${phaseChild ?? '-'}`;
209
+ const reason = `[Holmes-Kit] Runtime dispatch refused: ${error.message}${phases}${recovery}`;
185
210
  process.stderr.write(`${reason}\n`);
186
211
  // A partially loaded entry may have opened handles; exitCode alone would
187
212
  // leave a failed transport alive indefinitely.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "@implements A-SPEC-209",
3
3
  "name": "@holmes-lab/holmes-kit",
4
- "version": "0.35.16",
4
+ "version": "0.35.18",
5
5
  "description": "Holmes-Kit — deterministic Agentic Software Engineering (ASE) harness with causal traceability (spec chain + D-CPG + RTM + phase guardrail)",
6
6
  "main": "dist/holmes/mcp/server.js",
7
7
  "types": "dist/holmes/mcp/server.d.ts",
@@ -137,12 +137,33 @@ npm publish --access public
137
137
 
138
138
  ### 6단계: 외부 문서 표면 (External Docs Reach) — 발행이 닿는 곳까지 정직하게
139
139
 
140
- npm 만 갱신하고 끝나면, 사람들이 실제로 읽는 문서는 낡은 채로 남는다. **사고 이력**: 이 저장소에는
140
+ npm 만 갱신하고 끝나면, 사람들이 실제로 읽는 문서는 낡은 채로 남는다. **사고 이력 1**: 이 저장소에는
141
141
  GitHub 리모트가 없어(origin 이 로컬 gitea) 0.16.0·0.17.0·0.18.0 **세 릴리스 동안** GitHub README 가
142
- 한 번도 갱신되지 않았고, `package.json` 의 `homepage` 가 바로 그 문서를 가리킨다.
142
+ 한 번도 갱신되지 않았고, `package.json` 의 `homepage` 가 바로 그 문서를 가리킨다. **사고 이력 2
143
+ (2026-10-11 측정)**: 아래 4a 가 0.35.13 에 쓰인 뒤에도 GitHub 의 `.ax/badges/traced.svg` 는 **v0.27.0
144
+ (2026-09-20) 의 숫자 그대로**였고, GitHub README 는 v0.35.10 에서 멈춰 0.35.11–0.35.16 **여섯 릴리스**가
145
+ 올라가지 않았다 — 문장은 있었지만 **한 것을 증명하라는 요구가 없어서** 매번 조용히 건너뛰어졌다.
143
146
 
144
147
  **발행이 성공한 뒤에만** 실행한다 — 실패한 릴리스의 문서를 최신이라고 주장하지 않는다.
145
148
 
149
+ > [!IMPORTANT]
150
+ > **이 단계는 릴리스의 일부이고, 보고로 증명한다.** 릴리스 완료 보고(5단계 뒤)에는 다음 세 줄이 **반드시**
151
+ > 있어야 하며, 하나라도 비어 있으면 그 릴리스는 끝나지 않은 것이다:
152
+ > `README: 원격 sha <전> → <후>, 재조회 일치 yes/no` · `badge: 원격 sha <전> → <후>, 재조회 일치 yes/no` ·
153
+ > `SKIP 사유: <없음 | 정확한 사유>`. "동기화했다"는 문장은 이 세 줄이 아니다.
154
+
155
+ 가장 짧은 실행 경로(두 파일을 같은 방식으로; `<owner>/<repo>` 는 1 에서 파생한 값):
156
+
157
+ ```bash
158
+ for f in README.md .ax/badges/traced.svg; do
159
+ before=$(gh api "repos/<owner>/<repo>/contents/$f" --jq .sha)
160
+ gh api --method PUT "repos/<owner>/<repo>/contents/$f" \
161
+ -f message="docs: sync $f with vX.Y.Z" -f sha="$before" \
162
+ -f content="$(base64 < "$f" | tr -d '\n')" --jq .content.sha
163
+ gh api "repos/<owner>/<repo>/contents/$f" --jq .content | tr -d '\n' | base64 -d | cmp - "$f" && echo "$f: 재조회 일치"
164
+ done
165
+ ```
166
+
146
167
  1. **대상 파생 (하드코딩 금지)**: `package.json` 의 `repository` 에서 `<owner>/<repo>` 를 얻는다
147
168
  (`repoTargetFrom`). 이 플레이북은 **소비 프로젝트에도 설치**되므로 특정 저장소를 박아 두면 남의
148
169
  릴리스가 그 저장소를 덮어쓴다. 파생 실패 → **SKIP(사유: `repository` 필드 없음/비-GitHub)**.
@@ -152,10 +173,12 @@ GitHub 리모트가 없어(origin 이 로컬 gitea) 0.16.0·0.17.0·0.18.0 **세
152
173
  3. **동기화**: 로컬 `README.md` 를 `gh api --method PUT` 으로 올린다(`sha` 는 2 에서 읽은 값).
153
174
  4. **재조회 검증**: 다시 읽어 로컬과 일치하는지 확인한다. **쓴 것과 남은 것은 다를 수 있다** —
154
175
  검증 없는 "갱신했다"는 주장이지 사실이 아니다.
155
- 4a. **추적 배지도 같은 표면이다**: 로컬에 `.ax/badges/traced.svg` 가 있으면 README 와 **같은 대상
156
- `<owner>/<repo>`** 의 같은 경로를 2~4 와 똑같이 다룬다 — 원격을 먼저 읽어 차이를 보고하고, 올리고,
157
- **배지도 다시 읽어** 로컬과 일치하는지 확인한다. README 만 올리면 원격 README 는 새 숫자를 말하고
158
- 그림은 옛 숫자를 보여 준다. 배지 파일이 없으면 **SKIP(사유: 배지를 쓰지 않는 프로젝트)**.
176
+ 4a. **추적 배지도 같은 표면이다 — README 와 한 쌍으로, 같은 루프 안에서**: 로컬에 `.ax/badges/traced.svg` 가
177
+ 있으면 README 와 **같은 대상 `<owner>/<repo>`** 의 같은 경로를 2~4 와 똑같이 다룬다 — 원격을 먼저 읽어
178
+ 차이를 보고하고, 올리고, **배지도 다시 읽어** 로컬과 일치하는지 확인한다. README 만 올리면 원격 README 는
179
+ 새 숫자를 말하고 그림은 옛 숫자를 보여 준다(사고 이력 2: 그림이 **스물한 릴리스** 전 숫자였다). 배지
180
+ 파일이 없으면 **SKIP(사유: 배지를 쓰지 않는 프로젝트)**. 2.55단계의 재측정은 **로컬** 배지를 고치는
181
+ 것이고, 이 항목은 **원격** 배지를 고치는 것이다 — 둘은 서로를 대신하지 않는다.
159
182
  5. **profile README drift 감지 (자동 수정 금지)**: `<owner>/.github` 의 `profile/README.md` 를 읽어
160
183
  `profileDriftFindings` 로 주장-현실 불일치를 **보고만** 한다. 포지셔닝 문안은 오너 결정이며
161
184
  릴리스 절차가 정할 것이 아니다.
@@ -1,13 +0,0 @@
1
- /**
2
- * Whether `text` names one of `verbs` as a shell word, rather than as letters inside another word.
3
- *
4
- * Measured 2026-10-04: `\bverb\b` matched `install` in `docs/install-guide.md` and `ln` in `grep -ln`, so read-only
5
- * commands were refused as file writes. A verb occurrence still counts in every spelling a shell runs it under
6
- * (`cp`, `/usr/bin/install`, `'cp'`, `cp.exe`, `--to-command=tee`, `rsync-ssl`); only two shapes do not:
7
- * a. the word is a single-dash option cluster of letters and digits (`-ln`, `-rm1`);
8
- * b. inside the word the verb is followed by `/`, or the word ends in a file extension other than `.exe`.
9
- * Callers keep their own matching for what the verb targets — this answers only "is there such a verb at all", so a
10
- * caller's verdict is removed only when the whole text holds no counting occurrence. One pass: a word's shape is read
11
- * once however many occurrences it holds.
12
- */
13
- export declare function namesWriteVerb(text: string, verbs: RegExp): boolean;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.namesWriteVerb = namesWriteVerb;
4
- // @implements A-SPEC-747.1
5
- /** A shell word ends at white space or at one of `;|&()<>`. */
6
- function isBreak(code) {
7
- return code === 32 || code === 9 || code === 10 || code === 13 || code === 11 || code === 12
8
- || code === 59 || code === 124 || code === 38 || code === 40 || code === 41 || code === 60 || code === 62;
9
- }
10
- /**
11
- * Whether `text` names one of `verbs` as a shell word, rather than as letters inside another word.
12
- *
13
- * Measured 2026-10-04: `\bverb\b` matched `install` in `docs/install-guide.md` and `ln` in `grep -ln`, so read-only
14
- * commands were refused as file writes. A verb occurrence still counts in every spelling a shell runs it under
15
- * (`cp`, `/usr/bin/install`, `'cp'`, `cp.exe`, `--to-command=tee`, `rsync-ssl`); only two shapes do not:
16
- * a. the word is a single-dash option cluster of letters and digits (`-ln`, `-rm1`);
17
- * b. inside the word the verb is followed by `/`, or the word ends in a file extension other than `.exe`.
18
- * Callers keep their own matching for what the verb targets — this answers only "is there such a verb at all", so a
19
- * caller's verdict is removed only when the whole text holds no counting occurrence. One pass: a word's shape is read
20
- * once however many occurrences it holds.
21
- */
22
- function namesWriteVerb(text, verbs) {
23
- const re = new RegExp(verbs.source, verbs.flags.includes('g') ? verbs.flags : `${verbs.flags}g`);
24
- let wordStart = -1;
25
- let wordEnd = -1;
26
- let cluster = false;
27
- let extension = false;
28
- for (let m = re.exec(text); m !== null; m = re.exec(text)) {
29
- if (m[0].length === 0) {
30
- re.lastIndex++;
31
- continue;
32
- }
33
- const at = m.index;
34
- if (at < wordStart || at >= wordEnd) {
35
- let s = at;
36
- while (s > 0 && !isBreak(text.charCodeAt(s - 1)))
37
- s--;
38
- let e = at;
39
- while (e < text.length && !isBreak(text.charCodeAt(e)))
40
- e++;
41
- wordStart = s;
42
- wordEnd = e;
43
- const raw = text.slice(s, e);
44
- cluster = /^-[A-Za-z0-9]+$/.test(raw);
45
- const ext = /\.([A-Za-z0-9]{1,8})$/.exec(raw.replace(/["'\\]/g, ''));
46
- extension = ext !== null && ext[1].toLowerCase() !== 'exe';
47
- }
48
- if (cluster || extension)
49
- continue;
50
- if (text.charCodeAt(at + m[0].length) === 47)
51
- continue; // the verb is a directory name inside a path
52
- return true;
53
- }
54
- return false;
55
- }