@holmes-lab/holmes-kit 0.36.1 → 0.37.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +4 -3
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/cli/attest.d.ts +5 -1
  5. package/dist/holmes/cli/attest.js +18 -7
  6. package/dist/holmes/cli/index.js +38 -4
  7. package/dist/holmes/cpg/import-resolver.js +1 -1
  8. package/dist/holmes/governance/approval-queue.d.ts +5 -0
  9. package/dist/holmes/governance/approval-queue.js +11 -2
  10. package/dist/holmes/governance/push-gate-runner.js +3 -1
  11. package/dist/holmes/governance/tool-actions.js +4 -0
  12. package/dist/holmes/guardrail/operator-person.d.ts +14 -0
  13. package/dist/holmes/guardrail/operator-person.js +43 -0
  14. package/dist/holmes/guardrail/refusal-codes.js +4 -2
  15. package/dist/holmes/hooks/stop.js +3 -1
  16. package/dist/holmes/mcp/elicit-approval.d.ts +2 -0
  17. package/dist/holmes/mcp/elicit-approval.js +9 -3
  18. package/dist/holmes/mcp/handlers/approval-ask.d.ts +19 -0
  19. package/dist/holmes/mcp/handlers/approval-ask.js +89 -0
  20. package/dist/holmes/mcp/handlers/review-verdict.d.ts +18 -0
  21. package/dist/holmes/mcp/handlers/review-verdict.js +67 -0
  22. package/dist/holmes/mcp/handlers.d.ts +9 -0
  23. package/dist/holmes/mcp/handlers.js +25 -0
  24. package/dist/holmes/mcp/harness-attestation.d.ts +15 -3
  25. package/dist/holmes/mcp/harness-attestation.js +36 -9
  26. package/dist/holmes/mcp/operator-recovery.js +3 -1
  27. package/dist/holmes/mcp/tool-schemas.js +25 -0
  28. package/dist/holmes/review/verdicts.d.ts +4 -0
  29. package/dist/holmes/review/verdicts.js +17 -4
  30. package/dist/holmes/rtm/traced-files.d.ts +4 -0
  31. package/dist/holmes/rtm/traced-files.js +16 -5
  32. package/package.json +1 -1
  33. package/playbooks/promote-slice/PLAYBOOK.md +3 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,83 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
  <!-- @implements A-SPEC-209 -->
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.37.1] - 2026-10-21
11
+
12
+ Two fixes. On Windows, 0.37.0 refused grants from a person's own terminal; Windows has been checked with fixture tests here but not yet re-measured on a Windows machine. The traced-files badge now counts only what git tracks.
13
+
14
+ ### Fixed
15
+ - **Windows: a person's own terminal can grant again (A-SPEC-779.6).** In 0.37.0, A-SPEC-779.4 refuses a granting act when the process's parents cannot be read. On Windows that refused every terminal, the person's own included. The Windows agent measured it and the owner reproduced it (`approve` → `grant.operator-only (process 15464 could not be read)`).
16
+ - Cause: Windows does not reparent orphans, so every walk up `ParentProcessId` ends at a parent that has exited. The lookup could not tell "no such process" from "the query failed".
17
+ - The fix: the CIM query now runs with `-ErrorAction Stop` and says `GONE` only when it answered with no row. An exited parent, or a parent created after its child (a reused pid), is the top of the chain, as pid 1 is on POSIX. A failed query still refuses.
18
+ - `review record` takes the same walk and now records a person on Windows.
19
+ - When the parents cannot be read, the refusal names the session's approval form instead of "their own terminal".
20
+ - POSIX is unchanged. Covered by fixture tests on every OS; not yet re-measured on a Windows machine.
21
+ - `holmes-kit attest` counts only the files git tracks (A-SPEC-702.1). In a working checkout it also counted ignored build output and local scripts. `dist-tools/` `.js` copies carried the anchors and counted as traced; their `.d.ts` files did not. So the badge read 476/484 where a clean clone of the same commit read 466/468, and the commit it named did not reproduce it. The files left out are counted as `notTracked` in `--json`, and the text names how many. Outside git every scanned file still counts. A tracked listing that does not answer counts everything and marks the commit `+unknown`.
22
+ - A-SPEC-406 is anchored from code again. REQ-674 moved its dotted-import resolution into `cpg/import-resolver.ts`, and the `@implements` became a plain comment.
23
+ - This repository's badge excludes `docs/goals/probes/`, two dated measurement scripts kept verbatim beside their evidence. The README's reproduce line names the exclusion.
24
+
25
+ ## [0.37.0] - 2026-10-21
26
+
27
+ Approvals happen in the session. The owner asked on 2026-10-20 whether approvals still need a command typed in a
28
+ separate terminal. An audit found they did. Only spec seals, critical-finding resolutions and runtime binding were
29
+ asked in the session, and those forms closed after 240 seconds. Every shell, config, code-write, autonomy, reappraisal
30
+ and reconcile approval, and every independent review verdict, needed a terminal. The same audit found that an agent's
31
+ own shell could approve its own refused command. That hole is closed first in this release.
32
+
33
+ Upgrading: recommended for every workspace (security fix). From inside a session, `! holmes-kit approve --grant …`
34
+ now refuses. Answer the session's approval form instead (call `approval_ask`), or grant from your own terminal.
35
+
36
+ ### Security
37
+
38
+ - **An agent's own shell can no longer approve its own refused command** (A-SPEC-779.4).
39
+ - Measured on 0.36.1 in a throwaway fixture: `git push --force origin main` was denied with
40
+ `[승인 대기 req-…] 운영자: npx holmes-kit approve --grant req-…`. The hook allowed that command from a tool call,
41
+ `grantGuard` let a non-terminal grant through outside a run, and the refused command was then **allowed**.
42
+ - After: `approve --grant`, `approve --watch`, the interactive approval screen, and the terminal path of
43
+ `autonomy on` and `autonomy delegate` refuse when the process carries an agent harness's environment marker, has a
44
+ harness among its parents, or its parents cannot be read. Measured live: refused with `CLAUDECODE`, refused again
45
+ with the markers removed (`process:claude`), and no grant written.
46
+ - Deny, revoke, ask, withdraw and the read-only views are unchanged. A grant from your own terminal is unchanged.
47
+ - Residual, named: a script that loads the package's modules and calls `grantRequest` itself runs as the same user
48
+ and is not refused.
49
+
50
+ ### Added
51
+
52
+ - **`approval_ask`: decide any pending request in the session's approval form** (A-SPEC-718.4).
53
+ - It takes the id a refusal names, from the inbox or this machine's refusal log, and shows it to the person in the
54
+ harness's MCP form. The person's answer is recorded exactly as `approve --grant/--deny/--ask` records it, under
55
+ actor `elicitation:<client>`. Silence records nothing.
56
+ - Measured live in Claude Code: a refused `rm -rf <scratch dir>` was asked, the owner chose approve, and the retry
57
+ passed once.
58
+ - Shell, config and code-write requests are asked only on a client measured to wait for a person: claude-code today.
59
+ Codex and Antigravity are a named gap until their auto-answer modes are measured.
60
+ - **`review_verdict`: an independent review verdict from the session's approval form** (A-SPEC-102.9).
61
+ - approve records pass, deny records fail with the person's reason. The verdict is `person: true`,
62
+ `channel: elicitation:<client>`, `independent: true`, so it satisfies the review gate without a separate terminal.
63
+ - `holmes-kit review record` is unchanged: it is independent only from a person's own terminal.
64
+ - Measured live: the owner answered pass for `a633d753..41b82c30` in the form. The ledger line reads
65
+ `person: true, channel: elicitation:claude-code, independent: true`, and the review gate for that range passes.
66
+ - **A request a run awaits is decided in the interactive session's form** (A-SPEC-779.5).
67
+ - The run's own server still never asks. The CLI's terminal-only rule for such a request is unchanged.
68
+
69
+ ### Changed
70
+
71
+ - **Every approval refusal tells the agent to call `approval_ask` with its id** (A-SPEC-718.5).
72
+ - The hint now ends with `Agent: call approval_ask with id "req-…" — the person decides …`, in two rows inside the
73
+ 80-column approval screen. The `approval.required` envelope names `approval_ask` first. The operator's terminal
74
+ line above it is unchanged.
75
+ - **The in-session approval form waits for the person** (A-SPEC-718.6).
76
+ - Before: a lock-free form expired after 240 s, shown at most twice.
77
+ - After: it waits up to 24 h, and its last line says it waits. Measured live: a form left open about 6 minutes was
78
+ approved and the retry passed. review-resolve keeps 120 s because it holds the findings-ledger lock.
79
+
80
+ ### Known issues
81
+
82
+ - "Approve by typing it as the next prompt" was considered and left out (owner, 2026-10-21). The clients without forms
83
+ (`claude -p`, `codex exec`) have no person typing a next prompt, and interactive sessions already have the form.
84
+ - On Windows, five reds in four suites new in 0.36.0 are test-side or fail closed (747.7, 747.10, 747.9 ×2, 476.3),
85
+ plus a PowerShell-only 747.4 over-block (Windows report of 2026-10-20).
86
+
10
87
  ## [0.36.1] - 2026-10-20
11
88
 
12
89
  A Windows patch. On a Windows host, Codex and Antigravity run the shell text they send under a Bash name in Windows
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
- **473/481** source files (98.3%) trace to an approved spec · **928/1005** approved A-SPECs (92.3%) are anchored from code.
13
- Measured at `8b45cd0dcb78` (specs `sha256:0b3ecc947d6c`) — reproduce with `holmes-kit attest`.
12
+ **466/466** source files (100%) trace to an approved spec · **937/1013** approved A-SPECs (92.4%) are anchored from code.
13
+ Measured at `fd66f7ce5fef` (specs `sha256:7a6c4957d5c0`) — reproduce with `holmes-kit attest --exclude docs/goals/probes/`.
14
14
  <!-- holmes-kit:attest:end -->
15
15
 
16
16
  ---
