Skip to content

feat(leasing): a worker serves only enrolled devices on a platform whose virtualDevices is false - #1623

Merged
V3RON merged 30 commits into
feature/1588-adrfrom
task/1598
Nov 17, 2026
Merged

V3RON merged 30 commits into
feature/1588-adrfrom
task/1598

Conversation

@V3RON

@V3RON V3RON commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1598

Done when

  • pnpm test:changed passes, with every Tests line above as a test. — B1 config-platform-and-driver-settings.test.ts; B2, B3, B6 (catalog.get) and B7 dispatcher-virtual-devices-off.test.ts; B6 (CLI) index-catalog-components.test.ts; B5 create-leasing-virtual-devices-off-startup.test.ts; B4 create-leasing-warm-pool-virtual-devices-off.test.ts; B10 doctor-warm-pool-targets.test.ts; docs-manuals.test.ts 13/13 after baeaf51.
  • pnpm check passes, the protocol-bump check included: max is one above the value main holds when this lands (after Android leases that name no image tag get the worker's android.defaultImageTag where it fits #1595 and A worker's catalog names its default image tag, and a gateway ranks and shows it #1596). — protocol range is { min: 89, max: 93 } after the stack merge with main (src/contract/protocol.ts:13, d27a21a); the pre-push hooks passed.
  • The website build passes: pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs. — 92 pages built, check-openapi: 45 operations, 12 tags: ok.
  • docs/internal/EVENTS.md and reference/events.mdx list virtual-devices-off as an initiator of device.shutdown and device.deleted. — read in both files.

Status

Implement: done (stack merge d27a21a) Review: fix-check passed after the stack merge (coordinator) Hardware: n/a Gate: waiting for the stack
Next: CI on d27a21a; stays in stack #1592 → #1623 → #1657

Assumptions

  • Assumption: the doctor's config slice — DoctorConfig is narrowed with Pick to the two virtualDevices flags it reads, the smallest change.
  • Assumption: the startup delete's operation name — it logs as a cleanup ("Could not delete an idle device at start"), matching the existing startup steps.
  • Assumption: where the reserve is zeroed — in the warm-pool converger and in doctor through reserveOnVirtualPlatforms, not inside the policy view, so the policy stays pure.
  • Assumption: B6 is proved at two seams — catalog.get through the dispatcher and the CLI print through the CLI test, because the Tests line names both.

Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 1 blocking, 1 fixed, 0 notes. Claims review: 1 blocking, 1 fixed, 0 notes.
Rounds: 2. Tokens: 6.1M.
Runs: 19. Cost USD: 9.1982. Agent seconds: 2924.
Assessment: complete

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds independent virtualDevices settings for Android and iOS, enabled by default. When disabled, catalog entries identify the platform as physical-device-only, and non-physical lease resolution returns UNKNOWN_MODEL. Startup deletes idle virtual devices on disabled platforms. Warm-pool reserve calculations and Doctor findings also account for the setting. Tests and documentation cover configuration, catalog output, leases, startup cleanup, warm-pool behavior, and Doctor results.

Suggested reviewers: leonardoxr

Merge Risk: Minimal · up to d27a2

This change lets operators restrict a platform to enrolled physical devices. Default behavior is unchanged, and tests and docs cover the new paths. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a worker serves only enrolled physical devices on a platform whose virtualDevices setting is false. The changeset adds the virtualDevices config flag, refuses non-phys…
Linked Issues check Passed Direct issue: #1598. Parent #1588 is context only. Stack view: #1592 (reviewed) adds ADR 0080 and an index entry, with no code. #1623 (current) carries the implementation. #1657 (uncertain) is downstr…
Out of Scope Changes check Passed Changes introduced by #1623 map to #1598 objectives. Core config, warm-pool policy and converger, doctor, driver catalog, startup converger, leasing resolver and errors, contract schema and protocol m…
Description check Passed The description names the changeset's concrete behavior: disabling android.virtualDevices or ios.virtualDevices so a worker serves only enrolled physical devices. It cites the tests, the protocol …
Full details: Title check

Explanation

The title names the main change: a worker serves only enrolled physical devices on a platform whose virtualDevices setting is false. The changeset adds the virtualDevices config flag, refuses non-physical leases with VirtualDevicesOffError, deletes idle virtual devices at startup, and updates the warm pool, doctor, catalog, and docs to match. The title is specific and accurate. It is slightly long at 96 characters.

Full details: Linked Issues check

Explanation

Direct issue: #1598. Parent #1588 is context only. Stack view: #1592 (reviewed) adds ADR 0080 and an index entry, with no code. #1623 (current) carries the implementation. #1657 (uncertain) is downstream and not required for any #1598 objective. Stack objectives:

  1. Config, B1 [#1598]: Addressed by #1623. Config.ios and Config.android add virtualDevices: boolean (src/core/config-types.ts). Defaults are true (config-defaults.ts). Validators accept booleans (config-validators.ts). Tests in config-platform-and-driver-settings.test.ts.

  2. Plain lease refusal, B2 [#1598]: Addressed by #1623. At the reviewed head, AcquisitionSpecResolver.resolveSpec (src/leasing/acquisition-spec-resolver.ts) throws VirtualDevicesOffError before the baseline branch, any catalog read, or any download. The error extends UnknownModelError (acquisition-errors.ts). Test: dispatcher-virtual-devices-off.test.ts.

  3. Physical lease, B3 [#1598]: Addressed by #1623 per the PR summary and the dispatcher test list. The physical path was not read directly.

  4. Warm pool, B4 [#1598]: Addressed by #1623. reserveOnVirtualPlatforms (warm-pool/policy.ts) zeroes the reserve for off platforms, and the converger uses it. Test: create-leasing-warm-pool-virtual-devices-off.test.ts.

  5. Startup deletion, B5 [#1598]: Addressed by #1623. StartupConverger gains IdleDeviceDeletion. create-core.ts shuts down ready devices, then deletes idle ones, and logs failures as warnings. Test: create-leasing-virtual-devices-off-startup.test.ts.

  6. Catalog and CLI, B6 [#1598]: Addressed by #1623. DriverCatalog.listCatalog returns a phones-only entry without calling the driver for the off platform. formatCatalog adds the notice. platformCatalogSchema adds virtualDevices?: false. Tests: index-catalog-components.test.ts and the dispatcher test.

  7. Components, B7 [#1598]: Addressed by #1623 per the summary and the dispatcher test list. Not read directly.

  8. Doctor, B10 [#1598]: Addressed by #1623. unreachableTarget returns warm-pool-target-unreachable for an off platform. DoctorConfig carries per-platform virtualDevices. Doctor zeroes the reserve for off platforms. Test: doctor-warm-pool-targets.test.ts.

  9. Protocol, docs, website [#1598]: Addressed by #1623 per the summary. PROTOCOL_VERSION_RANGE.max is 92 in the summary. The website and event docs changes are listed.

Uncertainty: the incremental diff from baeaf51 to d27a21a could not be read because changed blobs are missing from the checkout. Changes in that range are known only from the PR description. The B2 guard was re-read at the reviewed head and is present. The tests were not run. #1595 and #1596 are named dependencies; their code is not in the supplied evidence.

Full details: Out of Scope Changes check

Explanation

Changes introduced by #1623 map to #1598 objectives. Core config, warm-pool policy and converger, doctor, driver catalog, startup converger, leasing resolver and errors, contract schema and protocol max, CLI catalog notice, and website and event docs implement listed behaviors. Hand-built test fixtures gain the new virtualDevices fields, which supports the tests. The ADR 0080 document belongs to #1592, not to this PR. The gateway merged-catalog work (#1599) and Android adb-only startup are not in the summary. Limit: the incremental diff from baeaf51 to d27a21a could not be read, so the changes in that range rest on the PR description and the whole-PR summary.

Full details: Description check

Explanation

The description names the changeset's concrete behavior: disabling android.virtualDevices or ios.virtualDevices so a worker serves only enrolled physical devices. It cites the tests, the protocol range bump to max 93, the website build, and the event docs for virtual-devices-off. That matches the summarized files, so the description is related to the changes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: ac623024-0677-47a1-8b73-696c2e7b6d0e
Commits

Reviewing files that changed from the base of the PR and between baeaf51 and d27a21a.

Files selected for processing: 4

  • docs/internal/flows/startup.md
  • src/contract/protocol.ts
  • src/core/create-core.ts
  • website/src/content/docs/docs/reference/configuration.mdx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

V3RON added 16 commits November 16, 2026 21:10
@V3RON
V3RON added this pull request to stack #1625 November 16, 2026 20:22
@V3RON

V3RON commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: ab4578b
Round 2: 2638b45
Round fix-check: baeaf51
Round fix-check: d27a21a
Round fix-check: 35b8371
Round fix-check: 72baba7

Runs: 19. Cost USD: 9.1982. Agent seconds: 2924.
Tokens input 708, output 171720, cache read 34962820, cache write 1148243.
- build implementer: claude-sonnet-5-5 1033 s $4.0054
- audit implementer: claude-sonnet-5-5 231 s $0.5033
- review 1 reviewer: claude-sonnet-5-5 432 s $0.3152
- review 1 spec: claude-sonnet-5-5 39 s $0.2932
- review 1 code both: claude-opus-5-5 355 s $1.9555
- review 1 claims: claude-sonnet-5-5 46 s $0.2578
- fix 1 implementer: claude-sonnet-5-5 41 s $0.1193
- review 2 reviewer: claude-sonnet-5-5 128 s $0.2051
- review 2 code tests: claude-opus-5-5 53 s $0.2696
- review 2 claims: claude-sonnet-5-5 15 s $0.0842
- fix fix-check implementer: claude-sonnet-5-5 49 s $0.1321
- review fix-check reviewer: claude-sonnet-5-5 39 s $0.0982
- fix fix-check implementer: claude-sonnet-5-5 237 s $0.2515
- review fix-check reviewer: claude-sonnet-5-5 67 s $0.1942
- fix fix-check implementer: claude-sonnet-5-5 42 s $0.1298
- review fix-check reviewer: claude-sonnet-5-5 45 s $0.1163
- fix fix-check implementer: claude-sonnet-5-5 18 s $0.0866
- fix fix-check implementer: claude-sonnet-5-5 24 s $0.0653
- review fix-check reviewer: claude-sonnet-5-5 30 s $0.1156
Finding outcomes: {"fixed":2}. Classes: {"comment false: failed destroy leaves shutdown":1,"testing 10 title promises unproven other-platform grant":1}.
{"findings":[{"id":"R1","role":"code","class":"testing 10 title promises unproven other-platform grant","outcome":"fixed","path":"src/daemon/dispatcher-virtual-devices-off.test.ts","round":"1","fix":"2638b4546acc8f3f2cfdcd856a80bd9cdda817c6"},{"id":"R2","role":"claims","class":"comment false: failed destroy leaves shutdown","outcome":"fixed","path":"src/core/create-core.ts","round":"1","fix":"2638b4546acc8f3f2cfdcd856a80bd9cdda817c6"}]}

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review November 17, 2026 10:43
@V3RON
V3RON merged commit e9595de into main Nov 17, 2026
44 checks passed
@V3RON
V3RON deleted the task/1598 branch November 17, 2026 11:40
V3RON added a commit that referenced this pull request Nov 17, 2026
Closes #1599

## Done when

- [x] `pnpm test:changed` passes, with every Tests line above as a test.
— B8 `src/gateway/fleet-routing-phones-only.test.ts` (one phones-only
worker, with an emulator worker, with a worker without the field, an
iOS-only worker beside a phones-only Android worker, no models,
`--physical`), B9 `src/gateway/aggregate-catalog.test.ts` (both orders);
`src/gateway` 840/840 at ee4dc82; the only other failures are
`src/daemon/lease-files.test.ts` and
`src/daemon/relay-gateway-files.e2e.test.ts`, which the open flaky-test
issue #1613 names.
- [x] `pnpm check` passes. — the pre-push hooks (fallow, protocol-bump,
docs-surface, typecheck) passed on every push, the last at f8f66bb; CI
green at f8f66bb.
- [x] The website build passes: `pnpm --dir website install && pnpm
--dir website build && node website/scripts/check-openapi.mjs`. — CI job
`build` (`.github/workflows/website.yml`: install, `pnpm build`, `node
scripts/check-openapi.mjs`) passed at f8f66bb.

## Completion conditions (#1588)

- [x] With `android.virtualDevices: false`, every plain Android lease in
Examples answers `UNKNOWN_MODEL` with the phones-only message at once,
and no emulator is created, booted or downloaded for it. —
`src/daemon/dispatcher-virtual-devices-off.test.ts`, the `it.each` over
android and ios with the Examples' request shapes (#1623).
- [x] With it, an Android `--physical` lease is granted, waits and is
refused exactly as on a worker without it. — same file, "serves a
--physical lease as on any worker: granted, waiting, NO_CAPACITY with
noWait, UNKNOWN_MODEL with no enrolled match" (#1623).
- [x] With it, a configured Android warm target and an Android learned
kind boot nothing, and an iOS target still fills. —
`src/leasing/create-leasing-warm-pool-virtual-devices-off.test.ts`
(#1623).
- [x] With it, the worker's idle Android emulators are gone after a
restart, a leased one is deleted at its release, and saved baselines are
still listed by `simlock baseline list`. —
`src/leasing/create-leasing-virtual-devices-off-startup.test.ts`, which
also asserts `baselines.list`, the call `baseline list` answers from
(#1623).
- [x] `simlock catalog` shows the phones-only line for that platform,
and `catalog.get` carries `virtualDevices: false`. —
`src/cli/index-catalog-components.test.ts` "prints the phones-only
line…", and the dispatcher test's `catalog.get` case (#1623).
- [x] With it, `simlock doctor` reports a configured Android warm target
as unreachable because `android.virtualDevices` is false. —
`src/core/doctor-warm-pool-targets.test.ts`, B10 (#1623).
- [x] `ios.virtualDevices: false` does the same for iOS. — the
dispatcher test runs both platforms (`it.each(["android", "ios"])`), and
its `--physical` and catalog cases use iOS (#1623).
- [x] Through a gateway whose only Android worker is phones-only, a
plain Android lease gets the gateway's phones-only message, and
`--physical` is routed to that worker. —
`src/gateway/fleet-routing-phones-only.test.ts` (this PR).
- [x] The configuration reference, the physical devices page, the errors
pages and the gateway routing page describe the setting. —
`reference/configuration.mdx`, `using-devices/physical-devices.mdx`,
`reference/errors.mdx` and `using-devices/errors.mdx` (#1623), and
`gateway/routing.mdx` (this PR).

### Status

Implement: done Review: round 2 + fix-checks passed (R1–R3 fixed, R4
note) Hardware: n/a Gate: waiting for the stack
Next: ADR 0084 to Accepted on this branch, then the gate on this PR for
the stack #1592 → #1623 → #1657

## Assumptions

none

## Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 3 blocking, 3
fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 1 notes.
Rounds: 2. Tokens: 4.4M.
Runs: 17. Cost USD: 3.7725. Agent seconds: 1687.
Assessment: complete

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A worker serves only enrolled devices on a platform whose virtualDevices is false

1 participant