Skip to content

id: keep versions and reports on disk through id_store::content_store - #12497

Merged
dezren39 merged 5 commits into
mainfrom
xaltha/id-record-store-disk
Nov 22, 2026
Merged

dezren39 merged 5 commits into
mainfrom
xaltha/id-record-store-disk

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes #12492

Stacked on #12470 (B2(a)): this PR is based on xaltha/id-record-join-admission and retargets to main when that merges. The diff against main includes #12470 until then.

Summary

  • New module pkgs/id/crates/id-sync/src/federation/record_store.rs (declared in federation/mod.rs in this change): a node keeps its versions and reports on disk through id_store::content_store, so it restarts with what it had.
  • Canonical encodings, domain-separated in the b07/b32 field style, for the two records kept: a version record (the B32 gate Envelope — which had no canonical encoding — plus ingress path, source, and admitted-at time) and a report record (a StoredReport: the report's canonical bytes plus its status, with a decoder for the canonical form).
  • A NodeStore ingests both as verified content under raw-blake3-256 content ids over iroh's FsStore (the production on-disk backend), with a small index file in the node directory naming the records: version records in admission order, latest record per report id. Content is digest-verified again on every load by ContentStore::get.
  • A StoredReplica owns a Replica and a NodeStore and presents the sync path's surface. Write-through: admissions persist at produce/receive; versions admitted during an exchange persist at the exchange's end, from the exchange's own outcomes; new or changed reports persist at the same points. Opening replays the version records through Replica::receive (same gate, same join check, same nows) and rebuilds the store exactly; persisted report records are checked against the rebuilt reports, a record lost to a crash between the two writes is re-written, and any other divergence is an error.
  • Nothing in b07/b09 changes: store and replica are driven through their existing public APIs, so the path-loaded slice suites are untouched.
  • Recorded scope limits: refusals are not persisted (re-refused deterministically on re-offer); report expiry is not reachable through a Replica, so replay reproduces the reports map exactly; one writer per node directory.
  • Plan step B2(b) in planning/plans/2026-11-21_results-first.md is recorded as landed; (c) transport between two processes is next.

Evidence

  • cargo test --manifest-path pkgs/id/Cargo.toml -p id-sync --test substrate_sync_path — 5 passed. The new restart test runs the exchange between disk-backed nodes dropped and reopened between steps: B restarts and reads the record from its address with no exchange; both restart and keep the open report under the same id with the same conflict key, versions and base; a post-restart resolution stays closed across a further restart. The four existing tests pass unchanged.
  • Mutation check: with the replay loop in StoredReplica::open disabled, the restart test fails at the first reopened-node assertion; restored, it passes.
  • cargo test --manifest-path pkgs/id/Cargo.toml -p id-sync --lib record_store — 5 passed (envelope/version-record/report-record codec round-trips, report id preserved; node-store round-trip in admission order; stored-replica restart over an in-memory backend).
  • cargo test -p id-sync --test federation_b07 — 11 passed; --test federation_b09 — 8 passed.
  • bash .github/scripts/check-rust-module-reach.sh — OK (819 files in 91 crates, all reached).

Merge Danger

  • No existing API changes: the slice is one new module, one new test, one plan line. Replica/ConflictStore behavior is unchanged for in-process nodes.
  • A node directory is reopened only after its blob store is shut down (StoredReplica::shutdown, the in-process form of a process exit): iroh's FsStore keeps its database locked after a plain drop — found by the restart test hanging on the second FsStore::load, isolated to the backend, and fixed by holding the api handle in the new FsBlobs backend wrapper.

Run Proof on this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…#12492)

New federation::record_store module beside record_join: canonical
encodings for the gate Envelope (none existed) and for StoredReport,
a NodeStore that ingests version records and report records as
verified content over iroh's FsStore behind id_store::content_store
with a small index file naming them, and a StoredReplica that writes
admissions and report changes through at produce/receive and at the
end of every exchange. Opening a node replays its version records
through Replica::receive and checks the persisted report records
against the rebuilt reports. Nothing in b07/b09 changes.

The substrate sync-path test gains a restart test: the same exchange
between disk-backed nodes dropped and reopened between steps, reading
from id:// addresses with no exchange after a restart, the conflict
report surviving under the same id, and a post-restart resolution
staying closed across a further restart. Plan step B2(b) ticked.

Stacked on #12470 (B2(a)).
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 10:20
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fceb2b9-8615-4ffd-89ed-47bda6e8a376
Commits

Reviewing files that changed from the base of the PR and between 9b5e17c and 90350a6.

Files selected for processing: 4

  • pkgs/id/crates/id-sync/src/federation/mod.rs
  • pkgs/id/crates/id-sync/src/federation/record_store.rs
  • pkgs/id/crates/id-sync/tests/substrate_sync_path.rs
  • planning/plans/2026-11-21_results-first.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T19:05:10.173570Z 90350a6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a575adc386

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- stale report record heals on open (thread 1, P1)
- failed version/report persist rolls the admission back, retry
  succeeds (thread 2, P2); failed reconcile rolls both sides back
- failed open releases the blob store (thread 4, P2)
- proptest codec round-trips and restart-equivalence against the
  in-memory Replica model (thread 3, P1)

These fail on the current head; the fixes follow.
…dmission rollback, backend shutdown on failed open

- Thread 1 (P1): a write-through point now stages the version and
  the reports it changed and publishes them in one index update
  (write-then-rename), so a crash leaves the old index or the new
  one, never a version without its reports. Opening also heals a
  stale report record: a report id is the hash of its canonical
  bytes, so a record under a rebuilt id can only be stale in status
  and is re-written from the replay; an unknown id is still
  ReportDiverged.
- Thread 2 (P2): a persist failure in produce/receive rolls the
  admission back (replica and index restored), so the envelope
  retries instead of being rejected as a replay and no child can be
  admitted on an unpersisted version; reconcile_with rolls both
  sides back.
- Thread 3 (P1): the failing-first commit already added proptest
  codec round-trips (envelope, version record, report record) and a
  model-based restart-equivalence test against the in-memory
  Replica; verified adequate, no further coverage added.
- Thread 4 (P2): DiskReplica::open_dir retains a backend handle
  and shuts it down when NodeStore::new or StoredReplica::open
  fails, so the directory can be retried in the same process.

Tests in 099edca define the expected behavior; compile/test
verification is by CI (no local rustc in this seat).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef127c76cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39

Copy link
Copy Markdown
Member Author

Picked up queue task 21071 to shepherd PR #12497. I found one new Codex review finding on cancellation during async persistence; validating it against current main and the existing branch before deciding the safe next action.

@dezren39 dezren39 added work/assigned Queue worker lifecycle state queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state labels Nov 22, 2026
…e-disk

# Conflicts:
#	planning/plans/2026-11-21_results-first.md
@dezren39
dezren39 merged commit d058c35 into main Nov 22, 2026
1 check passed
@dezren39
dezren39 deleted the xaltha/id-record-store-disk branch November 22, 2026 19:04
dezren39 pushed a commit that referenced this pull request Nov 22, 2026
…2232)

README gains 'The #9106 walking skeleton, by hand' — the five
steps as id walk commands, from a real run of the binary.
Registry: walk_cli_path joins id.rust.substrate-path (the
nightly runs it with the other substrate suites). Plan: B2(b)
marked landed (PR #12497), B3 marked landed with this PR, and
the Track B summary row updated. Plus rustfmt on the new code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state work/assigned Queue worker lifecycle state

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id: keep versions and reports on disk through id_store::content_store (#12232 slice 4)

1 participant