Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Done

- **Branch / head SHA**: `alanvardy-var-1175-run-the-regular-iphone-and-ipad-legs-in` / `2631b6875afa5afc88c1ce55a42977520cab8a31` (`fix: scope ControlPlateModifier to macOS`)
- **Mechanical checks**:
- `bash -n scripts/run-devices.sh` and `scripts/test-run-devices.sh`: pass.
- `./scripts/test-run-devices.sh`: pass (32 checks).
- `make lint`: pass (0 violations).
- `make format`: pass (no changes after the fix).
- `git diff --check`: pass.
- Shellcheck: pass except pre-existing `SC1111` unicode-quote warning at `scripts/run-devices.sh:124` (identical on `main`).
- Full CI-identical gate on `0d362077`: executable stages **PASS** — iOS UI 6/6, watch UI 1/1, watch unit 81/81, mac unit 862/862; warning-check 20/20; format/lint/build passed. The original gate aborted at Periphery with 2 findings in `ControlPlateModifier.swift`; the test-stage verdict was obtained via the authorized Option B continuation with Periphery skipped.
- **Periphery false positive fixed** in `2631b687`: `SingleThread/ControlPlateModifier.swift` is now compiled only on macOS, where its `.controlPlate()` usages live. `periphery scan --strict -- -destination "platform=iOS Simulator,id=BD205AB3-B188-48F1-B45A-3EE33B972ABB"` now reports **no unused code**. The macOS build also succeeds. The full gate was **not rerun** after this fix; targeted checks cover the changed file.
- **Review outcome**: No blockers. The bounded reviewer found no merge-blocking issue. Two non-blocking P1s remain deferred to the user: (1) `devicectl list` failure still hard-aborts `IOS_TARGET=sim` before the simulator legs run; (2) a set-but-nonmatching `DUO_DEVICE_ID` silently drops the Duo with no notice. Optional P2s noted: validate `IOS_TARGET` (`sim|device`), fix the empty `SIM_WATCH` notice text, adjust summary wording for device/no-Duo cases, mirror `test.sh`'s stale `.simulator_id` warning, wire the new offline harness into CI, and remove the walking-skeleton header wording. No P1/P2 fixes were applied because the review ran without `autofix`; the user's [1]/[2] menu decision remains open.
- **Remaining manual items**:
- Apply the P1s (and optionally P2s) if desired.
- Run the full gate again for the new fix commit if a complete post-fix verdict is required.
- Run `./scripts/run-devices.sh` against real hardware/simulators; the sim/Duo/watch/macOS legs were verified offline via stubs only.
- Complete the manual verification items in `plan.md`/`implement.md`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Implementation Summary

Ticket: VAR-1175 — run the regular iPhone and iPad legs in simulators.
Branch: `alanvardy-var-1175-run-the-regular-iphone-and-ipad-legs-in`

## Commits

| Phase | Commit | Description |
|-------|------------|----------------------------------------------------|
| 1 | `40425634` | Walking skeleton — sim iPhone leg end-to-end |
| 2 | `de664f63` | iPad simulator leg and sim sad paths |
| 3 | `f46205ca` | Watch leg on watch simulators |

Bootstrap commit (parent): `b0b7b4f9` — plan/task artifacts added, `DELETEME`
marker removed (`git rm DELETEME`) as required before merge.

## What shipped

`scripts/run-devices.sh` now:

- Runs the **regular iPhone and iPad legs in simulators** by default
(`IOS_TARGET=sim`), booting via `simctl bootstatus -b`, building with
`-destination id=<udid>`, then `simctl install` / `simctl launch`.
- Keeps the **physical iPhone Duo** on devicectl in both modes.
`DUO_DEVICE_ID=<udid>` wins when set, otherwise a case-insensitive
substring match on the device name (`iPhone Duo`).
- Runs the **Apple Watch leg on a watch simulator**
(`Apple Watch Series 11 (46mm)` by default); the physical watch discovery /
devicectl install / launch path, `WATCH_UNREACHABLE*`,
`WATCH_BUILD_NEEDED`, the launch-form bookkeeping and the 4016 messaging are
gone. An unavailable watch sim is a notice, not a failure.
- Offers `IOS_TARGET=device` to restore the old all-physical iPhone/iPad sweep
(the Duo is still deployed physically, and the watch still runs on a sim —
there is deliberately no `WATCH_TARGET`).
- Resolves simulator names to concrete UDIDs (`resolve_sim_udid` copied from
`scripts/test.sh`, anchored `index(s, n " (") == 1` match) so `iPhone 17`
never picks up the leftover `Gate iPhone 17` sim; the iPhone prefers this
worktree's `.simulator_id`, the iPad and watch never inherit it.
- Reports every leg honestly in the summary:
`iPhone/iPad (sim): N/M launched` + `iPhone Duo (device): …` in sim mode,
`iPhone/iPad (device): …` in device mode, `Apple Watch (sim): …` or
`skipped (RUN_WATCH=0)`.

