Skip to content

feat(id): generic event-body persistence, retrieval and range-sync (#4837) - #7657

Merged
dezren39 merged 1 commit into
mainfrom
queue/13568-4837-event-body-persistence
Nov 13, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/13568-4837-event-body-persistence

Conversation

@developing-today

@developing-today developing-today Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4837

Generic event-body persistence for pkgs/id's event store — the prerequisite the didit tracker phases (#2031) were missing: store_event persisted headers only, ingest verified bodies against the header and dropped them, and range sync carried no bodies.

What changed

  • Storage (event_store/mod.rs): new bodies table (event ID → body bytes); store format bumped to id.events.store.v9 (previous-format stores are refused and keep their data, as with prior bumps — covered by the existing format test).
  • Ingest (event_store/ingest.rs): the verified body from ingest_with_body is threaded through ingest_event/ingest_in/settle and stored when its event is accepted, held, or parked; a body arriving later for a header-only stored event is stored on the duplicate path (and counts as a change, so the transaction commits). New ingest_events_with_bodies batch entry point verifies every body against its signed header (BLAKE3 hash + size) before storing — a non-committed body refuses its event in place and stores nothing.
  • Retrieval: EventStore::event_body(id) returns the body byte-identically, or the new typed StoreError::MissingBody when the event is header-only, its body never arrived, or the ID is unknown. Header-only events are otherwise unaffected.
  • Range sync (event_store/sync.rs, store_traits.rs): data-phase records now carry the body after the event bytes (length-prefixed by the event length); the receiver checks the body against the header commitment before ingest and stores it through the batch path. The now-unused body-less RangeStore::ingest_events shim was removed.

Tests

cargo test --lib event_store in pkgs/id: 134 passed, 0 failed (was 133 + this change's new tests net +5, one pre-existing test adapted to the batch tuple shape).

New tests:

  • body stored at ingest and read back byte-identically
  • missing body is the typed MissingBody not-found (stored header-only and unknown ID)
  • body arriving after its header is stored on the duplicate path
  • a batch body that is not the committed one refuses its event; the committed body is stored
  • range sync carries bodies: a loopback session delivers bodies to the peer store, read back byte-identically

Queue task 13568 (lane code-w).


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

@developing-today
developing-today Bot requested review from a team and dezren39 as code owners November 8, 2026 11:21
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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: 9e689f36-77e9-4fbb-ae36-cfb4408b3831

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

…4837)

Port of PR #7657 commit 8ae8bd2 onto main across the pkgs/id crate split: FORMAT v9 bodies table, EventStore::event_body/stored_body, ingest_with_body, range-sync body carriage. StoreError::MissingBody lands in id-store event_types.rs; the SharedEventStore range_body/range_ingest_with_bodies surface lands in id-store store_traits.rs over the generic EventStoreBackend seam (new stored_body/ingest_events_with_bodies backend methods, delegated by the id-events impl); ingest reconciled with the current flow (body passed through to ingest_event, writer-body retention and device ops unchanged); ported test constructor gains the chat field main added to ChainExt.
@dezren39
dezren39 force-pushed the queue/13568-4837-event-body-persistence branch from 8ae8bd2 to 9650bf7 Compare November 13, 2026 09:44
@dezren39

Copy link
Copy Markdown
Member

Agent note — ported onto current main across the crate split (task 15861, lane any-d, 2026-11-13)

This PR's original commit (8ae8bd2) predated the pkgs/id crate split and no longer applied to main. It has been ported in a dedicated worktree and this branch force-updated (force-with-lease against 8ae8bd2) to the ported head 9650bf7 — a single commit on current main (46bf43a) with the same change, re-seamed:

  • StoreError::MissingBody lands in pkgs/id/crates/id-store/src/event_types.rs (the StoreError enum's post-split home).
  • The SharedEventStore range_body / range_ingest_with_bodies surface lands in pkgs/id/crates/id-store/src/store_traits.rs over the generic EventStoreBackend seam: two new backend methods (stored_body, ingest_events_with_bodies), delegated by the id-events EventStore backend impl. The old range_ingest_events had no other callers and is replaced, as in the original commit. pkgs/id/src/store_traits.rs stays the re-export facade.
  • The event_store changes land in pkgs/id/crates/id-events/src/event_store/{mod,ingest,sync}.rs, reconciled with main's current ingest flow: the verified body passes through ingest_event into the shared ingest_in path (which stores bodies in-transaction), while writer-body retention and device-op recording (id: resolve device-admin identity in event-store tag views #5656) are unchanged. The ported test constructor gains the chat field main added to ChainExt.

Verification on the laptop at head 9650bf7:

  • cargo check -p id-events -p id-store — pass
  • cargo test -p id-events event_store — 140 passed, 0 failed (incl. test_a_body_is_stored_at_ingest_and_read_back_byte_identically, test_a_missing_body_is_a_typed_not_found, test_a_body_arriving_after_its_header_is_stored, test_a_batch_body_that_is_not_the_committed_one_refuses_its_event)
  • cargo check -p id — pass (the id build without the world feature)

No prior review findings existed on this PR to disposition (no formal reviews; CodeRabbit skipped the old head). Merging on local verification per standing fleet practice while Actions checks are stalled fleet-wide.

@dezren39
dezren39 merged commit d18dd19 into main Nov 13, 2026
1 check passed
@dezren39
dezren39 deleted the queue/13568-4837-event-body-persistence branch November 13, 2026 09:47
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.

id: generic event-body persistence, retrieval and range-sync — prerequisite for the didit tracker phases (#2031)

1 participant