Skip to content

refactor(daemon): move the device selection cluster into @agent-device/device-selection - #2396

Merged
thymikee merged 4 commits into
mainfrom
refactor/device-selection-package
Sep 8, 2026
Merged

refactor(daemon): move the device selection cluster into @agent-device/device-selection#2396
thymikee merged 4 commits into
mainfrom
refactor/device-selection-package

Conversation

@thymikee

@thymikee thymikee commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

Moves the device-selection cluster (dispatch-resolve, device-selection-resolver, device-inventory-context + their tests/fixtures) into a new private workspace package @agent-device/device-selection — one subpath per module, no index, no re-export shims at the old paths.

Device selection no longer imports platform-apple app-resolution directly: the composition root (src/platform-runtime-device-inventory.ts) attaches an optional findInstalledApp probe to the composed inventory gateways (deferred Apple import), and the package reads the probe from the request context — absent probes fall back to the ordinary inventory rules. All ~60 consumers switch to the package subpaths; the layering gates gain the new leaf zone (the request zone is retired).

Dependency deltas (value edges, depgraph recipe: edges from the daemon-server zone to root files in other zones): 936 → 919 (−17, the three moved files). Replay root value deps: 6 → 4 (−2).

Validation

  • pnpm check:affected --run on the rebased head: format/lint/typecheck/layering/di-seams/fallow/mcp-metadata/build/package/integration-node/macos-coverage all green; vitest-related 3856/3857 — one transient 5s hard-timeout in trace-runtime.test.ts (not in this diff) passes in ~1.3s in isolation.
  • pnpm test:unit: remaining failures are wall-clock budget flakes reproducible on baseline under the same host load (load avg ~45: concurrent emulators + other worktree suites); test:smoke green.
  • check:fallow: no new findings; test-file-size ratchet and eager-closure budgets green; check:production-exports unchanged (all 65 pre-existing, none in touched files).

…package

git-rename src/core/dispatch-resolve.ts, src/core/device-selection-resolver.ts and src/request/device-inventory-context.ts (plus their tests and fixtures) into a new private package @agent-device/device-selection (deps: contracts, host-kit, kernel). One subpath per module points straight at the moved file; no index.ts, no re-export at the old path. Consumers switch to the owning specifier in the follow-up commit.
…teways and switch consumers to the device-selection package

The composition root (src/platform-runtime-device-inventory.ts) now attaches an optional findInstalledApp probe to the composed device inventory gateways, lazily importing the Apple simulator app-resolution mechanics. Device selection reads the probe from the request context instead of importing a platform package directly, so absent probes fall back to the ordinary inventory rules. All consumers switch to the @agent-device/device-selection/{dispatch-resolve,device-selection-resolver,device-inventory-context} subpaths; the moved tests carry a package-local inventory test util.
TARGET_DAG_RANK gains the device-selection leaf zone and drops the retired request zone; the back-edge fixture and the capture-kit ALS substrate fixture move to the package path.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-08 19:52 UTC

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.51 MB 4.51 MB +320 B
Package (unpacked) 4.51 MB 4.51 MB +320 B
Package (download) 1.34 MB 1.34 MB +67 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.6 ms 21.4 ms -0.2 ms
CLI --help 58.8 ms 56.4 ms -2.4 ms

@thymikee

thymikee commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

The move looks sound at ee11cdb, but the new installed-app probe needs one production-wiring regression. The moved selection tests supply the probe themselves, so removing it from createComposedDeviceInventoryGateways would leave those tests green while app-based simulator selection silently falls back. Add a test through that factory and the request context with two booted simulators and one installed-app match; show it fails when the factory omits the probe. Current CI passes.

… selection

The moved selection tests inject their own probe, so nothing covered the
composition root actually attaching findInstalledApp to the gateways:
omitting it would leave those tests green while app-based selection
silently fell back to the generic local rules.

The new case runs two booted simulators through
createComposedDeviceInventoryGateways and the request context, fakes
only the leaf xcrun spawn (core tool-provider), and asserts the
single-app-installed-local selection plus both probe consults.
@thymikee

thymikee commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Added in b93bfe1: 'narrows app-based simulator selection through the factory-installed probe' in src/platform-runtime-device-inventory.test.ts (the factory's co-located test).

It runs two booted simulators through createComposedDeviceInventoryGateways + withDeviceInventoryContext with com.example.demo installed on exactly one, and asserts device.id, reason: single-app-installed-local, and that the probe consulted both simulators. Only the leaf xcrun spawn is faked (runXcrun in platform-apple's core tool-provider), so the real findIosSimulatorInstalledApp → listapps chain executes behind the factory-installed probe.

Red proof: with findInstalledApp removed from the factory's return, the same test fails with AMBIGUOUS_MATCH ("2 devices match this request equally") — the silent fallback to generic local rules you described.

@thymikee

thymikee commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

The new regression test closes the wiring gap: it exercises the real inventory factory and selection route, with only the tool invocation mocked. Code review is clean at b93bfe1. The iOS alert-replacement test is still failing, but looks unrelated to this device-selection move; the relevant package, coverage and integration checks pass.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Sep 8, 2026
@thymikee
thymikee merged commit c5d9707 into main Sep 8, 2026
20 of 21 checks passed
@thymikee
thymikee deleted the refactor/device-selection-package branch September 8, 2026 19:51
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