Skip to content

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

Open
V3RON wants to merge 17 commits into
feature/1589-adrfrom
task/1604
Open

V3RON wants to merge 17 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 →

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 · up to 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.

This branch has not been deployed

No deployments
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