gstack/ios-qa/daemon
Autonomy AI, LLC ec58d9e561 fix(ios-qa): reuse rotated bearer across bootstraps so a real device drives end-to-end
The in-app StateServer boot token is single-use: the first POST /auth/rotate
invalidates it AND deletes the on-disk token file. But the daemon re-ran the
full bootstrap (copy boot token + rotate) on every 30s tunnel-cache refresh,
daemon restart, and new /ios-qa session, so the 2nd+ bootstrap hit
boot_token_unavailable (CoreDeviceError 7000, file gone) and a real device was
drivable exactly once per app launch (the simulator was unaffected; it never
uses the devicectl file-copy path).

Implement the warm-start that SKILL.md Phase 0 documents but the daemon never
had: persist the rotated bearer the daemon already holds to
~/.gstack/ios-qa-session.json (0600) and reuse it after a cheap authed probe;
only fall back to a full boot-token bootstrap when there is no cache or the
cached token is rejected (probe 401 = app was relaunched). Zero device-side
change: StateServer stays loopback-only, every endpoint still requires the
rotated bearer, and the boot token stays single-use.

Also close the cold-start gap: forward GSTACK_IOS_LAUNCH_ENV to
`devicectl ... --environment-variables` so the daemon can launch apps whose
debug bridge is env-gated (e.g. BuckHound's BH_ENABLE_IOS_QA_BRIDGE=1) instead
of launching them without the bridge.

- new ios-qa/daemon/src/session-cache.ts (acquireTunnel + cache I/O)
- index.ts realTunnelProvider uses acquireTunnel
- devicectl.launchApp forwards env; bootstrapTunnel threads launchEnv
- 16 new tests (session-cache, launch-env); full daemon suite 107 pass

Verified end-to-end on a physical iPhone 16 Pro: a fresh daemon process drove
/elements + /screenshot + /tap purely by reusing the cached bearer while the
boot token was confirmed consumed (CoreDeviceError 7000).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 21:37:56 -04:00
..
src fix(ios-qa): reuse rotated bearer across bootstraps so a real device drives end-to-end 2026-05-29 21:37:56 -04:00
test fix(ios-qa): reuse rotated bearer across bootstraps so a real device drives end-to-end 2026-05-29 21:37:56 -04:00