@lannguyensi/harness 0.50.0 → 0.51.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 +108 -0
- package/dist/cli/approve/understanding.d.ts +51 -0
- package/dist/cli/approve/understanding.js +17 -2
- package/dist/cli/approve/understanding.js.map +1 -1
- package/dist/cli/doctor/claude-mcp.d.ts +14 -0
- package/dist/cli/doctor/claude-mcp.js +7 -1
- package/dist/cli/doctor/claude-mcp.js.map +1 -1
- package/dist/cli/doctor/format.js +36 -1
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/index.d.ts +20 -0
- package/dist/cli/doctor/index.js +40 -1
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/settings-drift.d.ts +19 -0
- package/dist/cli/doctor/settings-drift.js +189 -0
- package/dist/cli/doctor/settings-drift.js.map +1 -0
- package/dist/cli/doctor/types.d.ts +26 -0
- package/dist/cli/doctor/types.js.map +1 -1
- package/dist/cli/doctor/ug-auto-approvals.d.ts +40 -0
- package/dist/cli/doctor/ug-auto-approvals.js +116 -0
- package/dist/cli/doctor/ug-auto-approvals.js.map +1 -0
- package/dist/cli/doctor/understanding-mode-env.d.ts +10 -0
- package/dist/cli/doctor/understanding-mode-env.js +12 -0
- package/dist/cli/doctor/understanding-mode-env.js.map +1 -1
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/pack/auto-approve-path.d.ts +118 -0
- package/dist/cli/pack/auto-approve-path.js +347 -0
- package/dist/cli/pack/auto-approve-path.js.map +1 -0
- package/dist/cli/pack/hook-codex-pre-tool-use.d.ts +9 -0
- package/dist/cli/pack/hook-codex-pre-tool-use.js +118 -4
- package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-pre-tool-use.d.ts +11 -0
- package/dist/cli/pack/hook-pre-tool-use.js +67 -1
- package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
- package/dist/cli/validate/checks.js +81 -0
- package/dist/cli/validate/checks.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.d.ts +136 -0
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js +224 -0
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +2 -1
- package/dist/policy-packs/builtin/understanding-before-execution/index.js +2 -1
- package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.d.ts +29 -0
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js +82 -0
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +23 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +29 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution.d.ts +23 -0
- package/dist/policy-packs/builtin/understanding-before-execution.js +27 -1
- package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
- package/dist/runtime/approval-signing.d.ts +22 -0
- package/dist/runtime/approval-signing.js +55 -1
- package/dist/runtime/approval-signing.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// Step 9 of the understanding-gate PreToolUse decision order: the
|
|
2
|
+
// operator-opt-in auto-approval attempt (agent-tasks/74b4b17d, slice 1 of
|
|
3
|
+
// docs/decisions/2026-08-27-ug-auto-mode-approval.md, "Option A").
|
|
4
|
+
//
|
|
5
|
+
// WHERE THIS RUNS, AND WHY IT MATTERS. `hook-pre-tool-use.ts` calls
|
|
6
|
+
// `attemptAutoApproval` on a call that EVERY branch above it has already
|
|
7
|
+
// declined: the signed-marker check (step 3), the read-only Bash
|
|
8
|
+
// exemption (step 6), the recovery-commit exemption (step 7) and the
|
|
9
|
+
// escape `ask` (step 8). So the auto path only ever acts on a call that
|
|
10
|
+
// would otherwise reach the final block. Three consequences the ADR's
|
|
11
|
+
// decision-order table spells out: the session's first `ls` or `git
|
|
12
|
+
// status` mints nothing, `max_age` starts counting from the call that
|
|
13
|
+
// actually needed an approval, and a bare `harness approve understanding`
|
|
14
|
+
// keeps whatever the interactive prompt resolves it to. The negative
|
|
15
|
+
// controls in tests/cli/pack-hook-pre-tool-use-auto-approve.test.ts pin
|
|
16
|
+
// that ordering; moving this call site up is a mutation those tests
|
|
17
|
+
// catch.
|
|
18
|
+
//
|
|
19
|
+
// WHAT IT IS NOT. This function never returns an allow of its own. On
|
|
20
|
+
// success it consumes the report, writes the signed SESSION marker
|
|
21
|
+
// through the same `writeApprovalMarker` path `harness approve
|
|
22
|
+
// understanding` uses, records an audit-only ledger fact, and then
|
|
23
|
+
// re-runs `checkOperatorApprovalMarkers` — that re-check, and nothing
|
|
24
|
+
// else, is what produces the allow. The gate's decision input stays
|
|
25
|
+
// exactly one signed marker (invariant 1). Every failure returns
|
|
26
|
+
// `approved: false` and the caller falls through to the existing final
|
|
27
|
+
// block with step 3's `markerExpired` / `markerForged` intact.
|
|
28
|
+
//
|
|
29
|
+
// FAIL CLOSED ON EVERY MISSING INPUT. Absent opt-in, unlisted
|
|
30
|
+
// `permission_mode`, a forged marker already detected at step 3, a
|
|
31
|
+
// failed session-consistency check, a missing signing key, a missing /
|
|
32
|
+
// already-consumed / foreign / invalid report: each one declines with
|
|
33
|
+
// one stderr line and no write.
|
|
34
|
+
//
|
|
35
|
+
// TWO CALL SITES, ONE BODY (slice 2, agent-tasks/57058364).
|
|
36
|
+
// `hook-codex-pre-tool-use.ts` calls this same function at the same
|
|
37
|
+
// place in its own decision order. Everything that differs between the
|
|
38
|
+
// two runtimes is an ARGUMENT, never a fork: the `harness` segment of
|
|
39
|
+
// the minted `approvedBy`, which session-consistency evidence the
|
|
40
|
+
// payload can be held against (`sessionConsistency`), the ledger fact's
|
|
41
|
+
// `source` verb, and the stderr `label`. Claude Code carries
|
|
42
|
+
// `$CLAUDE_CODE_SESSION_ID` in the hook environment; Codex carries no
|
|
43
|
+
// session-id environment variable at all (measured live, Codex 0.150.1)
|
|
44
|
+
// but does name a per-session `transcript_path` that exists on disk at
|
|
45
|
+
// PreToolUse time.
|
|
46
|
+
//
|
|
47
|
+
// ONE BODY IS NOT ONE OPT-IN. Sharing the body would otherwise mean an
|
|
48
|
+
// `auto_approve` block written for Claude Code opts every Codex session
|
|
49
|
+
// in too; `auto_approve.harnesses` is the explicit per-harness
|
|
50
|
+
// allowlist that prevents it, defaulting to Claude Code only when the
|
|
51
|
+
// key is absent (step 1b below).
|
|
52
|
+
import * as fs from "node:fs";
|
|
53
|
+
import * as path from "node:path";
|
|
54
|
+
import { autoApprovedByFor, autoApprovedLedgerTagFor, checkOperatorApprovalMarkers, harnessAllowed, listPersistedReports, parseAutoApprove, permissionModeAllowed, selectNewestStrictSessionReport, writeApprovalMarker, } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
|
|
55
|
+
import { sha256Hex, signingKeyExists } from "../../runtime/approval-signing.js";
|
|
56
|
+
import { clearPendingApproval, readPendingApproval, } from "../../runtime/pending-approval.js";
|
|
57
|
+
import { rewriteReportApproved, validatePersistedReport } from "../approve/understanding.js";
|
|
58
|
+
/**
|
|
59
|
+
* Source string the CLAUDE CODE hook records on the audit-only ledger
|
|
60
|
+
* fact — the verb that actually made the write.
|
|
61
|
+
*/
|
|
62
|
+
export const AUTO_APPROVE_LEDGER_SOURCE = "harness-pack-hook-pre-tool-use";
|
|
63
|
+
/**
|
|
64
|
+
* The Codex hook's counterpart. A shared body must not stamp the Claude
|
|
65
|
+
* verb on a Codex write: the ledger fact is an audit surface, and an
|
|
66
|
+
* auditor reading `harness-pack-hook-pre-tool-use` on a Codex session
|
|
67
|
+
* would be reading a fact about a hook that never ran (reviewer round-1
|
|
68
|
+
* finding on slice 2). The `approvedBy` segment already distinguishes
|
|
69
|
+
* the runtimes; this makes the ledger row agree with it.
|
|
70
|
+
*/
|
|
71
|
+
export const AUTO_APPROVE_LEDGER_SOURCE_CODEX = "harness-pack-hook-codex-pre-tool-use";
|
|
72
|
+
/** Default stderr prefix: the Claude Code hook's, byte-for-byte. */
|
|
73
|
+
const DEFAULT_LABEL = "harness pack hook";
|
|
74
|
+
function decline(reason) {
|
|
75
|
+
return { approved: false, reason };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Attempt the operator-opted-in auto-approval for this PreToolUse call.
|
|
79
|
+
* See the module header for placement and the fail-closed contract; the
|
|
80
|
+
* numbered steps below are conditions 1-6 of the ADR's Option A.
|
|
81
|
+
*/
|
|
82
|
+
export async function attemptAutoApproval(args) {
|
|
83
|
+
const { stderr } = args;
|
|
84
|
+
const label = args.label ?? DEFAULT_LABEL;
|
|
85
|
+
const note = (msg) => {
|
|
86
|
+
stderr.write(`${label}: ${msg}\n`);
|
|
87
|
+
};
|
|
88
|
+
// (1) Opt-in. Absent is the ordinary case and stays SILENT; a
|
|
89
|
+
// malformed block already wrote its own single line inside
|
|
90
|
+
// `parseAutoApprove` (fail-closed: malformed means "not opted in",
|
|
91
|
+
// never a partial default).
|
|
92
|
+
const packConfigObj = args.packConfig !== null && typeof args.packConfig === "object" && !Array.isArray(args.packConfig)
|
|
93
|
+
? args.packConfig
|
|
94
|
+
: {};
|
|
95
|
+
const cfg = parseAutoApprove(packConfigObj["auto_approve"], stderr, label);
|
|
96
|
+
if (cfg === null)
|
|
97
|
+
return decline("auto_approve not configured");
|
|
98
|
+
// (1b) Per-harness opt-in, checked BEFORE the `when` allowlist and
|
|
99
|
+
// before the ledger thunk below, so an unlisted harness resolves
|
|
100
|
+
// nothing and never reaches any evidence lookup. Two call sites share
|
|
101
|
+
// this body; without this check an `auto_approve` block written for
|
|
102
|
+
// Claude Code before the Codex hook existed would silently start
|
|
103
|
+
// auto-approving every Codex session that runs in a listed
|
|
104
|
+
// `permission_mode` (reviewer round-1 finding on slice 2). `harnesses`
|
|
105
|
+
// is absent in exactly those older configs and resolves to Claude Code
|
|
106
|
+
// only, so opting a second runtime in stays an explicit config edit.
|
|
107
|
+
// Diagnosed, unlike the silent `when` miss below: an unlisted harness
|
|
108
|
+
// is a configuration mismatch worth seeing once per call, not the
|
|
109
|
+
// ordinary state of an opted-in session.
|
|
110
|
+
if (!harnessAllowed(cfg, args.harness)) {
|
|
111
|
+
note(`auto-approval declined: harness "${args.harness}" is not listed in auto_approve.harnesses`);
|
|
112
|
+
return decline("harness not in auto_approve.harnesses");
|
|
113
|
+
}
|
|
114
|
+
// (2) `when` allowlist, exact string equality against the payload
|
|
115
|
+
// literal (hardening item 2). Absent / empty / unlisted is the normal
|
|
116
|
+
// case for an opted-in repo whose session simply runs in a prompting
|
|
117
|
+
// mode, and it fires on EVERY such call once the opt-in is present, so
|
|
118
|
+
// this stays SILENT (no stderr line): a per-call note here would echo
|
|
119
|
+
// the configured `auto_approve.when` allowlist to stderr on every
|
|
120
|
+
// ordinary prompting-mode call (reviewer round-1 finding).
|
|
121
|
+
const mode = args.permissionMode;
|
|
122
|
+
if (!permissionModeAllowed(cfg, mode)) {
|
|
123
|
+
return decline("permission_mode not in auto_approve.when");
|
|
124
|
+
}
|
|
125
|
+
const modeStr = mode;
|
|
126
|
+
// Resolve the audit-only ledger writer NOW, not earlier: this is the
|
|
127
|
+
// first point past both the opt-in check (1) and the `when` allowlist
|
|
128
|
+
// check (2), so `args.resolveLedger` runs only on a call that has an
|
|
129
|
+
// actual chance of reaching the ledger write below, never on the
|
|
130
|
+
// overwhelming majority of gated calls that are not opted in or run in
|
|
131
|
+
// an unlisted permission mode.
|
|
132
|
+
const ledger = args.resolveLedger();
|
|
133
|
+
// (3) A forgery detected at step 3 is never laundered into an
|
|
134
|
+
// approval (ADR condition 6). Declining also leaves the forged FILE and
|
|
135
|
+
// its distinct `forged/unsigned marker rejected` diagnostic on disk —
|
|
136
|
+
// `writeApprovalMarker` would atomically overwrite that exact path.
|
|
137
|
+
if (args.markerForged) {
|
|
138
|
+
note("auto-approval declined: forged/unsigned marker present");
|
|
139
|
+
return decline("forged marker present");
|
|
140
|
+
}
|
|
141
|
+
// (4) Session consistency (hardening item 1): the PAYLOAD's own
|
|
142
|
+
// `session_id` must be present and must agree with a SECOND input the
|
|
143
|
+
// hook reads for itself — the runtime's session-id environment
|
|
144
|
+
// variable on Claude Code, the named per-session transcript file on
|
|
145
|
+
// Codex. Compared against the payload field specifically, never the
|
|
146
|
+
// hook's env-fallback-resolved id, or the env variant would compare
|
|
147
|
+
// the environment with itself.
|
|
148
|
+
const payloadSid = typeof args.payloadSessionId === "string" && args.payloadSessionId.length > 0
|
|
149
|
+
? args.payloadSessionId
|
|
150
|
+
: null;
|
|
151
|
+
if (payloadSid === null) {
|
|
152
|
+
note("auto-approval declined: event payload carries no session_id");
|
|
153
|
+
return decline("no payload session_id");
|
|
154
|
+
}
|
|
155
|
+
const consistency = args.sessionConsistency;
|
|
156
|
+
if (consistency.kind === "env") {
|
|
157
|
+
const envSid = process.env[consistency.variable];
|
|
158
|
+
if (typeof envSid !== "string" || envSid.length === 0) {
|
|
159
|
+
note(`auto-approval declined: $${consistency.variable} is not set in the hook environment`);
|
|
160
|
+
return decline(`no ${consistency.variable}`);
|
|
161
|
+
}
|
|
162
|
+
if (envSid !== payloadSid) {
|
|
163
|
+
note(`auto-approval declined: payload session_id does not match $${consistency.variable} in the hook environment`);
|
|
164
|
+
return decline("session id mismatch");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
// Codex carries no session-id environment variable in the hook
|
|
169
|
+
// process (measured live, Codex 0.150.1: only CODEX_HOME,
|
|
170
|
+
// CODEX_MANAGED_BY_NPM, CODEX_MANAGED_PACKAGE_ROOT), so the env
|
|
171
|
+
// variant has no counterpart there. The payload's own
|
|
172
|
+
// `transcript_path` is the second input instead: Codex names the
|
|
173
|
+
// session's rollout file
|
|
174
|
+
// `<CODEX_HOME>/sessions/YYYY/MM/DD/rollout-<timestamp>-<session_id>.jsonl`
|
|
175
|
+
// and the file already exists when PreToolUse fires.
|
|
176
|
+
//
|
|
177
|
+
// Three separately-diagnosed conditions, each fail-closed: the
|
|
178
|
+
// field is a non-empty string; its BASENAME names this exact
|
|
179
|
+
// session (`-<sid>.jsonl`, or a bare `<sid>.jsonl` for a shim that
|
|
180
|
+
// drops the `rollout-<timestamp>` prefix); and the path resolves to
|
|
181
|
+
// a REGULAR FILE. `statSync().isFile()`, not `existsSync`: a
|
|
182
|
+
// directory named `<sid>.jsonl` is not a transcript, and neither is
|
|
183
|
+
// a socket or a device node, yet all of them satisfy mere existence
|
|
184
|
+
// (reviewer round-1 finding on slice 2). It is deliberately not a
|
|
185
|
+
// content check: reading and parsing the rollout would make the hook
|
|
186
|
+
// depend on Codex's internal transcript format for a check that is
|
|
187
|
+
// not a boundary anyway (see SessionConsistencyCheck).
|
|
188
|
+
const transcriptPath = typeof consistency.transcriptPath === "string" && consistency.transcriptPath.length > 0
|
|
189
|
+
? consistency.transcriptPath
|
|
190
|
+
: null;
|
|
191
|
+
if (transcriptPath === null) {
|
|
192
|
+
note("auto-approval declined: event payload carries no transcript_path");
|
|
193
|
+
return decline("no transcript_path");
|
|
194
|
+
}
|
|
195
|
+
const base = path.basename(transcriptPath);
|
|
196
|
+
if (base !== `${payloadSid}.jsonl` && !base.endsWith(`-${payloadSid}.jsonl`)) {
|
|
197
|
+
note(`auto-approval declined: transcript_path does not name session ${payloadSid} (basename ${base})`);
|
|
198
|
+
return decline("transcript_path session mismatch");
|
|
199
|
+
}
|
|
200
|
+
// `throwIfNoEntry: false` covers the ordinary ENOENT; the try/catch
|
|
201
|
+
// covers every other stat failure (a permission error, a symlink
|
|
202
|
+
// loop), which fails closed here rather than throwing out of a hook
|
|
203
|
+
// whose caller treats a throw as neither allow nor block.
|
|
204
|
+
let transcriptIsFile = false;
|
|
205
|
+
try {
|
|
206
|
+
transcriptIsFile = fs.statSync(transcriptPath, { throwIfNoEntry: false })?.isFile() === true;
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
transcriptIsFile = false;
|
|
210
|
+
}
|
|
211
|
+
if (!transcriptIsFile) {
|
|
212
|
+
note(`auto-approval declined: transcript_path does not name an existing file (${transcriptPath})`);
|
|
213
|
+
return decline("transcript_path missing");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// (5) Key precheck BEFORE any write (hardening item 5). The shared
|
|
217
|
+
// write path would otherwise mint the key it is supposed to require:
|
|
218
|
+
// `writeApprovalMarker` -> `signMarker` -> `getOrCreateSigningKey`
|
|
219
|
+
// generates one on ENOENT. Key creation stays an operator-side act.
|
|
220
|
+
if (args.generatedDir === undefined) {
|
|
221
|
+
note("auto-approval declined: harness.generated/ could not be resolved");
|
|
222
|
+
return decline("generatedDir unresolvable");
|
|
223
|
+
}
|
|
224
|
+
const generatedDir = args.generatedDir;
|
|
225
|
+
if (!signingKeyExists(generatedDir)) {
|
|
226
|
+
note("auto-approval declined: signing key absent (never created by the hook)");
|
|
227
|
+
return decline("signing key absent");
|
|
228
|
+
}
|
|
229
|
+
// (6) The report precondition: the NEWEST strict-session report, and
|
|
230
|
+
// only that one, must be exactly `pending`, parse, and pass the
|
|
231
|
+
// approve CLI's own content validation.
|
|
232
|
+
const newest = selectNewestStrictSessionReport(listPersistedReports(args.reportsDir), args.sessionId);
|
|
233
|
+
if (newest === null) {
|
|
234
|
+
note(`auto-approval declined: no persisted report bound to session ${args.sessionId}`);
|
|
235
|
+
return decline("no report for session");
|
|
236
|
+
}
|
|
237
|
+
if (newest.approvalStatus !== "pending") {
|
|
238
|
+
note(`auto-approval declined: newest report for session ${args.sessionId} is approvalStatus=${newest.approvalStatus ?? "<missing>"}, not pending`);
|
|
239
|
+
return decline("newest report not pending");
|
|
240
|
+
}
|
|
241
|
+
let raw;
|
|
242
|
+
try {
|
|
243
|
+
raw = fs.readFileSync(newest.filePath, "utf8");
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
note(`auto-approval declined: report unreadable (${err.message})`);
|
|
247
|
+
return decline("report unreadable");
|
|
248
|
+
}
|
|
249
|
+
let parsed;
|
|
250
|
+
try {
|
|
251
|
+
parsed = JSON.parse(raw);
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
note(`auto-approval declined: report invalid (unparseable JSON: ${err.message})`);
|
|
255
|
+
return decline("report unparseable");
|
|
256
|
+
}
|
|
257
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
258
|
+
note("auto-approval declined: report invalid (body is not a JSON object)");
|
|
259
|
+
return decline("report not an object");
|
|
260
|
+
}
|
|
261
|
+
const validation = validatePersistedReport(parsed);
|
|
262
|
+
if (!validation.ok) {
|
|
263
|
+
note(`auto-approval declined: report invalid (${validation.field}: ${validation.reason})`);
|
|
264
|
+
return decline(`report invalid: ${validation.field}`);
|
|
265
|
+
}
|
|
266
|
+
// Success sequence. `reportContentHash` binds the bytes as they were
|
|
267
|
+
// BEFORE the approval rewrite, exactly as the approve CLI computes it.
|
|
268
|
+
const reportContentHash = sha256Hex(raw);
|
|
269
|
+
const approvedAt = new Date().toISOString();
|
|
270
|
+
const approvedBy = autoApprovedByFor(args.harness, modeStr);
|
|
271
|
+
// CONSUME FIRST, then sign. If the marker write fails after this, the
|
|
272
|
+
// report is spent and no marker exists: the call blocks and the same
|
|
273
|
+
// report can never mint again. The reverse order would leave a
|
|
274
|
+
// still-`pending` report behind a failed write, i.e. a report that is
|
|
275
|
+
// mintable on the very next call — the direction this design refuses.
|
|
276
|
+
try {
|
|
277
|
+
rewriteReportApproved(newest.filePath, approvedAt, approvedBy, args.sessionId);
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
note(`auto-approval declined: could not consume the report (${err.message})`);
|
|
281
|
+
return decline("report consumption failed");
|
|
282
|
+
}
|
|
283
|
+
let markerPath;
|
|
284
|
+
try {
|
|
285
|
+
markerPath = writeApprovalMarker(generatedDir, args.sessionId, {
|
|
286
|
+
approvedAt,
|
|
287
|
+
approvedBy,
|
|
288
|
+
reportContentHash,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
note(`auto-approval declined: failed to write the approval marker (${err.message}); the report was consumed, so this session needs a fresh report`);
|
|
293
|
+
return decline("marker write failed");
|
|
294
|
+
}
|
|
295
|
+
// Audit-only ledger fact. Never a gate input, so every failure here is
|
|
296
|
+
// one stderr line and nothing more.
|
|
297
|
+
const tag = autoApprovedLedgerTagFor(args.sessionId);
|
|
298
|
+
if (ledger.write === null) {
|
|
299
|
+
note(`auto-approval ledger fact ${tag} not recorded (${ledger.reason ?? "ledger writer unavailable"}); audit only, continuing`);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
try {
|
|
303
|
+
const result = await ledger.write({
|
|
304
|
+
sessionId: args.sessionId,
|
|
305
|
+
content: tag,
|
|
306
|
+
source: args.ledgerSource,
|
|
307
|
+
});
|
|
308
|
+
if (!result.ok) {
|
|
309
|
+
note(`auto-approval ledger fact ${tag} not recorded (${result.reason ?? "unknown error"}); audit only, continuing`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
note(`auto-approval ledger fact ${tag} not recorded (${err.message}); audit only, continuing`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// Drop this session's `.pending-approval` staging entry (decision-order
|
|
317
|
+
// table, step 9). It is tier 5 of the approve verbs' session
|
|
318
|
+
// resolution and is otherwise cleared only by `harness approve
|
|
319
|
+
// understanding`, which auto mode never runs — so leaving it would let
|
|
320
|
+
// a later env-less operator `harness approve ...` resolve to this
|
|
321
|
+
// already-auto-approved id. Only ever clears OUR OWN id.
|
|
322
|
+
try {
|
|
323
|
+
if (readPendingApproval(generatedDir) === args.sessionId) {
|
|
324
|
+
clearPendingApproval(generatedDir);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
/* best-effort; staging is not a gate input */
|
|
329
|
+
}
|
|
330
|
+
// The verdict comes from the same marker check every other approval
|
|
331
|
+
// goes through — the auto path itself never allows.
|
|
332
|
+
const recheck = checkOperatorApprovalMarkers(generatedDir, args.sessionId, args.packConfig, stderr);
|
|
333
|
+
if (!recheck.matched) {
|
|
334
|
+
note(`auto-approval wrote a marker but the re-check did not match (${recheck.detail}); falling through to the block`);
|
|
335
|
+
return decline("post-write marker re-check did not match");
|
|
336
|
+
}
|
|
337
|
+
note(`auto-approved via session marker by ${approvedBy}`);
|
|
338
|
+
return {
|
|
339
|
+
approved: true,
|
|
340
|
+
detail: recheck.detail,
|
|
341
|
+
approvedBy,
|
|
342
|
+
markerPath,
|
|
343
|
+
reportPath: newest.filePath,
|
|
344
|
+
reportContentHash,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=auto-approve-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-approve-path.js","sourceRoot":"","sources":["../../../src/cli/pack/auto-approve-path.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,0EAA0E;AAC1E,mEAAmE;AACnE,EAAE;AACF,oEAAoE;AACpE,yEAAyE;AACzE,iEAAiE;AACjE,qEAAqE;AACrE,wEAAwE;AACxE,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,0EAA0E;AAC1E,qEAAqE;AACrE,wEAAwE;AACxE,oEAAoE;AACpE,SAAS;AACT,EAAE;AACF,sEAAsE;AACtE,mEAAmE;AACnE,+DAA+D;AAC/D,mEAAmE;AACnE,sEAAsE;AACtE,oEAAoE;AACpE,iEAAiE;AACjE,uEAAuE;AACvE,+DAA+D;AAC/D,EAAE;AACF,8DAA8D;AAC9D,mEAAmE;AACnE,uEAAuE;AACvE,sEAAsE;AACtE,gCAAgC;AAChC,EAAE;AACF,4DAA4D;AAC5D,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,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CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CACF,6BAA6B,GAAG,kBAAmB,GAAa,CAAC,OAAO,2BAA2B,CACpG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,wEAAwE;IACxE,6DAA6D;IAC7D,+DAA+D;IAC/D,uEAAuE;IACvE,kEAAkE;IAClE,yDAAyD;IACzD,IAAI,CAAC;QACH,IAAI,mBAAmB,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YACzD,oBAAoB,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,8CAA8C;IAChD,CAAC;IAED,oEAAoE;IACpE,oDAAoD;IACpD,MAAM,OAAO,GAAG,4BAA4B,CAC1C,YAAY,EACZ,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,MAAM,CACP,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CACF,gEAAgE,OAAO,CAAC,MAAM,iCAAiC,CAChH,CAAC;QACF,OAAO,OAAO,CAAC,0CAA0C,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,uCAAuC,UAAU,EAAE,CAAC,CAAC;IAC1D,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,UAAU;QACV,UAAU;QACV,UAAU,EAAE,MAAM,CAAC,QAAQ;QAC3B,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type LedgerEntry } from "../../policies/index.js";
|
|
2
2
|
import { type ApprovalCheckResult } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
|
|
3
|
+
import { type LedgerWriteFn } from "../../runtime/ledger-writer.js";
|
|
3
4
|
import { type Manifest } from "../../schema/index.js";
|
|
4
5
|
import { type LoaderOptions } from "../loader.js";
|
|
5
6
|
export interface PackHookCodexPreToolUseOptions extends LoaderOptions {
|
|
@@ -21,6 +22,14 @@ export interface PackHookCodexPreToolUseOptions extends LoaderOptions {
|
|
|
21
22
|
ledgerQuery?: (sessionId: string) => Promise<LedgerEntry[] | {
|
|
22
23
|
degraded: string;
|
|
23
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Inject the audit-only ledger WRITER that the auto-approval path
|
|
27
|
+
* records its fact through (test injection). Mirrors the Claude
|
|
28
|
+
* hook's option of the same name. Absent, the writer is resolved from
|
|
29
|
+
* the manifest, lazily, and only on a call that already passed the
|
|
30
|
+
* opt-in, `harnesses` and `when` checks.
|
|
31
|
+
*/
|
|
32
|
+
writeLedger?: LedgerWriteFn;
|
|
24
33
|
}
|
|
25
34
|
export interface PackHookCodexPreToolUseResult {
|
|
26
35
|
exitCode: number;
|
|
@@ -23,7 +23,10 @@ import * as path from "node:path";
|
|
|
23
23
|
import { queryLedgerByTag } from "../../policies/index.js";
|
|
24
24
|
import { checkOperatorApprovalMarkers, checkPersistedReport, defaultReportsDir, matchLedgerEntries, } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
|
|
25
25
|
import { findLatestParseError, renderMalformedSectionsNotice } from "../approve/understanding.js";
|
|
26
|
+
import { CODEX_HARNESS } from "../../policy-packs/builtin/understanding-before-execution/auto-approve.js";
|
|
27
|
+
import { attemptAutoApproval, AUTO_APPROVE_LEDGER_SOURCE_CODEX, } from "./auto-approve-path.js";
|
|
26
28
|
import { resolveGeneratedDir, writePendingApproval, } from "../../runtime/pending-approval.js";
|
|
29
|
+
import { resolveManifestLedgerWriter } from "../../runtime/ledger-writer.js";
|
|
27
30
|
import { extractShellCommand } from "../../runtime/tool-name-aliases.js";
|
|
28
31
|
import { renderAgentFacing } from "../../runtime/agent-facing.js";
|
|
29
32
|
import { isReadOnlyBashPipeline } from "../../runtime/read-only-bash.js";
|
|
@@ -58,6 +61,48 @@ function extractCodexShellCommand(rawInput) {
|
|
|
58
61
|
return command;
|
|
59
62
|
return typeof rawInput === "string" ? rawInput : null;
|
|
60
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The command the two EXEMPTIONS below (read-only Bash, recovery
|
|
66
|
+
* `git commit`) are allowed to act on, or `null` when the payload does
|
|
67
|
+
* not pin one down. Deliberately stricter than the shared
|
|
68
|
+
* `resolveToolInput` (hook-bootstrap.ts), which stays as it is: its
|
|
69
|
+
* other callers are PostToolUse observers whose worst case is a missed
|
|
70
|
+
* observation, whereas here the classified command decides whether a
|
|
71
|
+
* gated call is exempted (reviewer round-1 finding on slice 2). Two
|
|
72
|
+
* differences, both fail-closed:
|
|
73
|
+
*
|
|
74
|
+
* - `tool_input: null` is treated as ABSENT and falls back to
|
|
75
|
+
* `raw_input`, instead of shadowing it. `resolveToolInput` tests
|
|
76
|
+
* `!== undefined`, so a payload carrying an explicit null
|
|
77
|
+
* `tool_input` plus a real `raw_input` would otherwise classify to
|
|
78
|
+
* nothing.
|
|
79
|
+
* - When BOTH fields carry a command and they DISAGREE, this returns
|
|
80
|
+
* `null` rather than picking one. Otherwise a payload could pair a
|
|
81
|
+
* read-only `ls` in the preferred field with `rm -rf ...` in the
|
|
82
|
+
* other and be exempted on the harmless one while the runtime runs
|
|
83
|
+
* whichever field it itself reads.
|
|
84
|
+
*
|
|
85
|
+
* `null` is never an allow: both call sites fall through to the block
|
|
86
|
+
* path, and the auto-approval attempt below does not read this at all.
|
|
87
|
+
*/
|
|
88
|
+
function resolveCodexExemptionCommand(event) {
|
|
89
|
+
const toolInput = event.tool_input ?? undefined;
|
|
90
|
+
const rawInput = event.raw_input ?? undefined;
|
|
91
|
+
if (toolInput !== undefined && rawInput !== undefined) {
|
|
92
|
+
const fromToolInput = extractCodexShellCommand(toolInput);
|
|
93
|
+
const fromRawInput = extractCodexShellCommand(rawInput);
|
|
94
|
+
if (fromToolInput === null || fromRawInput === null)
|
|
95
|
+
return null;
|
|
96
|
+
if (fromToolInput.trim() !== fromRawInput.trim())
|
|
97
|
+
return null;
|
|
98
|
+
return fromToolInput;
|
|
99
|
+
}
|
|
100
|
+
if (toolInput !== undefined)
|
|
101
|
+
return extractCodexShellCommand(toolInput);
|
|
102
|
+
if (rawInput !== undefined)
|
|
103
|
+
return extractCodexShellCommand(rawInput);
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
61
106
|
async function checkLedger(manifest, sessionId, opts) {
|
|
62
107
|
if (opts.ledgerQuery) {
|
|
63
108
|
const result = await opts.ledgerQuery(sessionId);
|
|
@@ -200,10 +245,15 @@ export async function runPackHookCodexPreToolUseCli(opts = {}) {
|
|
|
200
245
|
const report = checkPersistedReport(reportsDir, sessionId);
|
|
201
246
|
// Audit-only ledger probe.
|
|
202
247
|
const ledger = await checkLedger(manifest, sessionId, opts);
|
|
203
|
-
// Exception: read-only shell commands. Codex
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
|
|
248
|
+
// Exception: read-only shell commands. Real Codex carries tool args in
|
|
249
|
+
// `tool_input`, harness's older published envelope in `raw_input`;
|
|
250
|
+
// `resolveCodexExemptionCommand` reads both (before this, a real Codex
|
|
251
|
+
// payload's command was invisible here and every read-only `ls` hit
|
|
252
|
+
// the block). If neither field carries a classifiable command — a
|
|
253
|
+
// conflicting `command`/`cmd` pair, or two fields naming DIFFERENT
|
|
254
|
+
// commands — this stays `null` and the call falls through to the block
|
|
255
|
+
// path (fail-closed); see that function for the full argument.
|
|
256
|
+
const commandStr = resolveCodexExemptionCommand(event);
|
|
207
257
|
if (commandStr !== null &&
|
|
208
258
|
CODEX_SHELL_TOOLS.has(toolName) &&
|
|
209
259
|
isReadOnlyBashPipeline(commandStr)) {
|
|
@@ -236,6 +286,70 @@ export async function runPackHookCodexPreToolUseCli(opts = {}) {
|
|
|
236
286
|
diagnostic,
|
|
237
287
|
};
|
|
238
288
|
}
|
|
289
|
+
// Step 9: the operator-opt-in auto-approval attempt (slice 2 of
|
|
290
|
+
// docs/decisions/2026-08-27-ug-auto-mode-approval.md, agent-tasks/
|
|
291
|
+
// 57058364). The SAME `attemptAutoApproval` the Claude hook calls, at
|
|
292
|
+
// the same place in the decision order: last, on a call that the
|
|
293
|
+
// marker check (source 1) and both exemptions above have already
|
|
294
|
+
// declined — i.e. exactly a call that would otherwise reach the final
|
|
295
|
+
// block. So a read-only `ls` or a recovery `git commit` mints nothing,
|
|
296
|
+
// and `max_age` starts counting from the call that actually needed an
|
|
297
|
+
// approval. Arguments carry everything that is Codex-specific:
|
|
298
|
+
// `harness: CODEX_HARNESS` (the minted `approvedBy` reads
|
|
299
|
+
// `auto-mode:codex:<mode>`, so an audit can tell the runtimes apart),
|
|
300
|
+
// the transcript-path session-consistency check (a Codex hook process
|
|
301
|
+
// carries no session-id environment variable for the Claude variant to
|
|
302
|
+
// compare against), and this hook's own ledger `source` and stderr
|
|
303
|
+
// label.
|
|
304
|
+
//
|
|
305
|
+
// Sharing the body does NOT share the opt-in: the attempt declines
|
|
306
|
+
// unless the operator listed `codex` in `auto_approve.harnesses`,
|
|
307
|
+
// which an `auto_approve` block written before this hook existed does
|
|
308
|
+
// not (an absent key means Claude Code only).
|
|
309
|
+
//
|
|
310
|
+
// It never returns an allow of its own: the allow below comes from the
|
|
311
|
+
// auto path's own re-run of `checkOperatorApprovalMarkers`, the same
|
|
312
|
+
// authority source 1 consults, and is reported through this hook's
|
|
313
|
+
// ordinary `allowResult` with `source: "marker"`. Any failure falls
|
|
314
|
+
// through to the block with `markerExpired` / `markerForged` intact.
|
|
315
|
+
//
|
|
316
|
+
// Placed BEFORE the `.pending-approval` staging write below on
|
|
317
|
+
// purpose: a successful auto-approval must not leave this session id
|
|
318
|
+
// staged for a later arg-less `harness approve understanding` to
|
|
319
|
+
// resolve to.
|
|
320
|
+
//
|
|
321
|
+
// The ledger writer resolves lazily, exactly like the Claude hook: the
|
|
322
|
+
// thunk runs only after the auto path's own opt-in and `when` checks
|
|
323
|
+
// both pass, so an ordinary gated Codex call never resolves one.
|
|
324
|
+
const resolveAutoLedger = () => {
|
|
325
|
+
if (opts.writeLedger)
|
|
326
|
+
return { write: opts.writeLedger };
|
|
327
|
+
const resolved = resolveManifestLedgerWriter(manifest, {
|
|
328
|
+
...(opts.ledgerTimeoutMs !== undefined ? { ledgerTimeoutMs: opts.ledgerTimeoutMs } : {}),
|
|
329
|
+
});
|
|
330
|
+
return resolved.ok ? { write: resolved.write } : { write: null, reason: resolved.reason };
|
|
331
|
+
};
|
|
332
|
+
const auto = await attemptAutoApproval({
|
|
333
|
+
generatedDir,
|
|
334
|
+
sessionId,
|
|
335
|
+
payloadSessionId: event.session_id,
|
|
336
|
+
permissionMode: event.permission_mode,
|
|
337
|
+
harness: CODEX_HARNESS,
|
|
338
|
+
// This hook's own verb on the audit-only ledger fact and its own
|
|
339
|
+
// stderr prefix, so neither an audit row nor a diagnostic line
|
|
340
|
+
// attributes a Codex decision to the Claude Code hook.
|
|
341
|
+
ledgerSource: AUTO_APPROVE_LEDGER_SOURCE_CODEX,
|
|
342
|
+
label: "harness pack hook codex",
|
|
343
|
+
sessionConsistency: { kind: "transcript-path", transcriptPath: event.transcript_path },
|
|
344
|
+
packConfig: declared.config,
|
|
345
|
+
reportsDir,
|
|
346
|
+
markerForged,
|
|
347
|
+
stderr,
|
|
348
|
+
resolveLedger: resolveAutoLedger,
|
|
349
|
+
});
|
|
350
|
+
if (auto.approved) {
|
|
351
|
+
return allowResult(auto.detail, "marker", stderr);
|
|
352
|
+
}
|
|
239
353
|
// Stage the session id so `harness approve understanding`, run from
|
|
240
354
|
// the operator's shell where none of $CODEX_SESSION_ID,
|
|
241
355
|
// $CLAUDE_CODE_SESSION_ID or $CLAUDE_SESSION_ID is set, can resolve it without scraping logs or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-codex-pre-tool-use.js","sourceRoot":"","sources":["../../../src/cli/pack/hook-codex-pre-tool-use.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,qEAAqE;AACrE,yEAAyE;AACzE,gDAAgD;AAChD,EAAE;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,CAAC;QACtF,CAAC,CAAC,IAAI,CAAC;IACX,kEAAkE;IAClE,qDAAqD;IACrD,wEAAwE;IACxE,6CAA6C;IAC7C,MAAM,eAAe,GAAG,6BAA6B,CACnD,gBAAgB,EAAE,iBAAiB,IAAI,EAAE,CAC1C,CAAC;IACF,IAAI,eAAe,EAAE,CAAC;QACpB,WAAW,GAAG,GAAG,WAAW,OAAO,eAAe,EAAE,CAAC;IACvD,CAAC;IACD,MAAM,UAAU,GAAG,QAAQ;QACzB,CAAC,CAAC,mCAAmC,MAAM,MAAM,WAAW,EAAE;QAC9D,CAAC,CAAC,mCAAmC,MAAM,WAAW,QAAQ,KAAK,WAAW,EAAE,CAAC;IACnF,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAClE,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"hook-codex-pre-tool-use.js","sourceRoot":"","sources":["../../../src/cli/pack/hook-codex-pre-tool-use.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,qEAAqE;AACrE,yEAAyE;AACzE,gDAAgD;AAChD,EAAE;AACF,+DAA+D;AAC/D,wEAAwE;AACxE,+DAA+D;AAC/D,0CAA0C;AAC1C,mEAAmE;AACnE,sCAAsC;AACtC,qEAAqE;AACrE,oEAAoE;AACpE,sEAAsE;AACtE,0DAA0D;AAC1D,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;AAErE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,i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Ae,EAAE,CAAC;QACpB,WAAW,GAAG,GAAG,WAAW,OAAO,eAAe,EAAE,CAAC;IACvD,CAAC;IACD,MAAM,UAAU,GAAG,QAAQ;QACzB,CAAC,CAAC,mCAAmC,MAAM,MAAM,WAAW,EAAE;QAC9D,CAAC,CAAC,mCAAmC,MAAM,WAAW,QAAQ,KAAK,WAAW,EAAE,CAAC;IACnF,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAClE,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type LedgerEntry } from "../../policies/index.js";
|
|
2
2
|
import { type ApprovalCheckResult } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
|
|
3
|
+
import { type LedgerWriteFn } from "../../runtime/ledger-writer.js";
|
|
3
4
|
import { type Manifest } from "../../schema/index.js";
|
|
4
5
|
import { type LoaderOptions } from "../loader.js";
|
|
5
6
|
export interface PackHookPreToolUseOptions extends LoaderOptions {
|
|
@@ -23,6 +24,16 @@ export interface PackHookPreToolUseOptions extends LoaderOptions {
|
|
|
23
24
|
ledgerQuery?: (sessionId: string) => Promise<LedgerEntry[] | {
|
|
24
25
|
degraded: string;
|
|
25
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Inject the ledger WRITER used for the auto-approval path's audit-only
|
|
29
|
+
* `understanding-auto-approved:<sid>` fact (test). Mirrors
|
|
30
|
+
* `hook-post-merge-gate-record.ts`'s injection point. When omitted the
|
|
31
|
+
* writer is resolved from the manifest's `grounding-mcp` entry, exactly
|
|
32
|
+
* as every other Trusted-Writer producer does; when that resolution
|
|
33
|
+
* fails the auto path logs one line and continues (audit only, never a
|
|
34
|
+
* gate input).
|
|
35
|
+
*/
|
|
36
|
+
writeLedger?: LedgerWriteFn;
|
|
26
37
|
/**
|
|
27
38
|
* Override "now" for the pause-sentinel expiry check (test injection).
|
|
28
39
|
* The lower layers (`checkPauseFromLoader`, `maybeAnnouncePause`,
|