@holmes-lab/holmes-kit 0.35.17 → 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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
  <!-- @implements A-SPEC-209 -->
8
+ ## [0.35.18] - 2026-10-12
9
+
10
+ ### Fixed
11
+
12
+ - **An autonomy refusal names the child rule that forces the human decision** (A-SPEC-769). Measured 2026-10-12 in
13
+ the Codex X1 runtime session: `spec_approve` on a parent spec answered "autonomy hitl" with no reason an operator
14
+ could act on. `specApprovalAutonomyReason` now returns `upstream-has-human-aspec: <child id> — <child rule>` (the
15
+ `files-to-touch-root-only` policy of A-SPEC-654 was the rule in the measured case; the policy itself is unchanged).
16
+ - **The `--autonomy` usage entry, the `init` refusal line and the interactive prompt say the same thing** (A-SPEC-769.1).
17
+ The three texts had drifted apart; each now names the grade, what it decides alone, and what still asks a person.
18
+ - **A runtime deadline refusal says which phase spent the budget** (A-SPEC-769.2). `Selected hook runtime deadline
19
+ exceeded` now ends with `; phases (ms of <budget>): input <n|->, selection <n|->, hook child <n|->`, and the Stop hook
20
+ prints `[Holmes-Kit] Stop hook used <total> ms of its 18000 ms hook budget — …` with the per-stage clock
21
+ (`src/holmes/hooks/stop-timing.ts`) once a run passes half the budget. Measured: the `scan` stage alone is ≈7 s on
22
+ this workspace; the figure is now visible, not reduced — see Known issues.
23
+ - **`runtime-binding status` separates drift from conflict** (A-SPEC-769.3, A-SPEC-769.5, A-SPEC-769.6). The status carries
24
+ `drift [{ path, kind: 'operator-config' | 'stale-workspace' }]` beside `conflicts`, `router: 'intact' | 'changed'`
25
+ and `activation`; `doctor` reads the harness identity from the router rows. A receipt that differs only because
26
+ the operator edited `~/.claude/settings.json` stays a conflict as A-SPEC-752.5/752.6 pin it (owner decision pending).
27
+ - **A refusal written to the refusal log is answerable from its own hint** (A-SPEC-770, 770.1). Field report
28
+ 2026-10-12 (jarvis): "approval impossible" — the design was intact (REQ-563/690: a refusal outside the inbox is
29
+ granted with `approve --grant <id>`), but the hint carried no id and the inbox never said such requests existed.
30
+ Every refusal line now ends with `run: holmes-kit approve --grant <id> --target <root>` carrying the actual id, the
31
+ inbox (`--list`, `--watch`) prints a footer counting requests outside the inbox, and the `--refusals` closing line
32
+ spells the same command. The first repair had written the positional form `approve <id>`, which the CLI refuses
33
+ with `unexpected argument` — measured once on the released CLI before the hint was rewritten (A-SPEC-770.1).
34
+
35
+ ### Known issues
36
+
37
+ - The Stop hook `scan` stage still takes ≈7 s on a 440-file workspace; under a parallel full-suite load (≥ 9) the
38
+ 18 s hook budget is exceeded and the refusal is now explained but still a refusal. Reduction is a separate slice.
39
+ - The inbox footer glyph is `◆` (the file's bullet, pinned by A-SPEC-770.1); A-SPEC-770's text says `◇`. The spec
40
+ text is the stale side; it is amended with the next unseal of REQ-770, not by a code change.
41
+
8
42
  ## [0.35.17] - 2026-10-11
9
43
 
10
44
  ### Fixed
package/README.md CHANGED
@@ -9,8 +9,8 @@
9
9
  <!-- holmes-kit:attest:begin -->
10
10
  ![traced files](.ax/badges/traced.svg)
11
11
 
12
- **438/440** source files (99.5%) trace to an approved spec · **761/824** approved A-SPECs (92.3%) are anchored from code.
13
- Measured at `70dcb37ccf6b` (specs `sha256:675042379d48`) — reproduce with `holmes-kit attest`.
12
+ **439/441** source files (99.5%) trace to an approved spec · **769/832** approved A-SPECs (92.4%) are anchored from code.
13
+ Measured at `32936217f72e` (specs `sha256:889a6e38d4b1`) — reproduce with `holmes-kit attest`.
14
14
  <!-- holmes-kit:attest:end -->
15
15
 
16
16
  ---
@@ -23,6 +23,7 @@ Measured at `70dcb37ccf6b` (specs `sha256:675042379d48`) — reproduce with `hol
23
23
 
24
24
  ### 🛡️ Currently Supported Features (Production Features)
25
25
 
26
+ - **A refusal you cannot see in the inbox is still answerable from its own hint** *(new in 0.35.18)*: six repairs measured in a Codex X1 runtime session and a field report. Every refusal line written to the refusal log ends with `run: holmes-kit approve --grant <id> --target <root>` carrying the actual id, the inbox (`approve --list` / `--watch`) prints a footer counting requests outside the inbox, and the `--refusals` closing line spells the same command (the positional `approve <id>` the first repair wrote is refused by the CLI, so it was measured and rewritten). An autonomy refusal on a parent spec names the child rule that forces the human decision (`upstream-has-human-aspec: <id> — <rule>`). A runtime deadline refusal ends with the per-phase millisecond split, and the Stop hook prints how much of its 18 s budget it used once it passes half. `runtime-binding status` separates `drift` (operator-config / stale-workspace) from `conflicts` and reports whether the router is intact. The `--autonomy` usage, the `init` refusal and the interactive prompt now say the same thing.
26
27
  - **An agent is told what to do after an approval, and a patch is judged the way the tool applies it** *(new in 0.35.17)*: five repairs measured on a Codex worker in a SWE-bench comparison. `approval_status` now carries `request { id, state, question?, reason?, ts? }` (pending / held / granted / consumed / denied / revoked, read from the approval queue, with the operator's LATEST hold question) and one `nextAction` sentence — a sealed spec says "stop polling", a held request relays the question; the pending-approval hint ends with an `Agent:` line beside the unchanged operator lines. `test_run` reports `anchorDiagnostics` for an `@implements` list joined by `;`, `|`, `&`, `/` or `and` (the comma grammar does not read them; attribution is unchanged, the omission is named). A Codex `apply_patch` update is applied chunk by chunk from the previous chunk's position, as the tool does, so a context line that recurs earlier in the file no longer makes it "unreadable", and a patch that does not apply is refused by a sentence naming the file and the chunk. A quoted or escaped glob (`rg ".*"`) is no longer read as a spelling of the `.ax` store (an unquoted `.*` still is). The background refresh child records `failure { stage, reason }` on its freshness receipt instead of failing silently.
27
28
  - **The analysis names the unchanged files a change has broken** *(new in 0.35.16)*: with `changedFiles` given, `maintenance_analyze` reports under `impacts.removedNameUsers` every unchanged file that imports a changed file and still uses a top-level name that file no longer defines (removed or renamed), and the files still importing a deleted TypeScript/JavaScript file. Deterministic and read-only; TypeScript/JavaScript and Python. Measured on public repositories: every file named was one the commit did change (22 of 22, 21 of 21). It fires rarely — 2–7% of the files an incomplete change set was missing. Member names and changed signatures are not read.
28
29
  - **The analysis names the file a change still has to create** *(new in 0.35.15)*: with `changedFiles` given, `maintenance_analyze` reports under `impacts.missingNewFiles` every relative import a changed TypeScript/JavaScript file newly introduces that resolves to nothing — the importing file, the specifier and the candidate paths. Deterministic and read-only. On two unseen windows of a public TypeScript monorepo every naming was a file the change did create (precision 1.000), covering 78–86% of the not-yet-existing files an incomplete change set was missing. Only uncommitted changes in a git repository; other languages, bare package names and path aliases are not read.
package/dist/.build-id CHANGED
@@ -1 +1 @@
1
- e14712a6-mv3zqox3
1
+ 313705f8-mv4rnlmn
@@ -205,6 +205,10 @@ async function runWatch(root, io, actor, opts = {}) {
205
205
  if (!idleAnnounced) {
206
206
  io.print(exports.WATCH_IDLE);
207
207
  idleAnnounced = true;
208
+ // @implements A-SPEC-770 — once per idle announcement: the refusals this surface does not list, by count.
209
+ const footer = (0, approve_1.outsideInboxFooter)((0, approval_queue_1.refusalsOutsideInbox)(root));
210
+ if (footer !== null)
211
+ io.print(footer);
208
212
  }
209
213
  // No reset of `lastPresented` here (round-3): the top-of-pass prune above already intersects
210
214
  // it with the current pending set every pass, so on an empty queue it becomes empty before it
@@ -57,10 +57,17 @@ export declare function staleView(flags: Record<string, unknown>): {
57
57
  ttlMs: number;
58
58
  showAll: boolean;
59
59
  } | null;
60
+ /**
61
+ * @implements A-SPEC-770 — the one line an inbox screen ends with when this machine's refusal log holds open requests
62
+ * the screen does not list (A-SPEC-563.1 keeps gate refusals out of the inbox; A-SPEC-563.2 / A-SPEC-690 let
63
+ * `approve --grant <id>` reach them). A count and two commands — never a target. `null` when there is nothing to say.
64
+ * @implements A-SPEC-770.1 — the grant command is spelled with its flag: a positional id is refused by the CLI.
65
+ */
66
+ export declare function outsideInboxFooter(outside: number | undefined): string | null;
60
67
  export declare function renderPending(state: QueueState, view?: {
61
68
  staleHours: number;
62
69
  showAll: boolean;
63
- }): string;
70
+ }, outside?: number): string;
64
71
  /**
65
72
  * @implements A-SPEC-262.1
66
73
  * What a decision line must say. Round-1: `✓ approved — valid until <expires>` named NOTHING, so an index
@@ -39,6 +39,7 @@ exports.revokeGrant = revokeGrant;
39
39
  exports.denyRequest = denyRequest;
40
40
  exports.holdRequest = holdRequest;
41
41
  exports.staleView = staleView;
42
+ exports.outsideInboxFooter = outsideInboxFooter;
42
43
  exports.renderPending = renderPending;
43
44
  exports.subjectCells = subjectCells;
44
45
  exports.subjectRoom = subjectRoom;
@@ -86,7 +87,7 @@ const MAX_TTL_MINUTES = 7 * 24 * 60;
86
87
  const DEFAULT_RATIONALE = 'approved via holmes-kit approve';
87
88
  const findPending = (root, id) => {
88
89
  // @implements A-SPEC-576.1 — RESOLUTION reads everything; the human's LIST reads decisions only.
89
- // The inbox filter hides gate refusals from the screen, but `approve <id>` must still find one:
90
+ // The inbox filter hides gate refusals from the screen, but `approve --grant <id>` must still find one:
90
91
  // the fallback below only holds entries written after the REQ-563 split, so anything refused
91
92
  // before it lives in the queue alone. Filtering here would cut the out-of-band approval path the
92
93
  // deny message itself promises.
@@ -345,17 +346,34 @@ function staleView(flags) {
345
346
  return null;
346
347
  return { ttlMs: hours * 3_600_000, showAll: flags.all === true };
347
348
  }
348
- function renderPending(state, view) {
349
+ /**
350
+ * @implements A-SPEC-770 — the one line an inbox screen ends with when this machine's refusal log holds open requests
351
+ * the screen does not list (A-SPEC-563.1 keeps gate refusals out of the inbox; A-SPEC-563.2 / A-SPEC-690 let
352
+ * `approve --grant <id>` reach them). A count and two commands — never a target. `null` when there is nothing to say.
353
+ * @implements A-SPEC-770.1 — the grant command is spelled with its flag: a positional id is refused by the CLI.
354
+ */
355
+ function outsideInboxFooter(outside) {
356
+ if (!outside || outside <= 0)
357
+ return null;
358
+ // `◆` rather than the `◇` the spec sketched: §13 (approve-corpus) admits only the template's own glyphs on a decision
359
+ // row, and U+25C7 is of ambiguous width while U+25C6 is already furniture of this screen.
360
+ return `◆ ${outside} refusal(s) on this machine are outside this inbox (shell/gate refusals) — list them: ${(0, npx_bin_1.npxBin)()} holmes-kit approve --refusals · grant one: ${(0, npx_bin_1.npxBin)()} holmes-kit approve --grant <id>`;
361
+ }
362
+ function renderPending(state, view, outside) {
363
+ const withFooter = (lines) => {
364
+ const footer = outsideInboxFooter(outside);
365
+ return (footer === null ? lines : [...lines, footer]).join('\n');
366
+ };
349
367
  if (state.pending.length === 0) {
350
368
  // Round-7: this early return made the malformed-line row below UNREACHABLE in exactly the case
351
369
  // it exists for — a wholly corrupted queue printed "no requests waiting" and exited 0, which is
352
370
  // what an agent would see after destroying it. approval-queue.ts promises the opposite:
353
371
  // "an empty-looking queue must be distinguishable from a corrupted one".
354
372
  if (state.malformedLines > 0) {
355
- return ['No requests awaiting approval.',
356
- `(${state.malformedLines} unreadable line(s) in the queue — check for corruption)`].join('\n');
373
+ return withFooter(['No requests awaiting approval.',
374
+ `(${state.malformedLines} unreadable line(s) in the queue — check for corruption)`]);
357
375
  }
358
- return 'No requests awaiting approval.';
376
+ return withFooter(['No requests awaiting approval.']);
359
377
  }
360
378
  const lines = [`◆ ${state.pending.length} request(s) awaiting approval`, ''];
361
379
  // @implements A-SPEC-507.1 — the LIST VIEW sorts newest-activity-first and folds stale entries
@@ -396,7 +414,7 @@ function renderPending(state, view) {
396
414
  }
397
415
  if (state.malformedLines > 0)
398
416
  lines.push(`(${state.malformedLines} unreadable line(s) in the queue — check for corruption)`);
399
- return lines.join('\n');
417
+ return withFooter(lines);
400
418
  }
401
419
  /**
402
420
  * @implements A-SPEC-262.1
@@ -476,7 +494,8 @@ function renderRefusals(refusals, limit = 20) {
476
494
  lines.push(`${(0, screen_safe_1.rowField)(r.id, 20)} ${(0, screen_safe_1.rowField)(r.kind, screen_safe_1.KIND_COLS)} ${(0, screen_safe_1.rowField)(r.target, 40)}`);
477
495
  lines.push(` \u2502 ${(0, screen_safe_1.rowField)(r.why, 66)} ${(0, screen_safe_1.rowField)(r.ts, 24)}`);
478
496
  }
479
- lines.push('', `decide one: ${(0, npx_bin_1.npxBin)()} holmes-kit approve <id>`);
497
+ // @implements A-SPEC-770.1 — `--grant <id>`: the positional form this line named since 2026-09-06 is refused.
498
+ lines.push('', `decide one: ${(0, npx_bin_1.npxBin)()} holmes-kit approve --grant <id>`);
480
499
  return lines.join('\n');
481
500
  }
482
501
  function renderNonTtyHint(state) {
@@ -530,7 +549,7 @@ function renderNonTtyHint(state) {
530
549
  */
531
550
  async function runInteractive(root, io, actor) {
532
551
  const state = (0, approval_queue_1.readQueue)(root);
533
- io.print(renderPending(state));
552
+ io.print(renderPending(state, undefined, (0, approval_queue_1.refusalsOutsideInbox)(root))); // @implements A-SPEC-770
534
553
  if (state.pending.length === 0)
535
554
  return;
536
555
  const grantDefault = (p) => {
@@ -712,7 +712,11 @@ async function runDoctor(packageRoot, target, opts, extraChecks) {
712
712
  try {
713
713
  const report = (0, runtime_binding_1.runtimeBindingStatus)(runtimeRegistry, target ?? process.cwd());
714
714
  const s = report.selection;
715
- if (report.conflicts.length === 0) {
715
+ // @implements A-SPEC-769.6 — the identity is the ROUTER's: conferred when the receipt rows under the registry
716
+ // directory are intact, whatever a settings or workspace wiring row says (those are reported on their own rows
717
+ // and on the `runtime binding` line). Before: any receipt conflict withheld it, and an edited user settings file
718
+ // made doctor call the intact router "not this install's server" (measured 2026-10-12).
719
+ if (report.router === 'intact') {
716
720
  const script = (h, e) => path.join(path.dirname(runtimeRegistry), `${h}-${e}.js`);
717
721
  routed = { script, command: (h, e) => (0, runtime_binding_1.runtimeHookCommand)(runtimeRegistry, h, e),
718
722
  mcp: (h, e) => ['claude', 'codex', 'antigravity'].includes(h) && e?.command === process.execPath
@@ -737,8 +741,16 @@ async function runDoctor(packageRoot, target, opts, extraChecks) {
737
741
  catch { /* no build id */ }
738
742
  own = `; doctor runs from ${packageRoot} (build ${ownBuild}); sessions routed by this registry load the package named first`;
739
743
  }
744
+ // @implements A-SPEC-769.3 — drift outside the registry directory is named, not counted as a conflict: the routed
745
+ // identity above is conferred on an intact router, and the line says which operator-owned files changed and which
746
+ // receipt rows belong to a workspace that no longer exists.
747
+ const drift = report.drift ?? [];
748
+ const changedSinceInstall = drift.filter((d) => d.kind === 'operator-config').map((d) => d.path);
749
+ const staleRows = drift.filter((d) => d.kind === 'stale-workspace').map((d) => d.path);
740
750
  add('runtime binding', report.conflicts.length ? 'FAIL' : 'WARN', `${s.mode}: workspace=${s.workspaceRoot}; package=${s.packageRoot}; build=${s.buildId}${own}; specs=${s.specsRoot}; live activation unverified`
741
- + (report.conflicts.length ? `; ${report.conflicts.join('; ')}` : ''), 'Use runtime-binding status and setup --dry-run to inspect routed wiring. Native hook trust and enable state remain operator-controlled.');
751
+ + (report.conflicts.length ? `; ${report.conflicts.join('; ')}` : '')
752
+ + (changedSinceInstall.length ? `; changed since installation (operator-owned, still routed): ${changedSinceInstall.join(', ')}` : '')
753
+ + (staleRows.length ? `; stale receipt rows (workspace gone): ${staleRows.join(', ')}` : ''), 'Use runtime-binding status and setup --dry-run to inspect routed wiring. Native hook trust and enable state remain operator-controlled.');
742
754
  // @implements A-SPEC-751.4 — a source checkout whose sessions are routed to another package: say whether the
743
755
  // hooks it builds are the hooks those sessions run. A consumer project holds no package source and gets no row.
744
756
  const checkoutRoot = [target ?? process.cwd(), packageRoot].find((candidate) => {
@@ -214,9 +214,12 @@ const USAGE = `holmes-kit — deterministic ASE governance for a project
214
214
  --dry-run print the diff, write nothing
215
215
  --remove remove holmes-kit wiring (holmes-owned entries only)
216
216
  --force re-wire an already-wired target (requires HOLMES_APPROVAL)
217
- --autonomy grant autonomous spec approval (low-risk only; governance-critical
218
- still ask you). Non-interactive: requires HOLMES_APPROVAL. At a TTY,
219
- init asks instead. Off is default; turn off with --no-autonomy.
217
+ --autonomy grant autonomous spec approval (low-risk only; high-risk, architecture
218
+ and gate specs still ask you). This explicit flag is the
219
+ non-interactive spelling: never prompted, even at a terminal; it needs
220
+ an out-of-band HOLMES_APPROVAL of kind "autonomy-grant". To be ASKED,
221
+ run init at a terminal WITHOUT --autonomy. Off is default;
222
+ --no-autonomy keeps it off.
220
223
  --no-autonomy keep every spec approval human (default)
221
224
 
222
225
  holmes-kit ledger rechain re-chain forked ledger files against the committed mainline
@@ -999,7 +1002,9 @@ async function main(argv) {
999
1002
  const queueOpts = stale ? { now: Date.now(), ttlMs: stale.ttlMs } : undefined;
1000
1003
  const listView = stale ? { staleHours: stale.ttlMs / 3_600_000, showAll: stale.showAll } : undefined;
1001
1004
  if (flags.list) {
1002
- process.stdout.write(renderPending(readQueue(root, queueOpts), listView) + '\n');
1005
+ // @implements A-SPEC-770 — the list ends with the count of refusals outside it.
1006
+ const { refusalsOutsideInbox } = require('../governance/approval-queue');
1007
+ process.stdout.write(renderPending(readQueue(root, queueOpts), listView, refusalsOutsideInbox(root)) + '\n');
1003
1008
  return 0;
1004
1009
  }
1005
1010
  // @implements A-SPEC-650 — the whole picture, read-only; the list above stays script-clean.
@@ -570,7 +570,9 @@ function runInitUnguarded(opts) {
570
570
  if (opts.autonomy === true && !opts.autonomyInteractive
571
571
  && !(0, risk_gate_1.approvalCovers)(opts.approval, { kind: 'autonomy-grant', target: opts.target }, new Date().toISOString())) {
572
572
  return { ok: false, exitCode: 2, changes, messages: [
573
- 'Enabling autonomous spec approval needs a human: answer the interactive prompt at a terminal, or supply an out-of-band approval.',
573
+ // @implements A-SPEC-769.1 — the flag is never prompted (X1, 2026-10-12: the old line sent the operator to a prompt
574
+ // that does not open with the flag).
575
+ 'Enabling autonomous spec approval needs a human: --autonomy is the non-interactive spelling and is never prompted, even at a terminal. Run init at a terminal WITHOUT --autonomy to be asked, or supply an out-of-band approval.',
574
576
  `Set HOLMES_APPROVAL='{"actor":"<you>","token":"<any>","rationale":"<why>"}' (scoped approvals need kind "autonomy-grant") and re-run with --autonomy.`,
575
577
  ] };
576
578
  }
@@ -14,4 +14,9 @@ export declare function promptAgentSelection(availableAgents?: readonly Agent[],
14
14
  * Non-TTY returns false (leave HITL); the caller does not treat that as an interactive answer.
15
15
  * Default is NO — autonomy is opt-in.
16
16
  */
17
+ /**
18
+ * @implements A-SPEC-769.1 — what the prompt says matches the grader (X1, 2026-10-12: the old text said REQ/H-SPEC
19
+ * "ALWAYS ask", while A-SPEC-587 seals an upstream autonomously when every A-SPEC beneath it is low-risk).
20
+ */
21
+ export declare const AUTONOMY_PROMPT_TEXT: string;
17
22
  export declare function promptAutonomy(): Promise<boolean>;
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AUTONOMY_PROMPT_TEXT = void 0;
36
37
  exports.parseAgentList = parseAgentList;
37
38
  exports.promptAgentSelection = promptAgentSelection;
38
39
  exports.promptAutonomy = promptAutonomy;
@@ -157,15 +158,22 @@ async function promptAgentSelection(availableAgents = agents_1.AGENTS, currentWi
157
158
  * Non-TTY returns false (leave HITL); the caller does not treat that as an interactive answer.
158
159
  * Default is NO — autonomy is opt-in.
159
160
  */
161
+ /**
162
+ * @implements A-SPEC-769.1 — what the prompt says matches the grader (X1, 2026-10-12: the old text said REQ/H-SPEC
163
+ * "ALWAYS ask", while A-SPEC-587 seals an upstream autonomously when every A-SPEC beneath it is low-risk).
164
+ */
165
+ exports.AUTONOMY_PROMPT_TEXT = '\n 🔑 Autonomous spec approval\n'
166
+ + ' The agent may self-approve LOW-RISK specs (tests, benign changes). High-risk and irreversible\n'
167
+ + ' specs (C-SPEC/ADR, gate/security/architecture files, root-only or unbounded Files to Touch)\n'
168
+ + ' still ask you; a REQ or H-SPEC seals on its own only when every A-SPEC beneath it is low-risk,\n'
169
+ + ' and a REQ never admitted through requirement_triage always asks. You can turn this off\n'
170
+ + ' anytime: holmes-kit autonomy off.\n';
160
171
  async function promptAutonomy() {
161
172
  if (!process.stdin.isTTY || !process.stdout.isTTY)
162
173
  return false;
163
174
  return new Promise((resolve) => {
164
175
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
165
- process.stdout.write('\n 🔑 Autonomous spec approval\n'
166
- + ' The agent may self-approve LOW-RISK specs (tests, benign changes). Governance-critical,\n'
167
- + ' high-risk and irreversible specs (REQ/H-SPEC/C-SPEC, gate/security/architecture) ALWAYS\n'
168
- + ' ask you. You can turn this off anytime: holmes-kit autonomy off.\n');
176
+ process.stdout.write(exports.AUTONOMY_PROMPT_TEXT);
169
177
  rl.question(' Grant autonomous spec approval for this project? [y/N] ', (ans) => {
170
178
  rl.close();
171
179
  resolve(/^\s*y(es)?\s*$/i.test(ans));
@@ -36,6 +36,11 @@ export declare function registryOwnedWiring(file: string, registryPath?: string)
36
36
  export declare function runtimeBindingStatus(registryPath: string, workspace: string): {
37
37
  selection: import("../runtime/binding").RuntimeSelection;
38
38
  conflicts: string[];
39
+ drift: {
40
+ path: string;
41
+ kind: "operator-config" | "stale-workspace";
42
+ }[];
43
+ router: "changed" | "intact";
39
44
  activation: "unverified";
40
45
  };
41
46
  export declare function runRuntimeBinding(opts: RuntimeBindingOptions): unknown;
@@ -162,11 +162,30 @@ function registryOwnedWiring(file, registryPath) {
162
162
  return registryWiringOwnership(file, registryPath).owned;
163
163
  }
164
164
  function runtimeBindingStatus(registryPath, workspace) {
165
- const selection = (0, binding_1.selectRuntime)((0, binding_1.readRuntimeRegistry)(registryPath), { cwd: workspace });
165
+ const registry = (0, binding_1.readRuntimeRegistry)(registryPath);
166
+ const selection = (0, binding_1.selectRuntime)(registry, { cwd: workspace });
166
167
  const manifest = readOptional(path.join(path.dirname(registryPath), 'installation.json'));
167
168
  const conflicts = [];
168
- if (manifest === null)
169
+ // @implements A-SPEC-769.3 — a row that differs from the receipt is classified, not only counted. Measured 2026-10-12
170
+ // (X1): every router file under the registry directory matched, and the "conflicts" were operator-owned configuration
171
+ // that changes by design (hook trust state, Claude settings) plus six rows of a removed temporary workspace — on which
172
+ // doctor refused the routed identity and called the intact router "not this install's server".
173
+ // @implements A-SPEC-769.5 / A-SPEC-769.6 — what counts as operator drift is only what was MEASURED to change by
174
+ // design: the registry file (a dead binding is deleted by hand; the dispatcher reads the registry live) and the Codex
175
+ // USER config (Codex rewrites its `[projects.*]`, `[hooks.state.*]`, plugin and marketplace tables itself). Every
176
+ // other wiring file — Claude settings (A-SPEC-752.5/752.6: a digest cannot say which key changed, and some keys
177
+ // switch Holmes off), `.mcp.json`, the Codex hooks files, a project Codex config, the Antigravity files — keeps the
178
+ // receipt conflict. The ROUTER verdict is the receipt rows under the registry directory alone.
179
+ const drift = [];
180
+ const registryDir = path.dirname(registryPath);
181
+ const under = (dir, file) => { const rel = path.relative(dir, file); return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel); };
182
+ const workspaceRoots = registry.bindings.map((b) => b.workspaceRoot);
183
+ const codexUserConfig = (file) => path.basename(file) === 'config.toml' && path.basename(path.dirname(file)) === '.codex' && !workspaceRoots.some((w) => under(w, file));
184
+ let routerChanged = false;
185
+ if (manifest === null) {
169
186
  conflicts.push('No installation receipt; registry selection alone does not establish wiring');
187
+ routerChanged = true;
188
+ }
170
189
  else {
171
190
  const rows = document(manifest, 'installation.json').files;
172
191
  if (!Array.isArray(rows))
@@ -176,11 +195,30 @@ function runtimeBindingStatus(registryPath, workspace) {
176
195
  throw new Error('Invalid installation file record');
177
196
  const current = readOptional(row.path);
178
197
  // A-SPEC-752.5: the view's digest, or the whole file's for a row written before the view existed.
179
- if (current === null || (digest(wiringViewOf(row.path, current)) !== row.digest && digest(current) !== row.digest))
198
+ if (current !== null && (digest(wiringViewOf(row.path, current)) === row.digest || digest(current) === row.digest))
199
+ continue;
200
+ const registryFile = current !== null && path.resolve(row.path) === path.resolve(registryPath);
201
+ // 1. a router program (or the receipt's neighbours) under the registry directory: a conflict, and the router is changed.
202
+ if (under(registryDir, row.path) && !registryFile) {
180
203
  conflicts.push(`Wiring changed or incomplete: ${row.path}`);
204
+ routerChanged = true;
205
+ continue;
206
+ }
207
+ // 2./3. the registry file, or the Codex user config, present but changed: operator drift.
208
+ if (registryFile || (current !== null && codexUserConfig(row.path))) {
209
+ drift.push({ path: row.path, kind: 'operator-config' });
210
+ continue;
211
+ }
212
+ // 4. a missing file whose directory is gone: a stale row of a workspace that no longer exists.
213
+ if (current === null && !fs.existsSync(path.dirname(row.path))) {
214
+ drift.push({ path: row.path, kind: 'stale-workspace' });
215
+ continue;
216
+ }
217
+ // 5. everything else — a changed wiring file, or a living workspace that lost one: the receipt conflict as before.
218
+ conflicts.push(`Wiring changed or incomplete: ${row.path}`);
181
219
  }
182
220
  }
183
- return { selection, conflicts, activation: 'unverified' };
221
+ return { selection, conflicts, drift, router: routerChanged ? 'changed' : 'intact', activation: 'unverified' };
184
222
  }
185
223
  function runRuntimeBinding(opts) {
186
224
  if (opts.activateHooks !== undefined && (!Array.isArray(opts.activateHooks)
@@ -24,7 +24,7 @@ export declare const DECISION_KINDS: ReadonlySet<string>;
24
24
  * The line a refusal ends with to name its pending request and the operator command.
25
25
  * @implements A-SPEC-134.2 — one wording for a request just filed and for one that was already pending.
26
26
  */
27
- export declare function pendingRequestLine(id: string): string;
27
+ export declare function pendingRequestLine(id: string, kind?: string): string;
28
28
  export interface RefusalRecord {
29
29
  event: 'requested';
30
30
  id: string;
@@ -222,6 +222,12 @@ export declare function queueHint(root: string, req: {
222
222
  *
223
223
  * Measured 2026-09-19: `readRefusals` found req-9e92e52bd233 while `approve --grant` refused it.
224
224
  */
225
+ /**
226
+ * @implements A-SPEC-770 — how many open requests this machine's refusal log (and any pre-split queue row of a
227
+ * non-decision kind) holds that the inbox screen does not list. Information for a footer, never a lever: an
228
+ * unreadable store counts 0 (the list itself still renders as today).
229
+ */
230
+ export declare function refusalsOutsideInbox(root: string): number;
225
231
  export declare function grantableRequests(root: string): PendingRequest[];
226
232
  /**
227
233
  * @implements A-SPEC-690
@@ -45,6 +45,7 @@ exports.enqueueApprovalRequestDetailed = enqueueApprovalRequestDetailed;
45
45
  exports.appendQueueEvent = appendQueueEvent;
46
46
  exports.readQueue = readQueue;
47
47
  exports.queueHint = queueHint;
48
+ exports.refusalsOutsideInbox = refusalsOutsideInbox;
48
49
  exports.grantableRequests = grantableRequests;
49
50
  exports.openOccurrences = openOccurrences;
50
51
  exports.asPendingRequest = asPendingRequest;
@@ -96,8 +97,18 @@ exports.DECISION_KINDS = new Set([
96
97
  * The line a refusal ends with to name its pending request and the operator command.
97
98
  * @implements A-SPEC-134.2 — one wording for a request just filed and for one that was already pending.
98
99
  */
99
- function pendingRequestLine(id) {
100
- return `\n[승인 대기 ${id}] 운영자: ${(0, npx_bin_1.npxBin)()} holmes-kit approve`;
100
+ function pendingRequestLine(id, kind) {
101
+ const command = `${(0, npx_bin_1.npxBin)()} holmes-kit approve`;
102
+ // @implements A-SPEC-770 — a request outside the decision inbox (A-SPEC-563.1 routes gate refusals to the local
103
+ // refusal log) names the id-bearing command, because the bare command opens a screen that by design does not list
104
+ // it. Field report (jarvis, 2026-10-11): the operator ran the bare command, saw six old inbox requests, and the
105
+ // agent's shell command was refused again with the same id. A decision kind keeps the short line: it IS listed.
106
+ // @implements A-SPEC-770.1 — the id rides the `--grant` flag: the CLI refuses a positional id (`unexpected
107
+ // argument: req-…`, measured by the operator on 0.35.17 with the command this line used to name).
108
+ if (kind !== undefined && !exports.DECISION_KINDS.has(kind)) {
109
+ return `\n[승인 대기 ${id}] 운영자: ${command} --grant ${id} — 인박스 화면에는 뜨지 않는 거부입니다(${command} --refusals 로 조회)`;
110
+ }
111
+ return `\n[승인 대기 ${id}] 운영자: ${command}`;
101
112
  }
102
113
  const REFUSALS_FILE_RE = /^refusals\.([^.]+)\.jsonl$/;
103
114
  function refusalsFilename(replica) {
@@ -519,7 +530,7 @@ function queueHint(root, req, opts) {
519
530
  // @implements A-SPEC-564.2 — the hint is composed BEFORE the enqueue so the refusal record can
520
531
  // carry its own feedback cost: reasonBytes = the caller's base reason + this hint, i.e. the text
521
532
  // that actually re-enters the conversation. Observation only — nothing reads it on a gate path.
522
- const hint = denialLine + (opts?.pendingHint ? opts.pendingHint(id) : pendingRequestLine(id));
533
+ const hint = denialLine + (opts?.pendingHint ? opts.pendingHint(id) : pendingRequestLine(id, req.kind)); // @implements A-SPEC-770
523
534
  return enqueueApprovalRequest(root, { ...req, reasonBytes: (opts?.baseReasonBytes ?? 0) + hint.length })
524
535
  ? hint
525
536
  : denialLine;
@@ -537,6 +548,20 @@ function queueHint(root, req, opts) {
537
548
  *
538
549
  * Measured 2026-09-19: `readRefusals` found req-9e92e52bd233 while `approve --grant` refused it.
539
550
  */
551
+ /**
552
+ * @implements A-SPEC-770 — how many open requests this machine's refusal log (and any pre-split queue row of a
553
+ * non-decision kind) holds that the inbox screen does not list. Information for a footer, never a lever: an
554
+ * unreadable store counts 0 (the list itself still renders as today).
555
+ */
556
+ function refusalsOutsideInbox(root) {
557
+ try {
558
+ const inbox = new Set(readQueue(root).pending.map((p) => p.id));
559
+ return grantableRequests(root).filter((p) => !inbox.has(p.id)).length;
560
+ }
561
+ catch {
562
+ return 0;
563
+ }
564
+ }
540
565
  function grantableRequests(root) {
541
566
  const state = readQueue(root, { includeAllKinds: true });
542
567
  const seen = new Set(state.pending.map((p) => p.id));
@@ -185,6 +185,10 @@ function autonomyRuleMeaning(rule) {
185
185
  return 'the gate change does not declare its direction as tightens or wording';
186
186
  if (rule.startsWith('breaking-change-'))
187
187
  return rule === 'breaking-change-undeclared' ? 'breaking_change is not declared' : 'the breaking_change grade is not one the grader knows';
188
+ // @implements A-SPEC-769 — `upstream-has-human-aspec: <child id> — <child rule>` composes the child's own meaning.
189
+ const upstream = /^upstream-has-human-aspec: (\S+) — (.+)$/.exec(rule);
190
+ if (upstream)
191
+ return `an A-SPEC beneath it (${upstream[1]}) is the operator's to seal — ${autonomyRuleMeaning(upstream[2])}`;
188
192
  switch (rule) {
189
193
  case 'upstream-without-aspec': return 'no A-SPEC exists beneath it yet, so its scope is unknown';
190
194
  case 'upstream-has-human-aspec': return 'an A-SPEC beneath it is the operator\'s to seal';
@@ -209,7 +213,15 @@ function specApprovalAutonomyReason(spec, resolveParent, descendants) {
209
213
  const below = (descendants ?? []).filter((s) => s.type === 'A-SPEC');
210
214
  if (below.length === 0)
211
215
  return 'upstream-without-aspec'; // unknown scope stays human
212
- return below.every((a) => specApprovalAutonomyReason(a, resolveParent) === null) ? null : 'upstream-has-human-aspec';
216
+ // @implements A-SPEC-769 — the FIRST child that is the operator's, with its own rule: X1 (2026-10-12) handed a
217
+ // REQ and an H-SPEC to the operator over one A-SPEC's root-only Files to Touch, and the note said only that
218
+ // "an A-SPEC beneath it" was the operator's — neither the agent nor the operator could tell which, or why.
219
+ for (const a of below) {
220
+ const childRule = specApprovalAutonomyReason(a, resolveParent);
221
+ if (childRule !== null)
222
+ return `upstream-has-human-aspec: ${a.id} — ${childRule}`;
223
+ }
224
+ return null;
213
225
  }
214
226
  case 'C-SPEC':
215
227
  case 'ADR': // @implements A-SPEC-571.1 — a decision is the human's to seal
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The Stop hook's stage clock. Measured 2026-10-12 (X1): the Stop hook took 11.3 s at load 5 against the
3
+ * dispatcher's 18 s budget (A-SPEC-751.1), and a deadline refusal said nothing about which stage took the time.
4
+ * `mark(name)` closes the stage that ran since the previous mark; `line(budget)` names every stage with its
5
+ * milliseconds when the stages together used at least `threshold` (default half) of the budget, else `null`.
6
+ * Pure: no I/O, no clock of its own beyond the injected `now`. It never touches the verdict.
7
+ */
8
+ export interface StageClock {
9
+ mark(name: string): void;
10
+ line(budgetMs: number, threshold?: number): string | null;
11
+ }
12
+ export declare function createStageClock(now?: () => number): StageClock;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStageClock = createStageClock;
4
+ function createStageClock(now = () => performance.now()) {
5
+ const stages = [];
6
+ let last = now();
7
+ return {
8
+ mark(name) {
9
+ const t = now();
10
+ stages.push({ name, ms: Math.max(0, t - last) });
11
+ last = t;
12
+ },
13
+ line(budgetMs, threshold = 0.5) {
14
+ if (stages.length === 0)
15
+ return null;
16
+ const total = stages.reduce((sum, s) => sum + s.ms, 0);
17
+ if (total < budgetMs * threshold)
18
+ return null;
19
+ return `[Holmes-Kit] Stop hook used ${Math.round(total)} ms of its ${budgetMs} ms hook budget — ${stages.map((s) => `${s.name} ${Math.round(s.ms)} ms`).join(', ')}`;
20
+ },
21
+ };
22
+ }
@@ -74,6 +74,9 @@ const autonomy_1 = require("../governance/autonomy");
74
74
  const risk_gate_1 = require("../guardrail/risk-gate");
75
75
  const json_state_1 = require("../project/json-state");
76
76
  const node_child_process_1 = require("node:child_process");
77
+ // @implements A-SPEC-769.2 — the stage clock and the budget it is measured against.
78
+ const stop_timing_1 = require("./stop-timing");
79
+ const hook_process_1 = require("../runtime/hook-process");
77
80
  /**
78
81
  * @implements A-SPEC-734 (round 11) — every git child of the Stop hook runs under a timeout, and a timeout or
79
82
  * failure is "no signal": a FIFO `.gitignore` (or a FIFO in place of a tracked file) kept `git status` blocked
@@ -1340,6 +1343,9 @@ if (require.main === module) {
1340
1343
  process.stdin.on('end', () => {
1341
1344
  try {
1342
1345
  const input = JSON.parse(buf || '{}');
1346
+ // @implements A-SPEC-769.2 — stage marks sit OUTSIDE every try block below, so a stage that throws is still closed
1347
+ // by the next mark; the line is printed once the verdict is decided and never touches it.
1348
+ const clock = (0, stop_timing_1.createStageClock)();
1343
1349
  const sessionId = typeof input.session_id === 'string' ? input.session_id : 'unknown-session';
1344
1350
  // @implements A-SPEC-190 (round 8) — same wiring channel as the PreToolUse hook.
1345
1351
  const { wiredSpecsDir } = require('./pre-tool-use');
@@ -1402,6 +1408,7 @@ if (require.main === module) {
1402
1408
  catch {
1403
1409
  testCasesByAspec = undefined;
1404
1410
  }
1411
+ clock.mark('specs');
1405
1412
  // EXECUTION evidence (ART-4 upgrade): usable only when produced at the CURRENT git HEAD, so a
1406
1413
  // stale record can never vouch for changed code. Absent/stale -> syntactic fallback.
1407
1414
  let executedByAspec;
@@ -1437,6 +1444,7 @@ if (require.main === module) {
1437
1444
  changedAspecs = undefined;
1438
1445
  outcomesByAspec = undefined;
1439
1446
  }
1447
+ clock.mark('evidence');
1440
1448
  // @implements A-SPEC-574.4 — the code graph's acyclicity, judged where the code exists. The
1441
1449
  // scan is the same one every other layer uses; the classification reads only the files an
1442
1450
  // import edge starts from. Fail-open in every direction: any error leaves the article silent,
@@ -1452,6 +1460,7 @@ if (require.main === module) {
1452
1460
  catch {
1453
1461
  sharedScan = undefined;
1454
1462
  }
1463
+ clock.mark('scan');
1455
1464
  // Its OWN try, like the observation below: a fault in the architecture judgement must not
1456
1465
  // discard the cycle evidence, nor the other way round.
1457
1466
  let forbiddenEdges;
@@ -1493,6 +1502,7 @@ if (require.main === module) {
1493
1502
  catch {
1494
1503
  cycles = undefined;
1495
1504
  }
1505
+ clock.mark('cycles');
1496
1506
  // Provenance-chain verification (fail-open: a verify error skips the check, never crashes).
1497
1507
  let provenance;
1498
1508
  // @implements A-SPEC-148
@@ -1509,6 +1519,7 @@ if (require.main === module) {
1509
1519
  catch {
1510
1520
  provenance = undefined;
1511
1521
  }
1522
+ clock.mark('provenance');
1512
1523
  // @implements A-SPEC-160 — supply the findings ledger so ART-6 can see judgements sealed on a
1513
1524
  // diverged server. An article nobody feeds is a dead article; ADR-014's discipline applies to
1514
1525
  // the constitution too.
@@ -1527,6 +1538,7 @@ if (require.main === module) {
1527
1538
  const unrecorded = unrecordedApprovals(stopProjectRoot());
1528
1539
  // @implements A-SPEC-455
1529
1540
  const rolledBack = rolledBackLedgers(stopProjectRoot());
1541
+ clock.mark('ledgers');
1530
1542
  // @implements A-SPEC-564.2 — the Claude usage enrichment: numbers out of transcript_path into
1531
1543
  // the session-context ledger, once per session. Capability-declared: Codex/AGY pass no
1532
1544
  // transcript_path and skip silently. Fail-open around EVERYTHING — observation never touches
@@ -1556,6 +1568,7 @@ if (require.main === module) {
1556
1568
  }
1557
1569
  }
1558
1570
  catch { /* silent skip — the other harnesses' path, and any read failure, land here */ }
1571
+ clock.mark('usage');
1559
1572
  // @implements A-SPEC-566.4 — graph freshness rides the same turn boundary, detached and
1560
1573
  // TTL-gated (A-SPEC-547.2's idiom): staleness was MEASURED to be the advisory's quality
1561
1574
  // factor (7 findings on an 8-day graph, 17 after a 1s reindex). Never waits, never judges.
@@ -1569,8 +1582,10 @@ if (require.main === module) {
1569
1582
  });
1570
1583
  }
1571
1584
  catch { /* maintenance, never a hook failure */ }
1585
+ clock.mark('refresh');
1572
1586
  // @implements A-SPEC-660 — the marker walk: no signal when it cannot run (never a clean verdict).
1573
1587
  const knownDefects = collectKnownDefects(stopProjectRoot(), new Date());
1588
+ clock.mark('defects');
1574
1589
  // @implements A-SPEC-664 — the CI matrix line rides beside the constitution's verdict.
1575
1590
  let ci;
1576
1591
  try {
@@ -1579,6 +1594,7 @@ if (require.main === module) {
1579
1594
  catch {
1580
1595
  ci = undefined;
1581
1596
  }
1597
+ clock.mark('ci');
1582
1598
  // @implements A-SPEC-673 — the build-freshness line rides the same non-blocking channel.
1583
1599
  let dist;
1584
1600
  try {
@@ -1587,6 +1603,7 @@ if (require.main === module) {
1587
1603
  catch {
1588
1604
  dist = undefined;
1589
1605
  }
1606
+ clock.mark('dist');
1590
1607
  // @implements A-SPEC-681 — the analysis line rides the same non-blocking channel.
1591
1608
  let analysis;
1592
1609
  try {
@@ -1595,6 +1612,7 @@ if (require.main === module) {
1595
1612
  catch {
1596
1613
  analysis = undefined;
1597
1614
  }
1615
+ clock.mark('analysis');
1598
1616
  // @implements A-SPEC-683 — read-only: the refresh child computed this, the hook only reports.
1599
1617
  let semantic;
1600
1618
  try {
@@ -1604,6 +1622,7 @@ if (require.main === module) {
1604
1622
  catch {
1605
1623
  semantic = undefined;
1606
1624
  }
1625
+ clock.mark('semantic');
1607
1626
  // @implements A-SPEC-694 — `cycles` rides in the evidence below. It was computed and written
1608
1627
  // to the observation ledger from the founding commit on (071bbf0c) and never handed over, so
1609
1628
  // the ART-2 track branch and the constitution's strict branch were dead code in the product:
@@ -1673,6 +1692,15 @@ if (require.main === module) {
1673
1692
  }
1674
1693
  const guard = decideStopGuard(out.block, guardCountOrZero(sessionId));
1675
1694
  const persisted = writeGuardCount(sessionId, guard.nextCount);
1695
+ // @implements A-SPEC-769.2 — the stage line, only when the stages used at least half of the hook budget; a
1696
+ // clock fault is swallowed, because an observation never touches the verdict.
1697
+ clock.mark('evaluate');
1698
+ try {
1699
+ const timing = clock.line(hook_process_1.HOOK_BUDGET_MS);
1700
+ if (timing !== null)
1701
+ process.stderr.write(`${timing}\n`);
1702
+ }
1703
+ catch { /* never a lever */ }
1676
1704
  // @implements A-SPEC-134 — the cap-yield is no longer silent: a clean turn clears any debt, a
1677
1705
  // give-up records the unresolved articles so WRITE_CODE is blocked until the constitution is
1678
1706
  // clean again. Fail-open: a debt-state write error never changes the stop verdict.
@@ -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.17",
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",