# 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 ` builds the old side's test binary from a detached worktree at that sha. It copies today's `upgrade_writer.rs` in, caches the binary under `/upgrade-cache/bin/-` and removes the worktree. The first build takes about 7 minutes; after that it is instant. - `crates/cotton-ffi/src/phone/upgrade_writer.rs` is the old side. Each test is one launch of the old build, run in order. - `crates/cotton-ffi/src/phone/upgrade_proof.rs` is 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.ts` runs 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 1. To prove an existing app at another build, add `{ "app": "words", "sha": "" }` to `cases.json`. That is the whole change. 2. To add a new app, write `upgrade_old_side_writes_a__copy_*` in `upgrade_writer.rs`. Use only what every phone build since 24 Nov has: the app's own methods, `personal.connect`, `seal.mintKey` and `seal.useKey`, `mint`, `rejected::park`. Write the manifest. 3. Write its HEAD side in `upgrade_proof.rs`: open, compare `copy_state` with the manifest, connect, `seal.useKey`, pass, compare again. 4. Name both in `WRITERS` in `upgrade-proof.ts`, and add any object-side counts. 5. Try it with `@head` first, then add the old shas to `cases.json`.