@lannguyensi/harness 0.50.0 → 0.52.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/dist/cli/approve/understanding.d.ts +97 -0
  3. package/dist/cli/approve/understanding.js +67 -24
  4. package/dist/cli/approve/understanding.js.map +1 -1
  5. package/dist/cli/audit.d.ts +29 -0
  6. package/dist/cli/audit.js +130 -17
  7. package/dist/cli/audit.js.map +1 -1
  8. package/dist/cli/delegate/index.d.ts +63 -0
  9. package/dist/cli/delegate/index.js +313 -0
  10. package/dist/cli/delegate/index.js.map +1 -0
  11. package/dist/cli/doctor/auto-approve-mode.d.ts +37 -0
  12. package/dist/cli/doctor/auto-approve-mode.js +80 -0
  13. package/dist/cli/doctor/auto-approve-mode.js.map +1 -0
  14. package/dist/cli/doctor/claude-mcp.d.ts +14 -0
  15. package/dist/cli/doctor/claude-mcp.js +7 -1
  16. package/dist/cli/doctor/claude-mcp.js.map +1 -1
  17. package/dist/cli/doctor/codex-config-drift.d.ts +28 -0
  18. package/dist/cli/doctor/codex-config-drift.js +240 -0
  19. package/dist/cli/doctor/codex-config-drift.js.map +1 -0
  20. package/dist/cli/doctor/format.js +67 -1
  21. package/dist/cli/doctor/format.js.map +1 -1
  22. package/dist/cli/doctor/index.d.ts +20 -0
  23. package/dist/cli/doctor/index.js +84 -1
  24. package/dist/cli/doctor/index.js.map +1 -1
  25. package/dist/cli/doctor/settings-drift.d.ts +25 -0
  26. package/dist/cli/doctor/settings-drift.js +203 -0
  27. package/dist/cli/doctor/settings-drift.js.map +1 -0
  28. package/dist/cli/doctor/types.d.ts +69 -0
  29. package/dist/cli/doctor/types.js.map +1 -1
  30. package/dist/cli/doctor/ug-auto-approvals.d.ts +40 -0
  31. package/dist/cli/doctor/ug-auto-approvals.js +116 -0
  32. package/dist/cli/doctor/ug-auto-approvals.js.map +1 -0
  33. package/dist/cli/doctor/ug-delegations.d.ts +26 -0
  34. package/dist/cli/doctor/ug-delegations.js +112 -0
  35. package/dist/cli/doctor/ug-delegations.js.map +1 -0
  36. package/dist/cli/doctor/understanding-mode-env.d.ts +12 -0
  37. package/dist/cli/doctor/understanding-mode-env.js +16 -1
  38. package/dist/cli/doctor/understanding-mode-env.js.map +1 -1
  39. package/dist/cli/index.js +100 -1
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/cli/pack/approve-escape.js +16 -7
  42. package/dist/cli/pack/approve-escape.js.map +1 -1
  43. package/dist/cli/pack/auto-approve-path.d.ts +135 -0
  44. package/dist/cli/pack/auto-approve-path.js +400 -0
  45. package/dist/cli/pack/auto-approve-path.js.map +1 -0
  46. package/dist/cli/pack/hook-codex-pre-tool-use.d.ts +9 -0
  47. package/dist/cli/pack/hook-codex-pre-tool-use.js +118 -4
  48. package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
  49. package/dist/cli/pack/hook-pre-tool-use.d.ts +36 -0
  50. package/dist/cli/pack/hook-pre-tool-use.js +402 -3
  51. package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
  52. package/dist/cli/pack/transcript-report-scan.d.ts +71 -0
  53. package/dist/cli/pack/transcript-report-scan.js +359 -0
  54. package/dist/cli/pack/transcript-report-scan.js.map +1 -0
  55. package/dist/cli/smoke/index.d.ts +18 -1
  56. package/dist/cli/smoke/index.js +54 -0
  57. package/dist/cli/smoke/index.js.map +1 -1
  58. package/dist/cli/validate/checks.js +81 -0
  59. package/dist/cli/validate/checks.js.map +1 -1
  60. package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.d.ts +210 -0
  61. package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js +361 -0
  62. package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js.map +1 -0
  63. package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.d.ts +223 -0
  64. package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js +633 -0
  65. package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js.map +1 -0
  66. package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +3 -1
  67. package/dist/policy-packs/builtin/understanding-before-execution/index.js +10 -1
  68. package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
  69. package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.d.ts +29 -0
  70. package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js +82 -0
  71. package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js.map +1 -0
  72. package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +23 -0
  73. package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +29 -0
  74. package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +1 -1
  75. package/dist/policy-packs/builtin/understanding-before-execution.d.ts +42 -0
  76. package/dist/policy-packs/builtin/understanding-before-execution.js +56 -1
  77. package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
  78. package/dist/runtime/approval-signing.d.ts +22 -0
  79. package/dist/runtime/approval-signing.js +83 -1
  80. package/dist/runtime/approval-signing.js.map +1 -1
  81. package/package.json +1 -1