@@ -22,6 +22,7 @@ Measured at `8b45cd0dcb78` (specs `sha256:0b3ecc947d6c`) — reproduce with `hol
22
22
  ---
23
23
 
24
24
  ### 🛡️ Currently Supported Features (Production Features)
25
+ - **Approvals happen in the session, not in a separate terminal** *(new in 0.37.0 — security fix, upgrade recommended)*: a refusal now ends with `Agent: call approval_ask with id "req-…"`. The MCP tool `approval_ask` shows that request in the harness's approval form, and the person's answer is recorded exactly as `holmes-kit approve` records it. That covers shell, config and code-write approvals (on Claude Code today; Codex and Antigravity are a named gap until measured) and a request a run awaits. `review_verdict` records an independent review verdict the same way. The form waits for the person (no 240-second limit). An agent's own shell, and the session's `!`, can no longer run `approve --grant`, `--watch` or `autonomy on`: through 0.36.1 an agent could approve its own refused command by running the command its refusal printed.
25
26
  - **An orchestrator can run governed agents, and reviews become gates** *(new in 0.36.0)*: `holmes-kit run start --worktree <dir> --engine claude|codex|agy [--scope <A-SPEC>]…` opens a run that pins the CLI, MCP and hook builds, prints the headless command and a stop key, and ends only with that key (`run status`, `run transition`, `run stop`). Inside a run every judgement fails closed: agent launches are refused, refusals are logged with a repeat stop, an approval pauses the run until the operator decides it in a terminal, a declared stage machine (analysis → design → implement → review → test → done) denies writes per stage, and Stop and push wait for an independent passing review. `holmes-kit review record|status|gate|mrp` records verdicts bound to a commit range, refuses self-review (an agent-harness ancestor process included), and assembles the merge-ready package. Every deny ends with a `[holmes-refusal]` line carrying a stable code. A project can cap its semantic tier (`semantic.maxTier`) and its automatic approval (`autonomy.ceiling`) in `ax.config.json`, and only an approval can raise either. doctor counts cloud embedding requests. `approve --withdraw` lets a run close its own request. Interactive sessions keep 0.35.25 verdicts, except for the gate holes this release closes: path-less spec staging, computed shell writes, executable files and side paths under a role policy, and Claude Code's PowerShell tool on Windows. Interactive agent launches may carry the autonomy options measured to keep the child's Holmes gate. This is an interim release of the role/phase goal: the acceptance scenario with a reference orchestrator has not been run yet.
26
27
 
27
28
  - **Agents clean up their own temporary work** *(new in 0.35.25)*: `holmes-kit scratch --new <label>` makes a directory under a per-user Holmes scratch root (`os.tmpdir()/holmes-scratch-<uid>`, mode 0700), and on macOS and Linux the gate lets an agent in Claude Code, Codex or Antigravity remove it with one plain `rm -rf <absolute path>` without an operator act; the root itself, tracked source, every other path and any compound command keep their verdict. Where another holmes-kit install sits in an ancestor `node_modules` of the workspace or the home directory (npm, Windows shims and pnpm alike), approval hints name the running install's own path so that copy cannot answer them (a PowerShell form on Windows), and doctor's `npx resolution` row names it.
@@ -42,7 +43,7 @@ Measured at `8b45cd0dcb78` (specs `sha256:0b3ecc947d6c`) — reproduce with `hol
42
43
  - **`doctor` shows when a checkout's hooks are not the ones its sessions run** *(new in 0.35.5)*: when you develop Holmes-Kit itself with sessions routed to a released install, the `development hooks` row compares the compiled files and has both hook programs judge the same payloads, so a hook change that is not live yet is visible instead of assumed. In the same release, `runtime-binding setup` refuses a plan that would write the Codex gate where Codex has it switched off *(security fix — if you ran setup with 0.35.2–0.35.4, check `doctor` for `FAIL codex user hooks`)*.
43
44
  - **No in-session shortcut around a person while autonomy is on** *(new in 0.35.4 — security fix, upgrade recommended)*: on a client without the MCP form dialog, the `approval_commit` continuation is no longer offered or accepted while autonomous approval is on — the request goes to the approval queue. Its only human check is the host's own tool confirmation, which an allow rule or auto mode removes. With autonomy off it works as before; seals made through it are recorded as `host-gated:<harness>`.
44
45
  - **An unanswered approval is held, never approved** *(new in 0.35.3 — security fix, upgrade recommended)*: with autonomous approval on, an in-session approval dialog that ran out of time used to be recorded as an approval (actor `autonomous-timeout:<harness>`) — for exactly the seals and critical-finding resolutions autonomy reserves for a person. An unanswered dialog now returns the request to the approval queue in every mode. To audit earlier sessions, search the provenance ledger for `autonomous-timeout`.
