@axtary/ledger 0.0.1 → 0.2.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/LICENSE +202 -0
- package/README.md +82 -3
- package/dist/behavior.d.ts +81 -0
- package/dist/behavior.d.ts.map +1 -0
- package/dist/behavior.js +0 -0
- package/dist/behavior.js.map +1 -0
- package/dist/forensics.d.ts +52 -0
- package/dist/forensics.d.ts.map +1 -0
- package/dist/forensics.js +249 -0
- package/dist/forensics.js.map +1 -0
- package/dist/index.d.ts +663 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +928 -29
- package/dist/index.js.map +1 -1
- package/dist/merkle.d.ts +42 -0
- package/dist/merkle.d.ts.map +1 -0
- package/dist/merkle.js +213 -0
- package/dist/merkle.js.map +1 -0
- package/package.json +6 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -2,29 +2,106 @@
|
|
|
2
2
|
|
|
3
3
|
Append-only JSONL action ledger with hash-chain verification for Axtary.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Early `0.x` release: the runtime path is real and tested, but the API is not stable yet and may change between minor versions.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @axtary/ledger
|
|
9
|
+
```
|
|
6
10
|
|
|
7
11
|
## What It Does
|
|
8
12
|
|
|
9
13
|
- Appends Axtary ledger records to local JSONL.
|
|
14
|
+
- Serializes concurrent processes with an inter-process lease lock.
|
|
15
|
+
- Appends in place and synchronizes the file plus directory metadata before
|
|
16
|
+
returning success; prior ledger bytes are never rewritten.
|
|
17
|
+
- Maintains a private O(1) head checkpoint and reconstructs it from the
|
|
18
|
+
verified JSONL chain after a crash or legacy-file migration.
|
|
10
19
|
- Maintains a `previousLedgerHash -> ledgerHash` chain.
|
|
11
20
|
- Reads ledger records back in order.
|
|
12
21
|
- Verifies hash-chain continuity and record integrity.
|
|
13
22
|
- Exports verified records by inclusive date range and decision type.
|
|
23
|
+
- Emits a detached signed attestation over an export, and an RFC 6962
|
|
24
|
+
transparency-log signed tree head (`merkleRoot`/`treeSize`) with inclusion and
|
|
25
|
+
consistency proofs (`proveLedgerInclusion`/`proveLedgerConsistency` +
|
|
26
|
+
`verifyLedgerInclusionProof`/`verifyLedgerConsistencyProof`). Inclusion proves
|
|
27
|
+
one record is committed by a signed head; consistency proves a later head
|
|
28
|
+
append-only-extends an earlier one. Both fail closed unless bound to a signed
|
|
29
|
+
head.
|
|
30
|
+
- Reconstructs a delegation+execution incident offline from ledger records alone
|
|
31
|
+
(`analyzeForensics`/`reconstructIncident`) and asserts attenuation structure,
|
|
32
|
+
exact authorization→execution correlation, and cascade containment — a
|
|
33
|
+
read-only auditor primitive, not anomaly detection.
|
|
14
34
|
- Formats verified exports as JSON, raw ledger JSONL, or SIEM-friendly JSONL events.
|
|
15
35
|
- Syncs a verified export to an optional hosted endpoint.
|
|
36
|
+
- Exports opt-in OTLP/HTTP GenAI `execute_tool` spans from ledger records,
|
|
37
|
+
carrying decisions, reasons, hashes, and audit dimensions without payload
|
|
38
|
+
bodies or secrets.
|
|
16
39
|
- Fails closed on malformed JSONL records.
|
|
40
|
+
- Records parent-to-child ActionPass delegation edges inside the hash chain.
|
|
41
|
+
- Records denied, pending, committed, and rolled-back budget events with
|
|
42
|
+
configured cost/limit and usage before/after.
|
|
43
|
+
- Carries a payload-free, hash-bound audit context on new records (tenant,
|
|
44
|
+
agent, human owner, task, tool, and resource) so operator search does not
|
|
45
|
+
infer identity from hashes or provider summaries.
|
|
17
46
|
- Carries trace IDs and sanitized provider evidence for GitHub, Slack, and Linear records when that evidence was present at decision time.
|
|
18
47
|
|
|
48
|
+
## Quickstart
|
|
49
|
+
|
|
50
|
+
This example runs as-is with Node 20+:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { evaluatePolicy } from "@axtary/policy";
|
|
54
|
+
import { parseNormalizedAction, demoAction } from "@axtary/actionpass";
|
|
55
|
+
import { LocalJsonlLedger, verifyLedgerFile } from "@axtary/ledger";
|
|
56
|
+
|
|
57
|
+
const ledger = new LocalJsonlLedger(".axtary/ledger.jsonl");
|
|
58
|
+
|
|
59
|
+
// Every decision appends a record chained to the previous record's hash.
|
|
60
|
+
const action = parseNormalizedAction(demoAction);
|
|
61
|
+
await ledger.appendDecision({ action, decision: evaluatePolicy(action) });
|
|
62
|
+
|
|
63
|
+
// Verification fails closed on any edited, reordered, or deleted line.
|
|
64
|
+
const verification = await verifyLedgerFile(".axtary/ledger.jsonl");
|
|
65
|
+
console.log(verification.valid, verification.records.length);
|
|
66
|
+
```
|
|
67
|
+
|
|
19
68
|
## Design Notes
|
|
20
69
|
|
|
21
70
|
The ledger is local-first. It is not a database, SIEM, or remote audit service. It gives the proxy and adapters a durable local trail that can later be uploaded, exported, or re-verified. Export and sync both verify the full hash chain before returning or sending filtered records. SIEM JSONL events include timestamps, trace IDs, outcomes, provider/resource summaries, policy metadata, reasons, and hashes without expanding protected action payloads or credential-bearing provider responses.
|
|
22
71
|
|
|
72
|
+
OpenTelemetry export is an operational projection, not the audit proof.
|
|
73
|
+
`exportLedgerRecordsToOtlp` posts verified records to an OTLP/HTTP traces
|
|
74
|
+
endpoint, and `LocalJsonlLedger` can be constructed with `OtlpHttpTraceExporter`
|
|
75
|
+
to stream spans after durable append. The span shape uses standard GenAI tool
|
|
76
|
+
attributes (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.type`)
|
|
77
|
+
plus Axtary namespaced attributes for decision, reason, payload hash, ledger
|
|
78
|
+
hash, policy, pass id, trace/correlation id, and audit context. It never emits
|
|
79
|
+
normalized payload bodies, provider tokens, auth headers, result rows, file
|
|
80
|
+
contents, or raw shell commands.
|
|
81
|
+
|
|
82
|
+
`LocalJsonlLedger` uses a filesystem lease lock (`<ledger>.lock`) so separate
|
|
83
|
+
processes resolve and append against one chain head. The JSONL file is opened
|
|
84
|
+
in append mode, one line is written, and the file is synchronized. A private
|
|
85
|
+
`<ledger>.head.json` checkpoint (mode `0600`) stores byte length, line number,
|
|
86
|
+
and the last hash for steady-state O(1) appends; it is never treated as audit
|
|
87
|
+
evidence. The checkpoint is atomically replaced and the containing directory
|
|
88
|
+
is synchronized. If a process dies after the durable JSONL append but before
|
|
89
|
+
checkpoint replacement or lock release, the lease becomes stale and the next
|
|
90
|
+
writer verifies the JSONL chain, reconstructs the head, and continues.
|
|
91
|
+
|
|
23
92
|
Hosted sync should use signed ledger sync tokens rather than dashboard user sessions. Sync tokens carry a signed `kid` so hosted verification can rotate keys with `AXTARY_LEDGER_SYNC_TOKEN_KID` and a JSON `AXTARY_LEDGER_SYNC_TOKEN_SECRETS` keyring. Hosted retention can be bounded with `AXTARY_LEDGER_SYNC_MAX_BATCHES`, `AXTARY_LEDGER_SYNC_MAX_AGE_DAYS`, or stricter limits embedded in the signed sync token.
|
|
24
93
|
|
|
25
94
|
The hosted sync store now sits behind a persistence adapter. The default adapter is local JSON at `.axtary/hosted-ledger-sync.json`; set `AXTARY_LEDGER_SYNC_STORE=neon` plus `AXTARY_LEDGER_SYNC_DATABASE_URL` to use the Neon/Postgres adapter. Apply `migrations/neon/001_hosted_ledger_sync_batches.sql` for deployed environments; `docs/neon-hosted-sync-runbook.md` covers the hosted setup and verification flow. Source file paths can be reduced before storage with `AXTARY_LEDGER_SYNC_REDACT_SOURCE_FILE_PATH=basename` or `redact`. Hash-bound ledger record fields are preserved so synced evidence remains verifiable.
|
|
26
95
|
|
|
27
|
-
|
|
96
|
+
Unified audit search is available through `/api/ledger/search` with optional
|
|
97
|
+
`q`, `decision`, `from`, `to`, and `limit` query parameters. In local dashboard
|
|
98
|
+
mode it searches the verified local JSONL chain plus tenant-scoped synced
|
|
99
|
+
batches; hosted mode searches only tenant-scoped synced evidence. The broad
|
|
100
|
+
query covers agent, human owner, task, tool, resource, hashes, policy, reasons,
|
|
101
|
+
traces, and provider evidence. Historical records without `auditContext`
|
|
102
|
+
remain valid but those identity dimensions are labeled unavailable. The older
|
|
103
|
+
`/api/ledger/sync?view=records` endpoint remains a synced-only view, and SIEM
|
|
104
|
+
exports remain available through `/api/ledger/sync?format=siem-jsonl`.
|
|
28
105
|
|
|
29
106
|
Fail-closed and secret boundaries:
|
|
30
107
|
|
|
@@ -32,4 +109,6 @@ Fail-closed and secret boundaries:
|
|
|
32
109
|
- Hosted sync accepts only verified exports through the sync route and keeps provider credentials, sync tokens, dashboard sessions, cookies, and auth headers out of stored batches and browser payloads.
|
|
33
110
|
- Provider evidence is extracted from normalized actions, not raw provider HTTP responses. GitHub content payloads record paths and lengths rather than file bodies unless an explicit sanitized diff is supplied.
|
|
34
111
|
|
|
35
|
-
Concurrent writers
|
|
112
|
+
Concurrent cooperating writers are serialized by the package lock. Direct
|
|
113
|
+
writes that bypass `LocalJsonlLedger` are unsupported; size drift is detected
|
|
114
|
+
before and after append and fails closed as `ledger_concurrent_write_detected`.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { NormalizedAction } from "@axtary/actionpass";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Behavioral observation store (risk-graph v0).
|
|
5
|
+
*
|
|
6
|
+
* This is the durable memory behind M5.6's deterministic novelty/sequence
|
|
7
|
+
* step-up. It records, per `(tenant, agentId)`, which `(tool, resource)`
|
|
8
|
+
* combinations and which `prevTool → tool` transitions have already been
|
|
9
|
+
* *executed*. From that it derives two booleans for an action:
|
|
10
|
+
*
|
|
11
|
+
* - `firstSeenCombo` — this agent has never executed this tool on this resource.
|
|
12
|
+
* - `abnormalSequence` — the transition from the agent's last executed tool to
|
|
13
|
+
* this one has never been executed before.
|
|
14
|
+
*
|
|
15
|
+
* HARD FENCE (PRD §4 non-goals): these are signals that only ever cause a
|
|
16
|
+
* `step_up`. Nothing here scores, ranks, or authorizes. `evaluate()` is
|
|
17
|
+
* read-only; an action only becomes "known" via `observe()`, which the proxy
|
|
18
|
+
* calls *after* a successful execution — so a denied or unapproved novel action
|
|
19
|
+
* is never silently whitelisted.
|
|
20
|
+
*/
|
|
21
|
+
export declare const BEHAVIOR_STORE_VERSION = "axtary.behavior_store.v0";
|
|
22
|
+
export declare const BehaviorStoreSchema: z.ZodObject<{
|
|
23
|
+
schemaVersion: z.ZodLiteral<"axtary.behavior_store.v0">;
|
|
24
|
+
agents: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
25
|
+
combos: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
26
|
+
transitions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
27
|
+
lastTool: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type BehaviorStoreData = z.infer<typeof BehaviorStoreSchema>;
|
|
31
|
+
export type BehaviorSignals = {
|
|
32
|
+
firstSeenCombo: boolean;
|
|
33
|
+
abnormalSequence: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Pure signal derivation against a loaded store. No IO, no mutation — the proxy
|
|
37
|
+
* uses this both for the durable file store and for tests/in-memory callers.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deriveBehaviorSignals(data: BehaviorStoreData, action: NormalizedAction): BehaviorSignals;
|
|
40
|
+
/**
|
|
41
|
+
* Fold an executed action into the store. Pure: returns the next state. Records
|
|
42
|
+
* the combo, the transition from the agent's last tool, and advances lastTool.
|
|
43
|
+
*/
|
|
44
|
+
export declare function recordBehaviorObservation(data: BehaviorStoreData, action: NormalizedAction): BehaviorStoreData;
|
|
45
|
+
export interface BehaviorStore {
|
|
46
|
+
evaluate(action: NormalizedAction): Promise<BehaviorSignals>;
|
|
47
|
+
observe(action: NormalizedAction): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/** In-memory store for tests and single-process callers. */
|
|
50
|
+
export declare class InMemoryBehaviorStore implements BehaviorStore {
|
|
51
|
+
private data;
|
|
52
|
+
evaluate(action: NormalizedAction): Promise<BehaviorSignals>;
|
|
53
|
+
observe(action: NormalizedAction): Promise<void>;
|
|
54
|
+
snapshot(): BehaviorStoreData;
|
|
55
|
+
}
|
|
56
|
+
export type FileBehaviorStoreOptions = {
|
|
57
|
+
lock?: {
|
|
58
|
+
staleMs?: number;
|
|
59
|
+
updateMs?: number;
|
|
60
|
+
retries?: number;
|
|
61
|
+
minTimeoutMs?: number;
|
|
62
|
+
maxTimeoutMs?: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Durable, lock-serialized behavior store shared across proxy/serve handlers
|
|
67
|
+
* and restarts, so novelty memory is not reset per process. `evaluate` is a
|
|
68
|
+
* lock-free read; `observe` is serialized under an inter-process lease and
|
|
69
|
+
* written `0600` via an atomic rename.
|
|
70
|
+
*/
|
|
71
|
+
export declare class FileBehaviorStore implements BehaviorStore {
|
|
72
|
+
readonly filePath: string;
|
|
73
|
+
private readonly options;
|
|
74
|
+
constructor(filePath: string, options?: FileBehaviorStoreOptions);
|
|
75
|
+
evaluate(action: NormalizedAction): Promise<BehaviorSignals>;
|
|
76
|
+
observe(action: NormalizedAction): Promise<void>;
|
|
77
|
+
private read;
|
|
78
|
+
private write;
|
|
79
|
+
private acquireLock;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=behavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior.d.ts","sourceRoot":"","sources":["../src/behavior.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,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O,CAAC;YACpC,CAAC;SACF,CAAC,CAAC;QACH,IAAI,iBAAiB,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,OAAO,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,iBAAiB,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { DelegationLedgerEdge, LedgerRecord } from "@axtary/actionpass";
|
|
2
|
+
export declare const LEDGER_FORENSICS_VERSION = "axtary.ledger_forensics.v0";
|
|
3
|
+
export type ForensicExecution = {
|
|
4
|
+
recordIndex: number;
|
|
5
|
+
recordId: string;
|
|
6
|
+
status: "succeeded" | "failed";
|
|
7
|
+
occurredAt: string;
|
|
8
|
+
};
|
|
9
|
+
export type ForensicNode = {
|
|
10
|
+
passId: string;
|
|
11
|
+
parentPassId: string | null;
|
|
12
|
+
rootPassId: string;
|
|
13
|
+
depth: number;
|
|
14
|
+
recordIndices: number[];
|
|
15
|
+
executions: ForensicExecution[];
|
|
16
|
+
/** Chain index of the first revocation-denial record naming this pass. */
|
|
17
|
+
revokedAtIndex: number | null;
|
|
18
|
+
};
|
|
19
|
+
export type ForensicTimelineEntry = {
|
|
20
|
+
recordIndex: number;
|
|
21
|
+
recordId: string;
|
|
22
|
+
occurredAt: string;
|
|
23
|
+
passId: string | null;
|
|
24
|
+
decision: LedgerRecord["decision"];
|
|
25
|
+
reasons: string[];
|
|
26
|
+
executionStatus: "succeeded" | "failed" | null;
|
|
27
|
+
};
|
|
28
|
+
export type ForensicIncident = {
|
|
29
|
+
nodes: ForensicNode[];
|
|
30
|
+
edges: DelegationLedgerEdge[];
|
|
31
|
+
roots: string[];
|
|
32
|
+
timeline: ForensicTimelineEntry[];
|
|
33
|
+
};
|
|
34
|
+
export type ForensicProperty = {
|
|
35
|
+
property: "delegation_attenuation" | "forensic_reconstructibility" | "cascade_containment";
|
|
36
|
+
holds: boolean;
|
|
37
|
+
violations: string[];
|
|
38
|
+
};
|
|
39
|
+
export type ForensicReport = {
|
|
40
|
+
schemaVersion: typeof LEDGER_FORENSICS_VERSION;
|
|
41
|
+
recordCount: number;
|
|
42
|
+
roots: string[];
|
|
43
|
+
nodeCount: number;
|
|
44
|
+
edgeCount: number;
|
|
45
|
+
properties: ForensicProperty[];
|
|
46
|
+
valid: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** Rebuild the delegation forest and execution timeline from ledger records. */
|
|
49
|
+
export declare function reconstructIncident(records: LedgerRecord[]): ForensicIncident;
|
|
50
|
+
/** Reconstruct the incident and assert the three forensic properties. */
|
|
51
|
+
export declare function analyzeForensics(records: LedgerRecord[]): ForensicReport;
|
|
52
|
+
//# sourceMappingURL=forensics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forensics.d.ts","sourceRoot":"","sources":["../src/forensics.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE7E,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAKrE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,0EAA0E;IAC1E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACl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