Skip to content

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

Merged
thymikee merged 5 commits into
mainfrom
refactor/colocate-platform-apple-tests
Oct 15, 2026
Merged

thymikee merged 5 commits into
mainfrom
refactor/colocate-platform-apple-tests

Conversation

@thymikee

@thymikee thymikee commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

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)

Old New Module under test
runner/__tests__/runner-close-finalization runner-session-close-finalization runner-session.ts (releaseIosRunnerOnClose, stopIosRunnerSession)
runner/__tests__/runner-command-busy-resend runner-client-busy-resend runner-client.ts (runAppleRunnerCommand)
runner/__tests__/runner-command-retry runner-client-command-retry runner-client.ts
runner/__tests__/runner-recovery-wiring runner-client-recovery-wiring runner-client.ts (header: enters at runAppleRunnerCommand on purpose)
runner/__tests__/runner-early-exit-diagnosis runner-startup-transport-early-exit runner-startup-transport.ts (buildRunnerEarlyExitError)
runner/__tests__/runner-readiness-routing runner-command-traits-readiness-routing runner-command-traits.ts
runner/__tests__/runner-request-cancellation runner-lifecycle-request-cancellation runner-lifecycle.ts
runner/__tests__/runner-start-admission runner-xctestrun-start-admission runner-xctestrun.ts (start-admission functions)
runner/__tests__/runner-startup-failure-reasons runner-xctestrun-startup-failure-reasons runner-xctestrun.ts (ensureXctestrunArtifact)
runner/__tests__/runner-response split → runner-contract-response, runner-exchange-response runner-contract.ts, runner-exchange.ts
runner/__tests__/runner-dispatch-disclosure index-dispatch-disclosure runner entry (drives several runner modules against the contracts table)
__tests__/screenshot-backend __tests__/interactor-screenshot-backend interactor.ts
__tests__/watchos-sentinel __tests__/interactor-watchos-sentinel interactor.ts
core/__tests__/interactions src/interactions.test.ts src/interactions.ts (+ the Swift route-parity test)
core/__tests__/runner-mac-arch core/__tests__/runner-client-mac-arch core/runner-client.ts (see below)
snapshot-source/native-runtime snapshot-source/cache-native-runtime snapshot-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)

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

File Mock Result
runner-session-close-finalization ../runner-io.ts 11 failed / 18
../runner-startup-transport.ts 15 failed / 18
../runner-transport.ts 2 failed / 18
../runner-xctestrun.ts 16 failed / 18
runner-client-busy-resend ../runner-session.ts 7 failed / 7
runner-client-command-retry ../runner-session.ts 33 failed / 33
../runner-xctestrun.ts 33 passed / 33
runner-client-recovery-wiring ../runner-session.ts 42 failed / 47
runner-lifecycle-request-cancellation ../runner-io.ts 8 passed / 8
../runner-startup-transport.ts 6 failed / 8
../runner-xctestrun.ts 8 failed / 8
interactions ./core/runner-client.ts 25 failed / 25
interactor-screenshot-backend ../core/screenshot.ts 1 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

View guided diff Turn on auto-fix

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 29 files

View guided diff | Turn on auto-fix | Re-trigger cubic

thymikee and others added 5 commits October 15, 2026 14:35
Pure moves and renames. Content changes are import specifiers, the Swift
sources path in interactions.test.ts, and references to the old paths in the
macOS workflow, docs, comments and the command-coverage and fault-matrix evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e it covers

decodeRunnerResponseBody and its siblings live in runner-contract.ts;
parseRunnerResponse lives in runner-exchange.ts. Each half now sits beside
its own module's name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…for the runner entry

The driver exercises the session executor, command recovery and press-series
sequencing against the contracts table, so it takes the runner entry's name.
The owning-path string in the contracts fixture follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… for the package and runner entries

Pure renames. The runner-requests.json producer paths and the comment that names
the runner-side driver follow in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onformance drivers

The producer paths move with the two drivers; the endsWith contract in the
runner-side driver already accepts index-runner-requests.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 8541862. It moves sixteen tests next to the modules they test, and I found no problems in the diff. There are no conflicts. CI had not run when I looked: all 16 non-passing jobs were queued, so there is no failure to attribute. I did not run any tests myself, and I checked the runner-response split statically. The 31 and 47 test counts and the vi.mock table come from your description. The layering, fallow, gate-manifest and vitest project-selection results from the earlier commit still need a rerun on this head. Not blocking, and fine to take or leave: runner-client-mac-arch.test.ts tests the destination helpers in apple-runner-platform.ts and imports runner-client.ts only for its host-binding side effect, so a short note in the test would help; and two comments in runner-exchange.ts and runner-swift-settlement-fixtures.ts got longer with the rename, so please check Lint & Format. Next, wait for CI to finish, mainly Repo Guards, Lint & Format and Integration Tests, and rerun check:quick, layering and fallow on this head.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 15, 2026
@thymikee
thymikee force-pushed the refactor/colocate-platform-apple-tests branch from 8541862 to 9eb850d Compare October 15, 2026 12:42
@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.25 MB 5.25 MB -15 B
Package (unpacked) 5.25 MB 5.25 MB -15 B
Package (download) 1.58 MB 1.58 MB +9 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.4 ms 26.6 ms +0.2 ms
CLI --help 76.5 ms 75.7 ms -0.8 ms

@thymikee

Copy link
Copy Markdown
Member Author

Full gate set on the final head 9eb850d75 (rebased onto main after #3653; includes the index-runner-requests renames):

Gate Result
pnpm check:quick exit 0
pnpm check:layering exit 0
pnpm check:fallow exit 0
pnpm check:gate-manifest exit 0
pnpm check:affected --run exit 0 — vitest related: 343 test files, 2,637 tests passed
pnpm format clean tree

The first check:affected attempt after the rebase failed with "node_modules does not match this worktree's pnpm-lock.yaml" (main had moved the lockfile); I reinstalled with --frozen-lockfile and reran. Also in this push: runner-requests.test.ts ×2 → index-runner-requests.test.ts with the runner-requests.json producer paths updated in a separate commit; the existing endsWith('runner-requests.test.ts') contract still holds. runner-xctestrun.ts mock in runner-client-command-retry is kept: its handle backs two calls.length === 0 assertions (lines 183, 206), so it is a live negative spy, not a dead mock; the runner-io.ts getFreePort mock in runner-lifecycle-request-cancellation is reached 11 times.

@thymikee
thymikee merged commit 22ae872 into main Oct 15, 2026
19 checks passed
@thymikee
thymikee deleted the refactor/colocate-platform-apple-tests branch October 15, 2026 13:37
@thymikee

Copy link
Copy Markdown
Member Author

The changes in 9eb850d look good, and the earlier review (8541862) found no code problems. The tests now sit next to the modules they cover, and the delta since then only renames tests and updates the producer strings in the JSON fixtures. No production code changed. I did not rerun the gates or the conformance test, and I did not capture the failing CI excerpts. The failures look unrelated to me, because the renamed drivers only feed the runner-requests conformance check, but that rests on the diff alone. No conflicts. Before merge, please confirm the CI failures do not come from the fixture producer-path change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant