Skip to content

fix(cli): route fbuild reset through daemon device-lease admission - #2155

Merged
zackees merged 2 commits into
mainfrom
agent/reset-lease-admission
Nov 22, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/reset-lease-admission

Conversation

@zackees

@zackees zackees commented Nov 22, 2026

Copy link
Copy Markdown
Member

Problem

fbuild reset was the last mutating device path that bypassed the daemon. cli/reset.rs called fbuild_deploy::reset::reset_device in-process (origin/main crates/fbuild-cli/src/cli/reset.rs L46) and had no --lease-id, so it could toggle DTR/RTS on a board another workflow had leased and was validating — exactly what the POST /api/reset admission added in #1864 exists to prevent.

Fix

The CLI no longer opens the port. It sends the reset to the daemon, which runs DeviceManager::admit_operation before preempt_for_deploy, so the bypass cannot recur through this entry point:

  • new DaemonClient::device_reset → POST /api/reset with ResetRequest { port, board, lease_id, verbose } (60 s transport ceiling; the daemon keeps its own 10 s hard reset deadline and answers 504).
  • HTTP 409 (foreign exclusive lease) becomes an error carrying the daemon's own message — it names the holder and the two ways out — instead of a hardware-flavoured failure.
  • fbuild reset --lease-id <id> added; omitting it on an unleased board behaves exactly as before.
  • Daemon acquisition uses ensure_daemon_running(), the same path deploy takes.
  • Preserved: the shared serial selector (resolve_port_arg, so ser=<USB serial> still resolves at use time), platformio.ini project/environment resolution, and the board id → platform-specific reset sequence mapping (the daemon runs the same detect_platform_for_reset).

Tests

Three stub-daemon regression tests in crates/fbuild-cli/src/cli/reset_tests.rs (no hardware, no real daemon), driving the same function run_reset calls:

  • reset_posts_port_board_and_lease_id_to_the_daemon — asserts POST /api/reset with the resolved port, the board id and the caller's lease_id.
  • foreign_lease_refusal_surfaces_the_daemon_message — a 409 must surface the holder explanation (leased by client 'other-flow', --lease-id) and must not report a completed reset.
  • unleased_board_resets_without_a_lease_id — an unleased board is admitted and no lease_id field is sent.

Real output: soldr cargo test -p fbuild-cli --bin fbuild → 502 passed; 0 failed; 0 ignored. soldr cargo fmt -p fbuild-cli -- --check clean. uv run --no-project python ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0, exit 0.

Daemon-side admission was already covered by handlers/operations/tests.rs::device_lease_admission_tests (competing_deploy_is_refused_at_admission, holder_deploys_and_resets_under_its_own_lease), so the CLI half was the missing link.

Not done here

A live-board lease e2e (acquire an exclusive lease on the attached ESP32-C6, reset without the id → refused, reset with it → done) needs a dev daemon plus CLI built from this worktree; it was not run in this tick. #2151 (remaining cell: that live-board check).

@coderabbitai

coderabbitai Bot commented Nov 22, 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

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • 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

ban_std_mpsc_in_async_reachable denies std mpsc under crates/*/src/ with no
allowlist; take the captured request off the server thread's join handle.
@zackees
zackees added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 18ff3c3 Nov 22, 2026
33 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 23, 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