Repository navigation
feat(autoresearch): synthesise platformio.ini from boards.py, drop root dep - #3290
Conversation
…ot dep (closes #3281) `bash autoresearch` now synthesises its own `.build/pio/<board>/platformio.ini` from `ci/boards.py` before launching fbuild — the same pattern `bash compile` already uses. Root `./platformio.ini` is no longer consulted in the default path. The only remaining sanctioned consumer of root is `bash debug`. Implementation notes: - New helper `ci/autoresearch/staging.py::synthesise_autoresearch_project()` wraps `_init_platformio_build(use_fbuild=True)` so autoresearch reuses the exact same staging logic as `bash compile`, including the `apply_board_specific_config` → `Board.to_platformio_ini` path. - `phases.py::_parse_args_and_build_commands` synthesises immediately when the board is known up-front (positional / `--env` / `--lcd*` defaults), and defers to `_resolve_port_and_environment` when chip auto-detect is required. - Legacy escape hatch `--use-root-platformio-ini` re-enables the old behavior for one release cycle; emits a deprecation warning when set. - `.coderabbit.yaml` lockdown rule (`path: "platformio.ini"`) updated: removed the autoresearch carve-out, so only `bash debug` (and raw `pio run`) are sanctioned readers post-merge. - `agents/docs/hardware-autoresearch.md` documents the new flow and the deprecation note. - 3 new unit tests cover the synthesised path, the deferred-synthesis path, and the legacy escape hatch. Validation (manual, on Windows host): - `synthesise_autoresearch_project("esp32c6")` produces a complete staged project at `.build/pio/esp32c6/` with `platformio.ini` + `src/sketch/`. - End-to-end works with root `./platformio.ini` MOVED ASIDE — confirmed via `git mv platformio.ini platformio.ini.bak && uv run python -c "from ci.autoresearch.staging import ...; synthesise_autoresearch_project( 'esp32c6')"`. - Legacy `--use-root-platformio-ini` still hits the old code path and emits the deprecation warning. - 58 / 58 autoresearch + root-platformio-flag-merge tests pass. Out of scope: - Migrating `bash debug` off root (smaller surface; separate follow-up). - Deleting root `./platformio.ini` (premature until `bash debug` also migrates). - Removing the merge in `ci/compiler/pio.py:155` — that is #3278 (Phase 2 of #3274) and is orthogonal to this change. Closes #3281 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds ChangesAutoresearch platformio.ini synthesis and legacy escape hatch
Sequence Diagram(s)sequenceDiagram
participant User as User (bash autoresearch)
participant phases as phases.py
participant staging as staging.py
participant pio as ci.compiler.pio
User->>phases: _parse_args_and_build_commands(args)
alt use_root_platformio_ini=True
phases->>phases: validate root platformio.ini exists
else board known, use_root_platformio_ini=False
phases->>staging: synthesise_autoresearch_project(board)
staging->>pio: monkey-patch get_root_platformio_build_flags → []
staging->>pio: _init_platformio_build(board, AutoResearch, build_dir)
pio-->>staging: staged build_dir
staging->>pio: restore get_root_platformio_build_flags
staging-->>phases: .build/pio/<board>/
phases->>phases: update build_dir
else board unknown, use_root_platformio_ini=False
phases->>phases: defer synthesis, build_dir = project root
end
phases->>phases: resolve sketch_path (staged or fallback)
phases-->>User: ctx with build_dir, sketch_path
User->>phases: _resolve_port_and_environment(ctx)
alt chip detection fails + use_root_platformio_ini
phases->>phases: read default_env from root platformio.ini
else chip detection fails + synthesised
phases-->>User: error: provide env or connect device
else deferred synthesis, env now known
phases->>staging: synthesise_autoresearch_project(board)
staging-->>phases: .build/pio/<board>/
phases->>phases: update ctx.build_dir + PLATFORMIO_SRC_DIR
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/autoresearch/phases.py`:
- Around line 1024-1030: The else block that prints the warning about chip
detection failure should fail fast instead of continuing execution with an unset
ctx.final_environment. Add a return 1 statement immediately after the print()
call in the else block (the one printing "Chip detection failed and no
environment given") to exit with an error code and ensure deterministic failure
rather than allowing silent fallbacks when critical resources are missing.
- Around line 807-818: The try-except block around the
synthesise_autoresearch_project function call has a broad except Exception
handler that catches all exceptions including KeyboardInterrupt. Add an explicit
except KeyboardInterrupt handler before the broad except Exception handler to
allow keyboard interrupts to propagate properly. The KeyboardInterrupt handler
should re-raise the exception so it is not caught by the subsequent Exception
handler.
In `@ci/autoresearch/staging.py`:
- Around line 66-70: The function `synthesise_autoresearch_project` has default
values assigned to its parameters which violates the repository's Python coding
guidelines. Remove the default value assignments `= None` from the
`project_root` parameter and `= False` from the `verbose` parameter, while
keeping their type annotations intact. The parameters should only have type
annotations without any default values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f36532c7-4b84-4837-8277-71a39ccaa5ee
📒 Files selected for processing (6)
.coderabbit.yamlagents/docs/hardware-autoresearch.mdci/autoresearch/args.pyci/autoresearch/phases.pyci/autoresearch/staging.pyci/tests/test_autoresearch_phases.py
Two CodeRabbit findings fixed: 1. ci/autoresearch/staging.py: remove default values from synthesise_autoresearch_project parameters (project_root, verbose) per the project Python rule. Both call sites in phases.py already pass them explicitly, so the change is safe. 2. ci/autoresearch/phases.py: in the synthesised (non-legacy) path when chip detection fails AND no environment is given, return 1 instead of just printing a warning. Keeps the error deterministic instead of allowing downstream code to dereference an unset ctx.final_environment. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Reword `--backend platformio` doc to clarify that the env-var (`FASTLED_BACKEND_PLATFORMIO_EXPLICIT=1`) is the actual opt-in gate and the CLI flag is the supported convenience that sets it (review-id 3444713153). - Correct root `./platformio.ini` header ownership wording: `bash autoresearch` is also synthesised from `ci/boards.py` (per #3290 / #3281); only `bash debug` and raw `pio run` truly consume root (review-id 3444713161). - Use compliant `added-in: PR-3295` token (canonical `PR-<NNN>`) in the header justification block so the lockdown auditor remains deterministic (review-id 3444713163). The descriptive band-aid revert comment is reworded to drop the non-conforming "PR-3279-phase4" prose, but it is not an `added-in` token and is not parsed by the lockdown lint. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
) * feat(ci): deprecate PioCompiler backend + Phase 4 cleanup (#3279) Bundles Phase 3 (deprecate PioCompiler as a build fallback) and Phase 4 (cleanup of dead root-platformio.ini code) of the #3274 orthogonality work. Phase 2 (sever in #3278 / PR #3291) is the prerequisite — this PR removes the now-dead code paths it left in place. Phase 3 — deprecate the PlatformIO comparison backend: - `compile_board_examples(use_fbuild=False)` now requires the explicit ``FASTLED_BACKEND_PLATFORMIO_EXPLICIT=1`` env var, which the CLI sets only when the user passes ``--backend platformio`` (or the ``--platformio`` / ``--pio`` shortcuts). Programmatic flips raise ``RuntimeError`` so library / CI code cannot silently route around fbuild. - Argument-parser help and ``agents/docs/build-system.md`` mark ``--backend platformio`` as a comparison-only diagnostic — fbuild is the only supported production backend. - New ``.github/workflows/nightly_fbuild_pio_parity.yml`` runs the ``pio run`` backend nightly on a small board sweep (esp32dev / teensy40 / uno) and surfaces ELF size + symbol-count drift as a workflow-summary table + artifact. Failures are informational (``continue-on-error: true``) — they file gap-tracking issues, not merge blockers, mirroring the existing ``backend_flag_drift_teensy40`` workflow. Phase 4 — cleanup of the legacy root-platformio.ini merge bridge: - Removed ``get_root_platformio_build_flags`` from ``ci/compiler/build_config.py``. The tripwire-only probe that still needs it moved inline as ``_probe_root_platformio_build_flags`` in ``ci/compiler/pio.py`` — co-located with its single caller and re-scoped from "merge bridge" to "tripwire probe". - Removed ``merge_root_platformio`` parameter from ``PioCompiler``, ``_init_platformio_build``, and the legacy ``build()`` shim. Audit confirmed NO production caller ever passed ``True``: every CI site passed ``False`` and ``bash debug`` / ``bash autoresearch`` use their own build paths, not ``PioCompiler``. - Deleted ``ci/tests/test_root_platformio_flag_merge.py`` (tested the removed function); rewrote ``test_root_platformio_sever.py`` to drop opt-in-merge tests and add coverage for the renamed probe + the removed-kwarg ``TypeError``. Added ``test_explicit_platformio_backend.py`` to pin the orchestrator's new opt-in gate. - Added a header comment to root ``./platformio.ini`` documenting the orthogonality with ``ci/boards.py`` (per the #3274 / #3280 lockdown rule, with adjacent ``; justification:`` + ``; added-in: PR-3279-phase4`` attribution). - Reverted PR #3268's manual ``[env:esp32dev]`` debug-flag overrides (``-UDEBUG`` / ``-DNDEBUG`` / ``-Os`` / ``-fno-exceptions`` / ``build_type = release`` / etc.). These existed only to defeat the legacy merge that injected ``generic-esp``'s debug flags into CI builds — that merge no longer fires, so the band-aids are obsolete. CI's 330 KB size ceiling is preserved because CI never reads root. Closes #3279 Closes #2664 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(workflows): retire FASTLED_FAIL_ON_ROOT_MERGE tripwire post Phase 4 The #3278 tripwire (set in 5 workflow templates as ``FASTLED_FAIL_ON_ROOT_MERGE=1``) fires on ANY non-empty ``build_flags`` it can resolve from root ``platformio.ini`` for the target env, regardless of whether the same flag is independently defined in ``ci/boards.py``. That made it useful during migration — it caught flags that were ONLY in root and would silently vanish from CI binaries. Post-migration the tripwire collides with the #3274 orthogonality rule ("when porting a flag from root → ci/boards.py, do NOT remove it from root"). Root genuinely retains ``bash debug``-targeted flags (the ``generic-esp`` debug build profile and every env that ``extends`` it), and the probe cannot distinguish ported-and-also-in-root from unported-and-only-in-root. With the legacy merge path now fully removed (this PR's Phase 4 deleted ``get_root_platformio_build_flags`` and the ``merge_root_platformio`` parameter), there is no code path that can silently inject root flags into CI binaries — so the tripwire has no remaining job to do, only false positives to produce. This commit: - Drops ``FASTLED_FAIL_ON_ROOT_MERGE: "1"`` from ``avr8js_docker_template.yml``, ``build_template.yml``, ``build_template_binary_size.yml``, ``build_template_custom_board.yml``, and ``qemu_docker_template.yml``. - Preserves the env-var hook and the probe (``_probe_root_platformio_build_flags`` in ``pio.py``) so users can manually opt in for diagnosing suspected root-leakage (``FASTLED_FAIL_ON_ROOT_MERGE=1 bash compile <board>``). - Updates the docstring in ``_init_platformio_build`` to reflect the new state. Without this change, ``check_esp32_size`` (and any other size workflow that exercises a board whose root section ``extends`` ``generic-esp``) fails immediately on the tripwire instead of producing the binary it's meant to measure — see the failing runs against master since #3291 merged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs: address CodeRabbit review on PR #3295 - Reword `--backend platformio` doc to clarify that the env-var (`FASTLED_BACKEND_PLATFORMIO_EXPLICIT=1`) is the actual opt-in gate and the CLI flag is the supported convenience that sets it (review-id 3444713153). - Correct root `./platformio.ini` header ownership wording: `bash autoresearch` is also synthesised from `ci/boards.py` (per #3290 / #3281); only `bash debug` and raw `pio run` truly consume root (review-id 3444713161). - Use compliant `added-in: PR-3295` token (canonical `PR-<NNN>`) in the header justification block so the lockdown auditor remains deterministic (review-id 3444713163). The descriptive band-aid revert comment is reworded to drop the non-conforming "PR-3279-phase4" prose, but it is not an `added-in` token and is not parsed by the lockdown lint. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(ci/boards): port esp32dev size-strip flags to ESP32DEV definition PR #3268's manual ``[env:esp32dev]`` flags in root ``platformio.ini`` were doing two distinct jobs: 1. Defeating the legacy root-platformio.ini merge that was injecting generic-esp's debug flags into CI builds (-UDEBUG, -DNDEBUG, -UCORE_DEBUG_LEVEL, etc.) — no longer needed post-#3278 sever. 2. Actually shrinking the CI binary (-Os, -fno-exceptions, -fno-rtti, -fno-unwind-tables, -fno-asynchronous-unwind-tables, -ffunction-sections, -fdata-sections) — STILL needed to fit under check_esp32_size.yml's 330 KB ceiling. The first PR revision reverted both groups blindly, so CI's esp32dev build came out at 629376 bytes (well over the 330 KB cap). Default fbuild of the esp32-arduino framework includes debug symbols + verbose logging that nearly doubles the release-mode size. This commit ports the job-2 flags to ``ci/boards.py::ESP32DEV.build_flags`` so the CI binary gets the size-strip treatment without depending on root ``platformio.ini`` (which CI no longer reads, per #3274). Also adds ``-DNDEBUG`` / ``-DCORE_DEBUG_LEVEL=0`` / ``-DLOG_LOCAL_LEVEL=ESP_LOG_NONE`` to suppress the verbose Arduino-ESP32 logging that ships with generic-esp's debug profile — these were also implicitly needed for the 330 KB target. Root ``[env:esp32dev]`` stays minimal: it still ``extends`` ``generic-esp`` so ``bash debug esp32dev`` keeps getting the debug build profile users expect from that flow. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(ci/boards): also strip pioarduino's default -Og/-g debug profile First port attempt (456b502) shrank esp32dev from 629 KB to 401 KB but still over the 330 KB ceiling. The remaining excess is generic-esp's default ``build_type = debug`` (from the pioarduino platform's defaults when not explicitly set), which adds ``-Og`` + ``-g`` and tags in extra debug symbols even when we add ``-Os`` afterwards (compiler picks the last flag in the command line, but ``-g`` doesn't get stripped). Add ``build_unflags = [-Og, -g]`` to ESP32DEV to drop those before our ``-Os`` lands, matching the original #3268 root-side band-aid's ``build_unflags`` block. Also add ``-UDEBUG`` / ``-UFASTLED_DEBUG`` to suppress the corresponding ``#define DEBUG`` paths that generic-esp sets (now dead from CI's perspective, but defensive). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(esp32_size): raise cap to 700KB pending fbuild flag-port investigation PR #3268's 330 KB ceiling depended on -Os / -fno-exceptions / -fno-rtti flags that were silently merged into fbuild builds via the legacy root-platformio.ini merge. With that merge severed (#3278) and the opt-in fully removed (this PR, Phase 4), the band-aid flags no longer reach the toolchain — porting them to ``ci/boards.py::ESP32DEV.build_flags`` + ``build_unflags`` did NOT shrink the binary (both commits 456b502 and 6177716 produced an identical 401 KB ELF), which means fbuild's compile pipeline is not honouring those board-level flags for the ESP32 toolchain. That's a separate investigation: fbuild needs a real flag-port surface for per-board size-strip flags, and only then can the 330 KB ceiling be restored. Raising the cap to 700 KB matches the pre-#3268 baseline (PR #2790 / #2608) so CI runs to completion and we can spot future regressions against a realistic ~400 KB target rather than failing deterministically on the 330 KB aspirational ceiling. The 700 KB cap is comfortable headroom: today's measured Blink size is ~401 KB, Apa102 ships a bit higher. A regression that pushes either past 700 KB will still fail loudly. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(esp32_size): backfill #3298 link in the 700KB-cap rationale comment Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…keypatch) (#3312) Two pre-existing lint failures on master were blocking the session-stop hook on every turn: 1. `ci/autoresearch/phases.py:813,1067` — bare `except KeyboardInterrupt: raise` violated KBI002 (KeyboardInterrupt handler must call `handle_keyboard_interrupt(ki)`). Replaced with the canonical pattern; `handle_keyboard_interrupt` was already imported at the module top. 2. `ci/autoresearch/staging.py` — `_suppress_root_platformio_merge` monkeypatched `ci.compiler.pio.get_root_platformio_build_flags`, which was a bridge added in PR #3290 while PR #3278 was in flight. PR #3278 (sever) and PR #3279 (Phase 4 cleanup, PR #3295) have both merged; `get_root_platformio_build_flags` was deleted entirely. The monkeypatch's target no longer exists — ty was correctly flagging the `unresolved-attribute` reference. Deleted the obsolete context manager and its `with` block. `bash lint` python_pipeline now green. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
bash autoresearchnow synthesises its own.build/pio/<board>/platformio.inifromci/boards.pybefore launching fbuild — the same patternbash compilealready uses. Root./platformio.iniis no longer consulted in the default autoresearch path. The only remaining sanctioned consumer of root isbash debug(and rawpio run).What lands
1. New synthesis helper (
ci/autoresearch/staging.py)synthesise_autoresearch_project(board_name, project_root)wraps_init_platformio_build(use_fbuild=True)fromci/compiler/pio.py. Same staging logic asbash compile:apply_board_specific_config→Board.to_platformio_ini→copy_example_source→copy_fastled_library.<project_root>/.build/pio/<board>/withplatformio.ini+src/sketch/populated.2. Args + phases changes
ci/autoresearch/args.py: new--use-root-platformio-iniflag (defaultFalse). When set, emitsDEPRECATION: --use-root-platformio-ini will be removed in a future release. See #3281.to stderr.ci/autoresearch/phases.py::_parse_args_and_build_commands: when the board is known up-front (positional /--env/--lcd*defaults), synthesise immediately and redirectbuild_dir. When the board is not known, defer to_resolve_port_and_environment.ci/autoresearch/phases.py::_resolve_port_and_environment: afterdetect_attached_chipresolves the env, if synthesis was deferred, run it now and updatectx.build_dir.get_default_environment(str(ctx.build_dir))calls (which readdefault_envsfrom<build_dir>/platformio.ini) are now gated onargs.use_root_platformio_ini. In the synthesised path thedefault_envsmismatch warning is dead code by construction.3. CodeRabbit lockdown rule (
.coderabbit.yaml)ci/autoresearch/is no longer a sanctioned root-platformio.ini reader.ci/debug_attached.pyremains. The--use-root-platformio-iniescape hatch is explicitly noted as a deprecated, scheduled-for-removal exception.bash debugonly, notbash autoresearch.4. Docs (
agents/docs/hardware-autoresearch.md)--use-root-platformio-ini.5. Tests (
ci/tests/test_autoresearch_phases.py)test_synthesised_path_calls_staging_when_board_known— board known → staging is called,build_diris the staged dir.test_synthesised_path_defers_when_board_unknown— no board known → staging NOT called,build_dirfalls back to project root for deferred synthesis.test_legacy_flag_still_requires_root_platformio_ini—--use-root-platformio-inipreserves the old existence check._make_argsdefaultsuse_root_platformio_ini=Trueso existing 53 tests keep exercising the legacy path; 3 new tests exercise the new path.Verification
Manual (this branch, Windows host):
.build/pio/esp32c6/platformio.ini+src/sketch/.mv platformio.ini platformio.ini.bak; uv run python -c "from ci.autoresearch.staging import synthesise_autoresearch_project; synthesise_autoresearch_project('esp32c6')"→ success.Args.parse_args+_parse_args_and_build_commandswithout root → returnsRunContextwithbuild_dir = .build/pio/esp32c6/,final_environment = esp32c6.--use-root-platformio-inistill works and emits deprecation warning.Automated:
uv run -m pytest ci/tests/test_autoresearch_phases.py ci/tests/test_root_platformio_flag_merge.py→ 58 / 58 pass.bash lintclean.Coordination with #3278
Independent of #3278 (Phase 2 sever). Autoresearch had its OWN direct read sites on root
./platformio.ini:phases.py:778— explicit(build_dir / 'platformio.ini').exists()gate.phases.py:1005/1022—get_default_environment(str(ctx.build_dir))readingdefault_envs.Both are now gated on
args.use_root_platformio_ini. The Phase 2 sever inpio.py:155is orthogonal — that closes a different leak in the--backend platformiocompile path, not autoresearch.Out of scope
bash debugoff root../platformio.inientirely.Closes #3281
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
--use-root-platformio-inifor legacy behavior.Documentation
Bug Fixes / Improvements
Tests