@holmes-lab/holmes-kit 0.40.1 → 0.41.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 +78 -0
- package/README.md +11 -3
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve-context.js +4 -3
- package/dist/holmes/cli/approve.js +22 -12
- package/dist/holmes/cli/autonomy.d.ts +21 -0
- package/dist/holmes/cli/autonomy.js +35 -5
- package/dist/holmes/cli/doctor.js +58 -6
- package/dist/holmes/cli/index.js +371 -250
- package/dist/holmes/cli/init.js +17 -6
- package/dist/holmes/cli/ledger-witness.d.ts +61 -0
- package/dist/holmes/cli/ledger-witness.js +212 -0
- package/dist/holmes/cli/playbook-skills.d.ts +3 -56
- package/dist/holmes/cli/playbook-skills.js +26 -349
- package/dist/holmes/config/config.d.ts +4 -0
- package/dist/holmes/config/config.js +10 -3
- package/dist/holmes/governance/approval-queue.d.ts +65 -1
- package/dist/holmes/governance/approval-queue.js +279 -9
- package/dist/holmes/governance/autonomous-shell.d.ts +13 -1
- package/dist/holmes/governance/autonomous-shell.js +157 -4
- package/dist/holmes/governance/autonomy.d.ts +209 -0
- package/dist/holmes/governance/autonomy.js +1127 -6
- package/dist/holmes/governance/install-manifest.d.ts +7 -4
- package/dist/holmes/governance/install-manifest.js +144 -14
- package/dist/holmes/governance/ledger-witness.d.ts +63 -0
- package/dist/holmes/governance/ledger-witness.js +296 -0
- package/dist/holmes/governance/provenance-chain.d.ts +8 -1
- package/dist/holmes/governance/provenance-chain.js +23 -4
- package/dist/holmes/governance/recorded-pairs.d.ts +4 -0
- package/dist/holmes/governance/recorded-pairs.js +25 -1
- package/dist/holmes/governance/session-context.d.ts +7 -0
- package/dist/holmes/governance/session-context.js +34 -6
- package/dist/holmes/guardrail/anchor-scope-text.d.ts +9 -0
- package/dist/holmes/guardrail/anchor-scope-text.js +7 -0
- package/dist/holmes/guardrail/command-traits.d.ts +102 -0
- package/dist/holmes/guardrail/command-traits.js +379 -0
- package/dist/holmes/guardrail/fixtures/manager-builtins.json +23 -0
- package/dist/holmes/guardrail/fixtures/npm-commands.json +7 -0
- package/dist/holmes/guardrail/outward-acts.d.ts +47 -0
- package/dist/holmes/guardrail/outward-acts.js +1102 -0
- package/dist/holmes/guardrail/refusal-codes.js +8 -1
- package/dist/holmes/guardrail/refusal-templates.d.ts +15 -0
- package/dist/holmes/guardrail/refusal-templates.js +71 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +22 -6
- package/dist/holmes/guardrail/risk-classifier.js +12 -118
- package/dist/holmes/guardrail/shell-lexer.d.ts +69 -0
- package/dist/holmes/guardrail/shell-lexer.js +567 -0
- package/dist/holmes/guardrail/write-target.js +7 -1
- package/dist/holmes/hooks/pre-tool-use.d.ts +60 -0
- package/dist/holmes/hooks/pre-tool-use.js +1423 -10
- package/dist/holmes/hooks/session-start.js +11 -1
- package/dist/holmes/hooks/stop.d.ts +7 -0
- package/dist/holmes/hooks/stop.js +39 -2
- package/dist/holmes/mcp/elicit-approval.d.ts +0 -21
- package/dist/holmes/mcp/elicit-approval.js +5 -2
- package/dist/holmes/mcp/handlers/approval-ask.js +3 -2
- package/dist/holmes/mcp/handlers/entity-integration.d.ts +1 -1
- package/dist/holmes/mcp/handlers/entity-integration.js +9 -6
- package/dist/holmes/mcp/handlers/entity-renumber.js +2 -1
- package/dist/holmes/mcp/handlers/entity-store.js +7 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -0
- package/dist/holmes/mcp/handlers/operator-inspection.js +25 -4
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -1
- package/dist/holmes/mcp/handlers/spec-approval.js +28 -10
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +10 -7
- package/dist/holmes/mcp/handlers/test-execution.js +4 -2
- package/dist/holmes/mcp/handlers.d.ts +5 -5
- package/dist/holmes/mcp/handlers.js +2 -1
- package/dist/holmes/mcp/tool-schemas.js +4 -4
- package/dist/holmes/project/playbook-reference.d.ts +50 -0
- package/dist/holmes/project/playbook-reference.js +259 -0
- package/dist/holmes/project/playbook-skill-states.d.ts +94 -0
- package/dist/holmes/project/playbook-skill-states.js +396 -0
- package/dist/holmes/project/root.d.ts +9 -1
- package/dist/holmes/project/root.js +23 -2
- package/dist/holmes/project/running-package.d.ts +15 -0
- package/dist/holmes/project/running-package.js +87 -0
- package/dist/holmes/review/test-runner.d.ts +2 -0
- package/dist/holmes/review/test-runner.js +27 -10
- package/dist/holmes/spec/entity-integration-transaction.d.ts +19 -2
- package/dist/holmes/spec/entity-integration-transaction.js +68 -7
- package/package.json +5 -2
|
@@ -37,7 +37,7 @@ exports.detectInstallMode = detectInstallMode;
|
|
|
37
37
|
exports.buildSessionStartOutput = buildSessionStartOutput;
|
|
38
38
|
exports.staleWiredServerLine = staleWiredServerLine;
|
|
39
39
|
exports.driftNudge = driftNudge;
|
|
40
|
-
// @implements A-SPEC-531.2, A-SPEC-734, A-SPEC-476.1, A-SPEC-251.5, A-SPEC-333.2, A-SPEC-333.4, A-SPEC-333.5
|
|
40
|
+
// @implements A-SPEC-794.84, A-SPEC-531.2, A-SPEC-734, A-SPEC-476.1, A-SPEC-251.5, A-SPEC-333.2, A-SPEC-333.4, A-SPEC-333.5
|
|
41
41
|
// The SessionStart banner hook. It emits the intro (+ optional update notice) as additionalContext,
|
|
42
42
|
// which Claude Code delivers to BOTH the human transcript and the agent context — the "human and
|
|
43
43
|
// agent" delivery REQ-531 asks for. The update refresh is a DETACHED, fire-and-forget child so the
|
|
@@ -226,6 +226,16 @@ if (require.main === module) {
|
|
|
226
226
|
out.hookSpecificOutput.additionalContext += '\n' + line;
|
|
227
227
|
}
|
|
228
228
|
catch { /* the banner is never a gate */ }
|
|
229
|
+
// @implements A-SPEC-794.84 — requests no requester can follow up close unrun 24 hours after their last filing; one
|
|
230
|
+
// line says how many. Fail-open: a failure leaves every request as it was.
|
|
231
|
+
try {
|
|
232
|
+
const { closeExpiredRequests } = require('../governance/approval-queue');
|
|
233
|
+
const { resolveProjectRoot } = require('../project/root');
|
|
234
|
+
const n = closeExpiredRequests(resolveProjectRoot(process.cwd()).root, Date.now());
|
|
235
|
+
if (n > 0)
|
|
236
|
+
out.hookSpecificOutput.additionalContext += `\n[Holmes-Kit] ${n} approval request${n === 1 ? '' : 's'} without a requester closed unrun after 24 hours (closed-expired); asking again files a new request`;
|
|
237
|
+
}
|
|
238
|
+
catch { /* the banner is never a gate */ }
|
|
229
239
|
// @implements A-SPEC-554.1 — remind the human of the current autonomy posture (surface only, the
|
|
230
240
|
// headless hook never decides), and clean up an expired/invalid session marker. Fail-open.
|
|
231
241
|
try {
|
|
@@ -318,6 +318,13 @@ export declare function trackedLines(tracked?: {
|
|
|
318
318
|
article: string;
|
|
319
319
|
detail: string;
|
|
320
320
|
}[]): string[];
|
|
321
|
+
/**
|
|
322
|
+
* @implements A-SPEC-794.96 (S1) — principle 7's seam is the working tree: in Holmes-Kit's own repository, a gate-file
|
|
323
|
+
* change (staged, unstaged or untracked) that no open person-seal window names keeps the turn from ending. Two ways out
|
|
324
|
+
* only, and the same change set gives the same text (the consecutive-block cap still applies). Null where there is
|
|
325
|
+
* nothing to judge (no src/holmes, git cannot answer, no principle 7 change).
|
|
326
|
+
*/
|
|
327
|
+
export declare function principle7StopReason(root: string, specsDir: string, nowIso: string): string | null;
|
|
321
328
|
export declare function evaluateStop(specs: Spec[], evidence?: StopEvidence): {
|
|
322
329
|
block: boolean;
|
|
323
330
|
reason?: string;
|
|
@@ -52,6 +52,7 @@ exports.rolledBackLedgers = rolledBackLedgers;
|
|
|
52
52
|
exports.governanceLostPreflight = governanceLostPreflight;
|
|
53
53
|
exports.outsideAnyProject = outsideAnyProject;
|
|
54
54
|
exports.trackedLines = trackedLines;
|
|
55
|
+
exports.principle7StopReason = principle7StopReason;
|
|
55
56
|
exports.evaluateStop = evaluateStop;
|
|
56
57
|
exports.stopBlockText = stopBlockText;
|
|
57
58
|
exports.stopDebtAction = stopDebtAction;
|
|
@@ -66,7 +67,7 @@ exports.collectForbiddenEdgeJudgement = collectForbiddenEdgeJudgement;
|
|
|
66
67
|
exports.stopSharedScan = stopSharedScan;
|
|
67
68
|
exports.scanCodeCycles = scanCodeCycles;
|
|
68
69
|
exports.writeGuardCount = writeGuardCount;
|
|
69
|
-
// @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, A-SPEC-102.12, A-SPEC-222.10, A-SPEC-222.12, A-SPEC-222.13
|
|
70
|
+
// @implements A-SPEC-794.97, A-SPEC-794.96, 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, A-SPEC-102.12, A-SPEC-222.10, A-SPEC-222.12, A-SPEC-222.13, A-SPEC-564.7
|
|
70
71
|
// @implements A-SPEC-769.9, A-SPEC-769.10, A-SPEC-769.11
|
|
71
72
|
const fs = __importStar(require("node:fs"));
|
|
72
73
|
// @implements A-SPEC-549.3 — evaluateStop's messages are English here; the Hangul-absence guard
|
|
@@ -823,6 +824,33 @@ function trackedLines(tracked) {
|
|
|
823
824
|
return `[Holmes-Kit] ${article}${label ? ` ${label}` : ''} (track): ${details.join(' | ')}`;
|
|
824
825
|
});
|
|
825
826
|
}
|
|
827
|
+
/**
|
|
828
|
+
* @implements A-SPEC-794.96 (S1) — principle 7's seam is the working tree: in Holmes-Kit's own repository, a gate-file
|
|
829
|
+
* change (staged, unstaged or untracked) that no open person-seal window names keeps the turn from ending. Two ways out
|
|
830
|
+
* only, and the same change set gives the same text (the consecutive-block cap still applies). Null where there is
|
|
831
|
+
* nothing to judge (no src/holmes, git cannot answer, no principle 7 change).
|
|
832
|
+
*/
|
|
833
|
+
function principle7StopReason(root, specsDir, nowIso) {
|
|
834
|
+
// A-SPEC-794.97 (B-M1) — a consumer repository reads no specs: the rule applies only where src/holmes exists
|
|
835
|
+
const p7 = require('../governance/autonomy');
|
|
836
|
+
if (!p7.isHolmesKitOwnRepo(root))
|
|
837
|
+
return null; // A-SPEC-794.97 r4b (L5)
|
|
838
|
+
let specs;
|
|
839
|
+
try {
|
|
840
|
+
specs = (0, pre_tool_use_1.readSpecsSync)(specsDir);
|
|
841
|
+
}
|
|
842
|
+
catch {
|
|
843
|
+
specs = [];
|
|
844
|
+
}
|
|
845
|
+
const v = p7.principle7Verdict(root, specs, Date.parse(nowIso));
|
|
846
|
+
if (v === null)
|
|
847
|
+
return null;
|
|
848
|
+
// A-SPEC-794.97 r4b (M2) — what a window saw is recorded whether or not another file is unopened
|
|
849
|
+
p7.recordWindowBlobs(root, nowIso, v);
|
|
850
|
+
if (v.unopened.length === 0)
|
|
851
|
+
return null;
|
|
852
|
+
return `[Holmes-Kit] ${p7.principle7RefusalText(v.unopened, v.base, { headSeen: v.headSeen, localOnly: v.localOnly })}`;
|
|
853
|
+
}
|
|
826
854
|
function evaluateStop(specs, evidence) {
|
|
827
855
|
// L1: the Stop gate IS the constitution's re-verification point — every turn boundary re-runs the
|
|
828
856
|
// inviolable articles (ART-2 RTM, ART-3 validity incl. 4-quadrant GWT, ART-4 coverage evidence).
|
|
@@ -1753,8 +1781,10 @@ if (require.main === module) {
|
|
|
1753
1781
|
const sum = sc.summarizeTranscript(text.split('\n'));
|
|
1754
1782
|
if (sum.turns > 0) {
|
|
1755
1783
|
sc.appendSessionContext(root, {
|
|
1784
|
+
// @implements A-SPEC-564.7 — the record names its counting rule, so a reader never adds it to an
|
|
1785
|
+
// older per-record count.
|
|
1756
1786
|
kind: 'usage', sessionKey: sessionId, models: sum.models, usage: sum.usage,
|
|
1757
|
-
turns: sum.turns, ...(sum.truncated ? { truncated: true } : {}), ts: new Date().toISOString(),
|
|
1787
|
+
turns: sum.turns, ...(sum.truncated ? { truncated: true } : {}), count: sc.USAGE_COUNT_RULE, ts: new Date().toISOString(),
|
|
1758
1788
|
});
|
|
1759
1789
|
}
|
|
1760
1790
|
}
|
|
@@ -1883,6 +1913,13 @@ if (require.main === module) {
|
|
|
1883
1913
|
}
|
|
1884
1914
|
catch { /* awareness is best-effort; a failure leaves the block intact */ }
|
|
1885
1915
|
}
|
|
1916
|
+
// @implements A-SPEC-794.96 (S1) — after the acknowledgement, so a queued request never waives it
|
|
1917
|
+
try {
|
|
1918
|
+
const p7 = principle7StopReason(stopProjectRoot(), specsDir, new Date().toISOString());
|
|
1919
|
+
if (p7 !== null)
|
|
1920
|
+
out = { ...out, block: true, reason: out.block && out.reason ? `${out.reason}\n${p7}` : p7 };
|
|
1921
|
+
}
|
|
1922
|
+
catch { /* the working-tree read is best-effort; the gate's other rules stand */ }
|
|
1886
1923
|
const guard = decideStopGuard(out.block, guardCountOrZero(sessionId));
|
|
1887
1924
|
const persisted = writeGuardCount(sessionId, guard.nextCount);
|
|
1888
1925
|
// @implements A-SPEC-778.1 — in a run, each blocked Stop goes on the run's log, and the cap yield stalls the run
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The decision comes INTO the session (REQ-263): an approval-shaped refusal (spec_approve without a
|
|
3
|
-
* covering HOLMES_APPROVAL) becomes an in-session question when the client advertises the MCP
|
|
4
|
-
* elicitation capability — the human answers at the point of decision, on the screen they are
|
|
5
|
-
* already looking at, and the tool call completes in place. No capability, an error, a timeout, or
|
|
6
|
-
* a dismissed window all degrade LOSSLESSLY to the current refusal + queue hint.
|
|
7
|
-
*
|
|
8
|
-
* TRUST MODEL (H-SPEC-263): an elicitation response is produced by the harness UI from a human —
|
|
9
|
-
* the model cannot forge it through tool arguments (the request travels server→client, off the tool
|
|
10
|
-
* surface). But the trust boundary sits at the harness, closer than the out-of-band env/grant
|
|
11
|
-
* channels an operator injects from a shell. Hence: (a) the kind allow-list below is conservative —
|
|
12
|
-
* soft-governance approvals only, hard-hitl (nonce-opened shell/config-write) stays out and
|
|
13
|
-
* widening it is a spec revision; (b) every grant is ledgered under an `elicitation:<client>` actor
|
|
14
|
-
* so audits can tell the channel apart; (c) grants are single-use by construction — the synthesized
|
|
15
|
-
* approval lives only inside the one call and is never persisted.
|
|
16
|
-
*
|
|
17
|
-
* PURE — no SDK import, no I/O. The server wires `Server.elicitInput` around these shapes; handlers
|
|
18
|
-
* receive an injected callback and never see the server instance, so tests drive every branch with
|
|
19
|
-
* a fake elicitor.
|
|
20
|
-
*/
|
|
21
|
-
/** Approval kinds that may ask in-session. Widening this set is a spec revision, not a drive-by. */
|
|
22
1
|
export declare const ELICITABLE_KINDS: ReadonlySet<string>;
|
|
23
2
|
/**
|
|
24
3
|
* @implements A-SPEC-540.1
|
|
@@ -1,5 +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
|
+
// @implements A-SPEC-794.90, A-SPEC-794.81, 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
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MAX_PRESENTATIONS = exports.WAIT_FOR_PERSON_MS = exports.ELICIT_TIMEOUT_MS = exports.ELICITABLE_KINDS = void 0;
|
|
5
5
|
exports.elicitationDisabled = elicitationDisabled;
|
|
@@ -32,7 +32,10 @@ exports.interpretElicitResult = interpretElicitResult;
|
|
|
32
32
|
*/
|
|
33
33
|
/** Approval kinds that may ask in-session. Widening this set is a spec revision, not a drive-by. */
|
|
34
34
|
// @implements A-SPEC-752.10 — `governance-wiring`: re-applying the binding the registry already names (never choosing one).
|
|
35
|
-
|
|
35
|
+
// A-SPEC-794.81 — un-seal and retire are asked in the form under their own kinds
|
|
36
|
+
// A-SPEC-794.90 — the transition kinds come from the one table (read at load; the table module does no I/O at load)
|
|
37
|
+
const { SPEC_TRANSITION_KIND } = require('../governance/approval-queue');
|
|
38
|
+
exports.ELICITABLE_KINDS = new Set([...Object.values(SPEC_TRANSITION_KIND), 'review-resolve', 'governance-wiring']);
|
|
36
39
|
/** The `HOLMES_ELICIT` values that turn the in-client prompt OFF. */
|
|
37
40
|
const ELICIT_DISABLED_TOKENS = new Set(['off', '0', 'false', 'no', 'disabled']);
|
|
38
41
|
/**
|
|
@@ -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, A-SPEC-792.1, A-SPEC-779.7, A-SPEC-245.9, A-SPEC-794.31, A-SPEC-794.33,A-SPEC-794.32
|
|
5
|
+
// @implements A-SPEC-794.84, A-SPEC-718.4, A-SPEC-792.1, A-SPEC-779.7, A-SPEC-245.9, A-SPEC-794.31, A-SPEC-794.33,A-SPEC-794.32
|
|
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
|
|
@@ -44,8 +44,9 @@ function createApprovalAskHandlers(context) {
|
|
|
44
44
|
// @implements A-SPEC-794.31, A-SPEC-794.32 — when no request is found, a development-build one is named in words,
|
|
45
45
|
// and no form is shown; a decidable request is never refused for it (the answer of a lookup that failed)
|
|
46
46
|
// A-SPEC-794.33 — on the exact id only: approval_ask names a request by its whole id (B-2)
|
|
47
|
+
// A-SPEC-794.84 — a request closed unrun says so
|
|
47
48
|
if (!request)
|
|
48
|
-
return { ok: false, id, reason: (0, approval_queue_1.devFiledRefusal)((0, approval_queue_1.readQueue)(root), id, true) ?? `no pending request ${oneLine(id, 40)} in the approval inbox or this machine's refusal log` };
|
|
49
|
+
return { ok: false, id, reason: (0, approval_queue_1.devFiledRefusal)((0, approval_queue_1.readQueue)(root), id, true) ?? (0, approval_queue_1.closedExpiredNote)((0, approval_queue_1.readQueue)(root, { includeAllKinds: true }), id) ?? `no pending request ${oneLine(id, 40)} in the approval inbox or this machine's refusal log` };
|
|
49
50
|
const client = context.clientName();
|
|
50
51
|
const attestation = context.attestation();
|
|
51
52
|
if ((0, elicit_approval_1.elicitationDisabled)(context.env()))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DerivedRebuild } from '../../spec/entity-integration-discharge';
|
|
2
2
|
import { EntityIntegrationPlan } from '../../spec/entity-integration-transaction';
|
|
3
3
|
export type IntegrationSealTransition = {
|
|
4
|
-
kind: 'spec-unsealed';
|
|
4
|
+
kind: 'spec-unsealed' | 'spec-retired';
|
|
5
5
|
id: string;
|
|
6
6
|
} | {
|
|
7
7
|
kind: 'spec-approved';
|
|
@@ -94,9 +94,10 @@ function renumberedMappingInputs(steps, renames = []) {
|
|
|
94
94
|
}
|
|
95
95
|
function integrationSealTransitions(operation) {
|
|
96
96
|
const transitions = [];
|
|
97
|
+
const retired = (0, entity_integration_transaction_1.retiredSpecIds)(operation); // A-SPEC-794.92 (M-1)
|
|
97
98
|
for (const step of operation.steps) {
|
|
98
99
|
if (step.phase === 'unseal' && step.specId)
|
|
99
|
-
transitions.push({ kind: 'spec-unsealed', id: step.specId });
|
|
100
|
+
transitions.push({ kind: retired.has(step.specId) ? 'spec-retired' : 'spec-unsealed', id: step.specId });
|
|
100
101
|
else if (step.phase === 'approve' && step.specId) {
|
|
101
102
|
if (typeof step.change.after !== 'string')
|
|
102
103
|
throw new entity_store_1.EntityStoreError('audit-conflict', 'Approve step ' + step.specId + ' publishes no document.');
|
|
@@ -222,8 +223,9 @@ function createEntityIntegrationHandlers(context) {
|
|
|
222
223
|
const grants = new Set(), authorities = new Set(), usedGrantRefs = new Set();
|
|
223
224
|
const spentHere = []; // A-SPEC-245.15 (item 2): the grants this act spent still authorize its later steps
|
|
224
225
|
const grantRef = (approval) => 'grant-use:' + (0, entity_transaction_1.entityContentVersion)(JSON.stringify({ actor: approval.actor, token: approval.token, nonce: approval.nonce, scope: approval.scope, expires: approval.expires }));
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
// A-SPEC-794.85 — a spec step's authority is its transition's kind, from the one table
|
|
227
|
+
const requireAuthority = (specId, transition = 'seal') => {
|
|
228
|
+
const action = { kind: specId ? approval_queue_1.SPEC_TRANSITION_KIND[transition] : 'config-write', target: specId ?? target };
|
|
227
229
|
const resolved = (0, approval_grants_1.resolveApproval)(bound.root, env, action, new Date().toISOString(), spentHere);
|
|
228
230
|
if (!resolved)
|
|
229
231
|
throw new entity_store_1.EntityStoreError(specId ? 'spec-approval-required' : 'approval-required', 'Current authority is required for this integration.' + (0, approval_queue_1.queueHint)(bound.root, { ...action, why: 'Integrate the exact Git inputs while preserving entity identity and official seal transitions.' }));
|
|
@@ -296,10 +298,11 @@ function createEntityIntegrationHandlers(context) {
|
|
|
296
298
|
for (const transition of integrationSealTransitions(operation)) {
|
|
297
299
|
if (events.some(event => event.kind === transition.kind && event.inputs?.includes(transition.id) && event.inputs?.includes(binding[0])))
|
|
298
300
|
continue;
|
|
299
|
-
const sealAuthority = requireAuthority(transition.id);
|
|
301
|
+
const sealAuthority = requireAuthority(transition.id, transition.kind === 'spec-unsealed' ? 'unseal' : transition.kind === 'spec-retired' ? 'retire' : 'seal');
|
|
300
302
|
ledger.append({ ts: new Date().toISOString(), actor: sealAuthority.approval.actor, kind: transition.kind,
|
|
301
|
-
summary: transition.kind === 'spec-
|
|
302
|
-
|
|
303
|
+
summary: transition.kind === 'spec-approved' ? 'approved ' + transition.id + ' sealing ' + transition.digest
|
|
304
|
+
: (transition.kind === 'spec-retired' ? 'retired ' : 'unsealed ') + transition.id + ' (integration ' + operation.operationId + ')',
|
|
305
|
+
inputs: transition.kind === 'spec-approved' ? [transition.id, transition.digest, binding[0]] : [transition.id, binding[0]],
|
|
303
306
|
rationale: sealAuthority.approval.rationale, authorization: (0, provenance_chain_1.authorizationRef)(sealAuthority.approval.actor, sealAuthority.approval.token) });
|
|
304
307
|
}
|
|
305
308
|
ledger.append({ ts: new Date().toISOString(), actor: authority.approval.actor, kind: 'entity-integrated', summary: 'Completed Git entity integration ' + operation.operationId,
|
|
@@ -121,7 +121,8 @@ function createEntityRenumberHandlers(context) {
|
|
|
121
121
|
const spentHere = []; // A-SPEC-245.15 (item 2): the grants this act spent still authorize its later steps
|
|
122
122
|
const grantRef = (approval) => 'grant-use:' + (0, entity_transaction_1.entityContentVersion)(JSON.stringify({ actor: approval.actor, token: approval.token, nonce: approval.nonce, scope: approval.scope, expires: approval.expires }));
|
|
123
123
|
const requireAuthority = (specId) => {
|
|
124
|
-
|
|
124
|
+
// A-SPEC-794.85 — a renumbered sealed document keeps its seal: the seal's kind, from the one table
|
|
125
|
+
const action = { kind: specId ? approval_queue_1.SPEC_TRANSITION_KIND.seal : 'config-write', target: specId ?? target };
|
|
125
126
|
const resolved = (0, approval_grants_1.resolveApproval)(bound.root, env, action, new Date().toISOString(), spentHere);
|
|
126
127
|
if (!resolved)
|
|
127
128
|
throw new entity_store_1.EntityStoreError(specId ? 'spec-approval-required' : 'approval-required', 'Current authority is required for this renumber operation.' + (0, approval_queue_1.queueHint)(bound.root, { ...action, why: 'Preserve UUIDs and the official approval closure while renumbering.' }));
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createEntityStoreHandlers = createEntityStoreHandlers;
|
|
37
|
-
// @implements A-SPEC-627, A-SPEC-627.1, A-SPEC-222.10, A-SPEC-222.12
|
|
37
|
+
// @implements A-SPEC-794.85, A-SPEC-627, A-SPEC-627.1, A-SPEC-222.10, A-SPEC-222.12
|
|
38
38
|
// @implements A-SPEC-642, A-SPEC-245.9, A-SPEC-245.15
|
|
39
39
|
// @implements A-SPEC-641
|
|
40
40
|
// @implements A-SPEC-638
|
|
@@ -149,7 +149,12 @@ function createEntityStoreHandlers(context) {
|
|
|
149
149
|
let result;
|
|
150
150
|
try {
|
|
151
151
|
result = (0, entity_store_1.recoverEntityStore)(context.storeRoot, plan, (before, after, inventory) => {
|
|
152
|
-
|
|
152
|
+
// A-SPEC-794.85 — the journal's target status names the transition, and the table its kind (an interrupted
|
|
153
|
+
// un-seal or retirement is recovered by its own kind, never by a seal's); an unsupported one asks for nothing
|
|
154
|
+
const transition = before ? (0, approval_queue_1.specTransitionOfStatus)(after.status) : null;
|
|
155
|
+
if (transition === null)
|
|
156
|
+
throw new entity_store_1.EntityStoreError('unsupported-recovery', 'Unsupported specification transition.');
|
|
157
|
+
const specAction = { kind: approval_queue_1.SPEC_TRANSITION_KIND[transition], target: after.id };
|
|
153
158
|
const requireAuthority = () => {
|
|
154
159
|
const authority = (0, approval_grants_1.resolveApproval)(bound.root, env, specAction, new Date().toISOString(), spentHere);
|
|
155
160
|
if (!authority)
|
|
@@ -11,6 +11,8 @@ export interface ApprovalRequestState {
|
|
|
11
11
|
state: 'pending' | 'held' | 'granted' | 'unusable' | 'claimed' | 'expired' | 'consumed' | 'denied' | 'revoked' | 'withdrawn';
|
|
12
12
|
question?: string;
|
|
13
13
|
reason?: string;
|
|
14
|
+
/** @implements A-SPEC-794.85 — which act the request is for: spec-approve, spec-unseal or spec-retire. */
|
|
15
|
+
kind?: string;
|
|
14
16
|
/** @implements A-SPEC-245.9 (1b-6) — for a live grant: "single use, until <time>" or "single use, no time limit". */
|
|
15
17
|
validity?: string;
|
|
16
18
|
ts?: string;
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.approvalRequestOf = approvalRequestOf;
|
|
37
37
|
exports.nextActionOf = nextActionOf;
|
|
38
38
|
exports.createOperatorInspectionHandlers = createOperatorInspectionHandlers;
|
|
39
|
-
// @implements A-SPEC-605, A-SPEC-605.1, A-SPEC-779.3, A-SPEC-245.17, A-SPEC-794.33, A-SPEC-794.34, A-SPEC-794.35, A-SPEC-794.37, A-SPEC-794.40, A-SPEC-794.41, A-SPEC-794.42, A-SPEC-794.44
|
|
39
|
+
// @implements A-SPEC-794.85, A-SPEC-605, A-SPEC-605.1, A-SPEC-779.3, A-SPEC-245.17, A-SPEC-794.33, A-SPEC-794.34, A-SPEC-794.35, A-SPEC-794.37, A-SPEC-794.40, A-SPEC-794.41, A-SPEC-794.42, A-SPEC-794.44
|
|
40
40
|
// @implements A-SPEC-642, A-SPEC-245.9, A-SPEC-245.15
|
|
41
41
|
// @implements A-SPEC-631
|
|
42
42
|
// @implements A-SPEC-768
|
|
@@ -59,9 +59,23 @@ const approval_queue_1 = require("../../governance/approval-queue");
|
|
|
59
59
|
* this reads it. Read-only; an unreadable queue is no request.
|
|
60
60
|
*/
|
|
61
61
|
function approvalRequestOf(root, specId) {
|
|
62
|
+
// @implements A-SPEC-794.85 — the spec's seal, un-seal and retirement requests: an open one (pending or held) first,
|
|
63
|
+
// the latest of them; else the latest decided one. 794.81 split the kinds and this looked up the seal's only.
|
|
62
64
|
try {
|
|
63
|
-
const id = (0, approval_queue_1.approvalRequestId)('spec-approve', specId);
|
|
64
65
|
const q = (0, approval_queue_1.readQueue)(root);
|
|
66
|
+
const states = Object.values(approval_queue_1.SPEC_TRANSITION_KIND)
|
|
67
|
+
.map((kind) => { const s = requestStateOf(root, q, kind, specId); return s && { ...s, kind }; })
|
|
68
|
+
.filter((s) => s !== undefined);
|
|
69
|
+
const latest = (xs) => [...xs].sort((a, b) => (b.ts ?? '').localeCompare(a.ts ?? ''))[0];
|
|
70
|
+
return latest(states.filter((s) => s.state === 'pending' || s.state === 'held')) ?? latest(states);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function requestStateOf(root, q, kind, specId) {
|
|
77
|
+
try {
|
|
78
|
+
const id = (0, approval_queue_1.approvalRequestId)(kind, specId);
|
|
65
79
|
const pending = q.pending.find((p) => p.id === id);
|
|
66
80
|
const hold = q.holds[id];
|
|
67
81
|
if (pending?.hold || hold) {
|
|
@@ -79,7 +93,7 @@ function approvalRequestOf(root, specId) {
|
|
|
79
93
|
// (A-M2: an expired, other-target or other-workspace file read `granted` here while it covered nothing)
|
|
80
94
|
// @implements A-SPEC-245.17 (item 4) — a grant past its expiry (or with an empty one) is expired, not granted
|
|
81
95
|
// @implements A-SPEC-245.18 (5c) — an expiry that is not a date is expired too: `grantedStateOf`, the one order (794.37)
|
|
82
|
-
const grant = (0, approval_grants_1.requestGrantState)(root, id, { kind
|
|
96
|
+
const grant = (0, approval_grants_1.requestGrantState)(root, id, { kind, target: specId }, new Date().toISOString());
|
|
83
97
|
const state = (0, approval_grants_1.grantedStateOf)({ covers: grant.state === 'covers', claimed: grant.state === 'claimed', ...(d.consumedTs ? { consumedTs: d.consumedTs } : {}), ...(d.expires !== undefined ? { expires: d.expires } : {}) }, Date.now());
|
|
84
98
|
if (state === 'live')
|
|
85
99
|
return { id, state: 'granted', validity: (0, approve_1.grantValidityText)(d.expires), ts: d.ts };
|
|
@@ -105,8 +119,15 @@ function approvalRequestOf(root, specId) {
|
|
|
105
119
|
* because nothing in the response said what to do once the seal was there.
|
|
106
120
|
*/
|
|
107
121
|
function nextActionOf(described, request) {
|
|
108
|
-
|
|
122
|
+
// @implements A-SPEC-794.90 — the advice names the act its request is for: an un-seal or a retirement waiting on a
|
|
123
|
+
// sealed spec is not "sealed — stop polling"
|
|
124
|
+
const act = request?.kind === approval_queue_1.SPEC_TRANSITION_KIND.unseal ? 'spec_unseal' : request?.kind === approval_queue_1.SPEC_TRANSITION_KIND.retire ? 'spec_retire' : 'spec_approve';
|
|
125
|
+
if (described.sealed && act === 'spec_approve')
|
|
109
126
|
return 'sealed — stop polling this id; call spec_slice_approve or spec_approve for the next unsealed spec of the chain (spec_next names it).';
|
|
127
|
+
const advice = adviceFor(described, request);
|
|
128
|
+
return act === 'spec_approve' ? advice : advice.replace(/\bspec_approve\b/g, act);
|
|
129
|
+
}
|
|
130
|
+
function adviceFor(described, request) {
|
|
110
131
|
switch (request?.state) {
|
|
111
132
|
case 'held': return `held — the operator asks: ${request.question ?? '(no question recorded)'}. Resolve it in the spec or tests, then call spec_approve again.`;
|
|
112
133
|
case 'denied': return `denied — ${request.reason ?? 'no reason recorded'}. Do not re-request the same act; report it to the user.`;
|
|
@@ -6,6 +6,8 @@ import { ElicitOutcome } from '../elicit-approval';
|
|
|
6
6
|
import { ApprovalIntent } from '../approval-intent';
|
|
7
7
|
import { ApprovalAdapter } from '../approval-adapters';
|
|
8
8
|
export interface SpecApprovalContext {
|
|
9
|
+
/** @implements A-SPEC-794.85 — the MCP server instance this handler runs in (`<pid>:<startedAt>`), recorded on a seal. */
|
|
10
|
+
serverInstance?: () => string | undefined;
|
|
9
11
|
store: SpecStore;
|
|
10
12
|
resolver(specs: Spec[]): (id: string) => Spec | null;
|
|
11
13
|
projectRootOf(root: string): string;
|
|
@@ -110,7 +112,7 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
|
|
|
110
112
|
advisoryIds?: Partial<Record<string, string>> | undefined;
|
|
111
113
|
killsAdvisory?: import("../../review/kills-check").KillsAdvisory | undefined;
|
|
112
114
|
fttFulfilment?: import("../../rtm/ftt-fulfilment").FttFulfilment | undefined;
|
|
113
|
-
impactAdvisoryUnavailable?: "
|
|
115
|
+
impactAdvisoryUnavailable?: "unreadable" | "empty" | undefined;
|
|
114
116
|
impactGraph?: {
|
|
115
117
|
status: "current" | "stale" | "unverified";
|
|
116
118
|
sourceCommit: string | null;
|
|
@@ -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, A-SPEC-792.1, A-SPEC-792.4
|
|
38
|
+
// @implements A-SPEC-794.95, A-SPEC-794.88, A-SPEC-794.85, A-SPEC-794.81, 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, A-SPEC-245.9, A-SPEC-245.15
|
|
40
40
|
const fs = __importStar(require("node:fs"));
|
|
41
41
|
const compat_impact_1 = require("../../spec/compat-impact");
|
|
@@ -54,11 +54,13 @@ const approval_grants_1 = require("../../governance/approval-grants");
|
|
|
54
54
|
const spec_digest_1 = require("../../spec/spec-digest");
|
|
55
55
|
const version_conflict_1 = require("../../spec/version-conflict");
|
|
56
56
|
const ledger_store_1 = require("../../governance/ledger-store");
|
|
57
|
+
const approval_queue_1 = require("../../governance/approval-queue"); // @implements A-SPEC-794.85
|
|
57
58
|
const provenance_chain_1 = require("../../governance/provenance-chain");
|
|
58
59
|
const review_targets_1 = require("../../review/review-targets");
|
|
59
60
|
const requirement_triage_evidence_1 = require("../requirement-triage-evidence");
|
|
60
61
|
const approval_policy_1 = require("../approval-policy");
|
|
61
62
|
const approval_blockers_1 = require("../../spec/approval-blockers");
|
|
63
|
+
const human_channel_1 = require("../../governance/human-channel"); // @implements A-SPEC-794.95
|
|
62
64
|
function createSpecApprovalHandlers(context) {
|
|
63
65
|
const { store, resolver, projectRootOf, cachedScan, tryElicit, elicitApproval, autonomousApproval } = context;
|
|
64
66
|
return {
|
|
@@ -86,7 +88,7 @@ function createSpecApprovalHandlers(context) {
|
|
|
86
88
|
// grant is checked against the ONE versioned read the seal uses (below), never against an
|
|
87
89
|
// extra read — an extra read moved the optimistic-write window and let an external edit be
|
|
88
90
|
// sealed (measured by the A-SPEC-188 TOCTOU pin).
|
|
89
|
-
const action = { kind:
|
|
91
|
+
const action = { kind: approval_queue_1.SPEC_TRANSITION_KIND.seal, target: a.id };
|
|
90
92
|
let approveResolved = context.resolveHandlerApproval(a.root, approval, action, new Date().toISOString());
|
|
91
93
|
// @implements A-SPEC-263.1 — asked ONLY after the existing channels failed to cover (an open
|
|
92
94
|
// door never summons a human), and only about a spec that exists (a question about a missing
|
|
@@ -217,7 +219,10 @@ function createSpecApprovalHandlers(context) {
|
|
|
217
219
|
}
|
|
218
220
|
else if (autonomyOn && risk === 'hitl') {
|
|
219
221
|
const rule = noIntake ? 'requirement-without-intake' : (0, autonomy_1.specApprovalAutonomyReason)(target.spec, resolver([target.spec]), below);
|
|
220
|
-
|
|
222
|
+
// @implements A-SPEC-794.88 — principle 7: a spec whose scope names the gate and approval-processing category is
|
|
223
|
+
// sealed by a person only: the full profile does not seal it and a run delegation does not cover it
|
|
224
|
+
const category = (0, autonomy_1.principle7Category)(target.spec, below);
|
|
225
|
+
if (rule !== null && fullEntry !== null && category === null) {
|
|
221
226
|
// @implements A-SPEC-792.4 — sealed as full-autonomy, or refused with the self-serve route; never asked.
|
|
222
227
|
const verdict = (0, full_autonomy_1.fullSealVerdict)(rule, fullEntry.flags);
|
|
223
228
|
if (verdict.outcome === 'refuse') {
|
|
@@ -235,7 +240,9 @@ function createSpecApprovalHandlers(context) {
|
|
|
235
240
|
// is unchanged — only its consumer learned a third envelope (A-SPEC-552.1 project default, A-SPEC-553.1
|
|
236
241
|
// session marker, and this).
|
|
237
242
|
const delegation = autonomyRoot === undefined ? { active: false, why: 'none' } : (0, delegation_1.readDelegation)(autonomyRoot, new Date().toISOString());
|
|
238
|
-
if (
|
|
243
|
+
if (category !== null)
|
|
244
|
+
autonomyNote += `\n[principle 7: ${category} is in the gate and approval-processing category — a person seals this spec]`;
|
|
245
|
+
if (delegation.active && category === null && (0, delegation_1.delegationCovers)(delegation.delegation, rule)) {
|
|
239
246
|
const base = autonomousApproval(below?.map((s) => s.id));
|
|
240
247
|
approveResolved = { approval: { ...base, actor: base.actor.replace(/^autonomous:/, 'delegated:'), rationale: `delegated grant (run ${delegation.delegation.run}, rule ${rule})` }, source: 'delegated' };
|
|
241
248
|
decidedSubject = targetSubject;
|
|
@@ -265,7 +272,7 @@ function createSpecApprovalHandlers(context) {
|
|
|
265
272
|
// The MODEL text is capped BEFORE the server markers are appended (round-2): a ~185+ char
|
|
266
273
|
// title pushed '(재봉인)' past the dialog's 200-char summary cap, dressing a re-seal (the
|
|
267
274
|
// more consequential act) as a first approval. The cap cuts the title, never the marker.
|
|
268
|
-
const out = await tryElicit(
|
|
275
|
+
const out = await tryElicit(approval_queue_1.SPEC_TRANSITION_KIND.seal, a.id, `${a.id} — ${target.spec.title.slice(0, 120)}${resealing ? ' (재봉인)' : ''}${noIntake ? ' (triage 기록 없음)' : ''}`);
|
|
269
276
|
const presentation = out.kind === 'answered'
|
|
270
277
|
? (out.decision.granted ? { kind: 'approve', reason: out.decision.reason } : { kind: 'deny', reason: out.decision.reason })
|
|
271
278
|
: out.kind === 'expired' ? { kind: 'timeout' } : { kind: 'unavailable' };
|
|
@@ -312,8 +319,8 @@ function createSpecApprovalHandlers(context) {
|
|
|
312
319
|
refusedGrants = '';
|
|
313
320
|
}
|
|
314
321
|
return { ok: false, reason: (elicitExpiredMs !== undefined ? (0, elicit_approval_1.expiredNotice)(elicitExpiredMs) : '') + refusedGrants + (context.approvalRouteNote?.() ?? '') + autonomyNote
|
|
315
|
-
+ 'spec_approve requires an out-of-band HOLMES_APPROVAL that COVERS this act — a request-payload approval is not a channel, and an expired or elsewhere-scoped token does not open this door (scoped approvals need kind "
|
|
316
|
-
+ context.refusalQueueHint(a.root, { kind:
|
|
322
|
+
+ 'spec_approve requires an out-of-band HOLMES_APPROVAL that COVERS this act — a request-payload approval is not a channel, and an expired or elsewhere-scoped token does not open this door (scoped approvals need kind "' + approval_queue_1.SPEC_TRANSITION_KIND.seal + '"). (fail-closed)'
|
|
323
|
+
+ context.refusalQueueHint(a.root, { kind: approval_queue_1.SPEC_TRANSITION_KIND.seal, target: a.id, why: '스펙 봉인 승인', ...(subject ? { subject } : {}), ...(risk ? { risk } : {}), ...(title ? { title } : {}) }) };
|
|
317
324
|
}
|
|
318
325
|
// @implements A-SPEC-188 — destination BEFORE seal.
|
|
319
326
|
// The old order (seal at :481, resolve the ledger at :483) produced both measured harms: a
|
|
@@ -396,14 +403,14 @@ function createSpecApprovalHandlers(context) {
|
|
|
396
403
|
// Measured 2026-09-14: a grant read against "Original title" sealed "CHANGED after the grant".
|
|
397
404
|
if (cur && decidedSubject !== undefined && (0, spec_digest_1.specDigest)(cur.spec) !== decidedSubject) {
|
|
398
405
|
return { ok: false, reason: `spec_approve: ${a.id} changed after the decision was made — the content decided on is not the content that would be sealed. Nothing was sealed; ask again.`
|
|
399
|
-
+ context.refusalQueueHint(a.root, { kind:
|
|
406
|
+
+ context.refusalQueueHint(a.root, { kind: approval_queue_1.SPEC_TRANSITION_KIND.seal, target: a.id, why: '스펙 봉인 승인', subject: (0, spec_digest_1.specDigest)(cur.spec), title: cur.spec.title }) };
|
|
400
407
|
}
|
|
401
408
|
if (cur && approveResolved.source === 'grant') {
|
|
402
409
|
const bound = approveResolved.approval;
|
|
403
410
|
if (typeof bound.subject === 'string' && bound.subject !== '' && bound.subject !== (0, spec_digest_1.specDigest)(cur.spec)) {
|
|
404
411
|
const current = (0, spec_digest_1.specDigest)(cur.spec);
|
|
405
412
|
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
|
|
406
|
-
+ context.refusalQueueHint(a.root, { kind:
|
|
413
|
+
+ context.refusalQueueHint(a.root, { kind: approval_queue_1.SPEC_TRANSITION_KIND.seal, target: a.id, why: '스펙 봉인 승인', subject: current, title: cur.spec.title }) };
|
|
407
414
|
}
|
|
408
415
|
}
|
|
409
416
|
// @implements A-SPEC-536.1 — BUG-1: a spec whose YAML is broken is dropped by read()/list(),
|
|
@@ -491,12 +498,23 @@ function createSpecApprovalHandlers(context) {
|
|
|
491
498
|
}
|
|
492
499
|
// @implements A-SPEC-148 — writes go to THIS replica's chain; the legacy file is read-only now.
|
|
493
500
|
const chain = new ledger_store_1.FileLedgerStore(path.join(ledgerRoot, '.ax', 'ledger'));
|
|
501
|
+
// A-SPEC-794.81 — the MCP server instance that sealed it, last, so id and digest keep their places (R8's "this session")
|
|
502
|
+
const sealingSession = context.serverInstance?.(); // A-SPEC-794.85 — injected, not the module-global
|
|
503
|
+
// @implements A-SPEC-794.95 — a seal by a grant the person minted at the terminal (holmes-kit approve, after
|
|
504
|
+
// operatorActGuard) records its channel and the grant's nonce, so the seal counts as a person's (isPersonSealRow);
|
|
505
|
+
// the server writes these from the resolved grant file, never from a tool input. A person-channel actor needs neither.
|
|
506
|
+
// (round-2 review A, L1: a grant the session form minted spends as `grant:<id>` and is not the terminal's)
|
|
507
|
+
const grantNonce = approveResolved.source === 'grant' && !(0, human_channel_1.isHumanChannelActor)(approveResolved.approval.actor)
|
|
508
|
+
&& !String(approveResolved.approval.actor).startsWith('grant:')
|
|
509
|
+
&& typeof approveResolved.approval.nonce === 'string' && /^[A-Za-z0-9_-]{8,}$/.test(approveResolved.approval.nonce)
|
|
510
|
+
? approveResolved.approval.nonce : undefined;
|
|
494
511
|
chain.append({
|
|
495
512
|
ts: new Date().toISOString(),
|
|
496
513
|
actor: approveResolved.approval.actor,
|
|
497
514
|
kind: 'spec-approved',
|
|
498
515
|
summary: `approved ${a.id} sealing ${digest}${sealedDirection}`,
|
|
499
|
-
inputs: [a.id, digest],
|
|
516
|
+
inputs: [a.id, digest, ...(sealingSession === undefined ? [] : [`session:${sealingSession}`]),
|
|
517
|
+
...(grantNonce === undefined ? [] : ['channel:cli-terminal', `grant-nonce:${grantNonce}`])],
|
|
500
518
|
rationale: approveResolved.approval.rationale,
|
|
501
519
|
authorization: (0, provenance_chain_1.authorizationRef)(approveResolved.approval.actor, approveResolved.approval.token),
|
|
502
520
|
});
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createSpecLifecycleHandlers = createSpecLifecycleHandlers;
|
|
37
|
-
// @implements A-SPEC-770.12, A-SPEC-628, A-SPEC-627.1, A-SPEC-621, A-SPEC-100.2, A-SPEC-128, A-SPEC-151, A-SPEC-222, A-SPEC-538.1, A-SPEC-255, A-SPEC-133, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245
|
|
37
|
+
// @implements A-SPEC-794.85, A-SPEC-794.81, A-SPEC-770.12, A-SPEC-628, A-SPEC-627.1, A-SPEC-621, A-SPEC-100.2, A-SPEC-128, A-SPEC-151, A-SPEC-222, A-SPEC-538.1, A-SPEC-255, A-SPEC-133, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245
|
|
38
38
|
// @implements A-SPEC-638, A-SPEC-222.3, A-SPEC-222.5, A-SPEC-245.9, A-SPEC-245.15
|
|
39
39
|
const fs = __importStar(require("node:fs"));
|
|
40
40
|
const os = __importStar(require("node:os"));
|
|
@@ -57,6 +57,7 @@ const approval_grants_1 = require("../../governance/approval-grants");
|
|
|
57
57
|
const renumber_1 = require("../../spec/renumber");
|
|
58
58
|
const id_collision_1 = require("../../spec/id-collision");
|
|
59
59
|
const remote_spec_refs_1 = require("../../spec/remote-spec-refs");
|
|
60
|
+
const approval_queue_1 = require("../../governance/approval-queue"); // @implements A-SPEC-794.85
|
|
60
61
|
/**
|
|
61
62
|
* @implements A-SPEC-222.5 — the machine conditions that stand in for a person when a sealed spec is retired in favour
|
|
62
63
|
* of a sealed successor (AU1-a). Every spec of the chain is judged; the first failed condition is the answer.
|
|
@@ -466,7 +467,8 @@ function createSpecLifecycleHandlers(context) {
|
|
|
466
467
|
catch {
|
|
467
468
|
approval = undefined;
|
|
468
469
|
}
|
|
469
|
-
|
|
470
|
+
// A-SPEC-794.81 — retiring a sealed spec is its own kind: a seal's grant does not cover it
|
|
471
|
+
const retireResolved = context.resolveHandlerApproval(a.root, approval, { kind: approval_queue_1.SPEC_TRANSITION_KIND.retire, target: a.id }, new Date().toISOString());
|
|
470
472
|
const covered = retireResolved !== undefined;
|
|
471
473
|
const sealed = typeof spec.frontmatter.approved_digest === 'string';
|
|
472
474
|
// @implements A-SPEC-222.5 — under a full profile, a directive and a sealed successor stand in for the person
|
|
@@ -559,8 +561,8 @@ function createSpecLifecycleHandlers(context) {
|
|
|
559
561
|
reason: (autonomousRefused ? `자율 폐기 조건 불충족(${autonomousRefused}) — ` : '')
|
|
560
562
|
+ `${a.id}은(는) 봉인된 문서입니다 — 폐기는 이 행위를 덮는 유효한 대역외 HOLMES_APPROVAL 이 필요합니다.`
|
|
561
563
|
+ ' 코드 게이트를 막고 있는 approved T-SPEC 을 폐기하면 그 게이트가 열리므로, 폐기가 승인 우회 경로가 되지 않도록 fail-closed 로 막습니다.'
|
|
562
|
-
+
|
|
563
|
-
+ context.refusalQueueHint(a.root, { kind:
|
|
564
|
+
+ ` (범위를 쓰면 kind "${approval_queue_1.SPEC_TRANSITION_KIND.retire}")`
|
|
565
|
+
+ context.refusalQueueHint(a.root, { kind: approval_queue_1.SPEC_TRANSITION_KIND.retire, target: a.id, why: '봉인된 스펙의 폐기', title: spec.title }),
|
|
564
566
|
};
|
|
565
567
|
}
|
|
566
568
|
// @implements A-SPEC-245, A-SPEC-245.1, A-SPEC-245.2 — a grant that authorized breaking a seal is claimed for the act
|
|
@@ -819,14 +821,15 @@ function createSpecLifecycleHandlers(context) {
|
|
|
819
821
|
catch {
|
|
820
822
|
approval = undefined;
|
|
821
823
|
}
|
|
822
|
-
|
|
824
|
+
// A-SPEC-794.81 — un-sealing is its own kind: a seal's grant does not cover it
|
|
825
|
+
const resolved = context.resolveHandlerApproval(a.root, approval, { kind: approval_queue_1.SPEC_TRANSITION_KIND.unseal, target: a.id }, new Date().toISOString());
|
|
823
826
|
if (resolved === undefined) {
|
|
824
827
|
return {
|
|
825
828
|
ok: false,
|
|
826
829
|
reason: `${a.id}은(는) 봉인된 문서입니다 — 봉인 해제는 이 행위를 덮는 유효한 대역외 HOLMES_APPROVAL 이 필요합니다.`
|
|
827
830
|
+ ' 봉인을 해제하면 코드 게이트가 요구하던 approved 스펙의 봉인이 사라지므로, 해제가 승인 우회 경로가 되지 않도록 fail-closed 로 막습니다.'
|
|
828
|
-
+
|
|
829
|
-
+ context.refusalQueueHint(a.root, { kind:
|
|
831
|
+
+ ` (범위를 쓰면 kind "${approval_queue_1.SPEC_TRANSITION_KIND.unseal}")`
|
|
832
|
+
+ context.refusalQueueHint(a.root, { kind: approval_queue_1.SPEC_TRANSITION_KIND.unseal, target: a.id, why: '봉인된 스펙의 해제', title: spec.title }),
|
|
830
833
|
};
|
|
831
834
|
}
|
|
832
835
|
// @implements A-SPEC-245, A-SPEC-245.1, A-SPEC-245.2 — the act runs inside the grant's claim: spent by the write it
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createTestExecutionHandlers = createTestExecutionHandlers;
|
|
37
|
-
// @implements A-SPEC-616, A-SPEC-100.2, A-SPEC-102.1, A-SPEC-121.2, A-SPEC-121.3, A-SPEC-128, A-SPEC-130, A-SPEC-189, A-SPEC-233, A-SPEC-419, A-SPEC-433, A-SPEC-534.5, A-SPEC-534.8, A-SPEC-578.4, A-SPEC-614, A-SPEC-734, A-SPEC-768.1, A-SPEC-466.1, A-SPEC-466.2, A-SPEC-466.3, A-SPEC-466.6, A-SPEC-128.2, A-SPEC-128.4, A-SPEC-128.5, A-SPEC-128.6, A-SPEC-128.7, A-SPEC-128.8, A-SPEC-128.9, A-SPEC-128.10, A-SPEC-128.13
|
|
37
|
+
// @implements A-SPEC-616, A-SPEC-100.2, A-SPEC-102.1, A-SPEC-121.2, A-SPEC-121.3, A-SPEC-128, A-SPEC-130, A-SPEC-189, A-SPEC-233, A-SPEC-419, A-SPEC-433, A-SPEC-534.5, A-SPEC-534.8, A-SPEC-578.4, A-SPEC-614, A-SPEC-734, A-SPEC-768.1, A-SPEC-466.1, A-SPEC-466.2, A-SPEC-466.3, A-SPEC-466.6, A-SPEC-128.2, A-SPEC-128.4, A-SPEC-128.5, A-SPEC-128.6, A-SPEC-128.7, A-SPEC-128.8, A-SPEC-128.9, A-SPEC-128.10, A-SPEC-128.13, A-SPEC-794.119
|
|
38
38
|
const fs = __importStar(require("node:fs"));
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
40
|
const node_child_process_1 = require("node:child_process");
|
|
@@ -255,7 +255,9 @@ function createTestExecutionHandlers(context) {
|
|
|
255
255
|
? { tier: testScope.tier, mode: 'full', ranFiles: [], passed: false, skipped: false, tail: opened.reason, executedByFile: {}, ranWith: [], workers: null,
|
|
256
256
|
testsRun: 0, testsRunBy: {}, stopped: false, detected: [], units: [], environment: [{ ecosystem: 'git', dir: '', reason: opened.reason }] }
|
|
257
257
|
// @implements A-SPEC-128.15 — L6: prepare and the units share one budget (at least one second is left for the units)
|
|
258
|
-
|
|
258
|
+
// @implements A-SPEC-794.119 — projectRoot: the tree that runs (HEAD's worktree in a full run) is what the test
|
|
259
|
+
// children's CLAUDE_PROJECT_DIR names, not the checkout the server's environment carries
|
|
260
|
+
: (0, test_runner_1.runTestScope)(testScope, execRoot, { ...(workers === undefined ? {} : { workers }), excludeDirs, isIgnored, projectRoot: execRoot,
|
|
259
261
|
timeoutMinutes: opened?.ok ? Math.max(1 / 60, timeoutMinutes - opened.wt.prepareMs / 60_000) : timeoutMinutes, ...(opened?.ok ? { sourceRoot: root } : {}) });
|
|
260
262
|
anchors = (0, test_scope_1.scanTestAnchors)(execRoot);
|
|
261
263
|
anchorRows = (0, test_scope_1.scanTestAnchorDiagnostics)(execRoot);
|