feat(audit): audit runs and attestations are journaled (P8)

A claim that someone checked the books is evidence the CPA handoff rests on,
so it is a journal fact and replays: audit.run (a programme run through a
day at the books' figure head, with the hashes that make it reproducible and
the two filed workpapers), receipt.attested, entry.reviewed and
period.attested. Behind the journal feature audits, schema 20; no figure
moves. The figure head is the last line that bears on a figure: filing a
workpaper, a run or an attestation never makes an audit stale, an entry,
document, close, settings or role change does, so a period is attested only
on an audit that still describes the books. A receipt reading that differs
from the entry is recorded as disagreeing and never counts; whether a claim
counts is derived against the bar when asked, never stored.

The store also reads what a ledger cannot: the chain, the database against
a replay, stored and extracted files, the access log, duplicate files, and
the backups' standing handed in by the server. Fixture old-books/p8_before
was written by the version before this one and opens to its figures.
period.attested was the tests' placeholder for an unknown event type; they
use ledger.not_yet_written now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
This commit is contained in:
swaitsandClaude Fable 5.1 committed 2026-10-29 15:54:08 -06:00
1 parent 843bcc421f
commit 6b7dccd1ee
19 files changed
+2479 -18

No files matched your search

+34
View File
@@ -51,6 +51,9 @@ use rust_decimal::Decimal;
use serde_json::{Value, json};
use std::path::{Path, PathBuf};
#[path = "audit.rs"]
pub mod audit;
/// File names inside the data directory.
pub const JOURNAL_FILE: &str = "journal.jsonl";
@@ -7594,6 +7597,21 @@ fn replay_line(
let a = crate::meta::annotated_of(line)?;
ledger.replay_annotate_attachment(a)?;
}
"audit.run" => {
// Not accounting state; the projection records it. Checked
// for shape here (an unknown scope is newer, rules.md B-27).
crate::meta::audit_run_of(line)?;
}
// A claim that someone checked; no figure moves.
"receipt.attested" => {
crate::meta::attestation_of(line)?;
}
"entry.reviewed" => {
crate::meta::attestation_of(line)?;
}
"period.attested" => {
crate::meta::attestation_of(line)?;
}
"entry.settles" => {
let (entry, settles) = crate::meta::entry_settles_of(p)?;
ledger.replay_set_entry_settles(entry, settles)?;
@@ -8809,6 +8827,22 @@ fn apply_line_rows(conn: &Connection, line: &JournalLine) -> Result<(), StoreErr
],
)?;
}
"audit.run" => {
let run = crate::meta::audit_run_of(line)?;
audit::insert_run(conn, &run)?;
}
"receipt.attested" => {
let a = crate::meta::attestation_of(line)?;
audit::insert_attestation(conn, &a)?;
}
"entry.reviewed" => {
let a = crate::meta::attestation_of(line)?;
audit::insert_attestation(conn, &a)?;
}
"period.attested" => {
let a = crate::meta::attestation_of(line)?;
audit::insert_attestation(conn, &a)?;
}
"entry.settles" => {
// Rebuilt into the ledger by replay; no report rows.
}