@holmes-lab/holmes-kit 0.40.1 → 0.41.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.
- package/CHANGELOG.md +86 -0
- package/README.md +12 -4
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-context.js +4 -3
- package/dist/holmes/cli/approve.js +22 -12
- package/dist/holmes/cli/autonomy.d.ts +21 -0
- package/dist/holmes/cli/autonomy.js +35 -5
- package/dist/holmes/cli/doctor.js +58 -6
- package/dist/holmes/cli/index.js +371 -250
- package/dist/holmes/cli/init.js +26 -6
- package/dist/holmes/cli/ledger-witness.d.ts +61 -0
- package/dist/holmes/cli/ledger-witness.js +252 -0
- package/dist/holmes/cli/playbook-skills.d.ts +3 -56
- package/dist/holmes/cli/playbook-skills.js +63 -354
- package/dist/holmes/cli/test-platform.d.ts +6 -0
- package/dist/holmes/cli/test-platform.js +12 -0
- package/dist/holmes/config/config.d.ts +9 -1
- package/dist/holmes/config/config.js +10 -3
- package/dist/holmes/governance/approval-grants.d.ts +2 -0
- package/dist/holmes/governance/approval-grants.js +6 -5
- package/dist/holmes/governance/approval-queue.d.ts +65 -1
- package/dist/holmes/governance/approval-queue.js +279 -9
- package/dist/holmes/governance/autonomous-shell.d.ts +13 -1
- package/dist/holmes/governance/autonomous-shell.js +157 -4
- package/dist/holmes/governance/autonomy.d.ts +209 -0
- package/dist/holmes/governance/autonomy.js +1129 -6
- package/dist/holmes/governance/install-manifest.d.ts +7 -4
- package/dist/holmes/governance/install-manifest.js +159 -15
- package/dist/holmes/governance/ledger-witness.d.ts +63 -0
- package/dist/holmes/governance/ledger-witness.js +296 -0
- package/dist/holmes/governance/provenance-chain.d.ts +8 -1
- package/dist/holmes/governance/provenance-chain.js +23 -4
- package/dist/holmes/governance/recorded-pairs.d.ts +4 -0
- package/dist/holmes/governance/recorded-pairs.js +25 -1
- package/dist/holmes/governance/session-context.d.ts +7 -0
- package/dist/holmes/governance/session-context.js +34 -6
- package/dist/holmes/guardrail/anchor-scope-text.d.ts +9 -0
- package/dist/holmes/guardrail/anchor-scope-text.js +7 -0
- package/dist/holmes/guardrail/command-traits.d.ts +102 -0
- package/dist/holmes/guardrail/command-traits.js +379 -0
- package/dist/holmes/guardrail/fixtures/manager-builtins.json +23 -0
- package/dist/holmes/guardrail/fixtures/npm-commands.json +7 -0
- package/dist/holmes/guardrail/outward-acts.d.ts +47 -0
- package/dist/holmes/guardrail/outward-acts.js +1102 -0
- package/dist/holmes/guardrail/refusal-codes.js +8 -1
- package/dist/holmes/guardrail/refusal-templates.d.ts +15 -0
- package/dist/holmes/guardrail/refusal-templates.js +71 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +22 -6
- package/dist/holmes/guardrail/risk-classifier.js +12 -118
- package/dist/holmes/guardrail/shell-lexer.d.ts +69 -0
- package/dist/holmes/guardrail/shell-lexer.js +567 -0
- package/dist/holmes/guardrail/write-target.js +7 -1
- package/dist/holmes/hooks/pre-tool-use.d.ts +60 -0
- package/dist/holmes/hooks/pre-tool-use.js +1423 -10
- package/dist/holmes/hooks/session-start.js +11 -1
- package/dist/holmes/hooks/stop.d.ts +7 -0
- package/dist/holmes/hooks/stop.js +39 -2
- package/dist/holmes/mcp/elicit-approval.d.ts +0 -21
- package/dist/holmes/mcp/elicit-approval.js +5 -2
- package/dist/holmes/mcp/handlers/approval-ask.js +3 -2
- package/dist/holmes/mcp/handlers/entity-integration.d.ts +1 -1
- package/dist/holmes/mcp/handlers/entity-integration.js +9 -6
- package/dist/holmes/mcp/handlers/entity-renumber.js +2 -1
- package/dist/holmes/mcp/handlers/entity-store.js +7 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -0
- package/dist/holmes/mcp/handlers/operator-inspection.js +25 -4
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -1
- package/dist/holmes/mcp/handlers/spec-approval.js +28 -10
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +10 -7
- package/dist/holmes/mcp/handlers/test-execution.d.ts +6 -0
- package/dist/holmes/mcp/handlers/test-execution.js +37 -9
- package/dist/holmes/mcp/handlers.d.ts +5 -5
- package/dist/holmes/mcp/handlers.js +2 -1
- package/dist/holmes/mcp/tool-schemas.js +4 -4
- package/dist/holmes/project/playbook-reference.d.ts +50 -0
- package/dist/holmes/project/playbook-reference.js +259 -0
- package/dist/holmes/project/playbook-skill-states.d.ts +94 -0
- package/dist/holmes/project/playbook-skill-states.js +396 -0
- package/dist/holmes/project/root.d.ts +9 -1
- package/dist/holmes/project/root.js +23 -2
- package/dist/holmes/project/running-package.d.ts +15 -0
- package/dist/holmes/project/running-package.js +87 -0
- package/dist/holmes/review/head-worktree.js +9 -1
- package/dist/holmes/review/test-runner.d.ts +2 -0
- package/dist/holmes/review/test-runner.js +38 -11
- package/dist/holmes/spec/entity-integration-transaction.d.ts +19 -2
- package/dist/holmes/spec/entity-integration-transaction.js +68 -7
- package/package.json +5 -2
|
@@ -59,7 +59,7 @@ exports.redJestTail = redJestTail;
|
|
|
59
59
|
exports.summarizeJestJson = summarizeJestJson;
|
|
60
60
|
// @implements A-SPEC-102.1, A-SPEC-128.4, A-SPEC-128.5, A-SPEC-128.6, A-SPEC-128.7, A-SPEC-128.8, A-SPEC-128.9, A-SPEC-128.10, A-SPEC-128.11, A-SPEC-128.12, A-SPEC-128.13
|
|
61
61
|
// @implements A-SPEC-647
|
|
62
|
-
// @implements A-SPEC-734, A-SPEC-466.1, A-SPEC-466.2, A-SPEC-466.3, A-SPEC-466.4, A-SPEC-466.5, A-SPEC-466.6
|
|
62
|
+
// @implements A-SPEC-734, A-SPEC-466.1, A-SPEC-466.2, A-SPEC-466.3, A-SPEC-466.4, A-SPEC-466.5, A-SPEC-466.6, A-SPEC-794.119
|
|
63
63
|
const node_child_process_1 = require("node:child_process");
|
|
64
64
|
const bounded_group_1 = require("../project/bounded-group");
|
|
65
65
|
const fs = __importStar(require("node:fs"));
|
|
@@ -97,6 +97,15 @@ let STOPPED = null;
|
|
|
97
97
|
*/
|
|
98
98
|
/** @implements A-SPEC-466.6 — the bound of the run in progress; `runTestScope` sets it from timeoutMinutes. */
|
|
99
99
|
let RUN_BUDGET_MS = exports.RUNNER_TIMEOUT_MS;
|
|
100
|
+
/**
|
|
101
|
+
* @implements A-SPEC-794.119 — the tree the run in progress executes in, held for the run as its budget is (`runTestScope`
|
|
102
|
+
* sets it from `projectRoot`). Every test child takes `testEnv()`: CLAUDE_PROJECT_DIR, where the server carries it, names
|
|
103
|
+
* this tree. Undefined: the environment is cleaned as before.
|
|
104
|
+
*/
|
|
105
|
+
let RUN_PROJECT_ROOT;
|
|
106
|
+
function testEnv() {
|
|
107
|
+
return (0, root_1.cleanTestEnv)(process.env, RUN_PROJECT_ROOT === undefined ? {} : { projectDir: RUN_PROJECT_ROOT });
|
|
108
|
+
}
|
|
100
109
|
function runBounded(cmd, args, opts, timeoutMs = RUN_BUDGET_MS) {
|
|
101
110
|
// @implements A-SPEC-734.4 — the group's whole lifetime lives in bounded-group: a watch shim ends it when this process
|
|
102
111
|
// goes, and the call ends it on the bound, an overflow or a signal, or when members outlive a normal exit
|
|
@@ -243,7 +252,7 @@ const unreadable = (what, out, workers) => ({ passed: false, tail: `runner outpu
|
|
|
243
252
|
function jestConfigReason(cmd, pre, cwd) {
|
|
244
253
|
let out;
|
|
245
254
|
try {
|
|
246
|
-
out = runBounded(cmd, [...pre, '--showConfig'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (
|
|
255
|
+
out = runBounded(cmd, [...pre, '--showConfig'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: testEnv() });
|
|
247
256
|
}
|
|
248
257
|
catch (e) {
|
|
249
258
|
const err = e;
|
|
@@ -303,7 +312,7 @@ function runJestWith(files, mode, cwd, opts, reportFile) {
|
|
|
303
312
|
}
|
|
304
313
|
function jestRun(cmd, args, cwd, mode, reportFile, applied) {
|
|
305
314
|
try {
|
|
306
|
-
const raw = runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (
|
|
315
|
+
const raw = runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: testEnv() });
|
|
307
316
|
const out = mode === 'full' ? (0, test_reports_1.readJestReport)(reportFile, raw) : raw;
|
|
308
317
|
if (out === null)
|
|
309
318
|
return unreadable('jest --json', raw, applied);
|
|
@@ -345,7 +354,17 @@ function runJestOutcomes(files, cwd, timeoutMinutes) {
|
|
|
345
354
|
if (files.length === 0)
|
|
346
355
|
return {};
|
|
347
356
|
// @implements A-SPEC-466.6 — a mutation's jest child is a runner child of the run too
|
|
348
|
-
|
|
357
|
+
// @implements A-SPEC-794.123 — and is told the tree it runs in, held for this run only and put back after, as runTestScope does
|
|
358
|
+
return withRunBudget(timeoutMinutes, () => {
|
|
359
|
+
const prevRoot = RUN_PROJECT_ROOT;
|
|
360
|
+
RUN_PROJECT_ROOT = cwd;
|
|
361
|
+
try {
|
|
362
|
+
return runJest(files, 'scoped', cwd).outcomes;
|
|
363
|
+
}
|
|
364
|
+
finally {
|
|
365
|
+
RUN_PROJECT_ROOT = prevRoot;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
349
368
|
}
|
|
350
369
|
/** Run the pytest half of a plan, taking execution evidence from pytest's built-in JUnit XML. */
|
|
351
370
|
// @implements A-SPEC-502.1 — exported for the wiring test (a fake venv python capturing argv).
|
|
@@ -386,7 +405,7 @@ function runPytest(files, mode, cwd, ignore = [], pythonFrom, run) {
|
|
|
386
405
|
const python = (0, python_env_1.pythonFor)(pythonFrom && fs.existsSync(pythonFrom) ? pythonFrom : cwd, { env: process.env, exists: fs.existsSync, platform: process.platform });
|
|
387
406
|
// @implements A-SPEC-128.14, A-SPEC-128.15, A-SPEC-128.16 — in HEAD's worktree: the pinned configuration and its confcutdir,
|
|
388
407
|
// the environment asked where HEAD's names resolve (refused before any test), and the loaded-module record
|
|
389
|
-
const prov = run ? (0, run_provenance_1.pytestRunProvenance)(dir, run, rootdir, python, (
|
|
408
|
+
const prov = run ? (0, run_provenance_1.pytestRunProvenance)(dir, run, rootdir, python, testEnv(), (c, a, o) => runBounded(c, a, { ...o, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER })) : null;
|
|
390
409
|
if (prov?.refused) {
|
|
391
410
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
392
411
|
return { passed: false, tail: prov.refused, executed: {}, outcomes: {}, testsRun: 0, environment: true };
|
|
@@ -437,7 +456,7 @@ function runPytest(files, mode, cwd, ignore = [], pythonFrom, run) {
|
|
|
437
456
|
// @implements A-SPEC-651.1 — launch from the canonical spelling: pytest keys its JUnit `file`
|
|
438
457
|
// attribute relative to its rootdir, and an 8.3 invocation dir made that key climb out of the
|
|
439
458
|
// project (`../../…/tests/test_calc.py`, measured 2026-09-14 on Windows).
|
|
440
|
-
const out = runBounded(python, args, { cwd: fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: prov ? prov.env((
|
|
459
|
+
const out = runBounded(python, args, { cwd: fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: prov ? prov.env(testEnv()) : testEnv() });
|
|
441
460
|
const executed = read();
|
|
442
461
|
// @implements A-SPEC-128.13 — T1: exit 0 is not green when the JUnit report holds a failure or an error
|
|
443
462
|
const outcomes = readOutcomes(true);
|
|
@@ -497,7 +516,7 @@ function runCargo(files, _mode, cwd, opts) {
|
|
|
497
516
|
let out = '';
|
|
498
517
|
let ok = true;
|
|
499
518
|
try {
|
|
500
|
-
out = runBounded('cargo', ['test'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (
|
|
519
|
+
out = runBounded('cargo', ['test'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: testEnv() });
|
|
501
520
|
}
|
|
502
521
|
catch (e) {
|
|
503
522
|
const err = e;
|
|
@@ -591,7 +610,7 @@ function runGradle(files, _mode, cwd, opts) {
|
|
|
591
610
|
}
|
|
592
611
|
let ok = true;
|
|
593
612
|
try {
|
|
594
|
-
runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (
|
|
613
|
+
runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: testEnv() });
|
|
595
614
|
}
|
|
596
615
|
catch (e) {
|
|
597
616
|
// @implements A-SPEC-128.10 — R4: the build tool itself missing is the environment, not the tests
|
|
@@ -626,7 +645,7 @@ function runDotnet(files, _mode, cwd, opts) {
|
|
|
626
645
|
const report = path.join(dir, 'junit.xml');
|
|
627
646
|
let ok = true;
|
|
628
647
|
try {
|
|
629
|
-
runBounded('dotnet', ['test', '--logger', `junit;LogFilePath=${report}`], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (
|
|
648
|
+
runBounded('dotnet', ['test', '--logger', `junit;LogFilePath=${report}`], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: testEnv() });
|
|
630
649
|
}
|
|
631
650
|
catch {
|
|
632
651
|
ok = false;
|
|
@@ -651,7 +670,7 @@ function runDotnet(files, _mode, cwd, opts) {
|
|
|
651
670
|
* `unsupported`, never a pass. `opts.goPresent` overrides the probe for testing.
|
|
652
671
|
*/
|
|
653
672
|
function runGo(files, mode, cwd, opts) {
|
|
654
|
-
const goEnv = { ...(
|
|
673
|
+
const goEnv = { ...testEnv(), ...(opts?.env ?? {}) };
|
|
655
674
|
const present = opts?.goPresent ?? (() => {
|
|
656
675
|
try {
|
|
657
676
|
(0, node_child_process_1.execFileSync)('go', ['version'], { cwd, stdio: 'ignore', timeout: PROBE_TIMEOUT_MS });
|
|
@@ -768,7 +787,15 @@ function runGo(files, mode, cwd, opts) {
|
|
|
768
787
|
* gate that ran part of its scope has verified less than it reports.
|
|
769
788
|
*/
|
|
770
789
|
function runTestScope(scope, cwd, opts = {}) {
|
|
771
|
-
|
|
790
|
+
// @implements A-SPEC-794.119 — held for this run only, put back after (a nested or later run is not given this tree)
|
|
791
|
+
const prevRoot = RUN_PROJECT_ROOT;
|
|
792
|
+
RUN_PROJECT_ROOT = opts.projectRoot;
|
|
793
|
+
try {
|
|
794
|
+
return withRunBudget(opts.timeoutMinutes, () => runScopeWithinBudget(scope, cwd, opts));
|
|
795
|
+
}
|
|
796
|
+
finally {
|
|
797
|
+
RUN_PROJECT_ROOT = prevRoot;
|
|
798
|
+
}
|
|
772
799
|
}
|
|
773
800
|
/** @implements A-SPEC-466.6 — each runner child started inside `fn` takes the budget; the default comes back after. */
|
|
774
801
|
function withRunBudget(timeoutMinutes, fn) {
|
|
@@ -2,6 +2,22 @@ import { EntityByteChange, entityLockOwner } from './entity-transaction';
|
|
|
2
2
|
import { EntityGitDocuments, EntityGitMergedSources } from './entity-integration';
|
|
3
3
|
import { entitySourcePublicationOwner } from './entity-renumber-transaction';
|
|
4
4
|
import { EntityRenumberEntry } from './entity-renumber';
|
|
5
|
+
import type { SpecTransition } from '../governance/approval-queue';
|
|
6
|
+
type TransitionStep = {
|
|
7
|
+
phase: string;
|
|
8
|
+
specId?: string;
|
|
9
|
+
change?: {
|
|
10
|
+
locator?: string;
|
|
11
|
+
after?: string | null;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @implements A-SPEC-794.92 (M-1) — an un-seal step whose document is later published as `outdated` is a retirement,
|
|
16
|
+
* not an un-seal: it needs spec-retire authority and records spec-retired, as spec_retire does outside an integration.
|
|
17
|
+
*/
|
|
18
|
+
export declare function retiredSpecIds(plan: {
|
|
19
|
+
steps: ReadonlyArray<TransitionStep>;
|
|
20
|
+
}): Set<string>;
|
|
5
21
|
export interface EntityIntegrationTransitions {
|
|
6
22
|
unseal: Array<{
|
|
7
23
|
entityId: string;
|
|
@@ -108,7 +124,7 @@ export interface EntityIntegrationPlan {
|
|
|
108
124
|
export declare function validateEntityIntegrationPlan(value: unknown): EntityIntegrationPlan;
|
|
109
125
|
export declare function entityIntegrationTarget(plan: EntityIntegrationPlan): string;
|
|
110
126
|
/** Internal execution core; the public adapter supplies current authority and durable audit. */
|
|
111
|
-
export declare function applyEntityIntegration(root: string, inspected: unknown, authorize: (specId?: string) => void, audit: (plan: EntityIntegrationPlan, verifyOnly?: boolean, renumbered?: NonNullable<EntityIntegrationCandidate['renumbered']>) => void, beforePublish?: (plan: EntityIntegrationPlan, index: number) => void): Promise<{
|
|
127
|
+
export declare function applyEntityIntegration(root: string, inspected: unknown, authorize: (specId?: string, transition?: SpecTransition) => void, audit: (plan: EntityIntegrationPlan, verifyOnly?: boolean, renumbered?: NonNullable<EntityIntegrationCandidate['renumbered']>) => void, beforePublish?: (plan: EntityIntegrationPlan, index: number) => void): Promise<{
|
|
112
128
|
ok: true;
|
|
113
129
|
state: 'completed';
|
|
114
130
|
operationId: string;
|
|
@@ -130,7 +146,7 @@ export declare function abandonEntityIntegration(root: string, inspected: unknow
|
|
|
130
146
|
untouched: string[];
|
|
131
147
|
preserved: string[];
|
|
132
148
|
}>;
|
|
133
|
-
export declare function recoverEntityIntegration(root: string, inspected: EntityIntegrationRecoveryInspection, authorize: (specId?: string) => void, audit: (plan: EntityIntegrationPlan, verifyOnly?: boolean) => void, beforePublish?: (plan: EntityIntegrationPlan, index: number) => void): Promise<{
|
|
149
|
+
export declare function recoverEntityIntegration(root: string, inspected: EntityIntegrationRecoveryInspection, authorize: (specId?: string, transition?: SpecTransition) => void, audit: (plan: EntityIntegrationPlan, verifyOnly?: boolean) => void, beforePublish?: (plan: EntityIntegrationPlan, index: number) => void): Promise<{
|
|
134
150
|
ok: true;
|
|
135
151
|
state: 'completed';
|
|
136
152
|
operationId: string;
|
|
@@ -177,3 +193,4 @@ export declare function planEntityIntegrationCandidate(root: string, revisions:
|
|
|
177
193
|
left: string;
|
|
178
194
|
right: string;
|
|
179
195
|
}, storeLocator: string): Promise<EntityIntegrationCandidate>;
|
|
196
|
+
export {};
|
|
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.retiredSpecIds = retiredSpecIds;
|
|
36
37
|
exports.prepareEntityIntegrationTransitions = prepareEntityIntegrationTransitions;
|
|
37
38
|
exports.validateEntityIntegrationPlan = validateEntityIntegrationPlan;
|
|
38
39
|
exports.entityIntegrationTarget = entityIntegrationTarget;
|
|
@@ -47,7 +48,7 @@ exports.prepareEntityIntegrationPlan = prepareEntityIntegrationPlan;
|
|
|
47
48
|
exports.reviewEntityIntegration = reviewEntityIntegration;
|
|
48
49
|
exports.compileEntityIntegrationSteps = compileEntityIntegrationSteps;
|
|
49
50
|
exports.planEntityIntegrationCandidate = planEntityIntegrationCandidate;
|
|
50
|
-
// @implements A-SPEC-629
|
|
51
|
+
// @implements A-SPEC-629, A-SPEC-794.90, A-SPEC-794.92, A-SPEC-794.95
|
|
51
52
|
// @implements A-SPEC-645
|
|
52
53
|
// @implements A-SPEC-641
|
|
53
54
|
// @implements A-SPEC-640
|
|
@@ -72,6 +73,64 @@ const spec_digest_1 = require("./spec-digest");
|
|
|
72
73
|
const transition_policy_1 = require("./transition-policy");
|
|
73
74
|
const node_crypto_1 = require("node:crypto");
|
|
74
75
|
const workspace_identity_1 = require("../project/workspace-identity");
|
|
76
|
+
/**
|
|
77
|
+
* @implements A-SPEC-794.92 (M-1) — an un-seal step whose document is later published as `outdated` is a retirement,
|
|
78
|
+
* not an un-seal: it needs spec-retire authority and records spec-retired, as spec_retire does outside an integration.
|
|
79
|
+
*/
|
|
80
|
+
function retiredSpecIds(plan) {
|
|
81
|
+
const out = new Set();
|
|
82
|
+
// A-SPEC-794.95 (A-M3) — judged by the spec, not the locator: a later document step is the spec's when it names the
|
|
83
|
+
// spec, sits at the un-sealed locator, or parses to the spec's id. Published as outdated → retired; the un-sealed
|
|
84
|
+
// document deleted and no document of the spec published again → retired (a deletion withdraws the seal as well)
|
|
85
|
+
const parsed = (after) => {
|
|
86
|
+
try {
|
|
87
|
+
const s = (0, spec_parser_1.parseSpec)(Buffer.from(after, 'base64').toString('utf8'));
|
|
88
|
+
return { id: s.id, status: s.status };
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
plan.steps.forEach((step, i) => {
|
|
95
|
+
if (step.phase !== 'unseal' || !step.specId || !step.change?.locator)
|
|
96
|
+
return;
|
|
97
|
+
const id = step.specId, locator = step.change.locator;
|
|
98
|
+
let deleted = false, published = null;
|
|
99
|
+
for (const s of plan.steps.slice(i + 1)) {
|
|
100
|
+
if (s.phase !== 'document' || !s.change)
|
|
101
|
+
continue;
|
|
102
|
+
const after = s.change.after;
|
|
103
|
+
if (typeof after !== 'string') {
|
|
104
|
+
if (s.change.locator === locator || s.specId === id)
|
|
105
|
+
deleted = true;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const p = parsed(after);
|
|
109
|
+
if (s.specId === id || s.change.locator === locator || p?.id === id)
|
|
110
|
+
published = p?.status ?? 'unreadable';
|
|
111
|
+
}
|
|
112
|
+
if (published === 'outdated' || (published === null && deleted))
|
|
113
|
+
out.add(id);
|
|
114
|
+
});
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
/** @implements A-SPEC-794.90 — each spec step's (id, transition): an un-seal step un-seals, an approval step seals. */
|
|
118
|
+
function stepTransitions(plan) {
|
|
119
|
+
const seen = new Set();
|
|
120
|
+
const out = [];
|
|
121
|
+
const retired = retiredSpecIds(plan);
|
|
122
|
+
for (const step of plan.steps) {
|
|
123
|
+
if (!step.specId)
|
|
124
|
+
continue;
|
|
125
|
+
const t = step.phase === 'unseal' ? (retired.has(step.specId) ? 'retire' : 'unseal') : 'seal';
|
|
126
|
+
const key = `${step.specId}\u0000${t}`;
|
|
127
|
+
if (!seen.has(key)) {
|
|
128
|
+
seen.add(key);
|
|
129
|
+
out.push([step.specId, t]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return out.sort((a, b) => (a[0] + a[1]).localeCompare(b[0] + b[1]));
|
|
133
|
+
}
|
|
75
134
|
/** Produces document transitions only; authority and durable application belong to the executor. */
|
|
76
135
|
function prepareEntityIntegrationTransitions(current, desired, readFile) {
|
|
77
136
|
const graph = (entries) => {
|
|
@@ -256,9 +315,10 @@ async function applyEntityIntegration(root, inspected, authorize, audit, beforeP
|
|
|
256
315
|
if (integrationRead(root, '.ax/state/entity-completed/' + plan.operationId + '/journal.json'))
|
|
257
316
|
throw new entity_transaction_1.EntityStoreError('recovery-required', 'This operation already has a completion receipt; verify it through recovery.');
|
|
258
317
|
const program = JSON.stringify(plan), journal = JSON.stringify({ schema: 'holmes-entity-integration-journal/1', plan, storeOwner, sourceOwner });
|
|
259
|
-
const progress = integrationProgress(root, plan)
|
|
260
|
-
|
|
261
|
-
|
|
318
|
+
const progress = integrationProgress(root, plan);
|
|
319
|
+
// A-SPEC-794.90 — each step's own kind before publication: an un-seal step asks spec-unseal here, not only in the audit
|
|
320
|
+
const authority = () => { authorize(); for (const [id, transition] of stepTransitions(plan))
|
|
321
|
+
authorize(id, transition); };
|
|
262
322
|
let persisted = false;
|
|
263
323
|
const verify = () => {
|
|
264
324
|
if (JSON.stringify(plan) !== program)
|
|
@@ -359,9 +419,10 @@ async function recoverEntityIntegration(root, inspected, authorize, audit, befor
|
|
|
359
419
|
const plan = observed.plan, program = JSON.stringify(plan), directory = '.ax/state/entity-transactions/' + plan.operationId, journalFile = directory + '/journal.json';
|
|
360
420
|
const journalBytes = integrationRead(root, journalFile);
|
|
361
421
|
const journal = JSON.parse(journalBytes.toString('utf8'));
|
|
362
|
-
|
|
363
|
-
const
|
|
364
|
-
|
|
422
|
+
// A-SPEC-794.90 — each step's own kind, as in apply
|
|
423
|
+
const steps = observed.completionVersion ? [] : stepTransitions(plan);
|
|
424
|
+
const authority = () => { authorize(); for (const [id, transition] of steps)
|
|
425
|
+
authorize(id, transition); };
|
|
365
426
|
const identity = () => {
|
|
366
427
|
const current = (0, workspace_identity_1.workspaceIdentity)(root);
|
|
367
428
|
if (current.state !== 'registered' || current.workspaceId !== plan.workspaceId)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "@implements A-SPEC-209, A-SPEC-794.58",
|
|
3
3
|
"name": "@holmes-lab/holmes-kit",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.41.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",
|
|
@@ -61,8 +61,11 @@
|
|
|
61
61
|
"**/src/**/*.test.ts"
|
|
62
62
|
],
|
|
63
63
|
"testTimeout": 30000,
|
|
64
|
+
"globalSetup": "<rootDir>/src/holmes/test-support/repo-artifacts-global.ts",
|
|
65
|
+
"globalTeardown": "<rootDir>/src/holmes/test-support/repo-artifacts-global.ts",
|
|
64
66
|
"setupFilesAfterEnv": [
|
|
65
|
-
"<rootDir>/src/holmes/test-support/jest-timeouts-setup.ts"
|
|
67
|
+
"<rootDir>/src/holmes/test-support/jest-timeouts-setup.ts",
|
|
68
|
+
"<rootDir>/src/holmes/test-support/own-repo-judge-setup.ts"
|
|
66
69
|
],
|
|
67
70
|
"maxWorkers": "50%",
|
|
68
71
|
"roots": [
|