UPGRADE PROOF
The owner's phone at an upgrade, on invented data. The core at an old sha, the build on the phone, fills a copy against a local personal object under wrangler dev. Then the core at HEAD opens that same copy and syncs it.
cd apps/business && pnpm -s exec tsx scripts/__tests__/upgrade-proof.ts # every case cd apps/business && pnpm -s exec tsx scripts/__tests__/upgrade-proof.ts words@head # HEAD plays the old side too
old-core.sh <sha>builds the old side's test binary from a detached worktree at that sha. It copies today'supgrade_writer.rsin, caches the binary under<lane>/upgrade-cache/bin/<sha>-<writer hash>and removes the worktree. The first build takes about 7 minutes; after that it is instant.crates/cotton-ffi/src/phone/upgrade_writer.rsis the old side. Each test is one launch of the old build, run in order.crates/cotton-ffi/src/phone/upgrade_proof.rsis the HEAD side. It checks the copy at open (before any pass) and after passes, then checks what a second phone reads from the object.apps/business/scripts/__tests__/upgrade-proof.tsruns both sides. It also checks the object's change log for each record: nothing sent twice, nothing refused arrives.
Adding a case in five lines
- To prove an existing app at another build, add
{ "app": "words", "sha": "<sha>" }tocases.json. That is the whole change. - To add a new app, write
upgrade_old_side_writes_a_<app>_copy_*inupgrade_writer.rs. Use only what every phone build since 24 Nov has: the app's own methods,personal.connect,seal.mintKeyandseal.useKey,mint,rejected::park. Write the manifest. - Write its HEAD side in
upgrade_proof.rs: open, comparecopy_statewith the manifest, connect,seal.useKey, pass, compare again. - Name both in
WRITERSinupgrade-proof.ts, and add any object-side counts. - Try it with
<app>@headfirst, then add the old shas tocases.json.