Repository navigation
Phase 5c-2b: receiver-side JOB_* fan-out to peer-link frames - #533
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #533 +/- ##
=======================================
Coverage 99.16% 99.17%
=======================================
Files 70 71 +1
Lines 9020 9095 +75
=======================================
+ Hits 8945 9020 +75
Misses 75 75
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Implements receiver-side fan-out of firmware JOB_* events into peer-link application frames for remote-submitted firmware jobs (issue #106 phase 5c-2b), so offloaders can receive lifecycle transitions and streaming build output over the existing peer-link session.
Changes:
- Added
JobFanouthelper that listens to firmware job lifecycle/output bus events and forwards them asjob_state_changed/job_outputpeer-link frames for jobs tagged withremote_peer+remote_job_id. - Threaded a new
FirmwareJob.remote_job_idfield from thesubmit_jobheader through job creation so the receiver can echo the offloader’s job id back on all frames. - Added a focused unit test suite for the fan-out behavior and updated existing peer-link tests/stubs for the new job-creation signature.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
esphome_device_builder/controllers/remote_build_job_fanout.py |
New receiver-side fan-out module that converts JOB_* bus events into peer-link job_state_changed / job_output frames. |
esphome_device_builder/controllers/remote_build.py |
Wires JobFanout into controller start()/stop() lifecycle. |
esphome_device_builder/controllers/remote_build_submit_job.py |
Passes remote_job_id when creating firmware jobs from peer-link submissions. |
esphome_device_builder/controllers/firmware/controller.py |
Extends _create_job() to accept/store remote_job_id. |
esphome_device_builder/models/firmware.py |
Adds FirmwareJob.remote_job_id field for tracking the offloader’s job id. |
tests/test_remote_build_job_fanout.py |
New tests covering lifecycle/output fan-out, skip paths, detachment, and send failure swallow behavior. |
tests/test_remote_build_peer_link.py |
Updates test stub firmware _create_job signature to include remote_job_id. |
This was referenced May 10, 2026
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.
What does this implement/fix?
Phase 5c-2b of #106 — receiver-side fan-out from firmware
JOB_*events to peer-link frames. Pairs with the just-merged 5c-2a accept path (#528): once a remote-peerFirmwareJobis queued (carryingremote_peer+remote_job_id), the firmware controller's existing lifecycle and output events drivejob_state_changed/job_outputframes back to the submitting offloader.What this PR adds:
controllers/remote_build_job_fanout.py—JobFanoutclass subscribes to firmwareJOB_*events, filters to remote-peer jobs, and forwards typed wire frames over the matching peer-link session.JOB_STARTED/JOB_COMPLETED/JOB_FAILED/JOB_CANCELLEDmap 1:1 tojob_state_changed{status: running|completed|failed|cancelled}.JOB_OUTPUTmaps tojob_output{stream: "stdout", line}. Wired intoRemoteBuildController.start()(gated on_db.firmware) and detached instop().FirmwareJob.remote_job_id— new optional string field carrying the offloader's submit-taggedjob_idfrom thesubmit_jobheader. The receiver-sideFirmwareJob.job_idis generated independently (uuid4 hex), so the two id-spaces don't collide; this field threads the offloader's tag through so the fan-out can echo it back on every frame. The offloader matches against its own submit-tagged id, not the receiver's local one._create_jobacceptsremote_job_idalongsideremote_peer, andSubmitJobReceiver._extract_and_queuepassespending.job_id.JOB_QUEUEDdeliberately doesn't fan out — thesubmit_job_ackresponse from 5c-2a already tells the offloader the job is queued, so a redundantjob_state_changed{queued}frame would race the ack and add wire noise without adding signal. TheLiteral["queued", ...]slot stays in the wire schema for future use; today only the four post-queue transitions fan out.Best-effort fan-out — a session that's unregistered between the
JOB_*fire and the lookup, or asend_app_framethat itself raises, is logged at debug and skipped. The job runs to completion either way; the offloader's missing-output is on the next session bring-up's problem to surface (or 5d's cancel path to mop up).16 unit tests in
tests/test_remote_build_job_fanout.pycovering: each lifecycle transition's status mapping,error_messagecarry-through onfailed, the local-job-no-fan-out filter, the session-gone graceful skip, theJOB_QUEUEDnot-fanned-out contract, theJOB_OUTPUThappy path + skip-paths (local job / unknown job_id / firmware unavailable / session gone),stop()listener detachment, and the swallow-on-send-failure path. 100% coverage on the new module.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
(
FirmwareJob.remote_job_iddefaults to"", so existing frontend renderers ignoring unknown fields keep working unchanged. Thejob_state_changed/job_outputframes go to the offloader-sidePeerLinkClient(which 5c-3 will surface as local bus events the frontend re-broadcasts viasubscribe_events); receiver-side frontend isn't affected.)Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.jsonhas not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.(Architecture mention deferred — the receive-side flow is half-described already in
docs/ARCHITECTURE.md's "Long-lived peer-link sessions" section; the proper end-to-end write-up belongs in 5c-3 alongside the offloader-side submit caller, when the round-trip is fully observable.)