Writes into a vault you can only read are refused, not kept on the device (#997) #24
Loading…
Reference in a new issue
No description provided.
Delete branch "board/997-df286d"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Board #997. A reader's (or a demoted creator's) writes were applied to the device's copy, and then
sync_vaultsilently skipped the push. They stayed on the device without a word:plaintext add,edit,rm,vault rename, MCPcreate_itemandimportall reported success.What changes (client):
put_item/put_item_async(CLI, MCP, apps, extension),delete_itemandrename_vaultnow go through a privateSession::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 returnsReadOnly("you can only read this vault"). Nothing is left changed.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.)ReadOnlyis 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::pushno 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'spushreturnsReadOnlyinstead, andsync()lists it as a problem on every sync. A reader with nothing pending still syncs cleanly.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'simport_itemsboth 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 callswritable()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 throughSession::import.Apps (ffi):
put_newundoes 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_itemchecks 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 aFlakytransport), 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_changegoes throughput_item/delete_itemwhile 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 ffiapp_end_to_endtest checks that a refused save from the inbox queues nothing.🤖 Generated with Claude Code