Skip to content

feat(autoresearch): synthesise platformio.ini from boards.py, drop root dep - #3290

Merged
zackees merged 2 commits into
masterfrom
feat/autoresearch-no-root-platformio
Jun 19, 2026
Merged

zackees merged 2 commits into
masterfrom
feat/autoresearch-no-root-platformio

Conversation

@zackees

@zackees zackees commented Jun 19, 2026 •

Copy link
Copy Markdown
Member

Summary

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 autoresearch path. The only remaining sanctioned consumer of root is bash debug (and raw pio 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) from ci/compiler/pio.py. Same staging logic as bash compile: apply_board_specific_config → Board.to_platformio_ini → copy_example_source → copy_fastled_library.
  • Output: <project_root>/.build/pio/<board>/ with platformio.ini + src/sketch/ populated.

2. Args + phases changes

  • ci/autoresearch/args.py: new --use-root-platformio-ini flag (default False). When set, emits DEPRECATION: --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 redirect build_dir. When the board is not known, defer to _resolve_port_and_environment.
  • ci/autoresearch/phases.py::_resolve_port_and_environment: after detect_attached_chip resolves the env, if synthesis was deferred, run it now and update ctx.build_dir.
  • The two get_default_environment(str(ctx.build_dir)) calls (which read default_envs from <build_dir>/platformio.ini) are now gated on args.use_root_platformio_ini. In the synthesised path the default_envs mismatch warning is dead code by construction.

3. CodeRabbit lockdown rule (.coderabbit.yaml)

  • Removed the autoresearch carve-out from rule Allow duplication of data to more LEDs #3 — ci/autoresearch/ is no longer a sanctioned root-platformio.ini reader.
  • Only ci/debug_attached.py remains. The --use-root-platformio-ini escape hatch is explicitly noted as a deprecated, scheduled-for-removal exception.
  • Updated wording throughout the lockdown block (1, 3) to reference bash debug only, not bash autoresearch.

4. Docs (agents/docs/hardware-autoresearch.md)

  • New section explaining the synthesised flow, board-resolution order, and the deprecation note for --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_dir is the staged dir.
  • test_synthesised_path_defers_when_board_unknown — no board known → staging NOT called, build_dir falls back to project root for deferred synthesis.
  • test_legacy_flag_still_requires_root_platformio_ini — --use-root-platformio-ini preserves the old existence check.
  • _make_args defaults use_root_platformio_ini=True so existing 53 tests keep exercising the legacy path; 3 new tests exercise the new path.

Verification

Manual (this branch, Windows host):

  • Synthesis with root present: succeeds, writes .build/pio/esp32c6/platformio.ini + src/sketch/.
  • Synthesis WITHOUT root (heavy validation from issue bash autoresearch: migrate off root platformio.ini; synthesise from ci/boards.py #3281 AC 2): mv platformio.ini platformio.ini.bak; uv run python -c "from ci.autoresearch.staging import synthesise_autoresearch_project; synthesise_autoresearch_project('esp32c6')" → success.
  • End-to-end Args.parse_args + _parse_args_and_build_commands without root → returns RunContext with build_dir = .build/pio/esp32c6/, final_environment = esp32c6.
  • Legacy --use-root-platformio-ini still 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 lint clean.

Coordination with #3278

Independent of #3278 (Phase 2 sever). Autoresearch had its OWN direct read sites on root ./platformio.ini:

  1. phases.py:778 — explicit (build_dir / 'platformio.ini').exists() gate.
  2. phases.py:1005 / 1022 — get_default_environment(str(ctx.build_dir)) reading default_envs.

Both are now gated on args.use_root_platformio_ini. The Phase 2 sever in pio.py:155 is orthogonal — that closes a different leak in the --backend platformio compile path, not autoresearch.

Out of scope

Closes #3281

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added deprecated --use-root-platformio-ini for legacy behavior.
    • AutoResearch now uses board-specific, synthesized build configurations by default (staged per board).
  • Documentation

    • Updated hardware AutoResearch documentation to describe default synthesized behavior and the legacy flag.
  • Bug Fixes / Improvements

    • Improved selection of sketches/build inputs and clearer guidance when board environment detection fails.
  • Tests

    • Added unit tests covering synthesized vs legacy configuration paths and error handling.

…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]>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5c4d7790-82dd-4d51-9412-f82505f33275

📥 Commits

Reviewing files that changed from the base of the PR and between d57d92b and afc0dfc.

