Skip to content

fix(daemon): follow a tracked renumber in lease admission and the wait queue - #1877

Merged
zackees merged 1 commit into
mainfrom
agent/1864-lease-renumber
Nov 3, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1864-lease-renumber

Conversation

@zackees

@zackees zackees commented Nov 3, 2026

Copy link
Copy Markdown
Member

Why

Fourth slice of #1864 (criterion 4: lease identity across re-enumeration).
A --track-serial lease already moves to the new port when the board
renumbers, but everything else keys on the port string:

  • the admission queue stayed under the old name, so a queued
    --lease-wait workflow polled a port the device no longer uses;
  • poll_admission/await_admission treat an unknown port as "outside the
    lease 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;
  • QueueGuard remembered the port name, so a waiter that did follow the
    board would drop its ticket from the wrong queue and strand a phantom
    head-of-line blocker;
  • admit_operation on a stale name silently passed (unknown port = emulator
    route), and the caller then failed later at open_port with no hint that
    the board had moved.

What

  • device_manager::renumbered_target() — the connected device that
    re-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 new
    name, merging by ticket sequence so arrival order survives; it runs both in
    refresh_devices (queue follows the migrated DeviceState) and mid-wait.
  • await_admission follows the board: current_port_for() (bounded to 8
    hops) is re-resolved before every poll, so a queued workflow keeps waiting
    behind the migrated holder and proceeds only when it releases.
  • QueueGuard now holds only its ticket and drops via the new
    leave_ticket() (a ticket is unique across the manager), so a renumber
    during the wait cannot leave a phantom waiter.
  • admit_operation on a stale name returns the new
    DeviceLeaseError::PortRenumbered { port, current_port, holder }: it names
    the 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 — PortRenumbered names
    the new port and holder; only the lease holder may operate there.
  • a_queued_workflow_follows_the_board_across_a_renumber — real spawned
    await_admission: not admitted on the vanished port, queue visible on the
    new name, admitted only after release_lease, guard leaves no ticket.

RED (stubbing current_port_for → identity and migrate_waiters → no-op):
1 passed; 2 failed — left: 1, right: 0 ("the old port is gone; its queue
must not linger") and "a waiting workflow was admitted on a port that no
longer exists". Restored → green.

cargo test -p fbuild-daemon --lib
test result: ok. 320 passed; 0 failed; 3 ignored   (baseline 317)
cargo clippy -p fbuild-daemon --all-targets -- -D warnings   rc 0
cargo fmt --all --check                                      rc 0
ci/enforce_platform_boundary.py --print-totals   rows=44; dylint_rows=43
ci/check_test_layout.py                          ok (8 categories)

No new host-platform calls (pure in-memory state), so the platform ledger is
untouched. Remaining on #1864: Python facade lease_id/lease_wait_ms
plumbing and the two-checkout hardware run.

…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.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@zackees
zackees added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 6c704c0 Nov 3, 2026
31 checks passed
@zackees
zackees deleted the agent/1864-lease-renumber branch November 3, 2026 16:42
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant