Repository navigation
Test that a notepad started over in NOTE never costs a file - #4
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ab32af854
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fresh = await startOver(note); | ||
| dropBlobs(); |
There was a problem hiding this comment.
Capture old blob refs before replacing the record
In every apply-based start-over scenario, startOver(note) replaces the record before dropBlobs() examines note.record(). Because the replacement is an empty notepad, the old attachment CIDs are no longer available to add to gone, so these cases do not simulate the specified replacement-then-blob-deletion sequence and could miss a device attempting to download an old attachment during that window. Capture the old record's blob refs before replacement, then mark those refs unavailable afterward.
Useful? React with 👍 / 👎.
Summary
NOTE is gaining "Start a new notepad": a signed-in owner whose passkey can't open the current notepad publishes a brand-new vault (new vault id, new key, epoch 1, only that passkey listed, a signed
create) over the existing vault record, compare-and-swap against the record it read, removes the old notepad's blobs and revokes every device token. A linked Obsidian vault must survive that without losing a file. These tests prove it does, with no code change needed.Test-only:
tests/e2e.test.tsgains aa notepad started over in NOTEblock, driving the real device client andSyncControlleragainst seal's in-memory Flow ID.tests/start-over.tsbuilds the replacement from seal'sinternal/*modules, the way the kit's ownadminBrowserbuilds the first vault (the kit can only create a vault where none exists), so no seal release is needed.What the tests show
For each order,
start overalone,revokealone,start over, then revokeandrevoke, then start over, with the vault both syncing and closed (14 files, more than the mass-deletion threshold, plus an edit and a new file made after the start-over):removedphase with the noticeThis vault was removed from your NOTE notepad's access. Link it again to keep syncing.when only the record changed, orFlow ID unlinked this vault. Link it again to keep syncing.once the token is revoked. A restart afterwards finds no link (unlinked).Synced); nothing is deleted, and the later replacement stops it as above.Why it is safe
VaultAccessErrorand the runtime locks (SYNC_LOCKED). The controller closes the engine before the session's key is wiped and reopens, and the reopen finds no access slot for this seed (or a refused token) and callsonRemoved, which wipes keys, the device database and every sync index, never a file.delete-localneeds an entry.Testing
bun run lint,bun run lint:obsidian(no errors; the 13 warnings predate this change),bun run typecheck,bun test(105 pass),bun run build,bun run smoke