Ledger format, version 1¶
This page specifies the ledger: the entries audit_trail.ledger appends, their leaves and tree, the package's own entry types, checkpoints and erasure journals, the checks ledger.verify() makes, and the bundle of stream type "ledger" that ledger.export_bundle() writes and verify_bundle() checks without the database. With it and the test vectors, a verifier can be written in another language.
The canonical JSON encoding and the commitments are specified in the canonical encoding spec, signed notes, key ids, key histories, host files and the manifest in the bundle format spec. This page relies on both and does not repeat them.
Conventions¶
The key words MUST, MUST NOT, SHOULD and MAY are to be read as in RFC 2119 and RFC 8174 when, and only when, they appear in capitals. SHA-256, ||, canonical(v), base64, timestamps, JSON, numbers and integers are as in the bundle format spec, with these rules for the ledger:
- A timestamp is read only in exactly the form
YYYY-MM-DDTHH:MM:SS.ffffffZ, of a real date of the proleptic Gregorian calendar from year 0001, an hour up to 23 and a minute and a second up to 59. Text in any other form, even one naming the same instant (+00:00forZ, fewer fraction digits, a space before or after), is not a timestamp. A ledger reader MUST NOT be more lenient, unlike the reference reader of audit bundles. - An integer has no fraction and no exponent:
1.0and1e0are numbers that are not integers. An integer this page reads, a field of a bundle record or an attribute of a package entry, MUST fit a signed 64-bit integer, from −263 to 263 − 1. One outside that range makes the bundle malformed, or fails the entry withMALFORMED_ENTRY, as a value that is not an integer would. Integers in the attributes of other entries are not read, and may be of any size. Nor does the rule bind the integers inside the text of a carriedjournalor the text of asystem_identifier. - A UUID is 32 hexadecimal digits in groups of 8, 4, 4, 4 and 12 joined by
-, in either case, without braces or a prefix. It is canonical in lowercase. - base64 is read strictly, as the bundle format spec says: only the alphabet and
=padding, a length that is a multiple of 4. It is canonical when it is what encoding the decoded bytes gives, that is, when the unused bits of its last character are zero.
LF is the byte 0x0A. Failing means adding a finding of a failure kind to the report, and noting adding a finding of a note kind; neither stops the verification.
Chains and entries¶
A ledger holds named chains. A chain name matches ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$: it holds no space, line break or /. Each chain is a log of entries numbered by seq, gapless from 1, in incarnations numbered from 1: a restore of the database starts a new one, and the sequence and the tree go on across it.
The body¶
An entry's body is the canonical encoding of a JSON object with exactly these members:
| Member | Value |
|---|---|
actor |
Text, or null: the principal that submitted the entry |
attributes |
An object: the fields never erased. The package checks only that they encode canonically |
commitments |
An object from group name to base64 of 32 bytes: one commitment per erasable payload group |
declared_at |
A timestamp: the time the writer declares |
id |
A UUID, lowercase and hyphenated: the entry id, stable before the entry is appended |
type |
Text matching ^[A-Za-z][A-Za-z0-9_.-]{0,127}$. Types starting with ledger., in any case, are the package's |
type_version |
An integer from 1 to 999999999 |
A group name matches ^[a-z][a-z0-9_]{0,63}$. The body is stored as written, byte for byte; the queryable columns of the entry table are copies of it.
Each member is of its type when it is the JSON value the table names, in the forms of the conventions: actor a string or null, attributes and commitments objects, each key of commitments a group name and each commitment a string that decodes as base64 to 32 bytes, declared_at a timestamp, id a UUID, type a string matching its pattern, type_version an integer in its range. The body is read as UTF-8 JSON text; an object with a key twice keeps its last value, and NaN, Infinity and -Infinity read as numbers that are not integers. A body that is not UTF-8, not JSON, or not an object with exactly these members, each of its type, is malformed. A body that is not malformed is canonical when it is byte for byte canonical of the value it parses to, its id is in lowercase and each commitment is canonical base64; a value that has no canonical encoding (a string holding U+0000, say) is not canonical.
Payload and commitments¶
Each payload group's value v is stored apart from the body, as canonical(v) with a fresh 16-byte salt, and the body commits to it as an integrity commitment does (commitments) over the stored bytes:
SHA-256("sqlalchemy-audit-trail/commit/v1" || 0x00 || u8(len(group)) || group || salt || canonical(v))
Erasing an entry deletes its payload rows, value and salt. The commitment stays in the body, so the leaf does not change.
The leaf and the tree¶
The leaf input of an entry is
where chain is the chain name, incarnation, seq and append_time are decimal ASCII integers without leading zeros, append_time in microseconds since 1970-01-01T00:00:00Z, with a - sign when it is negative (a time before 1970) and no sign otherwise, and body the stored body bytes. The append time is the time the append function read under the chain's lock. The leaf hash is the RFC 6962 leaf, SHA-256(0x00 || leaf input).
A chain's tree is the RFC 6962 Merkle tree of its leaf hashes in seq order, seq 1 being leaf 0. Node (level, index) is the tree hash of leaves [index * 2^level, (index + 1) * 2^level), level 0 being the leaf hash. The head of size n is (n, root), the root of the tree of the first n entries; a new incarnation shares the tree with the one before it. Inclusion and consistency proofs are those of RFC 9162, section 2.1; the Merkle vectors give roots, frontiers and proofs.
Package entry types¶
Each package entry has no commitments and type_version 1. The entries the database functions write themselves (ledger.incarnation_started, ledger.cluster_changed, ledger.maintenance, ledger.bundle_manifest, ledger.restored and ledger.upgrade_confirmed) have a declared_at not after their append time; the first two have a null actor.
| Type | Attributes | Written by |
|---|---|---|
ledger.chain_started |
The chain's config, whole: detect_restores (boolean), precondition (text or null), protected_types (array of types), reason_codes (array of reason codes, none starting with ledger. in any case), as ChainConfig.as_dict() gives it. Exactly entry 1 |
create_chain |
ledger.config_changed |
A whole config as above, with the detect_restores of the config before it |
change_config |
ledger.erased |
entry_id, incarnation and seq of the erased entry, and its reason_code; a re-applied receipt has a fifth, reapplies |
erase, record_restore |
ledger.incarnation_started |
cause (new_cluster, recreated or new_timeline), from and to, two cluster identities. The first entry of an incarnation |
restore detection |
ledger.cluster_changed |
from and to, two cluster identities that show a pg_upgrade |
restore detection |
ledger.maintenance |
incarnation, the one it was appended in, and reason, a reason code |
record_maintenance |
ledger.upgrade_confirmed |
entry_id, incarnation and seq of the ledger.cluster_changed entry it confirms |
confirm_upgrade |
ledger.checkpoint |
note: a signed checkpoint of a head of the chain |
record_checkpoint |
ledger.bundle_manifest |
sha256: canonical base64 of the 32-byte host-files digest of a bundle |
record_bundle_manifest |
ledger.restored |
checkpoint, incarnation, restored_size, journal, lost, proven, proof and reapplied: see restores |
record_restore |
A cluster identity is {"server_major": integer, "system_identifier": decimal text, "table_oid": integer, "timeline": integer}. The system identifier is the text of an integer: an optional - sign, then 0 or digits without a leading zero. Two identities are compared as the integers they name, so "-0" and "0" are the same system identifier. Restore detection compares the identity stored before with the one observed and applies the first rule that matches: the table OID changed, cause new_cluster when the system identifier changed too, else recreated; the system identifier changed and the major version is higher, ledger.cluster_changed; the system identifier changed, new_cluster; the timeline changed, new_timeline. A reason code matches ^[A-Za-z][A-Za-z0-9_.-]{0,63}$.
The ledger.cluster_changed rule assumes that a new system identifier with a higher major version and the same table OID is a pg_upgrade, which keeps the data files. A data-only restore of an older dump into a fresh cluster of a higher major version, its ledger tables created by the same migrations, gives the same identities: a fresh cluster gives out OIDs in the same order. The entries written after the dump are then lost with no new incarnation. So a ledger.cluster_changed stays unconfirmed until a ledger.upgrade_confirmed entry names it: the chain's owner appends one after checking the chain against a checkpoint taken just before the upgrade. Appends go on either way. confirm_upgrade refuses an entry that is not a ledger.cluster_changed and one confirmed already.
Restores¶
A restore brings a chain back to an earlier size, the restored size R. A signed checkpoint kept off the database may name a larger size C: the entries from R + 1 to C are the lost range, their receipts lost with them, and the restored payload rows bring back what those receipts erased. record_restore appends ledger.restored and, in the same call, one re-applied receipt per erasure it applies again, consecutive after it.
ledger.restored has exactly these attributes:
| Attribute | Value |
|---|---|
checkpoint |
The signed checkpoint note of the history the restore lost part of, of size C |
incarnation |
The incarnation the entry explains: its own |
restored_size |
R, an integer |
journal |
When C > R, the text of the checkpoint's erasure journal in its canonical form, as record_restore was given it, or null when none was; when C <= R, null |
lost |
[R + 1, C] when C > R, else null |
proven |
The proven-shared prefix, {"root": base64 of 32 bytes, "size": m} with m at least 1, or null when nothing is proven |
proof |
The proof steps, an array of {"path": [base64 of 32 bytes, ...], "root": base64 of 32 bytes, "size": integer} |
reapplied |
The number of re-applied receipts that follow it, at least 0 |
The incarnation. When restore detection started the current incarnation with ledger.incarnation_started and it holds no ledger.restored yet, ledger.restored explains that incarnation, and R is the seq before its first entry. A ledger.maintenance entry already in the incarnation does not change this: it explains the incarnation too, and ledger.restored still explains it rather than starting another. Otherwise (the incarnation was not started by restore detection, or holds a ledger.restored already) ledger.restored starts a new incarnation itself, as its first entry, and R is the size the host gives, or the chain's size before the entry. So an incarnation holds at most one ledger.restored, and one that explains it rather than starting it is in an incarnation that a ledger.incarnation_started started. An entry of type ledger.restored takes its incarnation even when its body or attributes are malformed: a ledger.restored after it may not explain that incarnation.
The proven-shared prefix. The first m entries are proven to be the first m of the checkpoint's tree:
- when
C <= R, the stored tree of sizeChas the checkpoint's root:provenis{"root": the checkpoint's root, "size": C},proofis empty andlostisnull; - when
C > R, the nodes a consistency proof up toCneeds were lost with the entries, so the database proves nothing by itself:provenisnullandproofempty, unless the host gives consistency proofs taken before the restore. Thenm <= R,proven.rootis the stored tree's root atm, and the steps lead from(m, proven.root)to(C, checkpoint root): each step'ssizeis above the size before it, itspathis an RFC 9162 consistency proof from the size and root before it to its ownsizeandroot, and the last step is the checkpoint's size and root. The roots of the steps are trusted only through the proofs: the stored root atmand the signed root atCare the anchors.
Re-applied receipts. For each erasure of the checkpoint's journal whose target seq is in the proven prefix, and whose target still has payload and no receipt, the payload rows are deleted and a ledger.erased receipt appended with the erasure's entry_id, incarnation, seq and reason_code, and reapplies, the entry id (a UUID, lowercase and hyphenated) of the receipt it applies again. The chain's current config is not asked: the erasure was checked under the config of then.
The committed journal. The re-applied receipts are trusted only through the checkpoint, so a verifier checks them against the journal it commits to, as far as the chain shows it. When C <= R, the chain still holds every receipt up to C: the journal is the journal of those receipts, and the journal line MUST state its commitment; record_restore refuses a checkpoint whose line does not, so nothing is applied again there that the chain does not show erased already. When C > R, the receipts of the lost range are gone, and the entry carries the journal it was given: it MUST have the commitment of the journal line, name the chain and C, and its erasures with a receipt up to the proven size MUST be the journal of the chain's receipts up to that size. Its erasures with a receipt above the proven size cannot be checked against the chain: they are trusted through the checkpoint's signatures alone. So, given the keys to trust, a restore's checkpoint without a trusted signature fails (below).
Checkpoints¶
A checkpoint is a C2SP tlog-checkpoint carried as a signed note:
<host origin>/<chain>/i<incarnation>
<size>
<base64 root>
[sqlalchemy-audit-trail/ledger-journal/v1 <base64 journal commitment>]
[extension lines]
- The origin names the host, the chain and the incarnation. The host origin is 1 to 200 printable ASCII characters without space or
+, not ending in/; the chain holds no/, so the last two/split the origin. The incarnation is a decimal integer from 1 to 231 − 1 without leading zeros. - The size is a decimal integer of at least 1 without leading zeros, and the root the canonical base64 of the 32-byte root of the tree of that size.
- The journal line, optional, states the commitment of the erasure journal of the size. It is a field of the package, not an extension line.
- Extension lines belong to the host, under the rules a writer of integrity's extension lines follows (checkpoints): none is empty or only whitespace, holds a refused code point or an invisible letter, or starts with
sqlalchemy-audit-trail/in any case, compared after Unicode case folding. A ledger reader applies the same rules, not the looser ones integrity's reader keeps for checkpoints 0.5.0 signed: a note with a line a writer refuses is not a checkpoint. Unassigned code points are those of the Unicode version the reader knows.
A note's signatures are checked as the bundle format spec says (signed notes), and each key against its window in a key history at the checkpoint's size.
Restore kits¶
A restore kit keeps together what record_restore needs of one checkpoint and the restored database may have lost: the signed note, its journal and consistency proofs taken while the nodes existed. The host keeps it off the database, next to the backups; prepare_checkpoint and record_checkpoint return the proof from the newest ledger.checkpoint entry at or below the checkpoint's size, or from a size the host gives. Its text is JSON, written as canonical JSON, with exactly these members:
| Member | Value |
|---|---|
checkpoint |
The signed checkpoint note |
journal |
The members of the canonical form of the journal the note's journal line commits to, or null when it has none |
proof |
The steps, in order: {"new_root": base64, "new_size": integer, "old_root": base64, "old_size": integer, "path": [base64, ...]}, each hash of 32 bytes |
v |
1 |
A kit is well formed when the journal is present exactly when the note has a journal line, is of the note's chain and size, and has the commitment the line states; and the steps go up from a size of at least 1, each starts at the size and root where the one before ends, its path is an RFC 9162 consistency proof between its own two roots, and the last ends at the note's size and root. Nothing in a kit is trusted for being there: record_restore checks the note's signatures, and the steps from the restored tree's root at the first old_size to the note's root, as restores say; the roots between are anchored only through the proofs.
Erasure journals¶
The journal of size n lists every ledger.erased receipt that is itself one of the first n entries, its own seq at most n, all incarnations together. The seq of the entry a receipt erases does not count: a receipt at n + 1 erasing an entry at or below n is not in the journal of size n. Its canonical form is
with one item per receipt, sorted by receipt: {"entry_id", "incarnation", "reason_code", "receipt", "receipt_id", "seq"}, where receipt and receipt_id are the receipt's seq and entry id and the others its attributes. A re-applied receipt is listed as any other; the item does not carry reapplies. A receipt whose attributes are not exactly the four of a receipt, and maybe reapplies, is left out. The commitment is SHA-256("sqlalchemy-audit-trail/ledger-journal/v1" || 0x00 || form).
Verification¶
What is checked¶
A verifier reads the entries in seq order and checks, for each entry:
- Sequence.
seqfollows the one before (SEQ_GAP, with the firstseqmissing), and the entries stop at the size the run is bounded by (SEQ_GAP). A ledger bundle verifier stops at the first missingseq(see verifying a ledger bundle); a database verifier reads on. - Body. It is not malformed (
MALFORMED_ENTRY), and it is canonical (NON_CANONICAL). A malformed body is not checked further: steps 5 and 6 skip it, and its type counts as none. - Start. Entry 1 is
ledger.chain_started(CHAIN_START_MISSING). The chain starts in incarnation 1 and the incarnation goes up by one only at aledger.incarnation_startedorledger.restoredentry; aledger.incarnation_startedalways starts one (INCARNATION_MISMATCH). An append time earlier than the entry before's is noted (CLOCK_BACK). - Leaf. The leaf hash of the leaf input is the stored leaf hash (
LEAF_MISMATCH). The tree is built from the leaf hashes computed, not the stored ones. - Payload. Each payload row's commitment is the body's for its group, the group is one the body commits to, the salt is 16 bytes (
COMMITMENT_MISMATCH), and the value is canonical (NON_CANONICAL). A committed group without a row needs aledger.erasedreceipt naming the entry (notedERASED), or fails withPAYLOAD_MISSING. - Package entries, by type:
- every one of a type this page lists has no commitments and
type_version1, and, for those the functions write, the actor anddeclared_atabove (MALFORMED_ENTRY); - a config entry holds a whole config;
ledger.chain_startedis entry 1 only;ledger.config_changedkeepsdetect_restores(MALFORMED_ENTRY). A config entry that holds a whole config becomes the chain's config, also when it fails for another reason, such as changingdetect_restores; - a receipt has exactly its four attributes, or those and
reapplies:entry_ida UUID in lowercase,incarnationandseqintegers,reason_codea string,reappliesa UUID in lowercase (MALFORMED_ENTRY). Its target is the entry at itsseq, which MUST be below the receipt's own; it names an earlier entry with that entry's id and incarnation, not of a package type nor of a type the config protects, whose body commits to payload and that has no payload row left, that no earlier receipt named by the sameentry_id, with a reason code the config allows (RECEIPT_MISMATCH). When its target exists, has itsentry_id, and no earlier receipt named thatentry_id, the target is notedERASED(itsseqandentry_id) and its missing payload is explained; so it is wherever the target is, before the run or the scope too, and also when the receipt fails for another reason. A re-applied receipt (one withreapplies) is not checked against the config's protected types and reason codes, but MUST be one of the receipts theledger.restoredbefore it announced, its targetseqMUST be at most that entry's proven size, 0 whenprovenisnull, and the committed journal of that entry MUST hold an erasure whosereceipt_idis itsreapplies, with itsentry_id,incarnation,seqandreason_code; with no committed journal, no receipt may be re-applied (RECEIPT_MISMATCH); ledger.incarnation_startedandledger.cluster_changedhave exactly their attributes and two identities; the cause, or thepg_upgrade, is what restore detection gives for them; theirfromis thetoof the identity entry before (MALFORMED_ENTRY), counting only one that has exactly its attributes and two identities.ledger.cluster_changedis notedCLUSTER_CHANGED;ledger.upgrade_confirmedhas exactly its three attributes,entry_ida UUID in lowercase,incarnationandseqintegers (MALFORMED_ENTRY). Its target is the entry at itsseq, read as a receipt's target is, which MUST be below its own; it is aledger.cluster_changedwith thatentry_idand incarnation, and no earlierledger.upgrade_confirmedof the run confirmed it (MALFORMED_ENTRY). A confirmation that fails confirms nothing, and does not keep a later one from confirming;ledger.maintenancehas exactly its attributes, its incarnation the one it was appended in (MALFORMED_ENTRY); it explains that incarnation, and aledger.restoredlater in the same incarnation explains it too, without starting another (see the incarnation);ledger.checkpointhas exactly anotethat reads as a checkpoint (MALFORMED_ENTRY); its origin names the chain and the entry's incarnation, its size is in that incarnation and below the entry'sseq, its root is the tree's at that size, by a consistency proof to the tree read so far, and its journal line states the commitment of the journal of the receipts up to its size (CHECKPOINT_MISMATCH). Every signature of a known key verifies (BAD_SIGNATURE) inside its window (KEY_NOT_VALID,KEY_COMPROMISED); a checkpoint with no signature of a known key is notedUNCHECKED_SIGNATURES;ledger.bundle_manifesthas exactlysha256, canonical base64 of 32 bytes (MALFORMED_ENTRY);ledger.restoredhas exactly its attributes, each of its type: acheckpointthat reads as a checkpoint, integersincarnation,restored_sizeandreapplied(at least 0), ajournalofnullor the canonical text of a journal, alostofnullor two integers, aprovenofnullor a size of at least 1 and a root, and steps of a size, a root and a path (MALFORMED_ENTRY). Then, withCthe size of its checkpoint andRitsrestored_size(RESTORE_MISMATCH): the checkpoint's origin names the chain and an incarnation below the entry's;incarnationis the entry's own; when the entry starts its incarnation,1 <= R < seq, else aledger.incarnation_startedstarted the incarnation, the incarnation holds noledger.restoredbefore the entry, andRis theseqbefore the first entry of the incarnation;lostis[R + 1, C]whenC > R, elsenull; whenC <= R,provenisCand the checkpoint's root andproofis empty; whenC > R, anullprovenhas an emptyproof, and otherwise its size is at mostRand the steps lead from it to the checkpoint as restores say; a proven root of a size below the entry'sseqis the tree's at that size, by a consistency proof to the tree read so far; whenC <= R,journalisnulland a journal line states the commitment of the journal of the receipts up toC; whenC > R, ajournalthat is notnullis the one the journal line commits to, of the chain atC, and lists the receipts up to the proven size as the chain holds them; and thereappliedentries after it are re-applied receipts, before the run ends. Its signatures are checked as aledger.checkpoint's (BAD_SIGNATURE,KEY_NOT_VALID,KEY_COMPROMISED,UNCHECKED_SIGNATURES), except that when the verifier is given both trusted keys and a key history, or signatures are required, a checkpoint with no signature of a trusted key fails withRESTORE_MISMATCHinstead of being noted, and that when it is given trusted keys alone, a checkpoint with no signature at all fails withRESTORE_MISMATCHtoo:record_restorenever records one. "No signature of a trusted key" is the condition aledger.checkpointis notedUNCHECKED_SIGNATURESunder: no signature line of a key the verifier is given. A signature of a trusted key outside its window in the key history is a signature of a trusted key: it fails withKEY_NOT_VALIDorKEY_COMPROMISEDonly. It explains its incarnation;- a
ledger.type the verifier does not know is notedUNKNOWN_TYPE, and nothing more is checked of it as a package entry.
- every one of a type this page lists has no commitments and
At the end, an incarnation that a ledger.incarnation_started of the entries read started and no ledger.maintenance or ledger.restored explains is noted UNEXPLAINED_INCARNATION (an incarnation started before the run is not: a bundle's context.jsonl carries no ledger.maintenance, so whether one explains it cannot be told), and a ledger.cluster_changed of the run that no ledger.upgrade_confirmed of the run confirms is noted UNCONFIRMED_UPGRADE (its seq and entry_id): the report stays valid, with notes. A second confirmation is caught only when the run reads both; a run after an earlier head, or a bundle's scope, may hold the second alone. A database verifier also compares the stored nodes, the state row and the config table with what it rebuilt, and checks the trusted checkpoints it is given against the stored tree, after their signatures as a bundle verifier's step 5 says: each names the chain, is at most the size the run is bounded by (TRUNCATED), and its root is the stored tree's at its size, in the incarnation its origin names, by the stored frontier of its size and a consistency proof from the stored nodes (CHAIN_MISMATCH). The report is ANCHORED when one matches, and the entries after the largest one that matched are noted UNANCHORED_TAIL.
Findings¶
| Kind | Failure or note | Raised when | Fields | In a bundle |
|---|---|---|---|---|
SEQ_GAP |
Failure | Entries are missing, in the middle or at the end | seq |
Yes |
LEAF_MISMATCH |
Failure | A stored leaf hash is not the leaf of the entry | seq, entry_id |
Yes |
MALFORMED_ENTRY |
Failure | A body, or a package entry, is not in its form | seq, entry_id |
Yes |
NON_CANONICAL |
Failure | A body or a payload value is not its canonical encoding | seq, entry_id, group |
Yes |
COLUMN_MISMATCH |
Failure | A queryable column is not the body's | seq, entry_id |
No |
COMMITMENT_MISMATCH |
Failure | A payload row does not match its commitment | seq, entry_id, group |
Yes |
PAYLOAD_MISSING |
Failure | A committed group has no row and no receipt | seq, entry_id |
Yes |
RECEIPT_MISMATCH |
Failure | A receipt does not match its target or the config | seq, entry_id |
Yes |
CHAIN_START_MISSING |
Failure | Entry 1 is not ledger.chain_started |
seq, entry_id |
Yes |
INCARNATION_MISMATCH |
Failure | An incarnation is not started by its entry | seq, entry_id |
Yes |
NODE_MISMATCH |
Failure | A stored node is missing or wrong | level, index |
No |
ROOT_MISMATCH |
Failure | The state row's root is not the entries' | none | No |
STATE_MISMATCH |
Failure | The state row's frontier or last append time is not the entries' | none | No |
CONFIG_MISMATCH |
Failure | The config table is not the newest config entry's | none | No |
TRUNCATED |
Failure | An earlier head, or a trusted checkpoint, is above the entries read | seq |
Yes |
CHAIN_MISMATCH |
Failure | An earlier head, a trusted checkpoint or a context entry is not of the tree | seq |
Yes |
CHECKPOINT_MISMATCH |
Failure | A ledger.checkpoint entry does not match the chain |
seq, entry_id |
Yes |
BAD_SIGNATURE |
Failure | A signature of a known key does not verify | seq, and entry_id for an entry's checkpoint |
Yes |
KEY_NOT_VALID |
Failure | A key signed outside its window | seq, and entry_id for an entry's checkpoint |
Yes |
KEY_COMPROMISED |
Failure | A key signed at or after compromised_from |
seq, and entry_id for an entry's checkpoint |
Yes |
RESTORE_MISMATCH |
Failure | A ledger.restored entry does not match the chain, its checkpoint or the re-applied receipts after it |
seq, entry_id |
Yes |
MANIFEST_MISMATCH |
Failure | A bundle entry does not match the manifest, or the manifest is not of the hash given | none | Only |
UNKNOWN_KEY |
Failure | A checkpoint given is signed only by unknown keys | seq |
Yes |
CLOCK_BACK |
Note | An entry was appended earlier than the one before | seq, entry_id |
Yes |
ERASED |
Note | A receipt explains an entry's missing payload | seq, entry_id |
Yes |
UNEXPLAINED_INCARNATION |
Note | No ledger.maintenance or ledger.restored explains an incarnation |
seq |
Yes |
CLUSTER_CHANGED |
Note | A ledger.cluster_changed entry |
seq, entry_id |
Yes |
UNCONFIRMED_UPGRADE |
Note | No ledger.upgrade_confirmed confirms a ledger.cluster_changed entry |
seq, entry_id |
Yes |
UNKNOWN_TYPE |
Note | A package type this verifier does not check | seq, entry_id |
Yes |
UNCHECKED_SIGNATURES |
Note | A checkpoint entry has no signature of a known key | seq, entry_id |
Yes |
OUT_OF_SCOPE |
Note | A bundle cannot check something outside its scope | seq, and entry_id for a receipt, count for re-applied receipts |
Only |
UNANCHORED |
Note | A host file is under a manifest that is not anchored | none | Only |
UNANCHORED_TAIL |
Note | Entries come after the newest trusted checkpoint that matched | seq, count |
Yes |
A finding about an entry names it by seq and entry_id. In a bundle, the entry_id is read from the body: its id when the body is a JSON object whose id is a UUID, written in lowercase, even when the body is otherwise malformed; else the zero UUID, 00000000-0000-0000-0000-000000000000. A database verifier gives the stored column. The signature findings of a checkpoint inside a ledger.checkpoint or ledger.restored entry have that entry's seq and entry_id; those of a checkpoint given or of a line of checkpoints.jsonl have the checkpoint's size as seq and no entry_id; those of the manifest are as the bundle format spec says (BAD_SIGNATURE without seq, the others with last).
A report holds each finding about an entry, one with an entry_id, once: two such findings of the same kind with the same fields are one, whatever their detail. So a body that is not canonical for two reasons, or a package entry malformed in two ways, has one finding. A finding without an entry_id is reported each time the steps below raise it: once per host file for UNANCHORED, say. A finding never holds a stored value or a salt. The order of findings and the wording of their detail are not part of the format.
Bundles of stream type ledger¶
A ledger bundle is a bundle of version 1 whose header.json has stream_type "ledger". The zip rules, the .jsonl and .json rules, the line limit, keys.json, the host/<name> files and manifest.note are those of the bundle format spec, with the chain name as the manifest's chain. Its entries MUST be these, in this order:
| # | Entry | Holds |
|---|---|---|
| 1 | header.json |
The version, the stream type, the chain and the scope |
| 2 | entries.jsonl |
The entries in scope |
| 3 | context.jsonl |
Entries outside the scope, or read out of order, that the checks need |
| 4 | nodes.jsonl |
Hashes of the tree before the scope |
| 5 | checkpoints.jsonl |
Checkpoints, as signed notes |
| 6 | keys.json |
Key ids and a key history |
| 7 | host/<name> |
Zero or more files of the writer |
| 8 | manifest.note |
The SHA-256 and size of every other entry |
A reader needs random access: it reads nodes.jsonl, context.jsonl and checkpoints.jsonl before entries.jsonl.
header.json¶
| Field | Value |
|---|---|
bundle_version |
1 |
stream_type |
"ledger" |
chain |
The chain name |
scope |
{"first": integer, "last": integer}: the seq of the first and last entry in scope, 1 <= first <= last |
created_at |
A timestamp; a reader does not read it |
The start of the scope is first - 1.
Entry records¶
entries.jsonl holds every entry from first to last, in seq order, and context.jsonl entries outside it, in seq order, one entry record per line:
| Field | Value |
|---|---|
seq |
Integer, at least 1 |
incarnation |
Integer, at least 1 |
appended_at |
The append time, a timestamp |
body |
base64 of the body bytes as stored |
leaf_hash |
base64 of the stored leaf hash; one that is not 32 bytes is not malformed, but not the entry's leaf (LEAF_MISMATCH) |
payload |
The payload rows still stored, sorted by group, by Unicode code point (group names are ASCII, so this is also the order of UTF-16 code units and of bytes): {"group": text, "salt": base64, "value": base64 of the stored bytes} |
The columns a database stores as copies of the body are not carried: a reader takes them from the body.
context.jsonl holds:
- when the start is above 0, the entry at the start, the newest
ledger.chain_startedorledger.config_changed, the newestledger.incarnation_started, the newestledger.restored, the newestledger.incarnation_startedorledger.cluster_changed, and everyledger.erased, each up to the start; and the entry at the size of each checkpoint ofcheckpoints.jsonlbelow the start; - the entry each receipt in scope erases, and the entry each
ledger.upgrade_confirmedin scope names, also when it is in scope: a verifier reads such a target only fromcontext.jsonl; - each receipt after
lastthat erases an entry in scope, each re-applied receipt afterlastup to theseqof the newestledger.restoredup tolastplus itsreapplied, and eachledger.upgrade_confirmedafterlastthat names an entry in scope.
A context entry in scope MUST be byte for byte its line in entries.jsonl: the same bytes, the line feed included, so a line that differs only by whitespace or key order is not its line.
nodes.jsonl¶
When the start is above 0: the hashes of the tree of the start's size that the checks need, as stored, sorted by (level, index), one per line, {"level": integer, "index": integer, "hash": base64 of 32 bytes}, each node entirely before the start. They are the frontier of the start (one node per set bit of the start, largest first), the nodes of the inclusion proof of each context entry up to the start in the tree of the start, and the nodes before the start of the consistency proofs from the size of each checkpoint below the start: to the start for those of checkpoints.jsonl, to the entry's seq for ledger.checkpoint entries in scope; and, for each ledger.restored entry in scope whose proven size is below the start, those of the consistency proof from the proven size to the entry's seq. It is empty when the start is 0.
checkpoints.jsonl¶
One checkpoint per line: source, "given" or "chain"; seq, the seq of the ledger.checkpoint entry that recorded it, or null; note, the checkpoint note; proof, null or {"from": integer, "path": [base64 of 32 bytes, ...]}. A writer includes the checkpoints it was given, the newest ledger.checkpoint entry up to the start, the newest ledger.checkpoint entry up to the start that is trusted when that one is not, and the ledger.checkpoint entries after last of a size up to last. The application role can record unsigned checkpoints, so the newest entry alone could leave the signed one out. Trusted is the writer's judgment from the keys it is given: the reference writer takes a checkpoint whose signatures verify under its verifier, each key in its window of the key history; without a verifier, one with a signature line of a key the key history gives a window at its size; without either, one with a signature line. source and seq are informative.
A proof links the line to another: from is the 0-based number of a line of checkpoints.jsonl whose checkpoint's size is below this line's, and path the RFC 9162 consistency proof from that checkpoint's size and root to this one's. A writer computes them from the chain's stored tree: of the lines whose checkpoint's root is the tree's root at its size, each gets the proof from the first such line of the next smaller size, and the others, those of the smallest such size among them, get null; so do the lines whose root is not the tree's. The proofs make a bundle a record of the restore kits' proofs between its checkpoints.
The host-files digest¶
The digest a ledger.bundle_manifest entry holds is
SHA-256("sqlalchemy-audit-trail/ledger-host-files/v1" || 0x00 || canonical({"chain": chain, "files": [{"name": name, "sha256": base64, "size": integer}, ...]}))
over the host files in the order of the zip, not sorted, each with its entry name (host/...), the SHA-256 of its bytes and its size: what the manifest lists for them. export_bundle writes the host files in order of their names, and record_bundle_manifest hashes them in that order, so a bundle written with the same files has the digest recorded; a bundle holding them in another order has another digest.
Malformed ledger bundles¶
A ledger bundle is malformed, an error and not a report, when it is malformed as the bundle format spec says for the zip, the lines, the host files, keys.json and manifest.note, or when:
header.jsonhas anotherbundle_version, achainthat is not a chain name (it does not match the pattern), or a scope that is not a range of entries;- an entry record has a field of the wrong type (an
appended_atthat is not a timestamp in exactly its form among them), or a payload whose groups are not distinct and sorted; - a record of
entries.jsonlhas aseqoutside the scope, fromfirsttolast, or not above the one before; a record ofcontext.jsonlhas aseqnot above the one before; a context entry in scope is not byte for byte its line inentries.jsonl, whenentries.jsonlhas a line of itsseq(a context entry in scope whoseseqentries.jsonllacks, after a gap, is not malformed: the run stops at the gap); - a node is not at a position entirely before the start, is not 32 bytes, or comes twice;
- when the start is above 0,
nodes.jsonllacks a node of the start's frontier, orcontext.jsonllacks the entry at the start; - a checkpoint record has another
source, aseqthat is not an integer ornull, or a note that is not a ledger checkpoint; or it has noproof, or aproofthat is neithernullnor an object of exactly an integerfrom, the number of another line whose checkpoint's size is below its own, and apathof 32-byte hashes.
Verifying a ledger bundle¶
The inputs are those of an audit bundle but retention and the system severity: trusted keys, trusted checkpoints (ledger checkpoints), a key history, require signatures (every checkpoint used must be signed), and a manifest hash. A bundle verifier is always given trusted keys, which may be an empty set: the rules for a verifier given no trusted keys do not apply to it, so a ledger.restored checkpoint with no signature at all fails with RESTORE_MISMATCH also when the set is empty.
- Read
manifest.note,header.json,nodes.jsonl,context.jsonlandcheckpoints.jsonl. - When the start is above 0, the tree starts from the frontier of the start; the entry before the scope is the context entry at the start; the config, the start of its incarnation and the last identity are those of the newest context entries above, up to the start, the start of the incarnation being the smaller
seqof the newestledger.incarnation_startedand the newestledger.restoredthat are in the incarnation of the entry before the scope, or 1. Aledger.restoredin scope may explain that incarnation only when the newestledger.incarnation_startedup to the start is in it and the newestledger.restoredup to the start is not. A bundle whosecontext.jsonlholds no config entry up to the start is not malformed: the chain then has no config before the scope and allows no reason code, so a receipt in scope that is not re-applied fails withRECEIPT_MISMATCHuntil a config entry in scope gives a config. When the newestledger.restoredup to the start is followed, through the start, only by re-applied receipts ofcontext.jsonl, and announced more of them, the scope starts inside its receipts: the rest of the count and its proven size carry into the check of the entries in scope. Each context entry up to the start MUST be in the tree of the start: an inclusion proof fromnodes.jsonlof its leaf hash, computed from its record, against the frontier's root; otherwise fail withCHAIN_MISMATCH(seq,entry_id). - Check the entries of
entries.jsonlas above, the run bounded bylast. The run stops at the first gap: when an entry'sseqis not one above the one before (or above the start, for the first), it and the entries after it are not checked, only read for the form of the bundle, so the oneSEQ_GAPis the first missingseq, and the entries read are those before the gap. After a gap the positions in the tree are no longer theseq, so nothing after it could be checked against a checkpoint. A receipt's target is read fromcontext.jsonl, also when it is in scope: a receipt whose targetseqcontext.jsonllacks names no earlier entry (RECEIPT_MISMATCH), and its target's missing payload stays unexplained; so is aledger.upgrade_confirmedentry's target (MALFORMED_ENTRY). The receipts up to the start, for journals and second receipts, are those ofcontext.jsonl. A proof the checks need is built from the nodes the entries in scope close and fromnodes.jsonl; a node that spans the start is folded from its halves. Aledger.checkpointorledger.restoredentry whose consistency proof needs a node the bundle lacks fails withCHECKPOINT_MISMATCHorRESTORE_MISMATCH: only the trusted checkpoints of step 5 are notedOUT_OF_SCOPEfor it. - A receipt in
context.jsonlafterlastwhoseentry_idis that of an entry read whose payload is missing explains it with anOUT_OF_SCOPEnote (seqof the entry,entry_id): it is outside the tree the bundle shows. The receipt is matched by itsentry_idalone, a UUID in either case; itsseqandincarnationare not compared. When aledger.restoredstill awaits re-applied receipts afterlast, and the entries read end atlast, the consecutive re-applied receipts ofcontext.jsonlfromlast + 1on count for it, noted once asOUT_OF_SCOPE(seq:last + 1,count: how many) when there is at least one; those it still awaits then fail withRESTORE_MISMATCH. When the entries read end beforelast, at a gap, aledger.restoredstill awaiting receipts fails withRESTORE_MISMATCH, andcontext.jsonlis not consulted for it. Aledger.upgrade_confirmedincontext.jsonlafterlastwhoseentry_idandseqare those of aledger.cluster_changedread and not confirmed (itsincarnationis not compared) confirms it with anOUT_OF_SCOPEnote (seqandentry_idof the cluster change) instead ofUNCONFIRMED_UPGRADE. -
Check the trusted checkpoints: the checkpoints given, those of
checkpoints.jsonlwith a signature line of a trusted key, and the notes ofledger.checkpointentries in scope with one. Findings about the last group are those of step 3; for the others, as listed:- a size above
last: noteOUT_OF_SCOPE(seq: the size), not used; - unsigned: used if given and signatures are not required, else fail with
BAD_SIGNATURE(seq) and do not use it; signed: verify the note,UNKNOWN_KEYorBAD_SIGNATURE(seq), and each verified key in its window at the size,KEY_NOT_VALIDorKEY_COMPROMISED(seq); a failure means it is not used; - another chain in the origin:
CHAIN_MISMATCH(seq); - a size below the start: its root must lead to the root of the start by a consistency proof from
nodes.jsonl; when the bundle lacks a node of it, noteOUT_OF_SCOPE(seq) and do not use it; - a size above the last entry read:
TRUNCATED(seq); - otherwise its root must be the root of the tree of its size;
- and the incarnation of the origin must be that of the entry at its size, when the bundle holds it. A root or incarnation that does not match:
CHAIN_MISMATCH(seq).
A note both given and in
checkpoints.jsonlis checked once, by its note text, as the bundle format spec says for audit bundles.A checkpoint that passes matches. The report is
ANCHOREDwhen one matches. When the last entry read is after the largest size that matched, noteUNANCHORED_TAIL(seq: one after that size,count: the entries after it).Every
proofofcheckpoints.jsonl, of a trusted checkpoint or not, MUST lead from the root of the line it names to the root of its own line by RFC 9162, section 2.1.4.2; otherwise fail withCHAIN_MISMATCH(seq: the size of its own line). 6. Checkkeys.jsonand the manifest as an audit bundle's (MANIFEST_MISMATCH,BAD_SIGNATURE,KEY_NOT_VALID,KEY_COMPROMISED). The host files are anchored by a trusted signature of the manifest, by the manifest hash given, or by the log: aledger.bundle_manifestentry in scope whose digest is the host-files digest of the host files read, at asequp to the largest size a trusted checkpoint matched. Otherwise each host file is notedUNANCHORED. - a size above
The report has status (FAILED with any failure, else VALID_WITH_NOTES with any note, else VALID), anchor, verified_to (the seq of the last entry read, or the start when none was), failures and notes. The reference verifier also returns the head of the entries read and since, the start when it is above 0.
What a ledger bundle verifier cannot check¶
- The stored columns, nodes, state row and config table: a bundle carries none of them, so it never reports
COLUMN_MISMATCH,NODE_MISMATCH,ROOT_MISMATCH,STATE_MISMATCHorCONFIG_MISMATCH. - That the context entries before the scope are the newest of their types, or that every receipt before the scope is there: they are proven to be in the tree, not to be all of it. A missing receipt shows only where a journal line commits to it.
- Receipts and upgrade confirmations after the scope: they are outside the tree the bundle shows, so they explain a missing payload, complete the re-applied receipts of a
ledger.restoredin scope, or confirm a cluster change in scope, only as a note. - That a
ledger.upgrade_confirmedin scope is the first to name its cluster change, when an earlier one is before the scope. - The erasures a
ledger.restoredentry's journal lists above its proven size: no verifier can check them against the chain, only through the checkpoint's signatures. - That the bundle is the real chain, without a trusted checkpoint.
Stability¶
This format does not change within the 0.x minor releases after the one it ships in. A change to an encoding or a hash input gets a new domain tag; a change to the bundle layout gets a new bundle version. New package entry types are added as new types: a verifier that does not know one notes UNKNOWN_TYPE.
Reference command line¶
python -m audit_trail.integrity verify-bundle FILE --keys KEYFILE reads the stream type and checks a ledger bundle too, with --checkpoint (a ledger checkpoint note), --key-history, --manifest-sha256, --require-signatures, --require-anchor and --json. --retention, --transaction-retention and --system-severity do not apply to a ledger bundle and exit with 2. A finding's entry_id prints as text. This section is informative.
Test vectors¶
The vectors are under docs/spec/vectors/ledger/, each a bundle, <name>.zip, and a JSON file, <name>.json, with description, bundle, options (keys, checkpoints, key_history, require_signatures, manifest_sha256) and expected (status, anchor, verified_to, failures, notes, each finding with its kind and its fields that are not null, without detail), or {"malformed": true} for a bundle a verifier MUST refuse as malformed. A verifier passes a vector when it gives the same status, anchor and verified_to, and the same failures and notes in any order, each once; or, for a malformed one, when it refuses the bundle. Keys, entry ids, times and salts are fixed and the zip entries stored, so tests/unit/ledger_vectors.py (uv run python -m tests.unit.ledger_vectors) rebuilds the files byte for byte; a test fails when they differ, when a vector does not give its expected report, or when a kind a ledger bundle verifier reports has no vector.
Most vectors are built from one chain: ledger.chain_started, two notes with payload, a ledger.bundle_manifest of the host file, a ledger.checkpoint of size 4 signed by a trusted key, and a note. The restore vectors are built from a chain restored to size 4 after its history reached size 6, the receipt erasing entry 2 at 5 lost, under a signed checkpoint of size 6 with a journal line: ledger.restored at 5 starts incarnation 2 with the proven prefix of size 3 and a consistency proof from 3 to 6 kept before the restore, ledger.restored carries the journal, the receipt at 6 re-applies the lost erasure, and a note follows at 7.
| Vector | Shows |
|---|---|
valid |
VALID, ANCHORED: the whole chain, a checkpoint of its last entry given, the host file anchored by the log |
valid-range |
VALID: entries 3 to 6, from the frontier of size 2 and the context entries |
recorded-checkpoint-before-scope |
ANCHORED, UNANCHORED_TAIL: entry 6 alone, anchored by the checkpoint recorded at 5, of size 4, by a consistency proof from nodes.jsonl |
checkpoint-proofs |
VALID: two checkpoints in checkpoints.jsonl, the one of size 6 with the consistency proof from the one of size 4 |
checkpoint-proof-mismatch |
CHAIN_MISMATCH: that proof altered; both checkpoints still match |
manifest-sha256 |
VALID: another host file, anchored by the manifest hash given |
manifest-signed |
VALID: another host file, under a manifest a trusted key signed |
manifest-mismatch |
MANIFEST_MISMATCH, UNANCHORED: the host file changed after the manifest |
unanchored |
UNANCHORED: another host file, under an unsigned manifest |
unanchored-tail |
UNANCHORED_TAIL: only the checkpoint recorded at 5 |
seq-gap |
SEQ_GAP: the entries end before the scope |
truncated |
TRUNCATED, SEQ_GAP: a checkpoint given above the entries read |
leaf-mismatch |
LEAF_MISMATCH |
malformed-entry |
MALFORMED_ENTRY |
non-canonical |
NON_CANONICAL |
commitment-mismatch |
COMMITMENT_MISMATCH |
payload-missing |
PAYLOAD_MISSING |
erased |
ERASED: a receipt, and a checkpoint with a journal line |
receipt-mismatch |
RECEIPT_MISMATCH, ERASED |
chain-start-missing |
CHAIN_START_MISSING |
incarnation-mismatch |
INCARNATION_MISMATCH |
chain-mismatch |
CHAIN_MISMATCH, UNANCHORED_TAIL: a checkpoint given with another root |
checkpoint-mismatch |
CHECKPOINT_MISMATCH |
bad-signature |
BAD_SIGNATURE |
key-not-valid |
KEY_NOT_VALID |
key-compromised |
KEY_COMPROMISED |
unknown-key |
UNKNOWN_KEY |
clock-back |
CLOCK_BACK |
unexplained-incarnation |
UNEXPLAINED_INCARNATION |
cluster-changed |
CLUSTER_CHANGED: a pg_upgrade at 2, confirmed by ledger.upgrade_confirmed at 3 |
unconfirmed-upgrade |
CLUSTER_CHANGED, UNCONFIRMED_UPGRADE: a pg_upgrade at 2 and no confirmation |
upgrade-confirmed-range |
VALID: entry 3 alone, the confirmation; the cluster change it names is in context.jsonl |
upgrade-confirmed-after-scope |
CLUSTER_CHANGED, OUT_OF_SCOPE: entries 1 and 2; the confirmation at 3 follows the scope |
upgrade-confirmed-twice |
MALFORMED_ENTRY, CLUSTER_CHANGED: a second confirmation of the same cluster change |
upgrade-confirmed-elsewhere |
MALFORMED_ENTRY, CLUSTER_CHANGED, UNCONFIRMED_UPGRADE: a confirmation naming entry 1, not a ledger.cluster_changed |
unknown-type |
UNKNOWN_TYPE |
unchecked-signatures |
UNCHECKED_SIGNATURES |
out-of-scope |
OUT_OF_SCOPE: a receipt after the scope, and a checkpoint given after it |
restored |
ERASED: a restore, its proven prefix and a re-applied receipt, the whole chain |
restored-range |
ERASED: entries 5 to 7; the proven prefix ends before the scope, its proof nodes in nodes.jsonl |
restored-receipt-range |
ERASED: entries 6 and 7; the scope starts at the re-applied receipt, the ledger.restored entry in context.jsonl |
restored-receipt-after-scope |
OUT_OF_SCOPE, UNANCHORED_TAIL: entries 1 to 5; the re-applied receipt follows the scope |
restore-mismatch |
RESTORE_MISMATCH, ERASED: a ledger.restored entry with another lost range |
restore-forged-journal |
RESTORE_MISMATCH, RECEIPT_MISMATCH, ERASED: a restore under a checkpoint at its restored size whose journal line commits to an erasure the chain's receipts do not hold, and the receipt re-applying it |
restore-unsigned |
RESTORE_MISMATCH, ERASED: the restored chain under an unsigned checkpoint, verified with trusted keys alone |
restore-unsigned-history |
RESTORE_MISMATCH, ERASED: the same, with a key history |
restore-unsigned-required |
RESTORE_MISMATCH, ERASED: the same, with signatures required |
restore-unknown-key |
UNCHECKED_SIGNATURES, ERASED: the restored chain under a checkpoint signed only by an unknown key, without a key history or signatures required |
restore-reapplied-elsewhere |
RECEIPT_MISMATCH, ERASED: a re-applied receipt naming the journal's receipt but erasing another entry |
restored-twice |
RESTORE_MISMATCH: a second ledger.restored explaining an incarnation that restore detection started and the first one explains |
id-uppercase |
NON_CANONICAL: a body id in uppercase; the finding names it in lowercase |
non-canonical-twice |
NON_CANONICAL: a body with a space and an id in uppercase, one finding |
type-version-fraction |
MALFORMED_ENTRY: a type_version of 1.0, not an integer; the finding names the body's id |
declared-at-offset |
MALFORMED_ENTRY: a declared_at ending in +00:00, not a timestamp |
declared-at-no-fraction |
MALFORMED_ENTRY: a declared_at without fraction digits |
no-encoding |
NON_CANONICAL: attributes holding U+0000, with no canonical encoding, and no COLUMN_MISMATCH |
seq-gap-middle |
SEQ_GAP, TRUNCATED: entry 3 missing; the run stops at the gap, verified to 2 |
entry-after-scope |
Malformed: entries.jsonl holds an entry after last |
context-whitespace |
Malformed: a context line in scope differs from its entries.jsonl line by a space |
appended-at-space |
Malformed: an appended_at with a space before it |
checkpoint-reserved-line |
Malformed: a checkpoint of checkpoints.jsonl with an extension line starting with SQLAlchemy-Audit-Trail/ |
appended-at-short-fraction |
Malformed: an appended_at with three fraction digits |
receipt-target-missing |
RECEIPT_MISMATCH, PAYLOAD_MISSING: the receipt's target is in entries.jsonl but not in context.jsonl |
erased-before-scope |
ERASED: entries 3 to 7; the receipt in scope erases entry 2, before the scope |
journal-receipt-after-size |
ERASED: a checkpoint of size 3 with the empty journal, the receipt at 4 erasing entry 2 |
host-files-zip-order |
VALID: two host files out of name order in the zip, anchored by a digest over them in zip order |
commitment-not-group |
MALFORMED_ENTRY: a body committing to Name, which is not a group name |
restore-unsigned-no-keys |
RESTORE_MISMATCH, ERASED: the restored chain under an unsigned checkpoint, verified with an empty set of trusted keys |
upgrade-confirmed-after-failed |
MALFORMED_ENTRY, CLUSTER_CHANGED: a cluster change between negative system identifiers; a confirmation naming another incarnation fails, and the next one confirms it |
out-of-scope-receipt-id |
OUT_OF_SCOPE: a receipt after the scope names an entry read by its entry id and another seq |
context-in-scope-after-gap |
SEQ_GAP, TRUNCATED: context.jsonl holds entry 2 in scope, entries.jsonl lacks it; not malformed |
checkpoint-blank-line |
Malformed: a checkpoint of checkpoints.jsonl with an extension line of a space only |
scope-beyond-64-bits |
Malformed: a scope whose last is 264 |
receipt-seq-beyond-64-bits |
MALFORMED_ENTRY: a receipt naming seq 264 |
out-of-scope-receipt-braced-id |
PAYLOAD_MISSING: a receipt after the scope names an entry read by its entry id in braces, which is not a UUID |
restored-twice-range |
RESTORE_MISMATCH: entry 6 alone of restored-twice; the first ledger.restored is in context.jsonl |
restored-after-restored-start |
RESTORE_MISMATCH: a second ledger.restored explaining an incarnation the first one started |
identity-after-malformed |
MALFORMED_ENTRY, CLUSTER_CHANGED, UNCONFIRMED_UPGRADE: a ledger.cluster_changed with an attribute too many fails, and the next one's from is not compared with its to |
displaced-checkpoint |
ANCHORED, UNANCHORED_TAIL: entry 7 alone; checkpoints.jsonl holds an unsigned checkpoint recorded after the signed one, and the signed one, which anchors |