refactor(platform-apple): colocate sixteen tests with the modules they test

Merged
TH
11h ago
+155-147

Summary

Colocation renames for platform-apple: 16 of the 19 test files that were not beside a module they are named for (my recount matched the coordinator's 19). No fixture export is touched. The remaining three are explained below.

The rule thread's baseline is now a merge-base ratchet, so there is nothing to delete; counts are from my scan (/tmp/coloc/scan.mjs, same definition as the coordinator's numbers).

Commits

  1. refactor(tests): name platform-apple tests for the module they test — git mv plus specifier changes. Beyond import specifiers: the Swift-sources path in interactions.test.ts (moved up two directories), and references to the old paths in .github/workflows/macos.yml (the native-proof lane lists cache-native-runtime.test.ts), two docs, an ADR, a few comments, the command-coverage evidence in test/integration/command-coverage/declarations.ts, and the boundary-fault evidence in packages/test-kit/src/boundary-fault-matrix.ts.
  2. refactor(platform-apple): split the runner response test by the module it covers — decodeRunnerResponseBody and siblings live in runner-contract.ts, parseRunnerResponse in runner-exchange.ts.
  3. refactor(platform-apple): name the runner dispatch-disclosure driver for the runner entry — per the coordinator's decision; the contracts fixture's owning path follows.

Renames (all under packages/platform-apple/src)

OldNewModule under test
runner/__tests__/runner-close-finalizationrunner-session-close-finalizationrunner-session.ts (releaseIosRunnerOnClose, stopIosRunnerSession)
runner/__tests__/runner-command-busy-resendrunner-client-busy-resendrunner-client.ts (runAppleRunnerCommand)
runner/__tests__/runner-command-retryrunner-client-command-retryrunner-client.ts
runner/__tests__/runner-recovery-wiringrunner-client-recovery-wiringrunner-client.ts (header: enters at runAppleRunnerCommand on purpose)
runner/__tests__/runner-early-exit-diagnosisrunner-startup-transport-early-exitrunner-startup-transport.ts (buildRunnerEarlyExitError)
runner/__tests__/runner-readiness-routingrunner-command-traits-readiness-routingrunner-command-traits.ts
runner/__tests__/runner-request-cancellationrunner-lifecycle-request-cancellationrunner-lifecycle.ts
runner/__tests__/runner-start-admissionrunner-xctestrun-start-admissionrunner-xctestrun.ts (start-admission functions)
runner/__tests__/runner-startup-failure-reasonsrunner-xctestrun-startup-failure-reasonsrunner-xctestrun.ts (ensureXctestrunArtifact)
runner/__tests__/runner-responsesplit → runner-contract-response, runner-exchange-responserunner-contract.ts, runner-exchange.ts
runner/__tests__/runner-dispatch-disclosureindex-dispatch-disclosurerunner entry (drives several runner modules against the contracts table)
__tests__/screenshot-backend__tests__/interactor-screenshot-backendinteractor.ts
__tests__/watchos-sentinel__tests__/interactor-watchos-sentinelinteractor.ts
core/__tests__/interactionssrc/interactions.test.tssrc/interactions.ts (+ the Swift route-parity test)
core/__tests__/runner-mac-archcore/__tests__/runner-client-mac-archcore/runner-client.ts (see below)
snapshot-source/native-runtimesnapshot-source/cache-native-runtimesnapshot-source/cache.ts (buildSnapshotBridgeCompileArgv)

Not changed

  • runner-mac-arch stays under core/. I first moved it beside apple-runner-platform.ts, and R77 (apple-runner-host-port) rejected it: the test imports @agent-device/host-kit/command and /process directly, which is forbidden under runner/. Its import '../runner-client.ts' is also the production host binding it relies on, so runner-client-mac-arch is the honest name in core/__tests__.
  • runner/__tests__/runner-requests.test.ts and __tests__/runner-requests.test.ts: cross-module request-site conformance drivers whose *runner-requests.test.ts name is a contract (runner-requests.json producer paths and the endsWith check). Unrenamed; flagged to the coordinator.
  • core/__tests__/apps.test.ts (24 tests over 6 modules) needs a real split; it is the next PR.

Test-count parity (vitest --reporter=json, passed/total)

BeforeAfter
runner-close-finalization 18runner-session-close-finalization 18
runner-command-busy-resend 7runner-client-busy-resend 7
runner-command-retry 33runner-client-command-retry 33
runner-recovery-wiring 47runner-client-recovery-wiring 47
runner-early-exit-diagnosis 11runner-startup-transport-early-exit 11
runner-readiness-routing 1runner-command-traits-readiness-routing 1
runner-request-cancellation 8runner-lifecycle-request-cancellation 8
runner-start-admission 12runner-xctestrun-start-admission 12
runner-startup-failure-reasons 33runner-xctestrun-startup-failure-reasons 33
runner-response 11runner-contract-response 8 + runner-exchange-response 3
screenshot-backend 1interactor-screenshot-backend 1
watchos-sentinel 2interactor-watchos-sentinel 2
core/__tests__/interactions 25interactions 25
runner-mac-arch 1runner-client-mac-arch 1
native-runtime 47cache-native-runtime 47
runner-dispatch-disclosure 31index-dispatch-disclosure 31
257 (+31) in 15 (+1) files257 (+31) in 16 (+1) files

Selection: runner/** files run in the apple-runner project, everything else in unit-core; no file changed project. check:affected --run selected 336 test files (2,519 tests, all passed) including the renamed ones. The macOS workflow lane that lists cache-native-runtime.test.ts is updated.

vi.mock effectiveness

Pointed each mock path at a nonexistent module, one at a time, and reverted:

FileMockResult
runner-session-close-finalization../runner-io.ts11 failed / 18
../runner-startup-transport.ts15 failed / 18
../runner-transport.ts2 failed / 18
../runner-xctestrun.ts16 failed / 18
runner-client-busy-resend../runner-session.ts7 failed / 7
runner-client-command-retry../runner-session.ts33 failed / 33
../runner-xctestrun.ts33 passed / 33
runner-client-recovery-wiring../runner-session.ts42 failed / 47
runner-lifecycle-request-cancellation../runner-io.ts8 passed / 8
../runner-startup-transport.ts6 failed / 8
../runner-xctestrun.ts8 failed / 8
interactions./core/runner-client.ts25 failed / 25
interactor-screenshot-backend../core/screenshot.ts1 failed / 1

Two mocks (bold) are not load-bearing for any current case. They are unchanged by this PR; I'll spy-check them and remove the dead ones in a follow-up unless you want them here.

Surface

  • exports counts: platform-apple 21 → 21 (no subpath added or removed).
  • Colocation offenders: platform-apple 19 → 3 (apps.test.ts and the two runner-requests.test.ts drivers described above).

Gates

check:quick, check:layering, check:fallow, check:gate-manifest, check:affected --run all pass on the commit before the dispatch-disclosure rename; the rename is covered by index-dispatch-disclosure (31) and contracts/dispatch-disclosure (3) passing, and pnpm format is clean. I'll rerun the full set on the final head if you want it before merge.

🤖 Generated with Claude Code