Skip to content

test(remote): wire-format echo bind canary (FastLED#3300 / #3325) - #3337

Closed
zackees wants to merge 1 commit into
masterfrom
test/3300-echo-bind-canary
Closed

zackees wants to merge 1 commit into
masterfrom
test/3300-echo-bind-canary

Conversation

@zackees

@zackees zackees commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a host unit test that mirrors AutoResearchLowMemory.h:158's exact bind pattern (remote.bind(\"echo\", [](int v) -> int { return v; })) and drives the full pull → handler → processRpc → mRpc.handle → sink → push pipeline using the literal JSON-RPC wire bytes the device receives.

The test PASSES on master. That is itself the finding: the bug seen on LPC845-BRK and ESP32-C6 (`{"error":{"code":-32601,"message":"Method not found: echo"}}`) does NOT reproduce in the host bind+dispatch chain. The regression must live in one of three places host doesn't model:

  1. Device-side serial source / parse — createSerialRequestSource() uses real serial I/O. If the line accumulator hands the dispatcher a request whose `method` field differs from `"echo"` (extra char, BOM, surrogate, etc.), lookup fails. Host bypasses this.
  2. Static-init / ODR linkage — static fl::Remote remote(...) inside an inline function in AutoResearchLowMemory.h, with g_low_memory_remote in an anonymous namespace per-TU. If the setup() and loop() functions resolve to different TUs' g_low_memory_remote, bind() and dispatch could touch different Remote instances. Host uses a directly-constructed Remote.
  3. Build-define divergence — host has -DSKETCH_HAS_LARGE_MEMORY=1 so FL_PLATFORM_HAS_LARGE_MEMORY=1. On LPC845-BRK the same flag is also 1, but only because FL_IS_ARM_LPC_845 mis-detects (ArduinoCore-LPC8xx's variant.h defines VARIANT_BOARD_LPC845BRK but not the LPC845* macros our is_lpc.h keys off of — see [#3300 bisect] Find the commit that broke LPC845-BRK JSON-RPC echo — bisect Arduino-core LPC8xx #3325 update). The TypedInvoker path then runs on a 16 KB part. If fl::make_shared<TypedInvoker<int(int)>>(fn) returns null shared_ptr under OOM and mRegistry[key] = fl::move(entry) silently no-ops on a full vector_inlined<Entry, 8>, lookup misses. Not yet proven.

Why land this anyway

Even though it currently passes, the canary anchors the bind+dispatch invariant against future regressions. The next time someone refactors RuntimeRpcBinding / TypedInvoker (e.g. another #3246-style change) and accidentally breaks the registration key, this test fails immediately instead of being discovered weeks later via a silent device.

The test is tiny (~50 LOC), runs in 0.03s, and uses zero new infrastructure (reuses the existing `TestIO` fixture + `makeRequest` helper).

Test plan

  • `bash test remote` — passes (the new case + 100+ existing remote tests, total ~0.22s test execution).
  • CI cross-platform.

Refs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added regression test for JSON-RPC echo functionality to validate proper request parsing and response handling, ensuring method resolution reliability.

Mirrors AutoResearchLowMemory.h:158 — `remote.bind("echo", [](int v) -> int
{ return v; })` — and the exact JSON-RPC wire request that LPC845-BRK and
ESP32-C6 both fail to dispatch on master. The test:

  1. Constructs an `fl::Remote` with a TestIO request source / sink.
  2. Binds `"echo"` with the exact signature AutoResearch uses.
  3. Parses the literal device wire bytes
       {"jsonrpc":"2.0","id":1,"method":"echo","params":[4242]}
     via `fl::json::parse()` (same path createSerialRequestSource takes).
  4. Drives `remote.update(0)` end-to-end (pull -> handler -> processRpc
     -> mRpc.handle -> response sink -> push).
  5. Asserts the response is `{"result": 4242}`, not the
     `{"error":{"code":-32601,"message":"Method not found: echo"}}` the
     device emits.

On master this test PASSES — which is itself a finding: the bug
isolated in #3300 (echo unbound at runtime on real device) does NOT
reproduce in the host bind+dispatch chain. Either the regression lives
on the device-side serial source / parse / static-init path that host
doesn't model, or in a build-define divergence between
`FL_PLATFORM_HAS_LARGE_MEMORY=1` on LPC8xx (mis-detected — see
update on #3325) vs the same flag on host. Either way, having this
canary in the test suite means any future regression in the core
bind+dispatch path will fail loud here first instead of being
discovered weeks later via a silent device.

Refs:
- #3300 — LPC845-BRK bring-up echo silence (root issue).
- #3325 — ACLPC bisection plan (re-scoped after this test
  showed the bug is FastLED-side, not Arduino-core; see comment
  #3325 (comment)).
- #3336 — agents/hooks forbid powershell SerialPort (the
  methodology bug that masked the real symptom for two sessions).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 20, 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: a848808b-777d-4651-b282-093192ca54da

📥 Commits

Reviewing files that changed from the base of the PR and between 5d18212 and 3befeee.

📒 Files selected for processing (1)
  • tests/fl/remote/remote.cpp

📝 Walkthrough

Walkthrough

A new FL_TEST_CASE is added to tests/fl/remote/remote.cpp that reproduces issue #3300. It registers an echo(int)->int RPC method, parses a hardcoded JSON-RPC wire request with param 4242 and id=1, enqueues it, runs remote.update(0), and asserts the response contains result=4242 with no error field.

Changes

JSON-RPC echo regression test

Layer / File(s) Summary
AutoResearch echo regression test case
tests/fl/remote/remote.cpp
Adds FL_TEST_CASE that binds echo(int)->int, parses a hardcoded wire JSON-RPC request (method: "echo", params: [4242], id: 1), enqueues it, drives remote.update(0), and asserts result=4242 with no error field present in the response.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • FastLED/FastLED#3258: Directly related — implements RuntimeRpcBinding decode/dispatch changes for non-template RPC binding, which is the exact code path this new regression test exercises and validates.

Poem

🐇 A wire request arrived with 4242,
The echo method stood ready and spry.
No error in sight, the result rang true,
A regression test born to keep bugs in view.
Hop hop, the RPC pipeline holds!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a wire-format echo bind canary test for FastLED issue #3300, which matches the test addition in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 test/3300-echo-bind-canary

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.

@zackees

zackees commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

Closing as a completed investigation rather than a change to merge.

This PR's own finding is that the test passes on master — the {"error":{"code":-32601,"message":"Method not found: echo"}} failure seen on LPC845-BRK and ESP32-C6 does not reproduce in the host bind+dispatch chain. That is a useful negative result (it rules out the host-modelled pull → handler → processRpc → mRpc.handle → sink → push path and points at the three device-side layers host doesn't model), but it is not a fix, and the branch has been red since 2026-06-20.

Merging a canary that passes for the wrong reason would add CI surface without protecting anything. The diagnostic value lives in the writeup, which stays on this closed PR and is linked from #3300 / #3325.

If the wire-format bug resurfaces, reopen and rebase — the test file is a good starting point once there's a device-side reproduction to anchor it.

@zackees zackees closed this Jul 27, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 27, 2026
@zackees
zackees deleted the test/3300-echo-bind-canary branch November 17, 2026 07:12
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.

1 participant