@holmes-lab/holmes-kit 0.37.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +17 -2
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-status.js +2 -1
- package/dist/holmes/cli/approve.d.ts +1 -0
- package/dist/holmes/cli/approve.js +36 -4
- package/dist/holmes/cli/autonomy.d.ts +28 -0
- package/dist/holmes/cli/autonomy.js +62 -8
- package/dist/holmes/cli/doctor.js +12 -1
- package/dist/holmes/cli/index.js +64 -5
- package/dist/holmes/cli/mcp-processes.d.ts +32 -0
- package/dist/holmes/cli/mcp-processes.js +132 -0
- package/dist/holmes/cli/run-provision.d.ts +6 -0
- package/dist/holmes/cli/run-provision.js +114 -0
- package/dist/holmes/cli/run.d.ts +5 -0
- package/dist/holmes/cli/run.js +38 -6
- package/dist/holmes/cli/runtime-binding-approval.js +2 -3
- package/dist/holmes/governance/approval-queue.d.ts +12 -1
- package/dist/holmes/governance/approval-queue.js +23 -28
- package/dist/holmes/governance/autonomy.d.ts +3 -1
- package/dist/holmes/governance/autonomy.js +28 -2
- package/dist/holmes/governance/full-autonomy.d.ts +72 -0
- package/dist/holmes/governance/full-autonomy.js +308 -0
- package/dist/holmes/governance/tool-actions.js +2 -0
- package/dist/holmes/guardrail/operator-person.js +3 -2
- package/dist/holmes/guardrail/refusal-codes.js +19 -4
- package/dist/holmes/guardrail/risk-classifier.js +21 -3
- package/dist/holmes/guardrail/run-refusals.d.ts +6 -1
- package/dist/holmes/guardrail/run-refusals.js +19 -12
- package/dist/holmes/guardrail/run-stages.d.ts +5 -0
- package/dist/holmes/guardrail/run-stages.js +23 -3
- package/dist/holmes/guardrail/write-target.js +4 -1
- package/dist/holmes/hooks/pre-tool-use.d.ts +2 -0
- package/dist/holmes/hooks/pre-tool-use.js +88 -11
- package/dist/holmes/hooks/session-start.d.ts +5 -0
- package/dist/holmes/hooks/session-start.js +29 -1
- package/dist/holmes/hooks/stop.js +6 -4
- package/dist/holmes/mcp/elicit-approval.js +5 -6
- package/dist/holmes/mcp/handlers/approval-ask.d.ts +11 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +18 -3
- package/dist/holmes/mcp/handlers/review-verdict.js +3 -2
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +2 -0
- package/dist/holmes/mcp/handlers/spec-approval.js +23 -5
- package/dist/holmes/mcp/handlers/workspace-preflight.d.ts +5 -0
- package/dist/holmes/mcp/handlers/workspace-preflight.js +10 -2
- package/dist/holmes/mcp/handlers.d.ts +12 -0
- package/dist/holmes/mcp/handlers.js +25 -3
- package/dist/holmes/mcp/operator-recovery.d.ts +7 -2
- package/dist/holmes/mcp/operator-recovery.js +15 -58
- package/dist/holmes/mcp/server-staleness.d.ts +43 -0
- package/dist/holmes/mcp/server-staleness.js +158 -0
- package/dist/holmes/mcp/server.js +26 -2
- package/dist/holmes/mcp/tool-schemas.js +14 -1
- package/dist/holmes/project/workspace-preflight.d.ts +5 -0
- package/dist/holmes/project/workspace-preflight.js +24 -1
- package/dist/holmes/review/verdicts.d.ts +5 -0
- package/dist/holmes/review/verdicts.js +16 -1
- package/package.json +1 -1
- package/playbooks/promote-slice/PLAYBOOK.md +2 -1
|
@@ -37,8 +37,9 @@ exports.TRANSITION_CHECKS = void 0;
|
|
|
37
37
|
exports.applyStageGate = applyStageGate;
|
|
38
38
|
exports.applyRoleStage = applyRoleStage;
|
|
39
39
|
exports.currentStage = currentStage;
|
|
40
|
+
exports.reviewPolicyOf = reviewPolicyOf;
|
|
40
41
|
exports.transitionRun = transitionRun;
|
|
41
|
-
// @implements A-SPEC-781, A-SPEC-781.1, A-SPEC-774.19, A-SPEC-781.2
|
|
42
|
+
// @implements A-SPEC-781, A-SPEC-781.1, A-SPEC-774.19, A-SPEC-781.2, A-SPEC-102.10
|
|
42
43
|
/**
|
|
43
44
|
* @implements A-SPEC-781 — a run's SDLC stage is recorded state. Only the holder of the run's stop key (the
|
|
44
45
|
* orchestrator; the session inside the run never sees it) moves it, along the edges the project's machine declares,
|
|
@@ -133,6 +134,12 @@ function currentStage(main, runId, machine) {
|
|
|
133
134
|
}
|
|
134
135
|
return machine.order[0];
|
|
135
136
|
}
|
|
137
|
+
/** @implements A-SPEC-102.10 — the review policy recorded at run start; anything unreadable is no policy. */
|
|
138
|
+
function reviewPolicyOf(rec) {
|
|
139
|
+
const r = rec?.review;
|
|
140
|
+
const rounds = typeof r?.rounds === 'number' && Number.isInteger(r.rounds) && r.rounds >= 1 && r.rounds <= 20 ? r.rounds : undefined;
|
|
141
|
+
return { ...(rounds !== undefined ? { rounds } : {}), strict: r?.strict === true };
|
|
142
|
+
}
|
|
136
143
|
function transitionRun(main, runId, to, opts) {
|
|
137
144
|
const rec = (0, run_records_1.listRuns)(main).find((r) => r.run_id === runId);
|
|
138
145
|
if (!rec)
|
|
@@ -154,9 +161,22 @@ function transitionRun(main, runId, to, opts) {
|
|
|
154
161
|
const range = (0, verdicts_1.resolveRange)(rec.worktree, rec.base, 'HEAD');
|
|
155
162
|
if ('error' in range)
|
|
156
163
|
return { ok: false, reason: range.error };
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
// @implements A-SPEC-102.10 — the run's recorded policy: strict review, and a cap on failing rounds.
|
|
165
|
+
const policy = reviewPolicyOf(rec);
|
|
166
|
+
const g = (0, verdicts_1.gateRange)(rec.worktree, range.base, range.head, { strict: policy.strict });
|
|
167
|
+
if (!g.ok) {
|
|
168
|
+
const capRounds = policy.rounds ?? null;
|
|
169
|
+
const failed = capRounds !== null ? (0, verdicts_1.failingRounds)(main, rec.base) : [];
|
|
170
|
+
if (capRounds !== null && failed.length >= capRounds) {
|
|
171
|
+
const findings = (failed[failed.length - 1].findings ?? []).slice(0, 50).map((f) => String(f).slice(0, 300));
|
|
172
|
+
(0, run_refusals_1.appendRunEvent)(main, runId, {
|
|
173
|
+
ts: (opts.now ? opts.now() : new Date()).toISOString(), event: 'review_unresolved', count: failed.length, cap: capRounds,
|
|
174
|
+
range: `${range.base}..${range.head}`, findings,
|
|
175
|
+
});
|
|
176
|
+
return { ok: false, reason: `this run stopped: review.unresolved — ${failed.length} failing independent review round(s) reached the cap of ${capRounds}; unresolved: ${findings.slice(0, 3).join(' | ') || 'none named'} — ${to} is refused` };
|
|
177
|
+
}
|
|
159
178
|
return { ok: false, reason: `${to} needs an independent passing review of ${range.base}..${range.head}: ${g.reasons.join('; ')}` };
|
|
179
|
+
}
|
|
160
180
|
}
|
|
161
181
|
// @implements A-SPEC-781.2 — the edge's conditions: a name nobody checks refuses; a slot is recorded as unchecked.
|
|
162
182
|
const edge = `${from}->${to}`;
|
|
@@ -73,7 +73,7 @@ exports.commandBases = commandBases;
|
|
|
73
73
|
exports.shellSegments = shellSegments;
|
|
74
74
|
exports.resolvesInside = resolvesInside;
|
|
75
75
|
exports.foreignMcpPaths = foreignMcpPaths;
|
|
76
|
-
// @implements A-SPEC-728, A-SPEC-733, A-SPEC-163, A-SPEC-627, A-SPEC-768.2, A-SPEC-768.3, A-SPEC-163.8, A-SPEC-476.3, A-SPEC-476.7
|
|
76
|
+
// @implements A-SPEC-728, A-SPEC-733, A-SPEC-163, A-SPEC-627, A-SPEC-768.2, A-SPEC-768.3, A-SPEC-163.8, A-SPEC-476.3, A-SPEC-476.7, A-SPEC-792.3
|
|
77
77
|
const fs = __importStar(require("node:fs"));
|
|
78
78
|
const path = __importStar(require("node:path"));
|
|
79
79
|
const os = __importStar(require("node:os"));
|
|
@@ -863,6 +863,9 @@ function wiringDirs(root, env, home) {
|
|
|
863
863
|
const out = [
|
|
864
864
|
{ dir: path.join(home, '.claude'), name: SETTINGS_NAME, known: ['settings.json', 'settings.local.json'], label: (n) => `~/.claude/${n}`, dirIsWiring: true },
|
|
865
865
|
...codexHomes(env, home).map((dir) => ({ dir, name: /^(?:config\.toml|hooks\.json)$/i, known: ['config.toml', 'hooks.json'], label: (n) => `Codex user ${n}`, dirIsWiring: true })),
|
|
866
|
+
// @implements A-SPEC-792.3 — the full autonomy profile: written by the operator CLI only; ~/.holmes itself is not
|
|
867
|
+
// wiring (its update cache and runtime copies keep their own rules).
|
|
868
|
+
{ dir: path.join(home, '.holmes'), name: /^full-autonomy\.json$/i, known: ['full-autonomy.json'], label: () => '~/.holmes/full-autonomy.json', dirIsWiring: false },
|
|
866
869
|
];
|
|
867
870
|
if (root !== null) {
|
|
868
871
|
out.push({ dir: path.join(root, '.claude'), name: SETTINGS_NAME, known: ['settings.json', 'settings.local.json'], label: (n) => `.claude/${n}`, dirIsWiring: true }, { dir: root, name: /^\.mcp\.json$/i, known: ['.mcp.json'], label: () => '.mcp.json', dirIsWiring: false }, ...(capsOutOfScope ? [] : [{ dir: root, name: /^ax\.config\.json$/i, known: [exports.PROJECT_CAPS_LABEL], label: () => exports.PROJECT_CAPS_LABEL, dirIsWiring: false }]), { dir: path.join(root, '.agents'), name: /^(?:hooks|mcp_config)\.json$/i, known: ['hooks.json', 'mcp_config.json'], label: (n) => `.agents/${n}`, dirIsWiring: true }, { dir: path.join(root, '.codex'), name: /^(?:config\.toml|mcp_config\.json)$/i, known: ['config.toml', 'mcp_config.json'], label: (n) => `.codex/${n}`, dirIsWiring: true },
|
|
@@ -286,6 +286,8 @@ export declare function evaluateHook(input: {
|
|
|
286
286
|
approvals: Approval[];
|
|
287
287
|
};
|
|
288
288
|
onApprovalsSpent?: (approvals: Approval[]) => void;
|
|
289
|
+
/** @implements A-SPEC-792.5 — the home whose full autonomy profile applies (default os.homedir()); a test seam. */
|
|
290
|
+
home?: string;
|
|
289
291
|
}): {
|
|
290
292
|
permissionDecision: 'allow' | 'deny';
|
|
291
293
|
permissionDecisionReason?: string;
|
|
@@ -53,7 +53,7 @@ exports.gateErrorDecision = gateErrorDecision;
|
|
|
53
53
|
exports.wiredSpecsDir = wiredSpecsDir;
|
|
54
54
|
exports.evaluateHook = evaluateHook;
|
|
55
55
|
exports.readSpecsSync = readSpecsSync;
|
|
56
|
-
// @implements A-SPEC-476.7, A-SPEC-226.3, A-SPEC-774.28, A-SPEC-747.4, A-SPEC-747.7, A-SPEC-774.23, A-SPEC-753.3, A-SPEC-773, A-SPEC-773.1, A-SPEC-773.2, A-SPEC-134.2,A-SPEC-278,A-SPEC-733, A-SPEC-734, A-SPEC-747, A-SPEC-477.1, A-SPEC-753, A-SPEC-163.7, A-SPEC-768.2, A-SPEC-772.1, A-SPEC-747.3, A-SPEC-774.26, A-SPEC-163.8, A-SPEC-790, A-SPEC-790.2, A-SPEC-790.7, A-SPEC-790.8
|
|
56
|
+
// @implements A-SPEC-476.7, A-SPEC-226.3, A-SPEC-774.28, A-SPEC-747.4, A-SPEC-747.7, A-SPEC-774.23, A-SPEC-753.3, A-SPEC-773, A-SPEC-773.1, A-SPEC-773.2, A-SPEC-134.2,A-SPEC-278,A-SPEC-733, A-SPEC-734, A-SPEC-747, A-SPEC-477.1, A-SPEC-753, A-SPEC-163.7, A-SPEC-768.2, A-SPEC-772.1, A-SPEC-747.3, A-SPEC-774.26, A-SPEC-163.8, A-SPEC-790, A-SPEC-790.2, A-SPEC-790.7, A-SPEC-790.8, A-SPEC-792.5
|
|
57
57
|
const powershell_shell_1 = require("../guardrail/powershell-shell");
|
|
58
58
|
const shell_argument_roles_1 = require("../guardrail/shell-argument-roles");
|
|
59
59
|
// @implements A-SPEC-549.3 — the hook's deny reasons are English here; hooks-english.test.ts drives
|
|
@@ -64,6 +64,8 @@ const shell_argument_roles_1 = require("../guardrail/shell-argument-roles");
|
|
|
64
64
|
const registry_1 = require("../messages/registry");
|
|
65
65
|
const root_1 = require("../project/root");
|
|
66
66
|
const scratch_root_1 = require("../project/scratch-root");
|
|
67
|
+
const crypto = __importStar(require("node:crypto"));
|
|
68
|
+
const full_autonomy_1 = require("../governance/full-autonomy"); // @implements A-SPEC-792.5
|
|
67
69
|
const fs = __importStar(require("node:fs"));
|
|
68
70
|
const path = __importStar(require("node:path"));
|
|
69
71
|
const os = __importStar(require("node:os"));
|
|
@@ -1733,6 +1735,22 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
1733
1735
|
}
|
|
1734
1736
|
// @implements A-SPEC-133 — resolved once so every gate in this call shares one timestamp.
|
|
1735
1737
|
const nowTs = opts?.now ?? new Date().toISOString();
|
|
1738
|
+
// @implements A-SPEC-792.5 — the full autonomy profile covering this project, read at most once per call. Under it no
|
|
1739
|
+
// refusal files a request: every place that would queue one answers with the route instead.
|
|
1740
|
+
let fullCache;
|
|
1741
|
+
const fullEntry = () => {
|
|
1742
|
+
if (fullCache === undefined) {
|
|
1743
|
+
try {
|
|
1744
|
+
const s = (0, full_autonomy_1.readFullProfile)(opts.home ?? os.homedir(), opts.projectRoot);
|
|
1745
|
+
fullCache = s.active ? s.entry : null;
|
|
1746
|
+
}
|
|
1747
|
+
catch {
|
|
1748
|
+
fullCache = null;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
return fullCache;
|
|
1752
|
+
};
|
|
1753
|
+
const hintOrRoute = (req, extra) => (fullEntry() !== null ? (0, full_autonomy_1.fullModeRefusalTail)(req.kind) : (0, approval_queue_1.queueHint)(opts.projectRoot, req, extra));
|
|
1736
1754
|
// @implements A-SPEC-125.4
|
|
1737
1755
|
// Bash/shell risk gate: this branch runs BEFORE the Write/Edit phaseCheck logic below and
|
|
1738
1756
|
// is intentionally fail-CLOSED — a classifier throw on the Bash surface denies, never
|
|
@@ -1822,14 +1840,41 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
1822
1840
|
// @implements A-SPEC-244 — the refusal itself files the review request. The queue kind is the
|
|
1823
1841
|
// approval SCOPE kind ('shell'), so the reviewing CLI can mint a covering grant mechanically.
|
|
1824
1842
|
hardHitlCovered = covers;
|
|
1825
|
-
|
|
1843
|
+
const full = covers ? null : fullEntry();
|
|
1844
|
+
if (full !== null) {
|
|
1845
|
+
// @implements A-SPEC-792.5 — a full scope approves a scoped destructive act after a recovery point and refuses
|
|
1846
|
+
// every other act at once; nothing is filed, so a run never waits on it.
|
|
1847
|
+
const v = (0, full_autonomy_1.fullModeShellVerdict)({ command, reasons: assessment.reasons, cwd: shellBase, workspace: opts.projectRoot, scratchRoot: (0, scratch_root_1.trustedScratchRoot)(), entry: full });
|
|
1848
|
+
if (v.outcome === 'refuse')
|
|
1849
|
+
return deny(`refused${(0, full_autonomy_1.fullModeRefusalTail)('shell', v.route)}`);
|
|
1850
|
+
let recoveryRef;
|
|
1851
|
+
if (v.recovery) {
|
|
1852
|
+
const r = (0, full_autonomy_1.writeRecoveryRef)(opts.projectRoot, nowTs);
|
|
1853
|
+
if ('error' in r)
|
|
1854
|
+
return deny(`refused${(0, full_autonomy_1.fullModeRefusalTail)('shell', r.error)}`);
|
|
1855
|
+
recoveryRef = r.ref;
|
|
1856
|
+
}
|
|
1857
|
+
try {
|
|
1858
|
+
new ledger_store_1.FileLedgerStore(path.join(opts.projectRoot, '.ax', 'ledger')).append({
|
|
1859
|
+
ts: nowTs, actor: `full-autonomy:${full.scope}`, kind: 'full-autonomy-approved',
|
|
1860
|
+
summary: `hard-hitl shell act approved under full autonomy${recoveryRef ? ` (recovery ${recoveryRef})` : ''}`.slice(0, 200),
|
|
1861
|
+
inputs: [crypto.createHash('sha256').update(command).digest('hex')],
|
|
1862
|
+
rationale: assessment.reasons.join('; ').slice(0, 300),
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
catch { /* the act is approved; the audit row is best effort like the other gate records */ }
|
|
1866
|
+
hardHitlCovered = true;
|
|
1867
|
+
}
|
|
1868
|
+
else if (!covers) {
|
|
1826
1869
|
// @implements A-SPEC-564.2 — the base reason's length rides along so the refusal record
|
|
1827
1870
|
// knows the FULL feedback cost (base + hint), not just the hint's half.
|
|
1828
1871
|
const base = 'requires an approval that covers this command';
|
|
1829
1872
|
return deny(base
|
|
1830
1873
|
+ (0, approval_queue_1.queueHint)(opts.projectRoot, { kind: 'shell', target: command, why: assessment.reasons.join('; ') }, { baseReasonBytes: base.length }));
|
|
1831
1874
|
}
|
|
1832
|
-
|
|
1875
|
+
else {
|
|
1876
|
+
pendingApprovals.push(resolved);
|
|
1877
|
+
}
|
|
1833
1878
|
}
|
|
1834
1879
|
// Bash BYPASS gates (adversarial review: `cat > evil.ts` created ungoverned files, `echo x >
|
|
1835
1880
|
// .claude/settings.json` forged hook config, and `echo $HOLMES_LEDGER_KEY` harvested the very
|
|
@@ -1916,7 +1961,10 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
1916
1961
|
// JSON key — was refused as an environment dump. The remaining alternatives
|
|
1917
1962
|
// (`process.env`, `os.environ`, `ENVIRON`, `getenv`) name real environment access; Perl's
|
|
1918
1963
|
// `%ENV`/`$ENV{…}` are the loss, and they are rarer than the false positives were.
|
|
1919
|
-
|
|
1964
|
+
// @implements A-SPEC-163.9 — `ENVIRON` under /i matched "environ" inside any word: G0 round 5 refused
|
|
1965
|
+
// `pytest … tests/test_environment.py` as a dump. It stands as a whole identifier now (environ, environb,
|
|
1966
|
+
// ENVIRON), which keeps `o.environ` after `import os as o`, `os.environb` and getattr(os, 'environ').
|
|
1967
|
+
tailAfterFirst(command, /\n/, /\b(?:node|python[0-9.]*|ruby|perl|deno|bun|php|awk|gawk)\b/i, /process\s*\.\s*env|os\s*\.\s*environ|from\s+os\s+import\s+environ|(?<![A-Za-z0-9_])environb?(?![A-Za-z0-9_])|getenv/i) ||
|
|
1920
1968
|
// @implements A-SPEC-163
|
|
1921
1969
|
// Perl's `$ENV{…}` and Ruby's bare `ENV` still have to be caught, but CASE-SENSITIVELY and
|
|
1922
1970
|
// not after a dot. The old alternative was `\bENV\b` under /i, which also matched `s.env` —
|
|
@@ -1959,7 +2007,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
1959
2007
|
: '[Holmes-Kit] command reads or dumps process environment (holds out-of-band approval secrets) — requires operator approval';
|
|
1960
2008
|
const resolved = resolveForCommand('config-write');
|
|
1961
2009
|
if (!resolved) {
|
|
1962
|
-
let hint = (
|
|
2010
|
+
let hint = hintOrRoute({ kind: 'config-write', target: command, why: reason }); // A-SPEC-792.5
|
|
1963
2011
|
// The queue deliberately suppresses duplicate writes, not the pending operator decision.
|
|
1964
2012
|
const id = (0, approval_queue_1.approvalRequestId)('config-write', command);
|
|
1965
2013
|
if (!hint && (0, approval_queue_1.readQueue)(opts.projectRoot).pending.some((request) => request.id === id)) {
|
|
@@ -2173,7 +2221,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
2173
2221
|
return null;
|
|
2174
2222
|
}
|
|
2175
2223
|
return { permissionDecision: 'deny', permissionDecisionReason: `[Holmes-Kit] ${why} — an out-of-band approval that includes config-write is required (A-SPEC-728)`
|
|
2176
|
-
+ (
|
|
2224
|
+
+ hintOrRoute({ kind: 'config-write', target: command, why }) }; // A-SPEC-792.5
|
|
2177
2225
|
};
|
|
2178
2226
|
let configWriteLifted = false;
|
|
2179
2227
|
if (userCfgKind) {
|
|
@@ -2675,7 +2723,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
2675
2723
|
const userResolved = (0, approval_grants_1.resolveApproval)(opts.projectRoot, weApproval, { kind: 'config-write', target: norm }, nowTs);
|
|
2676
2724
|
if (userResolved === undefined) {
|
|
2677
2725
|
return { permissionDecision: 'deny', permissionDecisionReason: `[Holmes-Kit] ${userKind} is a hook/approval config — it can forge HOLMES_APPROVAL or turn governance off, so an out-of-band approval that includes config-write is required`
|
|
2678
|
-
+ (
|
|
2726
|
+
+ hintOrRoute({ kind: 'config-write', target: norm, why: `writing ${userKind}` }) }; // A-SPEC-792.5
|
|
2679
2727
|
}
|
|
2680
2728
|
if (userResolved.source === 'grant' && userResolved.approval.nonce)
|
|
2681
2729
|
(0, approval_grants_1.consumeGrantFile)(opts.projectRoot, userResolved.approval.nonce);
|
|
@@ -2721,7 +2769,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
2721
2769
|
permissionDecision: 'deny',
|
|
2722
2770
|
permissionDecisionReason: '[Holmes-Kit] the role policy (.ax/roles/) defines the very authority this gate enforces —'
|
|
2723
2771
|
+ ' an agent cannot change it itself. An out-of-band approval that includes config-write is required.'
|
|
2724
|
-
+ (
|
|
2772
|
+
+ hintOrRoute({ kind: 'config-write', target: norm, why: 'writing the role policy (.ax/roles/)' }), // A-SPEC-792.5
|
|
2725
2773
|
};
|
|
2726
2774
|
}
|
|
2727
2775
|
if (rolesResolved.source === 'grant' && rolesResolved.approval.nonce)
|
|
@@ -2742,7 +2790,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
2742
2790
|
// wording false as harnesses grow (REQ-155: a diagnosis that points at the wrong file has negative value).
|
|
2743
2791
|
const kindName = configKind ?? (0, write_target_2.protectedKindOf)(opts.projectRoot, norm) ?? 'config';
|
|
2744
2792
|
return { permissionDecision: 'deny', permissionDecisionReason: `[Holmes-Kit] ${kindName} is a hook/approval config — it can forge HOLMES_APPROVAL or turn governance off, so an out-of-band approval that includes config-write is required`
|
|
2745
|
-
+ (
|
|
2793
|
+
+ hintOrRoute({ kind: 'config-write', target: norm, why: `writing ${kindName}` }) }; // A-SPEC-792.5
|
|
2746
2794
|
}
|
|
2747
2795
|
if (cfgResolved.source === 'grant' && cfgResolved.approval.nonce)
|
|
2748
2796
|
(0, approval_grants_1.consumeGrantFile)(opts.projectRoot, cfgResolved.approval.nonce);
|
|
@@ -2759,7 +2807,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
2759
2807
|
const capsResolved = (0, approval_grants_1.resolveApproval)(opts.projectRoot, weApproval, { kind: 'config-write', target: norm }, nowTs);
|
|
2760
2808
|
if (capsResolved === undefined) {
|
|
2761
2809
|
return { permissionDecision: 'deny', permissionDecisionReason: `[Holmes-Kit] this write raises or removes a project cap in ax.config.json (${capsAct}) — a cap narrows this agent, so only the owner lifts it: an out-of-band approval that includes config-write is required (A-SPEC-476.3)`
|
|
2762
|
-
+ (
|
|
2810
|
+
+ hintOrRoute({ kind: 'config-write', target: norm, why: `raising a project cap (${capsAct})` }) }; // A-SPEC-792.5
|
|
2763
2811
|
}
|
|
2764
2812
|
if (capsResolved.source === 'grant' && capsResolved.approval.nonce)
|
|
2765
2813
|
(0, approval_grants_1.consumeGrantFile)(opts.projectRoot, capsResolved.approval.nonce);
|
|
@@ -2845,6 +2893,35 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
2845
2893
|
permissionDecisionReason: registry_1.MESSAGES.SEAL_APPROVED_SPEC_MUTATION(path.basename(p, '.md'), undefined, 'A-SPEC-132'),
|
|
2846
2894
|
};
|
|
2847
2895
|
}
|
|
2896
|
+
// @implements A-SPEC-792.9 — a write that would leave the spec unreadable is refused with the parse error, whatever
|
|
2897
|
+
// approval is held. G0 HB-r5: a Write broke REQ-100's YAML, the repair Edit was then refused as a new REQ (below),
|
|
2898
|
+
// and the run ended asking a person. A file already unreadable on disk is judged as before.
|
|
2899
|
+
{
|
|
2900
|
+
let disk = null;
|
|
2901
|
+
try {
|
|
2902
|
+
disk = fs.existsSync(p) ? fs.readFileSync(p, 'utf8') : null;
|
|
2903
|
+
}
|
|
2904
|
+
catch {
|
|
2905
|
+
disk = null;
|
|
2906
|
+
}
|
|
2907
|
+
const parseError = (text) => {
|
|
2908
|
+
try {
|
|
2909
|
+
(0, spec_parser_1.parseSpec)(text);
|
|
2910
|
+
return null;
|
|
2911
|
+
}
|
|
2912
|
+
catch (e) {
|
|
2913
|
+
return String(e.message ?? e).split('\n')[0];
|
|
2914
|
+
}
|
|
2915
|
+
};
|
|
2916
|
+
const edited = editedResult(disk, input.tool_input);
|
|
2917
|
+
const broken = typeof edited === 'string' ? parseError(edited) : null;
|
|
2918
|
+
if (broken !== null && (disk === null || parseError(disk) === null)) {
|
|
2919
|
+
return {
|
|
2920
|
+
permissionDecision: 'deny',
|
|
2921
|
+
permissionDecisionReason: `[Holmes-Kit] the write would leave ${path.basename(p, '.md')} unreadable to the spec store (${broken}) — nothing was written; fix the frontmatter in this same write (a value holding ' or : goes in double quotes, or in a >- block)`,
|
|
2922
|
+
};
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2848
2925
|
// @implements A-SPEC-729 (round 4) — a NEW REQ enters the store only through spec_create(type=REQ)
|
|
2849
2926
|
// or spec_slice_init, which spend ledger-issued triage evidence. A hand-written REQ file walked
|
|
2850
2927
|
// around that intake entirely and could then be sealed (measured on 179b435b).
|
|
@@ -3249,7 +3326,7 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
3249
3326
|
if (debt && debt.length > 0 && !cureOnly
|
|
3250
3327
|
&& (0, approval_grants_1.resolveApproval)(projectRoot, weApproval, { kind: 'code-write', target: relPath }, nowTs) === undefined) {
|
|
3251
3328
|
const why = `code write under constitution debt (${debt.join(', ')})`;
|
|
3252
|
-
let hint = (
|
|
3329
|
+
let hint = hintOrRoute({ kind: 'code-write', target: relPath, why }); // A-SPEC-792.5
|
|
3253
3330
|
// @implements A-SPEC-134.2 — a decision-kind request that is already pending is not written again, so the
|
|
3254
3331
|
// hint is empty for it. The refusal still names that request; "could not persist" is for a queue that
|
|
3255
3332
|
// really could not be written.
|
|
@@ -30,4 +30,9 @@ export declare function buildSessionStartOutput(input: SessionStartInput): Sessi
|
|
|
30
30
|
* `upgrade`/`init --force`. Forward-drift + opt-out judgment is the pure `repinDecision`; every
|
|
31
31
|
* failure returns '' (fail-open — a banner is never a gate).
|
|
32
32
|
*/
|
|
33
|
+
/**
|
|
34
|
+
* @implements A-SPEC-251.5 — one line when a holmes-kit MCP server running from this workspace's wired node install
|
|
35
|
+
* started before that install was upgraded. Fail-open: '' on any failure, never a gate.
|
|
36
|
+
*/
|
|
37
|
+
export declare function staleWiredServerLine(cwd: string): string;
|
|
33
38
|
export declare function driftNudge(cwd: string, installed: string, env: NodeJS.ProcessEnv): string;
|
|
@@ -35,8 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.detectInstallMode = detectInstallMode;
|
|
37
37
|
exports.buildSessionStartOutput = buildSessionStartOutput;
|
|
38
|
+
exports.staleWiredServerLine = staleWiredServerLine;
|
|
38
39
|
exports.driftNudge = driftNudge;
|
|
39
|
-
// @implements A-SPEC-531.2, A-SPEC-734, A-SPEC-476.1
|
|
40
|
+
// @implements A-SPEC-531.2, A-SPEC-734, A-SPEC-476.1, A-SPEC-251.5
|
|
40
41
|
// The SessionStart banner hook. It emits the intro (+ optional update notice) as additionalContext,
|
|
41
42
|
// which Claude Code delivers to BOTH the human transcript and the agent context — the "human and
|
|
42
43
|
// agent" delivery REQ-531 asks for. The update refresh is a DETACHED, fire-and-forget child so the
|
|
@@ -86,6 +87,26 @@ function pkgVersion() {
|
|
|
86
87
|
* `upgrade`/`init --force`. Forward-drift + opt-out judgment is the pure `repinDecision`; every
|
|
87
88
|
* failure returns '' (fail-open — a banner is never a gate).
|
|
88
89
|
*/
|
|
90
|
+
/**
|
|
91
|
+
* @implements A-SPEC-251.5 — one line when a holmes-kit MCP server running from this workspace's wired node install
|
|
92
|
+
* started before that install was upgraded. Fail-open: '' on any failure, never a gate.
|
|
93
|
+
*/
|
|
94
|
+
function staleWiredServerLine(cwd) {
|
|
95
|
+
try {
|
|
96
|
+
const mcp = JSON.parse(fs.readFileSync(path.join(cwd, '.mcp.json'), 'utf8'));
|
|
97
|
+
const entry = mcp.mcpServers?.['holmes-kit'];
|
|
98
|
+
const bin = entry?.command === 'node' && typeof entry.args?.[0] === 'string' ? entry.args[0] : null;
|
|
99
|
+
if (bin === null || !/[\\/]bin[\\/]holmes-mcp\.js$/.test(bin))
|
|
100
|
+
return '';
|
|
101
|
+
const wiredRoot = path.dirname(path.dirname(path.resolve(cwd, bin)));
|
|
102
|
+
const { listProcessRows, staleMcpServers, readPackageInstall, mcpProcessBannerLine } = require('../cli/mcp-processes');
|
|
103
|
+
const rows = listProcessRows();
|
|
104
|
+
return rows === null ? '' : mcpProcessBannerLine(staleMcpServers(rows, readPackageInstall), wiredRoot);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return '';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
89
110
|
function driftNudge(cwd, installed, env) {
|
|
90
111
|
try {
|
|
91
112
|
const { mcpLaunchVersion } = require('../cli/mcp-version');
|
|
@@ -182,6 +203,13 @@ if (require.main === module) {
|
|
|
182
203
|
out.hookSpecificOutput.additionalContext += notice;
|
|
183
204
|
}
|
|
184
205
|
catch { /* the banner is never a gate */ }
|
|
206
|
+
// @implements A-SPEC-251.5 — the wiring can match while a server from the wired install still runs older code.
|
|
207
|
+
try {
|
|
208
|
+
const line = staleWiredServerLine(process.cwd());
|
|
209
|
+
if (line)
|
|
210
|
+
out.hookSpecificOutput.additionalContext += '\n' + line;
|
|
211
|
+
}
|
|
212
|
+
catch { /* the banner is never a gate */ }
|
|
185
213
|
// @implements A-SPEC-554.1 — remind the human of the current autonomy posture (surface only, the
|
|
186
214
|
// headless hook never decides), and clean up an expired/invalid session marker. Fail-open.
|
|
187
215
|
try {
|
|
@@ -65,7 +65,7 @@ exports.collectForbiddenEdgeJudgement = collectForbiddenEdgeJudgement;
|
|
|
65
65
|
exports.stopSharedScan = stopSharedScan;
|
|
66
66
|
exports.scanCodeCycles = scanCodeCycles;
|
|
67
67
|
exports.writeGuardCount = writeGuardCount;
|
|
68
|
-
// @implements A-SPEC-734, A-SPEC-772.1, A-SPEC-770.3, A-SPEC-770.7, A-SPEC-774.21, A-SPEC-778.1, A-SPEC-476.1
|
|
68
|
+
// @implements A-SPEC-734, A-SPEC-772.1, A-SPEC-770.3, A-SPEC-770.7, A-SPEC-774.21, A-SPEC-778.1, A-SPEC-476.1, A-SPEC-792.1, A-SPEC-102.10
|
|
69
69
|
// @implements A-SPEC-769.9, A-SPEC-769.10, A-SPEC-769.11
|
|
70
70
|
const fs = __importStar(require("node:fs"));
|
|
71
71
|
// @implements A-SPEC-549.3 — evaluateStop's messages are English here; the Hangul-absence guard
|
|
@@ -468,7 +468,9 @@ function runReviewGate(root, env, cwd, sessionId) {
|
|
|
468
468
|
return cannot(`the range ${rec.base}..HEAD does not resolve (${range.error})`, rec.base);
|
|
469
469
|
if (range.head === range.base)
|
|
470
470
|
return undefined;
|
|
471
|
-
|
|
471
|
+
// @implements A-SPEC-102.10 — a strict run is judged strictly at Stop too.
|
|
472
|
+
const { reviewPolicyOf } = require('../guardrail/run-stages');
|
|
473
|
+
const g = gateRange(rec.worktree, range.base, range.head, { strict: reviewPolicyOf(rec).strict });
|
|
472
474
|
return g.ok ? undefined : { base: range.base, head: range.head, reasons: g.reasons };
|
|
473
475
|
}
|
|
474
476
|
catch (e) {
|
|
@@ -1009,7 +1011,7 @@ function stopBlockText(violations, pending, launcher) {
|
|
|
1009
1011
|
: v.article === 'ART-7' ? v.findingId : undefined;
|
|
1010
1012
|
const request = subject === undefined ? undefined : requestFor.get(subject);
|
|
1011
1013
|
if (request !== undefined) {
|
|
1012
|
-
operator.push(`${line} — request ${request} is pending: the operator decides it
|
|
1014
|
+
operator.push(`${line} — request ${request} is pending: the operator decides it in the session's approval dialog (approval_ask with id "${request}")`); // A-SPEC-792.1
|
|
1013
1015
|
}
|
|
1014
1016
|
else if (v.article === 'ART-4') {
|
|
1015
1017
|
session.push(`${line} — anchor real covering tests, or, when the design is withdrawn, retire the spec with spec_retire`);
|
|
@@ -1878,7 +1880,7 @@ if (require.main === module) {
|
|
|
1878
1880
|
else if (ackWaiting.length > 0) {
|
|
1879
1881
|
// @implements A-SPEC-247 — acknowledged, not clean: name what is waiting so the user sees
|
|
1880
1882
|
// the standing approval debt exactly once, and the agent knows the ball is not in its court.
|
|
1881
|
-
process.stderr.write(`[Holmes-Kit] awaiting approval — items waiting on the owner's decision: ${ackWaiting.join(', ')}.
|
|
1883
|
+
process.stderr.write(`[Holmes-Kit] awaiting approval — items waiting on the owner's decision: ${ackWaiting.join(', ')}. The person decides each in the session's approval form (approval_ask with its id). (This debt does not re-block.)\n`); // A-SPEC-792.1
|
|
1882
1884
|
}
|
|
1883
1885
|
else if (guard.capped) {
|
|
1884
1886
|
process.stderr.write(`[Holmes-Kit] governance gate YIELDING after ${exports.MAX_CONSECUTIVE_BLOCKS} consecutive blocks — issues remain UNRESOLVED:\n${out.reason ?? ''}\n`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// @implements A-SPEC-718.2, A-SPEC-718, A-SPEC-263.1, A-SPEC-732, A-SPEC-770.3, A-SPEC-770.6, A-SPEC-792.1
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.MAX_PRESENTATIONS = exports.WAIT_FOR_PERSON_MS = exports.ELICIT_TIMEOUT_MS = exports.ELICITABLE_KINDS = void 0;
|
|
4
5
|
exports.elicitationDisabled = elicitationDisabled;
|
|
@@ -9,8 +10,6 @@ exports.buildDecisionForm = buildDecisionForm;
|
|
|
9
10
|
exports.buildReasonForm = buildReasonForm;
|
|
10
11
|
exports.runElicitFlow = runElicitFlow;
|
|
11
12
|
exports.interpretElicitResult = interpretElicitResult;
|
|
12
|
-
// @implements A-SPEC-718.2, A-SPEC-718, A-SPEC-263.1, A-SPEC-732, A-SPEC-770.3, A-SPEC-770.6
|
|
13
|
-
const npx_bin_1 = require("../project/npx-bin");
|
|
14
13
|
/**
|
|
15
14
|
* The decision comes INTO the session (REQ-263): an approval-shaped refusal (spec_approve without a
|
|
16
15
|
* covering HOLMES_APPROVAL) becomes an in-session question when the client advertises the MCP
|
|
@@ -94,7 +93,7 @@ function classifyElicitError(e, timeoutMs = exports.ELICIT_TIMEOUT_MS) {
|
|
|
94
93
|
* Template-owned text with no interpolated attacker data.
|
|
95
94
|
*/
|
|
96
95
|
function expiredNotice(waitedMs) {
|
|
97
|
-
return `[세션 승인 다이얼로그 만료 — ${Math.round(waitedMs / 1000)}초 무응답] 요청은 승인 큐로 회송되었습니다. 결정:
|
|
96
|
+
return `[세션 승인 다이얼로그 만료 — ${Math.round(waitedMs / 1000)}초 무응답] 요청은 승인 큐로 회송되었습니다. 결정: 에이전트가 approval_ask 로 다시 묻습니다. `;
|
|
98
97
|
}
|
|
99
98
|
// FLATTEN attacker-influenced text (round-1): the model chooses spec titles and finding ids, and
|
|
100
99
|
// interpolating them raw let a crafted title inject fake lines ("[시스템] … approve.") into the
|
|
@@ -115,8 +114,8 @@ function buildDecisionForm(req, attempt, timeoutMs) {
|
|
|
115
114
|
// @implements A-SPEC-718.2 — one outcome for silence, in every mode: the request returns to the queue.
|
|
116
115
|
// @implements A-SPEC-718.6 — a form that waits for the person says so instead of counting seconds.
|
|
117
116
|
const timeoutNotice = timeoutMs >= exports.WAIT_FOR_PERSON_MS
|
|
118
|
-
? `⏱ 결정할 때까지 기다립니다 — 결정 없이 세션이 끝나면 요청은 승인 큐에
|
|
119
|
-
: `⏱ ${timeoutMs / 1000}초 내 미결정 시 승인 큐로 회송됩니다(
|
|
117
|
+
? `⏱ 결정할 때까지 기다립니다 — 결정 없이 세션이 끝나면 요청은 승인 큐에 남고, 에이전트가 approval_ask 로 다시 물을 수 있습니다.`
|
|
118
|
+
: `⏱ ${timeoutMs / 1000}초 내 미결정 시 승인 큐로 회송됩니다(에이전트가 approval_ask 로 다시 물을 수 있습니다).`;
|
|
120
119
|
return {
|
|
121
120
|
// @implements A-SPEC-497.1 — the forewarning is the LAST line and template-owned: it survives a
|
|
122
121
|
// cap-filling summary (appended after the caps) and tells the human, before the clock runs out,
|
|
@@ -223,7 +222,7 @@ function interpretElicitResult(r) {
|
|
|
223
222
|
// @implements A-SPEC-732 — the protocol cannot tell a person's decline from a client that declines
|
|
224
223
|
// forms automatically (codex exec, measured 2026-09-24), so the reason names both and the fallback.
|
|
225
224
|
if (r.action === 'decline')
|
|
226
|
-
return { granted: false, reason: 'the session client declined the approval form (decline) — a person declined, or a client that cannot show forms (e.g. codex exec) declined automatically. If nobody saw the form,
|
|
225
|
+
return { granted: false, reason: 'the session client declined the approval form (decline) — a person declined, or a client that cannot show forms (e.g. codex exec) declined automatically. If nobody saw the form, the person decides it in the approval form of a Claude Code session on this workspace (approval_ask)' }; // A-SPEC-792.1
|
|
227
226
|
if (r.action !== 'accept')
|
|
228
227
|
return null; // cancel, absent, anything else: no decision
|
|
229
228
|
const content = r.content;
|
|
@@ -8,6 +8,8 @@ export interface ApprovalAskContext {
|
|
|
8
8
|
reason?: string;
|
|
9
9
|
};
|
|
10
10
|
env: () => NodeJS.ProcessEnv;
|
|
11
|
+
/** @implements A-SPEC-779.7 — this server's instance id, the requester key approval_withdraw checks. */
|
|
12
|
+
serverInstance?: () => string | undefined;
|
|
11
13
|
}
|
|
12
14
|
/** Clients whose form waits for the person in every mode measured (claude-code: forms expired unanswered, 2026-10-19). */
|
|
13
15
|
export declare const FORM_WAITS_FOR_PERSON: ReadonlySet<string>;
|
|
@@ -16,4 +18,13 @@ export declare function createApprovalAskHandlers(context: ApprovalAskContext):
|
|
|
16
18
|
root?: string;
|
|
17
19
|
id: string;
|
|
18
20
|
}): Promise<Record<string, unknown>>;
|
|
21
|
+
/**
|
|
22
|
+
* @implements A-SPEC-779.7 — the session withdraws a request its own MCP server filed: recorded as `withdrawn`, gone
|
|
23
|
+
* from the operator's inbox, never granted. Another session's request, and one filed by a hook or the CLI, is refused.
|
|
24
|
+
*/
|
|
25
|
+
approval_withdraw(a: {
|
|
26
|
+
root?: string;
|
|
27
|
+
id: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}): Promise<Record<string, unknown>>;
|
|
19
30
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FORM_WAITS_FOR_PERSON = void 0;
|
|
4
4
|
exports.createApprovalAskHandlers = createApprovalAskHandlers;
|
|
5
|
-
// @implements A-SPEC-718.4
|
|
5
|
+
// @implements A-SPEC-718.4, A-SPEC-792.1, A-SPEC-779.7
|
|
6
6
|
/**
|
|
7
7
|
* approval_ask — the person decides a pending request in the session's approval form, so no approval needs a typed
|
|
8
8
|
* command (owner audit 2026-10-20). Since A-SPEC-779.4 neither the agent's shell nor the session's `!` can run
|
|
@@ -15,7 +15,6 @@ exports.createApprovalAskHandlers = createApprovalAskHandlers;
|
|
|
15
15
|
const elicit_approval_1 = require("../elicit-approval");
|
|
16
16
|
const approval_queue_1 = require("../../governance/approval-queue");
|
|
17
17
|
const approve_1 = require("../../cli/approve");
|
|
18
|
-
const npx_bin_1 = require("../../project/npx-bin");
|
|
19
18
|
const screen_safe_1 = require("../../cli/screen-safe");
|
|
20
19
|
/** Clients whose form waits for the person in every mode measured (claude-code: forms expired unanswered, 2026-10-19). */
|
|
21
20
|
exports.FORM_WAITS_FOR_PERSON = new Set(['claude-code']);
|
|
@@ -30,7 +29,9 @@ function createApprovalAskHandlers(context) {
|
|
|
30
29
|
async approval_ask(a) {
|
|
31
30
|
const root = context.rootOf(a.root);
|
|
32
31
|
const id = typeof a.id === 'string' ? a.id.trim() : '';
|
|
33
|
-
|
|
32
|
+
// @implements A-SPEC-792.1 — the route that still reaches a person, never a command to type: a Claude Code session on
|
|
33
|
+
// this workspace, whose form is measured to wait for a person (FORM_WAITS_FOR_PERSON).
|
|
34
|
+
const fallback = `The request stays pending: the person decides it in the approval form of a Claude Code session on this workspace (approval_ask with id "${id}")`;
|
|
34
35
|
const refuse = (why) => ({ ok: false, id, reason: `${why}. ${fallback}` });
|
|
35
36
|
// @implements A-SPEC-779.5 — a run's own server never asks; a request a run awaits is the person's to decide in the
|
|
36
37
|
// interactive session's form (owner, 2026-10-20). The CLI keeps A-SPEC-779's terminal-only rule (grantGuard).
|
|
@@ -85,5 +86,19 @@ function createApprovalAskHandlers(context) {
|
|
|
85
86
|
return { ok: false, id, reason: r.reason };
|
|
86
87
|
return { ...base, decision: 'denied', reason: why, nextAction: 'Do not retry the act; the person denied it.' };
|
|
87
88
|
},
|
|
89
|
+
/**
|
|
90
|
+
* @implements A-SPEC-779.7 — the session withdraws a request its own MCP server filed: recorded as `withdrawn`, gone
|
|
91
|
+
* from the operator's inbox, never granted. Another session's request, and one filed by a hook or the CLI, is refused.
|
|
92
|
+
*/
|
|
93
|
+
async approval_withdraw(a) {
|
|
94
|
+
const root = context.rootOf(a.root);
|
|
95
|
+
const id = typeof a.id === 'string' ? a.id.trim() : '';
|
|
96
|
+
const reason = typeof a.reason === 'string' ? a.reason : '';
|
|
97
|
+
const server = context.serverInstance?.();
|
|
98
|
+
const r = (0, approve_1.withdrawRequest)(root, id, reason, { env: context.env(), cwd: root, ...(server ? { server } : {}) });
|
|
99
|
+
if (!r.ok)
|
|
100
|
+
return { ok: false, id, reason: r.reason };
|
|
101
|
+
return { ok: true, id, decision: 'withdrawn', nextAction: 'The request is closed; the operator will not see it. Do not retry the act it was filed for.' };
|
|
102
|
+
},
|
|
88
103
|
};
|
|
89
104
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createReviewVerdictHandlers = createReviewVerdictHandlers;
|
|
4
|
-
// @implements A-SPEC-102.9
|
|
4
|
+
// @implements A-SPEC-102.9, A-SPEC-792.1
|
|
5
5
|
/**
|
|
6
6
|
* review_verdict — the person records an independent review verdict in the session's approval form. A-SPEC-102.7/102.8
|
|
7
7
|
* make a CLI verdict independent only from a person's own terminal, so a review meant leaving the session (the owner's
|
|
@@ -20,7 +20,8 @@ function createReviewVerdictHandlers(context) {
|
|
|
20
20
|
async review_verdict(a) {
|
|
21
21
|
const root = context.rootOf(a.root);
|
|
22
22
|
const env = context.env();
|
|
23
|
-
|
|
23
|
+
// @implements A-SPEC-792.1 — a Claude Code session's form, never a command to type.
|
|
24
|
+
const fallback = `The verdict stays unrecorded: the person records it in the approval form of a Claude Code session on this workspace (review_verdict for ${a.base}..${a.head})`;
|
|
24
25
|
const refuse = (why) => ({ ok: false, reason: `${why}. ${fallback}` });
|
|
25
26
|
const marker = env[RUN];
|
|
26
27
|
if (typeof marker === 'string' && marker.trim() !== '')
|
|
@@ -47,6 +47,8 @@ export interface SpecApprovalContext {
|
|
|
47
47
|
foreignRootReason(root?: string): string | null;
|
|
48
48
|
/** @implements A-SPEC-732 — why no in-session route was offered (unattested server), or ''. */
|
|
49
49
|
approvalRouteNote?(): string;
|
|
50
|
+
/** @implements A-SPEC-792.4 — the home whose full autonomy profile applies (default os.homedir()). */
|
|
51
|
+
fullAutonomyHome?(): string;
|
|
50
52
|
}
|
|
51
53
|
export declare function createSpecApprovalHandlers(context: SpecApprovalContext): {
|
|
52
54
|
/**
|
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createSpecApprovalHandlers = createSpecApprovalHandlers;
|
|
37
37
|
exports.readProjectFile = readProjectFile;
|
|
38
|
-
// @implements A-SPEC-182.3, A-SPEC-718.3, A-SPEC-770.6, A-SPEC-718.1,A-SPEC-718.2, A-SPEC-718, A-SPEC-551.1, A-SPEC-551.2, A-SPEC-627.1, A-SPEC-622, A-SPEC-100.2, A-SPEC-128, A-SPEC-132, A-SPEC-133, A-SPEC-151, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245, A-SPEC-729, A-SPEC-532.7
|
|
38
|
+
// @implements A-SPEC-182.3, A-SPEC-718.3, A-SPEC-770.6, A-SPEC-718.1,A-SPEC-718.2, A-SPEC-718, A-SPEC-551.1, A-SPEC-551.2, A-SPEC-627.1, A-SPEC-622, A-SPEC-100.2, A-SPEC-128, A-SPEC-132, A-SPEC-133, A-SPEC-151, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245, A-SPEC-729, A-SPEC-532.7, A-SPEC-792.1, A-SPEC-792.4
|
|
39
39
|
// @implements A-SPEC-631, A-SPEC-733
|
|
40
40
|
const fs = __importStar(require("node:fs"));
|
|
41
41
|
const compat_impact_1 = require("../../spec/compat-impact");
|
|
@@ -48,6 +48,8 @@ const autonomy_1 = require("../../governance/autonomy");
|
|
|
48
48
|
const config_1 = require("../../config/config");
|
|
49
49
|
const write_target_1 = require("../../guardrail/write-target");
|
|
50
50
|
const delegation_1 = require("../../governance/delegation"); // @implements A-SPEC-771
|
|
51
|
+
const full_autonomy_1 = require("../../governance/full-autonomy"); // @implements A-SPEC-792.4
|
|
52
|
+
const os = __importStar(require("node:os"));
|
|
51
53
|
const approval_grants_1 = require("../../governance/approval-grants");
|
|
52
54
|
const spec_digest_1 = require("../../spec/spec-digest");
|
|
53
55
|
const version_conflict_1 = require("../../spec/version-conflict");
|
|
@@ -57,7 +59,6 @@ const review_targets_1 = require("../../review/review-targets");
|
|
|
57
59
|
const requirement_triage_evidence_1 = require("../requirement-triage-evidence");
|
|
58
60
|
const approval_policy_1 = require("../approval-policy");
|
|
59
61
|
const approval_blockers_1 = require("../../spec/approval-blockers");
|
|
60
|
-
const npx_bin_1 = require("../../project/npx-bin");
|
|
61
62
|
function createSpecApprovalHandlers(context) {
|
|
62
63
|
const { store, resolver, projectRootOf, cachedScan, tryElicit, elicitApproval, autonomousApproval } = context;
|
|
63
64
|
return {
|
|
@@ -150,7 +151,10 @@ function createSpecApprovalHandlers(context) {
|
|
|
150
151
|
catch {
|
|
151
152
|
return undefined;
|
|
152
153
|
} })();
|
|
153
|
-
|
|
154
|
+
// @implements A-SPEC-792.4 — a full autonomy profile covering this project: no seal here waits for a person.
|
|
155
|
+
const fullState = autonomyRoot === undefined ? null : (0, full_autonomy_1.readFullProfile)(context.fullAutonomyHome?.() ?? os.homedir(), autonomyRoot);
|
|
156
|
+
const fullEntry = fullState !== null && fullState.active ? fullState.entry : null;
|
|
157
|
+
const autonomyOn = fullEntry !== null || (0, autonomy_1.autonomousApprovalEnabled)(process.env, autonomyRoot, new Date().toISOString());
|
|
154
158
|
// @implements A-SPEC-718.3 — the continuation's only person is the host's own tool confirmation, which
|
|
155
159
|
// the server cannot see and an allow rule or auto mode removes. Under autonomous approval — the posture
|
|
156
160
|
// in which nobody is at the keyboard — it is neither spent here nor offered below (measured: the caller
|
|
@@ -205,11 +209,25 @@ function createSpecApprovalHandlers(context) {
|
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
if (ceilingNote !== null) {
|
|
212
|
+
// @implements A-SPEC-792.4 — under a full profile the owner's ceiling still binds, and refuses at once.
|
|
213
|
+
if (fullEntry !== null) {
|
|
214
|
+
return { ok: false, reason: `spec_approve: ${a.id} — [full autonomy: the owner's ceiling keeps this seal; the owner changes autonomy.ceiling in ax.config.json]${ceilingNote} (no approval request was filed)` };
|
|
215
|
+
}
|
|
208
216
|
autonomyNote = ceilingNote;
|
|
209
217
|
}
|
|
210
218
|
else if (autonomyOn && risk === 'hitl') {
|
|
211
219
|
const rule = noIntake ? 'requirement-without-intake' : (0, autonomy_1.specApprovalAutonomyReason)(target.spec, resolver([target.spec]), below);
|
|
212
|
-
if (rule !== null) {
|
|
220
|
+
if (rule !== null && fullEntry !== null) {
|
|
221
|
+
// @implements A-SPEC-792.4 — sealed as full-autonomy, or refused with the self-serve route; never asked.
|
|
222
|
+
const verdict = (0, full_autonomy_1.fullSealVerdict)(rule, fullEntry.flags);
|
|
223
|
+
if (verdict.outcome === 'refuse') {
|
|
224
|
+
return { ok: false, reason: `spec_approve: ${a.id} — [full autonomy: ${rule}] ${verdict.route} (no approval request was filed)` };
|
|
225
|
+
}
|
|
226
|
+
const base = autonomousApproval(below?.map((s) => s.id));
|
|
227
|
+
approveResolved = { approval: { ...base, actor: base.actor.replace(/^autonomous:/, 'full-autonomy:'), rationale: `full autonomy (scope ${fullEntry.scope}, rule ${rule})${verdict.mark}` }, source: 'full-autonomy' };
|
|
228
|
+
decidedSubject = targetSubject;
|
|
229
|
+
}
|
|
230
|
+
else if (rule !== null) {
|
|
213
231
|
autonomyNote = `\n[autonomy: this seal is the operator's — ${rule} (${(0, autonomy_1.autonomyRuleMeaning)(rule)})]${(0, autonomy_1.autonomyNextStep)(rule, a.id)}`; // A-SPEC-532.7
|
|
214
232
|
// @implements A-SPEC-771 — the operator's run delegation may cover this very rule: then the seal proceeds
|
|
215
233
|
// as a DELEGATED grant (actor `delegated:<client>`, the run and the rule in the ledger) and no person is
|
|
@@ -384,7 +402,7 @@ function createSpecApprovalHandlers(context) {
|
|
|
384
402
|
const bound = approveResolved.approval;
|
|
385
403
|
if (typeof bound.subject === 'string' && bound.subject !== '' && bound.subject !== (0, spec_digest_1.specDigest)(cur.spec)) {
|
|
386
404
|
const current = (0, spec_digest_1.specDigest)(cur.spec);
|
|
387
|
-
return { ok: false, reason: `[grant ${bound.nonce ?? '?'} refused: stale-subject] the grant was minted for another content of ${a.id}; the
|
|
405
|
+
return { ok: false, reason: `[grant ${bound.nonce ?? '?'} refused: stale-subject] the grant was minted for another content of ${a.id}; the person reads the current content and decides again in the session form (approval_ask with the id below); the new grant replaces the stale one.` // A-SPEC-792.1
|
|
388
406
|
+ context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', subject: current, title: cur.spec.title }) };
|
|
389
407
|
}
|
|
390
408
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Agent } from '../../cli/agents';
|
|
2
|
+
import type { InstallIdentity, StaleFact } from '../server-staleness';
|
|
2
3
|
export declare function createWorkspacePreflightHandlers(context: {
|
|
3
4
|
storeRoot?: string;
|
|
5
|
+
server?: () => {
|
|
6
|
+
loaded: InstallIdentity;
|
|
7
|
+
stale: StaleFact | null;
|
|
8
|
+
};
|
|
4
9
|
}): {
|
|
5
10
|
workspace_preflight(a: {
|
|
6
11
|
root: string;
|