@holmes-lab/holmes-kit 0.38.0 → 0.39.0
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 +26 -0
- package/README.md +7 -2
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve.d.ts +1 -0
- package/dist/holmes/cli/approve.js +12 -1
- package/dist/holmes/cli/doctor.js +12 -1
- package/dist/holmes/cli/index.js +7 -3
- package/dist/holmes/cli/mcp-processes.d.ts +32 -0
- package/dist/holmes/cli/mcp-processes.js +132 -0
- package/dist/holmes/cli/run-provision.d.ts +6 -0
- package/dist/holmes/cli/run-provision.js +114 -0
- package/dist/holmes/cli/run.d.ts +5 -0
- package/dist/holmes/cli/run.js +38 -6
- package/dist/holmes/governance/approval-queue.d.ts +5 -0
- package/dist/holmes/governance/approval-queue.js +13 -0
- package/dist/holmes/governance/tool-actions.js +2 -0
- package/dist/holmes/guardrail/refusal-codes.js +7 -1
- package/dist/holmes/guardrail/risk-classifier.js +21 -3
- package/dist/holmes/guardrail/run-refusals.d.ts +6 -1
- package/dist/holmes/guardrail/run-refusals.js +13 -7
- package/dist/holmes/guardrail/run-stages.d.ts +5 -0
- package/dist/holmes/guardrail/run-stages.js +23 -3
- package/dist/holmes/hooks/pre-tool-use.js +33 -1
- package/dist/holmes/hooks/session-start.d.ts +5 -0
- package/dist/holmes/hooks/session-start.js +29 -1
- package/dist/holmes/hooks/stop.js +4 -2
- package/dist/holmes/mcp/handlers/approval-ask.d.ts +11 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +15 -1
- package/dist/holmes/mcp/handlers/workspace-preflight.d.ts +5 -0
- package/dist/holmes/mcp/handlers/workspace-preflight.js +10 -2
- package/dist/holmes/mcp/handlers.d.ts +10 -0
- package/dist/holmes/mcp/handlers.js +24 -3
- package/dist/holmes/mcp/server-staleness.d.ts +43 -0
- package/dist/holmes/mcp/server-staleness.js +158 -0
- package/dist/holmes/mcp/server.js +26 -2
- package/dist/holmes/mcp/tool-schemas.js +13 -0
- package/dist/holmes/project/workspace-preflight.d.ts +5 -0
- package/dist/holmes/project/workspace-preflight.js +24 -1
- package/dist/holmes/review/verdicts.d.ts +5 -0
- package/dist/holmes/review/verdicts.js +16 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,32 @@ 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.39.0] - 2026-10-23
|
|
11
|
+
|
|
12
|
+
Orchestration hardening, for the reference orchestrator's staged multi-agent runs (supervisor directive of 2026-10-23, items D1, D2, D4 and D11), plus the fixes G0 round 5 found before the SDLC comparison pilot.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **`run start --provision` (A-SPEC-774.29).** It makes a Claude Code worktree governed:
|
|
16
|
+
- **What it writes.** The worktree's `.mcp.json` holmes-kit entry and `.claude/settings.local.json` hooks, pinned to the CLI's own package. It writes only where `git check-ignore` says the path is ignored, so nothing it writes can be committed, and nothing is left behind when the worktree is removed.
|
|
17
|
+
- **No secret is copied.** It never writes `.claude/settings.json`.
|
|
18
|
+
- **Checks.** Run start's checks read `settings.local.json` too. The provision result is the first check and is recorded on the run.
|
|
19
|
+
- **Other engines.** Codex and Antigravity are refused by name.
|
|
20
|
+
- **A run's review policy (A-SPEC-102.10).**
|
|
21
|
+
- `run start --review-rounds <1-20>` records a cap on failing review rounds. Once the independent `fail` verdicts on the run's base reach it, a transition to a reviewed stage stops the run as `review.unresolved` and names the last round's findings, and every later tool call in the run is refused as stopped.
|
|
22
|
+
- `--strict-review` makes open important findings block, at transitions and at Stop.
|
|
23
|
+
- A run without either flag is judged as before.
|
|
24
|
+
- **`approval_withdraw` (A-SPEC-779.7).** A session withdraws a request its own MCP server filed. The request is recorded as withdrawn and leaves the operator's inbox. Another session's request is refused.
|
|
25
|
+
- **A stale MCP server says so (A-SPEC-251.4, 251.5).**
|
|
26
|
+
- Every object tool result carries `serverStale` once the installed package's version or build differs from what the server loaded.
|
|
27
|
+
- `workspace_preflight` gains an `mcp-build` check. Servers write a heartbeat.
|
|
28
|
+
- `doctor` (row `mcp server processes`) and the SessionStart banner name every running holmes-kit MCP server that started before its install was last written. That includes servers older than the self-check.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- **A spec write the store could not read (A-SPEC-792.9).** A Write, Edit or MultiEdit that would leave a spec file unreadable to the store is now refused with the parse error (`spec.unreadable`, permanent). Before, a headless session could break a spec's frontmatter into a state only a person could repair, and that deadlocked a G0 run at Stop.
|
|
32
|
+
- **Interpreter environment reads (A-SPEC-163.9).** An interpreter command counts as an environment read only when `environ`, `environb` or `ENVIRON` stands as a whole identifier. `pytest tests/test_environment.py` and `import sphinx.environment` are no longer refused as dumps.
|
|
33
|
+
- **Refusals from a working directory inside `.ax` (A-SPEC-773.5).** A refusal judged over `.ax` only because the shell's working directory is inside `.ax` now says so, and names `cd <workspace root>` on its own as the way out.
|
|
34
|
+
- **SDLC evaluation arms are isolated (A-SPEC-791.8).** Every arm starts isolated from the operator's user settings and plugins (`--setting-sources project,local`, `--strict-mcp-config`), and the launch summary records the environment.
|
|
35
|
+
|
|
10
36
|
## [0.38.0] - 2026-10-22
|
|
11
37
|
|
|
12
38
|
Full autonomy mode, and no approval decided by a typed terminal command (REQ-792). Owner direction, 2026-10-22: "full, 100% self-driving mode must be supported", and "the lowest-grade approval UX — approving with a command in a terminal — must be zero".
|
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
<!-- holmes-kit:attest:begin -->
|
|
10
10
|

|
|
11
11
|
|
|
12
|
-
**
|
|
13
|
-
Measured at `
|
|
12
|
+
**478/478** source files (100%) trace to an approved spec · **963/1040** approved A-SPECs (92.5%) are anchored from code.
|
|
13
|
+
Measured at `91233aabcdaf` (specs `sha256:c6a0ee346e19`) — reproduce with `holmes-kit attest --exclude docs/goals/probes/`.
|
|
14
14
|
<!-- holmes-kit:attest:end -->
|
|
15
15
|
|
|
16
16
|
---
|
|
@@ -22,6 +22,11 @@ Measured at `622ce26a4958` (specs `sha256:35b66c9f8ccd`) — reproduce with `hol
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
24
|
### 🛡️ Currently Supported Features (Production Features)
|
|
25
|
+
- **An orchestrator's runs carry their own wiring and review policy** *(new in 0.39.0)*:
|
|
26
|
+
- **`run start --provision`** makes a Claude Code worktree governed. It writes the worktree's `.mcp.json` and `.claude/settings.local.json`, and only where git ignores them. They are pinned to the CLI's own build, no secret is copied, and nothing is left behind when the worktree is removed. Codex and Antigravity runs are refused by name for now.
|
|
27
|
+
- **`--review-rounds <1-20>`** stops a run as `review.unresolved` once its failing independent reviews reach the cap, and names the unresolved findings. **`--strict-review`** also blocks on open important findings, at transitions and at Stop.
|
|
28
|
+
- **`approval_withdraw`** lets a session withdraw a request its own MCP server filed. Another session's request is refused.
|
|
29
|
+
- **A stale MCP server says so.** A running server reports `serverStale` on every tool result once the install it loaded has changed. `workspace_preflight` checks its build, and `doctor` and the session banner name every holmes-kit server that started before the last upgrade.
|
|
25
30
|
- **Full autonomy mode — no judgment waits for a person, and no approval is typed in a terminal** *(new in 0.38.0)*:
|
|
26
31
|
- **Issuing.** `holmes-kit autonomy full --scope <dir>` issues a user-level profile. The person decides it once, in the session's approval form, and an agent can never issue it.
|
|
27
32
|
- **Inside the scope**, every judgment ends at once:
|
package/dist/.build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
b694c7d6-mvkb62p4
|
|
@@ -48,6 +48,7 @@ export declare function denyRequest(root: string, id: string, reason: string, ac
|
|
|
48
48
|
export declare function withdrawRequest(root: string, id: string, reason: string, ctx: {
|
|
49
49
|
env: NodeJS.ProcessEnv;
|
|
50
50
|
cwd: string;
|
|
51
|
+
server?: string;
|
|
51
52
|
}): DecisionResult;
|
|
52
53
|
/** Hold with a question — approve/deny later. The agent carries the question to the user. */
|
|
53
54
|
export declare function holdRequest(root: string, id: string, question: string, actor: string): DecisionResult;
|
|
@@ -348,10 +348,21 @@ function withdrawRequest(root, id, reason, ctx) {
|
|
|
348
348
|
return { ok: false, reason: `no pending request ${(0, screen_safe_1.rowField)(id, 40)}` };
|
|
349
349
|
if (!recordIsSelfConsistent(entry))
|
|
350
350
|
return { ok: false, reason: TAMPERED };
|
|
351
|
+
// @implements A-SPEC-779.7 — the MCP server instance that filed a request withdraws it: an interactive session's
|
|
352
|
+
// request otherwise had no requester, and the operator approved nine abandoned ones (2026-10-23).
|
|
353
|
+
if (entry.requesterServer !== undefined) {
|
|
354
|
+
if (ctx.server !== entry.requesterServer) {
|
|
355
|
+
return { ok: false, reason: `only the session whose MCP server filed ${(0, screen_safe_1.rowField)(id, 40)} withdraws it: filed by server ${(0, screen_safe_1.rowField)(entry.requesterServer, 60)}; this is ${ctx.server ? `server ${(0, screen_safe_1.rowField)(ctx.server, 60)}` : 'not that server'}` };
|
|
356
|
+
}
|
|
357
|
+
if (!appendEvent(root, { event: 'withdrawn', id, reason: reason.trim(), server: ctx.server, covered: entry.count })) {
|
|
358
|
+
return { ok: false, reason: 'could not write the withdrawal record (queue event) — check write permission on .ax/approvals. Nothing was recorded' };
|
|
359
|
+
}
|
|
360
|
+
return { ok: true };
|
|
361
|
+
}
|
|
351
362
|
const { runMode } = require('../governance/run-mode');
|
|
352
363
|
const here = runMode(ctx.env, root, ctx.cwd).id;
|
|
353
364
|
if (entry.requesterRun === undefined) {
|
|
354
|
-
return { ok: false, reason: `${(0, screen_safe_1.rowField)(id, 40)} was filed outside a run, so no requester can withdraw it — the operator denies it` };
|
|
365
|
+
return { ok: false, reason: `${(0, screen_safe_1.rowField)(id, 40)} was filed outside a run and outside an MCP server, so no requester can withdraw it — the operator denies it` };
|
|
355
366
|
}
|
|
356
367
|
if (here !== entry.requesterRun) {
|
|
357
368
|
return { ok: false, reason: `only the run that filed ${(0, screen_safe_1.rowField)(id, 40)} withdraws it: filed by run ${(0, screen_safe_1.rowField)(entry.requesterRun, 60)}; this is ${here ? `run ${(0, screen_safe_1.rowField)(here, 60)}` : 'not a run'}` };
|
|
@@ -75,7 +75,7 @@ exports.wiringHandshakeChecks = wiringHandshakeChecks;
|
|
|
75
75
|
exports.semanticCoverageCheck = semanticCoverageCheck;
|
|
76
76
|
exports.semanticTierVerdict = semanticTierVerdict;
|
|
77
77
|
exports.detectTreeKeyTemporary = detectTreeKeyTemporary;
|
|
78
|
-
// @implements A-SPEC-476.1, A-SPEC-476.5, A-SPEC-751.4, A-SPEC-751.9, A-SPEC-770.3, A-SPEC-770.6, A-SPEC-770.7, A-SPEC-770.9, A-SPEC-770.10,A-SPEC-733,A-SPEC-727, A-SPEC-774.22, A-SPEC-781.2, A-SPEC-182.3, A-SPEC-182.4,A-SPEC-721, A-SPEC-738, A-SPEC-734, A-SPEC-751, A-SPEC-751.2, A-SPEC-772.1, A-SPEC-772.5, A-SPEC-772.6, A-SPEC-772.7, A-SPEC-772.8, A-SPEC-772.9, A-SPEC-772.10, A-SPEC-772.11
|
|
78
|
+
// @implements A-SPEC-251.5, A-SPEC-476.1, A-SPEC-476.5, A-SPEC-751.4, A-SPEC-751.9, A-SPEC-770.3, A-SPEC-770.6, A-SPEC-770.7, A-SPEC-770.9, A-SPEC-770.10,A-SPEC-733,A-SPEC-727, A-SPEC-774.22, A-SPEC-781.2, A-SPEC-182.3, A-SPEC-182.4,A-SPEC-721, A-SPEC-738, A-SPEC-734, A-SPEC-751, A-SPEC-751.2, A-SPEC-772.1, A-SPEC-772.5, A-SPEC-772.6, A-SPEC-772.7, A-SPEC-772.8, A-SPEC-772.9, A-SPEC-772.10, A-SPEC-772.11
|
|
79
79
|
// @implements A-SPEC-704, A-SPEC-710, A-SPEC-712, A-SPEC-769.14, A-SPEC-769.16, A-SPEC-769.17, A-SPEC-769.18, A-SPEC-769.19, A-SPEC-769.20, A-SPEC-769.21
|
|
80
80
|
const doctor_guidance_1 = require("./doctor-guidance");
|
|
81
81
|
// @implements A-SPEC-264, A-SPEC-423, A-SPEC-549.1, A-SPEC-590
|
|
@@ -1573,6 +1573,17 @@ async function runDoctor(packageRoot, target, opts, extraChecks) {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
}
|
|
1575
1575
|
catch { /* .mcp.json absent or unparseable -> proceed without this check */ }
|
|
1576
|
+
// @implements A-SPEC-251.5 — the wiring can match while a running server still serves an older install: list every
|
|
1577
|
+
// holmes-kit MCP server process that started before its package was installed (read-only; ending them is the operator's).
|
|
1578
|
+
try {
|
|
1579
|
+
const { listProcessRows, staleMcpServers, readPackageInstall, mcpProcessesRow } = require('./mcp-processes');
|
|
1580
|
+
const rows = listProcessRows();
|
|
1581
|
+
const r = mcpProcessesRow(rows === null ? null : staleMcpServers(rows, readPackageInstall));
|
|
1582
|
+
// doctor has no INFO level: an unavailable scan adds no row, as an undecidable check never does here.
|
|
1583
|
+
if (r.level !== 'INFO')
|
|
1584
|
+
add(r.name, r.level, r.detail);
|
|
1585
|
+
}
|
|
1586
|
+
catch { /* the scan is diagnostic only */ }
|
|
1576
1587
|
// @implements A-SPEC-259 — the wiring is judged by SPAWNING it. String comparison is exactly how
|
|
1577
1588
|
// the dead `npx -y <pkg>@<ver> holmes-mcp` form (npx resolves the default bin and hands
|
|
1578
1589
|
// `holmes-mcp` to it as an argument) passed the launcher test, this doctor's own handshake check
|
package/dist/holmes/cli/index.js
CHANGED
|
@@ -37,7 +37,7 @@ exports.isBrokenPipe = void 0;
|
|
|
37
37
|
exports.packageRoot = packageRoot;
|
|
38
38
|
exports.main = main;
|
|
39
39
|
exports.installPipeGuard = installPipeGuard;
|
|
40
|
-
// @implements A-SPEC-704, A-SPEC-773, A-SPEC-770.11,A-SPEC-709, A-SPEC-734,A-SPEC-751, A-SPEC-752, A-SPEC-772.4, A-SPEC-779, A-SPEC-102.2, A-SPEC-774.20, A-SPEC-102.7, A-SPEC-779.2, A-SPEC-792.3
|
|
40
|
+
// @implements A-SPEC-704, A-SPEC-773, A-SPEC-770.11,A-SPEC-709, A-SPEC-734,A-SPEC-751, A-SPEC-752, A-SPEC-772.4, A-SPEC-779, A-SPEC-102.2, A-SPEC-774.20, A-SPEC-102.7, A-SPEC-779.2, A-SPEC-792.3, A-SPEC-102.10
|
|
41
41
|
// @implements A-SPEC-549.2
|
|
42
42
|
// @implements A-SPEC-591, A-SPEC-626
|
|
43
43
|
const cli_execution_1 = require("./cli-execution");
|
|
@@ -89,7 +89,7 @@ const KNOWN_FLAGS = {
|
|
|
89
89
|
scratch: ['help', 'new'],
|
|
90
90
|
// @implements A-SPEC-774.10 — the role policy rewritten into the new vocabulary with equal verdicts.
|
|
91
91
|
roles: ['help', 'target', 'dry-run'],
|
|
92
|
-
run: ['help', 'target', 'worktree', 'engine', 'engine-arg', 'id', 'key', 'scope', 'to', 'why', 'accept-unknown-versions'], // @implements A-SPEC-774.17, A-SPEC-102.5, A-SPEC-781, A-SPEC-774.20
|
|
92
|
+
run: ['help', 'target', 'worktree', 'engine', 'engine-arg', 'id', 'key', 'scope', 'to', 'why', 'accept-unknown-versions', 'provision', 'review-rounds', 'strict-review'], // @implements A-SPEC-774.17, A-SPEC-102.5, A-SPEC-781, A-SPEC-774.20, A-SPEC-774.29, A-SPEC-102.10
|
|
93
93
|
review: ['help', 'target', 'base', 'head', 'verdict', 'finding', 'engine', 'model', 'session', 'strict', 'solid'], // @implements A-SPEC-102.2, A-SPEC-102.7
|
|
94
94
|
skills: ['help', 'target'],
|
|
95
95
|
ci: ['help', 'target', 'specs-dir', 'json'],
|
|
@@ -136,7 +136,7 @@ class UnknownFlagError extends Error {
|
|
|
136
136
|
// A-SPEC-251.1 (round 26): `yes` — `upgrade --yes` was refused as "--yes requires a value", so the non-interactive
|
|
137
137
|
// upgrade its own guidance names could not run (measured).
|
|
138
138
|
// A-SPEC-774.24: --accept-unknown-versions names its fields, so it is a value flag, not one of these.
|
|
139
|
-
const BOOLEAN_FLAGS = new Set(['badge', 'readme', 'help', 'dry-run', 'no-mcp', 'remove', 'force', 'json', 'list', 'status', 'watch', 'autonomy', 'no-autonomy', 'yes', 'allow-push', 'allow-publish', 'no-architecture']); // `--revoke` stays a value flag: `approve --revoke <id>` // A-SPEC-650: --status
|
|
139
|
+
const BOOLEAN_FLAGS = new Set(['badge', 'readme', 'help', 'dry-run', 'no-mcp', 'remove', 'force', 'json', 'list', 'status', 'watch', 'autonomy', 'no-autonomy', 'yes', 'allow-push', 'allow-publish', 'no-architecture', 'provision', 'strict-review']); // `--revoke` stays a value flag: `approve --revoke <id>` // A-SPEC-650: --status
|
|
140
140
|
/** @implements A-SPEC-770.11 — value flags whose value may be omitted; the handler supplies the default. */
|
|
141
141
|
const OPTIONAL_VALUE_FLAGS = new Set(['refusals']);
|
|
142
142
|
/** @implements A-SPEC-771.1 — value flags that may be given more than once. */
|
|
@@ -632,6 +632,10 @@ async function main(argv) {
|
|
|
632
632
|
engineArgs: str('engine-arg')?.split('\n'), id: str('id'), key: str('key'), scope: str('scope')?.split('\n'), to: str('to'), why: str('why'),
|
|
633
633
|
// @implements A-SPEC-774.20 — start despite unreadable versions; run start records which.
|
|
634
634
|
...(acceptParsed !== null ? { acceptUnknownVersions: acceptParsed.fields } : {}),
|
|
635
|
+
...(flags.provision === true ? { provision: true } : {}), // @implements A-SPEC-774.29
|
|
636
|
+
// @implements A-SPEC-102.10 — the run's review policy, validated by run start.
|
|
637
|
+
...(str('review-rounds') !== undefined ? { reviewRounds: str('review-rounds') } : {}),
|
|
638
|
+
...(flags['strict-review'] === true ? { strictReview: true } : {}),
|
|
635
639
|
}, { stdout: (t) => process.stdout.write(t), stderr: (t) => process.stderr.write(t) });
|
|
636
640
|
}
|
|
637
641
|
// @implements A-SPEC-102.2 — review verdicts for callers that are not MCP clients.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface PsRow {
|
|
2
|
+
pid: number;
|
|
3
|
+
startedMs: number;
|
|
4
|
+
command: string;
|
|
5
|
+
}
|
|
6
|
+
export interface StaleServer {
|
|
7
|
+
pid: number;
|
|
8
|
+
startedAt: string;
|
|
9
|
+
packageRoot: string;
|
|
10
|
+
installedVersion: string;
|
|
11
|
+
installedAt: string;
|
|
12
|
+
}
|
|
13
|
+
/** Rows of `ps -Ao pid=,lstart=,command=` under LC_ALL=C: `<pid> <Dow Mon DD HH:MM:SS YYYY> <command>`. */
|
|
14
|
+
export declare function parsePsRows(text: string): PsRow[];
|
|
15
|
+
/** The holmes-kit package at `root`: its version and the mtime of its package.json (the install time). */
|
|
16
|
+
export declare function readPackageInstall(root: string): {
|
|
17
|
+
version: string;
|
|
18
|
+
installedMs: number;
|
|
19
|
+
} | null;
|
|
20
|
+
export declare function staleMcpServers(rows: PsRow[], readPkg: (root: string) => {
|
|
21
|
+
version: string;
|
|
22
|
+
installedMs: number;
|
|
23
|
+
} | null): StaleServer[];
|
|
24
|
+
/** The process table, or null where it cannot be read (win32, or ps failing). Bounded by a 3 s timeout. */
|
|
25
|
+
export declare function listProcessRows(): PsRow[] | null;
|
|
26
|
+
export declare function mcpProcessesRow(stale: StaleServer[] | null): {
|
|
27
|
+
name: string;
|
|
28
|
+
level: 'PASS' | 'WARN' | 'INFO';
|
|
29
|
+
detail: string;
|
|
30
|
+
};
|
|
31
|
+
/** One banner line for the servers running from the workspace's wired package root, or ''. */
|
|
32
|
+
export declare function mcpProcessBannerLine(stale: StaleServer[], wiredRoot: string): string;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parsePsRows = parsePsRows;
|
|
37
|
+
exports.readPackageInstall = readPackageInstall;
|
|
38
|
+
exports.staleMcpServers = staleMcpServers;
|
|
39
|
+
exports.listProcessRows = listProcessRows;
|
|
40
|
+
exports.mcpProcessesRow = mcpProcessesRow;
|
|
41
|
+
exports.mcpProcessBannerLine = mcpProcessBannerLine;
|
|
42
|
+
// @implements A-SPEC-251.5
|
|
43
|
+
/**
|
|
44
|
+
* Running holmes-kit MCP servers that started before their install was upgraded.
|
|
45
|
+
*
|
|
46
|
+
* Measured 2026-10-23 (D1): the jarvis session's server served v0.36.0 under a 0.38.0 global install — two such
|
|
47
|
+
* processes had been alive a day and a half. A server older than A-SPEC-251.4 cannot say so itself; from outside, its
|
|
48
|
+
* process started before its package.json was written. Read-only: nothing here signals a process.
|
|
49
|
+
*/
|
|
50
|
+
const fs = __importStar(require("node:fs"));
|
|
51
|
+
const path = __importStar(require("node:path"));
|
|
52
|
+
const node_child_process_1 = require("node:child_process");
|
|
53
|
+
const TOLERANCE_MS = 2000;
|
|
54
|
+
const MAX_ROWS = 2000;
|
|
55
|
+
const SERVER_RE = /(?:^|\s)(\S*?)[\\/]bin[\\/]holmes-mcp\.js(?:\s|$)/;
|
|
56
|
+
/** Rows of `ps -Ao pid=,lstart=,command=` under LC_ALL=C: `<pid> <Dow Mon DD HH:MM:SS YYYY> <command>`. */
|
|
57
|
+
function parsePsRows(text) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const line of text.split('\n').slice(0, MAX_ROWS)) {
|
|
60
|
+
const m = /^\s*(\d+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.*)$/.exec(line);
|
|
61
|
+
if (!m)
|
|
62
|
+
continue;
|
|
63
|
+
const startedMs = new Date(m[2]).getTime();
|
|
64
|
+
if (!Number.isFinite(startedMs))
|
|
65
|
+
continue;
|
|
66
|
+
out.push({ pid: Number(m[1]), startedMs, command: m[3].trim() });
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/** The holmes-kit package at `root`: its version and the mtime of its package.json (the install time). */
|
|
71
|
+
function readPackageInstall(root) {
|
|
72
|
+
try {
|
|
73
|
+
const file = path.join(root, 'package.json');
|
|
74
|
+
const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
75
|
+
if (pkg.name !== '@holmes-lab/holmes-kit' || typeof pkg.version !== 'string')
|
|
76
|
+
return null;
|
|
77
|
+
return { version: pkg.version.slice(0, 40), installedMs: fs.statSync(file).mtimeMs };
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function staleMcpServers(rows, readPkg) {
|
|
84
|
+
const out = [];
|
|
85
|
+
const cache = new Map();
|
|
86
|
+
for (const r of rows) {
|
|
87
|
+
const m = SERVER_RE.exec(r.command);
|
|
88
|
+
if (!m || m[1] === '')
|
|
89
|
+
continue;
|
|
90
|
+
const root = m[1];
|
|
91
|
+
if (!cache.has(root))
|
|
92
|
+
cache.set(root, readPkg(root));
|
|
93
|
+
const pkg = cache.get(root);
|
|
94
|
+
if (!pkg || r.startedMs >= pkg.installedMs - TOLERANCE_MS)
|
|
95
|
+
continue;
|
|
96
|
+
out.push({ pid: r.pid, startedAt: new Date(r.startedMs).toISOString(), packageRoot: root,
|
|
97
|
+
installedVersion: pkg.version, installedAt: new Date(pkg.installedMs).toISOString() });
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
/** The process table, or null where it cannot be read (win32, or ps failing). Bounded by a 3 s timeout. */
|
|
102
|
+
function listProcessRows() {
|
|
103
|
+
if (process.platform === 'win32')
|
|
104
|
+
return null;
|
|
105
|
+
try {
|
|
106
|
+
const p = (0, node_child_process_1.spawnSync)('ps', ['-Ao', 'pid=,lstart=,command='], { encoding: 'utf8', timeout: 3000, env: { ...process.env, LC_ALL: 'C', LANG: 'C' }, maxBuffer: 8 * 1024 * 1024 });
|
|
107
|
+
if (p.status !== 0 || typeof p.stdout !== 'string')
|
|
108
|
+
return null;
|
|
109
|
+
return parsePsRows(p.stdout);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const STEP = 'restart those sessions (their MCP servers) to load the installed build; nothing here stops a process';
|
|
116
|
+
function mcpProcessesRow(stale) {
|
|
117
|
+
const name = 'mcp server processes';
|
|
118
|
+
if (stale === null)
|
|
119
|
+
return { name, level: 'INFO', detail: 'process scan unavailable on this platform' };
|
|
120
|
+
if (stale.length === 0)
|
|
121
|
+
return { name, level: 'PASS', detail: 'no running holmes-kit MCP server predates its install' };
|
|
122
|
+
const list = stale.slice(0, 20).map((s) => `pid ${s.pid} (started ${s.startedAt}, ${s.packageRoot}, now v${s.installedVersion} since ${s.installedAt})`).join('; ');
|
|
123
|
+
return { name, level: 'WARN', detail: `${stale.length} holmes-kit MCP server(s) started before their install was upgraded: ${list} — ${STEP}` };
|
|
124
|
+
}
|
|
125
|
+
/** One banner line for the servers running from the workspace's wired package root, or ''. */
|
|
126
|
+
function mcpProcessBannerLine(stale, wiredRoot) {
|
|
127
|
+
const mine = stale.filter((s) => path.resolve(s.packageRoot) === path.resolve(wiredRoot));
|
|
128
|
+
if (mine.length === 0)
|
|
129
|
+
return '';
|
|
130
|
+
return `[Holmes-Kit] ${mine.length} holmes-kit MCP server process(es) from ${wiredRoot} started before it was upgraded to v${mine[0].installedVersion} `
|
|
131
|
+
+ `(${mine.slice(0, 10).map((s) => `pid ${s.pid}`).join(', ')}): sessions started then still serve the older tools — ${STEP}`;
|
|
132
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.provisionWorktree = provisionWorktree;
|
|
37
|
+
// @implements A-SPEC-774.29
|
|
38
|
+
/**
|
|
39
|
+
* `run start --provision`: make an orchestrator's worktree governed.
|
|
40
|
+
*
|
|
41
|
+
* Measured 2026-10-23 (D11): a real 0.38.0 `run start --engine claude` on a jarvis copy's worktree failed `mcp` and
|
|
42
|
+
* `versions` — jarvis keeps `.mcp.json` (it held an approval token) and `.claude/settings.local.json` out of git, so a
|
|
43
|
+
* fresh worktree carries neither. Provisioning writes those two files inside the worktree, and only when git ignores
|
|
44
|
+
* them there: built fresh from THIS CLI's package root (the build the run pins), nothing read from the main checkout
|
|
45
|
+
* (no secret copied), and nothing left once the worktree is removed. `init` would write tracked guidance files into
|
|
46
|
+
* the worktree; runtime-binding is machine-level state that outlives it.
|
|
47
|
+
*/
|
|
48
|
+
const fs = __importStar(require("node:fs"));
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const node_child_process_1 = require("node:child_process");
|
|
51
|
+
const init_1 = require("./init");
|
|
52
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
53
|
+
const MCP_FILE = '.mcp.json';
|
|
54
|
+
const LOCAL_SETTINGS = path.join('.claude', 'settings.local.json');
|
|
55
|
+
const readJson = (file) => {
|
|
56
|
+
try {
|
|
57
|
+
const v = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
58
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const namesHolmes = (file) => {
|
|
65
|
+
try {
|
|
66
|
+
return /holmes/i.test(fs.readFileSync(file, 'utf8'));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/** Whether git ignores `rel` in the worktree. `check-ignore` exits 0 for an ignored path. */
|
|
73
|
+
function ignored(worktree, rel) {
|
|
74
|
+
const r = (0, node_child_process_1.spawnSync)('git', ['-C', worktree, 'check-ignore', '-q', '--', rel], { stdio: 'ignore', timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER });
|
|
75
|
+
return r.status === 0;
|
|
76
|
+
}
|
|
77
|
+
function provisionWorktree(worktree, engine, packageRoot) {
|
|
78
|
+
if (engine !== 'claude') {
|
|
79
|
+
return { refused: `provisioning is not available for ${engine}: its gate is wired at user level (${engine === 'codex' ? '$CODEX_HOME/hooks.json' : 'the agy settings'}), which a worktree cannot carry without leaving a trace — wire it with holmes-kit init or runtime-binding` };
|
|
80
|
+
}
|
|
81
|
+
const plan = [];
|
|
82
|
+
const mcpPath = path.join(worktree, MCP_FILE);
|
|
83
|
+
if (!namesHolmes(mcpPath)) {
|
|
84
|
+
plan.push({ rel: MCP_FILE, write: () => {
|
|
85
|
+
const doc = readJson(mcpPath) ?? {};
|
|
86
|
+
const servers = (doc.mcpServers !== null && typeof doc.mcpServers === 'object' && !Array.isArray(doc.mcpServers) ? doc.mcpServers : {});
|
|
87
|
+
servers['holmes-kit'] = { command: 'node', args: [path.join(packageRoot, 'bin', 'holmes-mcp.js')], env: { HOLMES_SPECS: '.ax/specs' } };
|
|
88
|
+
fs.writeFileSync(mcpPath, JSON.stringify({ ...doc, mcpServers: servers }, null, 2) + '\n');
|
|
89
|
+
} });
|
|
90
|
+
}
|
|
91
|
+
const settingsPath = path.join(worktree, LOCAL_SETTINGS);
|
|
92
|
+
if (!namesHolmes(path.join(worktree, '.claude', 'settings.json')) && !namesHolmes(settingsPath)) {
|
|
93
|
+
plan.push({ rel: LOCAL_SETTINGS, write: () => {
|
|
94
|
+
const hp = (0, init_1.buildHookPlan)(packageRoot, '.*');
|
|
95
|
+
const doc = readJson(settingsPath) ?? {};
|
|
96
|
+
const hooks = (doc.hooks !== null && typeof doc.hooks === 'object' && !Array.isArray(doc.hooks) ? doc.hooks : {});
|
|
97
|
+
const add = (event, entry) => { hooks[event] = [...(Array.isArray(hooks[event]) ? hooks[event] : []), entry]; };
|
|
98
|
+
add('PreToolUse', { matcher: hp.preToolUseMatcher, hooks: [{ type: 'command', command: hp.preToolUseCommand }] });
|
|
99
|
+
add('Stop', { hooks: [{ type: 'command', command: hp.stopCommand, timeout: 75 }] });
|
|
100
|
+
add('SessionStart', { hooks: [{ type: 'command', command: hp.sessionStartCommand }] });
|
|
101
|
+
const enabled = Array.isArray(doc.enabledMcpjsonServers) ? doc.enabledMcpjsonServers : [];
|
|
102
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
103
|
+
fs.writeFileSync(settingsPath, JSON.stringify({ ...doc, hooks, enabledMcpjsonServers: [...new Set([...enabled, 'holmes-kit'])] }, null, 2) + '\n');
|
|
104
|
+
} });
|
|
105
|
+
}
|
|
106
|
+
// Every file is checked before any is written: a refusal leaves the worktree as it was.
|
|
107
|
+
const exposed = plan.filter((p) => !ignored(worktree, p.rel)).map((p) => p.rel);
|
|
108
|
+
if (exposed.length > 0) {
|
|
109
|
+
return { refused: `${exposed.join(', ')} is not ignored by git in ${worktree}; provisioning would leave wiring that could be committed — ignore it in the repository, or wire the worktree another way` };
|
|
110
|
+
}
|
|
111
|
+
for (const p of plan)
|
|
112
|
+
p.write();
|
|
113
|
+
return { written: plan.map((p) => p.rel) };
|
|
114
|
+
}
|
package/dist/holmes/cli/run.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface RunOptions {
|
|
|
18
18
|
why?: string;
|
|
19
19
|
/** @implements A-SPEC-774.20, A-SPEC-774.24 — the unreadable version fields to start despite, by name; recorded. */
|
|
20
20
|
acceptUnknownVersions?: string[];
|
|
21
|
+
/** @implements A-SPEC-774.29 — write git-ignored worktree-local wiring pinned to this CLI's build before the checks. */
|
|
22
|
+
provision?: boolean;
|
|
23
|
+
/** @implements A-SPEC-102.10 — the review policy: a cap on failing review rounds (1–20), and strict review. */
|
|
24
|
+
reviewRounds?: string;
|
|
25
|
+
strictReview?: boolean;
|
|
21
26
|
}
|
|
22
27
|
export interface RunDeps {
|
|
23
28
|
home?: string;
|
package/dist/holmes/cli/run.js
CHANGED
|
@@ -39,7 +39,7 @@ exports.unreadableVersions = unreadableVersions;
|
|
|
39
39
|
exports.parseAcceptedVersions = parseAcceptedVersions;
|
|
40
40
|
exports.versionsCheck = versionsCheck;
|
|
41
41
|
exports.runRun = runRun;
|
|
42
|
-
// @implements A-SPEC-774.17, A-SPEC-779, A-SPEC-780, A-SPEC-102.3, A-SPEC-102.5, A-SPEC-781, A-SPEC-774.20, A-SPEC-781.2
|
|
42
|
+
// @implements A-SPEC-774.17, A-SPEC-779, A-SPEC-780, A-SPEC-102.3, A-SPEC-102.5, A-SPEC-781, A-SPEC-774.20, A-SPEC-781.2, A-SPEC-774.29, A-SPEC-102.10
|
|
43
43
|
const node_child_process_1 = require("node:child_process");
|
|
44
44
|
const crypto = __importStar(require("node:crypto"));
|
|
45
45
|
const config_1 = require("../config/config");
|
|
@@ -120,7 +120,7 @@ function runVersions(worktree, engine, deps) {
|
|
|
120
120
|
mcp = null;
|
|
121
121
|
}
|
|
122
122
|
const hookFiles = engine === 'claude'
|
|
123
|
-
? [path.join(worktree, '.claude', 'settings.json'), path.join(home, '.claude', 'settings.json')]
|
|
123
|
+
? [path.join(worktree, '.claude', 'settings.json'), path.join(worktree, '.claude', 'settings.local.json'), path.join(home, '.claude', 'settings.json')]
|
|
124
124
|
: engine === 'codex' ? [path.join(deps.codexHome ?? process.env.CODEX_HOME ?? path.join(home, '.codex'), 'hooks.json')] : [];
|
|
125
125
|
const hookPkg = hookFiles.flatMap((f) => hookCommandsIn(readText(f))).map(hookCommandPackage).find((v) => v !== null) ?? null;
|
|
126
126
|
return {
|
|
@@ -178,7 +178,7 @@ function versionsCheck(v, engine, accepted) {
|
|
|
178
178
|
return { name: 'versions', status: 'pass', detail: `the MCP and hook versions equal this CLI ${v.cli}, and every ${s.exempt.length > 0 ? 'other ' : ''}build id was read${exemptNote}` };
|
|
179
179
|
}
|
|
180
180
|
const HEADLESS = { claude: ['claude', '-p'], codex: ['codex', 'exec'], agy: ['agy', '-p'] };
|
|
181
|
-
const USAGE = 'usage: holmes-kit run start --worktree <dir> --engine claude|codex|agy [--engine-arg <a>]... [--accept-unknown-versions <field,...>] [--target <dir>]\n'
|
|
181
|
+
const USAGE = 'usage: holmes-kit run start --worktree <dir> --engine claude|codex|agy [--engine-arg <a>]... [--accept-unknown-versions <field,...>] [--provision] [--review-rounds <1-20>] [--strict-review] [--target <dir>]\n'
|
|
182
182
|
+ ' holmes-kit run status [--target <dir>]\n'
|
|
183
183
|
+ ' holmes-kit run transition --id <run_id> --to <stage> --key <stop_key> [--why <text>] [--target <dir>]\n'
|
|
184
184
|
+ ' holmes-kit run stop --id <run_id> --key <stop_key> [--target <dir>]\n';
|
|
@@ -212,9 +212,11 @@ function checks(main, worktree, engine, args, deps) {
|
|
|
212
212
|
out.push(mcp ? { name: 'mcp', status: 'pass', detail: `the ${engine} MCP wiring in the worktree names holmes-kit` }
|
|
213
213
|
: { name: 'mcp', status: 'fail', detail: `the worktree carries no ${engine} MCP wiring that names holmes-kit` });
|
|
214
214
|
if (engine === 'claude') {
|
|
215
|
-
|
|
215
|
+
// @implements A-SPEC-774.29 — settings.local.json too: Claude loads it, and init writes the hooks there.
|
|
216
|
+
const hooked = namesHolmes(readText(path.join(worktree, '.claude', 'settings.json'))) || namesHolmes(readText(path.join(worktree, '.claude', 'settings.local.json')))
|
|
217
|
+
|| namesHolmes(readText(path.join(home, '.claude', 'settings.json')));
|
|
216
218
|
out.push(hooked ? { name: 'gate', status: 'pass', detail: 'a Holmes hook is wired in the project or user Claude settings' }
|
|
217
|
-
: { name: 'gate', status: 'fail', detail: 'no Holmes hook in <worktree>/.claude/settings.json or ~/.claude/settings.json — the Claude gate would not load' });
|
|
219
|
+
: { name: 'gate', status: 'fail', detail: 'no Holmes hook in <worktree>/.claude/settings.json, <worktree>/.claude/settings.local.json or ~/.claude/settings.json — the Claude gate would not load' });
|
|
218
220
|
}
|
|
219
221
|
else if (engine === 'codex') {
|
|
220
222
|
const codexHome = deps.codexHome ?? process.env.CODEX_HOME ?? path.join(home, '.codex');
|
|
@@ -269,12 +271,39 @@ function runRun(sub, opts, io, deps = {}) {
|
|
|
269
271
|
const engine = opts.engine;
|
|
270
272
|
const worktree = path.resolve(opts.worktree);
|
|
271
273
|
const args = opts.engineArgs ?? [];
|
|
274
|
+
// @implements A-SPEC-102.10 — the review policy is the orchestrator's, set once here and recorded.
|
|
275
|
+
let reviewRounds;
|
|
276
|
+
if (opts.reviewRounds !== undefined) {
|
|
277
|
+
const n = Number(opts.reviewRounds);
|
|
278
|
+
if (!/^\d+$/.test(opts.reviewRounds.trim()) || !Number.isInteger(n) || n < 1 || n > 20) {
|
|
279
|
+
io.stderr(`--review-rounds must be an integer from 1 to 20 (got ${JSON.stringify(opts.reviewRounds).slice(0, 40)})\n${USAGE}`);
|
|
280
|
+
return 2;
|
|
281
|
+
}
|
|
282
|
+
reviewRounds = n;
|
|
283
|
+
}
|
|
284
|
+
const review = reviewRounds !== undefined || opts.strictReview
|
|
285
|
+
? { ...(reviewRounds !== undefined ? { rounds: reviewRounds } : {}), ...(opts.strictReview ? { strict: true } : {}) } : undefined;
|
|
286
|
+
// @implements A-SPEC-774.29 — provisioning runs before the checks, so they judge the worktree as provisioned.
|
|
287
|
+
let provisioned = [];
|
|
288
|
+
let provisionRefusal = null;
|
|
289
|
+
if (opts.provision) {
|
|
290
|
+
const { provisionWorktree } = require('./run-provision');
|
|
291
|
+
const p = provisionWorktree(worktree, engine, path.resolve(__dirname, '..', '..', '..'));
|
|
292
|
+
if ('refused' in p)
|
|
293
|
+
provisionRefusal = p.refused;
|
|
294
|
+
else
|
|
295
|
+
provisioned = p.written;
|
|
296
|
+
}
|
|
272
297
|
const found = checks(main, worktree, engine, args, deps);
|
|
298
|
+
if (opts.provision) {
|
|
299
|
+
found.unshift(provisionRefusal !== null ? { name: 'provision', status: 'fail', detail: provisionRefusal }
|
|
300
|
+
: { name: 'provision', status: 'pass', detail: provisioned.length > 0 ? `wrote ${provisioned.join(', ')} (git-ignored, pinned to this CLI)` : 'the worktree already carries Holmes wiring' });
|
|
301
|
+
}
|
|
273
302
|
// @implements A-SPEC-774.18 — the builds that would govern the run, pinned before anything is written.
|
|
274
303
|
const versions = runVersions(worktree, engine, deps);
|
|
275
304
|
found.push(versionsCheck(versions, engine, opts.acceptUnknownVersions ?? []));
|
|
276
305
|
if (found.some((c) => c.status === 'fail')) {
|
|
277
|
-
io.stdout(`${JSON.stringify({ ok: false, refused: 'a check failed — the run would not be governed', checks: found, versions }, null, 2)}\n`);
|
|
306
|
+
io.stdout(`${JSON.stringify({ ok: false, refused: 'a check failed — the run would not be governed', checks: found, versions, ...(provisioned.length > 0 ? { provisioned } : {}) }, null, 2)}\n`);
|
|
278
307
|
return 3;
|
|
279
308
|
}
|
|
280
309
|
const now = (deps.now ?? (() => new Date()))();
|
|
@@ -288,6 +317,8 @@ function runRun(sub, opts, io, deps = {}) {
|
|
|
288
317
|
const rec = {
|
|
289
318
|
run_id: runId, worktree: fs.realpathSync(worktree), sessions: [], engine, started: now.toISOString(), stop_key_sha256: (0, run_records_1.keyHash)(stopKey),
|
|
290
319
|
versions, ...(base ? { base } : {}),
|
|
320
|
+
...(provisioned.length > 0 ? { provisioned } : {}), // @implements A-SPEC-774.29
|
|
321
|
+
...(review ? { review } : {}), // @implements A-SPEC-102.10
|
|
291
322
|
...(opts.scope && opts.scope.length > 0 ? { scope: [...opts.scope] } : {}),
|
|
292
323
|
...(accepted.length > 0 ? { accepted_unknown_versions: accepted } : {}),
|
|
293
324
|
...(exempt.length > 0 ? { exempt_unknown_versions: exempt } : {}),
|
|
@@ -302,6 +333,7 @@ function runRun(sub, opts, io, deps = {}) {
|
|
|
302
333
|
(0, run_refusals_1.appendRunEvent)(main, runId, { ts: now.toISOString(), event: 'stages_interpreted', notes: stageNotes });
|
|
303
334
|
io.stdout(`${JSON.stringify({
|
|
304
335
|
ok: true, run_id: runId, worktree, record, env: { HOLMES_RUN_ID: runId }, command: [...HEADLESS[engine], ...args],
|
|
336
|
+
...(provisioned.length > 0 ? { provisioned } : {}),
|
|
305
337
|
stop_key: stopKey, versions, checks: found, ...(stageNotes.length > 0 ? { stage_notes: stageNotes } : {}),
|
|
306
338
|
}, null, 2)}\n`);
|
|
307
339
|
return 0;
|
|
@@ -54,6 +54,8 @@ export interface RefusalRecord {
|
|
|
54
54
|
reasonBytes?: number;
|
|
55
55
|
/** @implements A-SPEC-779.2 — the run that filed it; absent outside a run. */
|
|
56
56
|
requester_run?: string;
|
|
57
|
+
/** @implements A-SPEC-779.7 — the MCP server instance that filed it; absent for hooks and the CLI. */
|
|
58
|
+
requester_server?: string;
|
|
57
59
|
}
|
|
58
60
|
export declare function refusalsFilename(replica: string): string;
|
|
59
61
|
/** Born split: there is no legacy single `refusals.jsonl` — the file did not exist before replicas did. */
|
|
@@ -92,7 +94,10 @@ export interface PendingRequest {
|
|
|
92
94
|
title?: string;
|
|
93
95
|
/** @implements A-SPEC-779.2 — the run that filed it, the only one that may withdraw it; absent outside a run. */
|
|
94
96
|
requesterRun?: string;
|
|
97
|
+
/** @implements A-SPEC-779.7 — the MCP server instance that filed it (`<pid>:<startedAt>`), which may withdraw it. */
|
|
98
|
+
requesterServer?: string;
|
|
95
99
|
}
|
|
100
|
+
export declare function setRequesterServer(instance: string | undefined): void;
|
|
96
101
|
export interface QueueState {
|
|
97
102
|
pending: PendingRequest[];
|
|
98
103
|
/**
|
|
@@ -40,6 +40,7 @@ exports.approvalAskLine = approvalAskLine;
|
|
|
40
40
|
exports.refusalsFilename = refusalsFilename;
|
|
41
41
|
exports.isRefusalsFilename = isRefusalsFilename;
|
|
42
42
|
exports.readRefusals = readRefusals;
|
|
43
|
+
exports.setRequesterServer = setRequesterServer;
|
|
43
44
|
exports.approvalRequestId = approvalRequestId;
|
|
44
45
|
exports.foldQueue = foldQueue;
|
|
45
46
|
exports.enqueueApprovalRequest = enqueueApprovalRequest;
|
|
@@ -171,6 +172,15 @@ function readRefusals(root) {
|
|
|
171
172
|
}
|
|
172
173
|
return out.sort((a, b) => (a.r.ts < b.r.ts ? -1 : a.r.ts > b.r.ts ? 1 : a.i - b.i)).map((e) => e.r);
|
|
173
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* @implements A-SPEC-779.7 — the requester key of a filing made inside the MCP server: its instance id, set once at
|
|
177
|
+
* server start. Process-global on purpose: a request is filed deep inside handlers that never see the server. Hooks and
|
|
178
|
+
* the CLI never set it, so their filings carry no `requester_server`.
|
|
179
|
+
*/
|
|
180
|
+
let requesterServer;
|
|
181
|
+
function setRequesterServer(instance) {
|
|
182
|
+
requesterServer = typeof instance === 'string' && instance !== '' ? instance.slice(0, 120) : undefined;
|
|
183
|
+
}
|
|
174
184
|
/**
|
|
175
185
|
* Deterministic request id from the action's identity.
|
|
176
186
|
*
|
|
@@ -268,6 +278,7 @@ function foldQueue(lines, opts) {
|
|
|
268
278
|
...(typeof e.risk === 'string' && e.risk !== '' ? { risk: e.risk } : {}),
|
|
269
279
|
...(typeof e.title === 'string' && e.title !== '' ? { title: e.title } : {}), // @implements A-SPEC-770.12
|
|
270
280
|
...(typeof e.requester_run === 'string' && e.requester_run !== '' ? { requesterRun: e.requester_run } : {}), // @implements A-SPEC-779.2
|
|
281
|
+
...(typeof e.requester_server === 'string' && e.requester_server !== '' ? { requesterServer: e.requester_server } : {}), // @implements A-SPEC-779.7
|
|
271
282
|
});
|
|
272
283
|
}
|
|
273
284
|
break;
|
|
@@ -426,6 +437,7 @@ function enqueueApprovalRequestDetailed(root, req) {
|
|
|
426
437
|
...(typeof req.risk === 'string' && req.risk !== '' ? { risk: req.risk } : {}),
|
|
427
438
|
...(typeof req.title === 'string' && req.title.trim() !== '' ? { title: (0, screen_safe_1.flattenField)(req.title, 200) } : {}), // @implements A-SPEC-770.12
|
|
428
439
|
...(requesterRun ? { requester_run: requesterRun } : {}),
|
|
440
|
+
...(requesterServer ? { requester_server: requesterServer } : {}), // @implements A-SPEC-779.7
|
|
429
441
|
// @implements A-SPEC-564.2 — only the refusal log carries the feedback cost; inbox kinds have
|
|
430
442
|
// no deny text to measure.
|
|
431
443
|
...(!exports.DECISION_KINDS.has(req.kind) && typeof req.reasonBytes === 'number' && Number.isFinite(req.reasonBytes)
|
|
@@ -669,5 +681,6 @@ function asPendingRequest(id, occurrences) {
|
|
|
669
681
|
lastTs: latest.ts,
|
|
670
682
|
...(latest.replica ? { replica: latest.replica } : {}),
|
|
671
683
|
...(latest.requester_run ? { requesterRun: latest.requester_run } : {}), // @implements A-SPEC-779.2
|
|
684
|
+
...(latest.requester_server ? { requesterServer: latest.requester_server } : {}), // @implements A-SPEC-779.7
|
|
672
685
|
};
|
|
673
686
|
}
|