45
- - **Approvals that fit how people work** *(new in 0.35.2)*: an approval for a request that carries the approved content's digest (a spec seal) no longer expires after 30 minutes — it stays valid until used, revoked, or the content changes (`--ttl` still bounds it; requests without a digest keep the default). With autonomous approval on, a gate change declared `gate-behavior: tightens — …` or `gate-behavior: wording — …` is sealed without the operator; any other gate change still asks, and a seal handed to the operator says which rule handed it over. On a machine with a runtime registry the in-session approval dialog is reachable again, and `init`/`upgrade` no longer replace wiring the registry owns. Not yet changed: the in-session dialog's own time limit.
46
+ - **Approvals that fit how people work** *(new in 0.35.2)*: an approval for a request that carries the approved content's digest (a spec seal) no longer expires after 30 minutes — it stays valid until used, revoked, or the content changes (`--ttl` still bounds it; requests without a digest keep the default). With autonomous approval on, a gate change declared `gate-behavior: tightens — …` or `gate-behavior: wording — …` is sealed without the operator; any other gate change still asks, and a seal handed to the operator says which rule handed it over. On a machine with a runtime registry the in-session approval dialog is reachable again, and `init`/`upgrade` no longer replace wiring the registry owns.
46
47
  - **Separate development and consumer runtimes** *(new in 0.35.0)*: `runtime-binding setup` explicitly registers a checkout and its built package in an operator-owned registry. Normal Claude, Codex and Antigravity launches select that development package for the registered workspace; other workspaces select the configured release. Missing or conflicting bindings refuse with diagnosis instead of silently switching builds. Setup previews exact changes and requires authority for a changed installation; a validated unchanged plan needs no new grant. Normal migration preserves disabled hooks and native trust. `--activate-hooks` explicitly restores selected Holmes entries, while native trust and global disable switches still require native review. See [development runtime setup and recovery](docs/install-guide.md#development-and-consumer-runtime-binding) for the workflow and current approval limitation. Configuration readiness does not prove live three-harness enforcement.
47
48
  - **Bounded routed-hook recovery** *(new in 0.35.0)*: routed hooks share an 18-second input/selection/execution budget and allow up to 8 seconds for owned-process cleanup. Failure reports the selected runtime and diagnosis commands, retains unresolved findings, and directs an approved repair followed by retry of the original operation. Cleanup uncertainty is reported; persistent MCP sessions have no hook lifetime deadline. Literal recovery prompts and recognized installer previews are distinguished from actual shell writes without permitting command substitutions or protected output targets.
48
49
  - **Maintenance evidence survives the RED commit, and test evidence records what ran** *(new in 0.35.0)*: persisted `maintenance_analyze` evidence includes the request and explicit `changedFiles`, allowing the pre-edit advisory to cover named new files and analyses up to 20 ancestor commits back when every intervening change is covered. A passing `test_run` records the tree captured before execution, so edits made during a run remain unverified changes. The static test counter handles literals and same-file aliases, and recognizes suite skips only in code. The shared shell gate accepts read-only loops, prose literals, and commit messages mentioning `.ax`, and classifies file redirects using `>&` and `>|` as protected writes where applicable.
package/dist/.build-id CHANGED
@@ -1 +1 @@
1
- 0ddc829e-mvgdgz84
1
+ 829a8208-mvhbw5jo
@@ -13,5 +13,9 @@ export interface AttestIo {
13
13
  export declare const BADGE_REL: string;
14
14
  /** Round 15: the text of the qualifier when the working-tree status did not answer (it claimed a clean commit — measured). */
15
15
  export declare const ATTEST_UNKNOWN = "+unknown";
16
- export declare function buildAttestReport(root: string, exclude: string[]): Promise<AttestReport>;
16
+ /** A-SPEC-702.1 — the tracked listing is injectable so a listing that does not answer can be pinned. */
17
+ export interface AttestDeps {
18
+ trackedFiles?: (root: string) => string | undefined;
19
+ }
20
+ export declare function buildAttestReport(root: string, exclude: string[], deps?: AttestDeps): Promise<AttestReport>;
17
21
  export declare function runAttest(o: AttestOptions, io: AttestIo): Promise<number>;
@@ -36,11 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.ATTEST_UNKNOWN = exports.BADGE_REL = void 0;
37
37
  exports.buildAttestReport = buildAttestReport;
38
38
  exports.runAttest = runAttest;
39
- // @implements A-SPEC-702, A-SPEC-734
39
+ // @implements A-SPEC-702, A-SPEC-734, A-SPEC-702.1
40
40
  /**
41
41
  * `holmes-kit attest` — the surface that calls `rtm/traced-files`.
42
42
  *
43
- * Reads: one scan, the spec store, git (optional — REQ-128). Writes: AT MOST two files, and only
43
+ * Reads: one scan, the spec store, git (optional — REQ-128; with it, only tracked files count — A-SPEC-702.1). Writes: AT MOST two files, and only
44
44
  * when asked: the badge (`--badge`) and the region between the README markers (`--readme`). A README
45
45
  * without markers is never written: placing the markers is the consent. Nothing reaches the network,
46
46
  * and the measured numbers never change the exit code — this is a statement, not a gate.
@@ -108,16 +108,27 @@ function decidingPathsDirty(root, scanned) {
108
108
  }
109
109
  return false;
110
110
  }
111
- async function buildAttestReport(root, exclude) {
111
+ /**
112
+ * A-SPEC-702.1 — the index (`--cached`): a staged new file counts, an unstaged one does not. Run from `root`, git
113
+ * prints paths relative to it and only below it, so a package inside a monorepo lists its own files.
114
+ */
115
+ const gitTrackedFiles = (root) => git(root, ['ls-files', '-z', '--cached']);
116
+ async function buildAttestReport(root, exclude, deps = {}) {
112
117
  (0, cpg_scanner_1.forgetUnverifiedUnder)(root);
113
118
  const scanned = new cpg_scanner_1.CpgScanner().scan(root, root);
114
119
  const specs = await new spec_store_1.LocalMarkdownRepository(path.join(root, SPECS_REL)).list();
115
120
  const approved = specs.filter((s) => s.status === 'approved');
116
121
  const files = scanned.map((f) => ({ path: f.sourcePath.split(path.sep).join('/'), anchors: f.implementsSpecs ?? [] }));
122
+ // A-SPEC-702.1: count what the commit holds. Asked only when HEAD answered — outside git there is no listing and
123
+ // every scanned file counts, as before; a listing that does not answer counts everything and says +unknown below.
124
+ const commit = git(root, ['rev-parse', 'HEAD'])?.trim();
125
+ const listing = commit ? (deps.trackedFiles ?? gitTrackedFiles)(root) : undefined;
126
+ const tracked = listing === undefined ? undefined : new Set(listing.split('\0').filter((p) => p !== '').map((p) => p.normalize('NFC')));
127
+ const isTracked = (p) => tracked === undefined || tracked.has(p.normalize('NFC'));
117
128
  // The spec axis, the way the dashboard computes it (A-SPEC-655). `weakMentions` stays empty: it
118
129
  // only splits the REASON a spec is unlinked, and this command reports the count.
119
130
  const excludes = (0, traced_files_1.normalizeExcludes)(exclude);
120
- const kept = files.filter((f) => !excludes.some((e) => f.path.startsWith(e)));
131
+ const kept = files.filter((f) => !excludes.some((e) => f.path.startsWith(e)) && isTracked(f.path));
121
132
  const census = (0, link_census_1.linkCensus)({
122
133
  approvedIds: approved.filter((s) => s.id.startsWith('A-SPEC')).map((s) => s.id),
123
134
  implemented: new Set(kept.flatMap((f) => f.anchors)),
@@ -125,7 +136,6 @@ async function buildAttestReport(root, exclude) {
125
136
  fileAnchors: (0, file_anchors_1.scanFileAnchors)(root),
126
137
  weakMentions: {},
127
138
  });
128
- const commit = git(root, ['rev-parse', 'HEAD'])?.trim();
129
139
  const dirty = commit ? decidingPathsDirty(root, new Set(files.map((f) => f.path))) : false;
130
140
  const provenance = (0, traced_files_1.attestProvenance)({
131
141
  commit,
@@ -138,12 +148,13 @@ async function buildAttestReport(root, exclude) {
138
148
  if (commit === undefined && git(root, ['rev-parse', '--git-dir']) === undefined && (0, bounded_io_1.gitEntryAbove)(root))
139
149
  provenance.at = 'unknown';
140
150
  // Round 17: a directory the scan skipped because git could not answer for it leaves the tree's content unknown.
141
- if (dirty === 'unknown' || (0, cpg_scanner_1.unverifiedUnder)(root).length > 0) {
151
+ // A-SPEC-702.1: so does a tracked listing that did not answer (every scanned file was counted instead).
152
+ if (dirty === 'unknown' || (0, cpg_scanner_1.unverifiedUnder)(root).length > 0 || (commit && listing === undefined)) {
142
153
  if (!provenance.at.endsWith(exports.ATTEST_UNKNOWN) && provenance.at !== 'unknown')
143
154
  provenance.at += exports.ATTEST_UNKNOWN;
144
155
  }
145
156
  return {
146
- files: (0, traced_files_1.tracedFiles)({ files, approvedIds: approved.map((s) => s.id), exclude }),
157
+ files: (0, traced_files_1.tracedFiles)({ files, approvedIds: approved.map((s) => s.id), exclude, ...(tracked !== undefined ? { tracked } : {}) }),
147
158
  specs: { total: census.total, linked: census.codeLinked },
148
159
  provenance,
149
160
  };
@@ -471,10 +471,27 @@ async function main(argv) {
471
471
  const str = (k) => (typeof flags[k] === 'string' ? flags[k] : undefined);
472
472
  const extra = { run: str('run'), allow: str('allow'), limits: str('limit')?.split('\n'), rationale: str('rationale') };
473
473
  return (0, cli_execution_1.runOperatorExecution)(root, () => {
474
- const r = runAutonomy(root, positionals[0], forStr, {
475
- now: new Date().toISOString(),
474
+ const now = new Date().toISOString();
475
+ const approval = readApproval();
476
+ // @implements A-SPEC-779.4 — the terminal path proves a person only when no agent harness started this process;
477
+ // a covering out-of-band approval is its own proof and keeps its path.
478
+ const sub = positionals[0];
479
+ if (sub === 'on' || sub === 'delegate') {
480
+ const { approvalCovers } = require('../guardrail/risk-gate');
481
+ if (!approvalCovers(approval, { kind: 'autonomy-grant', target: root }, now)) {
482
+ const { operatorActGuard } = require('../guardrail/operator-person');
483
+ const why = operatorActGuard(sub === 'on' ? 'enabling session autonomy' : 'issuing a run delegation');
484
+ if (why !== null) {
485
+ const { withRefusalLine } = require('../guardrail/refusal-codes');
486
+ process.stderr.write(`${withRefusalLine(why)}\n`);
487
+ return 2;
488
+ }
489
+ }
490
+ }
491
+ const r = runAutonomy(root, sub, forStr, {
492
+ now,
476
493
  isTTY: !!process.stdin.isTTY && !!process.stdout.isTTY,
477
- approval: readApproval(),
494
+ approval,
478
495
  }, extra);
479
496
  process[r.ok ? 'stdout' : 'stderr'].write(`${r.message}\n`);
480
497
  return r.exitCode;
@@ -1030,6 +1047,17 @@ async function main(argv) {
1030
1047
  catch {
1031
1048
  return 'operator';
1032
1049
  } })();
1050
+ // @implements A-SPEC-779.4 — the granting acts (a grant, the two screens that grant) are a person's, never an
1051
+ // agent's own shell; a denial, a revocation, a question and the read-only views grant nothing and stay open.
1052
+ const operatorRefusal = (act) => require('../guardrail/operator-person').operatorActGuard(act);
1053
+ const refuseOperatorAct = (act) => {
1054
+ const why = operatorRefusal(act);
1055
+ if (why === null)
1056
+ return false;
1057
+ const { withRefusalLine } = require('../guardrail/refusal-codes');
1058
+ process.stdout.write(`${withRefusalLine(`✗ ${why}`)}\n`);
1059
+ return true;
1060
+ };
1033
1061
  if (flags.help) {
1034
1062
  process.stdout.write(APPROVE_USAGE);
1035
1063
  return 0;
@@ -1048,7 +1076,9 @@ async function main(argv) {
1048
1076
  }
1049
1077
  // @implements A-SPEC-779 \u2014 never from inside a run; a run's awaited request only from a terminal.
1050
1078
  const { grantGuard } = require('../guardrail/run-refusals');
1051
- const guarded = grantGuard(root, ref.id, { env: process.env, interactive: process.stdin.isTTY === true && process.stdout.isTTY === true });
1079
+ // @implements A-SPEC-779.4 \u2014 and never from a process an agent harness started.
1080
+ const guarded = operatorRefusal(`a grant of ${ref.id}`)
1081
+ ?? grantGuard(root, ref.id, { env: process.env, interactive: process.stdin.isTTY === true && process.stdout.isTTY === true });
1052
1082
  if (guarded !== null) {
1053
1083
  // @implements A-SPEC-779.1 \u2014 the refusal carries its envelope, so an orchestrator reads its class.
1054
1084
  const { withRefusalLine } = require('../guardrail/refusal-codes');
@@ -1173,6 +1203,8 @@ async function main(argv) {
1173
1203
  process.stderr.write('✗ interactive resident mode (--watch) requires a TTY — use --list in scripts\n');
1174
1204
  return 1;
1175
1205
  }
1206
+ if (refuseOperatorAct('the approval screen (--watch)'))
1207
+ return 1; // @implements A-SPEC-779.4
1176
1208
  // @implements A-SPEC-497.2 — the resident surface decides on ONE raw keypress (a/d/q/s, no
1177
1209
  // Enter, no deadline) and pings the OS on each new arrival. Raw mode is restored on the way
1178
1210
  // out whatever happens; Ctrl-C arrives as \x03 through decideByKey and ends the loop.
@@ -1216,6 +1248,8 @@ async function main(argv) {
1216
1248
  process.stdout.write(renderPending(state, listView) + (hint ? '\n\n' + hint : '') + '\n');
1217
1249
  return 0;
1218
1250
  }
1251
+ if (refuseOperatorAct('the approval screen'))
1252
+ return 1; // @implements A-SPEC-779.4
1219
1253
  // @implements A-SPEC-262.1
1220
1254
  // AWAITED, not fire-and-forget. Measured 2026-08-25 against the shipped bin with a real pty: the
1221
1255
  // prompt printed and the session ended with zero grants, because `void runInteractive(...)`
@@ -201,7 +201,7 @@ function createImportResolver(scanned, opts) {
201
201
  return relative;
202
202
  return known.has(spec) ? spec : null; // repo-root-relative include
203
203
  }
204
- // A-SPEC-406
204
+ // @implements A-SPEC-406 (moved here from rtm/addImportEdges by REQ-674; anchor restored by A-SPEC-702.1)
205
205
  // A specifier without a leading dot used to be refused outright, on the ground that it names an
206
206
  // external package. That holds for `node:fs` and `js-yaml`; it does NOT hold for Python, which
207
207
  // writes intra-repository modules absolutely — `from src.core.memory_audit import X`. Measured
@@ -30,6 +30,11 @@ export declare const DECISION_KINDS: ReadonlySet<string>;
30
30
  */
31
31
  export declare function requestLabel(kind: string | undefined, target: string | undefined, title: string | undefined): string;
32
32
  export declare function pendingRequestLine(id: string, kind?: string, root?: string, title?: string, target?: string): string;
33
+ /**
34
+ * @implements A-SPEC-718.5 — the in-session route, addressed to the agent: since A-SPEC-779.4 neither the agent's shell
35
+ * nor the session's `!` can type the operator line above, so without this line an agent has no way to ask.
36
+ */
37
+ export declare function approvalAskLine(id: string): string;
33
38
  export interface RefusalRecord {
34
39
  event: 'requested';
35
40
  id: string;
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DECISION_KINDS = exports.QUEUE_RELPATH = void 0;
37
37
  exports.requestLabel = requestLabel;
38
38
  exports.pendingRequestLine = pendingRequestLine;
39
+ exports.approvalAskLine = approvalAskLine;
39
40
  exports.refusalsFilename = refusalsFilename;
40
41
  exports.isRefusalsFilename = isRefusalsFilename;
41
42
  exports.readRefusals = readRefusals;
@@ -126,9 +127,17 @@ function pendingRequestLine(id, kind, root, title, target) {
126
127
  // @implements A-SPEC-770.1 — the id rides the `--grant` flag: the CLI refuses a positional id (`unexpected
127
128
  // argument: req-…`, measured by the operator on 0.35.17 with the command this line used to name).
128
129
  if (kind !== undefined && !exports.DECISION_KINDS.has(kind)) {
129
- return `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${id}${targetFlag} — 인박스 화면에는 뜨지 않는 거부입니다(${command} --refusals${targetFlag} 로 조회)`;
130
+ return `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${id}${targetFlag} — 인박스 화면에는 뜨지 않는 거부입니다(${command} --refusals${targetFlag} 로 조회)${approvalAskLine(id)}`;
130
131
  }
131
- return root === undefined ? `\n[승인 대기 ${id}${label}] 운영자: ${command}` : `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${id}${targetFlag}`;
132
+ return root === undefined ? `\n[승인 대기 ${id}${label}] 운영자: ${command}${approvalAskLine(id)}` : `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${id}${targetFlag}${approvalAskLine(id)}`;
133
+ }
134
+ /**
135
+ * @implements A-SPEC-718.5 — the in-session route, addressed to the agent: since A-SPEC-779.4 neither the agent's shell
136
+ * nor the session's `!` can type the operator line above, so without this line an agent has no way to ask.
137
+ */
138
+ function approvalAskLine(id) {
139
+ // Two rows, each inside the 80-column screen rule the approval screens hold (approve-corpus).
140
+ return `\nAgent: call approval_ask with id "${id}" — the person decides\nin this session's approval form; after granted, retry once.`;
132
141
  }
133
142
  const REFUSALS_FILE_RE = /^refusals\.([^.]+)\.jsonl$/;
134
143
  function refusalsFilename(replica) {
@@ -98,7 +98,9 @@ function runPushReviewRefusal(cwd, env, sha) {
98
98
  if (g.ok)
99
99
  return null;
100
100
  return `[Holmes-Kit push gate] the run's commits ${rec.base}..${sha} are not reviewed (${g.reasons.join('; ')}) — an independent reviewer records a verdict with `
101
- + `holmes-kit review record --base ${rec.base} --head ${sha} --verdict pass`;
101
+ + `holmes-kit review record --base ${rec.base} --head ${sha} --verdict pass`
102
+ // @implements A-SPEC-102.9 — a person in the session answers the same verdict in the form.
103
+ + ` (a person in the session: review_verdict with base ${rec.base}, head ${sha})`;
102
104
  }
103
105
  catch (e) {
104
106
  return cannot(e instanceof Error ? e.message : String(e));
@@ -40,6 +40,10 @@ exports.TOOL_ACTIONS = {
40
40
  issue_localize: NONE, maintenance_calibration: NONE, impact_gate_check: NONE, rtm_impact: NONE, rtm_reindex: NONE,
41
41
  context_bundle: NONE, review_scope: NONE, review_prepare: NONE, review_status: NONE, reverse_scan: NONE,
42
42
  approval_status: NONE, rtm_dashboard: NONE,
43
+ // @implements A-SPEC-718.4 — the person decides in the form; the agent only asks, so no role act is the agent's.
44
+ approval_ask: NONE,
45
+ // @implements A-SPEC-102.9 — it writes a review verdict, the act a role policy names RECORD_REVIEW.
46
+ review_verdict: always('RECORD_REVIEW'),
43
47
  // approval_commit changes only the server's in-memory continuation; the act it completes is spec_approve's
44
48
  approval_commit: always('APPROVE_SPEC'),
45
49
  // evidence
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Who may grant. The refusal text prints the very command that approves it, so a model following that text from its
3
+ * own shell approved itself (measured on 0.36.1). A granting act here refuses a process that an agent harness started:
4
+ * its environment marker (A-SPEC-102.7), a harness among its parents (A-SPEC-102.8), or parents that cannot be read.
5
+ * A person's terminal and a CI operator without a TTY are unchanged. Named residual: a script that loads these modules
6
+ * and calls `grantRequest` itself, or a process reparented away with its markers removed, is the same user.
7
+ */
8
+ import { HarnessAncestry } from '../review/verdicts';
9
+ /** Null for a person's process, else why it is not one. */
10
+ export type OperatorProbe = () => string | null;
11
+ export declare function agentProcessReason(env: NodeJS.ProcessEnv, ancestry: () => HarnessAncestry): string | null;
12
+ /** Test seam only: code that can call this can call grantRequest itself, so it adds no authority. */
13
+ export declare function setOperatorProbeForTests(next: OperatorProbe | null): void;
14
+ export declare function operatorActGuard(act: string): string | null;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.agentProcessReason = agentProcessReason;
4
+ exports.setOperatorProbeForTests = setOperatorProbeForTests;
5
+ exports.operatorActGuard = operatorActGuard;
6
+ // @implements A-SPEC-779.4, A-SPEC-779.6
7
+ /**
8
+ * Who may grant. The refusal text prints the very command that approves it, so a model following that text from its
9
+ * own shell approved itself (measured on 0.36.1). A granting act here refuses a process that an agent harness started:
10
+ * its environment marker (A-SPEC-102.7), a harness among its parents (A-SPEC-102.8), or parents that cannot be read.
11
+ * A person's terminal and a CI operator without a TTY are unchanged. Named residual: a script that loads these modules
12
+ * and calls `grantRequest` itself, or a process reparented away with its markers removed, is the same user.
13
+ */
14
+ const verdicts_1 = require("../review/verdicts");
15
+ const harness_attestation_1 = require("../mcp/harness-attestation");
16
+ /** A-SPEC-779.6 — the reason prefix of an unreadable ancestry; the guard's remediation keys on it. */
17
+ const UNREADABLE = 'the parent processes cannot be read';
18
+ function agentProcessReason(env, ancestry) {
19
+ const marker = (0, verdicts_1.agentHarnessMarker)(env);
20
+ if (marker !== null)
21
+ return marker;
22
+ const walk = ancestry();
23
+ if (walk.kind === 'harness')
24
+ return `process:${walk.harness}`;
25
+ if (walk.kind === 'unreadable')
26
+ return `${UNREADABLE} (${walk.reason})`;
27
+ return null;
28
+ }
29
+ const liveProbe = () => agentProcessReason(process.env, () => (0, verdicts_1.harnessAncestor)(process.ppid, (0, harness_attestation_1.systemProcLookup)()));
30
+ let probe = liveProbe;
31
+ /** Test seam only: code that can call this can call grantRequest itself, so it adds no authority. */
32
+ function setOperatorProbeForTests(next) { probe = next ?? liveProbe; }
33
+ function operatorActGuard(act) {
34
+ const why = probe();
35
+ if (why === null)
36
+ return null;
37
+ // A-SPEC-779.6: on Windows the refused terminal was the person's own (measured) — do not send them back to it.
38
+ const remedy = why.startsWith(UNREADABLE)
39
+ ? 'The operator decides in the session\'s approval dialog (approval_ask) — this process\'s parents could not be read, '
40
+ + 'so it cannot be told apart from an agent\'s.'
41
+ : 'The operator decides in the session\'s approval dialog, or from their own terminal.';
42
+ return `${act} is the operator's — this process runs under an agent harness (${why}). ${remedy}`;
43
+ }
@@ -57,7 +57,8 @@ exports.REFUSAL_CODES = [
57
57
  // @implements A-SPEC-779.1 — a grant refused because it is not the operator's, or a run may await it.
58
58
  code: 'grant.operator-only', class: 'needs_hitl',
59
59
  remediation: ['the operator grants the request from their own terminal'],
60
- test: /a grant is the operator's|is awaited by run|cannot tell whether a run awaits/i,
60
+ // @implements A-SPEC-779.4 — and a granting act from a process an agent harness started.
61
+ test: /a grant is the operator's|is awaited by run|cannot tell whether a run awaits|runs under an agent harness/i,
61
62
  },
62
63
  {
63
64
  // @implements A-SPEC-476.4 — a run cannot change an owner cap in ax.config.json (A-SPEC-476.3).
@@ -67,7 +68,8 @@ exports.REFUSAL_CODES = [
67
68
  },
68
69
  {
69
70
  code: 'approval.required', class: 'needs_hitl',
70
- remediation: ['the act needs an operator approval', 'run the approve command the refusal names, or ask the operator'],
71
+ // @implements A-SPEC-718.5 — the in-session route first; the terminal command is the operator's alternative.
72
+ remediation: ['call approval_ask with the request id — the person decides in the session form', 'or the operator runs the approve command the refusal names'],
71
73
  // @implements A-SPEC-476.4 — and raising an owner cap, or a shell write over one (A-SPEC-476.3).
72
74
  test: /hard-hitl|Integrity\]|Governance Path Destruction|requires operator|raises or removes a project cap|sets a project cap/i,
73
75
  },
@@ -936,7 +936,9 @@ function evaluateStop(specs, evidence) {
936
936
  if (evidence?.reviewGate) {
937
937
  const g = evidence.reviewGate;
938
938
  const detail = `the run's commits ${g.base}..${g.head} are not reviewed (${g.reasons.join('; ')}) — an independent reviewer records a verdict with `
939
- + `holmes-kit review record --base ${g.base} --head ${g.head} --verdict pass`;
939
+ + `holmes-kit review record --base ${g.base} --head ${g.head} --verdict pass`
940
+ // @implements A-SPEC-102.9 — a person in the session answers the same verdict in the form.
941
+ + ` (a person in the session: review_verdict with base ${g.base}, head ${g.head})`;
940
942
  problems.push(`[ART-7] ${detail}`);
941
943
  structured.push({ article: 'ART-7', detail });
942
944
  }
@@ -62,6 +62,8 @@ export type Elicitor = (req: ElicitApprovalRequest) => Promise<ElicitOutcome>;
62
62
  * the findings-ledger lock while the dialog waits, so its ceiling never grows (REQ-497 기아 방지).
63
63
  */
64
64
  export declare const ELICIT_TIMEOUT_MS = 120000;
65
+ /** @implements A-SPEC-718.6 — a form that holds no lock waits for the person (owner, 2026-10-04: "wait until I decide"). */
66
+ export declare const WAIT_FOR_PERSON_MS: number;
65
67
  /**
66
68
  * Per-path dialog deadline — the ONE number the ⏱ forewarning, the SDK timeout option and the
67
69
  * summed `waitedMs` all derive from. Lock-free kinds (spec-approve) get 240s: nothing starves
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_PRESENTATIONS = exports.ELICIT_TIMEOUT_MS = exports.ELICITABLE_KINDS = void 0;
3
+ exports.MAX_PRESENTATIONS = exports.WAIT_FOR_PERSON_MS = exports.ELICIT_TIMEOUT_MS = exports.ELICITABLE_KINDS = void 0;
4
4
  exports.elicitationDisabled = elicitationDisabled;
5
5
  exports.elicitTimeoutMsFor = elicitTimeoutMsFor;
6
6
  exports.classifyElicitError = classifyElicitError;
@@ -53,6 +53,8 @@ function elicitationDisabled(env) {
53
53
  * the findings-ledger lock while the dialog waits, so its ceiling never grows (REQ-497 기아 방지).
54
54
  */
55
55
  exports.ELICIT_TIMEOUT_MS = 120_000;
56
+ /** @implements A-SPEC-718.6 — a form that holds no lock waits for the person (owner, 2026-10-04: "wait until I decide"). */
57
+ exports.WAIT_FOR_PERSON_MS = 24 * 60 * 60 * 1000;
56
58
  // @implements A-SPEC-497.3
57
59
  /**
58
60
  * Per-path dialog deadline — the ONE number the ⏱ forewarning, the SDK timeout option and the
@@ -61,7 +63,8 @@ exports.ELICIT_TIMEOUT_MS = 120_000;
61
63
  * lock-holding kind keeps 120s (see ELICIT_TIMEOUT_MS above).
62
64
  */
63
65
  function elicitTimeoutMsFor(kind) {
64
- return kind === 'review-resolve' ? exports.ELICIT_TIMEOUT_MS : 240_000;
66
+ // @implements A-SPEC-718.6 — the 240 s the owner rejected is gone: a lock-free form waits for the person.
67
+ return kind === 'review-resolve' ? exports.ELICIT_TIMEOUT_MS : exports.WAIT_FOR_PERSON_MS;
65
68
  }
66
69
  // @implements A-SPEC-497.3
67
70
  /**
@@ -110,7 +113,10 @@ const flat = (s, max) => s.replace(/[\u0000-\u001f\u007f\u0085\u2028\u2029\u200b
110
113
  function buildDecisionForm(req, attempt, timeoutMs) {
111
114
  const redisplay = attempt > 1 ? `⚠ 재표시 ${attempt}/${exports.MAX_PRESENTATIONS} — 이전 다이얼로그는 만료되어 무효입니다\n` : '';
112
115
  // @implements A-SPEC-718.2 — one outcome for silence, in every mode: the request returns to the queue.
113
- const timeoutNotice = `⏱ ${timeoutMs / 1000}초 내 미결정 시 승인 큐로 회송됩니다(운영자: ${(0, npx_bin_1.holmesKitCommand)()} approve).`;
116
+ // @implements A-SPEC-718.6 — a form that waits for the person says so instead of counting seconds.
117
+ const timeoutNotice = timeoutMs >= exports.WAIT_FOR_PERSON_MS
118
+ ? `⏱ 결정할 때까지 기다립니다 — 결정 없이 세션이 끝나면 요청은 승인 큐에 남습니다(운영자: ${(0, npx_bin_1.holmesKitCommand)()} approve).`
119
+ : `⏱ ${timeoutMs / 1000}초 내 미결정 시 승인 큐로 회송됩니다(운영자: ${(0, npx_bin_1.holmesKitCommand)()} approve).`;
114
120
  return {
115
121
  // @implements A-SPEC-497.1 — the forewarning is the LAST line and template-owned: it survives a
116
122
  // cap-filling summary (appended after the caps) and tells the human, before the clock runs out,
@@ -0,0 +1,19 @@
1
+ import type { Elicitor } from '../elicit-approval';
2
+ export interface ApprovalAskContext {
3
+ rootOf: (root: string | undefined) => string;
4
+ elicit?: Elicitor;
5
+ clientName: () => string;
6
+ attestation: () => {
7
+ attested: boolean;
8
+ reason?: string;
9
+ };
10
+ env: () => NodeJS.ProcessEnv;
11
+ }
12
+ /** Clients whose form waits for the person in every mode measured (claude-code: forms expired unanswered, 2026-10-19). */
13
+ export declare const FORM_WAITS_FOR_PERSON: ReadonlySet<string>;
14
+ export declare function createApprovalAskHandlers(context: ApprovalAskContext): {
15
+ approval_ask(a: {
16
+ root?: string;
17
+ id: string;
18
+ }): Promise<Record<string, unknown>>;
19
+ };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORM_WAITS_FOR_PERSON = void 0;
4
+ exports.createApprovalAskHandlers = createApprovalAskHandlers;
5
+ // @implements A-SPEC-718.4
6
+ /**
7
+ * approval_ask — the person decides a pending request in the session's approval form, so no approval needs a typed
8
+ * command (owner audit 2026-10-20). Since A-SPEC-779.4 neither the agent's shell nor the session's `!` can run
9
+ * `approve --grant`; this tool is the in-session route. The agent only asks: what is recorded is the person's answer,
10
+ * through the same grant, denial and hold functions the CLI calls, so a refused act's retry finds an ordinary grant.
11
+ *
12
+ * A hard-HITL kind (outside ELICITABLE_KINDS) is asked only on a client measured to wait for a person: a client that
13
+ * answers forms by itself would turn this tool into self-approval (the A-SPEC-551.1 side door).
14
+ */
15
+ const elicit_approval_1 = require("../elicit-approval");
16
+ const approval_queue_1 = require("../../governance/approval-queue");
17
+ const approve_1 = require("../../cli/approve");
18
+ const npx_bin_1 = require("../../project/npx-bin");
19
+ const screen_safe_1 = require("../../cli/screen-safe");
20
+ /** Clients whose form waits for the person in every mode measured (claude-code: forms expired unanswered, 2026-10-19). */
21
+ exports.FORM_WAITS_FOR_PERSON = new Set(['claude-code']);
22
+ /** The one line the form shows for a request's field: the screen-safe flattening the approval screens use. */
23
+ const oneLine = (s, max) => (0, screen_safe_1.flattenField)(s, max);
24
+ /** interpretElicitResult's reasons: a client's automatic decline is not a person's denial, and a question holds. */
25
+ const AUTOMATIC_DECLINE = 'the session client declined the approval form';
26
+ const QUESTION = '질문: ';
27
+ const RUN = ['HOLMES', 'RUN', 'ID'].join('_');
28
+ function createApprovalAskHandlers(context) {
29
+ return {
30
+ async approval_ask(a) {
31
+ const root = context.rootOf(a.root);
32
+ const id = typeof a.id === 'string' ? a.id.trim() : '';
33
+ const fallback = `The operator can decide it from their own terminal: ${(0, npx_bin_1.holmesKitCommand)()} approve --grant ${id} --target ${root}`;
34
+ const refuse = (why) => ({ ok: false, id, reason: `${why}. ${fallback}` });
35
+ // @implements A-SPEC-779.5 — a run's own server never asks; a request a run awaits is the person's to decide in the
36
+ // interactive session's form (owner, 2026-10-20). The CLI keeps A-SPEC-779's terminal-only rule (grantGuard).
37
+ const runMarker = context.env()[RUN];
38
+ if (typeof runMarker === 'string' && runMarker.trim() !== '') {
39
+ return refuse('a run\'s own server does not ask; the session that started the run asks the person');
40
+ }
41
+ const request = (0, approval_queue_1.grantableRequests)(root).find((p) => p.id === id);
42
+ if (!request)
43
+ return { ok: false, id, reason: `no pending request ${oneLine(id, 40)} in the approval inbox or this machine's refusal log` };
44
+ const client = context.clientName();
45
+ const attestation = context.attestation();
46
+ if ((0, elicit_approval_1.elicitationDisabled)(context.env()))
47
+ return refuse('this session cannot show an approval form (HOLMES_ELICIT is off)');
48
+ if (!attestation.attested)
49
+ return refuse(`this session cannot show an approval form (${attestation.reason ?? 'not launched by a harness'})`);
50
+ if (!context.elicit)
51
+ return refuse('this session cannot show an approval form (the client did not advertise forms)');
52
+ if (!elicit_approval_1.ELICITABLE_KINDS.has(request.kind) && !exports.FORM_WAITS_FOR_PERSON.has(client)) {
53
+ return refuse(`a ${request.kind} approval in the form is not yet measured for ${client} (it might answer forms by itself)`);
54
+ }
55
+ const title = typeof request.title === 'string' && request.title.trim() !== '' ? ` 「${oneLine(request.title, 80)}」` : '';
56
+ const outcome = await context.elicit({
57
+ kind: request.kind,
58
+ target: oneLine(request.target, 400),
59
+ summary: `${id}${title} — ${oneLine(request.why, 120)}`,
60
+ });
61
+ const actor = `elicitation:${client}`;
62
+ const base = { ok: true, id, kind: request.kind };
63
+ if (outcome.kind !== 'answered') {
64
+ return { ...base, decision: 'undecided', nextAction: 'Nobody answered the form; the request is still pending. Ask again when the person is there.' };
65
+ }
66
+ const { granted, reason } = outcome.decision;
67
+ if (granted) {
68
+ const r = (0, approve_1.grantRequest)(root, id, { actor, rationale: reason ?? `approved in the session form (${client})` });
69
+ if (!r.ok)
70
+ return { ok: false, id, reason: r.reason };
71
+ return { ...base, decision: 'granted', nextAction: 'Retry the refused act once; the grant covers it.' };
72
+ }
73
+ if (typeof reason === 'string' && reason.startsWith(AUTOMATIC_DECLINE)) {
74
+ return { ...base, decision: 'undecided', nextAction: `The client declined the form without a person. ${fallback}` };
75
+ }
76
+ if (typeof reason === 'string' && reason.startsWith(QUESTION)) {
77
+ const r = (0, approve_1.holdRequest)(root, id, reason.slice(QUESTION.length), actor);
78
+ if (!r.ok)
79
+ return { ok: false, id, reason: r.reason };
80
+ return { ...base, decision: 'held', question: reason.slice(QUESTION.length), nextAction: 'Answer the person\'s question, then ask again.' };
81
+ }
82
+ const why = reason ?? 'denied in the session form';
83
+ const r = (0, approve_1.denyRequest)(root, id, why, actor);
84
+ if (!r.ok)
85
+ return { ok: false, id, reason: r.reason };
86
+ return { ...base, decision: 'denied', reason: why, nextAction: 'Do not retry the act; the person denied it.' };
87
+ },
88
+ };
89
+ }
@@ -0,0 +1,18 @@
1
+ import type { Elicitor } from '../elicit-approval';
2
+ export interface ReviewVerdictContext {
3
+ rootOf: (root: string | undefined) => string;
4
+ elicit?: Elicitor;
5
+ clientName: () => string;
6
+ attestation: () => {
7
+ attested: boolean;
8
+ reason?: string;
9
+ };
10
+ env: () => NodeJS.ProcessEnv;
11
+ }
12
+ export declare function createReviewVerdictHandlers(context: ReviewVerdictContext): {
13
+ review_verdict(a: {
14
+ root?: string;
15
+ base: string;
16
+ head: string;
17
+ }): Promise<Record<string, unknown>>;
18
+ };
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReviewVerdictHandlers = createReviewVerdictHandlers;
4
+ // @implements A-SPEC-102.9
5
+ /**
6
+ * review_verdict — the person records an independent review verdict in the session's approval form. A-SPEC-102.7/102.8
7
+ * make a CLI verdict independent only from a person's own terminal, so a review meant leaving the session (the owner's
8
+ * `!` record during the 0.36.1 release came out independent:false). The form is answered by the person, not the model,
9
+ * so the answer is recorded as the person's — on a client measured to wait for a person (A-SPEC-718.4).
10
+ */
11
+ const elicit_approval_1 = require("../elicit-approval");
12
+ const verdicts_1 = require("../../review/verdicts");
13
+ const approval_ask_1 = require("./approval-ask");
14
+ /** interpretElicitResult's reasons: a client's automatic decline and a question are not a verdict. */
15
+ const AUTOMATIC_DECLINE = 'the session client declined the approval form';
16
+ const QUESTION = '질문: ';
17
+ const RUN = ['HOLMES', 'RUN', 'ID'].join('_');
18
+ function createReviewVerdictHandlers(context) {
19
+ return {
20
+ async review_verdict(a) {
21
+ const root = context.rootOf(a.root);
22
+ const env = context.env();
23
+ const fallback = `The person can record it from their own terminal: holmes-kit review record --base ${a.base} --head ${a.head} --verdict pass`;
24
+ const refuse = (why) => ({ ok: false, reason: `${why}. ${fallback}` });
25
+ const marker = env[RUN];
26
+ if (typeof marker === 'string' && marker.trim() !== '')
27
+ return refuse('a run\'s own server does not ask for a person\'s verdict');
28
+ const client = context.clientName();
29
+ const attestation = context.attestation();
30
+ if ((0, elicit_approval_1.elicitationDisabled)(env))
31
+ return refuse('this session cannot show an approval form (HOLMES_ELICIT is off)');
32
+ if (!attestation.attested)
33
+ return refuse(`this session cannot show an approval form (${attestation.reason ?? 'not launched by a harness'})`);
34
+ if (!context.elicit)
35
+ return refuse('this session cannot show an approval form (the client did not advertise forms)');
36
+ if (!approval_ask_1.FORM_WAITS_FOR_PERSON.has(client))
37
+ return refuse(`a review verdict in the form is not yet measured for ${client} (it might answer forms by itself)`);
38
+ const range = (0, verdicts_1.resolveRange)(root, a.base, a.head);
39
+ if ('error' in range)
40
+ return { ok: false, reason: range.error };
41
+ const touched = (0, verdicts_1.rangeAnchors)(root, range.base, range.head);
42
+ const files = 'error' in touched ? '?' : String(touched.files.length);
43
+ const specs = 'error' in touched || touched.aspecs.length === 0 ? 'no A-SPEC anchors'
44
+ : `${touched.aspecs.slice(0, 6).join(', ')}${touched.aspecs.length > 6 ? ` +${touched.aspecs.length - 6}` : ''}`;
45
+ const target = `${range.base.slice(0, 8)}..${range.head.slice(0, 8)}`;
46
+ const outcome = await context.elicit({
47
+ kind: 'review-verdict',
48
+ target,
49
+ summary: `review verdict — approve records pass, deny records fail with your reason · ${files} files · ${specs}`,
50
+ });
51
+ if (outcome.kind !== 'answered')
52
+ return { ok: true, decision: 'undecided', nextAction: 'Nobody answered the form; no verdict was recorded.' };
53
+ const { granted, reason } = outcome.decision;
54
+ if (!granted && typeof reason === 'string' && (reason.startsWith(AUTOMATIC_DECLINE) || reason.startsWith(QUESTION))) {
55
+ return { ok: true, decision: 'undecided', ...(reason.startsWith(QUESTION) ? { question: reason.slice(QUESTION.length) } : {}),
56
+ nextAction: reason.startsWith(QUESTION) ? 'Answer the person\'s question, then ask again.' : `The client declined the form without a person. ${fallback}` };
57
+ }
58
+ const r = (0, verdicts_1.recordVerdict)(root, {
59
+ base: range.base, head: range.head, verdict: granted ? 'pass' : 'fail',
60
+ findings: granted ? [] : [reason ?? 'failed in the session form'],
61
+ }, { env, cwd: root, interactive: false, answeredBy: `elicitation:${client}` });
62
+ if (!r.ok)
63
+ return { ok: false, reason: r.reason };
64
+ return { ok: true, decision: r.record.verdict, independent: r.record.independent, base: range.base, head: range.head };
65
+ },
66
+ };
67
+ }
@@ -387,6 +387,15 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
387
387
  operation?: string;
388
388
  plan?: unknown;
389
389
  }) => Promise<Record<string, unknown>>;
390
+ approval_ask: (a: {
391
+ root?: string;
392
+ id: string;
393
+ }) => Promise<Record<string, unknown>>;
394
+ review_verdict: (a: {
395
+ root?: string;
396
+ base: string;
397
+ head: string;
398
+ }) => Promise<Record<string, unknown>>;
390
399
  rtm_impact: (a: {
391
400
  root: string;
392
401
  changed: string[];
@@ -74,6 +74,8 @@ const runtime_binding_tool_1 = require("./handlers/runtime-binding-tool");
74
74
  const runtime_binding_1 = require("../cli/runtime-binding");
75
75
  const workspace_preflight_1 = require("./handlers/workspace-preflight");
76
76
  const operator_inspection_1 = require("./handlers/operator-inspection");
77
+ const approval_ask_1 = require("./handlers/approval-ask");
78
+ const review_verdict_1 = require("./handlers/review-verdict");
77
79
  const phase_queries_1 = require("./handlers/phase-queries");
78
80
  const risk_assessment_1 = require("./handlers/risk-assessment");
79
81
  const adoption_1 = require("./handlers/adoption");
@@ -858,6 +860,27 @@ function makeRawHandlers(store, opts) {
858
860
  return { kind: 'silent' };
859
861
  }
860
862
  };
863
+ // @implements A-SPEC-718.4 — the in-session route for every pending request: the person answers the form, and the
864
+ // answer is recorded through the CLI's own decision functions. The root is the caller's, checked against the store.
865
+ const formContext = {
866
+ rootOf: (root) => {
867
+ const foreign = foreignRootReason(store, root);
868
+ if (foreign)
869
+ throw new HandlerRefusal(foreign);
870
+ if (typeof root === 'string' && root !== '')
871
+ return projectRootOf(root);
872
+ if (store instanceof spec_store_1.LocalMarkdownRepository)
873
+ return projectRootOf(store.specsRoot);
874
+ throw new HandlerRefusal('this tool needs root: this server is not bound to a file store');
875
+ },
876
+ elicit: opts?.elicit,
877
+ clientName: () => opts?.clientName?.() ?? 'unknown',
878
+ attestation,
879
+ env: () => process.env,
880
+ };
881
+ const approvalAsk = (0, approval_ask_1.createApprovalAskHandlers)(formContext);
882
+ // @implements A-SPEC-102.9 — the person's review verdict, answered in the same form.
883
+ const reviewVerdict = (0, review_verdict_1.createReviewVerdictHandlers)(formContext);
861
884
  // A granted answer becomes a synthesized Approval that rides the EXISTING seal path unchanged —
862
885
  // the ledger's authorizationRef then honestly names the channel (`elicitation:<client>`), and
863
886
  // single-use is structural: the object exists only inside this call, persisted nowhere.
@@ -1072,6 +1095,8 @@ function makeRawHandlers(store, opts) {
1072
1095
  }),
1073
1096
  // @implements A-SPEC-700.2 — same unpinned slot: `spec_retire..spec_unseal` is a pinned run.
1074
1097
  spec_reconcile: specLifecycle.spec_reconcile,
1098
+ approval_ask: approvalAsk.approval_ask, // @implements A-SPEC-718.4 — a slot no pinned key order covers
1099
+ review_verdict: reviewVerdict.review_verdict, // @implements A-SPEC-102.9
1075
1100
  rtm_impact: graphOperations.rtm_impact,
1076
1101
  rtm_reindex: graphOperations.rtm_reindex,
1077
1102
  context_bundle: reviewQueries.context_bundle,
@@ -1,3 +1,4 @@
1
+ import { spawnSync } from 'node:child_process';
1
2
  /** `image` is the real executable (symlinks resolved); absent when it could not be read. */
2
3
  export interface ProcRow {
3
4
  pid: number;
@@ -6,8 +7,12 @@ export interface ProcRow {
6
7
  image?: string;
7
8
  /** The executable path on its own (`ps -o comm=`, Windows ExecutablePath) — unambiguous where args are not. */
8
9
  exe?: string;
10
+ /** A-SPEC-779.6 — creation time in ms, where the platform gives it (Windows CreationDate). */
11
+ created?: number;
9
12
  }
10
- export type ProcLookup = (pid: number) => ProcRow | null;
13
+ /** A-SPEC-779.6 — the table answered and holds no such pid (a parent that has exited). Null keeps meaning "unreadable". */
14
+ export declare const PROC_GONE: "gone";
15
+ export type ProcLookup = (pid: number) => ProcRow | typeof PROC_GONE | null;
11
16
  export interface HarnessAttestation {
12
17
  attested: boolean;
13
18
  chain: string[];
@@ -27,5 +32,12 @@ export declare function harnessOf(args: string, exe?: string): string | null;
27
32
  export declare function dispatcherVerifier(registryPath: string): (script: string) => boolean;
28
33
  /** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
29
34
  export declare function attestHarness(pid: number, lookup: ProcLookup, maxDepth?: number, isDispatcher?: (script: string) => boolean): HarnessAttestation;
30
- /** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
31
- export declare function systemProcLookup(platform?: NodeJS.Platform): ProcLookup;
35
+ /**
36
+ * The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable.
37
+ * @implements A-SPEC-779.6 — on Windows, PROC_GONE when the query answered with no row. Windows keeps an exited
38
+ * parent's pid in its children, so every walk ends at one; reading that as "unreadable" refused the person's own
39
+ * terminal (measured on 0.37.0). `-ErrorAction Stop` makes a CIM error a non-zero exit, so a failed query can never
40
+ * print GONE; only status 0 without a spawn error is believed. POSIX reparents an orphan to pid 1 and is unchanged.
41
+ * `spawn` is injectable so the Windows branch is tested on every OS.
42
+ */
43
+ export declare function systemProcLookup(platform?: NodeJS.Platform, spawn?: typeof spawnSync): ProcLookup;
@@ -33,11 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PROC_GONE = void 0;
36
37
  exports.harnessOf = harnessOf;
37
38
  exports.dispatcherVerifier = dispatcherVerifier;
38
39
  exports.attestHarness = attestHarness;
39
40
  exports.systemProcLookup = systemProcLookup;
40
- // @implements A-SPEC-732, A-SPEC-751.3, A-SPEC-102.8
41
+ // @implements A-SPEC-732, A-SPEC-751.3, A-SPEC-102.8, A-SPEC-779.6
41
42
  // In-session approval (a form, or the host-gated continuation) trusts the client that answers it. An
42
43
  // agent can start its own copy of this server, name itself `claude-code` and answer for a person
43
44
  // (measured, H7 round 1). So before offering either route, the server asks who launched it: the
@@ -53,6 +54,8 @@ const fs = __importStar(require("node:fs"));
53
54
  const path = __importStar(require("node:path"));
54
55
  const node_child_process_1 = require("node:child_process");
55
56
  const node_crypto_1 = require("node:crypto");
57
+ /** A-SPEC-779.6 — the table answered and holds no such pid (a parent that has exited). Null keeps meaning "unreadable". */
58
+ exports.PROC_GONE = 'gone';
56
59
  const HARNESS_EXES = new Set(['claude', 'codex', 'agy', 'antigravity']);
57
60
  const imageName = (image) => path.win32.basename(path.posix.basename(image)).toLowerCase().replace(/\.exe$/, '');
58
61
  /** `agy` and `antigravity` name the same harness. */
@@ -175,6 +178,9 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
175
178
  const row = lookup(cur);
176
179
  if (row === null)
177
180
  return { attested: false, chain, reason: 'the process table could not be read' };
181
+ // A-SPEC-779.6: a launcher that has exited attests nothing — fail closed, with the true reason.
182
+ if (row === exports.PROC_GONE)
183
+ return { attested: false, chain, reason: `process ${cur} exited before it could be read` };
178
184
  const harness = harnessOf(row.args, row.exe);
179
185
  // @implements A-SPEC-751.3 — the receipted runtime dispatcher is a launcher; the chain records the hop as such.
180
186
  const viaDispatcher = harness === null && isDispatcher !== undefined && ['node', 'nodejs'].includes(exeName(row.args))
@@ -200,23 +206,44 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
200
206
  }
201
207
  return { attested: false, chain, reason: 'launcher chain too deep' };
202
208
  }
203
- /** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
204
- function systemProcLookup(platform = process.platform) {
209
+ /** FILETIME (100 ns ticks since 1601) to ms since 1970; BigInt because the ticks exceed 2^53. */
210
+ const fileTimeToMs = (ticks) => Number(BigInt(ticks) / BigInt(10000)) - 11644473600000;
211
+ /**
212
+ * The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable.
213
+ * @implements A-SPEC-779.6 — on Windows, PROC_GONE when the query answered with no row. Windows keeps an exited
214
+ * parent's pid in its children, so every walk ends at one; reading that as "unreadable" refused the person's own
215
+ * terminal (measured on 0.37.0). `-ErrorAction Stop` makes a CIM error a non-zero exit, so a failed query can never
216
+ * print GONE; only status 0 without a spawn error is believed. POSIX reparents an orphan to pid 1 and is unchanged.
217
+ * `spawn` is injectable so the Windows branch is tested on every OS.
218
+ */
219
+ function systemProcLookup(platform = process.platform, spawn = node_child_process_1.spawnSync) {
205
220
  return (pid) => {
206
221
  try {
207
222
  if (platform === 'win32') {
208
- const r = (0, node_child_process_1.spawnSync)('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
209
- `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${Math.trunc(pid)}"; if ($p) { "$($p.ParentProcessId)\`t$($p.ExecutablePath)\`t$($p.CommandLine)" }`], { encoding: 'utf8', timeout: 5000, windowsHide: true });
210
- const m = /^(\d+)\t([^\t]*)\t([\s\S]*)$/.exec((r.stdout ?? '').trim());
211
- return m ? { pid, ppid: Number(m[1]), args: m[3].trim(), ...(m[2].trim() ? { image: m[2].trim(), exe: m[2].trim() } : {}) } : null;
223
+ const r = spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
224
+ `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${Math.trunc(pid)}" -ErrorAction Stop; if ($p) { $c = if ($p.CreationDate) { $p.CreationDate.ToFileTimeUtc() } else { '' }; "$($p.ParentProcessId)\`t$c\`t$($p.ExecutablePath)\`t$($p.CommandLine)" } else { 'GONE' }`], { encoding: 'utf8', timeout: 5000, windowsHide: true });
225
+ if (r.error !== undefined || r.status !== 0)
226
+ return null;
227
+ const out = String(r.stdout ?? '').trim();
228
+ if (out === 'GONE')
229
+ return exports.PROC_GONE;
230
+ const m = /^(\d+)\t(\d*)\t([^\t]*)\t([\s\S]*)$/.exec(out);
231
+ if (!m)
232
+ return null;
233
+ const exe = m[3].trim();
234
+ return {
235
+ pid, ppid: Number(m[1]), args: m[4].trim(),
236
+ ...(exe ? { image: exe, exe } : {}),
237
+ ...(m[2] !== '' ? { created: fileTimeToMs(m[2]) } : {}),
238
+ };
212
239
  }
213
- const r = (0, node_child_process_1.spawnSync)('ps', ['-o', 'ppid=,args=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
240
+ const r = spawn('ps', ['-o', 'ppid=,args=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
214
241
  const m = /^\s*(\d+)\s+([\s\S]*)$/.exec((r.stdout ?? '').trim());
215
242
  if (!m)
216
243
  return null;
217
244
  const row = { pid, ppid: Number(m[1]), args: m[2].trim() };
218
245
  // Round 6: the executable path alone (macOS prints it whole; Linux its name) — no args to split.
219
- const comm = (0, node_child_process_1.spawnSync)('ps', ['-o', 'comm=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
246
+ const comm = spawn('ps', ['-o', 'comm=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
220
247
  const exe = (comm.stdout ?? '').trim();
221
248
  if (exe !== '')
222
249
  row.exe = exe;
@@ -64,7 +64,9 @@ function operatorRecovery(root, target, operation, options) {
64
64
  return `\n[승인 대기 ${id}${label}] 운영자: ${command} --grant ${literal(id, platform)}`
65
65
  + `\nOr keep the approval surface open and decide each arriving request with one key: ${command} --watch`
66
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.`
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.';
67
+ // @implements A-SPEC-718.5 — the in-session route first: the person answers the form, nobody types a command.
68
+ + `\nAgent: call approval_ask with id "${id}" — the person decides in this session's approval form; after granted, retry once.`
69
+ + ' Otherwise 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.';
68
70
  },
69
71
  };
70
72
  }
@@ -223,6 +223,31 @@ exports.TOOL_SCHEMAS = {
223
223
  required: ['id'],
224
224
  },
225
225
  },
226
+ // @implements A-SPEC-718.4
227
+ approval_ask: {
228
+ description: "Ask the person to decide ONE pending approval request in this session's approval form — the id a refusal named (`[승인 대기 req-…]`), from the approval inbox or this machine's refusal log. The person chooses approve / deny / question; the answer is recorded exactly as `holmes-kit approve --grant/--deny/--ask` would record it (actor `elicitation:<client>`), so after `granted` retry the refused act once. Returns { ok, id, kind, decision: granted|denied|held|undecided, nextAction }. Nothing is recorded without the person's answer: silence leaves the request pending. A request a run awaits is asked here too, from the interactive session (the run resumes on the grant). Refuses, recording nothing, from a run's own server, when the session cannot show a form (HOLMES_ELICIT=off, a server no harness launched, a client without forms), and for a shell/config/code-write request on a client not yet measured to wait for a person (only claude-code today).",
229
+ inputSchema: {
230
+ type: 'object',
231
+ properties: {
232
+ id: str('The request id the refusal named, e.g. req-0123456789ab.'),
233
+ root: str('Optional when the server is bound to a file store; if supplied it must resolve to the SAME project.'),
234
+ },
235
+ required: ['id'],
236
+ },
237
+ },
238
+ // @implements A-SPEC-102.9
239
+ review_verdict: {
240
+ description: "Ask the person for an independent review verdict on base..head in this session's approval form. approve records pass, deny records fail with the person's reason as the finding; the verdict is recorded as the person's (reviewer.person true, channel elicitation:<client>, independent true), so it satisfies the review gate without a separate terminal. Returns { ok, decision: pass|fail|undecided, independent? }. Silence, a question and an automatic decline record nothing. Refuses, recording nothing, inside a run, when the session cannot show a form, and on a client not yet measured to wait for a person (only claude-code today).",
241
+ inputSchema: {
242
+ type: 'object',
243
+ properties: {
244
+ base: str('Base revision of the reviewed range (a commit id or ref).'),
245
+ head: str('Head revision of the reviewed range.'),
246
+ root: str('Optional when the server is bound to a file store; if supplied it must resolve to the SAME project.'),
247
+ },
248
+ required: ['base', 'head'],
249
+ },
250
+ },
226
251
  ledger_timeline: {
227
252
  description: "Read-only: return the provenance ledger's events in time order — { events: [{ ts, kind, actor, summary, inputs }] } ascending by ts (tiebroken by chain seq). Pass an `id` to narrow to one spec (only events whose `inputs` reference it: spec-approved, spec-unsealed, spec-retired, review-needed …). The chain-integrity fields (hash/prevHash/seq/replicaId) are plumbing and are projected away — this is the governance history, not the tamper-evidence chain. No writes. An absent ledger is an empty history, not an error.",
228
253
  inputSchema: {
@@ -19,12 +19,14 @@ export interface VerdictRecord {
19
19
  verdict: 'pass' | 'fail';
20
20
  findings: string[];
21
21
  /** `harness`: a marker variable, or `process:<name>` for an ancestor (A-SPEC-102.8); `ancestry`: why the process table could not be read. */
22
+ /** `channel`: the session form a person answered through (A-SPEC-102.9). */
22
23
  reviewer: {
23
24
  run?: string;
24
25
  session?: string;
25
26
  engine?: string;
26
27
  model?: string;
27
28
  person: boolean;
29
+ channel?: string;
28
30
  harness?: string;
29
31
  ancestry?: string;
30
32
  };
@@ -79,6 +81,8 @@ export interface VerdictContext {
79
81
  interactive: boolean;
80
82
  now?: () => Date;
81
83
  ancestry?: () => HarnessAncestry;
84
+ /** @implements A-SPEC-102.9 — the form channel a person answered this verdict through; only review_verdict passes it. */
85
+ answeredBy?: string;
82
86
  }
83
87
  export declare const verdictsFile: (main: string) => string;
84
88
  /** Both revisions as full commit ids, or the one that does not resolve. */
@@ -43,7 +43,7 @@ exports.readVerdicts = readVerdicts;
43
43
  exports.recordVerdict = recordVerdict;
44
44
  exports.gateRange = gateRange;
45
45
  exports.rangeStatus = rangeStatus;
46
- // @implements A-SPEC-102.2, A-SPEC-102.7, A-SPEC-102.8
46
+ // @implements A-SPEC-102.2, A-SPEC-102.7, A-SPEC-102.8, A-SPEC-779.6
47
47
  /**
48
48
  * @implements A-SPEC-102.2 — a review is a verdict that names who reviewed which commits. The ledger lives in the main
49
49
  * checkout (`.ax/reviews/verdicts.jsonl`, append-only), so a review recorded in a worktree outlives the worktree. A
@@ -75,13 +75,22 @@ function harnessAncestor(pid, lookup, maxDepth = 64) {
75
75
  const chain = [];
76
76
  const seen = new Set();
77
77
  let cur = pid;
78
+ let childCreated;
78
79
  for (let depth = 0; depth < maxDepth; depth++) {
79
80
  if (cur <= 1 || seen.has(cur))
80
81
  return { kind: 'none' };
81
82
  seen.add(cur);
82
83
  const row = lookup(cur);
84
+ // @implements A-SPEC-779.6 — Windows does not reparent orphans: a parent that has exited is the top of the chain,
85
+ // as pid 1 is on POSIX. So is a parent created after its child (the pid was reused by an unrelated process).
86
+ // Only a query that failed stays unreadable.
87
+ if (row === harness_attestation_1.PROC_GONE)
88
+ return { kind: 'none' };
83
89
  if (row === null)
84
90
  return { kind: 'unreadable', reason: `process ${cur} could not be read` };
91
+ if (childCreated !== undefined && row.created !== undefined && row.created > childCreated)
92
+ return { kind: 'none' };
93
+ childCreated = row.created;
85
94
  const harness = (0, harness_attestation_1.harnessOf)(row.args, row.exe);
86
95
  chain.push(harness ?? row.args.split(/\s+/)[0] ?? '?');
87
96
  if (harness !== null)
@@ -230,14 +239,17 @@ function recordVerdict(root, input, ctx) {
230
239
  if (issue)
231
240
  return { ok: false, reason: issue };
232
241
  }
242
+ // @implements A-SPEC-102.9 — a person answered this verdict in the session's form (review_verdict). The server that
243
+ // asked is under the harness by design, so its markers and parents say nothing about who answered; a run ignores it.
244
+ const answered = !mode.run && typeof ctx.answeredBy === 'string' && ctx.answeredBy !== '';
233
245
  // @implements A-SPEC-102.7 — a person is a terminal outside an agent harness: an agent session's own review is not one.
234
- const marker = agentHarnessMarker(ctx.env);
246
+ const marker = answered ? null : agentHarnessMarker(ctx.env);
235
247
  // @implements A-SPEC-102.8 — the walk runs only when the cheaper conditions already hold.
236
- const ancestry = !mode.run && ctx.interactive && marker === null
248
+ const ancestry = !answered && !mode.run && ctx.interactive && marker === null
237
249
  ? (ctx.ancestry ?? (() => harnessAncestor(process.ppid, (0, harness_attestation_1.systemProcLookup)())))()
238
250
  : { kind: 'none' };
239
251
  const harness = marker ?? (ancestry.kind === 'harness' ? `process:${ancestry.harness}` : null);
240
- const person = !mode.run && ctx.interactive && harness === null && ancestry.kind === 'none';
252
+ const person = answered || (!mode.run && ctx.interactive && harness === null && ancestry.kind === 'none');
241
253
  const touched = rangeAnchors(root, range.base, range.head);
242
254
  const anchored = 'error' in touched ? [] : touched.aspecs;
243
255
  const stated = statedSpecs(root, range.base, range.head);
@@ -253,6 +265,7 @@ function recordVerdict(root, input, ctx) {
253
265
  ...(input.engine ? { engine: input.engine } : {}),
254
266
  ...(input.model ? { model: input.model } : {}),
255
267
  person,
268
+ ...(answered ? { channel: ctx.answeredBy } : {}), // @implements A-SPEC-102.9
256
269
  ...(harness ? { harness } : {}),
257
270
  ...(ancestry.kind === 'unreadable' ? { ancestry: ancestry.reason } : {}),
258
271
  },
@@ -8,11 +8,15 @@ export interface TracedFilesInput {
8
8
  approvedIds: Iterable<string>;
9
9
  /** Path prefixes that are not this project's source (vendored trees). Explicit, and echoed back. */
10
10
  exclude?: readonly string[];
11
+ /** A-SPEC-702.1 — repo-relative paths git tracks. Absent: no listing, every scanned file counts. */
12
+ tracked?: Iterable<string>;
11
13
  }
12
14
  export interface TracedFiles {
13
15
  total: number;
14
16
  traced: number;
15
17
  excluded: number;
18
+ /** A-SPEC-702.1 — scanned files left out because git does not track them (0 without a listing). */
19
+ notTracked: number;
16
20
  /** Sorted. */
17
21
  untraced: string[];
18
22
  measurable: boolean;
@@ -43,7 +43,7 @@ exports.renderAttestJson = renderAttestJson;
43
43
  exports.renderAttestSvg = renderAttestSvg;
44
44
  exports.renderAttestMarker = renderAttestMarker;
45
45
  exports.replaceMarkerRegion = replaceMarkerRegion;
46
- // @implements A-SPEC-702
46
+ // @implements A-SPEC-702, A-SPEC-702.1
47
47
  /**
48
48
  * How many of a repository's source files trace to an APPROVED spec — said as a number anyone can
49
49
  * reproduce, with the commit and spec-store state it was measured at.
@@ -53,8 +53,8 @@ exports.replaceMarkerRegion = replaceMarkerRegion;
53
53
  * carries the `implements` anchor, which a gate verifies. What was missing is a repository-level
54
54
  * statement, and the spec-side half of it (`linkCensus`) lived only inside the dashboard.
55
55
  *
56
- * NO NEW JUDGEMENT. The denominator is whatever the scanner returned, the numerator is anchors ∩
57
- * approved ids. Everything here is pure — no clock, no filesystem, no git — so the same input is the
56
+ * NO NEW JUDGEMENT. The denominator is whatever the scanner returned (less what git does not track,
57
+ * when the caller hands a listing — A-SPEC-702.1), the numerator is anchors ∩ approved ids. Everything here is pure — no clock, no filesystem, no git — so the same input is the
58
58
  * same bytes and a committed badge does not churn. The CLI that feeds it is `cli/attest.ts`.
59
59
  */
60
60
  const crypto = __importStar(require("node:crypto"));
@@ -85,10 +85,15 @@ function flooredPct(num, den) {
85
85
  return null;
86
86
  return Math.floor((num / den) * 1000) / 10;
87
87
  }
88
+ /** A-SPEC-702.1 — one spelling for both sides of the tracked comparison: forward slashes, NFC. */
89
+ const trackedKey = (p) => posix(p).normalize('NFC');
88
90
  function tracedFiles(input) {
89
91
  const approved = new Set(input.approvedIds);
90
92
  const excludes = normalizeExcludes(input.exclude);
91
- let excluded = 0, traced = 0, total = 0;
93
+ // A-SPEC-702.1: the number is the commit's. Ignored build output and local scripts in a working checkout moved
94
+ // the badge (476/484 against a clean clone's 466/468 at the same commit, measured).
95
+ const tracked = input.tracked === undefined ? undefined : new Set([...input.tracked].map(trackedKey));
96
+ let excluded = 0, traced = 0, total = 0, notTracked = 0;
92
97
  const untraced = [];
93
98
  for (const f of input.files) {
94
99
  const p = posix(f.path);
@@ -97,6 +102,10 @@ function tracedFiles(input) {
97
102
  excluded++;
98
103
  continue;
99
104
  }
105
+ if (tracked !== undefined && !tracked.has(trackedKey(p))) {
106
+ notTracked++;
107
+ continue;
108
+ }
100
109
  total++;
101
110
  if (f.anchors.some((id) => approved.has(id)))
102
111
  traced++;
@@ -106,7 +115,7 @@ function tracedFiles(input) {
106
115
  untraced.sort();
107
116
  const reason = total === 0 ? 'no source files' : approved.size === 0 ? 'no approved specs' : undefined;
108
117
  return {
109
- total, traced, excluded, untraced,
118
+ total, traced, excluded, notTracked, untraced,
110
119
  measurable: reason === undefined,
111
120
  ...(reason !== undefined ? { reason } : {}),
112
121
  tracedPct: reason === undefined ? flooredPct(traced, total) : null,
@@ -145,6 +154,8 @@ function renderAttestText(r) {
145
154
  }
146
155
  if (r.provenance.exclude.length > 0)
147
156
  lines.push(`excluded ${f.excluded} file(s) under: ${r.provenance.exclude.join(', ')}`);
157
+ if (f.notTracked > 0)
158
+ lines.push(`not tracked ${f.notTracked} file(s) git does not track were not counted`);
148
159
  lines.push(`at ${r.provenance.at} · specs sha256:${r.provenance.specs}`);
149
160
  return lines.join('\n') + '\n';
150
161
  }
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.36.1",
4
+ "version": "0.37.1",
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",
@@ -13,8 +13,9 @@ description: >-
13
13
  계산 → `status: approved` + `approved_digest` + 부모 봉인 스냅샷 기록 → 원장 append를 한 번에.
14
14
  손으로 `status:`만 바꾸는 것으로는 부족하다: 봉인 없이 approved가 된 스펙은 `unsealed-approval`로
15
15
  검증에 걸리고, 봉인 후 본문을 고치면 `post-approval-edit`으로, 부모가 움직이면 `stale-parent`로
16
- 걸린다(REQ-132). `spec_approve`는 **서버 환경의** 유효한 `HOLMES_APPROVAL`을 요구한다(fail-closed) —
17
- 요청 인자로는 대체되지 않는다.
16
+ 걸린다(REQ-132). `spec_approve`는 사람의 승인을 요구한다(fail-closed) — 요청 인자로는 대체되지 않는다.
17
+ 사람은 세션의 승인 창에서 답한다. 거부가 `[승인 대기 req-…]`를 지목했다면 `approval_ask`에 그 id를 넘겨
18
+ 창을 띄운다(0.37.0). 창이 없는 세션에서는 운영자가 자기 터미널에서 `holmes-kit approve --grant <id>`로 결정한다.
18
19
 
19
20
  이 플레이북은 그 승인을 **언제·무엇에·어떤 근거로** 하는지를 다룬다. 문서를 새로 쓰는 일이라면
20
21
  이것이 아니라 `author-slice`다 — 판별은 3단계에 있다.