Skip to content

test(daemon): session-open-url-prewarm through the request seam - #2304

Merged
thymikee merged 2 commits into
mainfrom
claude/test-seam-session-open-url-prewarm
Sep 5, 2026
Merged

test(daemon): session-open-url-prewarm through the request seam#2304
thymikee merged 2 commits into
mainfrom
claude/test-seam-session-open-url-prewarm

Conversation

@thymikee

@thymikee thymikee commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

Rewrites src/daemon/session-lifecycle/internal/__tests__/session-open-url-prewarm.test.ts
(16 scenarios covering URL/app-bundle-id inference and iOS runner prewarm
timing on open/prepare) to drive through the production request router
(createRequestHandler + lifecycleDeviceRuntimeGateway, the seam
request-router-open.test.ts and session-relaunch-close already use)
instead of the bypassed session-test-harness.ts/session-command-harness.ts.

The rewrite initially dropped two assertions from the two prepare ios-runner
tests (inspectFacts/bind call counts, verifying fact-inspection runs once
and binding is correctly skipped before the android-device rejection). Fixed:
test-device-runtime-gateway.ts gained createLifecycleDeviceRuntimeGatewaySpies(),
a fresh unfrozen gateway with vi.fn()-wrapped inspectFacts/bind (the
shared frozen fixture can't be spied on in place without leaking call counts
into other suites); the two tests now use it and reassert the original counts.

Two assertions also changed to match what the real seam produces: logPath
now matches the router's session-scoped runner.log path, and the
blocked-prewarm error reads the top-level error.hint field this seam uses.

Validation

  • Full affected gate: green at c44cadf (pnpm check:affected --run; gates run: format, lint, typecheck, fallow, vitest-related)
  • npx vitest run --project unit-core src/daemon/session-lifecycle/internal/__tests__/session-open-url-prewarm.test.ts — 16/16 pass.
  • Sibling suites sharing touched fixtures (request-router-open.test.ts, request-router-lock-policy.test.ts, request-router-replay-scope.test.ts, request-router-response-level.test.ts, request-router-session-address.test.ts, request-router-typed-error.test.ts, session-relaunch-close.test.ts) — all pass.
  • tsc -p tsconfig.json --noEmit — clean.
  • Planted red, restored assertions: flipped inspectFacts/bind expected counts in both prepare ios-runner tests — each failed with the expected AssertionError — reverted, verified green.

Rewrites session-open-url-prewarm.test.ts (16 open/prepare scenarios
covering URL bundle-id inference and iOS runner prewarm timing) to drive
through the production request router (createRequestHandler +
lifecycleDeviceRuntimeGateway, the seam request-router-open.test.ts and
the #2262 session-relaunch-close rewrite already use) instead of calling
the daemon's session handler directly through the bypassed
session-test-harness.ts. Every scenario title and observable assertion
(response payload, session-store state, dispatch context, prewarm call
order, prepare timing/response data) is unchanged; only the entry point
and mock surface moved.

The file no longer imports session-test-harness.ts or
session-command-harness.ts (both still back their other consumers,
untouched). It keeps only the module mocks these open/prepare scenarios
actually reach: platform-apple runner operations, app-resolution, macos,
device-ready, and the Android open-target shim. logPath assertions now
match the real session-scoped runner.log path the router computes
(rather than the harness's single hardcoded daemon.log stand-in), and
the blocked-prewarm error assertion reads the top-level normalized
error.hint field instead of a details.hint that this seam never carried.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 2.61 MB 2.61 MB 0 B
JS gzip 879.1 kB 879.1 kB 0 B
npm bundled raw 2.61 MB 2.61 MB 0 B
npm bundled gzip 879.1 kB 879.1 kB 0 B
npm tarball 1.04 MB 1.04 MB 0 B
npm unpacked 3.52 MB 3.52 MB 0 B
npm clean-installed 3.52 MB 3.52 MB 0 B

npm unpacked components

Component Base Current Diff
JS / dist source 2.77 MB 2.77 MB 0 B
Apple runner source/project 544.4 kB 544.4 kB 0 B
Apple snapshot presentation source 33.8 kB 33.8 kB 0 B
Apple Simulator snapshot bridge source 30.5 kB 30.5 kB 0 B
macOS helper source 54.8 kB 54.8 kB 0 B
Android helper artifacts 43.3 kB 43.3 kB 0 B
Other package files 46.7 kB 46.7 kB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.3 ms 26.6 ms +0.3 ms
CLI --help 81.4 ms 80.0 ms -1.4 ms

Top changed chunks: no changes in the largest emitted chunks.

Top changed packed files

No changed packed files.

… ios-runner tests

PR #2304 review found the router-seam rewrite silently dropped two
assertions the original suite had: that `prepare ios-runner` inspects
facts and binds exactly once on an explicit iOS selector, and that it
inspects facts once but never binds before rejecting a non-Apple
device. The shared `lifecycleDeviceRuntimeGateway` fixture is frozen
and reused across many suites, so it can't be spied on in place.

Add `createLifecycleDeviceRuntimeGatewaySpies()` to
test-device-runtime-gateway.ts: a fresh, unfrozen gateway whose
inspectFacts/bind are vi.fn() spies backed by the same binding logic,
scoped per test so no call counts leak across files. Use it in the two
affected tests to reassert the original call-count expectations.

Planted red: flipped each restored assertion's expected count/call and
confirmed the test failed, then reverted.

Command: npx vitest run --project unit-core -t "prepare ios-runner starts the XCTest runner on an explicit iOS selector" src/daemon/session-lifecycle/internal/__tests__/session-open-url-prewarm.test.ts
Message: AssertionError: expected "vi.fn()" to be called 2 times, but got 1 times

Command: npx vitest run --project unit-core -t "prepare ios-runner rejects non-Apple runner devices" src/daemon/session-lifecycle/internal/__tests__/session-open-url-prewarm.test.ts
Message: AssertionError: expected "vi.fn()" to be called at least once
@thymikee

thymikee commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

Sentinel review at c44cadf.

No actionable findings. The existing request router/gateway now exercises URL inference, prewarm ordering/errors and prepare admission; restored gateway spies preserve inspect-once/no-bind coverage. Assertions correctly use routed runner.log and wire error.hint. Tests-only; CI completion remains separate from code readiness.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Sep 5, 2026
@thymikee
thymikee merged commit c82c584 into main Sep 5, 2026
17 checks passed
@thymikee
thymikee deleted the claude/test-seam-session-open-url-prewarm branch September 5, 2026 18:49
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-05 18:50 UTC

thymikee added a commit that referenced this pull request Sep 5, 2026
* origin/main:
  perf: bundle runtime dependencies and report full install size (#2310)
  ci: avoid unrelated Apple runner cache invalidation (#2303)
  fix(web): preserve the backend ref so snapshot refs match actionable refs (#2283)
  test(daemon): session-open-url-prewarm through the request seam (#2304)
  test(daemon): session-devices-batch-runtime through the request seam (#2305)
  chore(gates): layering baselines ratchet against merge-base (#2299)
  test(daemon): one typed conformance helper for the daemon runtime suites (#2298)
  chore(layering): derive the contracts export inventory from package.json (#2297)
  perf: bundle tar-stream to reduce install footprint (#2286)
  docs: simplify agent context and resolve conflicting guidance (#2287)
  refactor(cli): let help resolve command aliases itself and retire R12 (#2293)
thymikee added a commit that referenced this pull request Sep 5, 2026
* origin/main:
  perf: bundle runtime dependencies and report full install size (#2310)
  ci: avoid unrelated Apple runner cache invalidation (#2303)
  fix(web): preserve the backend ref so snapshot refs match actionable refs (#2283)
  test(daemon): session-open-url-prewarm through the request seam (#2304)
  test(daemon): session-devices-batch-runtime through the request seam (#2305)
  chore(gates): layering baselines ratchet against merge-base (#2299)
  test(daemon): one typed conformance helper for the daemon runtime suites (#2298)
  chore(layering): derive the contracts export inventory from package.json (#2297)
  perf: bundle tar-stream to reduce install footprint (#2286)
  docs: simplify agent context and resolve conflicting guidance (#2287)
  refactor(cli): let help resolve command aliases itself and retire R12 (#2293)
  refactor(commands): retire the navigation-only type projection (#2294)
  feat(runtime): route managed leases through contained transports (#2285)
  refactor(contracts): build unavailable runtime facts once (#2291)
  refactor(cli): derive the common flag readers from the common-field table (#2292)
  feat(daemon): add managed allocation operation journal (#2284)
thymikee added a commit that referenced this pull request Sep 5, 2026
* origin/main:
  perf: bundle runtime dependencies and report full install size (#2310)
  ci: avoid unrelated Apple runner cache invalidation (#2303)
  fix(web): preserve the backend ref so snapshot refs match actionable refs (#2283)
  test(daemon): session-open-url-prewarm through the request seam (#2304)
  test(daemon): session-devices-batch-runtime through the request seam (#2305)
  chore(gates): layering baselines ratchet against merge-base (#2299)
  test(daemon): one typed conformance helper for the daemon runtime suites (#2298)
  chore(layering): derive the contracts export inventory from package.json (#2297)
  perf: bundle tar-stream to reduce install footprint (#2286)
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