`scripts/test-run-devices.sh` was rewritten for the new behaviour and stays
offline-only (stubbed `xcrun`/`xcodebuild`/`open`, sim-vs-device fixtures).

## Automated Checks

- [x] `bash -n scripts/run-devices.sh` passes (all phases)
- [x] `bash -n scripts/test-run-devices.sh` passes
- [x] `shellcheck -S warning --exclude=SC1111 scripts/run-devices.sh` passes
- [x] `bash scripts/test-run-devices.sh` passes — all filter and flow checks,
including the sim happy path (`2/2 launched`), `IOS_TARGET=device`
oracle, `DUO_DEVICE_ID`, boot failure, missing sim product, unresolvable
iPad sim, watch launch, no-watch-sim notice, and watch boot failure
- [x] `make lint` passes (0 violations, 248 files)
- [x] No watch `devicectl` references remain in `scripts/run-devices.sh`
(`WATCH_DEVICES|WATCH_UNREACHABLE|watchkitapp.*devicectl` → nothing; the
`4016` alternative still matches two pre-existing **iOS-only** comments,
which are in scope for neither this ticket nor Phase 3)
- [x] `test-run-devices.sh` needs no gate wiring:
`rg -n 'test-run-devices' Makefile scripts/test.sh` returns nothing

## Observations (not changed — out of plan scope)

- Phase 3 used `resolve_ios_udid "$SIM_WATCH" "$DEFAULT_WATCH_SIM" 0` rather
than the plan's literal `resolve_sim_udid "$SIM_WATCH"`, so the documented
"empty → Apple Watch Series 11 (46mm)" default and the
`SIM_WATCH=No Such Watch` sad path both behave as the header and tests say.
- The header still describes devicectl provisioning-device registration for
the Duo (still accurate); the simulator legs don't need it.

## Manual Verification Items (from the plan)

- [ ] `IOS_TARGET=device DEVICES_JSON_IN=scripts/fixtures/devicectl-devices.json RUN_WATCH=0 RUN_MAC=0 ./scripts/run-devices.sh`
emits the old all-physical discovery/filter messages and the `(device)`
summary line.
- [ ] After the sim leg runs for real, confirm the booted worktree sim shows the
app launched.
- [ ] `./scripts/run-devices.sh` (or `r`) boots the worktree iPhone sim **and**
the iPad sim, installs/launches `SingleThread` on both, and the summary
prints `iPhone/iPad (sim): 2/2 launched`.
- [ ] With `SIM_IPAD=No Such Device ./scripts/run-devices.sh`, the run reports
the iPad as a failed step but still launches the Duo (if present) and
macOS.
- [ ] `./scripts/run-devices.sh` (or `r`) boots an Apple Watch simulator,
installs and launches `SingleThreadWatch`, and prints
`Apple Watch (sim): 1 launched, 0 failed`.
- [ ] `RUN_WATCH=0 ./scripts/run-devices.sh` prints
`Apple Watch (sim): skipped (RUN_WATCH=0)` and does no watch build.
- [ ] With `IOS_TARGET=device` and a Duo + watches present, only the Duo is
touched on hardware and the watch still runs on the simulator.

## Post-plan gate (review step)

- [ ] `./scripts/test.sh` via the `run-gate` skill (build + lint + Periphery +
unit + UI) — runs **once**, after the phases commit.
- [ ] `make format` + `make lint` before the final commit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Task

Change `scripts/run-devices.sh` so the **regular iPhone and iPad legs run in the
simulator** instead of on physical hardware, while the **physical iPhone Duo**
and the **macOS leg stay exactly as they are**.

Concretely:

