Skip to content

Split examples/AutoResearch/AutoResearchRemote.cpp (4,017 LOC) into 7 files of <1K LOC each (sub-issue of #3127) #3132

Closed

Description

@zackees

Tracked by #3127.

Goal

Split examples/AutoResearch/AutoResearchRemote.cpp (4,017 LOC, 171 kB) into 7 files of <1K LOC each. The dominant problem: registerFunctions() alone is 2,617 lines (1302–3919) — a single C++ method.

Hook policy note: ci/hooks/protect_example_ino.py blocks new .ino files but allows new .cpp companions to an existing .ino. AutoResearch's example sketch is AutoResearch.ino; sibling .cpp files already exist, so this split adds more siblings without needing the FL_AGENT_ALLOW_NEW_EXAMPLE override.

Split table

New file Content Source range Approx LOC
examples/AutoResearch/AutoResearchRemoteCore.cpp helpers (printJsonRaw, printStreamRaw, ScopedFastLedBrightness), ctor/dtor, tick(), registerAllMethods() glue, top-level registerFunctions() shell that calls bind*Methods() 1–310 + 3920–4017 + new dispatch shell ~480
examples/AutoResearch/AutoResearchRemoteRegistry.cpp runSingleTestImpl() + simple RPCs (status, debugTest, deliberateHang, drivers, runSingleTest) 311–1376 ~870 (may need internal split)
examples/AutoResearch/AutoResearchRemoteParallel.cpp runParallelTest, flexioObjectFledTest, RX-only bypass paths 1377–1963 ~590
examples/AutoResearch/AutoResearchRemoteGpio.cpp testGpioConnection, setTxPin, pin/driver state RPCs 1964–2487 ~525
examples/AutoResearch/AutoResearchRemoteSimd.cpp testSimd, testSimdBenchmark, parlioStreamValidate 2488–2844 ~360
examples/AutoResearch/AutoResearchRemoteAsync.cpp testAsync, runNetClientTest, runNetLoopback 2845–3162 ~320
examples/AutoResearch/AutoResearchRemoteCoroutines.cpp Coroutine tests (basic, stop-while-running, multi-concurrent, promise then/catch, pipeline) 3163–3919 ~760

After the split, the original AutoResearchRemote.cpp is deleted.

Split mechanism — needs maintainer call before PR 1

Option A (recommended): free-function helpers per family. Each family file exposes void bind<Family>Methods(fl::Remote*, fl::shared_ptr<AutoResearchState>, AutoResearchRemoteControl*) declared in a new private header examples/AutoResearch/AutoResearchRemoteFamilies.h. The shell in Core.cpp is then:

void AutoResearchRemoteControl::registerFunctions(fl::shared_ptr<AutoResearchState> state) {
    mState = state;
    bindRegistryMethods(mRemote, mState, this);
    bindParallelMethods(mRemote, mState, this);
    bindGpioMethods(mRemote, mState);
    bindSimdMethods(mRemote, mState);
    bindAsyncMethods(mRemote, mState);
    bindCoroutineMethods(mRemote, mState);
}

Option B: .cpp.hpp inline-includes. Each family file becomes a .cpp.hpp aggregated by a single Core.cpp #include. This keeps registerFunctions() as one literal body but the unity-build TU stays huge — defeats half the point of splitting.

Recommendation: Option A. Decision needed from @zackees before PR 1 lands.

PR plan

Assuming Option A:

  1. PR 1 (foundation): Create AutoResearchRemoteFamilies.h with forward declarations for bind*Methods family. Create AutoResearchRemoteCore.cpp with helpers + ctor/dtor + tick() + registerAllMethods() glue + shell registerFunctions(). The shell temporarily still calls the original monolithic registerFunctions() body inlined for backwards compatibility. PR is small (just the forward-decl scaffolding); CI should be green.
  2. PR 2: Extract AutoResearchRemoteRegistry.cpp (lines 311–1376). Move runSingleTestImpl() and simple-RPC binds. Replace the moved content in the original with bindRegistryMethods() call in the Core shell. CI green.
  3. PR 3: Extract AutoResearchRemoteParallel.cpp (lines 1377–1963).
  4. PR 4: Extract AutoResearchRemoteGpio.cpp (lines 1964–2487).
  5. PR 5: Extract AutoResearchRemoteSimd.cpp (lines 2488–2844).
  6. PR 6: Extract AutoResearchRemoteAsync.cpp (lines 2845–3162).
  7. PR 7: Extract AutoResearchRemoteCoroutines.cpp (lines 3163–3919); delete the now-empty original AutoResearchRemote.cpp.

PR 7 carries Closes #<this-issue>.

Validation per PR

  • bash compile uno --examples AutoResearch succeeds (host compile only — no upload needed for split-correctness).
  • bash compile wasm --examples AutoResearch succeeds.
  • bash compile esp32s3 --examples AutoResearch succeeds (the RPC machinery is most exercised on ESP32 — flash budget matters here).
  • bash autoresearch --parlio smoke test still succeeds against an attached device IF available; otherwise dry-run is acceptable for the split-correctness gate.

Acceptance criteria

  • All 7 PRs land, each green on CI.
  • Original AutoResearchRemote.cpp deleted in PR 7.
  • Every new AutoResearchRemote*.cpp < 1,000 LOC (or < 1,200 with an explicit justification).
  • No RPC method lost or renamed.
  • No new .ino files created (split only adds .cpp siblings).
  • Flash size on esp32s3 does not regress (cross-family bind calls should inline; verify with bash bloat esp32s3).

Notes

  • This is the dominant compile-time hog: 171 kB TU = ~5-12 s cold compile on ESP32 toolchain. After split, each family file recompiles independently for that-family-only edits — 5–8x faster edit cycle for the file under active edit.
  • runSingleTestImpl() is itself 800+ lines (311–1136) — if Registry.cpp ends up over 1,000 LOC after extraction, split it further with runSingleTestImpl() moved to its own helper file.
  • Family file naming pattern: AutoResearchRemote<Family>.cpp matches the existing AutoResearchRemote.cpp convention.

Activity

  1. added
    type: feature
    priority: medium
    area: examples
    on Jun 16, 2026
  2. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Deferring #3132 — file has evolved beyond original plan

    The original sub-issue plan was written when examples/AutoResearch/AutoResearchRemote.cpp was 4,017 LOC with a specific structure. The file has since grown to 3,960 LOC with significant additions (animartrixPerlinBench, wave8ExpandBenchmark, parlioEncodeBenchmark, startOta, stopOta, startBle, stopBle, decodeFile, and others — multiple new RPC bindings since the plan was authored).

    Why this can't ship safely in the current /clud-fix run

    1. Architectural blocker remains. Sub-issue body explicitly notes: "Needs maintainer call on split mechanism (free-function helpers vs .cpp.hpp aggregator) before PR 1." Picking the wrong mechanism propagates through 6-7 PRs and is expensive to undo.

    2. No automated host-side validation. AutoResearch tests require real hardware (bash autoresearch --parlio etc.). Host bash compile only checks compilation, not behavior. The bundled split would touch the RPC dispatch logic for ~30+ RPC methods — high blast radius without a safety net.

    3. File-structure drift. The new RPC bindings (decodeFile, OTA, BLE) introduce dependencies on H264, MP4 parsing, BLE state, etc. that need to be partitioned correctly across the family files. Original plan didn't account for these.

    Recommended re-plan

    When the maintainer (@zackees) is ready to decide split style, a fresh sub-issue should be filed with:

    • Updated section boundaries reflecting current AutoResearchRemote.cpp content
    • Explicit decision on Option A (free-function helpers) vs Option B (.cpp.hpp aggregator)
    • A hardware validation plan (run bash autoresearch --parlio --simd on an attached device after each PR in the stack)

    Status

    Sub-issue deferred. Original meta tracking issue #3127 has its other two sub-issues (#3130 fixed_point split, #3131 string split) successfully completed with 16 PRs merged to master.

  3. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Closing as deferred per the comment above. The AutoResearchRemote.cpp split needs a fresh sub-issue when the maintainer is ready to make the architectural call on split mechanism. Original meta #3127 successfully closed its two automated-testable sub-issues (#3130, #3131) via 16 merged PRs.

  4. moved this from Triage to Done in FastLED Trackeron Jun 16, 2026
  5. moved this from Done to Triage in FastLED Trackeron Jun 16, 2026
  6. added a commit that references this issue on Jun 16, 2026
    ec94e4d
  7. moved this from Triage to Done in FastLED Trackeron Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: examplespriority: mediumtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions