refactor: migrate snapshot to device runtime

Merged
TH
3mo ago
+2859-878

Summary

Migrate the public snapshot command from legacy capability dispatch to the ADR 0019 request-scoped device runtime.

  • model the cutover as three exact-owner operations and four parametrized request plans, with one facts inspection and one runtime bind per handler
  • enforce R32 through a deliberately bounded positive seam: the route selects one normalized plan.use and passes that exact use to the shared inspectRequiredRuntimeUse; local snapshot admission policy is rejected
  • remove the custom identity-flow/alias tracker instead of extending it with another omission patch; the structural rule no longer depends on identifier spelling, aliases, destructuring, or object wrapping
  • preserve Apple, Android, HarmonyOS, Linux, web, WebDriver, and Limrun behavior, including macOS surfaces, Linux shaping, cancellation, watchOS denial, provider fail-closed behavior, and public-only sparse screenshot fallback
  • retire generic snapshot dispatch, static capability admission, descriptor dispatch projection, and two daemon-to-platform value edges
  • keep shared diff/find/wait/interaction capture consumers on one narrow interactor seam until their own command units migrate; no unrelated command descriptor was implicitly migrated
  • remove duplicate Linux/macOS desktop capture implementations and the thin host wrapper; production duplication remains flat at 5 groups / 207 lines
  • make the iOS smoke scroll helper require actual visibility before skipping a scroll, with capture-stall retries that do not consume scroll attempts

The measured snapshot-unit budget approved on #1739 was +10,209 B JS raw, +3,058 B JS gzip, +2,590 B npm tarball, and +10,226 B unpacked against its authorized base: https://github.com/callstack/agent-device/issues/1739#issuecomment-5317036300. Returning to a non-positive delta requires separately migrating the remaining legacy capture consumers and is intentionally outside this command-atomic unit.

Validation

  • rebased onto main at 60f6356b0
  • exact head: bea6ce36d
  • clean committed tree: pnpm check:affected --run passed all locally runnable selected gates before the chained force-with-lease push
  • affected Vitest/coverage run: 603 files / 4,907 tests passed; changed-line coverage 206/217 (94.93%)
  • R32 planted red includes the reported { device } object-wrapper bypass; the positive route-to-owner-facts seam rejects the local admission reimplementation without reconstructing JavaScript data flow
  • rebase conflict reconciliation retained main's caller-supplied replay-source model and the migrated narrow snapshot capture seam; focused replay/runtime tests passed 82/82
  • latest-main replay-source test exposed one stale generic snapshot mock after rebase; the owning test now uses the narrow snapshot fixture (red: 5.00s timeout, green: 5/5 in 20ms)
  • pnpm typecheck, pnpm check:fallow --base origin/main, pnpm format, package verification, wire compatibility, replay compatibility, and git diff --check passed through the aggregate gate
  • no local simulator or device command was run because benchmarks are active; GitHub native/device lanes remain authoritative
  • fresh exact-head GitHub checks were queued after the force-push; this update does not claim they are complete

Docs/skills are unchanged because this is an internal runtime cutover, consolidation, and enforcement correction with no public CLI or workflow behavior change.