📒 Files selected for processing (2)
  • ci/autoresearch/phases.py
  • ci/autoresearch/staging.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • ci/autoresearch/phases.py

📝 Walkthrough

Walkthrough

Adds ci/autoresearch/staging.py with synthesise_autoresearch_project, which stages a per-board platformio.ini under .build/pio/<board>/ using a monkey-patched suppression of root build flags. Threads a --use-root-platformio-ini legacy escape-hatch flag through Args and phases.py, replacing the unconditional root-file check with three-way branching. Updates .coderabbit.yaml to restrict root platformio.ini consumers to bash debug only.

Changes

Autoresearch platformio.ini synthesis and legacy escape hatch

Layer / File(s) Summary
Args flag and synthesis engine
ci/autoresearch/args.py, ci/autoresearch/staging.py
Args gains use_root_platformio_ini: bool; parse_args registers --use-root-platformio-ini with a deprecation warning. New staging.py adds _suppress_root_platformio_merge (monkey-patches get_root_platformio_build_flags → [] during synthesis) and synthesise_autoresearch_project which creates the board, FastLEDPaths, and staged build directory via _init_platformio_build.
phases.py: root vs synthesised branching and deferred synthesis
ci/autoresearch/phases.py
Replaces unconditional root platformio.ini validation with three-way logic: validate root, synthesise immediately when board is known, or defer synthesis to environment-resolution time. Updates sketch path resolution to check synthesised locations. Gates default_env derivation and chip-detection fallback on --use-root-platformio-ini.
Tests, docs, and policy
ci/tests/test_autoresearch_phases.py, agents/docs/hardware-autoresearch.md, .coderabbit.yaml
Adds three new phase tests (immediate synthesis, deferred synthesis, legacy error). Updates _make_args default to use_root_platformio_ini=True. Documents the synthesised path and --use-root-platformio-ini deprecation in hardware-autoresearch.md. Tightens .coderabbit.yaml to restrict root platformio.ini to bash debug only, requiring ; added-in: audit tokens in justification comments.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2794: This PR's _suppress_root_platformio_merge monkey-patch directly counteracts the root build_flags merging introduced in that PR during synthesised PlatformIO init.
  • FastLED/FastLED#3009: Both PRs modify ci/autoresearch/phases.py's sketch dispatch and build-dir resolution logic in _parse_args_and_build_commands.
  • FastLED/FastLED#3280: This PR extends the root platformio.ini lockdown policy introduced in #3280 by adding ; added-in: audit tokens and explicitly forbidding ci/autoresearch/ as a sanctioned reader.

Poem

🐇 Hop hop, no more root ini to chase,
Each board gets its own synthesised space!
--use-root still works if you dare,
(Deprecated, so use it with care.)
The rabbit stamps: bash debug alone
Shall claim the old config as its own. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main objective: synthesizing platformio.ini from boards.py and removing root dependency for autoresearch.
Linked Issues check ✅ Passed All five acceptance criteria from #3281 are met: synthesized builds working [staging.py, phases.py], root-absent verification confirmed, escape hatch flag implemented [args.py], documentation updated [hardware-autoresearch.md], and lockdown rules enforced [.coderabbit.yaml].
Out of Scope Changes check ✅ Passed All changes are directly aligned with #3281 objectives; no out-of-scope modifications found beyond the five acceptance criteria and supporting test coverage.
Docstring Coverage ✅ Passed Docstring coverage is 81.82% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/autoresearch-no-root-platformio

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a427694 and d57d92b.

📒 Files selected for processing (6)
  • .coderabbit.yaml
  • agents/docs/hardware-autoresearch.md
  • ci/autoresearch/args.py
  • ci/autoresearch/phases.py
  • ci/autoresearch/staging.py
  • ci/tests/test_autoresearch_phases.py

Comment thread ci/autoresearch/phases.py Resolved
Comment thread ci/autoresearch/phases.py Resolved
Comment thread ci/autoresearch/staging.py Resolved
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]>
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 19, 2026
@zackees
zackees merged commit 3e11e65 into master Jun 19, 2026
28 checks passed
@zackees
zackees deleted the feat/autoresearch-no-root-platformio branch June 19, 2026 21:46
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 19, 2026
zackees added a commit that referenced this pull request Jun 19, 2026
- 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]>
zackees added a commit that referenced this pull request Jun 19, 2026
)

* 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]>
zackees added a commit that referenced this pull request Jun 20, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bash autoresearch: migrate off root platformio.ini; synthesise from ci/boards.py

1 participant