Skip to content

Physical iOS deploys never empty the app container (MOB-408) - #142

Merged
GenericJam merged 4 commits into
masterfrom
mob-408-ios-deploy-versioned
Oct 15, 2026
Merged

GenericJam merged 4 commits into
masterfrom
mob-408-ios-deploy-versioned

Conversation

@GenericJam

Copy link
Copy Markdown
Owner

MOB-408, deployer half. Runtime half: GenericJam/mob#207 (mob 0.9.20).

Problem

mix mob.deploy to a physical iPhone copied BEAMs with xcrun devicectl device copy to ... --destination Documents/otp/<app> --remove-existing-content true. Measured on Kevin's iPhone SE (devicectl 642.16): with that flag devicectl empties the app's whole data container except the destination. Reproduced with a blank host on mob 0.9.19 + mob_dev 0.7.26: a Documents sentinel, a SQLite row, a nested dir, a Library/ file and a sibling in Documents/otp were all gone after one BEAM-only deploy.

Change

  • No copy passes --remove-existing-content; every copy is a merge.
  • ios_code_plan/2: if the project's :mob dep ships ios/mob_code_versions.h and the phone has Documents/otp/<app>.versions/ (the new runtime creates it at boot), upload to a fresh <app>.versions/<N> (N above every listed entry), read back <app>.beam, then copy <N>/.mob_complete. Otherwise merge into Documents/otp/<app> for the older runtime.
  • After the relaunch, wait (≤ 20 s) for Documents/mob_diag_beams_dir.txt (written at boot by every runtime since mob 0.6.2) to name the directory just written; fail otherwise, naming where the app booted from. Catches an app whose native runtime and :mob dep disagree, where the plan's guess would be ignored or shadowed.
  • An error after the upload began says what it left on the phone.
  • Docs: CHANGELOG (Upgrading), AGENTS.md rule, mob.deploy moduledoc, decisions/2026-10-15-ios-deploy-never-empties-the-container.md, amendments to two older records, the persistable?/1 comment.

Verification

  • mix test (3042 passed), mix credo --strict, mix format --check-formatted, mix compile --warnings-as-errors locally.
  • Kevin's iPhone, blank host d408 with this branch + mob#207 (path deps): sentinels survived ~16 deploys (legacy push on the first --native, then versioned 1→12, GC'd behind); killing the devicectl copy mid-upload (382/448 entries) and killing mix mid-deploy both left the previous version booting; the next deploy collected the partial dirs. Old runtime (mob 0.9.19 via --native): legacy merges, nothing wiped, even with a leftover <app>.versions/. Mismatches: new deps on the old runtime and old deps on the new runtime each failed the deploy with the booted-from path instead of reporting success.

Review

Codex rate-limited (until 17:26) → reviewer subagent: MERGE; its should-fix (silent stale code when the guess is wrong) is fixed by the boot check in 06a826b. Re-review: see comment below.

The deploy copied BEAMs with devicectl --remove-existing-content, meant to
replace Documents/otp/<app>; on an iPhone it empties the app's whole data
container except the destination (SQLite, sessions, Library, tmp), on every
deploy. Every copy is now a merge.

For a runtime that reads them (the project's mob has ios/mob_code_versions.h
and the phone has Documents/otp/<app>.versions/, which that runtime creates at
boot), upload to a fresh <app>.versions/<N> numbered above every listed entry,
read back <app>.beam, then copy <N>/.mob_complete: the app loads only
committed versions, so an interrupted deploy leaves the previous code running.
Older runtimes get a merge into Documents/otp/<app>; an error after the copy
began says what each case leaves on the phone.

Decision: decisions/2026-10-15-ios-deploy-never-empties-the-container.md.
Review: ios_code_plan/2 can still guess wrong when the project's mob moves
across 0.9.20 without --native (a versioned upload an old runtime ignores, or a
legacy merge a new runtime shadows with its committed version), and the deploy
then reported success while the phone ran old code. After the relaunch, wait
(up to 20 s) for Documents/mob_diag_beams_dir.txt, which every runtime since
mob 0.6.2 writes at boot, to name the directory just written; otherwise fail,
naming where the app booted from. Clear the partial-upload note once the
marker is committed. Decision record: correct the downgrade claim, the
--native wording, note concurrent deploys.
A legacy deploy expects the same Documents/otp/<app> path every time, so the previous boot's mob_diag_beams_dir.txt could satisfy the check before the new boot wrote its own. Overwrite it with a placeholder before the relaunch; a placeholder or missing file at the deadline reports that the app never said what it loaded.
@GenericJam
GenericJam force-pushed the mob-408-ios-deploy-versioned branch from 06a826b to 6fc00a6 Compare October 15, 2026 20:16
@GenericJam
GenericJam merged commit 4c59bda into master Oct 15, 2026
6 checks passed
@GenericJam
GenericJam deleted the mob-408-ios-deploy-versioned branch October 15, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant