Expand description
Ledger integrity across the three places an entry lives.
- cache —
asd_ledger_cachein SQLite. Written by everyappend_entryand never deleted from, so it holds every entry ever acknowledged. Readers serve from it first. - ASG —
/asd/v1/ledger/<symbol>/<entry>, the authoritative store and the only thingasd syncexports. - sidecar —
.asd/v1/ledger/<symbol>/<entry>.json, whatasd syncwrote and whatasd hydraterestores from.
Before ASG compare-and-swapped its refs, concurrent writers and asd index speculation commits discarded ledger commits from ASG after the
cache had recorded them (1,684 of 12,085 on one store). Every surface kept
working because reads come from the cache, so the loss was invisible
until a hydrate came back short. This module makes the three counts
visible and restores cache-only entries into ASG.
Structs§
- Ledger
Counts - Ledger entry counts in each store, plus the gaps between them.
- Ledger
Restore Report - Outcome of
restore_missing_ledger_entries.
Functions§
- asg_
ledger_ entry_ ids - Every entry id in the ASG ledger tree, across all symbols.
- ledger_
counts - Count ledger entries in the cache, ASG and (when
sidecar_rootis given and has one) the sidecar, and the gaps between them. - missing_
ledger_ entries - Cached ledger entries whose
entry_idappears nowhere in the ASG ledger tree. Matching by id rather than path means an entry moved byledger rebind(whose cache row follows it to the new symbol) is never mistaken for a lost one. - restore_
missing_ ledger_ entries - Write every cache-only ledger entry back into ASG, with its reverse-index record, exactly as the cache holds it. Each restore is its own commit so the audit trail says what was recovered and from where.
- sidecar_
ledger_ entry_ ids - Every entry id under
<root>/.asd/v1/ledger/, orNonewhen the sidecar has no ledger directory.