Repository navigation
id: note policies survive a real host restart — persist + restore the checkpoint snapshot (#3819) - #12708
Merged
Conversation
Failing-first oracle for the host persistence wiring slice: a live CollabState with a snapshot path persists its checkpoint log as it mutates; a fresh state over the same file restores events and policies, so a scoped note stays scoped (granted user and group member chain on, stranger refused, refusal records nothing) and a public note stays public. A corrupt snapshot must fail the restart, never silently reopen notes.
The snapshot API from the previous slice had no caller across a restart: the serving host built its CollabState memory-only, so a rebuilt checkpoint log still reopened every scoped note as public in the running server. - id-store: AppliedNote is now Serialize/Deserialize — its fields already were — so the log's events have a durable form alongside the policy records. - id-web: NoteCheckpointSnapshot (events + policies in one document) with CollabState::note_snapshot / restore_note_snapshot (events first, then policies, validated as a whole) and a snapshot path installed by with_note_snapshot_path. Every mutation that leaves the log in a complete state — a publication, a policy change, a full restore — rewrites the file atomically (temp name + rename); a write failure is logged, never misreported as a failed mutation. restore_persisted_note_snapshot treats a missing file as a fresh host and a corrupt or non-folding file as a failed restart. - id-web serve path (web_routers_with_surface): the collab state gets the snapshot path beside the identity store (.note-checkpoints.json next to .identity.redb) and restores before any router serves; a bad snapshot fails startup. Oracle: the host restart drill — a live state persists as it mutates; a fresh state over the same file restores, and the boundary holds (granted user and group member chain on, stranger refused with nothing recorded) while a public note stays public. Plus a corrupt-snapshot test: failed restart, not silent reopen. Verification (laptop, pkgs/id dev shell): the two new tests pass; cargo test -p id-store -p id-web --lib: 244 + 737 passed, 0 failed (id-web 735 baseline + 2 new); cargo fmt --check clean; no clippy findings in the touched files.
|
Warning Review limit reachedYou'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 22 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 22, 2026
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.
Part of #3819 — slice 1 of the remainder named in the Lane AD record: host persistence wiring for the note-policy snapshot API landed in #12637.
The gap
The snapshot pair existed (
NoteCheckpoints::policies()/seed_policies(),CollabState::note_policies()/seed_note_policies()) and the restart path was proven at the log/session layer — but no host called it across a real restart.web_routers_with_surface(theid servepath) built itsCollabStatememory-only, so a restarted server still reopened every scoped note as public. The events side also had no durable form:AppliedNotelacked the serde derives its fields already carry.What lands
AppliedNoteis nowSerialize/Deserialize— the events are the durable form of the log, persistable alongside the policy records.NoteCheckpointSnapshot(events + policies in one document — never written or read apart),CollabState::note_snapshot()/restore_note_snapshot()(events first, then policies, validated as a whole viafrom_events_with_policies), and a snapshot path installed bywith_note_snapshot_path. Every mutation that leaves the log in a complete state — a publication, a policy change, a full restore — rewrites the file atomically (temp name + rename in the same directory). Persist is deliberately not hooked into the individual seed steps, so the file never holds an events-only intermediate that would reopen notes as public after a crash. A write failure is logged, not propagated: the mutation already landed in memory.web_routers_with_surfaceinstalls the snapshot path beside the identity store (.note-checkpoints.jsonnext to.identity.redb) and restores before any router serves. Missing file = fresh host; a file that does not parse or does not fold fails startup — per the seed API's contract, a refused restore is a failed restart, never a silent reopen.Oracle and evidence
Failing first (tests-only commit
14bf14a764a): compile fails with exactly the missing pieces —cannot find type NoteCheckpointSnapshot,no method named with_note_snapshot_path(5 errors).The oracle is the host restart drill,
test_note_policies_survive_a_host_restart_through_the_snapshot_file: a live state with a snapshot path persists as it mutates (file parses; 2 events, 2 policy records); a fresh state over the same file restores — granted user and group member chain onto the scoped note, a stranger is refused and the refusal records nothing, and a public note stays public for the same stranger. Plustest_a_corrupt_note_snapshot_fails_the_restart_not_opens_notes.Verification (laptop,
nix developinsidepkgs/id):cargo test -p id-store -p id-web --lib: id-store 244 passed / 0 failed (unchanged from baseline), id-web 737 passed / 0 failed (735 baseline + 2 new).cargo fmt --check -p id-store -p id-web: clean. No clippy findings in the touched files (workspace-D warningsclippy debt in unrelated crates is the standing clippy-lint gate red since 2026-11-02: 571 deny-level sites in pkgs/id (campaign) #6462 campaign, untouched here).Merge danger
Low-moderate. Behavior change is confined to the serve path: a host that has never checkpointed a note sees no file and no change. A host with a snapshot restores it at startup; a corrupt snapshot now fails startup loudly instead of serving notes reopened to public — that loudness is the point. No wire or storage format changes elsewhere;
AppliedNote's new derives are additive.Remainders on #3819, unchanged and in order: (2) replica sync of policies (needs the
note.policyordering-rule design note first), (3) wire-level tests.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.