Skip to content

feat(id-web): collab note-session wiring — WS note resolution + checkpoint publish on session end (#3819 slice 2) - #10831

Merged
dezren39 merged 1 commit into
mainfrom
queue/5826-3819-slice2-wiring
Nov 16, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5826-3819-slice2-wiring

Conversation

@dezren39

@dezren39 dezren39 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Refs #3819 — Phase 3 slice 2 of 4 (route/WS wiring). Slice 1 (checkpoint core + note-ID session keying) landed in PR #10808.

What this slice wires

  • Handler resolution (collab.rs): a WebSocket doc_id of the form note:<note id hex> now resolves a note session through CollabState::get_or_create_for_note — by the note's stable ID, never by filename. Every other doc_id keeps the exact filename path it had. parse_note_doc_id is the one place that decides which namespace a doc_id belongs to.
  • The checkpoint log lives in CollabState: an Arc<Mutex<NoteCheckpoints>> plus the session-key → note-ID bindings recorded when a note session opens. seed_note_events rebuilds the log from applied note events (the restart/sync entry — the events are the durable state), and note_events reads them back for persistence and sync.
  • Publishing from a live session (publish_note_checkpoint): takes the session's current plain text (the same extract_plain_text the save path uses), references it through the document path (DocumentRef::for_bytes), and records one signed revision in the core. The first publication establishes the note (create event = the note's own ID); later ones build on the single current head via checkpoint_on_heads. A multi-head note refuses with ExplicitMergeRequired — a save never joins concurrent heads silently. Event IDs are minted as a digest of note, author, parent heads, content, and session version.
  • Session end is a checkpoint point: when the last editor of a note session disconnects and the session's version moved since that connection opened it, the handler publishes a checkpoint signed with the server's key (IdentityStore::author_key, the new accessor for the verifying half of the store's signing key). A refusal is logged, never fatal to the disconnect. Editor steps remain ephemeral — only this explicit publication crosses into the durable graph.

Deliberately not in this slice

  • The access boundary at checkpoint time (slice 3, per Drew's Q2 answer on id: design: Zettelkasten layer — multiplayer docs/wiki on ID #2048) and wire-level integration tests (slice 4) stay with task 5826's recorded plan.
  • Hydrating a note session's initial content from the checkpoint log's head blob: the log records content references, and the blob fetch belongs with the wire-level work in slice 4. A note session opened before its first publication starts from the filename path's content when a filename hint resolves one, exactly like a file with no stored hash does today.

Tests

New in collab.rs (all under cargo test -p id-web --lib collab):

  • test_parse_note_doc_id — the wire form parses; filenames and malformed IDs do not.
  • test_publish_note_checkpoint_creates_then_chains_on_the_head — first publish creates (note ID stable, one head), second publish chains on that head.
  • test_publish_note_checkpoint_refuses_a_filename_session — no note, no checkpoint, nothing recorded.
  • test_note_checkpoint_log_rebuilds_from_seeded_events — a fresh state seeded with the live log's events folds to the same heads and chains onto them (restart/sync at the wiring level).
  • test_publish_note_checkpoint_refuses_to_join_concurrent_heads — a forked log (two heads) refuses publication with ExplicitMergeRequired and records nothing.

Queue task 5826 (lane any-d). Slices 3–4 remain on #3819.


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

…he WS handler, publish checkpoints on session end (#3819 slice 2)
@dezren39
dezren39 requested a review from a team as a code owner November 16, 2026 16:49
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T16:49:29.111692Z
We couldn’t complete this review. Comment @codex review to try again.
277d318 PR opened
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Nov 16, 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 38 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: 589ed165-6d8a-43eb-86ea-64916d45a2b2
Commits

Reviewing files that changed from the base of the PR and between 86ebce1 and 277d318.

Files selected for processing: 4

  • pkgs/id/crates/id-web/src/collab.rs
  • pkgs/id/crates/id-web/src/identity.rs
  • pkgs/id/crates/id-web/src/routes.rs
  • pkgs/id/crates/id-web/src/routes/file_handlers.rs
  • 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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.

1 participant