agent-sanitizer 2.68.0 → 2.69.1

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.
@@ -286,6 +286,25 @@ export function safeErrMessage(err: unknown, cap?: number): string;
286
286
  * @returns {void}
287
287
  */
288
288
  export function emitHookResponse(hookEventName: string, fields: Record<string, unknown>): void;
289
+ /**
290
+ * @typedef {{
291
+ * add: (envelope: Record<string, any>) => void,
292
+ * emit: (hookEventName: string, fields: Record<string, unknown>) => void,
293
+ * flush: () => void,
294
+ * }} EnvelopeBuffer
295
+ */
296
+ /**
297
+ * Collect everything a hook run wants to say on stdout and write it as exactly
298
+ * ONE JSON object on `flush`. Claude Code parses a hook's stdout as a single
299
+ * document, so two envelopes written by two reporters (a fault notice, then the
300
+ * slow-hook notice from the timing wrapper's `finally`) concatenate into invalid
301
+ * output and the host DROPS the whole response — the model never sees either
302
+ * warning. Every reporter in a run therefore adds here instead of writing, and
303
+ * the entry point flushes once, last.
304
+ * @param {(chunk: string) => void} [write] injectable stdout sink, for tests
305
+ * @returns {EnvelopeBuffer}
306
+ */
307
+ export function createEnvelopeBuffer(write?: (chunk: string) => void): EnvelopeBuffer;
289
308
  /**
290
309
  * The directory the session-lifetime stores live under: the alert markers and
291
310
  * findings (invisible-alert.mjs) and the reveal sidecars (reveal.mjs). They must
@@ -307,6 +326,15 @@ export function emitHookResponse(hookEventName: string, fields: Record<string, u
307
326
  * @returns {string}
308
327
  */
309
328
  export function resolveStateRoot(env: Record<string, string | undefined>): string;
329
+ /**
330
+ * Every root a hook process given `env` can resolve STATE_ROOT to, deduplicated.
331
+ * Each process resolves its own root, and one whose check faulted takes $TMPDIR
332
+ * while the rest keep the plugin data dir, so a reader of state another hook
333
+ * wrote looks under each. Unchecked: the reader's own trust checks apply.
334
+ * @param {Record<string, string | undefined>} env
335
+ * @returns {string[]}
336
+ */
337
+ export function stateRootCandidates(env: Record<string, string | undefined>): string[];
310
338
  /**
311
339
  * Adopt a host's own cold-start marker path in place of the derived one, so a
312
340
  * host whose setup script already writes a marker under its own convention can
@@ -522,14 +550,16 @@ export function touchLiveState(path: string): void;
522
550
  * file the hook's user owns. Unlink any existing entry first (removing a squatted
523
551
  * symlink), then create exclusively (O_EXCL) so a symlink re-planted in the race
524
552
  * window fails the open rather than being dereferenced. Content is irrelevant —
525
- * callers test only for existence — so the file is left empty. Best-effort: a
526
- * missing/read-only $TMPDIR or a lost race just leaves the sentinel absent, and
527
- * every caller treats "absent" as "not yet done" (a repeated ask, never a crash),
528
- * so all failures are swallowed.
553
+ * callers test only for existence — so the file is left empty. Never throws: a
554
+ * missing/read-only $TMPDIR or a lost race leaves the sentinel absent, and the
555
+ * return value says so. A caller whose refusal is released only by a later read
556
+ * of this sentinel must branch on it, because a refusal that records nothing can
557
+ * never be released.
529
558
  * @param {string} path
530
- * @returns {void}
559
+ * @returns {boolean} whether a sentinel this uid owns now exists at `path`
560
+ * (the same test {@link markerIsTrusted} applies when a reader looks for it)
531
561
  */
532
- export function writeSentinelFile(path: string): void;
562
+ export function writeSentinelFile(path: string): boolean;
533
563
  /**
534
564
  * Write `content` to `path` without following a symlink a co-tenant may have
535
565
  * pre-planted there — the content-bearing counterpart to writeSentinelFile. These
@@ -635,6 +665,11 @@ export const STATE_ROOT: string;
635
665
  * says it locks may be judged by the lock.
636
666
  */
637
667
  export const SETUP_LOCK_DECLARATION: "flock";
668
+ export type EnvelopeBuffer = {
669
+ add: (envelope: Record<string, any>) => void;
670
+ emit: (hookEventName: string, fields: Record<string, unknown>) => void;
671
+ flush: () => void;
672
+ };
638
673
  /**
639
674
  * EVERY process-wide slot these helpers keep — the four a host can observe or
640
675
  * steer, so a second instance that adopts this object is steered in all four at
@@ -10,15 +10,17 @@
10
10
  * files needs neither the clear nor the ordering — past sessions' artifacts
11
11
  * simply age out through {@link sweepStaleSessions}.
12
12
  * @param {string} [sessionId] the harness's session identity
13
+ * @param {string} [base] the store's root prefix
13
14
  * @returns {string}
14
15
  */
15
- export function sessionPrefix(sessionId?: string): string;
16
+ export function sessionPrefix(sessionId?: string, base?: string): string;
16
17
  /**
17
18
  * The directory holding this session's alert findings, one file per finding.
18
19
  * @param {string} [sessionId]
20
+ * @param {string} [base] the store's root prefix
19
21
  * @returns {string}
20
22
  */
21
- export function alertDir(sessionId?: string): string;
23
+ export function alertDir(sessionId?: string, base?: string): string;
22
24
  /**
23
25
  * Companion marker the PreToolUse gate writes once it has surfaced the alert
24
26
  * this session, so the gate asks ONCE then degrades to a passive reminder
@@ -32,9 +34,10 @@ export function alertAckFile(sessionId?: string): string;
32
34
  * Marker the InstructionsLoaded scanner writes on every fire, so another hook
33
35
  * can tell whether that event is being scanned at all this session.
34
36
  * @param {string} [sessionId]
37
+ * @param {string} [base] the store's root prefix
35
38
  * @returns {string}
36
39
  */
37
- export function instructionsLoadedFile(sessionId?: string): string;
40
+ export function instructionsLoadedFile(sessionId?: string, base?: string): string;
38
41
  /**
39
42
  * Companion marker: the notice below has been surfaced this session.
40
43
  * @param {string} [sessionId]
@@ -50,6 +53,12 @@ export function instructionsLoadedNoticeFile(sessionId?: string): string;
50
53
  * it is written once at launch, so otherwise a session outliving
51
54
  * MARKER_TTL_MS would have it swept by another session's SessionStart and read
52
55
  * its absence as the event never having fired.
56
+ *
57
+ * A session's marker is also looked for under the other {@link ALERT_BASES},
58
+ * where a scanner that resolved a different STATE_ROOT wrote it. The shared
59
+ * no-session marker is read only under this process's root, which this
60
+ * process's sweep ages out; read elsewhere it could silence the notice for
61
+ * every later session-less run on the machine.
53
62
  * @param {string} [sessionId]
54
63
  * @returns {boolean}
55
64
  */
@@ -155,7 +164,9 @@ export function recordInstructionsLoadedNotice(sessionId?: string): void;
155
164
  * the one report of an unscanned instruction file unreachable. The ack stays
156
165
  * strictly session-keyed, so the gate still asks exactly once per session. A
157
166
  * fallback finding is read only while it is inside FALLBACK_TTL_MS, which is
158
- * what keeps it from re-arming the gate for a later session.
167
+ * what keeps it from re-arming the gate for a later session. Both stores are
168
+ * read under every one of {@link ALERT_BASES}, where a writer that resolved a
169
+ * different STATE_ROOT left its finding.
159
170
  * @param {string} [sessionId]
160
171
  * @returns {string | null}
161
172
  */
@@ -193,11 +204,14 @@ export function alertAcknowledged(sessionId?: string): boolean;
193
204
  /**
194
205
  * Record that the gate has surfaced its blocking ask, so later tool calls get a
195
206
  * passive reminder instead of an ask on every call. Session-keyed, so the next
196
- * session re-asks once without anything having to clear this.
207
+ * session re-asks once without anything having to clear this. Returns false
208
+ * when the ack could not be recorded, so the caller knows the next call will
209
+ * ask again: under the fail-open posture it surfaces the finding as a warning
210
+ * rather than asking on every tool call for the rest of the session.
197
211
  * @param {string} [sessionId]
198
- * @returns {void}
212
+ * @returns {boolean}
199
213
  */
200
- export function acknowledgeAlert(sessionId?: string): void;
214
+ export function acknowledgeAlert(sessionId?: string): boolean;
201
215
  /**
202
216
  * The blocking ask. The heading states only that the scan did not finish clean:
203
217
  * the alert carries injection findings, unreadable targets, or a scanner fault,
@@ -11,6 +11,28 @@
11
11
  * @returns {string}
12
12
  */
13
13
  export function dropFingerprint(filePath: string, content: string, dropped?: string[]): string;
14
+ /**
15
+ * Fingerprint of one refusal of one exact tool call — same refusing site, same
16
+ * tool, same input — released by re-issuing that call. Keyed on the site too, so
17
+ * a call refused by two sites in turn needs a confirmation for each and one
18
+ * re-issue never releases a refusal the model was not shown. The input is
19
+ * hashed in canonical key order, so a re-issue whose keys arrive reordered is
20
+ * still the same call. Distinct domain tags keep it disjoint from
21
+ * {@link dropFingerprint}.
22
+ * @param {string} site
23
+ * @param {unknown} tool
24
+ * @param {unknown} toolInput
25
+ * @returns {string}
26
+ */
27
+ export function reissueFingerprint(site: string, tool: unknown, toolInput: unknown): string;
28
+ /**
29
+ * Record a confirm sentinel for `fingerprint`, so the identical re-issue is
30
+ * approved by {@link consumeConfirm}. False when it could not be recorded: the
31
+ * caller then must not refuse, because nothing could ever release the refusal.
32
+ * @param {string} fingerprint
33
+ * @returns {boolean}
34
+ */
35
+ export function recordConfirm(fingerprint: string): boolean;
14
36
  /**
15
37
  * The confirm sentinel's path for one fingerprint. Predictable and
16
38
  * world-visible like the alert markers, hence the markerIsTrusted read.
@@ -50,15 +72,16 @@ export function gitTracked(filePath: string, spawn?: typeof spawnSync): boolean;
50
72
  * rehydration substituted any placeholders — so a preserved secret shows up as
51
73
  * its real value in `content`. `io` is the rehydrate-shaped I/O bag (readFile /
52
74
  * redact / redactMap). Injectable seams: `isTracked` (the git probe),
53
- * `confirmSeen`/`recordConfirm` (the sentinel state).
75
+ * `confirmSeen`/`recordConfirm` (the sentinel state). A deny whose confirmation
76
+ * could not be recorded carries `fault` (see {@link dropUnconfirmable}).
54
77
  * @param {{file_path?: unknown, content?: unknown}} toolInput
55
78
  * @param {import("agent-sanitizer/rehydrate").RehydrateIo} io
56
79
  * @param {{
57
80
  * isTracked?: (filePath: string) => boolean,
58
81
  * confirmSeen?: (fingerprint: string) => boolean,
59
- * recordConfirm?: (fingerprint: string) => void,
82
+ * recordConfirm?: (fingerprint: string) => boolean,
60
83
  * }} [opts]
61
- * @returns {Promise<{deny: string} | null>}
84
+ * @returns {Promise<{deny: string, fault?: string} | null>}
62
85
  */
