@holmes-lab/holmes-kit 0.35.5 → 0.35.7
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 +35 -0
- package/README.md +2 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/runtime-binding.d.ts +2 -0
- package/dist/holmes/cli/runtime-binding.js +6 -1
- package/dist/holmes/hooks/stop.d.ts +19 -0
- package/dist/holmes/hooks/stop.js +22 -0
- package/dist/holmes/mcp/elicit-approval.js +2 -1
- package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +45 -0
- package/dist/holmes/mcp/handlers/runtime-binding-tool.js +135 -0
- package/dist/holmes/mcp/handlers.d.ts +38 -0
- package/dist/holmes/mcp/handlers.js +13 -0
- package/dist/holmes/mcp/tool-schemas.js +13 -0
- package/dist/holmes/rtm/test-scope.js +41 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
<!-- @implements A-SPEC-209 -->
|
|
8
|
+
## [0.35.7] - 2026-10-05
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **The Stop hook no longer judges repositories that are not Holmes projects** (A-SPEC-452.1). In a git repository
|
|
13
|
+
with no `.ax` directory and an untracked source file, the Stop hook answered a block: `[ART-1] … the changed source
|
|
14
|
+
has no @implements anchor`. Codex wires the Stop hook at user level, shared by every workspace on the machine, so
|
|
15
|
+
with that hook trusted every repository there had its turns held and was told to write Holmes specs. Where no
|
|
16
|
+
project can be found — no `.ax` marker and no wired spec directory at or above the working directory, and no
|
|
17
|
+
approval in a ledger there — the hook now answers nothing and creates nothing. Inside a project nothing changes,
|
|
18
|
+
and a project whose spec tree is gone while its ledger records approvals is still blocked with the
|
|
19
|
+
governance-lost reason. If you use Codex with Holmes hooks and saw turns blocked in unrelated repositories,
|
|
20
|
+
upgrade.
|
|
21
|
+
- **A Jest each-table written with a type argument is counted** (A-SPEC-750.1). The static case counter behind ART-4
|
|
22
|
+
recognised `it.each(table)(…)` and the template form, and stopped at the `<` of `it.each<Row>(table)(…)`, so a
|
|
23
|
+
TypeScript suite that types its tables on the call was counted below what Jest runs (measured: 7 where Jest ran 8).
|
|
24
|
+
The typed form now counts, including nested generics and arrow types in the argument. The counter remains a lower
|
|
25
|
+
bound: a type argument list that never closes counts nothing.
|
|
26
|
+
|
|
27
|
+
## [0.35.6] - 2026-10-05
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **A registered binding can be re-applied from inside the session** (A-SPEC-752.10). The new MCP tool
|
|
32
|
+
`runtime_binding` previews (`operation: "preview"`, the default) and applies (`operation: "apply"`) the plan
|
|
33
|
+
`holmes-kit runtime-binding setup` would make for the workspace the session is in, with `activate_hooks` naming the
|
|
34
|
+
harnesses whose Holmes hooks to restore. It takes no package argument: it plans only for the package and release
|
|
35
|
+
package the operator registry already names, so which build governs a workspace is still decided in a terminal, and
|
|
36
|
+
a workspace the registry does not name is refused. `apply` shows the plan digest and the files in the approval
|
|
37
|
+
dialog and writes only on an explicit approve answer there. A denial, an unanswered dialog, a client without the
|
|
38
|
+
form dialog and autonomous approval all write nothing; the request the CLI would file is filed and returned
|
|
39
|
+
instead. A plan with conflicts is not applied, and a plan that changed between the preview and the answer is
|
|
40
|
+
refused. An approved apply is recorded in the provenance ledger with the plan digest, like a terminal grant.
|
|
41
|
+
Limit: native trust of a hook in Codex is still given in Codex's own `/hooks` review.
|
|
42
|
+
|
|
8
43
|
## [0.35.5] - 2026-10-05
|
|
9
44
|
|
|
10
45
|
### Added
|
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ Measured at `173b99650442` (specs `sha256:215f84d4e9f4`) — reproduce with `hol
|
|
|
24
24
|
### 🛡️ Currently Supported Features (Production Features)
|
|
25
25
|
|
|
26
26
|
- **The protected store is recognised however a shell command spells it** *(new in 0.35.2 — security fix, upgrade recommended)*: through 0.35.1 a path into `.ax/specs`, `.ax/ledger`, `.ax/approvals` or `.ax/state` written directly after a shell expansion, a variable, or a character the shell removes at run time was not seen as protected, so a removal, move or overwrite of governance state could pass the gate. The store spelling now counts wherever it appears in a command, and an output redirect to a computed target is not a read. Reads still pass. A directory that merely ends in `.ax` and has a child named like the store's is judged as the store. Limit: a path assembled so the spelling never appears in the command text is outside this rule.
|
|
27
|
+
- **The Stop hook leaves other repositories alone** *(new in 0.35.7 — upgrade recommended for Codex users)*: Codex wires the Holmes Stop hook at user level, so it is called in every repository on the machine. Through 0.35.6 it blocked the end of a turn in a repository that is not a Holmes project (`[ART-1] … no @implements anchor`). It now answers nothing where no project can be found; inside a project nothing changes.
|
|
28
|
+
- **Re-apply a registered runtime binding without leaving the session** *(new in 0.35.6)*: the MCP tool `runtime_binding` previews and applies the plan `runtime-binding setup` would make for the registered workspace, including `activate_hooks`. It never chooses a build — it uses the package the operator registry already names — and it writes only when you answer approve in the approval dialog, which shows the plan digest and the files. No answer, a denial, a client without the dialog, or autonomous approval write nothing and leave the usual queue request. Native hook trust in Codex is still given in Codex's `/hooks`.
|
|
27
29
|
- **`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`)*.
|
|
28
30
|
- **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>`.
|
|
29
31
|
- **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`.
|
package/dist/.build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d2e28281-muvdpxtn
|
|
@@ -12,6 +12,8 @@ export interface RuntimeBindingOptions {
|
|
|
12
12
|
installerPackageRoot?: string;
|
|
13
13
|
approval?: Approval;
|
|
14
14
|
activateHooks?: string[];
|
|
15
|
+
/** @implements A-SPEC-752.10 — the digest a reviewer was shown; a plan that computes to another one is not applied. */
|
|
16
|
+
expectedPlanDigest?: string;
|
|
15
17
|
}
|
|
16
18
|
export declare function runtimeHookCommand(registryPath: string, harness: RuntimeHarness, entry: RuntimeEntry): string;
|
|
17
19
|
/**
|
|
@@ -41,7 +41,7 @@ exports.registryOwnedWiring = registryOwnedWiring;
|
|
|
41
41
|
exports.runtimeBindingStatus = runtimeBindingStatus;
|
|
42
42
|
exports.runRuntimeBinding = runRuntimeBinding;
|
|
43
43
|
exports.trackedWorkspacePaths = trackedWorkspacePaths;
|
|
44
|
-
// @implements A-SPEC-752.9, A-SPEC-751.5, A-SPEC-751, A-SPEC-752, A-SPEC-752.7, A-SPEC-752.8
|
|
44
|
+
// @implements A-SPEC-752.10, A-SPEC-752.9, A-SPEC-751.5, A-SPEC-751, A-SPEC-752, A-SPEC-752.7, A-SPEC-752.8
|
|
45
45
|
const fs = __importStar(require("node:fs"));
|
|
46
46
|
const os = __importStar(require("node:os"));
|
|
47
47
|
const path = __importStar(require("node:path"));
|
|
@@ -645,6 +645,11 @@ function runRuntimeBinding(opts) {
|
|
|
645
645
|
const changes = [...planned.values()].filter((c) => c.before !== c.after);
|
|
646
646
|
const planDigest = (0, runtime_binding_approval_1.runtimePlanDigest)({ operation: opts.operation, root, selection, releasePackageRoot: next.releasePackageRoot,
|
|
647
647
|
releaseBuild, activateHooks: [...activate].sort() }, changes);
|
|
648
|
+
// @implements A-SPEC-752.10 — what is applied is what was reviewed: the in-session dialog shows a digest, and a
|
|
649
|
+
// file that moved while the dialog was open makes this another plan.
|
|
650
|
+
if (opts.expectedPlanDigest !== undefined && opts.expectedPlanDigest !== planDigest) {
|
|
651
|
+
throw new Error(`Runtime plan changed since it was reviewed (reviewed ${opts.expectedPlanDigest}, now ${planDigest}); nothing written — preview it again`);
|
|
652
|
+
}
|
|
648
653
|
if (!opts.dryRun) {
|
|
649
654
|
if (conflicts.length)
|
|
650
655
|
throw new Error(`Runtime configuration conflicts; nothing written: ${conflicts.join('; ')}`);
|
|
@@ -219,6 +219,25 @@ export declare function rolledBackLedgers(root: string): string[] | undefined;
|
|
|
219
219
|
* Returns the reason to block with, or null when there is nothing to report.
|
|
220
220
|
*/
|
|
221
221
|
export declare function governanceLostPreflight(specsDir: string, projectRoot?: string): string | null;
|
|
222
|
+
/**
|
|
223
|
+
* @implements A-SPEC-452.1
|
|
224
|
+
* Is this turn outside every Holmes project?
|
|
225
|
+
*
|
|
226
|
+
* Measured 2026-10-05: in a plain git repository with no `.ax` directory and one untracked `a.js` this hook answered
|
|
227
|
+
* an ART-1 block. Codex wires Stop at user level, shared by every workspace on the machine, so every repository there
|
|
228
|
+
* had its turns held and was told to write Holmes specs. A-SPEC-452 guarded "no repository" and missed the
|
|
229
|
+
* repository that is not a project.
|
|
230
|
+
*
|
|
231
|
+
* All three must hold: the project lookup found nothing (no `.ax` marker and no wired spec directory at or above the
|
|
232
|
+
* working directory), the wired spec directory does not exist, and no ledger here records an approval. A project
|
|
233
|
+
* whose spec tree is gone while its ledger remembers approvals is NOT outside — that is A-SPEC-175's block, and the
|
|
234
|
+
* caller checks it first.
|
|
235
|
+
*/
|
|
236
|
+
export declare function outsideAnyProject(a: {
|
|
237
|
+
foundRoot: string | null;
|
|
238
|
+
specsDir: string;
|
|
239
|
+
cwd: string;
|
|
240
|
+
}): boolean;
|
|
222
241
|
/**
|
|
223
242
|
* One line per ARTICLE, each under its own name.
|
|
224
243
|
*
|
|
@@ -47,6 +47,7 @@ exports.escalateReappraisals = escalateReappraisals;
|
|
|
47
47
|
exports.unrecordedApprovals = unrecordedApprovals;
|
|
48
48
|
exports.rolledBackLedgers = rolledBackLedgers;
|
|
49
49
|
exports.governanceLostPreflight = governanceLostPreflight;
|
|
50
|
+
exports.outsideAnyProject = outsideAnyProject;
|
|
50
51
|
exports.trackedLines = trackedLines;
|
|
51
52
|
exports.evaluateStop = evaluateStop;
|
|
52
53
|
exports.stopDebtAction = stopDebtAction;
|
|
@@ -676,6 +677,23 @@ function governanceLostPreflight(specsDir, projectRoot) {
|
|
|
676
677
|
const root = projectRoot ?? path.resolve(specsDir, '..', '..');
|
|
677
678
|
return (0, governance_history_1.hasGovernanceHistory)(root) ? governance_history_1.GOVERNANCE_LOST_HINT : null;
|
|
678
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* @implements A-SPEC-452.1
|
|
682
|
+
* Is this turn outside every Holmes project?
|
|
683
|
+
*
|
|
684
|
+
* Measured 2026-10-05: in a plain git repository with no `.ax` directory and one untracked `a.js` this hook answered
|
|
685
|
+
* an ART-1 block. Codex wires Stop at user level, shared by every workspace on the machine, so every repository there
|
|
686
|
+
* had its turns held and was told to write Holmes specs. A-SPEC-452 guarded "no repository" and missed the
|
|
687
|
+
* repository that is not a project.
|
|
688
|
+
*
|
|
689
|
+
* All three must hold: the project lookup found nothing (no `.ax` marker and no wired spec directory at or above the
|
|
690
|
+
* working directory), the wired spec directory does not exist, and no ledger here records an approval. A project
|
|
691
|
+
* whose spec tree is gone while its ledger remembers approvals is NOT outside — that is A-SPEC-175's block, and the
|
|
692
|
+
* caller checks it first.
|
|
693
|
+
*/
|
|
694
|
+
function outsideAnyProject(a) {
|
|
695
|
+
return a.foundRoot === null && !fs.existsSync(a.specsDir) && !(0, governance_history_1.hasGovernanceHistory)(a.cwd);
|
|
696
|
+
}
|
|
679
697
|
// @implements A-SPEC-578.1
|
|
680
698
|
/** What each article's track observations are called on the operator's screen. */
|
|
681
699
|
const TRACK_LABELS = {
|
|
@@ -1293,6 +1311,10 @@ if (require.main === module) {
|
|
|
1293
1311
|
process.stderr.write(`${lost}\n`);
|
|
1294
1312
|
return;
|
|
1295
1313
|
}
|
|
1314
|
+
// @implements A-SPEC-452.1 — a user-level entry (Codex) is called in every repository on the machine. Where
|
|
1315
|
+
// there is no project this hook has nothing to judge: no answer, no notice, no file.
|
|
1316
|
+
if (outsideAnyProject({ foundRoot: findProjectRoot(wired), specsDir, cwd: process.cwd() }))
|
|
1317
|
+
return;
|
|
1296
1318
|
const specs = (0, pre_tool_use_1.readSpecsSync)(specsDir);
|
|
1297
1319
|
// H1 evidence: count EXECUTABLE test cases per anchored A-SPEC (countTestCases strips comments/
|
|
1298
1320
|
// strings — sham-resistant). A scan FAILURE yields `undefined` (ART-4 skipped this turn, true
|
|
@@ -32,7 +32,8 @@ const npx_bin_1 = require("../project/npx-bin");
|
|
|
32
32
|
* a fake elicitor.
|
|
33
33
|
*/
|
|
34
34
|
/** Approval kinds that may ask in-session. Widening this set is a spec revision, not a drive-by. */
|
|
35
|
-
|
|
35
|
+
// @implements A-SPEC-752.10 — `governance-wiring`: re-applying the binding the registry already names (never choosing one).
|
|
36
|
+
exports.ELICITABLE_KINDS = new Set(['spec-approve', 'review-resolve', 'governance-wiring']);
|
|
36
37
|
/** The `HOLMES_ELICIT` values that turn the in-client prompt OFF. */
|
|
37
38
|
const ELICIT_DISABLED_TOKENS = new Set(['off', '0', 'false', 'no', 'disabled']);
|
|
38
39
|
/**
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Approval } from '../../guardrail/risk-gate';
|
|
2
|
+
import { ElicitOutcome } from '../elicit-approval';
|
|
3
|
+
export interface RuntimeBindingToolContext {
|
|
4
|
+
foreignRootReason(root?: string): string | null;
|
|
5
|
+
projectRootOf(root: string): string;
|
|
6
|
+
tryElicit(kind: string, target: string, summary: string): Promise<ElicitOutcome>;
|
|
7
|
+
elicitApproval(reason: string | undefined): Approval;
|
|
8
|
+
registryPath(): string;
|
|
9
|
+
home?: string;
|
|
10
|
+
installerPackageRoot?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createRuntimeBindingToolHandlers(context: RuntimeBindingToolContext): {
|
|
13
|
+
runtime_binding(a: {
|
|
14
|
+
root: string;
|
|
15
|
+
operation?: string;
|
|
16
|
+
activate_hooks?: string[];
|
|
17
|
+
}): Promise<{
|
|
18
|
+
ok: boolean;
|
|
19
|
+
applied: boolean;
|
|
20
|
+
reason: string;
|
|
21
|
+
} | {
|
|
22
|
+
planDigest: string;
|
|
23
|
+
conflicts: string[];
|
|
24
|
+
changes: {
|
|
25
|
+
path: string;
|
|
26
|
+
added: number;
|
|
27
|
+
removed: number;
|
|
28
|
+
}[];
|
|
29
|
+
ok: boolean;
|
|
30
|
+
applied: boolean;
|
|
31
|
+
operation: string;
|
|
32
|
+
reason?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
planDigest: string;
|
|
35
|
+
conflicts: string[];
|
|
36
|
+
changes: {
|
|
37
|
+
path: string;
|
|
38
|
+
added: number;
|
|
39
|
+
removed: number;
|
|
40
|
+
}[];
|
|
41
|
+
ok: boolean;
|
|
42
|
+
applied: boolean;
|
|
43
|
+
reason?: undefined;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
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.createRuntimeBindingToolHandlers = createRuntimeBindingToolHandlers;
|
|
37
|
+
// @implements A-SPEC-752.10
|
|
38
|
+
/**
|
|
39
|
+
* `runtime_binding` — re-apply the binding the operator registry ALREADY names for this workspace, from inside the
|
|
40
|
+
* session, on the owner's explicit answer in the approval dialog.
|
|
41
|
+
*
|
|
42
|
+
* What the out-of-band rule protects is the choice of which build governs a workspace. This tool makes no such
|
|
43
|
+
* choice: it takes no package argument, and plans for the package and release package the registry holds. It
|
|
44
|
+
* refreshes the dispatcher files and the wiring and can restore a harness's hooks — the act a reviewed plan waited
|
|
45
|
+
* three session restarts for on 2026-10-05, because only a terminal could perform it.
|
|
46
|
+
*
|
|
47
|
+
* Only an explicit approve answer applies a plan. A denial, an unanswered dialog, a client without the form dialog,
|
|
48
|
+
* autonomous approval: none of them write anything; the same queue request the CLI files is filed and returned.
|
|
49
|
+
*/
|
|
50
|
+
const fs = __importStar(require("node:fs"));
|
|
51
|
+
const path = __importStar(require("node:path"));
|
|
52
|
+
const node_crypto_1 = require("node:crypto");
|
|
53
|
+
const binding_1 = require("../../runtime/binding");
|
|
54
|
+
const runtime_binding_1 = require("../../cli/runtime-binding");
|
|
55
|
+
const HARNESSES = ['claude', 'codex', 'antigravity'];
|
|
56
|
+
/** How many lines a change adds and removes — what a reviewer needs from a tool answer; the contents stay on disk. */
|
|
57
|
+
function lineCounts(change) {
|
|
58
|
+
const before = (change.before ?? '').split('\n');
|
|
59
|
+
const after = change.after.split('\n');
|
|
60
|
+
const was = new Set(before);
|
|
61
|
+
const now = new Set(after);
|
|
62
|
+
return { path: change.path, added: after.filter((line) => !was.has(line)).length, removed: before.filter((line) => !now.has(line)).length };
|
|
63
|
+
}
|
|
64
|
+
function createRuntimeBindingToolHandlers(context) {
|
|
65
|
+
return {
|
|
66
|
+
async runtime_binding(a) {
|
|
67
|
+
const foreign = context.foreignRootReason(a.root);
|
|
68
|
+
if (foreign)
|
|
69
|
+
return { ok: false, applied: false, reason: foreign };
|
|
70
|
+
const operation = a.operation ?? 'preview';
|
|
71
|
+
if (operation !== 'preview' && operation !== 'apply')
|
|
72
|
+
return { ok: false, applied: false, reason: 'runtime_binding: operation is preview or apply' };
|
|
73
|
+
const activate = a.activate_hooks ?? [];
|
|
74
|
+
if (!Array.isArray(activate) || activate.some((h) => !HARNESSES.includes(h))) {
|
|
75
|
+
return { ok: false, applied: false, reason: `runtime_binding: activate_hooks takes only ${HARNESSES.join(', ')}` };
|
|
76
|
+
}
|
|
77
|
+
const registryPath = context.registryPath();
|
|
78
|
+
const unregistered = { ok: false, applied: false,
|
|
79
|
+
reason: 'runtime_binding: this workspace is not registered in the operator runtime registry. Registering a workspace, or choosing which build governs it, is done by the operator with `holmes-kit runtime-binding setup` in a terminal; this tool only re-applies a registered binding.' };
|
|
80
|
+
let root;
|
|
81
|
+
let binding;
|
|
82
|
+
let releasePackageRoot;
|
|
83
|
+
try {
|
|
84
|
+
root = fs.realpathSync.native(context.projectRootOf(a.root));
|
|
85
|
+
if (!fs.existsSync(registryPath))
|
|
86
|
+
return unregistered;
|
|
87
|
+
const registry = (0, binding_1.readRuntimeRegistry)(registryPath);
|
|
88
|
+
binding = registry.bindings.find((b) => b.workspaceRoot === root);
|
|
89
|
+
releasePackageRoot = registry.releasePackageRoot;
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
return { ok: false, applied: false, reason: `runtime_binding: ${e.message}` };
|
|
93
|
+
}
|
|
94
|
+
if (binding === undefined)
|
|
95
|
+
return unregistered;
|
|
96
|
+
const options = { operation: 'setup', workspace: root, packageRoot: binding.packageRoot, releasePackageRoot, registryPath,
|
|
97
|
+
activateHooks: activate, ...(context.home !== undefined ? { home: context.home } : {}),
|
|
98
|
+
...(context.installerPackageRoot !== undefined ? { installerPackageRoot: context.installerPackageRoot } : {}) };
|
|
99
|
+
let plan;
|
|
100
|
+
try {
|
|
101
|
+
plan = (0, runtime_binding_1.runRuntimeBinding)({ ...options, dryRun: true });
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
return { ok: false, applied: false, reason: `runtime_binding: ${e.message}` };
|
|
105
|
+
}
|
|
106
|
+
const changes = plan.changes.map(lineCounts);
|
|
107
|
+
const answer = { planDigest: plan.planDigest, conflicts: plan.conflicts, changes };
|
|
108
|
+
if (operation === 'preview')
|
|
109
|
+
return { ok: true, applied: false, operation, ...answer };
|
|
110
|
+
if (plan.conflicts.length > 0)
|
|
111
|
+
return { ok: false, applied: false, reason: `runtime_binding: the plan has conflicts and was not applied — ${plan.conflicts.join('; ')}`, ...answer };
|
|
112
|
+
if (plan.changes.length === 0)
|
|
113
|
+
return { ok: true, applied: false, reason: 'runtime_binding: the wiring already matches the registered binding; nothing to apply', ...answer };
|
|
114
|
+
const names = [...new Set(plan.changes.map((c) => path.basename(c.path)))].join(', ');
|
|
115
|
+
const out = await context.tryElicit('governance-wiring', root, `plan ${plan.planDigest.slice(0, 19)}… — ${plan.changes.length} file(s): ${names}`);
|
|
116
|
+
const approved = out.kind === 'answered' && out.decision.granted;
|
|
117
|
+
try {
|
|
118
|
+
// Without an approve answer no approval is passed: the planner then applies only if the operator already
|
|
119
|
+
// granted this exact plan in a terminal, and otherwise files the request and refuses — the CLI's own path.
|
|
120
|
+
// The single-use nonce is what makes the planner write the authorization to the ledger (actor, plan digest):
|
|
121
|
+
// an answer given in a dialog must leave the same audit line a terminal grant does.
|
|
122
|
+
(0, runtime_binding_1.runRuntimeBinding)({ ...options, dryRun: false, expectedPlanDigest: plan.planDigest,
|
|
123
|
+
...(approved ? { approval: { ...context.elicitApproval(out.kind === 'answered' ? out.decision.reason : undefined), nonce: (0, node_crypto_1.randomUUID)() } } : {}) });
|
|
124
|
+
return { ok: true, applied: true, ...answer };
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
const message = e.message;
|
|
128
|
+
const request = /\brequest (req-[0-9a-f]+)/.exec(message)?.[1];
|
|
129
|
+
const dialog = out.kind === 'answered' ? (approved ? 'approved in the dialog, but ' : `declined in the dialog${out.decision.reason ? ` (${out.decision.reason})` : ''}; `)
|
|
130
|
+
: out.kind === 'expired' ? 'the approval dialog was not answered; ' : 'no approval dialog could be shown in this session; ';
|
|
131
|
+
return { ok: false, applied: false, reason: `runtime_binding: nothing was applied — ${dialog}${message}`, ...(request ? { request } : {}), ...answer };
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -53,6 +53,12 @@ export interface ElicitOpts {
|
|
|
53
53
|
continuations: ApprovalContinuationStore;
|
|
54
54
|
runId: string;
|
|
55
55
|
};
|
|
56
|
+
/** @implements A-SPEC-752.10 — test seam for `runtime_binding`: an isolated registry, home and installer package. */
|
|
57
|
+
runtimeBinding?: {
|
|
58
|
+
registryPath?: string;
|
|
59
|
+
home?: string;
|
|
60
|
+
installerPackageRoot?: string;
|
|
61
|
+
};
|
|
56
62
|
}
|
|
57
63
|
/**
|
|
58
64
|
* @implements A-SPEC-299
|
|
@@ -652,6 +658,38 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
652
658
|
reason: string;
|
|
653
659
|
}[];
|
|
654
660
|
}>;
|
|
661
|
+
runtime_binding(a: {
|
|
662
|
+
root: string;
|
|
663
|
+
operation?: string;
|
|
664
|
+
activate_hooks?: string[];
|
|
665
|
+
}): Promise<{
|
|
666
|
+
ok: boolean;
|
|
667
|
+
applied: boolean;
|
|
668
|
+
reason: string;
|
|
669
|
+
} | {
|
|
670
|
+
planDigest: string;
|
|
671
|
+
conflicts: string[];
|
|
672
|
+
changes: {
|
|
673
|
+
path: string;
|
|
674
|
+
added: number;
|
|
675
|
+
removed: number;
|
|
676
|
+
}[];
|
|
677
|
+
ok: boolean;
|
|
678
|
+
applied: boolean;
|
|
679
|
+
operation: string;
|
|
680
|
+
reason?: undefined;
|
|
681
|
+
} | {
|
|
682
|
+
planDigest: string;
|
|
683
|
+
conflicts: string[];
|
|
684
|
+
changes: {
|
|
685
|
+
path: string;
|
|
686
|
+
added: number;
|
|
687
|
+
removed: number;
|
|
688
|
+
}[];
|
|
689
|
+
ok: boolean;
|
|
690
|
+
applied: boolean;
|
|
691
|
+
reason?: undefined;
|
|
692
|
+
}>;
|
|
655
693
|
workspace_preflight(a: {
|
|
656
694
|
root: string;
|
|
657
695
|
harness?: import("../cli/agents").Agent;
|
|
@@ -69,6 +69,8 @@ const spec_authoring_1 = require("./handlers/spec-authoring");
|
|
|
69
69
|
const spec_lifecycle_1 = require("./handlers/spec-lifecycle");
|
|
70
70
|
const spec_approval_1 = require("./handlers/spec-approval");
|
|
71
71
|
const workspace_identity_2 = require("./handlers/workspace-identity");
|
|
72
|
+
const runtime_binding_tool_1 = require("./handlers/runtime-binding-tool");
|
|
73
|
+
const runtime_binding_1 = require("../cli/runtime-binding");
|
|
72
74
|
const workspace_preflight_1 = require("./handlers/workspace-preflight");
|
|
73
75
|
const operator_inspection_1 = require("./handlers/operator-inspection");
|
|
74
76
|
const phase_queries_1 = require("./handlers/phase-queries");
|
|
@@ -1030,6 +1032,17 @@ function makeRawHandlers(store, opts) {
|
|
|
1030
1032
|
// rtm_impact+4, rtm_reindex..review_record, review_prepare..risk_check, risk_check±, and the tail).
|
|
1031
1033
|
ledger_reconcile: operatorInspection.ledger_reconcile,
|
|
1032
1034
|
...(0, workspace_preflight_1.createWorkspacePreflightHandlers)({ storeRoot: store instanceof spec_store_1.LocalMarkdownRepository ? store.specsRoot : undefined }),
|
|
1035
|
+
// @implements A-SPEC-752.10 — same unpinned slot. Re-applies the registered binding on the owner's answer in the
|
|
1036
|
+
// dialog; never autonomous.
|
|
1037
|
+
...(0, runtime_binding_tool_1.createRuntimeBindingToolHandlers)({
|
|
1038
|
+
foreignRootReason: (root) => foreignRootReason(store, root),
|
|
1039
|
+
projectRootOf,
|
|
1040
|
+
tryElicit,
|
|
1041
|
+
elicitApproval,
|
|
1042
|
+
registryPath: () => opts?.runtimeBinding?.registryPath ?? (0, runtime_binding_1.defaultRuntimeRegistry)(),
|
|
1043
|
+
...(opts?.runtimeBinding?.home !== undefined ? { home: opts.runtimeBinding.home } : {}),
|
|
1044
|
+
...(opts?.runtimeBinding?.installerPackageRoot !== undefined ? { installerPackageRoot: opts.runtimeBinding.installerPackageRoot } : {}),
|
|
1045
|
+
}),
|
|
1033
1046
|
// @implements A-SPEC-700.2 — same unpinned slot: `spec_retire..spec_unseal` is a pinned run.
|
|
1034
1047
|
spec_reconcile: specLifecycle.spec_reconcile,
|
|
1035
1048
|
rtm_impact: graphOperations.rtm_impact,
|
|
@@ -76,6 +76,19 @@ exports.TOOL_SCHEMAS = {
|
|
|
76
76
|
description: 'Read-only diagnosis of this live MCP server workspace binding. Mismatched roots are not scanned. Identity and checkout are inspected only for a matching root. Does not rebind, initialize, register or prove client hook enforcement.',
|
|
77
77
|
inputSchema: { type: 'object', properties: { root: ROOT_ANY, harness: { type: 'string', enum: [...agents_1.AGENTS] } }, required: ['root'] },
|
|
78
78
|
},
|
|
79
|
+
// @implements A-SPEC-752.10
|
|
80
|
+
runtime_binding: {
|
|
81
|
+
description: 'Re-apply the runtime binding the operator registry ALREADY names for this workspace: refresh the dispatcher files and harness wiring, optionally restoring a harness\'s hooks. `preview` (default) writes nothing and returns the plan digest, conflicts and per-file line counts. `apply` opens the in-session approval dialog and writes the plan only on an explicit approve answer there; any other outcome writes nothing and returns the pending request. It cannot register a workspace or choose which build governs it — that is `holmes-kit runtime-binding setup`, run by the operator in a terminal. Native hook trust in each harness stays the operator\'s.',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
root: ROOT_ANY,
|
|
86
|
+
operation: { type: 'string', enum: ['preview', 'apply'], description: 'Defaults to preview.' },
|
|
87
|
+
activate_hooks: { type: 'array', items: { type: 'string', enum: ['claude', 'codex', 'antigravity'] }, description: 'Harnesses whose Holmes hooks to restore in this workspace.' },
|
|
88
|
+
},
|
|
89
|
+
required: ['root'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
79
92
|
workspace_identity: {
|
|
80
93
|
description: 'Inspect canonical workspace and local replica identity without writes by default. Explicit initialize creates a Git-shareable .ax/workspace.json and registers this checkout; register requires an existing canonical identity. Preserve legacy specs and ledgers; these identifiers grant no approval authority. Share the manifest through Git and keep .ax/state local. Registered MCP writes include holmes-execution/1 provenance and require a reader supporting that schema; matching package versions alone do not establish this capability.',
|
|
81
94
|
inputSchema: {
|
|
@@ -41,7 +41,7 @@ exports.countTestCases = countTestCases;
|
|
|
41
41
|
exports.extractAnchors = extractAnchors;
|
|
42
42
|
exports.scanTestAnchors = scanTestAnchors;
|
|
43
43
|
exports.computeTestScope = computeTestScope;
|
|
44
|
-
// @implements A-SPEC-121.2, A-SPEC-734, A-SPEC-750
|
|
44
|
+
// @implements A-SPEC-121.2, A-SPEC-734, A-SPEC-750, A-SPEC-750.1
|
|
45
45
|
const anchor_ids_1 = require("./anchor-ids");
|
|
46
46
|
const fs = __importStar(require("node:fs"));
|
|
47
47
|
const path = __importStar(require("node:path"));
|
|
@@ -356,6 +356,33 @@ function skipGroup(code, j) {
|
|
|
356
356
|
}
|
|
357
357
|
return code.length;
|
|
358
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* @implements A-SPEC-750.1
|
|
361
|
+
* Index just past the type argument list opened by the `<` at `j`, or -1 when it does not close. Round, square and
|
|
362
|
+
* curly groups inside it are skipped whole, and the `>` of an arrow does not close it. A `;` outside every group ends
|
|
363
|
+
* the search: no type argument holds one.
|
|
364
|
+
*/
|
|
365
|
+
function skipTypeArguments(code, j) {
|
|
366
|
+
let depth = 0;
|
|
367
|
+
for (; j < code.length; j++) {
|
|
368
|
+
const ch = code[j];
|
|
369
|
+
if (ch === '(' || ch === '[' || ch === '{' || ch === '`') {
|
|
370
|
+
j = skipGroup(code, j) - 1;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (ch === '<')
|
|
374
|
+
depth++;
|
|
375
|
+
else if (ch === '=' && code[j + 1] === '>')
|
|
376
|
+
j++;
|
|
377
|
+
else if (ch === '>') {
|
|
378
|
+
if (--depth === 0)
|
|
379
|
+
return j + 1;
|
|
380
|
+
}
|
|
381
|
+
else if (ch === ';' || ch === ')' || ch === ']' || ch === '}')
|
|
382
|
+
return -1;
|
|
383
|
+
}
|
|
384
|
+
return -1;
|
|
385
|
+
}
|
|
359
386
|
const JEST_HEADS = ['it', 'test', 'fit'];
|
|
360
387
|
// @implements A-SPEC-653 — the platform helpers of A-SPEC-220.3 (`posixOnly('why')(…)`) are heads too: a POSIX-only suite
|
|
361
388
|
// written with the REPORTING skip must not read as "no real cases". `.skip` on a helper is still not a head.
|
|
@@ -391,6 +418,10 @@ function jestCount(code) {
|
|
|
391
418
|
}
|
|
392
419
|
const names = [...direct, ...[...JEST_HELPERS].filter((h) => !direct.has(h))].map((s) => s.replace(/\$/g, '\\$'));
|
|
393
420
|
let cases = 0;
|
|
421
|
+
// @implements A-SPEC-750.1 — a type argument list that does not close is searched to the end of the text. The searches
|
|
422
|
+
// of one file share an allowance of two passes over it; a file that spends it (it is not TypeScript that compiles)
|
|
423
|
+
// has its later typed tables left uncounted, which is the direction a lower bound may err in.
|
|
424
|
+
let typeArgumentWork = 2 * code.length + 1024;
|
|
394
425
|
for (const m of code.matchAll(new RegExp(`(?<![\\w$.])(?:${names.join('|')})(?![\\w$])`, 'g'))) {
|
|
395
426
|
let j = m.index + m[0].length;
|
|
396
427
|
if (!direct.has(m[0])) {
|
|
@@ -410,6 +441,15 @@ function jestCount(code) {
|
|
|
410
441
|
if (!code.startsWith('each', k) || /[\w$]/.test(code[k + 4] ?? ''))
|
|
411
442
|
continue;
|
|
412
443
|
k = skipSpace(code, k + 4);
|
|
444
|
+
if (code[k] === '<') {
|
|
445
|
+
if (typeArgumentWork <= 0)
|
|
446
|
+
continue;
|
|
447
|
+
const end = skipTypeArguments(code, k);
|
|
448
|
+
typeArgumentWork -= (end < 0 ? code.length : end) - k;
|
|
449
|
+
if (end < 0)
|
|
450
|
+
continue;
|
|
451
|
+
k = skipSpace(code, end);
|
|
452
|
+
}
|
|
413
453
|
if (code[k] !== '(' && code[k] !== '`')
|
|
414
454
|
continue;
|
|
415
455
|
k = skipSpace(code, skipGroup(code, k));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "@implements A-SPEC-209",
|
|
3
3
|
"name": "@holmes-lab/holmes-kit",
|
|
4
|
-
"version": "0.35.
|
|
4
|
+
"version": "0.35.7",
|
|
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",
|