Skip to content

feat(python): plumb the workflow lease through the PyO3 facade - #1879

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

zackees merged 1 commit into
mainfrom
agent/1864-lease-python-facade

Conversation

@zackees

@zackees zackees commented Nov 3, 2026

Copy link
Copy Markdown
Member

Fifth slice of #1864 — Python facade lease plumbing (the last code criterion).

Why

The daemon now admits every mutating device path on an exclusive workflow
lease (#1869 deploy, #1871 serial write/RPC, #1873 bounded wait,
#1877 renumber follow). The PyO3 surface never carried the lease id, so a
Python workflow that held the lease still looked like a foreign client to
its own deploy, and SerialMonitor could not attach the board it reserved.

What

  • Deploy: OpRequest gains lease_id (omitted when None) and
    lease_wait_ms (omitted at 0, matching the daemon's serde(default)).
    DaemonConnection.deploy / deploy_result and the async counterparts
    accept lease_id=None, lease_wait_ms=0, so defaults keep the historical
    fail-fast admission and the JSON stays byte-identical for existing callers.
  • Serial attach: ClientMessage::Attach gains lease_id,
    SessionConfig carries it, and SerialMonitor(lease_id=...) /
    AsyncSerialMonitor(lease_id=...) present it. Frame construction moved to
    serial_session::attach_message (sibling module, keeps serial_session.rs
    at the 1000-LOC gate) so the config-to-frame mapping is testable without a
    daemon.
  • Contract pin (AT-P9) now includes lease_id for both facades;
    docs/architecture/pyo3-bindings.md and python/fbuild/api/README.md
    document the kwarg.

A Python workflow can now: acquire the lease, deploy(lease_id=...),
SerialMonitor(port, lease_id=...), validate, release — with no
release/reacquire gap.

Tests (real output)

  • New deploy_request_forwards_lease_identity (sync),
    async_deploy_request_forwards_lease_identity,
    op_request_omits_lease_fields_by_default, and
    attach_frame_forwards_configured_lease.
  • Behavioural RED first — stubbing the forwarding (lease_id: None,
    lease_wait_ms: 0) and the attach mapping gives
    1 passed; 3 failed with left: None / right: Some("lease-abc"); restored
    -> 4 passed; 0 failed.
  • soldr cargo test -p fbuild-python --lib — 68 passed / 0 failed.
  • python_facades -- --ignored (embedded CPython) — 22 passed;
    cases::at_p7_async_cancel_read_lines_repeatedly is a pre-existing flake
    (2 of 5 runs fail at the same commit without this diff, stashed and
    reran), unrelated to lease plumbing.
  • soldr cargo clippy -p fbuild-python --all-targets rc 0,
    cargo fmt --all -- --check rc 0,
    python -m ci.run_dylint --package fbuild-python rc 0.

Remaining on #1864 after this: criterion 6 (two real checkouts taking turns on
one board) — needs a board slot not in use for FastLED/FastLED#5001.

The daemon admits deploy and serial attach on an exclusive device lease
(#1869/#1871/#1873/#1877), but the PyO3 surface never carried the lease
id, so a Python workflow that took a lease could not deploy, let alone
attach its own monitor: its own request looked like a foreign client.

- OpRequest gains lease_id (omitted when None) and lease_wait_ms
  (omitted at 0), so DaemonConnection.deploy/deploy_result and their
  async counterparts accept lease_id=None, lease_wait_ms=0. Defaults
  keep the historical fail-fast behaviour and byte-identical JSON.
- ClientMessage::Attach gains lease_id, SessionConfig carries it, and
  SerialMonitor/AsyncSerialMonitor accept lease_id=None. The attach
  frame is built in one place (serial_session::attach_message) so the
  config-to-frame mapping is testable without a daemon.
- Contract pin (AT-P9) and the pyo3-bindings doc track the new kwarg.

Tests: new deploy_request forwarding (sync + async), OpRequest lease
serialization, and attach-frame mapping; behavioural RED first (stub
the forwarding -> 3 failed) then green. fbuild-python --lib 68 passed;
python_facades --ignored 22 passed (at_p7 is a pre-existing flake,
2/5 at origin/main baseline); clippy rc 0; fmt rc 0; dylint rc 0.

Refs #1864
@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 fcfc2f5 Nov 3, 2026
29 checks passed
@zackees
zackees deleted the agent/1864-lease-python-facade branch November 3, 2026 18:47
@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