@holmes-lab/holmes-kit 0.35.25 → 0.36.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 +298 -0
- package/README.md +3 -2
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-status.js +4 -1
- package/dist/holmes/cli/approve-watch.js +3 -1
- package/dist/holmes/cli/approve.d.ts +10 -0
- package/dist/holmes/cli/approve.js +31 -1
- package/dist/holmes/cli/claude-switches.d.ts +7 -1
- package/dist/holmes/cli/claude-switches.js +11 -7
- package/dist/holmes/cli/codex-toml.d.ts +3 -0
- package/dist/holmes/cli/codex-toml.js +2 -1
- package/dist/holmes/cli/doctor.d.ts +25 -1
- package/dist/holmes/cli/doctor.js +153 -7
- package/dist/holmes/cli/index.js +99 -4
- package/dist/holmes/cli/init.js +4 -3
- package/dist/holmes/cli/os-notify.d.ts +3 -1
- package/dist/holmes/cli/os-notify.js +10 -4
- package/dist/holmes/cli/review.d.ts +25 -0
- package/dist/holmes/cli/review.js +111 -0
- package/dist/holmes/cli/roles-readme.d.ts +11 -0
- package/dist/holmes/cli/roles-readme.js +38 -16
- package/dist/holmes/cli/roles.d.ts +12 -0
- package/dist/holmes/cli/roles.js +86 -0
- package/dist/holmes/cli/run.d.ts +65 -0
- package/dist/holmes/cli/run.js +308 -0
- package/dist/holmes/cli/runtime-binding.d.ts +30 -0
- package/dist/holmes/cli/runtime-binding.js +96 -7
- package/dist/holmes/cli/test-platform.d.ts +16 -0
- package/dist/holmes/cli/test-platform.js +31 -1
- package/dist/holmes/config/config.d.ts +49 -0
- package/dist/holmes/config/config.js +146 -3
- package/dist/holmes/config/project-caps.d.ts +21 -0
- package/dist/holmes/config/project-caps.js +114 -0
- package/dist/holmes/governance/approval-queue.d.ts +17 -3
- package/dist/holmes/governance/approval-queue.js +48 -6
- package/dist/holmes/governance/autonomy.d.ts +6 -0
- package/dist/holmes/governance/autonomy.js +21 -0
- package/dist/holmes/governance/push-gate-runner.d.ts +8 -0
- package/dist/holmes/governance/push-gate-runner.js +49 -1
- package/dist/holmes/governance/replica-id.d.ts +9 -0
- package/dist/holmes/governance/replica-id.js +44 -7
- package/dist/holmes/governance/role-policy.d.ts +41 -1
- package/dist/holmes/governance/role-policy.js +137 -20
- package/dist/holmes/governance/run-mode.d.ts +14 -0
- package/dist/holmes/governance/run-mode.js +120 -0
- package/dist/holmes/governance/tool-actions.d.ts +30 -0
- package/dist/holmes/governance/tool-actions.js +121 -0
- package/dist/holmes/guardrail/agent-launch-policy.d.ts +15 -0
- package/dist/holmes/guardrail/agent-launch-policy.js +177 -0
- package/dist/holmes/guardrail/classification-mode.d.ts +17 -0
- package/dist/holmes/guardrail/classification-mode.js +135 -0
- package/dist/holmes/guardrail/dynamic-write.d.ts +43 -0
- package/dist/holmes/guardrail/dynamic-write.js +304 -0
- package/dist/holmes/guardrail/phase.d.ts +2 -1
- package/dist/holmes/guardrail/phase.js +22 -8
- package/dist/holmes/guardrail/powershell-shell.d.ts +21 -0
- package/dist/holmes/guardrail/powershell-shell.js +801 -0
- package/dist/holmes/guardrail/refusal-codes.d.ts +24 -0
- package/dist/holmes/guardrail/refusal-codes.js +140 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +17 -0
- package/dist/holmes/guardrail/risk-classifier.js +242 -26
- package/dist/holmes/guardrail/risk-types.d.ts +15 -0
- package/dist/holmes/guardrail/run-plan-scope.d.ts +23 -0
- package/dist/holmes/guardrail/run-plan-scope.js +155 -0
- package/dist/holmes/guardrail/run-refusals.d.ts +116 -0
- package/dist/holmes/guardrail/run-refusals.js +348 -0
- package/dist/holmes/guardrail/run-stages.d.ts +67 -0
- package/dist/holmes/guardrail/run-stages.js +188 -0
- package/dist/holmes/guardrail/scope-judgment.d.ts +5 -1
- package/dist/holmes/guardrail/scope-judgment.js +8 -10
- package/dist/holmes/guardrail/scope-refusal-memory.d.ts +3 -0
- package/dist/holmes/guardrail/scope-refusal-memory.js +85 -0
- package/dist/holmes/guardrail/shell-words.js +7 -7
- package/dist/holmes/guardrail/write-target.d.ts +31 -2
- package/dist/holmes/guardrail/write-target.js +118 -16
- package/dist/holmes/hooks/pre-tool-use.d.ts +35 -1
- package/dist/holmes/hooks/pre-tool-use.js +702 -81
- package/dist/holmes/hooks/session-start.js +5 -3
- package/dist/holmes/hooks/stop.d.ts +32 -0
- package/dist/holmes/hooks/stop.js +129 -4
- package/dist/holmes/mcp/handlers/graph-operations.js +5 -5
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +2 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -1
- package/dist/holmes/mcp/handlers/operator-inspection.js +3 -1
- package/dist/holmes/mcp/handlers/phase-queries.js +16 -1
- package/dist/holmes/mcp/handlers/requirement-triage.js +2 -2
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -3
- package/dist/holmes/mcp/handlers/spec-approval.js +54 -8
- package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +1 -0
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +3 -3
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +7 -0
- package/dist/holmes/mcp/handlers/spec-queries.js +5 -0
- package/dist/holmes/mcp/handlers/workspace-queries.js +2 -2
- package/dist/holmes/mcp/handlers.d.ts +2 -3
- package/dist/holmes/mcp/handlers.js +22 -2
- package/dist/holmes/mcp/harness-attestation.d.ts +2 -0
- package/dist/holmes/mcp/harness-attestation.js +3 -1
- package/dist/holmes/mcp/operator-recovery.d.ts +2 -0
- package/dist/holmes/mcp/operator-recovery.js +4 -3
- package/dist/holmes/mcp/server.js +9 -0
- package/dist/holmes/mcp/tool-schemas.js +6 -3
- package/dist/holmes/project/root.js +6 -1
- package/dist/holmes/project/run-records.d.ts +17 -0
- package/dist/holmes/project/run-records.js +126 -0
- package/dist/holmes/review/mrp.d.ts +35 -0
- package/dist/holmes/review/mrp.js +119 -0
- package/dist/holmes/review/verdicts.d.ts +117 -0
- package/dist/holmes/review/verdicts.js +345 -0
- package/dist/holmes/semantic/cloud-usage.d.ts +20 -0
- package/dist/holmes/semantic/cloud-usage.js +106 -0
- package/dist/holmes/semantic/embedder.d.ts +15 -6
- package/dist/holmes/semantic/embedder.js +84 -3
- package/dist/holmes/semantic/local-model.d.ts +21 -2
- package/dist/holmes/semantic/local-model.js +14 -3
- package/dist/holmes/semantic/tier.d.ts +25 -0
- package/dist/holmes/semantic/tier.js +86 -1
- package/dist/holmes/semantic/vector-cache.d.ts +1 -0
- package/dist/holmes/semantic/vector-cache.js +4 -1
- package/dist/holmes/spec/approval-blockers.d.ts +11 -1
- package/dist/holmes/spec/approval-blockers.js +70 -2
- package/dist/holmes/spec/renumber.d.ts +1 -1
- package/dist/holmes/spec/renumber.js +5 -2
- package/dist/holmes/spec/transition-policy.d.ts +5 -7
- package/dist/holmes/spec/transition-policy.js +17 -2
- package/package.json +1 -1
|
@@ -34,6 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.defaultRuntimeRegistry = void 0;
|
|
37
|
+
exports.holmesAgyWrapper = holmesAgyWrapper;
|
|
38
|
+
exports.sameAgyCommand = sameAgyCommand;
|
|
37
39
|
exports.runtimeHookCommand = runtimeHookCommand;
|
|
38
40
|
exports.wiringViewOf = wiringViewOf;
|
|
39
41
|
exports.codexProjectUntrusted = codexProjectUntrusted;
|
|
@@ -43,7 +45,7 @@ exports.codexDuplicateRoutes = codexDuplicateRoutes;
|
|
|
43
45
|
exports.runtimeBindingStatus = runtimeBindingStatus;
|
|
44
46
|
exports.runRuntimeBinding = runRuntimeBinding;
|
|
45
47
|
exports.trackedWorkspacePaths = trackedWorkspacePaths;
|
|
46
|
-
// @implements A-SPEC-769.10,
|
|
48
|
+
// @implements A-SPEC-751.8, A-SPEC-751.9, A-SPEC-769.22,A-SPEC-769.10,A-SPEC-752.11,A-SPEC-752.12, A-SPEC-752.13, A-SPEC-752.14, A-SPEC-752.15, A-SPEC-752.16, A-SPEC-752.17, A-SPEC-752.10, A-SPEC-752.9, A-SPEC-751.5, A-SPEC-751.6, A-SPEC-751, A-SPEC-752, A-SPEC-752.7, A-SPEC-752.8, A-SPEC-772.1, A-SPEC-772.2, 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, A-SPEC-772.12
|
|
47
49
|
const fs = __importStar(require("node:fs"));
|
|
48
50
|
const os = __importStar(require("node:os"));
|
|
49
51
|
const path = __importStar(require("node:path"));
|
|
@@ -55,6 +57,7 @@ const hook_process_1 = require("../runtime/hook-process");
|
|
|
55
57
|
const runtime_binding_approval_1 = require("./runtime-binding-approval");
|
|
56
58
|
const codex_toml_1 = require("./codex-toml");
|
|
57
59
|
const codex_hooks_1 = require("./codex-hooks");
|
|
60
|
+
const write_target_1 = require("../guardrail/write-target");
|
|
58
61
|
const agents_1 = require("./agents");
|
|
59
62
|
const heartbeat_1 = require("../hooks/heartbeat");
|
|
60
63
|
const root_1 = require("../project/root");
|
|
@@ -99,6 +102,76 @@ function quote(word) {
|
|
|
99
102
|
}
|
|
100
103
|
return `'${word.replace(/'/g, `'\\''`)}'`;
|
|
101
104
|
}
|
|
105
|
+
/** Holmes's direct Antigravity wrapper as written: one space-free script token after node (A-SPEC-586). */
|
|
106
|
+
const AGY_DIRECT = /^(?:node|[^\s]+[/\\]node(?:\.exe)?) ([^\s]+)$/;
|
|
107
|
+
const AGY_SCRIPT_LITERAL = /^[^\s]+[/\\]bin[/\\]holmes-(?:hook|stop)-antigravity\.js$/;
|
|
108
|
+
const AGY_SCRIPTS = new Set(['holmes-hook-antigravity.js', 'holmes-stop-antigravity.js']);
|
|
109
|
+
/** A token a shell would not run as one literal path. */
|
|
110
|
+
const AGY_TOKEN_UNSAFE = /["'`$;&|<>()]/;
|
|
111
|
+
/**
|
|
112
|
+
* Whether one Antigravity hook command is Holmes's own direct wrapper.
|
|
113
|
+
*
|
|
114
|
+
* @implements A-SPEC-751.8
|
|
115
|
+
* The shape and a literal script name decide exactly as the inline test did before. Only on a win32 host, and only
|
|
116
|
+
* when the literal name does not, the token is read back to its long name: init writes a spaced install root as its
|
|
117
|
+
* 8.3 form, and `%~sI` shortens the file name too (`HOLMES~4.JS`, measured 2026-10-17), so the literal test refused
|
|
118
|
+
* Holmes's own entry and setup wrote nothing. A token a shell would not take literally, or one the resolver cannot
|
|
119
|
+
* read, is not a match — the entry stays a conflict (A-SPEC-751 rule 5). Host and resolver are injectable so either
|
|
120
|
+
* host can assert the other's answers.
|
|
121
|
+
*/
|
|
122
|
+
function holmesAgyWrapper(cmd, opts = {}) {
|
|
123
|
+
if (typeof cmd !== 'string')
|
|
124
|
+
return false;
|
|
125
|
+
const m = AGY_DIRECT.exec(cmd);
|
|
126
|
+
if (m === null)
|
|
127
|
+
return false;
|
|
128
|
+
if (AGY_SCRIPT_LITERAL.test(m[1]))
|
|
129
|
+
return true;
|
|
130
|
+
if ((opts.host ?? (0, write_target_1.hostFlavor)()).sep !== '\\' || AGY_TOKEN_UNSAFE.test(m[1]))
|
|
131
|
+
return false;
|
|
132
|
+
let long;
|
|
133
|
+
try {
|
|
134
|
+
long = (opts.realpath ?? fs.realpathSync.native)(m[1]);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return path.win32.basename(path.win32.dirname(long)).toLowerCase() === 'bin'
|
|
140
|
+
&& AGY_SCRIPTS.has(path.win32.basename(long).toLowerCase());
|
|
141
|
+
}
|
|
142
|
+
const AGY_TWO_TOKENS = /^([^\s]+) ([^\s]+)$/;
|
|
143
|
+
/**
|
|
144
|
+
* Whether an existing Antigravity command is the canonical dispatcher command `runtimeHookCommand` computes now.
|
|
145
|
+
*
|
|
146
|
+
* @implements A-SPEC-751.9
|
|
147
|
+
* Identical strings always are. On a win32 host only, two space-free two-token commands are also the same when each
|
|
148
|
+
* token resolves to the same long path: `shortPathIfSpaced` shortens only components that exist, so the command a first
|
|
149
|
+
* setup wrote (`…\operator\antigravity-stop.js`, the file not yet made) is not the string the next one computes
|
|
150
|
+
* (`…\operator\ANTIGR~1.JS`, measured 2026-10-18) — and setup refused its own entry while doctor counted none. A token a
|
|
151
|
+
* shell would not take literally, or one the resolver cannot read, makes them different (A-SPEC-751 rule 5 still holds).
|
|
152
|
+
*/
|
|
153
|
+
function sameAgyCommand(written, canonical, opts = {}) {
|
|
154
|
+
if (typeof written !== 'string')
|
|
155
|
+
return false;
|
|
156
|
+
if (written === canonical)
|
|
157
|
+
return true;
|
|
158
|
+
if ((opts.host ?? (0, write_target_1.hostFlavor)()).sep !== '\\')
|
|
159
|
+
return false;
|
|
160
|
+
const a = AGY_TWO_TOKENS.exec(written);
|
|
161
|
+
const b = AGY_TWO_TOKENS.exec(canonical);
|
|
162
|
+
if (a === null || b === null)
|
|
163
|
+
return false;
|
|
164
|
+
if ([a[1], a[2], b[1], b[2]].some((t) => AGY_TOKEN_UNSAFE.test(t)))
|
|
165
|
+
return false;
|
|
166
|
+
const real = opts.realpath ?? fs.realpathSync.native;
|
|
167
|
+
try {
|
|
168
|
+
const long = (t) => path.win32.normalize(real(t)).toLowerCase();
|
|
169
|
+
return long(a[1]) === long(b[1]) && long(a[2]) === long(b[2]);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
102
175
|
function runtimeHookCommand(registryPath, harness, entry) {
|
|
103
176
|
const file = path.join(path.dirname(registryPath), `${harness}-${entry}.js`);
|
|
104
177
|
if (harness !== 'antigravity')
|
|
@@ -307,7 +380,9 @@ function codexDuplicateRoutes(codexHome, workspace) {
|
|
|
307
380
|
if (object(entry) && entry.enabled === false)
|
|
308
381
|
continue;
|
|
309
382
|
out.push({ harness: 'codex', event: stateKey, files: [userHooks, wsHooks],
|
|
310
|
-
|
|
383
|
+
// @implements A-SPEC-769.22 — the key as a TOML basic string: a Windows path's `\U…` raw is a unicode escape, and
|
|
384
|
+
// following the line wrote a config.toml Codex cannot load. Byte-identical for a key with no backslash or quote.
|
|
385
|
+
fix: `set enabled = false under [hooks.state.${(0, codex_toml_1.tomlStr)(key)}] in ${configPath} (or remove the ${stateKey} entry from one file) — Holmes runs once per lifecycle` });
|
|
311
386
|
}
|
|
312
387
|
return out;
|
|
313
388
|
}
|
|
@@ -712,23 +787,37 @@ function runRuntimeBinding(opts) {
|
|
|
712
787
|
throw new Error(`Invalid Antigravity hook group: ${file}`);
|
|
713
788
|
for (const h of entries) {
|
|
714
789
|
const cmd = h?.command;
|
|
715
|
-
const direct =
|
|
716
|
-
if (!direct && cmd
|
|
717
|
-
throw new Error(`Unknown Antigravity wrapper requires explicit migration: ${file}`);
|
|
790
|
+
const direct = holmesAgyWrapper(cmd); // A-SPEC-751.8
|
|
791
|
+
if (!direct && !sameAgyCommand(cmd, command('antigravity', event === 'PreToolUse' ? 'pre-tool-use' : 'stop')))
|
|
792
|
+
throw new Error(`Unknown Antigravity wrapper requires explicit migration: ${file}`); // A-SPEC-751.9
|
|
718
793
|
}
|
|
719
794
|
}
|
|
720
795
|
}
|
|
796
|
+
// @implements A-SPEC-751.9 — an entry that already names the canonical dispatcher keeps its spelling: a Windows short
|
|
797
|
+
// path is spelled differently once the file exists while it still names the same file, and rewriting it to today's
|
|
798
|
+
// spelling made every second setup plan a change.
|
|
799
|
+
const spelled = (event, entry) => {
|
|
800
|
+
const canonical = command('antigravity', entry);
|
|
801
|
+
for (const group of Array.isArray(old?.[event]) ? old[event] : []) {
|
|
802
|
+
for (const h of event === 'PreToolUse' ? (Array.isArray(group?.hooks) ? group.hooks : []) : [group]) {
|
|
803
|
+
const written = h?.command;
|
|
804
|
+
if (typeof written === 'string' && written !== canonical && sameAgyCommand(written, canonical))
|
|
805
|
+
return written;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return canonical;
|
|
809
|
+
};
|
|
721
810
|
// Preserve the native enable switch and fields other than our lifecycle entries.
|
|
722
811
|
const ours = { ...old };
|
|
723
812
|
if (activate.has('antigravity') && primary.size)
|
|
724
813
|
ours.enabled = true;
|
|
725
814
|
if (primary.has('PreToolUse')) {
|
|
726
|
-
ours.PreToolUse = !activate.has('antigravity') && Array.isArray(old?.PreToolUse) && old.PreToolUse.length === 0 ? [] : [{ matcher: '*', hooks: [{ command:
|
|
815
|
+
ours.PreToolUse = !activate.has('antigravity') && Array.isArray(old?.PreToolUse) && old.PreToolUse.length === 0 ? [] : [{ matcher: '*', hooks: [{ command: spelled('PreToolUse', 'pre-tool-use') }] }];
|
|
727
816
|
}
|
|
728
817
|
else if (!(Array.isArray(old?.PreToolUse) && old.PreToolUse.length === 0))
|
|
729
818
|
delete ours.PreToolUse;
|
|
730
819
|
if (primary.has('Stop'))
|
|
731
|
-
ours.Stop = !activate.has('antigravity') && Array.isArray(old?.Stop) && old.Stop.length === 0 ? [] : [{ command:
|
|
820
|
+
ours.Stop = !activate.has('antigravity') && Array.isArray(old?.Stop) && old.Stop.length === 0 ? [] : [{ command: spelled('Stop', 'stop'), timeout: hook_process_1.STOP_HOOK_TIMEOUT_SECONDS }]; // A-SPEC-769.10
|
|
732
821
|
else if (!(Array.isArray(old?.Stop) && old.Stop.length === 0))
|
|
733
822
|
delete ours.Stop;
|
|
734
823
|
add(file, json({ ...doc, 'holmes-kit': ours }));
|
|
@@ -49,6 +49,22 @@ export declare function foldsCase(dir: string): boolean;
|
|
|
49
49
|
* the platform and the uid, so it belongs in the same choice.
|
|
50
50
|
*/
|
|
51
51
|
export declare function posixOnlyWithCommand(reason: string, command: string, platform?: string, uid?: number | undefined, lookup?: (command: string) => boolean): typeof it | typeof it.skip;
|
|
52
|
+
/**
|
|
53
|
+
* @implements A-SPEC-220.4
|
|
54
|
+
* A path as ONE Bash word. A Windows temp path holds backslashes (Bash escapes) and may hold a space (a word break), so
|
|
55
|
+
* a fixture that interpolates it unquoted is read, correctly, as other words; single quotes keep the native spelling.
|
|
56
|
+
*/
|
|
57
|
+
export declare function bashWord(p: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* @implements A-SPEC-220.4
|
|
60
|
+
* Remove a directory a child process ran in. Windows holds such a directory for a moment after the process has gone;
|
|
61
|
+
* `fs.rmSync`'s own `maxRetries` did not cover it and a retry of the whole call did (A-SPEC-698, measured 2026-09-20).
|
|
62
|
+
* Bounded: past `ms` the last error is thrown, so a genuine failure is not swallowed.
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeWhenReleased(dir: string, ms?: number, remove?: (dir: string, opts: {
|
|
65
|
+
recursive: true;
|
|
66
|
+
force: true;
|
|
67
|
+
}) => void): Promise<void>;
|
|
52
68
|
/**
|
|
53
69
|
* @implements A-SPEC-255
|
|
54
70
|
* The mirror of `posixOnly`: a test whose SUBJECT only exists on Windows.
|
|
@@ -37,11 +37,13 @@ exports.posixOnly = posixOnly;
|
|
|
37
37
|
exports.posixOnlyNonRoot = posixOnlyNonRoot;
|
|
38
38
|
exports.foldsCase = foldsCase;
|
|
39
39
|
exports.posixOnlyWithCommand = posixOnlyWithCommand;
|
|
40
|
+
exports.bashWord = bashWord;
|
|
41
|
+
exports.removeWhenReleased = removeWhenReleased;
|
|
40
42
|
exports.win32Only = win32Only;
|
|
41
43
|
const fs = __importStar(require("node:fs"));
|
|
42
44
|
const path = __importStar(require("node:path"));
|
|
43
45
|
const node_crypto_1 = require("node:crypto");
|
|
44
|
-
// @implements A-SPEC-220.3
|
|
46
|
+
// @implements A-SPEC-220.3, A-SPEC-220.4
|
|
45
47
|
// @implements A-SPEC-597
|
|
46
48
|
/**
|
|
47
49
|
* A test that cannot run here says so, instead of returning early and being counted as a pass.
|
|
@@ -145,6 +147,34 @@ function posixOnlyWithCommand(reason, command, platform = process.platform, uid
|
|
|
145
147
|
const base = posixOnlyNonRoot(reason, platform, uid); // reason is validated here, before anything else
|
|
146
148
|
return lookup(command) ? base : it.skip;
|
|
147
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* @implements A-SPEC-220.4
|
|
152
|
+
* A path as ONE Bash word. A Windows temp path holds backslashes (Bash escapes) and may hold a space (a word break), so
|
|
153
|
+
* a fixture that interpolates it unquoted is read, correctly, as other words; single quotes keep the native spelling.
|
|
154
|
+
*/
|
|
155
|
+
function bashWord(p) {
|
|
156
|
+
return `'${p.replace(/'/g, `'\\''`)}'`;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @implements A-SPEC-220.4
|
|
160
|
+
* Remove a directory a child process ran in. Windows holds such a directory for a moment after the process has gone;
|
|
161
|
+
* `fs.rmSync`'s own `maxRetries` did not cover it and a retry of the whole call did (A-SPEC-698, measured 2026-09-20).
|
|
162
|
+
* Bounded: past `ms` the last error is thrown, so a genuine failure is not swallowed.
|
|
163
|
+
*/
|
|
164
|
+
async function removeWhenReleased(dir, ms = 10000, remove = fs.rmSync) {
|
|
165
|
+
const t0 = Date.now();
|
|
166
|
+
for (;;) {
|
|
167
|
+
try {
|
|
168
|
+
remove(dir, { recursive: true, force: true });
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
if (Date.now() - t0 > ms)
|
|
173
|
+
throw e;
|
|
174
|
+
await new Promise((res) => setTimeout(res, 100));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
148
178
|
/**
|
|
149
179
|
* @implements A-SPEC-255
|
|
150
180
|
* The mirror of `posixOnly`: a test whose SUBJECT only exists on Windows.
|
|
@@ -36,6 +36,55 @@ export interface AxConfig {
|
|
|
36
36
|
*/
|
|
37
37
|
cycleIgnore: string[];
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* @implements A-SPEC-775.1
|
|
41
|
+
* `strict` is the owner's opt-in to the run-mode classification outside a run (the supervisor's
|
|
42
|
+
* `strict_classification`): nested test folders narrow and unclassified writes off the safe list are code.
|
|
43
|
+
* `testDirs` are folders the owner declares as test folders, in every mode.
|
|
44
|
+
*/
|
|
45
|
+
classification: {
|
|
46
|
+
strict: boolean;
|
|
47
|
+
testDirs: string[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* @implements A-SPEC-532.6
|
|
51
|
+
* The owner's ceiling on automatic approval (autonomous and delegated seals). It only narrows the grader; `default`
|
|
52
|
+
* when absent, `off` when malformed — a ceiling must never fail toward wider.
|
|
53
|
+
*/
|
|
54
|
+
autonomy: {
|
|
55
|
+
ceiling: AutonomyCeiling;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @implements A-SPEC-778
|
|
59
|
+
* In a run, a refusal code repeated this many times stops the run. An integer from 1 to 1000; anything else is 5.
|
|
60
|
+
*/
|
|
61
|
+
run: {
|
|
62
|
+
refusalRepeatLimit: number;
|
|
63
|
+
approvalWaitMinutes: number;
|
|
64
|
+
};
|
|
65
|
+
/** @implements A-SPEC-781 — a run's stage machine: the stages, the allowed edges, and the stages that need review. */
|
|
66
|
+
stages: StageMachine;
|
|
67
|
+
}
|
|
68
|
+
/** @implements A-SPEC-781 */
|
|
69
|
+
/** @implements A-SPEC-781.1 — `deny`: per stage, the classifier actions the gate refuses in a run at that stage. */
|
|
70
|
+
/**
|
|
71
|
+
* @implements A-SPEC-781.2 — `conditions`: per edge `from->to`, the checks a transition must pass; `notes`: how the
|
|
72
|
+
* declaration was read (a fallback, a filled-in deny), for the run log and doctor.
|
|
73
|
+
*/
|
|
74
|
+
export interface StageMachine {
|
|
75
|
+
order: string[];
|
|
76
|
+
transitions: Record<string, string[]>;
|
|
77
|
+
reviewed: string[];
|
|
78
|
+
deny: Record<string, string[]>;
|
|
79
|
+
conditions: Record<string, string[]>;
|
|
80
|
+
notes: string[];
|
|
39
81
|
}
|
|
82
|
+
export declare const DEFAULT_STAGES: StageMachine;
|
|
83
|
+
/** @implements A-SPEC-778 */
|
|
84
|
+
export declare const RUN_REFUSAL_LIMIT_DEFAULT = 5;
|
|
85
|
+
/** @implements A-SPEC-779 — how long a run may wait for an operator's decision before it stops. */
|
|
86
|
+
export declare const RUN_APPROVAL_WAIT_DEFAULT = 60;
|
|
87
|
+
/** @implements A-SPEC-532.6 — narrowest first. */
|
|
88
|
+
export type AutonomyCeiling = 'off' | 'tests' | 'no-gate' | 'default';
|
|
40
89
|
export declare const DEFAULT_CONFIG: AxConfig;
|
|
41
90
|
export declare function loadConfig(root: string): AxConfig;
|
|
@@ -33,13 +33,117 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DEFAULT_CONFIG = void 0;
|
|
36
|
+
exports.DEFAULT_CONFIG = exports.RUN_APPROVAL_WAIT_DEFAULT = exports.RUN_REFUSAL_LIMIT_DEFAULT = exports.DEFAULT_STAGES = void 0;
|
|
37
37
|
exports.loadConfig = loadConfig;
|
|
38
|
-
// @implements A-SPEC-278
|
|
38
|
+
// @implements A-SPEC-278, A-SPEC-781.2, A-SPEC-476.3
|
|
39
39
|
// @implements A-SPEC-125.5
|
|
40
40
|
// src/holmes/config/config.ts
|
|
41
41
|
const fs = __importStar(require("node:fs"));
|
|
42
42
|
const path = __importStar(require("node:path"));
|
|
43
|
+
exports.DEFAULT_STAGES = {
|
|
44
|
+
order: ['analysis', 'design', 'implement', 'review', 'test', 'done'],
|
|
45
|
+
transitions: { analysis: ['design'], design: ['implement'], implement: ['review'], review: ['test', 'implement'], test: ['done', 'implement'], done: [] },
|
|
46
|
+
reviewed: ['test', 'done'],
|
|
47
|
+
deny: {
|
|
48
|
+
analysis: ['WRITE_CODE', 'WRITE_TEST'], design: ['WRITE_CODE', 'WRITE_TEST'], implement: [],
|
|
49
|
+
review: ['WRITE_CODE', 'WRITE_TEST'], test: ['WRITE_CODE'], done: ['WRITE_CODE', 'WRITE_TEST'],
|
|
50
|
+
},
|
|
51
|
+
// @implements A-SPEC-781.2 — the G5.7 slot: design → implement needs a design section (checked when G5.7 lands).
|
|
52
|
+
conditions: { 'design->implement': ['design-section'] },
|
|
53
|
+
notes: [],
|
|
54
|
+
};
|
|
55
|
+
/** @implements A-SPEC-781.2 — what a new-named stage without a deny entry refuses. */
|
|
56
|
+
const NEW_STAGE_DENY = ['WRITE_CODE', 'WRITE_TEST'];
|
|
57
|
+
/**
|
|
58
|
+
* @implements A-SPEC-781 — a declaration is taken whole or not at all: any flaw means the default machine.
|
|
59
|
+
* @implements A-SPEC-781.2 — never silently: the fallback, and every deny filled in for a stage, is a note.
|
|
60
|
+
*/
|
|
61
|
+
function stageMachineOf(raw) {
|
|
62
|
+
if (raw === undefined)
|
|
63
|
+
return structuredClone(exports.DEFAULT_STAGES);
|
|
64
|
+
const fallback = (what) => ({ ...structuredClone(exports.DEFAULT_STAGES), notes: [`the stages declaration is ignored (${what}): the default machine is used`] });
|
|
65
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
|
|
66
|
+
return fallback('it is not an object');
|
|
67
|
+
const r = raw;
|
|
68
|
+
if (!Array.isArray(r.order) || r.order.length === 0 || !r.order.every((s) => typeof s === 'string' && s !== '')) {
|
|
69
|
+
return fallback('order is not a non-empty list of stage names');
|
|
70
|
+
}
|
|
71
|
+
const order = r.order;
|
|
72
|
+
if (new Set(order).size !== order.length)
|
|
73
|
+
return fallback('order names a stage twice');
|
|
74
|
+
const known = new Set(order);
|
|
75
|
+
const transitions = {};
|
|
76
|
+
if (r.transitions !== undefined) {
|
|
77
|
+
if (r.transitions === null || typeof r.transitions !== 'object' || Array.isArray(r.transitions))
|
|
78
|
+
return fallback('transitions is not an object');
|
|
79
|
+
for (const [from, tos] of Object.entries(r.transitions)) {
|
|
80
|
+
if (!known.has(from) || !Array.isArray(tos) || !tos.every((t) => typeof t === 'string' && known.has(t))) {
|
|
81
|
+
return fallback(`transitions.${from} names a stage the order does not have`);
|
|
82
|
+
}
|
|
83
|
+
transitions[from] = tos;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
order.forEach((s, i) => { transitions[s] = i + 1 < order.length ? [order[i + 1]] : []; });
|
|
88
|
+
}
|
|
89
|
+
let reviewed = [];
|
|
90
|
+
if (r.reviewed !== undefined) {
|
|
91
|
+
if (!Array.isArray(r.reviewed) || !r.reviewed.every((s) => typeof s === 'string' && known.has(s)))
|
|
92
|
+
return fallback('reviewed names a stage the order does not have');
|
|
93
|
+
reviewed = r.reviewed;
|
|
94
|
+
}
|
|
95
|
+
// @implements A-SPEC-781.1 — a stage's deny as declared; A-SPEC-781.2 fills in the stages it leaves out.
|
|
96
|
+
const deny = {};
|
|
97
|
+
if (r.deny !== undefined) {
|
|
98
|
+
if (r.deny === null || typeof r.deny !== 'object' || Array.isArray(r.deny))
|
|
99
|
+
return fallback('deny is not an object');
|
|
100
|
+
for (const [stage, actions] of Object.entries(r.deny)) {
|
|
101
|
+
if (!known.has(stage) || !Array.isArray(actions) || !actions.every((a) => typeof a === 'string'))
|
|
102
|
+
return fallback(`deny.${stage} is not a list for a known stage`);
|
|
103
|
+
deny[stage] = actions;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// @implements A-SPEC-781.2 — a stage the declaration leaves without deny denies by default, and says so.
|
|
107
|
+
const notes = [];
|
|
108
|
+
for (const stage of order) {
|
|
109
|
+
if (deny[stage] !== undefined)
|
|
110
|
+
continue;
|
|
111
|
+
const dflt = exports.DEFAULT_STAGES.deny[stage];
|
|
112
|
+
if (dflt !== undefined) {
|
|
113
|
+
deny[stage] = [...dflt];
|
|
114
|
+
notes.push(`stage ${stage} has no deny entry: the default (${dflt.join(', ') || 'nothing denied'}) applies`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
deny[stage] = [...NEW_STAGE_DENY];
|
|
118
|
+
notes.push(`stage ${stage} has no deny entry: ${NEW_STAGE_DENY.join(', ')} are denied (declare deny.${stage}: [] to allow them)`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const conditions = {};
|
|
122
|
+
const isEdge = (edge) => {
|
|
123
|
+
const [from, to, ...rest] = edge.split('->');
|
|
124
|
+
return rest.length === 0 && (transitions[from] ?? []).includes(to);
|
|
125
|
+
};
|
|
126
|
+
if (r.conditions !== undefined) {
|
|
127
|
+
if (r.conditions === null || typeof r.conditions !== 'object' || Array.isArray(r.conditions))
|
|
128
|
+
return fallback('conditions is not an object');
|
|
129
|
+
for (const [edge, names] of Object.entries(r.conditions)) {
|
|
130
|
+
if (!isEdge(edge) || !Array.isArray(names) || !names.every((n) => typeof n === 'string'))
|
|
131
|
+
return fallback(`conditions.${edge} is not a list for an edge of the machine`);
|
|
132
|
+
conditions[edge] = names;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
for (const [edge, names] of Object.entries(exports.DEFAULT_STAGES.conditions))
|
|
137
|
+
if (isEdge(edge))
|
|
138
|
+
conditions[edge] = [...names];
|
|
139
|
+
}
|
|
140
|
+
return { order, transitions, reviewed, deny, conditions, notes };
|
|
141
|
+
}
|
|
142
|
+
/** @implements A-SPEC-778 */
|
|
143
|
+
exports.RUN_REFUSAL_LIMIT_DEFAULT = 5;
|
|
144
|
+
/** @implements A-SPEC-779 — how long a run may wait for an operator's decision before it stops. */
|
|
145
|
+
exports.RUN_APPROVAL_WAIT_DEFAULT = 60;
|
|
146
|
+
const CEILINGS = ['off', 'tests', 'no-gate', 'default'];
|
|
43
147
|
exports.DEFAULT_CONFIG = {
|
|
44
148
|
// @implements A-SPEC-332
|
|
45
149
|
// `warn`, not `off` and not `block`. Off left Phase 2 present in code and absent in behaviour;
|
|
@@ -51,6 +155,10 @@ exports.DEFAULT_CONFIG = {
|
|
|
51
155
|
highRiskDomains: ['@auth', '@payment'],
|
|
52
156
|
storage: { specStore: 'local-markdown' },
|
|
53
157
|
architecture: { cycleIgnore: [] },
|
|
158
|
+
classification: { strict: false, testDirs: [] },
|
|
159
|
+
autonomy: { ceiling: 'default' },
|
|
160
|
+
run: { refusalRepeatLimit: exports.RUN_REFUSAL_LIMIT_DEFAULT, approvalWaitMinutes: exports.RUN_APPROVAL_WAIT_DEFAULT },
|
|
161
|
+
stages: structuredClone(exports.DEFAULT_STAGES),
|
|
54
162
|
};
|
|
55
163
|
function deepMerge(base, ov) {
|
|
56
164
|
if (ov == null || typeof ov !== 'object')
|
|
@@ -79,9 +187,44 @@ function loadConfig(root) {
|
|
|
79
187
|
merged.architecture = {
|
|
80
188
|
cycleIgnore: Array.isArray(declared) ? declared.filter((x) => typeof x === 'string') : [],
|
|
81
189
|
};
|
|
190
|
+
// @implements A-SPEC-775.1 — the same rule for the classification keys: strict only when literally
|
|
191
|
+
// true, and a declaration that is not an array of strings declares nothing.
|
|
192
|
+
const cls = merged.classification;
|
|
193
|
+
const dirs = cls && typeof cls === 'object' ? cls.testDirs : undefined;
|
|
194
|
+
merged.classification = {
|
|
195
|
+
strict: cls !== null && typeof cls === 'object' && cls.strict === true,
|
|
196
|
+
testDirs: Array.isArray(dirs) ? dirs.filter((x) => typeof x === 'string') : [],
|
|
197
|
+
};
|
|
198
|
+
// @implements A-SPEC-532.6 — absent is `default` (deepMerge carried the default object in); anything present that is
|
|
199
|
+
// not a known value, including a non-object `autonomy`, is `off`.
|
|
200
|
+
const auto = merged.autonomy;
|
|
201
|
+
const declaredCeiling = auto !== null && typeof auto === 'object' ? auto.ceiling : undefined;
|
|
202
|
+
merged.autonomy = {
|
|
203
|
+
ceiling: CEILINGS.includes(declaredCeiling) ? declaredCeiling : 'off',
|
|
204
|
+
};
|
|
205
|
+
// @implements A-SPEC-778 — only an integer from 1 to 1000 is a limit.
|
|
206
|
+
const runCfg = merged.run;
|
|
207
|
+
const limit = runCfg !== null && typeof runCfg === 'object' ? runCfg.refusalRepeatLimit : undefined;
|
|
208
|
+
// @implements A-SPEC-779 — and only an integer from 1 to 10080 (a week) is a wait limit.
|
|
209
|
+
const wait = runCfg !== null && typeof runCfg === 'object' ? runCfg.approvalWaitMinutes : undefined;
|
|
210
|
+
merged.run = {
|
|
211
|
+
refusalRepeatLimit: typeof limit === 'number' && Number.isInteger(limit) && limit >= 1 && limit <= 1000 ? limit : exports.RUN_REFUSAL_LIMIT_DEFAULT,
|
|
212
|
+
approvalWaitMinutes: typeof wait === 'number' && Number.isInteger(wait) && wait >= 1 && wait <= 10080 ? wait : exports.RUN_APPROVAL_WAIT_DEFAULT,
|
|
213
|
+
};
|
|
214
|
+
// @implements A-SPEC-781 — read from the file as written, not from the deep merge with the default machine.
|
|
215
|
+
let declaredStages;
|
|
216
|
+
try {
|
|
217
|
+
declaredStages = JSON.parse(fs.readFileSync(f, 'utf8')).stages;
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
declaredStages = undefined;
|
|
221
|
+
}
|
|
222
|
+
merged.stages = stageMachineOf(declaredStages);
|
|
82
223
|
return merged;
|
|
83
224
|
}
|
|
84
225
|
catch {
|
|
85
|
-
|
|
226
|
+
// @implements A-SPEC-476.3 — the defaults carry the widest ceiling, so a broken file raised it; it reads `off`, as a
|
|
227
|
+
// malformed ceiling already does (A-SPEC-532.6: a ceiling never fails toward wider).
|
|
228
|
+
return { ...structuredClone(exports.DEFAULT_CONFIG), autonomy: { ceiling: 'off' } };
|
|
86
229
|
}
|
|
87
230
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AutonomyCeiling } from './config';
|
|
2
|
+
/**
|
|
3
|
+
* The two owner caps ax.config.json carries, read from a text the way their readers read the file: `semantic.maxTier`
|
|
4
|
+
* as `readSemanticCap` (A-SPEC-476.1) and `autonomy.ceiling` as `loadConfig` (A-SPEC-532.6). `null` is "no file".
|
|
5
|
+
* A test holds both equal to the readers, so the gate judges the value the runtime will use.
|
|
6
|
+
*/
|
|
7
|
+
export type SemanticCapValue = 'cloud' | 'local' | 'none';
|
|
8
|
+
export interface ProjectCaps {
|
|
9
|
+
semantic: SemanticCapValue;
|
|
10
|
+
ceiling: AutonomyCeiling;
|
|
11
|
+
}
|
|
12
|
+
export declare const NARROWEST_CAPS: ProjectCaps;
|
|
13
|
+
export declare function projectCapsOfText(text: string | null): ProjectCaps;
|
|
14
|
+
/** The caps `after` sets wider than `before` (an absent cap is its widest value, so removing a set cap is a raise). */
|
|
15
|
+
export declare function raisedCaps(before: ProjectCaps, after: ProjectCaps): string[];
|
|
16
|
+
export declare function capsAtWidest(c: ProjectCaps): boolean;
|
|
17
|
+
export declare function sameCaps(a: ProjectCaps, b: ProjectCaps): boolean;
|
|
18
|
+
/** The disk text of `<root>/ax.config.json`: `null` when absent, `undefined` when it cannot be read. */
|
|
19
|
+
export declare function projectConfigText(root: string): string | null | undefined;
|
|
20
|
+
/** The caps on disk; a file that cannot be read is the narrowest caps (nothing about it may be widened unseen). */
|
|
21
|
+
export declare function readProjectCaps(root: string): ProjectCaps;
|
|
@@ -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.NARROWEST_CAPS = void 0;
|
|
37
|
+
exports.projectCapsOfText = projectCapsOfText;
|
|
38
|
+
exports.raisedCaps = raisedCaps;
|
|
39
|
+
exports.capsAtWidest = capsAtWidest;
|
|
40
|
+
exports.sameCaps = sameCaps;
|
|
41
|
+
exports.projectConfigText = projectConfigText;
|
|
42
|
+
exports.readProjectCaps = readProjectCaps;
|
|
43
|
+
// @implements A-SPEC-476.3
|
|
44
|
+
const fs = __importStar(require("node:fs"));
|
|
45
|
+
const path = __importStar(require("node:path"));
|
|
46
|
+
const SEMANTIC_ORDER = ['none', 'local', 'cloud'];
|
|
47
|
+
const CEILING_ORDER = ['off', 'tests', 'no-gate', 'default'];
|
|
48
|
+
exports.NARROWEST_CAPS = { semantic: 'none', ceiling: 'off' };
|
|
49
|
+
function projectCapsOfText(text) {
|
|
50
|
+
if (text === null)
|
|
51
|
+
return { semantic: 'cloud', ceiling: 'default' };
|
|
52
|
+
let parsed;
|
|
53
|
+
try {
|
|
54
|
+
parsed = JSON.parse(text);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return { ...exports.NARROWEST_CAPS };
|
|
58
|
+
}
|
|
59
|
+
const obj = parsed !== null && typeof parsed === 'object' ? parsed : null;
|
|
60
|
+
return { semantic: semanticOf(obj), ceiling: ceilingOf(obj) };
|
|
61
|
+
}
|
|
62
|
+
function semanticOf(obj) {
|
|
63
|
+
if (obj === null || !('semantic' in obj))
|
|
64
|
+
return 'cloud';
|
|
65
|
+
const s = obj.semantic;
|
|
66
|
+
if (s === null || typeof s !== 'object' || Array.isArray(s))
|
|
67
|
+
return 'none';
|
|
68
|
+
if (!('maxTier' in s))
|
|
69
|
+
return 'cloud';
|
|
70
|
+
const v = s.maxTier;
|
|
71
|
+
return SEMANTIC_ORDER.includes(v) ? v : 'none';
|
|
72
|
+
}
|
|
73
|
+
// loadConfig deep-merges over the defaults: a root that is not an object, or no `autonomy`, keeps `default`; an
|
|
74
|
+
// `autonomy` object without `ceiling` keeps the default object's `default`; anything else not a known value is `off`.
|
|
75
|
+
function ceilingOf(obj) {
|
|
76
|
+
if (obj === null || Array.isArray(obj) || !('autonomy' in obj))
|
|
77
|
+
return 'default';
|
|
78
|
+
const a = obj.autonomy;
|
|
79
|
+
if (a === null || typeof a !== 'object')
|
|
80
|
+
return 'off';
|
|
81
|
+
if (!('ceiling' in a))
|
|
82
|
+
return 'default';
|
|
83
|
+
const v = a.ceiling;
|
|
84
|
+
return CEILING_ORDER.includes(v) ? v : 'off';
|
|
85
|
+
}
|
|
86
|
+
/** The caps `after` sets wider than `before` (an absent cap is its widest value, so removing a set cap is a raise). */
|
|
87
|
+
function raisedCaps(before, after) {
|
|
88
|
+
const out = [];
|
|
89
|
+
if (SEMANTIC_ORDER.indexOf(after.semantic) > SEMANTIC_ORDER.indexOf(before.semantic))
|
|
90
|
+
out.push(`semantic.maxTier ${before.semantic} → ${after.semantic}`);
|
|
91
|
+
if (CEILING_ORDER.indexOf(after.ceiling) > CEILING_ORDER.indexOf(before.ceiling))
|
|
92
|
+
out.push(`autonomy.ceiling ${before.ceiling} → ${after.ceiling}`);
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
function capsAtWidest(c) {
|
|
96
|
+
return c.semantic === 'cloud' && c.ceiling === 'default';
|
|
97
|
+
}
|
|
98
|
+
function sameCaps(a, b) {
|
|
99
|
+
return a.semantic === b.semantic && a.ceiling === b.ceiling;
|
|
100
|
+
}
|
|
101
|
+
/** The disk text of `<root>/ax.config.json`: `null` when absent, `undefined` when it cannot be read. */
|
|
102
|
+
function projectConfigText(root) {
|
|
103
|
+
try {
|
|
104
|
+
return fs.readFileSync(path.join(root, 'ax.config.json'), 'utf8');
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
return e.code === 'ENOENT' ? null : undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** The caps on disk; a file that cannot be read is the narrowest caps (nothing about it may be widened unseen). */
|
|
111
|
+
function readProjectCaps(root) {
|
|
112
|
+
const t = projectConfigText(root);
|
|
113
|
+
return t === undefined ? { ...exports.NARROWEST_CAPS } : projectCapsOfText(t);
|
|
114
|
+
}
|
|
@@ -24,7 +24,12 @@ export declare const DECISION_KINDS: ReadonlySet<string>;
|
|
|
24
24
|
* The line a refusal ends with to name its pending request and the operator command.
|
|
25
25
|
* @implements A-SPEC-134.2 — one wording for a request just filed and for one that was already pending.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @implements A-SPEC-770.12 — what a request is, for a person reading its refusal: ` · <kind> <target> 「<title>」`, or ''
|
|
29
|
+
* without a title (A-SPEC-770.1's bytes). Every field is flattened and bounded and loses `]`, so the bracket closes once.
|
|
30
|
+
*/
|
|
31
|
+
export declare function requestLabel(kind: string | undefined, target: string | undefined, title: string | undefined): string;
|
|
32
|
+
export declare function pendingRequestLine(id: string, kind?: string, root?: string, title?: string, target?: string): string;
|
|
28
33
|
export interface RefusalRecord {
|
|
29
34
|
event: 'requested';
|
|
30
35
|
id: string;
|
|
@@ -36,6 +41,8 @@ export interface RefusalRecord {
|
|
|
36
41
|
/** @implements A-SPEC-564.2 — the byte size of the deny feedback this refusal put back into the
|
|
37
42
|
* conversation (base reason + queue hint). Observation only; absent on legacy records. */
|
|
38
43
|
reasonBytes?: number;
|
|
44
|
+
/** @implements A-SPEC-779.2 — the run that filed it; absent outside a run. */
|
|
45
|
+
requester_run?: string;
|
|
39
46
|
}
|
|
40
47
|
export declare function refusalsFilename(replica: string): string;
|
|
41
48
|
/** Born split: there is no legacy single `refusals.jsonl` — the file did not exist before replicas did. */
|
|
@@ -70,6 +77,10 @@ export interface PendingRequest {
|
|
|
70
77
|
execution?: ExecutionContext;
|
|
71
78
|
subject?: string;
|
|
72
79
|
risk?: string;
|
|
80
|
+
/** @implements A-SPEC-770.12 — the spec's title as the first filing named it; display only. */
|
|
81
|
+
title?: string;
|
|
82
|
+
/** @implements A-SPEC-779.2 — the run that filed it, the only one that may withdraw it; absent outside a run. */
|
|
83
|
+
requesterRun?: string;
|
|
73
84
|
}
|
|
74
85
|
export interface QueueState {
|
|
75
86
|
pending: PendingRequest[];
|
|
@@ -91,8 +102,9 @@ export interface QueueState {
|
|
|
91
102
|
* retries of one blocked action, because the agent had no way to see that a human had said no.
|
|
92
103
|
* An invisible decision cannot stop a retry loop.
|
|
93
104
|
*/
|
|
105
|
+
/** @implements A-SPEC-779.2 — `withdrawn`: the filing run closed its own request; no operator decided it. */
|
|
94
106
|
decisions: Record<string, {
|
|
95
|
-
event: 'granted' | 'denied' | 'revoked';
|
|
107
|
+
event: 'granted' | 'denied' | 'revoked' | 'withdrawn';
|
|
96
108
|
reason?: string;
|
|
97
109
|
ts: string;
|
|
98
110
|
covered?: number;
|
|
@@ -100,6 +112,7 @@ export interface QueueState {
|
|
|
100
112
|
consumedTs?: string;
|
|
101
113
|
expires?: string;
|
|
102
114
|
actor?: string;
|
|
115
|
+
run?: string;
|
|
103
116
|
}>;
|
|
104
117
|
/**
|
|
105
118
|
* @implements A-SPEC-650
|
|
@@ -156,7 +169,8 @@ export declare function foldQueue(lines: string[], opts?: {
|
|
|
156
169
|
/** @implements A-SPEC-649 — what a request may say about its subject and risk, beyond kind/target/why. */
|
|
157
170
|
export interface RequestDetails {
|
|
158
171
|
subject?: string;
|
|
159
|
-
risk?: string;
|
|
172
|
+
risk?: string; /** @implements A-SPEC-770.12 */
|
|
173
|
+
title?: string;
|
|
160
174
|
}
|
|
161
175
|
export declare function enqueueApprovalRequest(root: string, req: {
|
|
162
176
|
kind: string;
|