@holmes-lab/holmes-kit 0.40.0 → 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 +312 -0
- package/README.md +79 -5
- 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 +394 -267
- package/dist/holmes/cli/init.js +17 -6
- package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
- package/dist/holmes/cli/interactive-prompt.js +98 -16
- 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 +21 -0
- package/dist/holmes/config/config.js +22 -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 +216 -0
- package/dist/holmes/governance/autonomy.js +1162 -10
- 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/push-gate-runner.d.ts +2 -0
- package/dist/holmes/governance/push-gate-runner.js +40 -3
- package/dist/holmes/governance/push-gate.d.ts +13 -2
- package/dist/holmes/governance/push-gate.js +106 -14
- 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/advisory-line.d.ts +102 -0
- package/dist/holmes/guardrail/advisory-line.js +718 -0
- 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/impact-gate.d.ts +6 -0
- package/dist/holmes/guardrail/impact-gate.js +32 -5
- 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 +71 -0
- package/dist/holmes/hooks/pre-tool-use.js +1466 -14
- package/dist/holmes/hooks/session-start.js +27 -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/maintenance-analysis.d.ts +13 -0
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -0
- package/dist/holmes/mcp/handlers/operator-inspection.js +25 -4
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -1
- package/dist/holmes/mcp/handlers/spec-approval.js +28 -10
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +10 -7
- package/dist/holmes/mcp/handlers/test-execution.d.ts +470 -3
- package/dist/holmes/mcp/handlers/test-execution.js +201 -21
- package/dist/holmes/mcp/handlers.d.ts +473 -8
- package/dist/holmes/mcp/handlers.js +6 -1
- package/dist/holmes/mcp/maintenance-analyze.d.ts +5 -0
- package/dist/holmes/mcp/maintenance-analyze.js +4 -2
- package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
- package/dist/holmes/mcp/maintenance-evidence.js +4 -1
- package/dist/holmes/mcp/tool-schemas.js +16 -10
- package/dist/holmes/project/baseline.d.ts +15 -2
- package/dist/holmes/project/baseline.js +11 -6
- package/dist/holmes/project/bounded-io.d.ts +1 -0
- package/dist/holmes/project/bounded-io.js +4 -2
- package/dist/holmes/project/change-source.d.ts +4 -0
- package/dist/holmes/project/change-source.js +13 -5
- 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 +26 -3
- package/dist/holmes/project/running-package.d.ts +15 -0
- package/dist/holmes/project/running-package.js +87 -0
- package/dist/holmes/review/evidence-mode.d.ts +21 -0
- package/dist/holmes/review/evidence-mode.js +33 -0
- package/dist/holmes/review/head-worktree.d.ts +55 -0
- package/dist/holmes/review/head-worktree.js +329 -0
- package/dist/holmes/review/mrp.js +13 -3
- package/dist/holmes/review/run-provenance.d.ts +45 -0
- package/dist/holmes/review/run-provenance.js +314 -0
- package/dist/holmes/review/test-evidence.d.ts +174 -0
- package/dist/holmes/review/test-evidence.js +330 -2
- package/dist/holmes/review/test-reports.d.ts +94 -0
- package/dist/holmes/review/test-reports.js +382 -0
- package/dist/holmes/review/test-runner.d.ts +178 -65
- package/dist/holmes/review/test-runner.js +551 -319
- package/dist/holmes/review/test-units.d.ts +159 -0
- package/dist/holmes/review/test-units.js +814 -0
- 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
- package/playbooks/publish/PLAYBOOK.md +2 -1
|
@@ -51,8 +51,9 @@ exports.keyedSelfConsistent = keyedSelfConsistent;
|
|
|
51
51
|
exports.bodyCanon = bodyCanon;
|
|
52
52
|
exports.parseLedgerLines = parseLedgerLines;
|
|
53
53
|
exports.consumeNonceExclusively = consumeNonceExclusively;
|
|
54
|
-
// @implements A-SPEC-125.2, A-SPEC-624, A-SPEC-734, A-SPEC-794.46
|
|
54
|
+
// @implements A-SPEC-125.2, A-SPEC-624, A-SPEC-734, A-SPEC-794.46, A-SPEC-794.115
|
|
55
55
|
const execution_context_1 = require("../project/execution-context");
|
|
56
|
+
const witness = __importStar(require("./ledger-witness"));
|
|
56
57
|
const crypto = __importStar(require("node:crypto"));
|
|
57
58
|
const fs = __importStar(require("node:fs"));
|
|
58
59
|
const path = __importStar(require("node:path"));
|
|
@@ -392,12 +393,30 @@ class ProvenanceChain {
|
|
|
392
393
|
appendInsideLock(body) {
|
|
393
394
|
return this.appendUnlocked(body);
|
|
394
395
|
}
|
|
395
|
-
/**
|
|
396
|
+
/**
|
|
397
|
+
* The append itself, assuming exclusion is already held. Only callers INSIDE a hold may use it.
|
|
398
|
+
*
|
|
399
|
+
* @implements A-SPEC-794.115 — the chain's one write point, so the ledger witness of A-SPEC-794.114 moves here and
|
|
400
|
+
* nowhere else: every append, the grant spend (`consumeNonceExclusively` appends inside its own hold) and the
|
|
401
|
+
* stale-lock record. The witness's pending entry is written before the row, its head after; the witness module decides
|
|
402
|
+
* whether to move at all (it never creates an entry, and never moves one the current file does not match).
|
|
403
|
+
*/
|
|
396
404
|
appendUnlocked(body) {
|
|
397
|
-
|
|
405
|
+
let before = '';
|
|
406
|
+
try {
|
|
407
|
+
before = (0, bounded_io_1.readRegularTextSync)(this.file);
|
|
408
|
+
}
|
|
409
|
+
catch (err) {
|
|
410
|
+
if (err.code !== 'ENOENT')
|
|
411
|
+
throw err;
|
|
412
|
+
}
|
|
413
|
+
const chain = parseLedgerLines(before, this.file, { throwOnCorruption: false });
|
|
398
414
|
const evt = chainNext(chain, writtenBody(body), process.env.HOLMES_LEDGER_KEY || undefined);
|
|
415
|
+
const line = JSON.stringify(evt) + '\n';
|
|
416
|
+
const token = witness.beforeAppend(this.file, before, evt, line);
|
|
399
417
|
fs.mkdirSync(path.dirname(this.file), { recursive: true });
|
|
400
|
-
fs.appendFileSync(this.file,
|
|
418
|
+
fs.appendFileSync(this.file, line, 'utf8');
|
|
419
|
+
witness.afterAppend(token);
|
|
401
420
|
return evt;
|
|
402
421
|
}
|
|
403
422
|
/**
|
|
@@ -19,5 +19,7 @@ export interface PrePushIo {
|
|
|
19
19
|
* gate stays fail-open on collection errors, H-SPEC-509).
|
|
20
20
|
*/
|
|
21
21
|
export declare function runPushReviewRefusal(cwd: string, env: NodeJS.ProcessEnv, sha: string): string | null;
|
|
22
|
+
/** @implements A-SPEC-128.8 — the ledger of pushes allowed without evidence (D3); appended, never read by the gate. */
|
|
23
|
+
export declare const NO_EVIDENCE_PUSHES_FILE: string;
|
|
22
24
|
/** Exit code of the hook: 0 = push proceeds, 1 = refused. */
|
|
23
25
|
export declare function runPrePush(io: PrePushIo): 0 | 1;
|
|
@@ -33,10 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NO_EVIDENCE_PUSHES_FILE = void 0;
|
|
36
37
|
exports.effectiveHooksDir = effectiveHooksDir;
|
|
37
38
|
exports.runPushReviewRefusal = runPushReviewRefusal;
|
|
38
39
|
exports.runPrePush = runPrePush;
|
|
39
|
-
// @implements A-SPEC-509.1, A-SPEC-734, A-SPEC-102.4, A-SPEC-774.21, A-SPEC-102.12
|
|
40
|
+
// @implements A-SPEC-509.1, A-SPEC-734, A-SPEC-102.4, A-SPEC-774.21, A-SPEC-102.12, A-SPEC-128.3, A-SPEC-128.4, A-SPEC-128.5, A-SPEC-128.7, A-SPEC-128.8, A-SPEC-128.9
|
|
40
41
|
/**
|
|
41
42
|
* The push gate's IMPURE half: collect (stdin lines, git facts, the evidence ledger) and hand
|
|
42
43
|
* everything to the pure judgePush. Any collection failure ALLOWS — this gate safens the default
|
|
@@ -110,6 +111,23 @@ function runPushReviewRefusal(cwd, env, sha) {
|
|
|
110
111
|
return cannot(e instanceof Error ? e.message : String(e));
|
|
111
112
|
}
|
|
112
113
|
}
|
|
114
|
+
/** @implements A-SPEC-128.8 — the ledger of pushes allowed without evidence (D3); appended, never read by the gate. */
|
|
115
|
+
exports.NO_EVIDENCE_PUSHES_FILE = path.join('.ax', 'ledger', 'no-evidence-pushes.jsonl');
|
|
116
|
+
/**
|
|
117
|
+
* @implements A-SPEC-128.9 — E2: the line is `{ts, head, reason: 'no-tests'}`. False when it could not be written, so the
|
|
118
|
+
* hook can say so; the record is observation and never changes the verdict.
|
|
119
|
+
*/
|
|
120
|
+
function recordNoEvidencePush(cwd, head) {
|
|
121
|
+
try {
|
|
122
|
+
const file = path.join(cwd, exports.NO_EVIDENCE_PUSHES_FILE);
|
|
123
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
124
|
+
fs.appendFileSync(file, JSON.stringify({ ts: new Date().toISOString(), head, reason: 'no-tests' }) + '\n', 'utf8');
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
113
131
|
/** Exit code of the hook: 0 = push proceeds, 1 = refused. */
|
|
114
132
|
function runPrePush(io) {
|
|
115
133
|
try {
|
|
@@ -119,7 +137,13 @@ function runPrePush(io) {
|
|
|
119
137
|
const hasGovernance = fs.existsSync(path.join(io.cwd, '.ax'));
|
|
120
138
|
if (!hasGovernance)
|
|
121
139
|
return 0; // un-adopted: silent
|
|
122
|
-
|
|
140
|
+
// @implements A-SPEC-128.5 — an existing test-evidence file that is not a record is 'unreadable', never absent
|
|
141
|
+
const full = (0, test_evidence_1.testEvidenceState)(io.cwd);
|
|
142
|
+
const evidence = full.state === 'unreadable' ? 'unreadable' : full.evidence ?? null;
|
|
143
|
+
// @implements A-SPEC-128.3 — read only when there is no full ledger; the judgement stays in judgePush
|
|
144
|
+
// @implements A-SPEC-128.4 — an existing file that is not a record is passed as 'unreadable', never as absent
|
|
145
|
+
const scoped = evidence ? null : (0, test_evidence_1.scopedEvidenceState)(io.cwd);
|
|
146
|
+
const scopedEvidence = !scoped || scoped.state === 'absent' ? null : scoped.state === 'unreadable' ? 'unreadable' : scoped.evidence ?? null;
|
|
123
147
|
let refused = false;
|
|
124
148
|
for (const line of lines) {
|
|
125
149
|
let claimCommits = [];
|
|
@@ -134,9 +158,22 @@ function runPrePush(io) {
|
|
|
134
158
|
});
|
|
135
159
|
}
|
|
136
160
|
catch { /* claim surfacing is optional — judgment inputs stay deterministic */ }
|
|
137
|
-
|
|
161
|
+
// @implements A-SPEC-128.7 — an exception INSIDE the judgement is not a collection failure: the gate could not judge
|
|
162
|
+
// the records it read, so it refuses, naming the exception (a malformed record threw here and the hook exited 0)
|
|
163
|
+
let v;
|
|
164
|
+
try {
|
|
165
|
+
v = (0, push_gate_1.judgePush)({ pushedHead: line.localSha, evidence, hasGovernance, claimCommits, scopedEvidence });
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
v = { allow: false, notices: [], reason: `[Holmes-Kit push 게이트] 원장 기록을 판정하지 못했습니다(${e instanceof Error ? e.message : String(e)}) — 기록을 새로 쓰십시오. 복구: 현재 HEAD에서 ${push_gate_1.FULL_RUN_CALL}를 실행한 뒤 다시 push하십시오. 의도적 우회는 git push --no-verify.` };
|
|
169
|
+
}
|
|
138
170
|
for (const n of v.notices)
|
|
139
171
|
io.write(n + '\n');
|
|
172
|
+
// @implements A-SPEC-128.8 — D3: a push allowed without evidence is a line in the ledger, not only a notice
|
|
173
|
+
// @implements A-SPEC-128.9 — a ledger line that could not be written is said, not swallowed
|
|
174
|
+
if (v.allow && v.noEvidencePush && !recordNoEvidencePush(io.cwd, line.localSha)) {
|
|
175
|
+
io.write(`[Holmes-Kit] 증빙 없는 push를 원장(${exports.NO_EVIDENCE_PUSHES_FILE})에 기록하지 못했습니다\n`);
|
|
176
|
+
}
|
|
140
177
|
if (!v.allow) {
|
|
141
178
|
io.write((v.reason ?? '[Holmes-Kit push 게이트] 거부') + '\n');
|
|
142
179
|
refused = true;
|
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
* gates own security). And `git push --no-verify` is git's own escape hatch — respected, not
|
|
10
10
|
* re-litigated: this gate safens the default, it does not take the human's final say.
|
|
11
11
|
*/
|
|
12
|
-
import type
|
|
12
|
+
import { type ScopedEvidence, type TestEvidence } from '../review/test-evidence';
|
|
13
|
+
import { FULL_RUN_CALL } from '../review/evidence-mode';
|
|
13
14
|
/** Identifies OUR installed hook — the single truth doctor and re-install both key on. */
|
|
14
15
|
export declare const PUSH_HOOK_SIGNATURE = "HOLMES-KIT PUSH GATE v1";
|
|
15
16
|
export interface PushJudgeInput {
|
|
16
17
|
pushedHead: string;
|
|
17
|
-
evidence
|
|
18
|
+
/** @implements A-SPEC-128.5 — `'unreadable'`: the test-evidence file exists but is not a record. */
|
|
19
|
+
evidence: TestEvidence | 'unreadable' | null;
|
|
18
20
|
/** `.ax` exists — the repo opted into governance. */
|
|
19
21
|
hasGovernance: boolean;
|
|
20
22
|
/** Commits in the pushed range, for the claim cross-check (surfacing only). */
|
|
@@ -22,11 +24,20 @@ export interface PushJudgeInput {
|
|
|
22
24
|
sha: string;
|
|
23
25
|
subject: string;
|
|
24
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* @implements A-SPEC-128.3 — the record of a run that was not full; read only when there is no test-evidence.
|
|
29
|
+
* @implements A-SPEC-128.4 — `'unreadable'`: the file exists but is not a record.
|
|
30
|
+
*/
|
|
31
|
+
scopedEvidence?: ScopedEvidence | 'unreadable' | null;
|
|
25
32
|
}
|
|
33
|
+
/** @implements A-SPEC-128.4 — the one call that clears a refusal (A-SPEC-128.5: it lives in review/evidence-mode). */
|
|
34
|
+
export { FULL_RUN_CALL };
|
|
26
35
|
export interface PushVerdict {
|
|
27
36
|
allow: boolean;
|
|
28
37
|
reason?: string;
|
|
29
38
|
notices: string[];
|
|
39
|
+
/** @implements A-SPEC-128.8 — D3: allowed without evidence because the root has nothing to run; the runner records it. */
|
|
40
|
+
noEvidencePush?: true;
|
|
30
41
|
}
|
|
31
42
|
export declare function judgePush(input: PushJudgeInput): PushVerdict;
|
|
32
43
|
/**
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PUSH_HOOK_SIGNATURE = void 0;
|
|
3
|
+
exports.FULL_RUN_CALL = exports.PUSH_HOOK_SIGNATURE = void 0;
|
|
4
4
|
exports.judgePush = judgePush;
|
|
5
5
|
exports.parsePushLines = parsePushLines;
|
|
6
|
+
// @implements A-SPEC-509.1, A-SPEC-128.2, A-SPEC-128.3, 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.12
|
|
7
|
+
/**
|
|
8
|
+
* The push gate's PURE judgment. A push is the moment a commit becomes other agents' baseline
|
|
9
|
+
* (field basis: a multi-agent regression reached production unguarded), so the default is made
|
|
10
|
+
* safe: the test-evidence ledger must vouch for EXACTLY the head being pushed, green, with real
|
|
11
|
+
* executions. Deterministic facts only — commit-message prose ("전체 스위트 초록") never moves
|
|
12
|
+
* the verdict; an unbacked claim is SURFACED as a notice so the dishonesty is audible.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately NOT a security boundary: collection failures and un-adopted repos pass (the tool
|
|
15
|
+
* gates own security). And `git push --no-verify` is git's own escape hatch — respected, not
|
|
16
|
+
* re-litigated: this gate safens the default, it does not take the human's final say.
|
|
17
|
+
*/
|
|
18
|
+
const test_evidence_1 = require("../review/test-evidence");
|
|
19
|
+
const evidence_mode_1 = require("../review/evidence-mode");
|
|
20
|
+
Object.defineProperty(exports, "FULL_RUN_CALL", { enumerable: true, get: function () { return evidence_mode_1.FULL_RUN_CALL; } });
|
|
6
21
|
/** Identifies OUR installed hook — the single truth doctor and re-install both key on. */
|
|
7
22
|
exports.PUSH_HOOK_SIGNATURE = 'HOLMES-KIT PUSH GATE v1';
|
|
23
|
+
/** @implements A-SPEC-128.2, A-SPEC-128.3, A-SPEC-128.4 — the recovery and escape every refusal carries. */
|
|
24
|
+
const RECOVERY = `복구: 현재 HEAD에서 ${evidence_mode_1.FULL_RUN_CALL}를 초록으로 실행해 원장을 갱신한 뒤 다시 push하십시오. 의도적 우회는 git push --no-verify.`;
|
|
8
25
|
/** Prose that CLAIMS a test success — a surfacing pattern, never a judgment input. */
|
|
9
26
|
const SUCCESS_CLAIM_RE = /초록|green|pass(es|ed)?\b|✅/i;
|
|
10
27
|
// @implements A-SPEC-509.1
|
|
@@ -12,37 +29,112 @@ function judgePush(input) {
|
|
|
12
29
|
if (!input.hasGovernance)
|
|
13
30
|
return { allow: true, notices: [] }; // un-adopted: never coerce adoption
|
|
14
31
|
const notices = [];
|
|
15
|
-
const ev = input.evidence;
|
|
32
|
+
const ev = input.evidence === 'unreadable' ? null : input.evidence;
|
|
16
33
|
// Claim cross-check first — it rides allow AND deny alike.
|
|
17
34
|
for (const c of input.claimCommits) {
|
|
18
35
|
if (!SUCCESS_CLAIM_RE.test(c.subject))
|
|
19
36
|
continue;
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
// the ledger backs this claim (A-SPEC-128.2: full only; @implements A-SPEC-128.7 — by the one predicate)
|
|
38
|
+
if (ev && (0, test_evidence_1.isPushEvidence)(ev, c.sha))
|
|
39
|
+
continue;
|
|
22
40
|
notices.push(`[Holmes-Kit] 커밋 ${c.sha.slice(0, 7)}의 메시지가 테스트 성공을 주장하지만 test_run 원장이 그 커밋을 뒷받침하지 않습니다: "${flatSubject(c.subject)}"`);
|
|
23
41
|
}
|
|
42
|
+
// @implements A-SPEC-128.5 — an unreadable ledger is a run history the gate cannot read: refused, not the unrun pass
|
|
43
|
+
if (input.evidence === 'unreadable') {
|
|
44
|
+
return {
|
|
45
|
+
allow: false,
|
|
46
|
+
reason: `[Holmes-Kit push 게이트] test-evidence 원장 파일(${test_evidence_1.EVIDENCE_FILE})이 있지만 읽을 수 있는 기록이 아닙니다 — full test_run 필요. ${RECOVERY}`,
|
|
47
|
+
notices,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
24
50
|
if (!ev) {
|
|
51
|
+
// @implements A-SPEC-128.3 — a repository whose runs have all been scoped has run tests: it is not the unrun pass.
|
|
52
|
+
// @implements A-SPEC-128.4 — a scoped record that exists but cannot be read is still a run history
|
|
53
|
+
if (input.scopedEvidence === 'unreadable') {
|
|
54
|
+
return {
|
|
55
|
+
allow: false,
|
|
56
|
+
reason: `[Holmes-Kit push 게이트] full 실행 원장이 없고, 범위 실행 기록 파일(${test_evidence_1.SCOPED_EVIDENCE_FILE})이 있지만 읽을 수 있는 기록이 아닙니다 — 실행 이력이 있으므로 full test_run 필요. ${RECOVERY}`,
|
|
57
|
+
notices,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (input.scopedEvidence) {
|
|
61
|
+
noticeNotDetected(input.scopedEvidence, notices);
|
|
62
|
+
// @implements A-SPEC-128.5 — a full attempt (red, stopped, or short of an ecosystem) is named as such
|
|
63
|
+
// @implements A-SPEC-128.6 — the ecosystems that ran nothing are named
|
|
64
|
+
// @implements A-SPEC-128.7 — with the act that clears it (I2), read fail-closed on shape
|
|
65
|
+
if (input.scopedEvidence.mode === 'full-attempt') {
|
|
66
|
+
const allowed = nothingTestable(input.scopedEvidence, input.pushedHead, notices);
|
|
67
|
+
if (allowed)
|
|
68
|
+
return allowed;
|
|
69
|
+
const v = (0, test_evidence_1.attemptVerdict)(input.scopedEvidence, input.pushedHead);
|
|
70
|
+
return { allow: false, reason: `[Holmes-Kit push 게이트] full 실행 원장이 없고 full 실행 시도 기록만 있습니다: ${v.problem} — ${recoveryFor(v)}`, notices };
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
allow: false,
|
|
74
|
+
reason: `[Holmes-Kit push 게이트] full 실행 원장이 없고 범위 실행 기록만 있습니다(${(0, test_evidence_1.evidenceKind)(input.scopedEvidence)}) — 범위 초록은 증빙이 아닙니다, full test_run 필요. ${RECOVERY}`,
|
|
75
|
+
notices,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
25
78
|
// Adopted but no ledger yet: pass honestly, say how to activate. A broken ledger folds here
|
|
26
79
|
// too — the gate is a default-safener, not a security boundary, so it must not dead-lock a
|
|
27
80
|
// repo whose ledger file was corrupted.
|
|
28
|
-
notices.push(
|
|
81
|
+
notices.push(`[Holmes-Kit] test-evidence 원장이 없어 push 증빙 대조를 건너뜁니다 — ${evidence_mode_1.FULL_RUN_CALL}를 실행하면 다음 push부터 대조가 활성화됩니다`);
|
|
29
82
|
return { allow: true, notices };
|
|
30
83
|
}
|
|
31
|
-
|
|
32
|
-
|
|
84
|
+
// @implements A-SPEC-128.2, A-SPEC-128.5 — only a full run's record, counting what the runner ran, is push evidence
|
|
85
|
+
// @implements A-SPEC-128.6 — decided by THE predicate the writer and mrp read; its reason is the refusal's
|
|
86
|
+
// @implements A-SPEC-128.7 — and its act words the recovery (I2)
|
|
87
|
+
noticeNotDetected(ev, notices);
|
|
88
|
+
// also where an attempt voided the older evidence in place
|
|
89
|
+
const allowed = nothingTestable(ev, input.pushedHead, notices);
|
|
90
|
+
if (allowed)
|
|
91
|
+
return allowed;
|
|
92
|
+
const v = (0, test_evidence_1.pushEvidenceVerdict)(ev, input.pushedHead);
|
|
93
|
+
if (v === null)
|
|
33
94
|
return { allow: true, notices };
|
|
34
|
-
}
|
|
35
|
-
const why = ev.head !== input.pushedHead
|
|
36
|
-
? `원장 head ${ev.head.slice(0, 7)} ≠ push head ${input.pushedHead.slice(0, 7)} — 증빙 이후 커밋이 있습니다`
|
|
37
|
-
: ev.passed !== true
|
|
38
|
-
? `원장이 붉은 실행(passed: false)입니다 — 붉은 스위트는 기준선이 될 수 없습니다`
|
|
39
|
-
: `원장이 아무것도 실행하지 않았습니다(executed 0) — no-op 초록은 증빙이 아닙니다`;
|
|
40
95
|
return {
|
|
41
96
|
allow: false,
|
|
42
|
-
reason: `[Holmes-Kit push 게이트] ${
|
|
97
|
+
reason: `[Holmes-Kit push 게이트] 원장이 push 증빙이 아닙니다: ${v.problem} — ${recoveryFor(v)}`,
|
|
43
98
|
notices,
|
|
44
99
|
};
|
|
45
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* @implements A-SPEC-128.7 — I2: the recovery a refusal carries is the act that reaches allow. Running the same call again
|
|
103
|
+
* cannot pass a real red or a suite of the project's own that ran nothing, so those say the fix is the tests.
|
|
104
|
+
*/
|
|
105
|
+
function recoveryFor(v) {
|
|
106
|
+
if (v.act === 'fix-tests') {
|
|
107
|
+
return `복구: 고칠 것은 시험입니다 — 시험을 고쳐 커밋한 뒤 ${evidence_mode_1.FULL_RUN_CALL}로 다시 증빙하십시오(같은 상태에서 다시 실행해도 결과는 같습니다). 의도적 우회는 git push --no-verify.`;
|
|
108
|
+
}
|
|
109
|
+
// @implements A-SPEC-128.9 — E4: environment carries its own words and no generic recovery (A L1)
|
|
110
|
+
if (v.act === 'environment')
|
|
111
|
+
return '복구: 실행 환경을 고치십시오(위 사유). 같은 환경에서 다시 실행해도 결과는 같습니다. 의도적 우회는 git push --no-verify.';
|
|
112
|
+
// @implements A-SPEC-128.10 — I3: a fact about tests that did not run; the remedy is the runner's configuration or the
|
|
113
|
+
// user's own exclusion, then the full call
|
|
114
|
+
if (v.act === 'collect')
|
|
115
|
+
return `복구: 위 시험이 실행되도록 러너 설정을 고치거나, 프로젝트 것이 아니면 제외한 뒤 ${evidence_mode_1.FULL_RUN_CALL}를 실행하십시오. 의도적 우회는 git push --no-verify.`;
|
|
116
|
+
return `full test_run 필요. ${RECOVERY}`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @implements A-SPEC-128.9 — E2, one place (B L3: the D3 notice was written twice): a full attempt that found nothing
|
|
120
|
+
* testable — no unit and no implementation code — is allowed, said, and recorded by the runner.
|
|
121
|
+
*/
|
|
122
|
+
function nothingTestable(rec, head, notices) {
|
|
123
|
+
if (!(0, test_evidence_1.noTestableCode)(rec, head))
|
|
124
|
+
return null;
|
|
125
|
+
notices.push('[Holmes-Kit] 시험할 대상이 없습니다(시험 파일도 구현 코드도 없음) — 이 push는 증빙 없이 허용되고 원장(no-evidence-pushes)에 기록됩니다');
|
|
126
|
+
return { allow: true, notices, noEvidencePush: true };
|
|
127
|
+
}
|
|
128
|
+
/** @implements A-SPEC-128.7 — build files the run left out are named on every push that reads the record. */
|
|
129
|
+
function noticeNotDetected(rec, notices) {
|
|
130
|
+
const list = rec.notDetected;
|
|
131
|
+
if (!Array.isArray(list) || list.length === 0)
|
|
132
|
+
return;
|
|
133
|
+
const names = list.map((n) => (n && typeof n === 'object' ? `${String(n.path)} (${String(n.ecosystem)})` : String(n)));
|
|
134
|
+
// @implements A-SPEC-128.10 — B M4: sub-modules run as units now; what is named here is a file no unit runs
|
|
135
|
+
// @implements A-SPEC-128.12 — and git submodules, which are always outside the evidence: one heading for both
|
|
136
|
+
notices.push(`[Holmes-Kit] 증빙 밖에 둔 것 — full 실행이 판정하지 않았습니다: ${names.join(', ')}`);
|
|
137
|
+
}
|
|
46
138
|
/** One control-character-free line of a commit subject for interpolation into gate text. */
|
|
47
139
|
function flatSubject(s) {
|
|
48
140
|
return s.replace(/[\u0000-\u001f\u007f]+/g, ' ').replace(/\s{2,}/g, ' ').trim().slice(0, 80);
|
|
@@ -36,6 +36,10 @@ export declare function trustedActor(e: {
|
|
|
36
36
|
actor?: unknown;
|
|
37
37
|
authorization?: unknown;
|
|
38
38
|
}): boolean;
|
|
39
|
+
export declare function trustedLedgerEventsCached(root: string): {
|
|
40
|
+
events: StoreEvent[];
|
|
41
|
+
ignored: IgnoredEvent[];
|
|
42
|
+
};
|
|
39
43
|
/** Every trusted event across the ledger's chains, and every event or chain that was ignored with its reason. */
|
|
40
44
|
export declare function trustedLedgerEvents(root: string, deps?: TrustDeps): {
|
|
41
45
|
events: StoreEvent[];
|
|
@@ -38,12 +38,13 @@ exports.headRefOf = headRefOf;
|
|
|
38
38
|
exports.headCommitOf = headCommitOf;
|
|
39
39
|
exports.committedLedgerTexts = committedLedgerTexts;
|
|
40
40
|
exports.trustedActor = trustedActor;
|
|
41
|
+
exports.trustedLedgerEventsCached = trustedLedgerEventsCached;
|
|
41
42
|
exports.trustedLedgerEvents = trustedLedgerEvents;
|
|
42
43
|
exports.ownLedgerShortened = ownLedgerShortened;
|
|
43
44
|
exports.approvedSeals = approvedSeals;
|
|
44
45
|
exports.recordedPairsPort = recordedPairsPort;
|
|
45
46
|
exports.describeIgnored = describeIgnored;
|
|
46
|
-
// @implements A-SPEC-222.9, A-SPEC-222.10, A-SPEC-222.12, A-SPEC-222.13
|
|
47
|
+
// @implements A-SPEC-222.9, A-SPEC-222.10, A-SPEC-222.12, A-SPEC-222.13, A-SPEC-794.95
|
|
47
48
|
/**
|
|
48
49
|
* The ledger events a successor, a seal or a provenance proof may be taken from (H1 of the 2026-10-25 review, SD1
|
|
49
50
|
* finding 2; A-SPEC-222.10 H-A, H-C, M-1): one port for every reader that needs trust, so none opens the ledger itself.
|
|
@@ -269,6 +270,29 @@ function trustedActor(e) {
|
|
|
269
270
|
const a = typeof e.authorization === 'string' ? e.authorization : '';
|
|
270
271
|
return a.startsWith(`${actor}:`) && /^[0-9a-f]{12}$/.test(a.slice(actor.length + 1)) && !/(?:^|:)unattested:/.test(a);
|
|
271
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* @implements A-SPEC-794.95 (B-M2) — trustedLedgerEvents over the real ledger, remembered in this process while every
|
|
275
|
+
* ledger file keeps its size and modification time and HEAD stays the same commit (a hook judging several things, and
|
|
276
|
+
* the MCP server, read it once). Nothing is kept on disk: a cache another process could write would forge seals.
|
|
277
|
+
*/
|
|
278
|
+
const trustedMemo = new Map();
|
|
279
|
+
function trustedLedgerEventsCached(root) {
|
|
280
|
+
let key;
|
|
281
|
+
try {
|
|
282
|
+
const dir = path.join(root, '.ax', 'ledger');
|
|
283
|
+
const files = fs.readdirSync(dir).filter((f) => f.endsWith('.jsonl')).sort();
|
|
284
|
+
key = files.map((f) => { const st = fs.statSync(path.join(dir, f)); return `${f}:${st.size}:${st.mtimeMs}`; }).join('|') + `|head:${headCommitOf(root) ?? ''}`;
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return trustedLedgerEvents(root);
|
|
288
|
+
}
|
|
289
|
+
const hit = trustedMemo.get(root);
|
|
290
|
+
if (hit && hit.key === key)
|
|
291
|
+
return hit.value;
|
|
292
|
+
const value = trustedLedgerEvents(root);
|
|
293
|
+
trustedMemo.set(root, { key, value });
|
|
294
|
+
return value;
|
|
295
|
+
}
|
|
272
296
|
/** Every trusted event across the ledger's chains, and every event or chain that was ignored with its reason. */
|
|
273
297
|
function trustedLedgerEvents(root, deps = realTrustDeps(root)) {
|
|
274
298
|
const ignored = [];
|
|
@@ -30,6 +30,12 @@ export interface ClientRecord {
|
|
|
30
30
|
ts: string;
|
|
31
31
|
replica?: string;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @implements A-SPEC-564.7 — the counting rule a usage record was made under. 564.5 changed usage/turns from per
|
|
35
|
+
* record to per response; a record without this marker is the old per-record count (about 2.7 times larger), and a
|
|
36
|
+
* reader must not add the two kinds together.
|
|
37
|
+
*/
|
|
38
|
+
export declare const USAGE_COUNT_RULE: "per-message-id";
|
|
33
39
|
export interface UsageRecord {
|
|
34
40
|
execution?: ExecutionContext;
|
|
35
41
|
kind: 'usage';
|
|
@@ -38,6 +44,7 @@ export interface UsageRecord {
|
|
|
38
44
|
usage: UsageTotals;
|
|
39
45
|
turns: number;
|
|
40
46
|
truncated?: boolean;
|
|
47
|
+
count?: typeof USAGE_COUNT_RULE;
|
|
41
48
|
ts: string;
|
|
42
49
|
replica?: string;
|
|
43
50
|
}
|
|
@@ -33,17 +33,24 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.USAGE_COUNT_RULE = void 0;
|
|
36
37
|
exports.sessionContextFilename = sessionContextFilename;
|
|
37
38
|
exports.isSessionContextFilename = isSessionContextFilename;
|
|
38
39
|
exports.appendSessionContext = appendSessionContext;
|
|
39
40
|
exports.readSessionContext = readSessionContext;
|
|
40
41
|
exports.makeSessionStamper = makeSessionStamper;
|
|
41
42
|
exports.summarizeTranscript = summarizeTranscript;
|
|
42
|
-
// @implements A-SPEC-564.1, A-SPEC-625
|
|
43
|
+
// @implements A-SPEC-564.1, A-SPEC-625, A-SPEC-564.5, A-SPEC-564.7
|
|
43
44
|
const execution_context_1 = require("../project/execution-context");
|
|
44
45
|
const fs = __importStar(require("node:fs"));
|
|
45
46
|
const path = __importStar(require("node:path"));
|
|
46
47
|
const replica_id_1 = require("./replica-id");
|
|
48
|
+
/**
|
|
49
|
+
* @implements A-SPEC-564.7 — the counting rule a usage record was made under. 564.5 changed usage/turns from per
|
|
50
|
+
* record to per response; a record without this marker is the old per-record count (about 2.7 times larger), and a
|
|
51
|
+
* reader must not add the two kinds together.
|
|
52
|
+
*/
|
|
53
|
+
exports.USAGE_COUNT_RULE = 'per-message-id';
|
|
47
54
|
const FILE_RE = /^session-context\.([^.]+)\.jsonl$/;
|
|
48
55
|
function sessionContextFilename(replica) {
|
|
49
56
|
return `session-context.${replica}.jsonl`;
|
|
@@ -169,6 +176,17 @@ function summarizeTranscript(lines, opts) {
|
|
|
169
176
|
let bytes = 0;
|
|
170
177
|
let truncated = false;
|
|
171
178
|
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
179
|
+
const add = (u) => {
|
|
180
|
+
usage.input += u.input;
|
|
181
|
+
usage.output += u.output;
|
|
182
|
+
usage.cacheRead += u.cacheRead;
|
|
183
|
+
usage.cacheCreation += u.cacheCreation;
|
|
184
|
+
};
|
|
185
|
+
// @implements A-SPEC-564.5 — Claude Code writes one response as several records (one per content block), each
|
|
186
|
+
// carrying the same usage: counting records counted one response ~2.7 times. One per distinct message id now,
|
|
187
|
+
// from the line with the largest output (ties: the later line) — the rule of A-SPEC-564.4 D7. A usage line with
|
|
188
|
+
// no id (older or synthetic shapes) still counts on its own.
|
|
189
|
+
const byId = new Map();
|
|
172
190
|
for (const line of lines) {
|
|
173
191
|
bytes += line.length + 1;
|
|
174
192
|
if (bytes > maxBytes) {
|
|
@@ -185,13 +203,23 @@ function summarizeTranscript(lines, opts) {
|
|
|
185
203
|
}
|
|
186
204
|
if (!m || typeof m !== 'object' || !m.usage || typeof m.usage !== 'object')
|
|
187
205
|
continue;
|
|
188
|
-
turns += 1;
|
|
189
206
|
if (typeof m.model === 'string' && m.model !== '' && !models.includes(m.model))
|
|
190
207
|
models.push(m.model);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
208
|
+
const u = {
|
|
209
|
+
input: num(m.usage.input_tokens), output: num(m.usage.output_tokens),
|
|
210
|
+
cacheRead: num(m.usage.cache_read_input_tokens), cacheCreation: num(m.usage.cache_creation_input_tokens),
|
|
211
|
+
};
|
|
212
|
+
if (typeof m.id === 'string' && m.id !== '') {
|
|
213
|
+
const prev = byId.get(m.id);
|
|
214
|
+
if (prev === undefined || u.output >= prev.output)
|
|
215
|
+
byId.set(m.id, u);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
turns += 1;
|
|
219
|
+
add(u);
|
|
195
220
|
}
|
|
221
|
+
for (const u of byId.values())
|
|
222
|
+
add(u);
|
|
223
|
+
turns += byId.size;
|
|
196
224
|
return { models, usage, turns, truncated };
|
|
197
225
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type EditEvidenceReason, type EditEvidenceVerdict } from './impact-gate';
|
|
2
|
+
/**
|
|
3
|
+
* A pre-edit warning said once, then not again while it is still in the reader's context.
|
|
4
|
+
*
|
|
5
|
+
* Measured over 379 transcripts of this repository (2026-11-05): 98.6% of the Holmes hook context was this gate's warning,
|
|
6
|
+
* and half of it repeated a sentence already shown. The decision never changes here — only what is said with it.
|
|
7
|
+
*
|
|
8
|
+
* Per compaction epoch (opened by SessionStart, every source), per session and agent, in a Claude Code session only
|
|
9
|
+
* (A-SPEC-333.4: the one harness whose compaction signal is observed):
|
|
10
|
+
* - each code's explanation is said once, with the call to clear it;
|
|
11
|
+
* - a line — codes, target, detail — is said once; again after REEMIT_AFTER warnings (context editing drops old results
|
|
12
|
+
* with no compact signal), after SILENT_STREAK_MAX silent judgements of the same file, and whenever its detail changes;
|
|
13
|
+
* - an allowed `git commit` names the files still at a refuse verdict, once per epoch.
|
|
14
|
+
* Nothing is recorded while judging: `commitAdvisory` records only what the final allow actually carried. Every committed
|
|
15
|
+
* warning of every harness also appends a judgement-ledger row, outside the epoch store (A-SPEC-333.5). Every doubt about
|
|
16
|
+
* the store, the epoch or the transcript means "say it in full".
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* MUST_SAY_MEANING — "must say" means at least once per epoch, and again whenever the wording (the detail) changes.
|
|
20
|
+
* So no code is exempt from the silent repeat: a repeat inside the epoch is already in the reader's context (supervisor
|
|
21
|
+
* decision (b), 2026-11-05; the measured cost of exempting contract-untested and multi-step codes was c/d 0.441).
|
|
22
|
+
*/
|
|
23
|
+
export declare const MUST_SAY_MEANING = "at least once per epoch, and again whenever the detail changes";
|
|
24
|
+
/**
|
|
25
|
+
* Re-say a silent line after this many warnings in the session (A-SPEC-333.3). No context-horizon measurement exists to
|
|
26
|
+
* set it; the per-file silence cap below bounds silence on the file being edited (A-SPEC-333.4, 333.5).
|
|
27
|
+
*/
|
|
28
|
+
export declare const REEMIT_AFTER = 29;
|
|
29
|
+
/** A file judged silent this many times since it was last said is said again on its next judgement (A-SPEC-333.5). */
|
|
30
|
+
export declare const SILENT_STREAK_MAX = 5;
|
|
31
|
+
/** The ledger rows' wording, so the wording's effect on behaviour can be measured apart (A-SPEC-333.5). */
|
|
32
|
+
export declare const WORDING_VERSION = 2;
|
|
33
|
+
/** The next step for each code, short and without call arguments: the first explanation carries those. */
|
|
34
|
+
export declare const ADVISORY_SHORT: Record<EditEvidenceReason['code'], string>;
|
|
35
|
+
/** What a judgement wants recorded if, and only if, the final allow carried `said` ('' when it said nothing). */
|
|
36
|
+
export interface AdvisoryRecord {
|
|
37
|
+
file: string;
|
|
38
|
+
entries: string[];
|
|
39
|
+
said: string;
|
|
40
|
+
ledger?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The session reading the warnings. `compress` is true only for a Claude Code session (A-SPEC-333.4); otherwise the full
|
|
44
|
+
* sentence is said and only the ledger row is kept. `pending` holds what waits for the final decision.
|
|
45
|
+
*/
|
|
46
|
+
export interface AdvisoryContext {
|
|
47
|
+
session: string;
|
|
48
|
+
agent?: string;
|
|
49
|
+
dir?: string;
|
|
50
|
+
pending: AdvisoryRecord[];
|
|
51
|
+
compress: boolean;
|
|
52
|
+
transcriptPath?: string;
|
|
53
|
+
toolUseId?: string;
|
|
54
|
+
/** the harness the hook judged (A-SPEC-333.9: the holdout population is read from the ledger by it) */
|
|
55
|
+
harness?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* SessionStart, first act: a new epoch for the session. Every epoch marker of the session goes first, then every table,
|
|
59
|
+
* then the new marker with its time, the transcript's size and the SessionStart source. The judgement ledger is outside
|
|
60
|
+
* and is never touched. Fail-quiet: without a marker the gate says everything in full.
|
|
61
|
+
*/
|
|
62
|
+
export declare function openEpoch(projectRoot: string, session: string, opts?: string | {
|
|
63
|
+
dir?: string;
|
|
64
|
+
transcriptPath?: string;
|
|
65
|
+
source?: string;
|
|
66
|
+
}): void;
|
|
67
|
+
/** The detail a line names: the analysis it read, and HEAD only when HEAD is the reason. (The hook's evidence carries no trace gaps.) */
|
|
68
|
+
export declare function advisoryDetail(o: {
|
|
69
|
+
artifactDigest?: string | null;
|
|
70
|
+
traceGaps?: Array<{
|
|
71
|
+
id: string;
|
|
72
|
+
}>;
|
|
73
|
+
head: string;
|
|
74
|
+
codes: string[];
|
|
75
|
+
}): string;
|
|
76
|
+
/** The line: the verdict's strength and the outcome first, then what clears it (no "required": nothing enforces it under warn). */
|
|
77
|
+
export declare function advisoryLine(verdict: EditEvidenceVerdict, target: string, detail?: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* What to say for a warn allow. `undefined`: say `full`, the A-SPEC-333 sentence (no session, no compression for this
|
|
80
|
+
* harness, no epoch, a void epoch, an untrusted store). `null`: say nothing. A string: say it. What the caller commits
|
|
81
|
+
* after the final decision goes into `ctx.pending`, the ledger row with it — a ledger row in every case.
|
|
82
|
+
*/
|
|
83
|
+
export declare function adviseWarn(projectRoot: string, ctx: AdvisoryContext | undefined, verdict: EditEvidenceVerdict, target: string, detail: string, full?: string): string | null | undefined;
|
|
84
|
+
/** A clean allow of a file: it is no longer warned (the commit reminder drops it). Recorded with the final allow. */
|
|
85
|
+
export declare function adviseClean(projectRoot: string, ctx: AdvisoryContext | undefined, target: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* `git commit` as the shell runs it: leading assignments and the prefixes `env` (with its options and assignments),
|
|
88
|
+
* `command`, `time` and `nohup` are skipped; `git` is matched by its basename; git's global options before the subcommand
|
|
89
|
+
* are skipped; `sh|bash|zsh|dash -c <script>` is read again, a few levels deep. `commit-tree`, `HEAD^{commit}`, a quoted
|
|
90
|
+
* mention and `--dry-run` are not a commit (A-SPEC-333.5, 333.6).
|
|
91
|
+
*/
|
|
92
|
+
export declare function isGitCommit(command: string, depth?: number): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* One line for an allowed `git commit`, at most once per epoch: up to three files whose last judgement in the epoch was a
|
|
95
|
+
* refuse verdict, and how many more. Its own record waits in `ctx.pending` like a warning's.
|
|
96
|
+
*/
|
|
97
|
+
export declare function commitReminder(projectRoot: string, ctx: AdvisoryContext | undefined): string | null;
|
|
98
|
+
/** After the final decision: record what an allow actually carried. A deny, or a record whose text is absent, records nothing. */
|
|
99
|
+
export declare function commitAdvisory(projectRoot: string, ctx: AdvisoryContext | undefined, out: {
|
|
100
|
+
permissionDecision: string;
|
|
101
|
+
permissionDecisionReason?: string;
|
|
102
|
+
}): void;
|