Skip to content

id: build: durable multiplayer note checkpoints and merges #3819

Open

Description

@dezren39

Parent: #2048 (ID Zettelkasten design). Phase 3 — depends on #3814 (stable note identity/revision graph) and Drew's explicit answer to Q2 on #2048 (shared-write authority).

Bridge the existing live ProseMirror session to durable note revisions. Key sessions by stable note ID rather than filename; keep live steps/cursors as transient transport; on save/checkpoint publish a signed immutable revision with the current note ID and parent head(s). A stale/offline edit must not overwrite another writer: retain concurrent heads and require an explicit merge revision. Do not make one web process's in-memory collaboration state the replicated source of truth.

Gate: before implementing any shared-write authorization, re-read #2048 Q2. Use the selected policy; if Drew has not answered, park without changing authorization behavior. Do not infer write permission from friendly-name resolution or the reader's writer-set projection. No cross-store resolver work (that remains #2259).

Acceptance:

  • Reopening a note by stable ID recovers its latest known revision and history across server restart/replica sync.
  • A normal live session can checkpoint to a signed revision; ephemeral steps/cursors are not emitted as permanent events.
  • Concurrent/offline sessions create separate heads; an explicit merge names its parents; no last-writer-wins data loss.
  • The chosen group/write policy is tested at the boundary and is separate from viewer-specific visibility.
  • Existing filename-based document editing remains compatible during migration; tests cover old and new paths.

Activity

  1. added
    priority/highImportant and time-sensitive
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    on Nov 1, 2026
  2. developing-today commented on Nov 1, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — queued, parent #2048 phase 3; queue task 5826, dedupe repo-health:v1:fix:developing-today/code:issue:3819. Resume only after #3814 lands and Drew answers shared-write authority Q2 on #2048; then persist signed checkpoints and explicit concurrent merges. Filed by repo-worker-code, OpenChamber scheduled lane, 2026-11-01T16:54Z.

  4. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 1, 2026
  5. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked — claimed early; both start gates in the packet are unmet

  6. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

  7. 141 remaining items

  8. added a commit that references this issue on Nov 18, 2026
  9. removed their assignment
    on Nov 20, 2026
  10. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: progress
    task: 9602
    lane: xaltha

    Fresh re-verification (2026-11-22): #3819 still OPEN. All four Phase 3 slices are merged (#10808, #10831, #10843, #10846) and the group resolver landed via #11732, but the access-boundary acceptance is not complete: a checkpoint log rebuilt from its events treated every note as public, because policies lived only in the log's in-memory map and from_events dropped them.

    This run worked the blocker instead of re-triaging it. Slice PR #12637 (#12637, branch xaltha/9602-3819-note-policy-restart, commit 455cef1) makes policies durable in snapshot form: NotePolicyRecord (serde) + policies() / seed_policies() / from_events_with_policies() in id-store, note_policies() / seed_note_policies() on CollabState. Five new tests prove a scoped policy (user grant, group grant, owner) and its authorization survive a restart rebuild, and that mis-ordered or corrupt seeding is refused. Laptop evidence: cargo test -p id-store -p id-web --lib polic — 5 passed id-store, 3 passed id-web, 0 failed. Full note_checkpoints/collab module runs not done in this slice (laptop shell route degraded); CI is the backstop.

    Remaining on #3819: persisting the events+policies snapshot in the host (today nothing persists either), syncing policies to replicas (a note.policy event kind, which needs an ordering rule), and wire-level tests.

  11. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Progress on PR #12637 — Codex P2 review thread answered and fixed.

    What was fixed: The Codex thread (review of 455cef1) found that a rebuilt log rejected its own valid policy snapshot when a note had a revision whose ID sorts before its create event and whose author differs from the creator: NoteCheckpoints::access() derived the owner from record.revisions.first(), while fold_notes sorts revisions by ID. Commit bd7252d ("fix(id): validate restored note owners against the create event author (#3819)") derives the owner directly from the create event instead — the revision whose ID is the note's ID (record.revision(note)?.author) — fixing both restore paths (from_events_with_policies and the two-step from_events + seed_policies). It also corrects the stale NoteRecord.revisions doc comment in notes.rs that claimed the first sorted revision is the create. A regression test (test_restored_owner_comes_from_the_create_event_not_the_first_sorted_revision) covers a revision by another author whose ID sorts before the create event, asserting both restore paths accept the persisted snapshot.

    Thread status: the one Codex thread (PRRT_kwDOJWP47866mHw2) is answered — reply: #12637 (comment) — and resolved. No unresolved review threads remain on the PR.

    What still blocks merge: CI on the new head bd7252d. Checks were SUCCESS on the previous head (455cef1); the fix commit was just pushed and CI has not reported yet (combined state pending; only CodeRabbit neutral so far). The fix was not compiled locally — no Rust toolchain in this seat — so CI is the first compile/test run. Nothing was merged.

  12. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Lane AD (archer) claimed queue task 9602 via #5535: shepherding PR #12637 ("id: note policies survive a checkpoint-log rebuild") to a verdict — full review against this issue's acceptance criteria plus independent test verification on the PR head — then a remainder assessment on #3819 and #5535. No new Phase 3 implementation under #5535.

  13. added a commit that references this issue on Nov 22, 2026
  14. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    PR #12637 merged (merge commit 2ba5263dfacd5965c4226fc9c67cad15d65e584c, head bd7252dd0) — shepherded by Lane AD under queue task 9602 (via #5535). This issue stays open; what the PR settled and what remains:

    Settled by #12637

    • The policy half of the boundary acceptance: the Q2/Q3 policy (public by default; scoped user/group grants) now survives a checkpoint-log rebuild. Before, NoteCheckpoints::from_events rebuilt every note as Public, so a scoped note silently reopened after a restart and a stranger's append was lawful. Now policies() snapshots the effective policy of every note and seed_policies() / from_events_with_policies() re-state it after a rebuild (events first, then policies), refusing corrupt input atomically — a record for an unknown note (UnknownNote) or naming an owner other than the create event's author. CollabState::note_policies() / seed_note_policies() expose the pair on the session path.
    • Owner derivation fixed en route (Codex P2, commit bd7252dd0): access() reads the owner from the create event — the revision whose ID is the note's ID — not the first ID-sorted revision, which a later revision can precede.
    • Tests pin the restart path, not just in-memory state: id-store (test_a_scoped_policy_survives_a_restart_rebuild, test_seed_policies_refuses_unknown_notes_and_wrong_owners, test_restored_owner_comes_from_the_create_event_not_the_first_sorted_revision, test_policies_snapshot_serializes_for_the_host_to_persist) and id-web's production CollabState (test_note_policies_survive_a_restart_rebuild — granted user and group member checkpoint after a rebuild, stranger refused and the refusal records nothing; test_seed_note_policies_before_events_is_refused).

    Independent verification (Lane AD, not the author's runs)

    • fleet-run 45060419204 on PR head bd7252dd0, in the pkgs/id dev shell: cargo test -p id-store -p id-web --lib → id-store 244 passed / 0 failed, id-web 735 passed / 0 failed. This includes the full note_checkpoints and collab:: module runs the PR body listed as not run.

    What remains on #3819 (unchanged by this PR, named precisely)

    1. Host persistence wiring — nothing yet persists the events+policies snapshot or re-seeds it on startup: the API pair exists, but no host code calls it across a real restart. Acceptance bullet 1 is now proven at the log/session layer, not yet end-to-end in the serving host. Bounded next slice: persist note_events() + note_policies() with the host's checkpoint snapshot and re-seed (events, then policies) on startup, with a host-level restart test.
    2. Replica sync of policies — policies still do not travel with the events: a peer that rebuilds from events alone treats scoped notes as public. The named vehicle is a note.policy event kind, which needs an ordering rule (design note first). Acceptance bullet 1's replica-sync half and the boundary on replicas stay open until then.
    3. Wire-level tests for both wirings.

    The remaining acceptance bullets (checkpoint to a signed revision without emitting ephemeral steps/cursors; concurrent heads with explicit merges; filename-based editing compatibility) rest on the previously landed checkpoint-log work and are untouched by this PR.

  15. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Lane AW claiming slice 1 of the #3819 remainder (per the Lane AD record): host persistence wiring.

    Premise (from PR #12637, merged 2ba5263dfa): the snapshot API pair exists — NoteCheckpoints::policies() / seed_policies() / from_events_with_policies() in id-store, CollabState::note_policies() / seed_note_policies() alongside note_events() / seed_note_events() in id-web — and the restart path is proven at the log/session layer. What is missing: no host persists the events+policies snapshot or re-seeds it on startup, so acceptance bullet 1 is not yet end-to-end in the serving host.

    Slice: persist note_events() + note_policies() with the host's checkpoint snapshot and re-seed (events first, then policies) on startup, with a host-level restart test as the oracle — set a non-Public policy, restart the host state, assert the policy is still in force (and a Public note stays Public).

    Out of scope for this slice, in order: (2) replica sync of policies (needs the note.policy ordering-rule design note first), (3) wire-level tests. #5535 unchanged.

  16. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Slice 1 of the remainder is landed: host persistence wiring. PR #12708 merged (773a306a014ef0495ac518114732b5b9f58cb4bc).

    Premise (verified on main dee25f7dbf6): the snapshot pair from #12637 existed with no caller across a restart — web_routers_with_surface (the id serve path) built its CollabState memory-only. One gap inside the gap: AppliedNote carried no serde derives (its fields already do — the same types NotePolicyRecord serializes), so the events half of the snapshot had no durable form at all until this slice added them.

    The wiring:

    • id-store: AppliedNote is Serialize/Deserialize — the events are the durable form of the log.
    • id-web: 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 via from_events_with_policies); a snapshot path installed by with_note_snapshot_path. Every mutation that leaves the log in a complete state — a publication (publish_note_checkpoint_text, so create + checkpoint), a policy change (set_note_access), a full restore — rewrites the file atomically (temp name + rename in the same directory). Persist is deliberately not hooked into the individual seed steps: the file never holds an events-only intermediate that would reopen notes as public after a crash. A write failure is logged (tracing::warn!), not propagated — the mutation already landed in memory.
    • Host: web_routers_with_surface in id-web — the path id serve (id-cli) actually runs. The snapshot lives at .note-checkpoints.json beside the identity store (derived from identity_db_path, mirroring how the local-events dir is derived), and restore runs before any router serves. Missing file = fresh host; a file that does not parse or does not fold fails startup (NoteSnapshotError::{Corrupt, Checkpoint}) — a failed restart, never a host that silently reopens scoped notes to public. States without an installed path (in-process AppState::new, tests) are unchanged, memory-only.

    Oracle and evidence: failing first — the tests-only commit fails to compile with exactly the missing pieces (cannot find type NoteCheckpointSnapshot, no method named with_note_snapshot_path; 5 errors). The drill, test_note_policies_survive_a_host_restart_through_the_snapshot_file: a live state persists as it mutates (file parses as a snapshot: 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 with NotAuthorized and the refusal records nothing, and a public note stays public for the same stranger. Plus test_a_corrupt_note_snapshot_fails_the_restart_not_opens_notes (truncated JSON → Err; missing file → Ok(false)).

    Verification (laptop worktree, nix develop inside pkgs/id, per the workspace's own flake): the two new tests pass; cargo test -p id-store -p id-web --lib → id-store 244 passed / 0 failed (baseline unchanged), id-web 737 passed / 0 failed (735 baseline + 2 new); cargo fmt --check clean; no clippy findings in the touched files. Execution note: this lane's sandbox clone tripped the platform execution-risk flag on arrival, so all git/build/test ran in a laptop worktree (~/wt-lane-aw-3819, branch archer-lane-aw/3819-host-persistence) under Drew's standing clone/laptop approvals; the sandbox clone was read-only reference only.

    Remainders, in order (unchanged):
    2. Replica sync of policies — the note.policy sync kind and its ordering rule; needs the design note first (does a policy travel with the events it governs, or as its own kind, and what wins when they arrive out of order?). Not designed in this lane.
    3. Wire-level tests — policy enforcement asserted over real transports (iroh + loopback HTTP), including a scoped note created on one node, synced, and refused to a stranger on a second node after that node restarts — the restart leg of that drill can now run against the persisted snapshot this slice landed.

    #5535 stays parked on this issue; this slice does not change its state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepic/id-programReprioritization program epic (2026-11-12)kind/enhancementpriority/highImportant and time-sensitivequeue/parkedQueue task is parked (waiting on CI, time, or an event)status/parkedDeliberately paused with a recorded resume conditiontask/small-fixQueue packet kind: bounded fix with reproduction and targeted testswork/assignedQueue worker lifecycle state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions