Repository navigation
Description
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:
- PR 1 (foundation): Create
AutoResearchRemoteFamilies.hwith forward declarations forbind*Methodsfamily. CreateAutoResearchRemoteCore.cppwith helpers + ctor/dtor +tick()+registerAllMethods()glue + shellregisterFunctions(). The shell temporarily still calls the original monolithicregisterFunctions()body inlined for backwards compatibility. PR is small (just the forward-decl scaffolding); CI should be green. - PR 2: Extract
AutoResearchRemoteRegistry.cpp(lines 311–1376). MoverunSingleTestImpl()and simple-RPC binds. Replace the moved content in the original withbindRegistryMethods()call in the Core shell. CI green. - PR 3: Extract
AutoResearchRemoteParallel.cpp(lines 1377–1963). - PR 4: Extract
AutoResearchRemoteGpio.cpp(lines 1964–2487). - PR 5: Extract
AutoResearchRemoteSimd.cpp(lines 2488–2844). - PR 6: Extract
AutoResearchRemoteAsync.cpp(lines 2845–3162). - PR 7: Extract
AutoResearchRemoteCoroutines.cpp(lines 3163–3919); delete the now-empty originalAutoResearchRemote.cpp.
PR 7 carries Closes #<this-issue>.
Validation per PR
bash compile uno --examples AutoResearchsucceeds (host compile only — no upload needed for split-correctness).bash compile wasm --examples AutoResearchsucceeds.bash compile esp32s3 --examples AutoResearchsucceeds (the RPC machinery is most exercised on ESP32 — flash budget matters here).bash autoresearch --parliosmoke 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.cppdeleted 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
.inofiles created (split only adds.cppsiblings). - Flash size on
esp32s3does not regress (cross-family bind calls should inline; verify withbash 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) — ifRegistry.cppends up over 1,000 LOC after extraction, split it further withrunSingleTestImpl()moved to its own helper file.- Family file naming pattern:
AutoResearchRemote<Family>.cppmatches the existingAutoResearchRemote.cppconvention.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 16, 2026
Deferring #3132 — file has evolved beyond original plan
The original sub-issue plan was written when
examples/AutoResearch/AutoResearchRemote.cppwas 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
Architectural blocker remains. Sub-issue body explicitly notes: "Needs maintainer call on split mechanism (free-function helpers vs
.cpp.hppaggregator) before PR 1." Picking the wrong mechanism propagates through 6-7 PRs and is expensive to undo.No automated host-side validation. AutoResearch tests require real hardware (
bash autoresearch --parlioetc.). Hostbash compileonly checks compilation, not behavior. The bundled split would touch the RPC dispatch logic for ~30+ RPC methods — high blast radius without a safety net.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:
AutoResearchRemote.cppcontent.cpp.hppaggregator)bash autoresearch --parlio --simdon 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.
zackees commentedon Jun 16, 2026
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.
refactor(examples): split AutoResearchRemote.cpp into 10 files all un…