63
86
  export function secretDropGuard(toolInput: {
64
87
  file_path?: unknown;
@@ -66,9 +89,10 @@ export function secretDropGuard(toolInput: {
66
89
  }, io: import("agent-sanitizer/rehydrate").RehydrateIo, opts?: {
67
90
  isTracked?: (filePath: string) => boolean;
68
91
  confirmSeen?: (fingerprint: string) => boolean;
69
- recordConfirm?: (fingerprint: string) => void;
92
+ recordConfirm?: (fingerprint: string) => boolean;
70
93
  }): Promise<{
71
94
  deny: string;
95
+ fault?: string;
72
96
  } | null>;
73
97
  /**
74
98
  * Compose a Layer-4 rehydrator with this guard: for a Write the rehydrator
@@ -76,14 +100,41 @@ export function secretDropGuard(toolInput: {
76
100
  * substitution — so a rehydrated secret counts as preserved and only a
77
101
  * genuinely dropped one can trip it. A rehydrate deny short-circuits (the
78
102
  * guard never runs), non-Write tools skip the guard entirely, and a guard
79
- * deny wins over a pass/rewrite result.
80
- * @typedef {{updatedInput: any, context: string} | {deny: string} | null} RehydrateResult
103
+ * deny wins over a pass/rewrite result. A guard FAULT deny carries the
104
+ * rewrite as `release`: the open posture lets that call proceed, and it must
105
+ * proceed rehydrated, or every secret the rewrite restored is overwritten by
106
+ * its placeholder.
107
+ * @typedef {{updatedInput: any, context: string}} RehydrateRewrite
108
+ * @typedef {RehydrateRewrite | {deny: string, fault?: string, release?: RehydrateRewrite} | null} RehydrateResult
81
109
  * @param {(tool: string, toolInput: any) => Promise<RehydrateResult>} rehydrate
82
110
  * @param {import("agent-sanitizer/rehydrate").RehydrateIo} io
83
111
  * @param {typeof secretDropGuard} [guard]
84
112
  * @returns {(tool: string, toolInput: any) => Promise<RehydrateResult>}
85
113
  */
86
114
  export function withSecretDropGuard(rehydrate: (tool: string, toolInput: any) => Promise<RehydrateResult>, io: import("agent-sanitizer/rehydrate").RehydrateIo, guard?: typeof secretDropGuard): (tool: string, toolInput: any) => Promise<RehydrateResult>;
115
+ /**
116
+ * True when a trusted, fresh confirm sentinel exists for `fingerprint`,
117
+ * consuming it so one confirmation approves exactly one call. A sentinel
118
+ * older than {@link CONFIRM_TTL_MS} is stale — an abandoned deny from a
119
+ * previous session, not a live confirmation — so it is removed and NOT
120
+ * honored, preventing a leftover marker from acting as a standing
121
+ * auto-approval. Removal is best-effort: a fresh marker we could not unlink
122
+ * still counted as consumed for THIS call, and a leftover empty sentinel only
123
+ * ever re-approves the identical fingerprinted call the model already
124
+ * confirmed — and only within the TTL.
125
+ * @param {string} fingerprint
126
+ * @returns {boolean}
127
+ */
128
+ export function consumeConfirm(fingerprint: string): boolean;
129
+ /**
130
+ * True when a trusted confirm sentinel younger than {@link CONFIRM_TTL_MS}
131
+ * exists for `fingerprint`, WITHOUT consuming it — for a caller that learns
132
+ * only later whether the call it confirms actually proceeds, and consumes it
133
+ * then.
134
+ * @param {string} fingerprint
135
+ * @returns {boolean}
136
+ */
137
+ export function confirmFresh(fingerprint: string): boolean;
87
138
  /** A confirm sentinel older than this is stale, not a confirmation. */
88
139
  export const CONFIRM_TTL_MS: number;
89
140
  /**
@@ -92,12 +143,29 @@ export const CONFIRM_TTL_MS: number;
92
143
  * substitution — so a rehydrated secret counts as preserved and only a
93
144
  * genuinely dropped one can trip it. A rehydrate deny short-circuits (the
94
145
  * guard never runs), non-Write tools skip the guard entirely, and a guard
95
- * deny wins over a pass/rewrite result.
146
+ * deny wins over a pass/rewrite result. A guard FAULT deny carries the
147
+ * rewrite as `release`: the open posture lets that call proceed, and it must
148
+ * proceed rehydrated, or every secret the rewrite restored is overwritten by
149
+ * its placeholder.
96
150
  */
97
- export type RehydrateResult = {
151
+ export type RehydrateRewrite = {
98
152
  updatedInput: any;
99
153
  context: string;
100
- } | {
154
+ };
155
+ /**
156
+ * Compose a Layer-4 rehydrator with this guard: for a Write the rehydrator
157
+ * did not deny, run the guard on the FINAL content — after any placeholder
158
+ * substitution — so a rehydrated secret counts as preserved and only a
159
+ * genuinely dropped one can trip it. A rehydrate deny short-circuits (the
160
+ * guard never runs), non-Write tools skip the guard entirely, and a guard
161
+ * deny wins over a pass/rewrite result. A guard FAULT deny carries the
162
+ * rewrite as `release`: the open posture lets that call proceed, and it must
163
+ * proceed rehydrated, or every secret the rewrite restored is overwritten by
164
+ * its placeholder.
165
+ */
166
+ export type RehydrateResult = RehydrateRewrite | {
101
167
  deny: string;
168
+ fault?: string;
169
+ release?: RehydrateRewrite;
102
170
  } | null;
103
171
  import { spawnSync } from "node:child_process";
@@ -29,13 +29,14 @@
29
29
  * @param {boolean} [secretsOn] the run's secret opt-in (decided once by
30
30
  * buildPreToolUseResponse; a direct caller reads the env); only with it on
31
31
  * does the context claim the restored bytes were redacted
32
- * @returns {{ updatedInput: any, context: string } | { deny: string } | null}
32
+ * @returns {{ updatedInput: any, context: string } | { deny: string, fault?: string } | null}
33
33
  */
34
34
  export function rehydrateLayer2(tool: string, toolInput: any, secretsOn?: boolean): {
35
35
  updatedInput: any;
36
36
  context: string;
37
37
  } | {
38
38
  deny: string;
39
+ fault?: string;
39
40
  } | null;
40
41
  /**
41
42
  * The declared stage chain after the gate. Every entry states the two properties
@@ -53,9 +54,12 @@ export function rehydrateLayer2(tool: string, toolInput: any, secretsOn?: boolea
53
54
  * @param {NodeJS.ProcessEnv | Record<string, string | undefined>} [env]
54
55
  * @param {boolean} [secretsOn] the run's secret opt-in (see
55
56
  * buildPreToolUseResponse, which decides it once and passes it here)
57
+ * @param {FaultLedger} [ledger] where a fault deny the open posture lets
58
+ * through leaves its warning; required as soon as a stage reports a fault,
59
+ * since a warning with nowhere to go would let the call through silently
56
60
  * @returns {import("./lib/layer-pipeline.mjs").Layer[]}
57
61
  */
58
- export function preToolUseLayers(rehydrate: ((tool: string, toolInput: any) => ReturnType<typeof rehydrateRedacted>) | null, env?: NodeJS.ProcessEnv | Record<string, string | undefined>, secretsOn?: boolean): import("./lib/layer-pipeline.mjs").Layer[];
62
+ export function preToolUseLayers(rehydrate: ((tool: string, toolInput: any) => ReturnType<typeof rehydrateRedacted>) | null, env?: NodeJS.ProcessEnv | Record<string, string | undefined>, secretsOn?: boolean, ledger?: FaultLedger): import("./lib/layer-pipeline.mjs").Layer[];
59
63
  /**
60
64
  * Compose the five stages. Returns the `hookSpecificOutput` fields to emit, or
61
65
  * null for a clean no-op. Throws only if a stage's engine throws; the caller
@@ -79,9 +83,11 @@ export function buildPreToolUseResponse(input: any, rehydrate?: (tool: string, t
79
83
  * ToolCallEvent and returns a Verdict, so a non-Claude host can run the same
80
84
  * sanitization pipeline through its own adapter. The wired Claude CLI below
81
85
  * routes through this judge and renders the Verdict with the Claude adapter; on
82
- * any throw (a control-plane package-load failure included) it falls back to
83
- * hookFailureFields — a native response that needs no package — so the
84
- * caller's fault posture holds even when the adapter never loaded.
86
+ * any throw (a control-plane package-load failure, or an event the adapter
87
+ * could not classify) it falls back to hookFailureFields — a native response
88
+ * that needs no package — so the caller's fault posture holds even when the
89
+ * adapter never loaded. A host calling this directly renders its throws the
90
+ * same way.
85
91
  * @param {import("agent-control-plane-core").ToolCallEvent} event
86
92
  * @param {(tool: string, toolInput: any) => ReturnType<typeof rehydrateRedacted>} [rehydrate]
87
93
  * @param {{
@@ -147,8 +153,8 @@ export function failClosedFields(parsedOk: boolean, err: unknown, opts?: {
147
153
  }): Record<string, unknown>;
148
154
  /**
149
155
  * True when a faulting PreToolUse call is the one case the OPEN posture must
150
- * still not pass: a write-shaped tool whose input carries a redaction
151
- * placeholder, matched by the real grammar (containsPlaceholder) so
156
+ * not pass on the first try: a write-shaped tool whose input carries a
157
+ * redaction placeholder, matched by the real grammar (containsPlaceholder) so
152
158
  * hint-prefixed prose such as `[REDACTED…]` is not mistaken for one. Such a
153
159
  * placeholder stands for a secret the sanitizer redacted out of the model's
154
160
  * view; with the sanitizer down, rehydration cannot translate it back, so
@@ -159,7 +165,7 @@ export function failClosedFields(parsedOk: boolean, err: unknown, opts?: {
159
165
  *
160
166
  * Deliberately NOT exhaustive over every clobber path: Bash can also write a
161
167
  * placeholder to disk (`>`, `tee`, `sed -i`, a heredoc), but command strings
162
- * mention "[REDACTED" benignly far too often for an ask to hold precision
168
+ * mention "[REDACTED" benignly far too often for a refusal to hold precision
163
169
  * there. That is an accepted gap, named in THREAT-MODEL.md's carve-out.
164
170
  * @param {unknown} input raw parsed PreToolUse payload (undefined if unparsed)
165
171
  * @returns {boolean}
@@ -172,8 +178,9 @@ export function hintedWriteFault(input: unknown): boolean;
172
178
  * fail-CLOSED verdict of {@link failClosedFields} when the caller set
173
179
  * AGENT_SANITIZER_FAIL_OPEN=0. The open default has ONE carve-out, declared in
174
180
  * this hook's fault policy below: a write-shaped call whose input carries a
175
- * `[REDACTED…]` placeholder asks instead of passing (see
176
- * {@link hintedWriteFault}) — pass `input` so the policy can see it.
181
+ * `[REDACTED…]` placeholder is refused once, and its exact re-issue proceeds
182
+ * with a warning (see {@link hintedWriteFault}) — pass `input` so the policy
183
+ * can see it.
177
184
  *
178
185
  * The posture covers this hook's own failures, whatever their cause. What it
179
186
  * does NOT cover is the verdict of a sanitizer that ran: a payload
@@ -239,6 +246,17 @@ export const PRE_TOOL_USE_MESSAGES: Readonly<{
239
246
  remedy: string;
240
247
  }>;
241
248
  export const REDACTION_HINT: "[REDACTED";
249
+ /**
250
+ * What the stage table hands back besides the pipeline's own result: the
251
+ * warnings of fault denies the open posture let through (the pipeline drops a
252
+ * stage's note when the input is unchanged, and these calls proceed unchanged),
253
+ * and the re-issue confirmations they rode on, consumed only once the call is
254
+ * known to proceed.
255
+ */
256
+ export type FaultLedger = {
257
+ warnings: string[];
258
+ released: string[];
259
+ };
242
260
  /**
243
261
  * A host-supplied deny gate: given the PreToolUse input, the reason this call
244
262
  * must be blocked, or null to let the pipeline continue. Hosts use these for
@@ -2,8 +2,9 @@
2
2
  * Judge a normalized prompt-submit event. Agent-agnostic: consumes the
3
3
  * control-plane ToolCallEvent and returns a Verdict, so the same prompt gate
4
4
  * renders through any agent adapter, not just Claude's. Throws (into the
5
- * calling hook's catch) when the sanitizer package never loaded, so a prompt it
6
- * cannot classify takes the hook's fault posture rather than a silent ALLOW.
5
+ * calling hook's catch) when the sanitizer package never loaded or the payload
6
+ * is no recognizable event, so a prompt it cannot classify takes the hook's
7
+ * fault posture rather than a silent ALLOW.
7
8
  * @param {import("agent-control-plane-core").ToolCallEvent} event
8
9
  * @param {((s: string) => string) | null} [strip] the ANSI stripper (defaults
9
10
  * to the package's stripAnsiFully; injectable so the fault path is testable)
@@ -28,9 +28,9 @@ export function scanProject(dir?: string): {
28
28
  absent: string[];
29
29
  };
30
30
  /**
31
- * The report for targets the scan could not read. Rendered into the alert the
32
- * PreToolUse gate surfaces, so an incomplete scan reaches the operator as a
33
- * checkpoint rather than as silence.
31
+ * The report for targets the scan could not read: a SessionStart warning under
32
+ * the open posture, and the alert the PreToolUse gate surfaces under the closed
33
+ * one — either way an incomplete scan reaches the operator rather than silence.
34
34
  * @param {Array<{file: string, reason: string}>} skipped
35
35
  * @returns {string}
36
36
  */
@@ -8,6 +8,12 @@
8
8
  * there is nothing to do. Throws only on internal error (the caller fails
9
9
  * closed).
10
10
  *
11
+ * A deny carrying `fault` is not a verdict on the input but this module being
12
+ * unable to do its job (an unreadable target, a redactor map that fails
13
+ * validation): `fault` states what proceeding un-rehydrated would write, and the
14
+ * caller's failure posture decides whether the deny stands. A deny without it
15
+ * is a verdict and stands in every posture.
16
+ *
11
17
  * `io` is the injected I/O (file read + redactor map/plain). `hint` is the
12
18
  * redaction-placeholder prefix (defaults to {@link DEFAULT_HINT}); override it
13
19
  * only if the injected redactor emits a different placeholder shape.
@@ -15,7 +21,7 @@
15
21
  * @param {any} toolInput
16
22
  * @param {RehydrateIo} io
17
23
  * @param {{ hint?: string }} [options]
18
- * @returns {Promise<{updatedInput: any, context: string} | {deny: string} | null>}
24
+ * @returns {Promise<{updatedInput: any, context: string} | {deny: string, fault?: string} | null>}
19
25
  */
20
26
  export function rehydrateRedacted(tool: string, toolInput: any, io: RehydrateIo, { hint }?: {
21
27
  hint?: string;
@@ -24,6 +30,7 @@ export function rehydrateRedacted(tool: string, toolInput: any, io: RehydrateIo,
24
30
  context: string;
25
31
  } | {
26
32
  deny: string;
33
+ fault?: string;
27
34
  } | null>;
28
35
  export const DEFAULT_HINT: "[REDACTED";
29
36
  /**