1. **Split the iOS discovery filter.** Today one inline-Python filter over
`xcrun devicectl list devices -j` selects every physical `platform == iOS`,
`deviceType in (iPhone, iPad)` entry, and one build/install/launch loop runs
per entry — which sweeps in the physical `iPhone Duo`
(`scripts/fixtures/devicectl-devices.json`: `Fixture iPhone Duo | iOS iPhone
physical`). Split it so:
* physical **Duo** keeps the existing `devicectl` build / `install` /
`launch` path (targeting `Debug-iphoneos/SingleThread.app`);
* regular physical iPhone/iPad entries are dropped from the device loop.
2. **Add a simulator leg** for a regular iPhone and a regular iPad:
* Defaults `iPhone 17` and `iPad (A16)`, overridable via `SIM_IPHONE=` /
`SIM_IPAD=`, resolved to UDIDs with the **same precedence as
`scripts/test.sh:28-72`** (this worktree's `.simulator_id` → shared
default, pinned by UDID; never a bare ambiguous `name=`).
* Recipe to copy: `simctl boot` → `bootstatus -b` → build with
`-destination` = the sim → `simctl install` → `simctl launch`, against the
**sim** product path `Debug-iphonesimulator/SingleThread.app` (distinct
from the `Debug-iphoneos/` path the Duo uses).
* Respect the per-worktree simulator lock / window conventions (see the
`simulator` skill) — do not boot a shared device another lane holds.
3. **Escape hatch:** add `IOS_TARGET=sim|device` (default `sim`) so the old
all-physical behavior is one env var away. Document it in the header block.
4. **Two decisions the plan must resolve with the human** (the ticket flags
both as "decision needed"):
* Watch leg — leave on physical watches (ticket's assumption) or move to
paired watch sims.
* Duo identity — name match on `iPhone Duo` (fails open if renamed) vs a
hardcoded `DUO_DEVICE_ID=` env override.
5. **Summary output** must report both legs honestly (Duo launched, sims
launched, macOS status) instead of collapsing them into one line.
6. **Update `scripts/test-run-devices.sh` (223 lines):** the
`"every paired physical iPhone installs (Duo included)"` flow assertion
becomes Duo-only (1/1); the discovery-filter fixtures need a sim-vs-device
split; flow tests need a **stubbed `simctl`**; cover both happy and sad
paths (sim boot failure, missing sim product, Duo unreachable).

Why: each current run costs N device builds and needs unlocked, on-network
hardware for the phone/iPad legs — that friction is what this removes. Sims give
the same "app is running where I can poke at it" feedback without the hardware
dance. No new unit-test target is required — `scripts/test-run-devices.sh` is
the coverage. Out of scope: the watch leg (unless decided above), the macOS leg,
and CI.

## Why MEDIUM

M1 holds: approach known — 2 flagged decisions only, no new technology (`simctl`
is already used), and a working recipe exists to copy
(`scripts/appstore-screenshots.sh:548-551`) alongside a UDID-resolution pattern
(`scripts/test.sh:28-72`). M2 holds: no schema/migration, no new subsystem or
integration, no API/UI surface, no new test target; the two open items are
scoped choices resolvable at the plan gate. M3 holds: **MULTI_MODULE** (spans
`scripts/run-devices.sh`, `scripts/test-run-devices.sh`, and the devicectl
fixture) and **BROAD_TEST_SURFACE** (the flow-test harness must gain a stubbed
`simctl` plus sim-vs-device fixtures and sad-path cases). This is known-approach
work at a broad size — one plan step, then the standard implement → review tail.

## Key files

* `scripts/run-devices.sh` (468 lines) — the target; iOS discovery filter,
device build/install/launch loop, leg counters, and Phase 3 summary, plus the
`RUN_WATCH` / `RUN_MAC` env-var pattern to mirror for `IOS_TARGET`.
* `scripts/test-run-devices.sh` (223 lines) — the coverage; `extract_filter()`,
`run_flow()` harness, the 3/3-launched assertion to retarget, and the fixture
assertions.
* `scripts/fixtures/devicectl-devices.json` — device inventory fixture; contains
the physical `Fixture iPhone Duo` and the sim entries that drive the
sim-vs-device split.
* `scripts/appstore-screenshots.sh:548-551` — the working `simctl` boot/install/
launch recipe to copy.
* `scripts/test.sh:28-72` — `.simulator_id` / shared-default UDID resolution and
the multi-runtime ambiguity guard to replicate, not reinvent.
* `Makefile` / `scripts/test.sh` — check whether a new `IOS_TARGET`/fixture seam
needs wiring into the test gate.
Loading