Repository navigation
feat(ledger): backfill, anchor, verify-anchors and project in process - #55
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the ledger maintenance tools from eb-staged-rebuild, which ran them as
python -m eb_staged_rebuild.ledger_maintenanceand shelled out toeb-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 totests/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 --locked1993 passed;tests/ledger_maintenance.rs33 passed,tests/mcp_v1.rs52 passed.Merge before eb-staged-rebuild
refactor/ledger-to-eb-stack.