A device can drop vault changes it can no longer send (#999) #25

Merged
backmeupplz merged 16 commits from board/999-5d4440 into main 2026-11-28 06:12:48 +00:00
Owner

Board #999. Stacked on PR #24 (#997): merge that first. This branch includes #24's commits; once #24 is in main, merging main here leaves only this ticket's diff. For this ticket alone, see git diff origin/board/997-df286d...board/999-5d4440.

The problem: since #997, a device holding unsent changes to a vault where you're now only a reader warns "you can only read this vault" on every sync. Nothing let you drop those changes.

Client:

  • New Session::discard_changes(id) -> usize. It pulls, then downloads the vault from scratch, because an edit overwrote the server's copy and a delete removed it.
  • It keeps the new copy only if it verified the same latest manifest (counter and hash, Vault::same_head) as the copy this device already had.
    • An older copy, or a different copy of the same version, returns Rollback.
    • A newer copy (another device pushed in between) says to try again.
    • Any failure leaves the pending changes and the keyring as they were.
  • The sync warning for a reader with pending changes ends with "…so this device's changes to it can't be sent; to drop them, run plaintext vault reset ". It uses the id because anyone who can write may name a vault anything, shell syntax included.
  • Core: adds Vault::changes() (a count), changed() (added or edited items) and same_head().

CLI: plaintext vault reset V says how many changes it dropped, or that there were none. It lists the titles of the added or edited items it drops, since they may exist nowhere else.

Tests: I extended a_reader_s_writes_are_refused_not_kept_on_the_device. In it, bob is a writer who makes an offline edit, a delete and a rename, and is then demoted.

  • The warning names vault reset <id>.
  • A failed download drops nothing.
  • A replayed older from-scratch reply is refused as Rollback with all 3 changes kept. The test fails with the head check removed.
  • After the reset, the edit, the delete and the name are back to the server's copy, and the next sync is clean.
  • Promoted again, bob pushes an unrelated item, and alice sees every item intact. This catches stale entries left behind.

cargo test --locked and clippy -D warnings pass.

Follow-up: #1000. Unsent changes to a vault you were removed from (not demoted) still stay without a warning. This predates this PR.

🤖 Generated with Claude Code

Board #999. **Stacked on PR #24 (#997): merge that first.** This branch includes #24's commits; once #24 is in main, merging main here leaves only this ticket's diff. For this ticket alone, see `git diff origin/board/997-df286d...board/999-5d4440`. **The problem:** since #997, a device holding unsent changes to a vault where you're now only a reader warns "you can only read this vault" on every sync. Nothing let you drop those changes. **Client:** - New `Session::discard_changes(id) -> usize`. It pulls, then downloads the vault from scratch, because an edit overwrote the server's copy and a delete removed it. - It keeps the new copy only if it verified the same latest manifest (counter and hash, `Vault::same_head`) as the copy this device already had. - An older copy, or a different copy of the same version, returns `Rollback`. - A newer copy (another device pushed in between) says to try again. - Any failure leaves the pending changes and the keyring as they were. - The sync warning for a reader with pending changes ends with "…so this device's changes to it can't be sent; to drop them, run plaintext vault reset <id prefix>". It uses the id because anyone who can write may name a vault anything, shell syntax included. - Core: adds `Vault::changes()` (a count), `changed()` (added or edited items) and `same_head()`. **CLI:** `plaintext vault reset V` says how many changes it dropped, or that there were none. It lists the titles of the added or edited items it drops, since they may exist nowhere else. **Tests:** I extended `a_reader_s_writes_are_refused_not_kept_on_the_device`. In it, bob is a writer who makes an offline edit, a delete and a rename, and is then demoted. - The warning names `vault reset <id>`. - A failed download drops nothing. - A replayed older from-scratch reply is refused as `Rollback` with all 3 changes kept. The test fails with the head check removed. - After the reset, the edit, the delete and the name are back to the server's copy, and the next sync is clean. - Promoted again, bob pushes an unrelated item, and alice sees every item intact. This catches stale entries left behind. `cargo test --locked` and clippy `-D warnings` pass. **Follow-up:** #1000. Unsent changes to a vault you were *removed* from (not demoted) still stay without a warning. This predates this PR. 🤖 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>
Session::discard_changes re-downloads the vault and keeps the new copy only
if it is the version this device already verified. plaintext vault reset V
runs it, and the reader warning on sync names the command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reset: hint by id, cover the rollback check, list dropped items
All checks were successful
CI / check (pull_request) Successful in 3m48s
CI / wasm (pull_request) Successful in 2m16s
aea580825a
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
Merge PR #24's head; port discard_changes to the async Session
Some checks failed
Apple / Apple (pull_request) Successful in 37s
release / build (macos-latest, true, aarch64-apple-darwin) (pull_request) Successful in 7m48s
release / build (macos-latest, true, x86_64-apple-darwin) (pull_request) Successful in 8m51s
CI / check (pull_request) Successful in 4m51s
CI / wasm (pull_request) Has been cancelled
release / build (ubuntu-24.04, false, x86_64-pc-windows-gnu) (pull_request) Has been cancelled
release / build (ubuntu-24.04, true, aarch64-unknown-linux-musl) (pull_request) Has been cancelled
release / build (ubuntu-24.04, true, x86_64-unknown-linux-musl) (pull_request) Has been cancelled
release / release (pull_request) Has been cancelled
release / homebrew (pull_request) Has been cancelled
release / docker (pull_request) Has been cancelled
7048f0b42a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/main' into board/999-c7c712
All checks were successful
Apple / Apple (pull_request) Successful in 39s
release / build (macos-latest, true, aarch64-apple-darwin) (pull_request) Successful in 7m5s
release / build (macos-latest, true, x86_64-apple-darwin) (pull_request) Successful in 7m16s
CI / check (pull_request) Successful in 4m11s
CI / wasm (pull_request) Successful in 5m21s
release / build (ubuntu-24.04, false, x86_64-pc-windows-gnu) (pull_request) Successful in 10m10s
release / build (ubuntu-24.04, true, aarch64-unknown-linux-musl) (pull_request) Successful in 12m24s
release / build (ubuntu-24.04, true, x86_64-unknown-linux-musl) (pull_request) Successful in 8m10s
release / release (pull_request) Has been skipped
release / docker (pull_request) Has been skipped
release / homebrew (pull_request) Has been skipped
Android / android (pull_request) Successful in 28m37s
2b0b7467ac
# Conflicts:
#	client/src/lib.rs
#	client/src/tests.rs
backmeupplz deleted branch board/999-5d4440 2026-11-28 06:12:50 +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!25
No description provided.