Repository navigation
fix(daemon): follow a tracked renumber in lease admission and the wait queue - #1877
Merged
Merged
Conversation
…t queue A `--track-serial` lease already moved with the board when it re-enumerated, but the port string keyed everything else: - the admission queue stayed under the old name, so a queued `--lease-wait` workflow polled a port the device no longer uses; - `poll_admission` treats an unknown port as outside the lease path, so that waiter was admitted on the vanished port while the lease sat on the new one; - `QueueGuard` remembered the port name, so it would drop its ticket from the wrong queue and strand a phantom head-of-line blocker; - `admit_operation` on a stale name silently passed and the caller failed later at `open_port` with no hint that the board had moved. Now `renumbered_target()` proves the move (only a tracked renumber writes `previous_port`), `migrate_waiters()` carries the FIFO to the new name merging by ticket sequence (from `refresh_devices` and mid-wait), `await_admission` re-resolves the port before every poll, `QueueGuard` drops via `leave_ticket()` so it cannot depend on the name still existing, and a stale name returns `DeviceLeaseError::PortRenumbered` naming the current port and its holder. Ports that never renumbered (emulator/probe routes) are still admitted. #1864 criterion 4.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fourth slice of #1864 (criterion 4: lease identity across re-enumeration).
A
--track-seriallease already moves to the new port when the boardrenumbers, but everything else keys on the port string:
--lease-waitworkflow polled a port the device no longer uses;poll_admission/await_admissiontreat an unknown port as "outside thelease path", so that waiter was admitted on the vanished port while the
holder's lease sat on the new one — the exact bypass fix(daemon): enforce exclusive device leases across deploy and RPC workflows; add bounded sharing queue #1864 is about, now
reachable inside a queue instead of around it;
QueueGuardremembered the port name, so a waiter that did follow theboard would drop its ticket from the wrong queue and strand a phantom
head-of-line blocker;
admit_operationon a stale name silently passed (unknown port = emulatorroute), and the caller then failed later at
open_portwith no hint thatthe board had moved.
What
device_manager::renumbered_target()— the connected device thatre-enumerated from a port (only a tracked renumber writes
previous_port,so a match proves the physical board moved).
DeviceManager::migrate_waiters(from, to)moves a port's FIFO to the newname, merging by ticket sequence so arrival order survives; it runs both in
refresh_devices(queue follows the migratedDeviceState) and mid-wait.await_admissionfollows the board:current_port_for()(bounded to 8hops) is re-resolved before every poll, so a queued workflow keeps waiting
behind the migrated holder and proceeds only when it releases.
QueueGuardnow holds only its ticket and drops via the newleave_ticket()(a ticket is unique across the manager), so a renumberduring the wait cannot leave a phantom waiter.
admit_operationon a stale name returns the newDeviceLeaseError::PortRenumbered { port, current_port, holder }: it namesthe port the board uses now and the lease reserving it. Ports that never
renumbered (emulator/probe-only routes) are still admitted.
docs/reference/cli.md— "Workflow leases" documents the new behaviour.Tests (behaviourally RED first)
New
device_manager::tests::lease_renumber_tests(3 tests, hardware-free,real
DeviceState+ refresh path):tracked_renumber_moves_the_admission_queue— queue moves to the new port,waiter still behind the migrated holder, admitted on release.
a_stale_port_name_reports_the_renumbered_port—PortRenumberednamesthe new port and holder; only the lease holder may operate there.
a_queued_workflow_follows_the_board_across_a_renumber— real spawnedawait_admission: not admitted on the vanished port, queue visible on thenew name, admitted only after
release_lease, guard leaves no ticket.RED (stubbing
current_port_for→ identity andmigrate_waiters→ no-op):1 passed; 2 failed—left: 1, right: 0("the old port is gone; its queuemust not linger") and "a waiting workflow was admitted on a port that no
longer exists". Restored → green.
No new host-platform calls (pure in-memory state), so the platform ledger is
untouched. Remaining on #1864: Python facade
lease_id/lease_wait_msplumbing and the two-checkout hardware run.