Skip to content

feat(ledger): backfill, anchor, verify-anchors and project in process - #55

Merged
HaoZeke merged 11 commits into
mainfrom
feat/ledger-maintenance
Nov 18, 2026
Merged

HaoZeke merged 11 commits into
mainfrom
feat/ledger-maintenance

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Moves the ledger maintenance tools from eb-staged-rebuild, which ran them as python -m eb_staged_rebuild.ledger_maintenance and shelled out to eb-stack ledger head/verify/append, into eb-stack next to those verbs. Each runs in process, prints one JSON object, refuses with status 2 and returns 75 when an append or signature did not finish. Each has its MCP tool, as every CLI command does (catalog 60 to 64). The 33 cases of the Python suite are ported to tests/ledger_maintenance.rs; cases that only corrupted or hung the eb-stack subprocess have no counterpart, and crash cases build the state a crash leaves instead of injecting faults. Event ids and schema names are kept, so a rerun over an existing log is acknowledged as already recorded. Projection files keep owner and mode on replace, not extended ACLs.

Checked on an x86_64 host: cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test --locked 1993 passed; tests/ledger_maintenance.rs 33 passed, tests/mcp_v1.rs 52 passed.

Merge before eb-staged-rebuild refactor/ledger-to-eb-stack.

Port the observed-history backfill, daily anchor and package history
projection from eb-staged-rebuild's ledger maintenance module into the
library, calling ledger::append, ledger::sign_head and ledger::verify
directly instead of the eb-stack binary.

The manifest format and its SHA-256 pin, the anchor directory layout,
lock files and never-replace rule, the projection files and their bytes,
and the refusals keep their behaviour. The schema names and backfill
event ids keep their eb-staged-rebuild/ spelling, so a rerun over an
existing log is acknowledged as already recorded.

Dropped because they existed only for a subprocess: the --eb-stack
executable check, the per-call timeout, the bounded output reader, the
parsing of stdout receipt lines, and the fault injection points. The
in-process receipts are checked from the reports the library returns.
Log lines are parsed by ledger::parse_log, which also recomputes ids and
checks timestamps, so a tampered line is a verification failure at read
time. Projection files keep owner and mode across a replace but not
extended ACL attributes.

tempfile moves from dev-dependencies to dependencies for the private
verification and staging directories.
Each prints its result as one JSON object with sorted keys. A refusal is
exit status 2; an append or signature that did not finish is 75, so the
same command can be run again.
eb_ledger_backfill, eb_ledger_anchor, eb_ledger_verify_anchors and
eb_ledger_project run the same library calls as the CLI and return its
JSON summary with the printed text. The catalog grows to 64 tools.
Every case of eb-staged-rebuild's ledger maintenance suite runs against
real logs, heads and anchors written by the library. Cases that crashed
a run at a fault injection point now build the state such a crash
leaves (a first append only, a staging directory with an unlinked head,
half-written package and index temporaries) and check that a rerun
completes. Cases that wrapped the eb-stack binary to corrupt its stdout
receipts or to hang it past --timeout have no counterpart: there is no
subprocess. The command-line case checks status 75 through an append
the ledger refuses.
caf\u{e9} matched codespell's caf->calf rule; r\u{e9}sum\u{e9} keeps the
same two-byte percent-encoding case.
An inline literal that ends in a space is not an RST literal, so the
generated API page failed the Sphinx build.
@HaoZeke
HaoZeke merged commit e949a0f into main Nov 18, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant