Writes into a vault you can only read are refused, not kept on the device (#997) #24

Merged
backmeupplz merged 11 commits from board/997-df286d into main 2026-11-28 05:14:42 +00:00
Owner

Board #997. A reader's (or a demoted creator's) writes were applied to the device's copy, and then sync_vault silently skipped the push. They stayed on the device without a word: plaintext add, edit, rm, vault rename, MCP create_item and import all reported success.

What changes (client):

  • put_item / put_item_async (CLI, MCP, apps, extension), delete_item and rename_vault now go through a private Session::change_async. It applies the change, pulls, and if the freshest roster says your role is below Writer it undoes the change (restoring a snapshot of the vault taken just before), pulls again so the refusing roster stays on the device, and returns ReadOnly ("you can only read this vault"). Nothing is left changed.
  • The change goes in before the pull, as on main (sync_vault), so the pull still sees another device's newer copy of the item: a concurrent edit is kept as a conflict copy, and a concurrent edit brings back an item deleted here. (Pulling first would make that newer copy the edit's base and overwrite it without a word.)
  • Offline edits still queue (PARITY "Offline access & sync"): when the pull fails with a network error or a 5xx, the edit waits for the next sync, unless the roster on the device already says reader, in which case it is undone and ReadOnly is returned. Any other pull failure (401, 403, a verification error) is returned with the change still waiting, as on main; only a refusal is undone.
  • Session::push no longer returns Ok for a reader with changes pending. That covers an offline edit followed by a demotion, and a demotion seen by a 409's re-pull. The vault's push returns ReadOnly instead, and sync() lists it as a problem on every sync. A reader with nothing pending still syncs cleanly.
  • New Session::writable(id) (pull + check, with the same offline rule).

Import (CLI and apps): main moved import into Session::import, which the CLI and the app's import_items both call. It now resolves every existing target first (--vault, the default vault, or your own vault of that name, which also matches a vault you made but now only read) and calls writable() on each. Only then does it make vaults, upload files or put items. The loop uses those checked targets, so a pull during the check that renames a vault can't redirect items to an unchecked one. A reader's import is refused with nothing changed and nothing saved. When PR #18 (#979) merges main, its import has to keep going through Session::import.

Apps (ffi):

  • put_new undoes a failed put only if the item is actually in the vault. A refused put changed nothing, and the delete would have queued a change of its own (save from inbox, move).
  • move_item checks the source vault against the freshest roster, so a stale writer gets refused before the copy is made, not after.

Known limits: if the network drops between the refusing pull and the second pull, the device keeps its older roster, so a later offline edit is queued and then reported on every sync instead of refused. There is no way yet to discard a reader's unsendable changes, so the warning repeats on each sync (follow-up #999).

Tests: a_reader_s_writes_are_refused_not_kept_on_the_device (client/src/tests.rs) covers a stale roster where put, edit, delete and rename are refused and nothing is left pending. It also covers writing again once restored, an offline edit queued and pushed (via a Flaky transport), an offline edit then demotion reported by sync, and an offline known reader refused. It also covers a reader's import refused, and a demoted creator's multi-vault import refused with no vault made. an_edit_or_delete_keeps_another_device_s_newer_change goes through put_item/delete_item while another device edits the same item: the edit keeps a conflict copy, the delete gives way. The agent test checks that a reader's sync now reports why it won't push. The ffi app_end_to_end test checks that a refused save from the inbox queues nothing.

🤖 Generated with Claude Code

Board #997. A reader's (or a demoted creator's) writes were applied to the device's copy, and then `sync_vault` silently skipped the push. They stayed on the device without a word: `plaintext add`, `edit`, `rm`, `vault rename`, MCP `create_item` and `import` all reported success. **What changes (client):** - `put_item` / `put_item_async` (CLI, MCP, apps, extension), `delete_item` and `rename_vault` now go through a private `Session::change_async`. It applies the change, pulls, and if the freshest roster says your role is below Writer it undoes the change (restoring a snapshot of the vault taken just before), pulls again so the refusing roster stays on the device, and returns `ReadOnly` ("you can only read this vault"). Nothing is left changed. - The change goes in before the pull, as on main (`sync_vault`), so the pull still sees another device's newer copy of the item: a concurrent edit is kept as a conflict copy, and a concurrent edit brings back an item deleted here. (Pulling first would make that newer copy the edit's base and overwrite it without a word.) - Offline edits still queue (PARITY "Offline access & sync"): when the pull fails with a network error or a 5xx, the edit waits for the next sync, unless the roster on the device already says reader, in which case it is undone and `ReadOnly` is returned. Any other pull failure (401, 403, a verification error) is returned with the change still waiting, as on main; only a refusal is undone. - `Session::push` no longer returns Ok for a reader with changes pending. That covers an offline edit followed by a demotion, and a demotion seen by a 409's re-pull. The vault's `push` returns `ReadOnly` instead, and `sync()` lists it as a problem on every sync. A reader with nothing pending still syncs cleanly. - New `Session::writable(id)` (pull + check, with the same offline rule). **Import (CLI and apps):** main moved import into `Session::import`, which the CLI and the app's `import_items` both call. It now resolves every existing target first (`--vault`, the default vault, or your own vault of that name, which also matches a vault you made but now only read) and calls `writable()` on each. Only then does it make vaults, upload files or put items. The loop uses those checked targets, so a pull during the check that renames a vault can't redirect items to an unchecked one. A reader's import is refused with nothing changed and nothing saved. When PR #18 (#979) merges main, its import has to keep going through `Session::import`. **Apps (ffi):** - `put_new` undoes a failed put only if the item is actually in the vault. A refused put changed nothing, and the delete would have queued a change of its own (save from inbox, move). - `move_item` checks the source vault against the freshest roster, so a stale writer gets refused before the copy is made, not after. **Known limits:** if the network drops between the refusing pull and the second pull, the device keeps its older roster, so a later offline edit is queued and then reported on every sync instead of refused. There is no way yet to discard a reader's unsendable changes, so the warning repeats on each sync (follow-up #999). **Tests:** `a_reader_s_writes_are_refused_not_kept_on_the_device` (client/src/tests.rs) covers a stale roster where put, edit, delete and rename are refused and nothing is left pending. It also covers writing again once restored, an offline edit queued and pushed (via a `Flaky` transport), an offline edit then demotion reported by sync, and an offline known reader refused. It also covers a reader's import refused, and a demoted creator's multi-vault import refused with no vault made. `an_edit_or_delete_keeps_another_device_s_newer_change` goes through `put_item`/`delete_item` while another device edits the same item: the edit keeps a conflict copy, the delete gives way. The agent test checks that a reader's sync now reports why it won't push. The ffi `app_end_to_end` test checks that a refused save from the inbox queues nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A known reader offline is told the edit is refused (#997)
All checks were successful
CI / check (pull_request) Successful in 5m54s
CI / wasm (pull_request) Successful in 4m5s
8ef9669724
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
writable() lets an offline writer through, like an edit (#997)
All checks were successful
CI / check (pull_request) Successful in 4m8s
CI / wasm (pull_request) Successful in 2m26s
83e9552061
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge main; Session::import refuses a read-only target before anything changes
Some checks failed
Apple / Apple (pull_request) Successful in 40s
release / build (macos-latest, true, x86_64-apple-darwin) (pull_request) Successful in 4m44s
release / build (macos-latest, true, aarch64-apple-darwin) (pull_request) Successful in 5m5s
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
release / build (ubuntu-24.04, false, x86_64-pc-windows-gnu) (pull_request) Failing after 23s
release / build (ubuntu-24.04, true, aarch64-unknown-linux-musl) (pull_request) Failing after 23s
release / build (ubuntu-24.04, true, x86_64-unknown-linux-musl) (pull_request) Failing after 14s
release / release (pull_request) Has been skipped
release / homebrew (pull_request) Has been skipped
release / docker (pull_request) Has been skipped
ad670f0a41
Main moved import into Session::import (CLI and apps). It now checks every
existing target with writable() first, so a reader's import is refused
rather than kept on the device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: a refused put queues no undo; move checks the fresh roster; import keeps its checked targets
All checks were successful
Apple / Apple (pull_request) Successful in 45s
CI / check (pull_request) Successful in 3m42s
CI / wasm (pull_request) Successful in 1m37s
a3ff5d6053
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge main: the read-only guard moves onto the async session
Some checks failed
Apple / Apple (pull_request) Successful in 1m34s
release / build (macos-latest, true, aarch64-apple-darwin) (pull_request) Successful in 9m42s
release / build (macos-latest, true, x86_64-apple-darwin) (pull_request) Successful in 10m23s
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
release / build (ubuntu-24.04, false, x86_64-pc-windows-gnu) (pull_request) Failing after 6s
release / build (ubuntu-24.04, true, aarch64-unknown-linux-musl) (pull_request) Failing after 5s
release / build (ubuntu-24.04, true, x86_64-unknown-linux-musl) (pull_request) Failing after 6s
release / release (pull_request) Has been skipped
release / homebrew (pull_request) Has been skipped
release / docker (pull_request) Has been skipped
3b6e7999e2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: change before pulling again, undo it if we may only read, so another device's newer edit is kept
Some checks failed
Apple / Apple (pull_request) Successful in 32s
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
9382418e60
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: undo only a refused change; any other pull error keeps a writer's edit waiting
All checks were successful
Apple / Apple (pull_request) Successful in 37s
CI / check (pull_request) Successful in 3m57s
CI / wasm (pull_request) Successful in 5m40s
bbef971508
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/main' into HEAD
All checks were successful
Apple / Apple (pull_request) Successful in 42s
release / build (macos-latest, true, aarch64-apple-darwin) (pull_request) Successful in 7m34s
release / build (macos-latest, true, x86_64-apple-darwin) (pull_request) Successful in 7m46s
CI / check (pull_request) Successful in 4m10s
CI / wasm (pull_request) Successful in 4m59s
release / build (ubuntu-24.04, false, x86_64-pc-windows-gnu) (pull_request) Successful in 6m30s
release / build (ubuntu-24.04, true, aarch64-unknown-linux-musl) (pull_request) Successful in 5m48s
release / build (ubuntu-24.04, true, x86_64-unknown-linux-musl) (pull_request) Successful in 6m5s
release / release (pull_request) Has been skipped
release / homebrew (pull_request) Has been skipped
release / docker (pull_request) Has been skipped
290c8e63ca
backmeupplz deleted branch board/997-df286d 2026-11-28 05:14:43 +00:00
Sign in to join this conversation.
No reviewers
No labels
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
backmeupplz/plaintext!24
No description provided.