@irisrun/audit 0.1.0 → 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/README.md +27 -0
- package/dist/audit.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/verify.d.ts +13 -0
- package/dist/verify.js +19 -8
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @irisrun/audit
|
|
2
|
+
|
|
3
|
+
**Compliance-grade audit, straight from the journal.** Because every effect,
|
|
4
|
+
marker, and approval is recorded in a deterministic, event-sourced journal, "what
|
|
5
|
+
happened" isn't a log you hope is complete — it's a **replay-verifiable record**.
|
|
6
|
+
No separate audit log to fall out of sync.
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
A read-only projection over the existing journal (**zero kernel change**).
|
|
11
|
+
`auditSession` produces a whole-session, compliance-grade trail over the *full*
|
|
12
|
+
retained journal with a completeness check; `verifyReplay` / `verifySession`
|
|
13
|
+
re-derive the session from its journal and assert structural integrity +
|
|
14
|
+
in-process replay-determinism + totality; `renderAudit` formats the trail. This
|
|
15
|
+
verifies **faithful record-replay** of captured effects — it does not make the
|
|
16
|
+
model deterministic. Depends on `@irisrun/core` + `@irisrun/auth` only.
|
|
17
|
+
|
|
18
|
+
## Use it
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
iris audit s1 --db /tmp/s1.sqlite # a replay-verified, compliance-grade trail for session s1
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
See **[docs/Audit & reproducible evals](../../docs/audit-and-evals.md)**.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
Part of [Iris](../../README.md) — own, portable, verifiable state.
|
package/dist/audit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// auditSession
|
|
1
|
+
// auditSession: a whole-session, compliance-grade audit. UNLIKE
|
|
2
2
|
// `inspectSession` (which reads only the POST-snapshot tail), this reads the FULL
|
|
3
3
|
// retained journal from seq 0 — every effect intent/result, every marker — plus the
|
|
4
4
|
// governed approval trail (via @irisrun/auth's `auditApprovals`, also full-journal).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const PACKAGE = "@irisrun/audit";
|
|
2
2
|
export { auditSession, renderAudit } from "./audit.js";
|
|
3
3
|
export type { AuditEntry, SessionAudit } from "./audit.js";
|
|
4
|
-
export { verifyReplay, verifySession } from "./verify.js";
|
|
4
|
+
export { verifyReplay, verifySession, verifyStructure } from "./verify.js";
|
|
5
5
|
export type { VerifyResult } from "./verify.js";
|
|
6
6
|
export { fnv1a32hex } from "./fnv.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// @irisrun/audit — the audit & reproducible-eval product surface
|
|
1
|
+
// @irisrun/audit — the audit & reproducible-eval product surface.
|
|
2
2
|
// Pure read-only projections over the existing journal; zero kernel change.
|
|
3
3
|
export const PACKAGE = "@irisrun/audit";
|
|
4
4
|
export { auditSession, renderAudit } from "./audit.js";
|
|
5
|
-
export { verifyReplay, verifySession } from "./verify.js";
|
|
5
|
+
export { verifyReplay, verifySession, verifyStructure } from "./verify.js";
|
|
6
6
|
export { fnv1a32hex } from "./fnv.js";
|
package/dist/verify.d.ts
CHANGED
|
@@ -12,6 +12,19 @@ export type VerifyResult = {
|
|
|
12
12
|
complete: boolean;
|
|
13
13
|
issues: string[];
|
|
14
14
|
};
|
|
15
|
+
/** The reducer-FREE structural core (guarantee #1). Checks dense/monotonic seq,
|
|
16
|
+
* self-seq vs store row position, ≤1 result per effectId, and — only when
|
|
17
|
+
* `complete` — that every result joins a prior intent (an orphan result in a
|
|
18
|
+
* truncated window is legitimate and NOT flagged). Pure; no reducer, no replay.
|
|
19
|
+
* Reused by @irisrun/journal-export's file-only (Tier 1) verification. */
|
|
20
|
+
export declare function verifyStructure(records: JournalRecord[], opts?: {
|
|
21
|
+
complete?: boolean;
|
|
22
|
+
rowSeqs?: number[];
|
|
23
|
+
}): {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
complete: boolean;
|
|
26
|
+
issues: string[];
|
|
27
|
+
};
|
|
15
28
|
/** Pure verification of a fold over `startState`. `records` is the retained tail to
|
|
16
29
|
* fold; `reducer` MUST match how the session was recorded (caller's responsibility).
|
|
17
30
|
* `opts.rowSeqs` are the store row positions for the self-seq integrity check. */
|
package/dist/verify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// verifyReplay/verifySession
|
|
1
|
+
// verifyReplay/verifySession: offline, compliance-grade verification
|
|
2
2
|
// of a recorded session. THREE SOUND GUARANTEES (and no more — honesty matters):
|
|
3
3
|
// 1. structural integrity (reducer-free, the strongest claim): dense monotonic seq;
|
|
4
4
|
// each record's self-reported seq matches its store row position (corruption/
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
// which is not journaled for no-snapshot sessions — see the initiative decisions).
|
|
16
16
|
import { replay, canonicalize, canonicalEqual, decode } from "@irisrun/core";
|
|
17
17
|
import { fnv1a32hex } from "./fnv.js";
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* `
|
|
21
|
-
|
|
18
|
+
/** The reducer-FREE structural core (guarantee #1). Checks dense/monotonic seq,
|
|
19
|
+
* self-seq vs store row position, ≤1 result per effectId, and — only when
|
|
20
|
+
* `complete` — that every result joins a prior intent (an orphan result in a
|
|
21
|
+
* truncated window is legitimate and NOT flagged). Pure; no reducer, no replay.
|
|
22
|
+
* Reused by @irisrun/journal-export's file-only (Tier 1) verification. */
|
|
23
|
+
export function verifyStructure(records, opts = {}) {
|
|
22
24
|
const complete = opts.complete ?? true;
|
|
23
25
|
const structural = [];
|
|
24
|
-
const retainedRange = records.length ? { from: records[0].seq, to: records[records.length - 1].seq } : null;
|
|
25
26
|
// (a) dense, monotonic seq within the retained range
|
|
26
27
|
for (let i = 1; i < records.length; i++) {
|
|
27
28
|
if (records[i].seq !== records[i - 1].seq + 1) {
|
|
@@ -53,8 +54,18 @@ export function verifyReplay(reducer, records, startState, opts = {}) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
return { ok: structural.length === 0, complete, issues: structural };
|
|
58
|
+
}
|
|
59
|
+
/** Pure verification of a fold over `startState`. `records` is the retained tail to
|
|
60
|
+
* fold; `reducer` MUST match how the session was recorded (caller's responsibility).
|
|
61
|
+
* `opts.rowSeqs` are the store row positions for the self-seq integrity check. */
|
|
62
|
+
export function verifyReplay(reducer, records, startState, opts = {}) {
|
|
63
|
+
const retainedRange = records.length ? { from: records[0].seq, to: records[records.length - 1].seq } : null;
|
|
64
|
+
// structural integrity (guarantee #1) — delegated to the reducer-free core.
|
|
65
|
+
const struct = verifyStructure(records, { complete: opts.complete, rowSeqs: opts.rowSeqs });
|
|
66
|
+
const complete = struct.complete;
|
|
67
|
+
const wellFormed = struct.ok;
|
|
68
|
+
const issues = [...struct.issues];
|
|
58
69
|
// replay: in-process determinism (fold twice) + totality
|
|
59
70
|
let total = true;
|
|
60
71
|
let replayDeterministic = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@irisrun/audit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Iris audit & reproducible-eval product surface — whole-session, compliance-grade audit over the FULL retained journal (every effect/marker/approval, with completeness) plus offline replay-verification (structural integrity + in-process replay-determinism + totality). Pure: a read-only projection over the existing journal, zero kernel change. Deps @irisrun/core + @irisrun/auth only.",
|
|
6
6
|
"exports": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@irisrun/core": "^0.
|
|
15
|
-
"@irisrun/auth": "^0.
|
|
14
|
+
"@irisrun/core": "^0.2.0",
|
|
15
|
+
"@irisrun/auth": "^0.2.0"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"engines": {
|