Skip to content

feat(core): a phone's hardware serial is kept on its record, and one phone keeps one record - #1622

Merged
V3RON merged 18 commits into
feature/1589-adrfrom
task/1604
Nov 17, 2026
Merged

V3RON merged 18 commits into
feature/1589-adrfrom
task/1604

Conversation

@V3RON

@V3RON V3RON commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1604

Status

Implement: done (build 8/8, audit probed 33/33, covered 17/17) Review: passed round 1 Hardware: n/a Gate: waiting for the stack
Next: none until the stack merges

Done when

  • pnpm test:changed passes, with a test per B6–B9 case above. — audit run at f951fed, every B6–B9 case probed red
  • pnpm test:e2e e2e/physical-enrollment-auto-enroll.test.ts e2e/physical-enrollment.test.ts passes. — audit run, 33 passed
  • website/src/content/docs/docs/reference/errors.mdx and the reasons table of worker/enrolling-physical-devices.mdx list enrolled-under-other-id with what to do. — read in the diff; claims review found no defect
  • The website build and its HTTP API check pass (src/contract/ changes). — audit ran the website build and check-openapi.mjs: pass

Assumptions

  • Assumption: the protocol bump — PROTOCOL_VERSION_RANGE moves max by one (92) and leaves min, since a new refusal reason is additive and an older client still reads every other answer.
  • Assumption: a re-enrol whose new read carries no hardware serial clears the record's — the record takes the new read, as it does for model and apps.

Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 0 blocking, 0 fixed, 1 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 1. Tokens: 3.5M.
Runs: 6. Cost USD: 4.5207. Agent seconds: 1951.

Assessment: complete

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 31d2cdde-6c1a-444b-8823-cd98c6869660
Commits

Reviewing files that changed from the base of the PR and between f951fed and 24f52dc.

Files selected for processing: 43

  • e2e/fake-driver/fake-driver.ts
  • e2e/fake-driver/types.ts
  • e2e/physical-enrollment-auto-enroll.test.ts
  • e2e/physical-enrollment.test.ts
  • src/contract/errors.ts
  • src/contract/protocol.ts
  • src/core/domain.ts
  • src/core/driver.test.ts
  • src/core/driver.ts
  • src/core/fake-driver.test.ts
  • src/core/fake-driver.ts
  • src/core/index.ts
  • src/core/physical-enrollment.test.ts
  • src/core/physical-enrollment.ts
  • src/core/physical-presence.test.ts
  • src/core/physical-presence.ts
  • src/core/quarantine-coordinator-physical-presence.test.ts
  • src/core/quarantine-coordinator.ts
  • src/core/reclaim-coordinator.test.ts
  • src/core/reclaim-coordinator.ts
  • src/core/registry-physical.test.ts
  • src/core/registry-rows.ts
  • src/core/registry-schema.ts
  • src/core/registry-types.ts
  • src/core/registry.test.ts
  • src/core/registry.ts
  • src/core/test-registry.ts
  • src/drivers/android/index.ts
  • src/drivers/android/physical-handler-inspect-list.test.ts
  • src/drivers/android/physical-handler-windows.test.ts
  • src/drivers/android/physical-handler.test.ts
  • src/drivers/android/physical-handler.ts
  • src/drivers/ios/index.ts
  • src/drivers/ios/physical-files-and-limits.test.ts
  • src/drivers/ios/physical-presence.test.ts
  • src/leasing/acquisition-workflow.ts
  • src/leasing/physical-device-watcher-acting.test.ts
  • src/leasing/physical-device-watcher.test.ts
  • src/leasing/physical-device-watcher.ts
  • src/leasing/physical-leasing.test.ts
  • src/leasing/test-physical-device-watcher.ts
  • website/src/content/docs/docs/reference/errors.mdx
  • website/src/content/docs/docs/worker/enrolling-physical-devices.mdx

No actionable comments were generated in the recent review.

Walkthrough

Physical-device records now support an optional hardware serial, which the registry stores across reloads. Enrollment rejects a device when its ID or serial conflicts with another active physical-device record. Presence-read APIs now accept enrolled-device records and pass available serials through to callers and drivers. The refusal reason and documentation include enrolled-under-other-id. The protocol version range now extends through version 92.

Merge Risk: Minimal · previous review f951f

This change stores a phone's hardware serial and refuses a second record for the same phone with a new reason, enrolled-under-other-id. Real-worker behavior changes only through that reason, since drivers do not yet set the serial. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title describes the main change: physical device records now keep a phone's hardware serial, and enrollment blocks a second record for the same phone. The raw summary confirms this through the har…
Description check Passed The description names the linked issue (#1604) and gives a status with test and audit results. It lists the done-when checks, which match the changeset: the e2e enrollment tests, the docs for enrolled…
Linked Issues check Passed Objectives from #1604, with stack status (current PR #1622 plus reviewed #1594):

1. Store hardware serial on physical records, persist across restart, pass through presence reads and reclaim [#1604, …
Out of Scope Changes check Passed Changes introduced by #1622 map to #1604 objectives. Signature changes from string IDs to EnrolledPhysical records in Driver, FakeDriver, OutOfProcessFakeDriver, AndroidDriver, IosSimctlDriver and the…
Full details: Title check

Explanation

The title describes the main change: physical device records now keep a phone's hardware serial, and enrollment blocks a second record for the same phone. The raw summary confirms this through the hardwareSerial field, the new enrolled-under-other-id refusal reason, and the duplicate check in PhysicalEnrollment.add. The title is specific and does not use vague terms. It is a long, two-clause title, but it is still a single sentence and it is related to the changeset.

Full details: Description check

Explanation

The description names the linked issue (#1604) and gives a status with test and audit results. It lists the done-when checks, which match the changeset: the e2e enrollment tests, the docs for enrolled-under-other-id, and the website build. It also states assumptions about the protocol range bump and re-enrollment clearing the serial, which match the changes to protocol.ts and the registry. It is related to the changeset, so it passes.

Full details: Linked Issues check

Explanation

Objectives from #1604, with stack status (current PR #1622 plus reviewed #1594):

  1. Store hardware serial on physical records, persist across restart, pass through presence reads and reclaim [#1604, B8]: Addressed. Evidence: registry-schema.ts adds migration V7 (nullable hardware_serial) and registryOwner reports version 7; registry-rows.ts writes and reads hardware_serial; registry.ts stores the input serial on enrol and clears it on re-enrol when omitted; physical-presence.ts, physical-device-watcher.ts, quarantine-coordinator.ts, reclaim-coordinator.ts and acquisition-workflow.ts pass the full PhysicalDevice (driverDeviceId and hardwareSerial); driver.ts toDriverDevice includes hardwareSerial when defined. Tests cover reopen, v6 migration, and the call arguments (per the diff summary; not run by this review). Stack note: #1594 is an ADR only and adds no code.

  2. Refuse device add when another live record holds the same hardware serial, regardless of transport, reason enrolled-under-other-id [#1604, B7, B9]: Addressed. Evidence: physical-enrollment.ts #requireOneRecord throws DeviceNotEnrollableError with reason enrolled-under-other-id and canonicalId set to the holder's driverDeviceId. It matches the driver ID against another record's hardwareSerial, and the inspected serial against another record's driverDeviceId or hardwareSerial. Deleted records are excluded. Reason added to DeviceNotEnrollableReason and DeviceNotEnrollableReason contract in src/contract/errors.ts.

  3. Duplicate check under the lock at each commit, check and write in the same SerializedDecision.run, no driver I/O inside [#1604, Core lock rule]: Addressed. Evidence: in PhysicalEnrollment.add, #requireOneRecord runs inside decisions.run before registry.enrollPhysical for a new record, and again inside the second decisions.run before reenrollPhysical. The inspection calls (#inspect) run outside the lock; the locked blocks call no driver.

  4. Protocol range max moves by one [#1604, Contract rule]: Addressed. Evidence: src/contract/protocol.ts range now 89 to 92.

  5. Website docs list enrolled-under-other-id with action [#1604, Done when]: Addressed. Evidence: errors.mdx and enrolling-physical-devices.mdx reasons table each gain an entry (one-line diffs).

  6. Auto-enrolment B6 and e2e tests [#1604, Tests]: Addressed per the diff summary. e2e/physical-enrollment-auto-enroll.test.ts and e2e/physical-enrollment.test.ts add cases. Test results were not re-run by this review.

Dependencies #1595 and #1596 are listed in #1604 but are not in the supplied stack evidence. This review does not establish their state at the base. The requirements above are met by code visible at the reviewed head, so no requirement depends on their absence. Uncertainty remains only for test pass results, which rely on the author's run records.

Full details: Out of Scope Changes check

Explanation

Changes introduced by #1622 map to #1604 objectives. Signature changes from string IDs to EnrolledPhysical records in Driver, FakeDriver, OutOfProcessFakeDriver, AndroidDriver, IosSimctlDriver and the physical handler carry driverDeviceId and hardwareSerial to presence reads. These support B8. Fixture and test updates in driver, fake-driver, physical-presence, drivers/android, drivers/ios and leasing test files follow those signature changes. The e2e fake driver adds an optional hardwareSerial field used by the new e2e tests. The contract, protocol range, migration V7 and docs match the issue. No driver sets hardwareSerial or reads ro.serialno; the android and ios driver diffs only forward records. No status, worker view, or event change appears in the diff summary, which matches the #1605 and feature Decisions exclusions. No unrelated change was identified.

  • 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: b45c8110-e03f-42e7-9121-5bfdc85fb5d6
Commits

Reviewing files that changed from the base of the PR and between f2e4ffa and f951fed.

Files selected for processing: 43

  • e2e/fake-driver/fake-driver.ts
  • e2e/fake-driver/types.ts
  • e2e/physical-enrollment-auto-enroll.test.ts
  • e2e/physical-enrollment.test.ts
  • src/contract/errors.ts
  • src/contract/protocol.ts
  • src/core/domain.ts
  • src/core/driver.test.ts
  • src/core/driver.ts
  • src/core/fake-driver.test.ts
  • src/core/fake-driver.ts
  • src/core/index.ts
  • src/core/physical-enrollment.test.ts
  • src/core/physical-enrollment.ts
  • src/core/physical-presence.test.ts
  • src/core/physical-presence.ts
  • src/core/quarantine-coordinator-physical-presence.test.ts
  • src/core/quarantine-coordinator.ts
  • src/core/reclaim-coordinator.test.ts
  • src/core/reclaim-coordinator.ts
  • src/core/registry-physical.test.ts
  • src/core/registry-rows.ts
  • src/core/registry-schema.ts
  • src/core/registry-types.ts
  • src/core/registry.test.ts
  • src/core/registry.ts
  • src/core/test-registry.ts
  • src/drivers/android/index.ts
  • src/drivers/android/physical-handler-inspect-list.test.ts
  • src/drivers/android/physical-handler-windows.test.ts
  • src/drivers/android/physical-handler.test.ts
  • src/drivers/android/physical-handler.ts
  • src/drivers/ios/index.ts
  • src/drivers/ios/physical-files-and-limits.test.ts
  • src/drivers/ios/physical-presence.test.ts
  • src/leasing/acquisition-workflow.ts
  • src/leasing/physical-device-watcher-acting.test.ts
  • src/leasing/physical-device-watcher.test.ts
  • src/leasing/physical-device-watcher.ts
  • src/leasing/physical-leasing.test.ts
  • src/leasing/test-physical-device-watcher.ts
  • website/src/content/docs/docs/reference/errors.mdx
  • website/src/content/docs/docs/worker/enrolling-physical-devices.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
V3RON added this pull request to stack #1624 November 16, 2026 20:17
@V3RON

V3RON commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: f951fed

Runs: 6. Cost USD: 4.5207. Agent seconds: 1951.
Tokens input 311, output 101706, cache read 13312123, cache write 533698.
- build implementer: claude-sonnet-5-5 786 s $1.7898
- audit implementer: claude-sonnet-5-5 341 s $0.3219
- review 1 reviewer: claude-sonnet-5-5 441 s $0.3855
- review 1 spec: claude-sonnet-5-5 30 s $0.2053
- review 1 claims: claude-sonnet-5-5 35 s $0.1432
- review 1 code both: claude-opus-5-5 318 s $1.675
Finding outcomes: {"nonblocking":1}. Classes: {"testing 10":1}.
{"findings":[{"id":"R1","role":"code","class":"testing 10","outcome":"nonblocking","path":"src/core/physical-presence.test.ts","round":"1"}]}

Written by an agent.

@V3RON

V3RON commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • code: src/core/physical-presence.test.ts:49 the title's "and nothing else" clause is unproven in its own file: no input carries an extra field, so dropping the projection stays green there (it goes red at quarantine-coordinator-physical-presence.test.ts:314).

Written by an agent.

@V3RON
V3RON merged commit 959b632 into main Nov 17, 2026
33 checks passed
@V3RON
V3RON deleted the task/1604 branch November 17, 2026 07:35
V3RON added a commit that referenced this pull request Nov 17, 2026
Closes #1605

### Status

Implement: done (build 8/8, audit probed 10/10, fixes R1-R4, Fallow
splits, ADR 0080 Accepted) Review: passed round 2 + fix-check (R4
verified by coordinator) Hardware: pass (network case, 6154a06) Gate:
running on the stack
Next: gate merges #1594, #1622, #1627

## Done when

- [x] `pnpm test:changed` passes, with a test per B1–B5 and B10–B12 case
above (B12's core case excepted, already pinned), and today's
`network-only` tests (X19) pass unchanged. — audit run at bc75164, 10/10
tests probed red; remaining failures are base flakes #1613, #1628
- [x] The website build and its HTTP API check pass (`definition.ts`
changes). — audit ran the project checks the diff triggers: pass
- [x] `website/src/content/docs/docs/reference/configuration.mdx` has
the `android.networkDevices` row;
`worker/enrolling-physical-devices.mdx` and
`using-devices/physical-devices.mdx` describe network phones,
reconnects, the address as the ID, moving a phone, and the warning that
with both keys on any network phone connected on the worker is enrolled.
— read in the diff; claims review found no defect
- [x] `safety.md` rules 1, 7 and 8 and `src/drivers/android/AGENTS.md`
name the exceptions; `toolchain.md`'s Physical Android row names
`SIMLOCK_PHYSICAL_ANDROID_NETWORK` beside
`SIMLOCK_PHYSICAL_ANDROID_APK`. — fixed in review (R1, R3), verified by
round 2 claims lens
- [x] Slow lane: `scripts/slow-e2e.sh --physical
e2e/slow-android-physical.test.ts` passes its network case on a phone
connected by `adb connect` or wireless debugging
(`SIMLOCK_PHYSICAL_ANDROID_NETWORK` and `SIMLOCK_PHYSICAL_ANDROID_APK`
set). — hardware lane at 6154a06, network case pass over wireless
debugging (1 min)

## Assumptions

- Assumption: a record's reclaim guard follows the record, not the key —
a record that has a hardware serial is checked before any `pm` command
even when `android.networkDevices` is later turned off, the conservative
choice for the "another phone is never cleaned up" rule.
- Assumption: no reconnect when the first `devices -l` fails or is
blocked — nothing is run beyond what the list allowed, and every ID
reads `not-present` as today.


## Completion conditions (#1589)

- [x] On a worker with `android.networkDevices: true`, `simlock device
add --platform android <ip>:5555` enrols a phone connected by `adb
connect`, and `simlock lease --platform android --physical` grants it
with `ANDROID_SERIAL=<ip>:5555`. — slow-lane network case at 6154a06
asserts the ID and ANDROID_SERIAL (wireless-debugging address)
- [x] After `adb kill-server` on that worker, the enrolled phone is
present again within two probe intervals with no command typed. — B4
reconnect tests at the handler with scripted adb, probed red; not run on
a real phone
- [x] A different phone answering at an enrolled address reads absent,
and a release of a lease on that address uninstalls nothing on it. — B3
and B12 tests, probed red in the audit
- [x] `device add` of a phone already enrolled under another ID is
refused `enrolled-under-other-id`. — #1622's B6–B9 tests
- [x] With the key off, every row of the Examples tables answers as its
key-off column says, and a worker that has no network record answers
every `device add` exactly as today. — key-off rows of B1–B5 and B10,
and today's `network-only` tests unchanged
- [x] With `devices.autoEnroll` on too, a phone connected by `adb
connect` is enrolled within one probe interval. — B5 host-level list
tests feed the existing auto-enrol path; not run on a real phone

## Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 2 blocking, 2
fixed, 0 notes. Claims review: 2 blocking, 2 fixed, 0 notes.
Rounds: 2. Tokens: 5.4M.
Runs: 18. Cost USD: 6.5168. Agent seconds: 3449.
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 phone's hardware serial is kept on its record, and one phone keeps one record

1 participant