Repository navigation
fix(store): adopt runs.offers_choice under contract 7; reclaim the mobile share cache - #1630
Merged
Merged
Conversation
Opening or sharing an attachment hands the OS a copy under `futureos-exports`, kept for 24 hours. The cap that guarded that directory only ever counted, never reclaimed: once 100 MB of copies (or 128 of them) accumulated, every later handoff threw `attachment_export_cache_full` and kept throwing until retention expired — a burst of 7 MB podcast wavs was enough to lock sharing for a whole day. Reclaim instead of refusing. Copies older than `EXPORT_PROTECT_MS` go first, because a handoff is a live `content://` grant an app may still be reading; if a burst inside that window leaves no room, a second pass reclaims the oldest anyway. Refusal now survives only for a single file larger than the whole budget, which the transfer layer already rules out, and it deletes nothing on the way out. The refusal code also reached the user verbatim, because the handoff alert appends the failure's own words on Android. Keep that for native failures — they name the URI grant or chooser that refused — but map our own code to `attachment.exportCacheFull` in both locales.
The choice mark reached SCHEMA (and the best-effort ADDED_COLUMNS list) without a contract step, so a database already at version 6 — the released contract, and every desktop written by it — has no such column. Startup reads the header, sees �ersion == APP_DB_SCHEMA_VERSION, runs �alidate_core before any migration can touch the table, and refuses to open: Desktop database is incomplete: required runs.offers_choice is missing. The same shape as #1496 (workspaces.archived_at): ADDED_COLUMNS only runs from �pply_schema, i.e. on a fresh database, never on the current-version path. Adopt the column under contract 7, with the released 6 kept immutable: - uns_offers_choice.sql adds the column; ADDITIVE_COLUMN_STEPS skips the ALTER on a fresh install or a build that wrote the column early, so an existing mark and its row survive either layout. - APP_DB_SCHEMA_VERSION 6 -> 7, so the upgrade is checksummed, transactional and snapshotted before it runs. - Drop the ADDED_COLUMNS entry: the contract step now owns the column. Tests cover both layouts (missing column fails �alidate_core first, an early column is recorded without replaying), the double-open idempotence, and a rollback that retries from its ledger like the other steps. ER.md documents the run field.
huichen
enabled auto-merge (squash)
November 16, 2026 14:27
huichen
added a commit
that referenced
this pull request
Nov 16, 2026
The multi-device e2e test asserted "the controller must not be told to stand by just because a device connected" by counting *any* control packet in a 300 ms window. The machine also announces a device's own arrival (`control: active`) on that same channel, from a task the handshake spawns after it has answered, so that notice races the activation of the sealed channel: while the seal has no key it is dropped, and once the client's `secure_ready` activated one it is delivered. On a loaded runner it is delivered, the `active` lands inside the window, and the assertion reported a displacement that never happened (CI run 43885835542 on PR #1630). `told_to_stand_by` now opens each packet and counts only a control state that is not `active` — and, deliberately, any state this test does not know and any packet it cannot open — so a real "stand by" notice still fails it (verified by publishing one at a device's connect) while the device's own arrival no longer does. The window, the assertion and its message are unchanged; only what counts as news is.
huichen
added a commit
that referenced
this pull request
Nov 16, 2026
The multi-device e2e test asserted "the controller must not be told to stand by just because a device connected" by counting *any* control packet in a 300 ms window. The machine also announces a device's own arrival (`control: active`) on that same channel, from a task the handshake spawns after it has answered, so that notice races the activation of the sealed channel: while the seal has no key it is dropped, and once the client's `secure_ready` activated one it is delivered. On a loaded runner it is delivered, the `active` lands inside the window, and the assertion reported a displacement that never happened (CI run 43885835542 on PR #1630). `told_to_stand_by` now opens each packet and counts only a control state that is not `active` — and, deliberately, any state this test does not know and any packet it cannot open — so a real "stand by" notice still fails it (verified by publishing one at a device's connect) while the device's own arrival no longer does. The window, the assertion and its message are unchanged; only what counts as news is.
huichen
added a commit
that referenced
this pull request
Nov 16, 2026
The multi-device e2e test asserted "the controller must not be told to stand by just because a device connected" by counting *any* control packet in a 300 ms window. The machine also announces a device's own arrival (`control: active`) on that same channel, from a task the handshake spawns after it has answered, so that notice races the activation of the sealed channel: while the seal has no key it is dropped, and once the client's `secure_ready` activated one it is delivered. On a loaded runner it is delivered, the `active` lands inside the window, and the assertion reported a displacement that never happened (CI run 43885835542 on PR #1630). `told_to_stand_by` now opens each packet and counts only a control state that is not `active` — and, deliberately, any state this test does not know and any packet it cannot open — so a real "stand by" notice still fails it (verified by publishing one at a device's connect) while the device's own arrival no longer does. The window, the assertion and its message are unchanged; only what counts as news is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes: an existing desktop database can open again after the choice mark reached
SCHEMAwithout a contract of its own, and the phone's share cache reclaims old copies instead of locking attachment handoff for a day.Commits
runs.offers_choicebefore startup validation — adopt the column under contract 7 (APP_DB_SCHEMA_VERSION6 → 7), keep the released 6 immutable, and drop theADDED_COLUMNSentry the contract step now owns. Tests cover a contract-6 database with and without the early column, the double-open idempotence, and a rollback retried from its ledger.ER.mddocuments the field.namedExternalFilenow frees the oldest copies underfutureos-exports(copies younger thanEXPORT_PROTECT_MSfirst, then the oldest anyway when a burst leaves no room) instead of throwingattachment_export_cache_fulluntil the 24 h retention expired. The one refusal left is the code mapped to a localizedattachment.exportCacheFullline; a native failure still shows its own words.Verification
Toolchain: pinned rustc 1.99.1 (Homebrew's 1.96.0 shadowed off PATH), Node 26.3.0,
ulimit -n 8192. Run atb566353fdin the main checkout, tracked tree clean.cargo fmt --all -- --check→ cleancargo check -p future-host -p future-app-settings --all-targets→ clean, 8.2 scargo clippy -p future-host -p future-app-settings --all-targets -- -D warnings→ clean, 7.4 scargo test -p future-app-settings→ 22 passedcargo test -p future-host --lib→ 2269 passed / 0 failed / 15 ignored, 446 snpx tsc --noEmitclean;npx eslinton the five changed files clean;npx jest src/remote/__tests__/files.test.ts src/features/chat/__tests__/useFileDownload.test.ts→ 2 suites, 261 passedmake check-docs→ 421 docs OK, 0 pairs pending, provider matrix 13 rowsNotes
app.dbupgrades it from contract 6 to 7. The step is checksummed, transactional and snapshotted before it runs; a failure rolls back and retries from the ledger like the other steps. A row written before the column existed is kept, with the mark defaulting to 0.ALTER, so early marks survive either layout.User-visible changes
runs.offers_choice— the released contract and every desktop built since the mark landed — was refused at startup withDesktop database is incomplete: required runs.offers_choice is missing.After: it opens, the column is added inside a snapshotted transaction, and the run rows are kept. Revert898ff2e3d.futureos-exports, every open/share threwattachment_export_cache_fulluntil the 24 h retention expired (a burst of 7 MB wavs was enough to lock sharing for a day). After: the oldest copies are deleted to make room, copies younger than 10 minutes are preserved while an older one is available, and the single remaining refusal is shown as a localized sentence (attachment.exportCacheFull, en + zh) rather than the internal code. Revert666cbc8b9.