attenu-guard 0.3.0 → 0.4.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 +62 -0
- package/README.md +8 -2
- package/dist/cjs/adapters/langgraph.d.ts +27 -3
- package/dist/cjs/adapters/langgraph.d.ts.map +1 -1
- package/dist/cjs/adapters/langgraph.js +290 -11
- package/dist/cjs/adapters/langgraph.js.map +1 -1
- package/dist/cjs/audit.d.ts +38 -1
- package/dist/cjs/audit.d.ts.map +1 -1
- package/dist/cjs/audit.js +69 -8
- package/dist/cjs/audit.js.map +1 -1
- package/dist/cjs/canonical.d.ts +19 -0
- package/dist/cjs/canonical.d.ts.map +1 -1
- package/dist/cjs/canonical.js +60 -2
- package/dist/cjs/canonical.js.map +1 -1
- package/dist/cjs/ceilings.d.ts.map +1 -1
- package/dist/cjs/ceilings.js +18 -0
- package/dist/cjs/ceilings.js.map +1 -1
- package/dist/cjs/chain.d.ts +32 -0
- package/dist/cjs/chain.d.ts.map +1 -1
- package/dist/cjs/chain.js +0 -0
- package/dist/cjs/chain.js.map +1 -1
- package/dist/cjs/cli.d.ts.map +1 -1
- package/dist/cjs/cli.js +4 -0
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/evidence.d.ts +41 -2
- package/dist/cjs/evidence.d.ts.map +1 -1
- package/dist/cjs/evidence.js +571 -13
- package/dist/cjs/evidence.js.map +1 -1
- package/dist/cjs/guard.d.ts +163 -9
- package/dist/cjs/guard.d.ts.map +1 -1
- package/dist/cjs/guard.js +426 -26
- package/dist/cjs/guard.js.map +1 -1
- package/dist/cjs/index.d.ts +12 -9
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +24 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/params.d.ts +52 -0
- package/dist/cjs/params.d.ts.map +1 -0
- package/dist/cjs/params.js +97 -0
- package/dist/cjs/params.js.map +1 -0
- package/dist/cjs/reasons.d.ts +89 -1
- package/dist/cjs/reasons.d.ts.map +1 -1
- package/dist/cjs/reasons.js +99 -3
- package/dist/cjs/reasons.js.map +1 -1
- package/dist/cjs/version.d.ts +10 -0
- package/dist/cjs/version.d.ts.map +1 -0
- package/dist/cjs/version.js +13 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/cjs/wire.d.ts.map +1 -1
- package/dist/cjs/wire.js +7 -0
- package/dist/cjs/wire.js.map +1 -1
- package/dist/esm/adapters/langgraph.d.ts +27 -3
- package/dist/esm/adapters/langgraph.d.ts.map +1 -1
- package/dist/esm/adapters/langgraph.js +290 -11
- package/dist/esm/adapters/langgraph.js.map +1 -1
- package/dist/esm/audit.d.ts +38 -1
- package/dist/esm/audit.d.ts.map +1 -1
- package/dist/esm/audit.js +68 -8
- package/dist/esm/audit.js.map +1 -1
- package/dist/esm/canonical.d.ts +19 -0
- package/dist/esm/canonical.d.ts.map +1 -1
- package/dist/esm/canonical.js +58 -1
- package/dist/esm/canonical.js.map +1 -1
- package/dist/esm/ceilings.d.ts.map +1 -1
- package/dist/esm/ceilings.js +19 -1
- package/dist/esm/ceilings.js.map +1 -1
- package/dist/esm/chain.d.ts +32 -0
- package/dist/esm/chain.d.ts.map +1 -1
- package/dist/esm/chain.js +0 -0
- package/dist/esm/chain.js.map +1 -1
- package/dist/esm/cli.d.ts.map +1 -1
- package/dist/esm/cli.js +4 -0
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/evidence.d.ts +41 -2
- package/dist/esm/evidence.d.ts.map +1 -1
- package/dist/esm/evidence.js +570 -12
- package/dist/esm/evidence.js.map +1 -1
- package/dist/esm/guard.d.ts +163 -9
- package/dist/esm/guard.d.ts.map +1 -1
- package/dist/esm/guard.js +393 -27
- package/dist/esm/guard.js.map +1 -1
- package/dist/esm/index.d.ts +12 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/params.d.ts +52 -0
- package/dist/esm/params.d.ts.map +1 -0
- package/dist/esm/params.js +92 -0
- package/dist/esm/params.js.map +1 -0
- package/dist/esm/reasons.d.ts +89 -1
- package/dist/esm/reasons.d.ts.map +1 -1
- package/dist/esm/reasons.js +97 -2
- package/dist/esm/reasons.js.map +1 -1
- package/dist/esm/version.d.ts +10 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +10 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/esm/wire.d.ts.map +1 -1
- package/dist/esm/wire.js +8 -1
- package/dist/esm/wire.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,68 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.0] — 2026-08-31
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **Execution binding**, opt-in per chain via `Guard.issue(agentId, authority, {schemaVersion: 2})`
|
|
13
|
+
(schema version 1 is unchanged and remains the default): `check`/`recordDenial` now allocate a
|
|
14
|
+
`callId` (fail-closed, with meters restored, if `crypto.randomBytes` throws) and return it on
|
|
15
|
+
`Decision.callId`; `check` gains `authorizedParams`/`capture`/`adapter` options and refuses
|
|
16
|
+
further calls once the node is `complete()`d (`ReasonCode.NODE_FINALIZED`).
|
|
17
|
+
`Guard.recordOutcome(callId, bodyState, options)` binds what a body-owning wrapper observed
|
|
18
|
+
afterwards — `returned`/`raised`/`abandoned`/`deferred`, with `errorCode` required exactly when
|
|
19
|
+
raised. `complete()` returns a plain `boolean` on a `schemaVersion: 1` chain (byte-and-type
|
|
20
|
+
unchanged from every prior release) and a `CompletionResult` on `schemaVersion: 2` only — see
|
|
21
|
+
its doc comment for the JavaScript limits of its truthiness bridge, since unlike Python's
|
|
22
|
+
`__bool__`, `if (guard.complete())` cannot be made to read `false` there — and refuses on v2
|
|
23
|
+
while calls are pending; `revoke`/`revokeAgent` snapshot still-pending callIds onto the `kill`
|
|
24
|
+
entry as `pending_at_kill` without clearing them, so a late `recordOutcome` after a kill is
|
|
25
|
+
still accepted. `check`/`recordOutcome` roll back meters and re-throw on ANY pre-commit failure
|
|
26
|
+
(not only a `crypto.randomBytes` failure), and `recordOutcome` marks a call outcomed only after
|
|
27
|
+
its append actually commits, so a pre-commit failure leaves the call retryable. `Guard.issue`
|
|
28
|
+
refuses `{schemaVersion: 2, auditOverwrite: true}` — the restart rule has no escape hatch on v2.
|
|
29
|
+
Arguments are committed via `params_c14n_v1` (`params.ts`): `SHA-256(rawSalt || JCS(params))`,
|
|
30
|
+
never the raw value; validated against the language-neutral vector file also published for
|
|
31
|
+
Python (`test/fixtures/params_c14n_v1.json`). `verifyBundle` gains `execution_binding`: per-call
|
|
32
|
+
observed/unobserved/unaccounted (an outcome must be bound correctly — right node, right order —
|
|
33
|
+
to count as observed), per-node finalized/in_progress/revoked/revoked_with_pending, an aggregate
|
|
34
|
+
clean/incomplete/failed, and `params_coverage` (computed over every valid allow) as its own axis
|
|
35
|
+
— `{status: "not applicable"}` for a schema-version-1 bundle. `verifyBundle` also gains
|
|
36
|
+
`root_version_mismatch`/`mixed_entry_versions` checks (a chain is created at one schema version
|
|
37
|
+
and never mixes), requires exactly one root event (`checks.root`), does strict, null-aware,
|
|
38
|
+
type-checked schema validation on every conditional field (`capture`/`adapter` are now
|
|
39
|
+
REQUIRED, not merely paired, on every v2 allow — a bare `check()` with no `capture` supplied
|
|
40
|
+
gets a truthful guard-attributed `pre_hook_only` default rather than leaving the ledger silent;
|
|
41
|
+
any allow-only field on a `deny`, or any v2-only field on a `schemaVersion: 1` entry
|
|
42
|
+
— `v2_field_on_v1` — is invalid), and accepts an optional `expectedAnchor`/`expectedHead` to
|
|
43
|
+
verify against an independently retained reference point instead of only the bundle's own
|
|
44
|
+
enclosed anchor. `AuditLog` gains `CommittedAuditError` (a
|
|
45
|
+
post-commit persistence failure after the entry is already in the in-memory chain) and
|
|
46
|
+
overwrite protection (constructing over a `path` that already names a non-empty ledger now
|
|
47
|
+
throws unless `overwrite: true`). The LangGraph adapter (`adapters/langgraph`) is the reference
|
|
48
|
+
wiring: `guardNode`/`guardTool` snapshot a call's arguments once, immutably, before invocation
|
|
49
|
+
and call `recordOutcome` on a `schemaVersion: 2` guard, sync and async, reporting a
|
|
50
|
+
generator/promise-like result as `deferred` and an `AbortController`-driven cancellation as
|
|
51
|
+
`abandoned`; wrapping an async callable on a `schemaVersion: 1` guard stays byte-and-type
|
|
52
|
+
unchanged (never itself becomes an async function). Mirrors attenu-guard (Python) 0.9.0's
|
|
53
|
+
execution-binding layer plus its post-review merge-gate hardening, byte-for-byte on every
|
|
54
|
+
reason-code string; ported test suite: `test/execution-binding.test.ts` (82 cases),
|
|
55
|
+
`test/params-c14n-vectors.test.ts` (the shared parity vectors), plus adapter and evidence
|
|
56
|
+
coverage in `test/adapter-langgraph.test.ts`/`test/evidence.test.ts`.
|
|
57
|
+
|
|
58
|
+
## [0.3.1] — 2026-08-30
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
- Integers beyond the RFC 8785 safe range (±(2**53-1)) are now rejected — at canonicalization, at
|
|
62
|
+
`RowLimit`/`SpendCap`/`CallLimit` construction, and by `load` (as `malformed`) — instead of
|
|
63
|
+
silently colliding with a neighbouring integer once serialized as a double. The interop suite
|
|
64
|
+
will show 20 vectors, and `valid_jcs_big_integer`/`valid_jcs_exponent_form` will pin different
|
|
65
|
+
values, once the Python package ships them; until then the affected interop assertions are a
|
|
66
|
+
known, expected failure (see the README note on `npm run fixtures`).
|
|
67
|
+
- `verifyBundle` and `AuditLog.verifyAnchor` now check the bundle/anchor schema version and chain
|
|
68
|
+
identity instead of ignoring them, so a bundle for the wrong version or the wrong chain no
|
|
69
|
+
longer verifies.
|
|
70
|
+
|
|
9
71
|
## [0.3.0] — 2026-08-29
|
|
10
72
|
|
|
11
73
|
### Changed
|
package/README.md
CHANGED
|
@@ -66,6 +66,12 @@ run; the anchor is reported as `not checked`, and `ok` then means *consistent*
|
|
|
66
66
|
rather than *verified* — a consistent full rewrite by someone holding the signing
|
|
67
67
|
key cannot be excluded without the key.
|
|
68
68
|
|
|
69
|
+
> **Want to try this before wiring it in?** The repo ships a sample: from a clone,
|
|
70
|
+
> `npx attenu-guard@latest verify test/fixtures/clean_ed25519.bundle.json --pubkey d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a`
|
|
71
|
+
> prints the same `anchor=verified` / `OK` result shown above. For the three-bundle
|
|
72
|
+
> version — clean, tampered, widened, each a different kind of failure — see the
|
|
73
|
+
> [Python library's walkthrough](https://github.com/attenu-io/attenu-guard/blob/main/examples/verify/README.md).
|
|
74
|
+
|
|
69
75
|
## Guard a delegation chain
|
|
70
76
|
|
|
71
77
|
```ts
|
|
@@ -159,7 +165,7 @@ ledger, and one bundle per tamper mode with the report Python produces for each.
|
|
|
159
165
|
The suite reproduces all of it, and a separate test writes a ledger and bundle
|
|
160
166
|
here and has the Python CLI verify them, so both directions are covered.
|
|
161
167
|
|
|
162
|
-
|
|
168
|
+
Versions 0.2 and later use [RFC 8785 JCS](https://www.rfc-editor.org/rfc/rfc8785) for every
|
|
163
169
|
signed or hashed JSON surface: Delegation Tokens, ledger entries, anchors and
|
|
164
170
|
evidence bundles. Tokens, ledger entries, anchors and bundles emit
|
|
165
171
|
`"c14n":"JCS"` as an informational label. Verifiers enforce JCS from canonical
|
|
@@ -168,7 +174,7 @@ numbers, lone UTF-16 surrogates and non-canonical spellings are rejected instead
|
|
|
168
174
|
of being normalized after verification.
|
|
169
175
|
|
|
170
176
|
This is the only supported format. There is no 0.1 compatibility reader or
|
|
171
|
-
dual-signing mode. The
|
|
177
|
+
dual-signing mode. The 19 committed interop vectors include the separating cases
|
|
172
178
|
for number spelling, raw Unicode, UTF-16 member ordering, large integers,
|
|
173
179
|
duplicates, non-finite values and an unmarked canonical header.
|
|
174
180
|
|
|
@@ -35,6 +35,22 @@
|
|
|
35
35
|
* this adapter does not prescribe which. It guarantees only that the tool body
|
|
36
36
|
* never executes on a denial.
|
|
37
37
|
*
|
|
38
|
+
* ## Execution binding (0.9.0, reference wiring for this adapter)
|
|
39
|
+
*
|
|
40
|
+
* When `guard`'s chain was issued with `schemaVersion: 2` (see `Guard.issue`), `guardNode` also
|
|
41
|
+
* passes `capture`/`adapter`/`authorizedParams` to `check` and calls `guard.recordOutcome` once
|
|
42
|
+
* the wrapped callable finishes — `Capture.WRAPPER_ASYNC` when `fn` is a genuine `async function`
|
|
43
|
+
* (`fn.constructor.name === "AsyncFunction"`, the same test Python's `inspect.iscoroutinefunction`
|
|
44
|
+
* makes), `Capture.WRAPPER_SYNC` otherwise. `authorizedParams`/`invokedParams` are
|
|
45
|
+
* `{args: [...]}` built from exactly what the wrapped callable is called with — JavaScript has no
|
|
46
|
+
* separate `kwargs`, so unlike the Python adapter's `{args, kwargs}` this carries only `args`; a
|
|
47
|
+
* LangGraph.js node in any case receives one state object, not Python's `(*args, **kwargs)`. They
|
|
48
|
+
* are unchanged between the two observations here, since this decorator itself never mutates
|
|
49
|
+
* them; a framework that DOES mutate arguments between authorization and invocation is where a
|
|
50
|
+
* real substitution would become visible. On a `schemaVersion: 1` chain (the default), this
|
|
51
|
+
* adapter behaves exactly as it did before 0.9.0: no `capture`/`authorizedParams`, no
|
|
52
|
+
* `recordOutcome` call. Every other framework adapter is unchanged in this release.
|
|
53
|
+
*
|
|
38
54
|
* ## Delegation
|
|
39
55
|
*
|
|
40
56
|
* Handing work to a sub-agent is the delegation moment. `delegateTo` mints the
|
|
@@ -52,7 +68,7 @@
|
|
|
52
68
|
import { type Guard } from "../guard.js";
|
|
53
69
|
import type { Authority } from "../authority.js";
|
|
54
70
|
import type { Context } from "../ceilings.js";
|
|
55
|
-
import type
|
|
71
|
+
import { type Decision } from "../reasons.js";
|
|
56
72
|
/** Options shared by every guarded wrapper. */
|
|
57
73
|
export interface GuardOptions {
|
|
58
74
|
/**
|
|
@@ -81,7 +97,9 @@ export type GuardedNode<F extends (...args: any[]) => any> = F & {
|
|
|
81
97
|
* `guard.check(toolScope, {context, tool})`. On a denial this throws
|
|
82
98
|
* `AuthorityDenied` and the wrapped callable is NEVER invoked. Otherwise it
|
|
83
99
|
* calls through with the original arguments and returns the result unchanged —
|
|
84
|
-
* including a promise, which is passed along untouched.
|
|
100
|
+
* including a promise, which is passed along untouched. On a `schemaVersion: 2`
|
|
101
|
+
* guard, also binds the call's outcome via `guard.recordOutcome` — see the
|
|
102
|
+
* module doc comment's "Execution binding" section.
|
|
85
103
|
*
|
|
86
104
|
* Use the Guard for the SPECIFIC agent this callable belongs to, not the
|
|
87
105
|
* orchestrator's broader one, so a denial reflects that node's real, narrowed
|
|
@@ -125,7 +143,13 @@ export interface GuardToolOptions extends GuardOptions {
|
|
|
125
143
|
* The context function receives the raw invoke arguments. `ToolNode` passes a
|
|
126
144
|
* tool call object, so the arguments the model proposed are at `input.args`;
|
|
127
145
|
* a direct `tool.invoke({...})` passes them at the top level. `toolArgs` below
|
|
128
|
-
* reads either shape
|
|
146
|
+
* reads either shape — and, on a `schemaVersion: 2` guard, feeds a single
|
|
147
|
+
* IMMUTABLE snapshot taken BEFORE `tool.invoke` runs, reused for both
|
|
148
|
+
* `authorizedParams` and `invokedParams`: this adapter's closest analogue of "the
|
|
149
|
+
* exact tool-call JSON object" the execution-binding spec names (see the module
|
|
150
|
+
* doc comment's "Execution binding" section; this is the one construct in this
|
|
151
|
+
* adapter that wraps a tool BODY, so it is the reference wiring for
|
|
152
|
+
* `recordOutcome`, mirroring `guardNode` above).
|
|
129
153
|
*/
|
|
130
154
|
export declare function guardTool<T extends ToolLike>(guard: Guard, tool: T, options?: GuardToolOptions): T;
|
|
131
155
|
/** Marker properties, so a caller can tell a guarded tool from a bare one. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langgraph.d.ts","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"langgraph.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EAAE,MAAM,CAAC,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CACpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAC3C,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,GAAE,iBAAsB,GAC9B,CAAC,EAAE,CAUL;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAMxD;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,GAAG,KAAK,CAEzE;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAQ7D"}
|
|
@@ -36,6 +36,22 @@
|
|
|
36
36
|
* this adapter does not prescribe which. It guarantees only that the tool body
|
|
37
37
|
* never executes on a denial.
|
|
38
38
|
*
|
|
39
|
+
* ## Execution binding (0.9.0, reference wiring for this adapter)
|
|
40
|
+
*
|
|
41
|
+
* When `guard`'s chain was issued with `schemaVersion: 2` (see `Guard.issue`), `guardNode` also
|
|
42
|
+
* passes `capture`/`adapter`/`authorizedParams` to `check` and calls `guard.recordOutcome` once
|
|
43
|
+
* the wrapped callable finishes — `Capture.WRAPPER_ASYNC` when `fn` is a genuine `async function`
|
|
44
|
+
* (`fn.constructor.name === "AsyncFunction"`, the same test Python's `inspect.iscoroutinefunction`
|
|
45
|
+
* makes), `Capture.WRAPPER_SYNC` otherwise. `authorizedParams`/`invokedParams` are
|
|
46
|
+
* `{args: [...]}` built from exactly what the wrapped callable is called with — JavaScript has no
|
|
47
|
+
* separate `kwargs`, so unlike the Python adapter's `{args, kwargs}` this carries only `args`; a
|
|
48
|
+
* LangGraph.js node in any case receives one state object, not Python's `(*args, **kwargs)`. They
|
|
49
|
+
* are unchanged between the two observations here, since this decorator itself never mutates
|
|
50
|
+
* them; a framework that DOES mutate arguments between authorization and invocation is where a
|
|
51
|
+
* real substitution would become visible. On a `schemaVersion: 1` chain (the default), this
|
|
52
|
+
* adapter behaves exactly as it did before 0.9.0: no `capture`/`authorizedParams`, no
|
|
53
|
+
* `recordOutcome` call. Every other framework adapter is unchanged in this release.
|
|
54
|
+
*
|
|
39
55
|
* ## Delegation
|
|
40
56
|
*
|
|
41
57
|
* Handing work to a sub-agent is the delegation moment. `delegateTo` mints the
|
|
@@ -93,6 +109,71 @@ exports.toolArgs = toolArgs;
|
|
|
93
109
|
exports.delegateTo = delegateTo;
|
|
94
110
|
exports.isLangGraphAvailable = isLangGraphAvailable;
|
|
95
111
|
const guard_js_1 = require("../guard.js");
|
|
112
|
+
const reasons_js_1 = require("../reasons.js");
|
|
113
|
+
const version_js_1 = require("../version.js");
|
|
114
|
+
/**
|
|
115
|
+
* An IMMUTABLE snapshot of the call's arguments, taken BEFORE the wrapped callable runs and
|
|
116
|
+
* reused for BOTH `authorizedParams` (`check`) and `invokedParams` (`recordOutcome`) — so a
|
|
117
|
+
* callable that mutates its own inputs in place cannot make this adapter observe two different
|
|
118
|
+
* values for what was actually one call's arguments (see the module doc comment's "Execution
|
|
119
|
+
* binding" section; no `kwargs` — JavaScript has no separate keyword-argument bag).
|
|
120
|
+
*/
|
|
121
|
+
function snapshotParams(args) {
|
|
122
|
+
const raw = { args: [...args] };
|
|
123
|
+
try {
|
|
124
|
+
return structuredClone(raw);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// Best-effort: something in here isn't structured-cloneable (a live socket, a function, ...).
|
|
128
|
+
// Fall back to the shallow copy — a residual risk only if THAT specific object is later
|
|
129
|
+
// mutated in place, a rare edge case documented here rather than silently claimed away.
|
|
130
|
+
return raw;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* `true` if `result` is a generator/async-generator/promise-like value whose consumption this
|
|
135
|
+
* wrapper does not itself observe — spec's `deferred`: "the record covers the call, not the
|
|
136
|
+
* eventual exhaustion." A promise counts too (the closest JavaScript analogue of Python's
|
|
137
|
+
* `asyncio.Future`/`concurrent.futures.Future`): the async branch here already `await`s `fn`
|
|
138
|
+
* itself, so a bare promise surfacing as `result` there means `fn` returned ANOTHER promise
|
|
139
|
+
* without awaiting it, which is exactly the same "not actually consumed" situation.
|
|
140
|
+
*/
|
|
141
|
+
function isDeferredResult(result) {
|
|
142
|
+
if (result === null || typeof result !== "object")
|
|
143
|
+
return false;
|
|
144
|
+
const r = result;
|
|
145
|
+
if (typeof r["next"] === "function" && typeof r[Symbol.iterator] === "function")
|
|
146
|
+
return true;
|
|
147
|
+
if (typeof r["next"] === "function" && typeof r[Symbol.asyncIterator] === "function")
|
|
148
|
+
return true;
|
|
149
|
+
if (typeof r["then"] === "function")
|
|
150
|
+
return true;
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
function bodyStateFor(result) {
|
|
154
|
+
return isDeferredResult(result) ? reasons_js_1.BodyState.DEFERRED : reasons_js_1.BodyState.RETURNED;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* `true` for the JavaScript analogue of Python's `asyncio.CancelledError`: an `AbortController`/
|
|
158
|
+
* `AbortSignal`-driven abort, surfaced as a `DOMException`/`Error` named `"AbortError"` — the
|
|
159
|
+
* standard shape Node and the Fetch/Web platform both use. There is no single universal async
|
|
160
|
+
* cancellation exception type in JavaScript the way `asyncio.CancelledError` is in Python, so this
|
|
161
|
+
* is the best-grounded, most widely applicable translation rather than a exact 1:1 port.
|
|
162
|
+
*/
|
|
163
|
+
function isAbortError(exc) {
|
|
164
|
+
return exc instanceof Error && exc.name === "AbortError";
|
|
165
|
+
}
|
|
166
|
+
/** The class/constructor name of a thrown value — JavaScript's nearest analogue of Python's `type(exc).__name__`. */
|
|
167
|
+
function errorCodeOf(exc) {
|
|
168
|
+
if (exc instanceof Error)
|
|
169
|
+
return exc.constructor.name || "Error";
|
|
170
|
+
if (exc === null)
|
|
171
|
+
return "null";
|
|
172
|
+
return typeof exc === "object" ? "object" : typeof exc;
|
|
173
|
+
}
|
|
174
|
+
function elapsedMs(start) {
|
|
175
|
+
return Math.round(performance.now() - start);
|
|
176
|
+
}
|
|
96
177
|
/**
|
|
97
178
|
* Wrap a callable so every call is authorized through `guard` first.
|
|
98
179
|
*
|
|
@@ -100,7 +181,9 @@ const guard_js_1 = require("../guard.js");
|
|
|
100
181
|
* `guard.check(toolScope, {context, tool})`. On a denial this throws
|
|
101
182
|
* `AuthorityDenied` and the wrapped callable is NEVER invoked. Otherwise it
|
|
102
183
|
* calls through with the original arguments and returns the result unchanged —
|
|
103
|
-
* including a promise, which is passed along untouched.
|
|
184
|
+
* including a promise, which is passed along untouched. On a `schemaVersion: 2`
|
|
185
|
+
* guard, also binds the call's outcome via `guard.recordOutcome` — see the
|
|
186
|
+
* module doc comment's "Execution binding" section.
|
|
104
187
|
*
|
|
105
188
|
* Use the Guard for the SPECIFIC agent this callable belongs to, not the
|
|
106
189
|
* orchestrator's broader one, so a denial reflects that node's real, narrowed
|
|
@@ -108,18 +191,102 @@ const guard_js_1 = require("../guard.js");
|
|
|
108
191
|
*/
|
|
109
192
|
function guardNode(guard, toolScope, fn, options = {}) {
|
|
110
193
|
const resolvedTool = options.tool !== undefined ? options.tool : (fn.name || null);
|
|
111
|
-
const
|
|
194
|
+
const isAsyncFn = fn.constructor.name === "AsyncFunction";
|
|
195
|
+
// guard.schemaVersion never changes for a guard's lifetime, so it is safe (and correct: a
|
|
196
|
+
// wrapper's sync-vs-async SHAPE must be fixed at definition time, not per-call) to decide it
|
|
197
|
+
// once, here, at decoration time.
|
|
198
|
+
const v2 = guard.schemaVersion === 2;
|
|
199
|
+
const capture = isAsyncFn ? reasons_js_1.Capture.WRAPPER_ASYNC : reasons_js_1.Capture.WRAPPER_SYNC;
|
|
200
|
+
const adapterInfo = {
|
|
201
|
+
module: "attenu-guard/adapters/langgraph",
|
|
202
|
+
version: version_js_1.VERSION,
|
|
203
|
+
hookPath: `guardNode:${fn.name || toolScope}`,
|
|
204
|
+
};
|
|
205
|
+
function authorize(args, snapshot) {
|
|
112
206
|
const context = options.contextFn ? options.contextFn(...args) : {};
|
|
207
|
+
const extra = v2 ? { capture, adapter: adapterInfo, authorizedParams: snapshot ?? undefined } : {};
|
|
113
208
|
const decision = guard.check(toolScope, {
|
|
114
209
|
context,
|
|
115
210
|
tool: resolvedTool,
|
|
116
211
|
disposition: options.disposition ?? null,
|
|
117
212
|
metered: options.metered ?? false,
|
|
213
|
+
...extra,
|
|
118
214
|
});
|
|
119
215
|
if (!decision.allowed)
|
|
120
216
|
throw new guard_js_1.AuthorityDenied(decision);
|
|
121
|
-
return
|
|
122
|
-
}
|
|
217
|
+
return decision;
|
|
218
|
+
}
|
|
219
|
+
let wrapped;
|
|
220
|
+
if (isAsyncFn && v2) {
|
|
221
|
+
wrapped = (async function (...args) {
|
|
222
|
+
const snapshot = snapshotParams(args);
|
|
223
|
+
const decision = authorize(args, snapshot);
|
|
224
|
+
const start = performance.now();
|
|
225
|
+
try {
|
|
226
|
+
const result = await fn.apply(this, args);
|
|
227
|
+
guard.recordOutcome(decision.callId, bodyStateFor(result), {
|
|
228
|
+
invokedParams: snapshot,
|
|
229
|
+
durationMs: elapsedMs(start),
|
|
230
|
+
});
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
catch (exc) {
|
|
234
|
+
// The wrapper stopped observing while the body may still run — exactly spec's
|
|
235
|
+
// `abandoned`, not `raised`. Still re-thrown: cancellation must propagate normally.
|
|
236
|
+
if (isAbortError(exc)) {
|
|
237
|
+
guard.recordOutcome(decision.callId, reasons_js_1.BodyState.ABANDONED, {
|
|
238
|
+
invokedParams: snapshot,
|
|
239
|
+
durationMs: elapsedMs(start),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
guard.recordOutcome(decision.callId, reasons_js_1.BodyState.RAISED, {
|
|
244
|
+
errorCode: errorCodeOf(exc),
|
|
245
|
+
invokedParams: snapshot,
|
|
246
|
+
durationMs: elapsedMs(start),
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
throw exc;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
else if (isAsyncFn) {
|
|
254
|
+
// v1 (schemaVersion: 1, the default): EXACTLY the pre-0.9.0 shape — a plain SYNC wrapper
|
|
255
|
+
// that authorizes, then returns fn(...args) UNAWAITED. The caller awaits the returned
|
|
256
|
+
// promise itself, as it always has; `wrapped` is never itself an async function on v1, even
|
|
257
|
+
// when `fn` is.
|
|
258
|
+
wrapped = (function (...args) {
|
|
259
|
+
authorize(args, null);
|
|
260
|
+
return fn.apply(this, args);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
wrapped = (function (...args) {
|
|
265
|
+
if (!v2) {
|
|
266
|
+
authorize(args, null);
|
|
267
|
+
return fn.apply(this, args);
|
|
268
|
+
}
|
|
269
|
+
const snapshot = snapshotParams(args);
|
|
270
|
+
const decision = authorize(args, snapshot);
|
|
271
|
+
const start = performance.now();
|
|
272
|
+
try {
|
|
273
|
+
const result = fn.apply(this, args);
|
|
274
|
+
guard.recordOutcome(decision.callId, bodyStateFor(result), {
|
|
275
|
+
invokedParams: snapshot,
|
|
276
|
+
durationMs: elapsedMs(start),
|
|
277
|
+
});
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
catch (exc) {
|
|
281
|
+
guard.recordOutcome(decision.callId, reasons_js_1.BodyState.RAISED, {
|
|
282
|
+
errorCode: errorCodeOf(exc),
|
|
283
|
+
invokedParams: snapshot,
|
|
284
|
+
durationMs: elapsedMs(start),
|
|
285
|
+
});
|
|
286
|
+
throw exc;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
123
290
|
Object.defineProperties(wrapped, {
|
|
124
291
|
name: { value: fn.name, configurable: true },
|
|
125
292
|
guard: { value: guard, enumerable: true },
|
|
@@ -149,26 +316,138 @@ function addGuardedNode(graph, name, guard, toolScope, fn, options = {}) {
|
|
|
149
316
|
* The context function receives the raw invoke arguments. `ToolNode` passes a
|
|
150
317
|
* tool call object, so the arguments the model proposed are at `input.args`;
|
|
151
318
|
* a direct `tool.invoke({...})` passes them at the top level. `toolArgs` below
|
|
152
|
-
* reads either shape
|
|
319
|
+
* reads either shape — and, on a `schemaVersion: 2` guard, feeds a single
|
|
320
|
+
* IMMUTABLE snapshot taken BEFORE `tool.invoke` runs, reused for both
|
|
321
|
+
* `authorizedParams` and `invokedParams`: this adapter's closest analogue of "the
|
|
322
|
+
* exact tool-call JSON object" the execution-binding spec names (see the module
|
|
323
|
+
* doc comment's "Execution binding" section; this is the one construct in this
|
|
324
|
+
* adapter that wraps a tool BODY, so it is the reference wiring for
|
|
325
|
+
* `recordOutcome`, mirroring `guardNode` above).
|
|
153
326
|
*/
|
|
154
327
|
function guardTool(guard, tool, options = {}) {
|
|
155
328
|
const scope = options.scope ?? tool.name;
|
|
156
329
|
const label = options.tool !== undefined ? options.tool : tool.name;
|
|
157
|
-
const
|
|
330
|
+
const isAsyncInvoke = tool.invoke.constructor.name === "AsyncFunction";
|
|
331
|
+
// guard.schemaVersion never changes for a guard's lifetime — decided once, at wrap time, same
|
|
332
|
+
// as guardNode.
|
|
333
|
+
const v2 = guard.schemaVersion === 2;
|
|
334
|
+
const capture = isAsyncInvoke ? reasons_js_1.Capture.WRAPPER_ASYNC : reasons_js_1.Capture.WRAPPER_SYNC;
|
|
335
|
+
const adapterInfo = {
|
|
336
|
+
module: "attenu-guard/adapters/langgraph",
|
|
337
|
+
version: version_js_1.VERSION,
|
|
338
|
+
hookPath: `guardTool:${tool.name}`,
|
|
339
|
+
};
|
|
340
|
+
function snapshotToolParams(input) {
|
|
341
|
+
const raw = toolArgs(input);
|
|
342
|
+
try {
|
|
343
|
+
return structuredClone(raw);
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return raw;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function authorize(input, config, snapshot) {
|
|
158
350
|
const context = options.contextFn ? options.contextFn(input, config) : {};
|
|
351
|
+
const extra = v2 ? { capture, adapter: adapterInfo, authorizedParams: snapshot ?? undefined } : {};
|
|
159
352
|
const decision = guard.check(scope, {
|
|
160
353
|
context,
|
|
161
354
|
tool: label,
|
|
162
355
|
disposition: options.disposition ?? null,
|
|
163
356
|
metered: options.metered ?? false,
|
|
357
|
+
...extra,
|
|
164
358
|
});
|
|
165
|
-
if (!decision.allowed)
|
|
166
|
-
if (options.onDenied)
|
|
167
|
-
return options.onDenied(decision, input);
|
|
359
|
+
if (!decision.allowed)
|
|
168
360
|
throw new guard_js_1.AuthorityDenied(decision);
|
|
361
|
+
return decision;
|
|
362
|
+
}
|
|
363
|
+
/** `authorize`, but returns `{denied: ...}` instead of throwing when `onDenied` is set. */
|
|
364
|
+
function authorizeOrDenied(input, config, snapshot) {
|
|
365
|
+
try {
|
|
366
|
+
return { decision: authorize(input, config, snapshot) };
|
|
169
367
|
}
|
|
170
|
-
|
|
171
|
-
|
|
368
|
+
catch (exc) {
|
|
369
|
+
if (exc instanceof guard_js_1.AuthorityDenied && options.onDenied) {
|
|
370
|
+
return { denied: options.onDenied(exc.decision, input) };
|
|
371
|
+
}
|
|
372
|
+
throw exc;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
let guardedInvoke;
|
|
376
|
+
if (isAsyncInvoke && v2) {
|
|
377
|
+
guardedInvoke = async (input, config) => {
|
|
378
|
+
const snapshot = snapshotToolParams(input);
|
|
379
|
+
const outcome = authorizeOrDenied(input, config, snapshot);
|
|
380
|
+
if ("denied" in outcome)
|
|
381
|
+
return outcome.denied;
|
|
382
|
+
const start = performance.now();
|
|
383
|
+
try {
|
|
384
|
+
const result = await tool.invoke(input, config);
|
|
385
|
+
guard.recordOutcome(outcome.decision.callId, bodyStateFor(result), {
|
|
386
|
+
invokedParams: snapshot,
|
|
387
|
+
durationMs: elapsedMs(start),
|
|
388
|
+
});
|
|
389
|
+
return result;
|
|
390
|
+
}
|
|
391
|
+
catch (exc) {
|
|
392
|
+
if (isAbortError(exc)) {
|
|
393
|
+
guard.recordOutcome(outcome.decision.callId, reasons_js_1.BodyState.ABANDONED, {
|
|
394
|
+
invokedParams: snapshot,
|
|
395
|
+
durationMs: elapsedMs(start),
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
guard.recordOutcome(outcome.decision.callId, reasons_js_1.BodyState.RAISED, {
|
|
400
|
+
errorCode: errorCodeOf(exc),
|
|
401
|
+
invokedParams: snapshot,
|
|
402
|
+
durationMs: elapsedMs(start),
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
throw exc;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
else if (isAsyncInvoke) {
|
|
410
|
+
// v1: EXACTLY the pre-0.9.0 shape — a plain SYNC function that authorizes, then returns
|
|
411
|
+
// tool.invoke(...) UNAWAITED (the caller — typically ToolNode's own `await` — consumes the
|
|
412
|
+
// returned promise itself, as it always has).
|
|
413
|
+
guardedInvoke = (input, config) => {
|
|
414
|
+
const outcome = authorizeOrDenied(input, config, null);
|
|
415
|
+
if ("denied" in outcome)
|
|
416
|
+
return outcome.denied;
|
|
417
|
+
return tool.invoke(input, config);
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
guardedInvoke = (input, config) => {
|
|
422
|
+
if (!v2) {
|
|
423
|
+
const outcome = authorizeOrDenied(input, config, null);
|
|
424
|
+
if ("denied" in outcome)
|
|
425
|
+
return outcome.denied;
|
|
426
|
+
return tool.invoke(input, config);
|
|
427
|
+
}
|
|
428
|
+
const snapshot = snapshotToolParams(input);
|
|
429
|
+
const outcome = authorizeOrDenied(input, config, snapshot);
|
|
430
|
+
if ("denied" in outcome)
|
|
431
|
+
return outcome.denied;
|
|
432
|
+
const start = performance.now();
|
|
433
|
+
try {
|
|
434
|
+
const result = tool.invoke(input, config);
|
|
435
|
+
guard.recordOutcome(outcome.decision.callId, bodyStateFor(result), {
|
|
436
|
+
invokedParams: snapshot,
|
|
437
|
+
durationMs: elapsedMs(start),
|
|
438
|
+
});
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
441
|
+
catch (exc) {
|
|
442
|
+
guard.recordOutcome(outcome.decision.callId, reasons_js_1.BodyState.RAISED, {
|
|
443
|
+
errorCode: errorCodeOf(exc),
|
|
444
|
+
invokedParams: snapshot,
|
|
445
|
+
durationMs: elapsedMs(start),
|
|
446
|
+
});
|
|
447
|
+
throw exc;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
172
451
|
return new Proxy(tool, {
|
|
173
452
|
get(target, prop, receiver) {
|
|
174
453
|
if (prop === "invoke")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langgraph.js","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CH,8BA2BC;AAcD,wCAWC;AA+BD,8BAgCC;AAkBD,gCAcC;AAOD,4BAMC;AAkBD,gCAEC;AAOD,oDAQC;AA5OD,0CAA0D;AA4B1D;;;;;;;;;;;;GAYG;AACH,SAAgB,SAAS,CACvB,KAAY,EACZ,SAAiB,EAC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AAU;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5F,MAAM,IAAI,GAAI,KAA2B,CAAC,IAAI,CAAC;QAC/C,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,IAA2B,CAAC;IACpF,CAAC;IACD,OAAO,CAAC,KAAK,IAAI,EAAE,CAAwB,CAAC;AAC9C,CAAC;AAQD;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAC,MAAa,EAAE,OAAwB;IAChE,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,oBAAoB;IACxC,MAAM,SAAS,GAAG,sBAAsB,CAAC;IACzC,IAAI,CAAC;QACH,yBAAa,SAAS,uCAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/cjs/audit.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* identical content — see `canonical.ts` for how that is guaranteed.
|
|
12
12
|
*/
|
|
13
13
|
import { type CJson } from "./canonical.js";
|
|
14
|
+
import type { Decision } from "./reasons.js";
|
|
14
15
|
import type { Signer } from "./wire.js";
|
|
15
16
|
export declare const SCHEMA_VERSION = 1;
|
|
16
17
|
export declare const GENESIS: string;
|
|
@@ -36,16 +37,52 @@ export interface Anchor {
|
|
|
36
37
|
}
|
|
37
38
|
/** `sha256(prev_hash || canonical(event-without-hash))`, as hex. */
|
|
38
39
|
export declare function hashEntry(prevHash: string, payload: LedgerEntry): string;
|
|
40
|
+
/**
|
|
41
|
+
* Thrown by `AuditLog.append` when the entry was committed to the in-memory chain but persisting
|
|
42
|
+
* it afterward (the audit-path file write, or a sink) threw.
|
|
43
|
+
*
|
|
44
|
+
* The entry IS committed — it is in `.entries`/`.head()` and every later `hash`/`prev_hash` is
|
|
45
|
+
* computed on top of it. Callers must not retry the operation that produced this entry merely
|
|
46
|
+
* because this was thrown: retrying would record it a second time. The original error is chained
|
|
47
|
+
* as `.cause` (the standard `Error` cause, same as Python's `__cause__`).
|
|
48
|
+
*/
|
|
49
|
+
export declare class CommittedAuditError extends Error {
|
|
50
|
+
readonly entry: LedgerEntry;
|
|
51
|
+
/**
|
|
52
|
+
* Set by `Guard.check`/`Guard.recordDenial` before this propagates out of them (0.9.0
|
|
53
|
+
* execution binding — spec section 1: "carries the committed entry and the decision"). Absent
|
|
54
|
+
* for a `CommittedAuditError` raised by an `AuditLog` used directly, without a `Guard`.
|
|
55
|
+
*/
|
|
56
|
+
decision?: Decision;
|
|
57
|
+
constructor(entry: LedgerEntry, cause: unknown);
|
|
58
|
+
}
|
|
39
59
|
export interface AuditLogInit {
|
|
40
60
|
/** Where to append the `.jsonl` ledger. Omit for an in-memory log. */
|
|
41
61
|
path?: string | null;
|
|
42
62
|
/** Local sinks; each gets every entry after the file write. */
|
|
43
63
|
sinks?: readonly Sink[];
|
|
64
|
+
/**
|
|
65
|
+
* 0.9.0: the schema version this WHOLE chain is created at (1, the default and unchanged
|
|
66
|
+
* behaviour, or 2 — execution binding). Stated once, on `v` of every entry (see
|
|
67
|
+
* `Guard.issue({schemaVersion})`); a chain never mixes schema versions.
|
|
68
|
+
*/
|
|
69
|
+
schemaVersion?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Allow constructing over a `path` that already names a non-empty file, replacing it. Default
|
|
72
|
+
* `false`: refuse (`Error`) rather than silently truncate a pre-existing ledger.
|
|
73
|
+
*/
|
|
74
|
+
overwrite?: boolean;
|
|
44
75
|
}
|
|
45
76
|
/** Append-only, hash-chained decision log. */
|
|
46
77
|
export declare class AuditLog {
|
|
47
78
|
readonly path: string | null;
|
|
48
|
-
|
|
79
|
+
readonly schemaVersion: number;
|
|
80
|
+
/**
|
|
81
|
+
* Local sinks; each gets every entry after the file write. Public and mutable (not just
|
|
82
|
+
* constructor-supplied) so a caller — or a test simulating a post-commit persistence failure —
|
|
83
|
+
* can swap them in after construction.
|
|
84
|
+
*/
|
|
85
|
+
sinks: readonly Sink[];
|
|
49
86
|
private prev;
|
|
50
87
|
private seq;
|
|
51
88
|
private readonly _entries;
|
package/dist/cjs/audit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,OAAO,QAAiB,CAAC;AAEtC,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD,0EAA0E;AAC1E,MAAM,WAAW,IAAI;IACnB,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CACjC;AAED,oDAAoD;AACpD,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,K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