Skip to content

Route Analyze memory through the remote build-server pool - #3032

Merged
J. Nick Koston (bdraco) merged 2 commits into
mainfrom
analyze-memory-remote
Nov 6, 2026
Merged

J. Nick Koston (bdraco) merged 2 commits into
mainfrom
analyze-memory-remote

Conversation

@bdraco

Copy link
Copy Markdown
Member

What does this implement/fix?

Analyze memory now runs on a paired build server like Compile and Install do, so it stops pulling toolchains and building on the local machine.

# before: always local
return await self._enqueue(self._create_job(configuration, JobType.ANALYZE_MEMORY))

# after: routed through the build scheduler like a compile
return await factories.enqueue_compile(
    self, configuration=configuration, job_type=JobType.ANALYZE_MEMORY
)
  • The receiver runs esphome analyze-memory itself and the report streams back as job output; nothing is downloaded.
  • Gated on a new analyze_memory_supported handshake flag, so an older receiver is never picked and the job runs locally as before.
  • Backend only; the frontend already just renders the job output.
How it works

The receiver accepts a new submit_job target, analyze_memory. On the offloader, build_scheduler.inputs_for_job_type narrows the pairings to capable receivers both at submit and in the dispatch pool, a REMOTE_PENDING analysis waits in the pool beside compiles, and the runner finalises it on the receiver's terminal frame without fetching artifacts (same as clean). The post job hash refresh is skipped for a remote analysis since there is no local build_info.json to read. The capability is plumbed the same way as reset_build_env_supported.

