test(sharing): prove a recipient's room sync never carries text deleted before the share #1042

Closed
kayg wants to merge 0 commits from test/shared-room-no-deleted-text into dev
Owner

Privacy check (11-09): does a recipient's room sync carry text the owner deleted before sharing? No. This PR is the proof, as a test.

Why it doesn't leak

The room's Yjs document is built with yrs' default options (ydoc::new_doc: skip_gc = false), so garbage collection is on. When a transaction commits, deleted runs keep only their length; their content is gone. That includes deletions applied while the server rebuilds a room from stored history. A full-state sync (SyncStep1 with an empty state vector → encode_state_as_update_v1) therefore can't contain deleted text.

The test

isolation::grants::a_recipient_never_receives_text_deleted_before_the_share:

  1. Alice creates a note with a secret line, saves it, then replaces the text without the line (notes.replace) and saves again.
  2. She shares the note with Bob (Read). Bob joins the room alice/<id> and asks for everything: SyncStep1 with an empty state vector, as a fresh device does.
  3. No frame of the first sync contains the secret's bytes.
  4. Those frames rebuild exactly the current file (front matter + # Trip\n\nKeep this line.\n), so the check looked at real content.
  5. Alice appends a line afterwards. The update Bob receives doesn't contain the secret either.

Gates (head ccc30d635)

gate result
cargo fmt --check / clippy -D warnings clean / clean
the new test ×5 5/5 passed
cargo test -p calternal isolation 40 passed, 0 failed

Test only, with no product change, so there's no web, first-paint or perf impact.

🤖 Generated with Claude Code

**Privacy check (11-09): does a recipient's room sync carry text the owner deleted before sharing? No.** This PR is the proof, as a test. ## Why it doesn't leak The room's Yjs document is built with yrs' default options (`ydoc::new_doc`: `skip_gc = false`), so garbage collection is on. When a transaction commits, deleted runs keep only their length; their content is gone. That includes deletions applied while the server rebuilds a room from stored history. A full-state sync (`SyncStep1` with an empty state vector → `encode_state_as_update_v1`) therefore can't contain deleted text. ## The test `isolation::grants::a_recipient_never_receives_text_deleted_before_the_share`: 1. Alice creates a note with a secret line, saves it, then replaces the text without the line (`notes.replace`) and saves again. 2. She shares the note with Bob (Read). Bob joins the room `alice/<id>` and asks for everything: `SyncStep1` with an empty state vector, as a fresh device does. 3. No frame of the first sync contains the secret's bytes. 4. Those frames rebuild exactly the current file (front matter + `# Trip\n\nKeep this line.\n`), so the check looked at real content. 5. Alice appends a line afterwards. The update Bob receives doesn't contain the secret either. ## Gates (head `ccc30d635`) | gate | result | |---|---| | `cargo fmt --check` / clippy `-D warnings` | clean / clean | | the new test ×5 | 5/5 passed | | `cargo test -p calternal isolation` | 40 passed, 0 failed | Test only, with no product change, so there's no web, first-paint or perf impact. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Privacy check (11-09): the owner writes a secret, deletes it, then shares.
The recipient's first sync (full state from an empty state vector) and a
later update must not contain the secret's bytes, and the first sync must
rebuild exactly the current text. The room document collects garbage
(yrs default), so a deleted run keeps only its length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
style: rustfmt
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
ccc30d6359
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged into dev locally (head ccc30d635 is in origin/dev); closing.

Merged into dev locally (head `ccc30d635` is in origin/dev); closing.
kayg closed this pull request 2026-11-09 18:55:14 +00:00
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!1042
No description provided.