Hashed manifest envelopes, paged pulls, history in the quota (#994) #32

Open
backmeupplz wants to merge 60 commits from board/994-e74e21 into main
Owner

Board #994. Stacked on #18 (ticket #979), which this builds on (its quota counting and staged pushes), so it targets board/979-ebe940. Once #18 merges, retarget it to main.

Bounds a vault's manifest and roster history and pages pulls. DESIGN.md is updated (Servers and accounts, Sync, Wire API, Known limits).

Paged pulls

  • GET /v1/vaults/{id} sends rosters, then manifests, then items (by id), each in order, up to about 16 MiB per response. Every response carries at least one entry, and more: true means more pages follow.
  • The client asks for the next page with roster, from and after set to the last entry of each kind it has, plus at set to the counter its first page showed. If the vault has moved on, the server answers 409 and the client starts over (five tries).
  • The client joins the pages and runs Vault::apply once, so a failure still changes nothing.
  • If a pull is still restarting after five tries, the vault is reported and the next sync tries again. That error is Refused, not "held back", so no files are collected from stale state.
  • The client refuses a page query it has already sent during the same pull.
  • MAX_PUSH (at most 64 MiB of items per push) is gone, along with the import pre-check that relied on it. Any vault can now be pulled by a new device and can change its key (staged), which settles the #979 review comment on this ticket.
  • Agent reads are audited once per pull. The server can't tell a first page from a later one, so the log skips a read only when the agent's last audit entry for the vault is a read from the past minute.

Hashed manifest envelopes

  • The envelope signs sealed_hash, and the sealed part travels next to it (VaultPut.sealed, NewVault.sealed, and VaultResponse.sealed for the latest manifest).
  • The server keeps the sealed part only for the latest manifest. Older ones are emptied to x'' in a new manifests.sealed column, so each push adds about 400 bytes of history for good. Envelopes are capped at 512 bytes.
  • Manifests in the old form (sealed part inside the envelope) still verify, whether one is the latest or sits in the middle of a chain. The server keeps them but refuses new ones with "update the app".
  • Compatibility: apps from before this can't read a vault once a newer app has pushed to it, and can't push to an updated server. Newer apps can't push to an older server either. The server and the apps have to be updated together. Only Android test builds are tagged so far (android-0.1.0-test.*).

Quota counts history

  • usage counts every roster version and every manifest envelope, plus the latest sealed part.
  • Rosters and manifests stored before this change count only while they are the latest (rosters.counted and NULL manifests.sealed, both added by migration), since nobody can delete them.
  • Over the quota, a push goes through only if it removes items and nothing else grows: item bytes, the sealed part and the envelope's unknown fields. A key rotation's re-seal doesn't need to remove anything.
  • Over the quota, a roster change goes through only if it removes or demotes someone and adds, promotes or extends no one (narrows). Anything else needs room.
  • So how far an account can go past its quota is bounded by the items it removes and the access it takes away.
  • Behaviour change from #18: edits that take no more room, promotions and new expiries now wait for room. Known limits now also covers a writer filling the paying account with history, and a busy vault outrunning a slow pull.

Tests

  • core: manifests_sign_the_hash_of_their_sealed_part (old form → new form, a tampered or missing sealed part, an envelope with both forms or neither) and pull_query_pages.
  • server: narrowing_roster_changes. creator_migration now also covers the new columns and what counts toward the quota.
  • client end to end:
    • paged_pulls: 4 KB pages; catching up and fresh pulls; a push landing between pages; restart exhaustion; a server that replays pages; agent audit with at.
    • manifest_history_stays_small: only the latest sealed part is kept; usage counts history; old-form envelopes, envelopes without a hash and over-size envelopes are refused.
    • manifests_from_older_apps: a database whose latest manifest is old-form, with catch-up, a fresh start and an over-quota delete on top.
    • storage_quota is updated for the new rules.
  • cargo test --locked --workspace and cargo clippy --workspace --all-targets --locked pass.

🤖 Generated with Claude Code

Board #994. **Stacked on #18** (ticket #979), which this builds on (its quota counting and staged pushes), so it targets `board/979-ebe940`. Once #18 merges, retarget it to `main`. Bounds a vault's manifest and roster history and pages pulls. DESIGN.md is updated (Servers and accounts, Sync, Wire API, Known limits). ## Paged pulls - `GET /v1/vaults/{id}` sends rosters, then manifests, then items (by id), each in order, up to about 16 MiB per response. Every response carries at least one entry, and `more: true` means more pages follow. - The client asks for the next page with `roster`, `from` and `after` set to the last entry of each kind it has, plus `at` set to the counter its first page showed. If the vault has moved on, the server answers 409 and the client starts over (five tries). - The client joins the pages and runs `Vault::apply` once, so a failure still changes nothing. - If a pull is still restarting after five tries, the vault is reported and the next sync tries again. That error is `Refused`, not "held back", so no files are collected from stale state. - The client refuses a page query it has already sent during the same pull. - `MAX_PUSH` (at most 64 MiB of items per push) is gone, along with the import pre-check that relied on it. Any vault can now be pulled by a new device and can change its key (staged), which settles the #979 review comment on this ticket. - Agent reads are audited once per pull. The server can't tell a first page from a later one, so the log skips a read only when the agent's last audit entry for the vault is a read from the past minute. ## Hashed manifest envelopes - The envelope signs `sealed_hash`, and the sealed part travels next to it (`VaultPut.sealed`, `NewVault.sealed`, and `VaultResponse.sealed` for the latest manifest). - The server keeps the sealed part only for the latest manifest. Older ones are emptied to `x''` in a new `manifests.sealed` column, so each push adds about 400 bytes of history for good. Envelopes are capped at 512 bytes. - Manifests in the old form (sealed part inside the envelope) still verify, whether one is the latest or sits in the middle of a chain. The server keeps them but refuses new ones with "update the app". - **Compatibility:** apps from before this can't read a vault once a newer app has pushed to it, and can't push to an updated server. Newer apps can't push to an older server either. The server and the apps have to be updated together. Only Android test builds are tagged so far (`android-0.1.0-test.*`). ## Quota counts history - `usage` counts every roster version and every manifest envelope, plus the latest sealed part. - Rosters and manifests stored before this change count only while they are the latest (`rosters.counted` and NULL `manifests.sealed`, both added by migration), since nobody can delete them. - Over the quota, a push goes through only if it removes items and nothing else grows: item bytes, the sealed part and the envelope's unknown fields. A key rotation's re-seal doesn't need to remove anything. - Over the quota, a roster change goes through only if it removes or demotes someone and adds, promotes or extends no one (`narrows`). Anything else needs room. - So how far an account can go past its quota is bounded by the items it removes and the access it takes away. - **Behaviour change from #18:** edits that take no more room, promotions and new expiries now wait for room. Known limits now also covers a writer filling the paying account with history, and a busy vault outrunning a slow pull. ## Tests - core: `manifests_sign_the_hash_of_their_sealed_part` (old form → new form, a tampered or missing sealed part, an envelope with both forms or neither) and `pull_query_pages`. - server: `narrowing_roster_changes`. `creator_migration` now also covers the new columns and what counts toward the quota. - client end to end: - `paged_pulls`: 4 KB pages; catching up and fresh pulls; a push landing between pages; restart exhaustion; a server that replays pages; agent audit with `at`. - `manifest_history_stays_small`: only the latest sealed part is kept; usage counts history; old-form envelopes, envelopes without a hash and over-size envelopes are refused. - `manifests_from_older_apps`: a database whose latest manifest is old-form, with catch-up, a fresh start and an over-quota delete on top. - `storage_quota` is updated for the new rules. - `cargo test --locked --workspace` and `cargo clippy --workspace --all-targets --locked` pass. 🤖 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>
Review: agent reads audited on every pull, a pull that keeps restarting isn't a held-back change, pages must move on, expiry in the narrowing rule, older rosters uncounted, 512-byte envelopes
Some checks failed
Apple / Apple (pull_request) Successful in 32s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
03893b9ea4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: a busy vault is reported without the leave hint; DESIGN counts and audit wording
Some checks failed
Apple / Apple (pull_request) Successful in 30s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
ca1f17bc10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge board/979-ebe940 (#999 dropping unsendable changes): its fresh download pulls in pages too; a busy vault shares the no-leave-hint branch with read-only ones
Some checks failed
Apple / Apple (pull_request) Successful in 33s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
990c4beb98
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: the busy message fits a reset too; PARITY on agent read audit
Some checks failed
Apple / Apple (pull_request) Successful in 33s
CI / wasm (pull_request) Failing after 3m12s
CI / check (pull_request) Successful in 6m21s
Android / android (pull_request) Has been cancelled
6029f82c90
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuild docs/s (core changed)
All checks were successful
Apple / Apple (pull_request) Successful in 44s
CI / check (pull_request) Successful in 5m42s
CI / wasm (pull_request) Successful in 6m32s
Android / android (pull_request) Successful in 24m46s
ec2529f8c7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/board/979-ebe940' into board/994-f17372
Some checks failed
Apple / Apple (pull_request) Successful in 44s
CI / check (pull_request) Successful in 6m26s
CI / wasm (pull_request) Successful in 6m24s
Android / android (pull_request) Has been cancelled
99c96ab1a4
# Conflicts:
#	core/src/vault.rs
backmeupplz changed target branch from board/979-ebe940 to main 2026-11-28 08:45:39 +00:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes: cursor range check, quota-bound and audit wording, batching hint, tests
Some checks failed
Apple / Apple (pull_request) Successful in 45s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
85e78cd3d3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: 507 hint fits one-item deletes, quota-bound wording, tighter test asserts
All checks were successful
Apple / Apple (pull_request) Successful in 31s
CI / check (pull_request) Successful in 5m31s
CI / wasm (pull_request) Successful in 6m59s
Android / android (pull_request) Successful in 23m57s
b5eba54d65
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes: item pages by index, deletes sent alone over the quota, staging cap without a quota
Some checks failed
Apple / Apple (pull_request) Successful in 35s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
050c70bc5f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: rebase a new item the server already has; doc and comment wording
All checks were successful
Apple / Apple (pull_request) Successful in 30s
CI / check (pull_request) Successful in 6m39s
CI / wasm (pull_request) Successful in 6m26s
Android / android (pull_request) Successful in 30m8s
9904564392
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes: partial pushes list only the server's copies, big pushes go in parts
Some checks failed
Apple / Apple (pull_request) Successful in 37s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
2bcecd0f36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: no split pushes with a quota; a change during a push starts from what it sent; no conflict copy for a lost answer
Some checks failed
Apple / Apple (pull_request) Successful in 30s
CI / wasm (pull_request) Successful in 6m43s
CI / check (pull_request) Successful in 11m56s
Android / android (pull_request) Has been cancelled
4c8378985f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/main' into board/994-42ca72
Some checks failed
Apple / Apple (pull_request) Successful in 35s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
290972fcdd
# Conflicts:
#	client/src/lib.rs
Test: a busy vault shared with you gets no leave hint
All checks were successful
Apple / Apple (pull_request) Successful in 24s
CI / check (pull_request) Successful in 5m26s
CI / wasm (pull_request) Successful in 5m31s
Android / android (pull_request) Successful in 20m3s
939205e838
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Over the quota, drop deletes the server already has; split after an idle upgrade; assume a quota until known
Some checks failed
Apple / Apple (pull_request) Successful in 31s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
6be1fc74e7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop pending deletes the server has no item for on every pull, not by guessing at delete time
Some checks failed
Apple / Apple (pull_request) Successful in 42s
Android / android (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
CI / wasm (pull_request) Has been cancelled
80ebc564aa
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge main into board/994-e74e21
Some checks failed
Apple / Apple (pull_request) Successful in 46s
release / build (macos-latest, true, aarch64-apple-darwin) (pull_request) Successful in 4m35s
release / build (macos-latest, true, x86_64-apple-darwin) (pull_request) Successful in 4m53s
CI / check (pull_request) Failing after 7m15s
CI / wasm (pull_request) Successful in 6m2s
Android / android (pull_request) Has been cancelled
release / build (ubuntu-24.04, false, x86_64-pc-windows-gnu) (pull_request) Successful in 8m20s
release / build (ubuntu-24.04, true, aarch64-unknown-linux-musl) (pull_request) Successful in 7m12s
release / build (ubuntu-24.04, true, x86_64-unknown-linux-musl) (pull_request) Successful in 6m37s
release / release (pull_request) Has been skipped
release / homebrew (pull_request) Has been skipped
release / docker (pull_request) Has been skipped
4c933b18dd
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/main' into HEAD
Some checks are pending
CI / check (pull_request) Waiting to run
CI / wasm (pull_request) Waiting to run
Apple / Apple (pull_request) Successful in 40s
Android / android (pull_request) Has started running
1891e43cff
# Conflicts:
#	DESIGN.md
Some checks are pending
CI / check (pull_request) Waiting to run
CI / wasm (pull_request) Waiting to run
Apple / Apple (pull_request) Successful in 40s
Android / android (pull_request) Has started running
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'board/994-e74e21:board/994-e74e21'
git switch 'board/994-e74e21'
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!32
No description provided.