Related issue or feature (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — docs
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Frontend coordination

  • No frontend change needed
  • Companion frontend PR: esphome/device-builder-frontend#

Checklist

  • The code change is tested and works locally.
  • Pre-commit hooks pass (ruff, codespell, yaml/json/python checks).
  • Tests have been added or updated under tests/ where applicable.
  • components.index.json / definitions/components/*.json have not been hand-edited (regenerate via script/sync_components.py if a sync is needed).
  • Architecture-level changes are reflected in docs/ARCHITECTURE.md and/or docs/API.md.

A paired receiver that advertises analyze_memory_supported now runs
esphome analyze-memory itself and streams the report back; older
receivers are skipped and the job runs locally as before.
@bdraco J. Nick Koston (bdraco) added the enhancement Improvement to an existing feature label Nov 6, 2026
@bdraco

Copy link
Copy Markdown
Member Author

ESPHome Bot (@esphbot) review

@bdraco
J. Nick Koston (bdraco) marked this pull request as ready for review November 6, 2026 01:01
Copilot AI balanced review requested due to automatic review settings November 6, 2026 01:01
@codspeed

codspeed Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing analyze-memory-remote (3694822) with main (7b433eb)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.77%. Comparing base (7c5102c) to head (3694822).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3032   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files         300      300           
  Lines       26522    26556   +34     
=======================================
+ Hits        26461    26495   +34     
  Misses         61       61           
Flag Coverage Δ
py3.12 99.73% <100.00%> (+<0.01%) ⬆️
py3.14 99.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...evice_builder/controllers/devices/firmware_sync.py 100.00% <100.00%> (ø)
...home_device_builder/controllers/firmware/_state.py 100.00% <100.00%> (ø)
...e_device_builder/controllers/firmware/constants.py 100.00% <100.00%> (ø)
..._device_builder/controllers/firmware/controller.py 100.00% <100.00%> (ø)
...e_device_builder/controllers/firmware/factories.py 100.00% <100.00%> (ø)
...ce_builder/controllers/firmware/remote_dispatch.py 100.00% <ø> (ø)
...vice_builder/controllers/firmware/remote_runner.py 98.89% <100.00%> (+<0.01%) ⬆️
...ice_builder/controllers/remote_build/_summaries.py 100.00% <ø> (ø)
...e_builder/controllers/remote_build/bus_handlers.py 100.00% <100.00%> (ø)
..._builder/controllers/remote_build/pair_commands.py 100.00% <100.00%> (ø)
... and 14 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues require changes before approval.

No open issues 🎉

What changed in this PR

Routes Analyze Memory through the existing remote build-server pool, addressing #3003 so capable paired receivers can perform the build and analysis instead of the local dashboard.

Changes:

  • Adds capability-aware scheduling at submission and dispatch, preserving local fallback for older receivers.
  • Introduces an analyze_memory wire target, streams the report without downloading artifacts, and skips local hash refresh for remote analysis.
  • Extends capability persistence, events, tests, and documentation; no frontend changes are needed.
File Description
tests/​test_remote_build_submit_job.py Tests receiver creation of analysis jobs.
tests/​test_remote_build_peer_link.py Checks handshake capability advertisement.
tests/​test_remote_build_peer_link_client.py Tests capability parsing and pairing refresh.
tests/​test_remote_build_controller.py Tests capability exposure in pairing summaries.
tests/​controllers/​firmware/​test_remote_runner.py Tests remote analysis without artifact downloads.
tests/​controllers/​firmware/​test_remote_dispatch.py Tests capability-aware dispatch and local fallback.
tests/​controllers/​firmware/​test_refresh.py Tests hash refresh behavior by job source.
tests/​controllers/​firmware/​test_analyze_memory.py Tests analysis scheduling with capable and older receivers.
tests/​controllers/​firmware/​conftest.py Adds capability support to pairing fixtures.
esphome_device_builder/​models/​remote_build/​wire_frames.py Defines shared submission targets including analysis.
esphome_device_builder/​models/​remote_build/​offloader.py Adds stored and summarized analysis capability.
esphome_device_builder/​models/​remote_build/​offloader_events.py Adds capability fields to event payloads.
esphome_device_builder/​models/​remote_build/​__init__.py Exports the shared submission-target type.
esphome_device_builder/​helpers/​build_scheduler.py Filters analysis scheduling inputs by receiver capability.
esphome_device_builder/​controllers/​remote_build/​submit_job/​const.py Maps the analysis target to its job type.
esphome_device_builder/​controllers/​remote_build/​provision.py Declares receiver support for remote analysis.
esphome_device_builder/​controllers/​remote_build/​peer_link/​wire_io.py Advertises analysis support during handshakes.
esphome_device_builder/​controllers/​remote_build/​peer_link_client/​one_shot.py Extracts the capability with a false default.
esphome_device_builder/​controllers/​remote_build/​peer_link_client/​client.py Carries capability data and accepts the analysis target.
esphome_device_builder/​controllers/​remote_build/​peer_link_client/​_submit.py Uses shared target typing for submission frames.
esphome_device_builder/​controllers/​remote_build/​peer_link_client/​_dispatch.py Includes analysis capability in session-open events.
esphome_device_builder/​controllers/​remote_build/​peer_link_client/​__init__.py Exports the capability extraction helper.
esphome_device_builder/​controllers/​remote_build/​pair_status.py Includes capability in pairing-added events.
esphome_device_builder/​controllers/​remote_build/​pair_commands.py Preserves capability when re-pairing.
esphome_device_builder/​controllers/​remote_build/​bus_handlers.py Refreshes stored capability on session open.
esphome_device_builder/​controllers/​remote_build/​_summaries.py Projects capability into pairing summaries.
esphome_device_builder/​controllers/​firmware/​remote_runner.py Dispatches analysis and completes without artifact retrieval.
esphome_device_builder/​controllers/​firmware/​remote_dispatch.py Applies capability filtering when assigning queued jobs.
esphome_device_builder/​controllers/​firmware/​factories.py Generalizes compile scheduling for analysis jobs.
esphome_device_builder/​controllers/​firmware/​controller.py Routes the analysis command through the scheduler.
esphome_device_builder/​controllers/​firmware/​constants.py Includes analysis among remote-pool job types.
esphome_device_builder/​controllers/​firmware/​_state.py Holds pending analysis jobs in the remote pool.
esphome_device_builder/​controllers/​devices/​firmware_sync.py Skips local hash recomputation after remote analysis.
docs/​ARCHITECTURE.md Documents remote analysis and capability propagation.
docs/​API.md Documents analysis routing and handshake additions.

Review effort: Balanced

@esphbot

ESPHome Bot (esphbot) commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Previous review — superseded by a newer review below.

@esphbot ESPHome Bot (esphbot) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@bdraco

Copy link
Copy Markdown
Member Author

ESPHome Bot (@esphbot) review

@bdraco
J. Nick Koston (bdraco) enabled auto-merge (squash) November 6, 2026 01:18
@esphbot

Copy link
Copy Markdown
Contributor

PR Review — Route Analyze memory through the remote build-server pool

Ready to merge. Both nits from my last review are fixed, and I found nothing new.

What the PR does well:

  • Capability check in both places. inputs_for_job_type drops receivers that lack the capability before pick_build_path (at submit) and before pick_dispatch_target (in _dispatch_one). A setup with only older receivers falls back to running locally, even under EXACT_REQUIRED. A receiver that downgrades while an analysis waits in the pool is also skipped.
  • Reuses existing paths.
    • enqueue_compile keeps the default supersede=True, so the documented "supersedes the device's job" behaviour still holds.
    • _REMOTE_POOL_JOB_TYPES lets place_on_lane hold a pending analysis and re-route it when a server is lost.
    • _NO_ARTIFACT_JOB_TYPES finishes the job on the receiver's terminal frame without downloading anything.
    • Analysis already counts as a compiling job type, so a receiver running a different esphome version still provisions it.
  • Receiver mapping. TARGET_TO_JOB_TYPE is the receiver's runtime check on the target, so adding analyze_memory there is the only receiver-side change needed. upload stays explicitly rejected.
  • Hash skip. firmware_sync skips the hash recompute only for a REMOTE analysis, because no local build_info.json exists. An analysis that fell back to local keeps the recompute.
  • Plumbing and tests. The capability flag is plumbed the same way as reset_build_env_supported: storage schema, events, re-pair carry-over, summaries and docs. All are additive and default to False. The capability tests now use parametrize instead of duplicating code.

Prior findings, now resolved:

  • The docstring in test_submit_job_non_compile_target_creates_matching_job now covers both the clean and analyze_memory targets.
  • The _finalise_after_receiver_completed docstring rewrap is tidied (commit 3694822).


Checklist

  • Capability gating keeps older receivers on the local path
  • Remote pool, re-route and fallback paths handle the new job type
  • Receiver runtime check on the target accepts analyze_memory and still rejects upload
  • No hardcoded secrets / injection / path traversal introduced
  • Backward-compatible storage and wire format (additive, defaults False)
  • Tests cover submit routing, dispatch, runner, receiver mapping, hash skip

Automated review by Kōan (Claude) HEAD=3694822 19s

@esphbot ESPHome Bot (esphbot) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@bdraco
J. Nick Koston (bdraco) merged commit 70b10ec into main Nov 6, 2026
27 checks passed
@bdraco
J. Nick Koston (bdraco) deleted the analyze-memory-remote branch November 6, 2026 01:22
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement Improvement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Analyze Memory' does not use remote build server

3 participants