@@ -0,0 +1,400 @@
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
+ // TWO ALTERNATIVE KEY-ONE SIGNALS (slice 3, agent-tasks 37ad0b05). The
48
+ // ADR's "Decision: two-key design" makes the trusted signal a
49
+ // disjunction: a `when`-listed `permission_mode`, OR a valid delegation
50
+ // for this child session that the CALLING HOOK has already verified and
51
+ // passes in as `delegation`. Both are only key ONE. Key two, the child's
52
+ // own strict-session `pending` report, is condition (6) below and is
53
+ // identical on both paths; nothing about a delegation relaxes it, and no
54
+ // branch here reads a delegation file, so the one verifier stays in
55
+ // `understanding-before-execution/delegation-markers.ts`.
56
+ //
57
+ // ONE BODY IS NOT ONE OPT-IN. Sharing the body would otherwise mean an
58
+ // `auto_approve` block written for Claude Code opts every Codex session
59
+ // in too; `auto_approve.harnesses` is the explicit per-harness
60
+ // allowlist that prevents it, defaulting to Claude Code only when the
61
+ // key is absent (step 1b below).
62
+ import * as fs from "node:fs";
63
+ import * as path from "node:path";
64
+ import { autoApprovedByFor, autoApprovedLedgerTagFor, checkOperatorApprovalMarkers, harnessAllowed, listPersistedReports, parseAutoApprove, permissionModeAllowed, selectNewestStrictSessionReport, writeApprovalMarker, } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
65
+ import { sha256Hex, signingKeyExists } from "../../runtime/approval-signing.js";
66
+ import { clearPendingApproval, readPendingApproval, } from "../../runtime/pending-approval.js";
67
+ import { rewriteReportApproved, validatePersistedReport } from "../approve/understanding.js";
68
+ /**
69
+ * Source string the CLAUDE CODE hook records on the audit-only ledger
70
+ * fact — the verb that actually made the write.
71
+ */
72
+ export const AUTO_APPROVE_LEDGER_SOURCE = "harness-pack-hook-pre-tool-use";
73
+ /**
74
+ * The Codex hook's counterpart. A shared body must not stamp the Claude
75
+ * verb on a Codex write: the ledger fact is an audit surface, and an
76
+ * auditor reading `harness-pack-hook-pre-tool-use` on a Codex session
77
+ * would be reading a fact about a hook that never ran (reviewer round-1
78
+ * finding on slice 2). The `approvedBy` segment already distinguishes
79
+ * the runtimes; this makes the ledger row agree with it.
80
+ */
81
+ export const AUTO_APPROVE_LEDGER_SOURCE_CODEX = "harness-pack-hook-codex-pre-tool-use";
82
+ /** Default stderr prefix: the Claude Code hook's, byte-for-byte. */
83
+ const DEFAULT_LABEL = "harness pack hook";
84
+ /**
85
+ * The `<mode>` segment an auto-marker carries whenever key one came from
86
+ * the DELEGATION rather than from a `when`-listed `permission_mode`.
87
+ * `auto-mode:claude-code:delegated;delegated:<parent-sid>` reads as what
88
+ * it is: a child whose trusted signal was the parent's pre-authorization,
89
+ * not a permission mode. Used unconditionally on that path, whatever the
90
+ * payload's own mode says, since that mode played no part in the decision.
91
+ */
92
+ const DELEGATED_MODE_LABEL = "delegated";
93
+ function decline(reason) {
94
+ return { approved: false, reason };
95
+ }
96
+ /**
97
+ * Attempt the operator-opted-in auto-approval for this PreToolUse call.
98
+ * See the module header for placement and the fail-closed contract; the
99
+ * numbered steps below are conditions 1-6 of the ADR's Option A.
100
+ */
101
+ export async function attemptAutoApproval(args) {
102
+ const { stderr } = args;
103
+ const label = args.label ?? DEFAULT_LABEL;
104
+ const note = (msg) => {
105
+ stderr.write(`${label}: ${msg}\n`);
106
+ };
107
+ // (1) Opt-in. Absent is the ordinary case and stays SILENT; a
108
+ // malformed block already wrote its own single line inside
109
+ // `parseAutoApprove` (fail-closed: malformed means "not opted in",
110
+ // never a partial default).
111
+ const packConfigObj = args.packConfig !== null && typeof args.packConfig === "object" && !Array.isArray(args.packConfig)
112
+ ? args.packConfig
113
+ : {};
114
+ const cfg = parseAutoApprove(packConfigObj["auto_approve"], stderr, label);
115
+ if (cfg === null)
116
+ return decline("auto_approve not configured");
117
+ // (1b) Per-harness opt-in, checked BEFORE the `when` allowlist and
118
+ // before the ledger thunk below, so an unlisted harness resolves
119
+ // nothing and never reaches any evidence lookup. Two call sites share
120
+ // this body; without this check an `auto_approve` block written for
121
+ // Claude Code before the Codex hook existed would silently start
122
+ // auto-approving every Codex session that runs in a listed
123
+ // `permission_mode` (reviewer round-1 finding on slice 2). `harnesses`
124
+ // is absent in exactly those older configs and resolves to Claude Code
125
+ // only, so opting a second runtime in stays an explicit config edit.
126
+ // Diagnosed, unlike the silent `when` miss below: an unlisted harness
127
+ // is a configuration mismatch worth seeing once per call, not the
128
+ // ordinary state of an opted-in session.
129
+ if (!harnessAllowed(cfg, args.harness)) {
130
+ note(`auto-approval declined: harness "${args.harness}" is not listed in auto_approve.harnesses`);
131
+ return decline("harness not in auto_approve.harnesses");
132
+ }
133
+ // (2) `when` allowlist, exact string equality against the payload
134
+ // literal (hardening item 2). Absent / empty / unlisted is the normal
135
+ // case for an opted-in repo whose session simply runs in a prompting
136
+ // mode, and it fires on EVERY such call once the opt-in is present, so
137
+ // this stays SILENT (no stderr line): a per-call note here would echo
138
+ // the configured `auto_approve.when` allowlist to stderr on every
139
+ // ordinary prompting-mode call (reviewer round-1 finding).
140
+ const mode = args.permissionMode;
141
+ const modeAllowed = permissionModeAllowed(cfg, mode);
142
+ if (!modeAllowed && args.delegation === undefined) {
143
+ return decline("permission_mode not in auto_approve.when");
144
+ }
145
+ // Which of the ADR's two alternative key-one signals actually applied.
146
+ // Logged only on the delegation path: the `when` hit is the ordinary
147
+ // slice-1 case and stays as silent as it was, so slice 1's stderr trail
148
+ // is byte-identical to what it was before this argument existed.
149
+ if (args.delegation !== undefined) {
150
+ note(modeAllowed
151
+ ? `auto-approval key one: permission_mode ${JSON.stringify(mode)} in auto_approve.when (a valid delegation from parent session ${args.delegation.parentSessionId} is also present)`
152
+ : `auto-approval key one: valid delegation from parent session ${args.delegation.parentSessionId}`);
153
+ }
154
+ // The `<mode>` segment of `approvedBy` records WHICH key one applied,
155
+ // so it carries a payload literal in exactly one case: the mode itself
156
+ // was `when`-listed, i.e. the operator wrote that exact string in the
157
+ // config and this call matched it.
158
+ //
159
+ // On the delegation path the payload's mode is UNCONSTRAINED (that is
160
+ // the whole point: a `-p` child may carry `default`, or nothing) and it
161
+ // played no part in the decision, so it is replaced by the neutral
162
+ // `delegated` literal wholesale rather than filtered. Filtering only the
163
+ // encoding-breaking characters was not enough: `approvedBy` is a signed
164
+ // AUDIT record, and a payload-composed mode carrying a newline or a tab
165
+ // survives a `;`/`:` check, lands verbatim in the signed field, and then
166
+ // shows up in the doctor listing as a permission mode that never
167
+ // existed (reviewer finding L2). Nothing is lost: the payload's mode is
168
+ // not evidence of anything on this path.
169
+ const modeStr = modeAllowed ? mode : DELEGATED_MODE_LABEL;
170
+ // Resolve the audit-only ledger writer NOW, not earlier: this is the
171
+ // first point past both the opt-in check (1) and the `when` allowlist
172
+ // check (2), so `args.resolveLedger` runs only on a call that has an
173
+ // actual chance of reaching the ledger write below, never on the
174
+ // overwhelming majority of gated calls that are not opted in or run in
175
+ // an unlisted permission mode.
176
+ const ledger = args.resolveLedger();
177
+ // (3) A forgery detected at step 3 is never laundered into an
178
+ // approval (ADR condition 6). Declining also leaves the forged FILE and
179
+ // its distinct `forged/unsigned marker rejected` diagnostic on disk —
180
+ // `writeApprovalMarker` would atomically overwrite that exact path.
181
+ if (args.markerForged) {
182
+ note("auto-approval declined: forged/unsigned marker present");
183
+ return decline("forged marker present");
184
+ }
185
+ // (4) Session consistency (hardening item 1): the PAYLOAD's own
186
+ // `session_id` must be present and must agree with a SECOND input the
187
+ // hook reads for itself — the runtime's session-id environment
188
+ // variable on Claude Code, the named per-session transcript file on
189
+ // Codex. Compared against the payload field specifically, never the
190
+ // hook's env-fallback-resolved id, or the env variant would compare
191
+ // the environment with itself.
192
+ const payloadSid = typeof args.payloadSessionId === "string" && args.payloadSessionId.length > 0
193
+ ? args.payloadSessionId
194
+ : null;
195
+ if (payloadSid === null) {
196
+ note("auto-approval declined: event payload carries no session_id");
197
+ return decline("no payload session_id");
198
+ }
199
+ const consistency = args.sessionConsistency;
200
+ if (consistency.kind === "env") {
201
+ const envSid = process.env[consistency.variable];
202
+ if (typeof envSid !== "string" || envSid.length === 0) {
203
+ note(`auto-approval declined: $${consistency.variable} is not set in the hook environment`);
204
+ return decline(`no ${consistency.variable}`);
205
+ }
206
+ if (envSid !== payloadSid) {
207
+ note(`auto-approval declined: payload session_id does not match $${consistency.variable} in the hook environment`);
208
+ return decline("session id mismatch");
209
+ }
210
+ }
211
+ else {
212
+ // Codex carries no session-id environment variable in the hook
213
+ // process (measured live, Codex 0.150.1: only CODEX_HOME,
214
+ // CODEX_MANAGED_BY_NPM, CODEX_MANAGED_PACKAGE_ROOT), so the env
215
+ // variant has no counterpart there. The payload's own
216
+ // `transcript_path` is the second input instead: Codex names the
217
+ // session's rollout file
218
+ // `<CODEX_HOME>/sessions/YYYY/MM/DD/rollout-<timestamp>-<session_id>.jsonl`
219
+ // and the file already exists when PreToolUse fires.
220
+ //
221
+ // Three separately-diagnosed conditions, each fail-closed: the
222
+ // field is a non-empty string; its BASENAME names this exact
223
+ // session (`-<sid>.jsonl`, or a bare `<sid>.jsonl` for a shim that
224
+ // drops the `rollout-<timestamp>` prefix); and the path resolves to
225
+ // a REGULAR FILE. `statSync().isFile()`, not `existsSync`: a
226
+ // directory named `<sid>.jsonl` is not a transcript, and neither is
227
+ // a socket or a device node, yet all of them satisfy mere existence
228
+ // (reviewer round-1 finding on slice 2). It is deliberately not a
229
+ // content check: reading and parsing the rollout would make the hook
230
+ // depend on Codex's internal transcript format for a check that is
231
+ // not a boundary anyway (see SessionConsistencyCheck).
232
+ const transcriptPath = typeof consistency.transcriptPath === "string" && consistency.transcriptPath.length > 0
233
+ ? consistency.transcriptPath
234
+ : null;
235
+ if (transcriptPath === null) {
236
+ note("auto-approval declined: event payload carries no transcript_path");
237
+ return decline("no transcript_path");
238
+ }
239
+ const base = path.basename(transcriptPath);
240
+ if (base !== `${payloadSid}.jsonl` && !base.endsWith(`-${payloadSid}.jsonl`)) {
241
+ note(`auto-approval declined: transcript_path does not name session ${payloadSid} (basename ${base})`);
242
+ return decline("transcript_path session mismatch");
243
+ }
244
+ // `throwIfNoEntry: false` covers the ordinary ENOENT; the try/catch
245
+ // covers every other stat failure (a permission error, a symlink
246
+ // loop), which fails closed here rather than throwing out of a hook
247
+ // whose caller treats a throw as neither allow nor block.
248
+ let transcriptIsFile = false;
249
+ try {
250
+ transcriptIsFile = fs.statSync(transcriptPath, { throwIfNoEntry: false })?.isFile() === true;
251
+ }
252
+ catch {
253
+ transcriptIsFile = false;
254
+ }
255
+ if (!transcriptIsFile) {
256
+ note(`auto-approval declined: transcript_path does not name an existing file (${transcriptPath})`);
257
+ return decline("transcript_path missing");
258
+ }
259
+ }
260
+ // (5) Key precheck BEFORE any write (hardening item 5). The shared
261
+ // write path would otherwise mint the key it is supposed to require:
262
+ // `writeApprovalMarker` -> `signMarker` -> `getOrCreateSigningKey`
263
+ // generates one on ENOENT. Key creation stays an operator-side act.
264
+ if (args.generatedDir === undefined) {
265
+ note("auto-approval declined: harness.generated/ could not be resolved");
266
+ return decline("generatedDir unresolvable");
267
+ }
268
+ const generatedDir = args.generatedDir;
269
+ if (!signingKeyExists(generatedDir)) {
270
+ note("auto-approval declined: signing key absent (never created by the hook)");
271
+ return decline("signing key absent");
272
+ }
273
+ // (6) The report precondition: the NEWEST strict-session report, and
274
+ // only that one, must be exactly `pending`, parse, and pass the
275
+ // approve CLI's own content validation.
276
+ const newest = selectNewestStrictSessionReport(listPersistedReports(args.reportsDir), args.sessionId);
277
+ if (newest === null) {
278
+ note(`auto-approval declined: no persisted report bound to session ${args.sessionId}`);
279
+ return decline("no report for session");
280
+ }
281
+ if (newest.approvalStatus !== "pending") {
282
+ note(`auto-approval declined: newest report for session ${args.sessionId} is approvalStatus=${newest.approvalStatus ?? "<missing>"}, not pending`);
283
+ return decline("newest report not pending");
284
+ }
285
+ let raw;
286
+ try {
287
+ raw = fs.readFileSync(newest.filePath, "utf8");
288
+ }
289
+ catch (err) {
290
+ note(`auto-approval declined: report unreadable (${err.message})`);
291
+ return decline("report unreadable");
292
+ }
293
+ let parsed;
294
+ try {
295
+ parsed = JSON.parse(raw);
296
+ }
297
+ catch (err) {
298
+ note(`auto-approval declined: report invalid (unparseable JSON: ${err.message})`);
299
+ return decline("report unparseable");
300
+ }
301
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
302
+ note("auto-approval declined: report invalid (body is not a JSON object)");
303
+ return decline("report not an object");
304
+ }
305
+ const validation = validatePersistedReport(parsed);
306
+ if (!validation.ok) {
307
+ note(`auto-approval declined: report invalid (${validation.field}: ${validation.reason})`);
308
+ return decline(`report invalid: ${validation.field}`);
309
+ }
310
+ // Success sequence. `reportContentHash` binds the bytes as they were
311
+ // BEFORE the approval rewrite, exactly as the approve CLI computes it.
312
+ const reportContentHash = sha256Hex(raw);
313
+ const approvedAt = new Date().toISOString();
314
+ // The parent linkage rides in the same signed `approvedBy` field the
315
+ // source already travels in (ADR "Audit and doctor"): no new signed
316
+ // field, therefore no `SIGNING_ALG` bump. `parseAutoApprovedBy` strips
317
+ // the suffix, so the doctor listing still buckets the marker by
318
+ // harness/mode. The parent id needs no escaping here: it comes out of a
319
+ // verified delegation whose own writer already refused a `;` or `=` in
320
+ // it (`buildDelegationApprovedBy`'s `rejectUnsafeSegmentValue`).
321
+ const approvedBy = args.delegation === undefined
322
+ ? autoApprovedByFor(args.harness, modeStr)
323
+ : `${autoApprovedByFor(args.harness, modeStr)};delegated:${args.delegation.parentSessionId}`;
324
+ // CONSUME FIRST, then sign. If the marker write fails after this, the
325
+ // report is spent and no marker exists: the call blocks and the same
326
+ // report can never mint again. The reverse order would leave a
327
+ // still-`pending` report behind a failed write, i.e. a report that is
328
+ // mintable on the very next call — the direction this design refuses.
329
+ try {
330
+ rewriteReportApproved(newest.filePath, approvedAt, approvedBy, args.sessionId);
331
+ }
332
+ catch (err) {
333
+ note(`auto-approval declined: could not consume the report (${err.message})`);
334
+ return decline("report consumption failed");
335
+ }
336
+ let markerPath;
337
+ try {
338
+ markerPath = writeApprovalMarker(generatedDir, args.sessionId, {
339
+ approvedAt,
340
+ approvedBy,
341
+ reportContentHash,
342
+ });
343
+ }
344
+ catch (err) {
345
+ note(`auto-approval declined: failed to write the approval marker (${err.message}); the report was consumed, so this session needs a fresh report`);
346
+ return decline("marker write failed");
347
+ }
348
+ // Audit-only ledger fact. Never a gate input, so every failure here is
349
+ // one stderr line and nothing more.
350
+ const tag = autoApprovedLedgerTagFor(args.sessionId);
351
+ if (ledger.write === null) {
352
+ note(`auto-approval ledger fact ${tag} not recorded (${ledger.reason ?? "ledger writer unavailable"}); audit only, continuing`);
353
+ }
354
+ else {
355
+ try {
356
+ const result = await ledger.write({
357
+ sessionId: args.sessionId,
358
+ content: tag,
359
+ source: args.ledgerSource,
360
+ });
361
+ if (!result.ok) {
362
+ note(`auto-approval ledger fact ${tag} not recorded (${result.reason ?? "unknown error"}); audit only, continuing`);
363
+ }
364
+ }
365
+ catch (err) {
366
+ note(`auto-approval ledger fact ${tag} not recorded (${err.message}); audit only, continuing`);
367
+ }
368
+ }
369
+ // Drop this session's `.pending-approval` staging entry (decision-order
370
+ // table, step 9). It is tier 5 of the approve verbs' session
371
+ // resolution and is otherwise cleared only by `harness approve
372
+ // understanding`, which auto mode never runs — so leaving it would let
373
+ // a later env-less operator `harness approve ...` resolve to this
374
+ // already-auto-approved id. Only ever clears OUR OWN id.
375
+ try {
376
+ if (readPendingApproval(generatedDir) === args.sessionId) {
377
+ clearPendingApproval(generatedDir);
378
+ }
379
+ }
380
+ catch {
381
+ /* best-effort; staging is not a gate input */
382
+ }
383
+ // The verdict comes from the same marker check every other approval
384
+ // goes through — the auto path itself never allows.
385
+ const recheck = checkOperatorApprovalMarkers(generatedDir, args.sessionId, args.packConfig, stderr);
386
+ if (!recheck.matched) {
387
+ note(`auto-approval wrote a marker but the re-check did not match (${recheck.detail}); falling through to the block`);
388
+ return decline("post-write marker re-check did not match");
389
+ }
390
+ note(`auto-approved via session marker by ${approvedBy}`);
391
+ return {
392
+ approved: true,
393
+ detail: recheck.detail,
394
+ approvedBy,
395
+ markerPath,
396
+ reportPath: newest.filePath,
397
+ reportContentHash,
398
+ };
399
+ }
400
+ //# 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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;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's documented hook
204
- // envelope carries tool args in `raw_input`; if that field is absent
205
- // or unclassifiable, fall through to the block path (fail-closed).
206
- const commandStr = extractCodexShellCommand(event.raw_input);
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;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,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,sBAAsB,E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,EAAE,CAAC;IACvI,mEAAmE;IACnE,uEAAuE;IACvE,mEAAmE;IACnE,yDAAyD;IACzD,qEAAqE;IACrE,mEAAmE;IACnE,mEAAmE;IACnE,gEAAgE;IAChE,kEAAkE;IAClE,sEAAsE;IACtE,oEAAoE;IACpE,mEAAmE;IACnE,yEAAyE;IACzE,MAAM,gBAAgB,GACpB,MAAM,CAAC,MAAM,KAAK,IAAI;QACpB,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,EAAE,SAAS,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;AA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