Repository navigation
Description
TL;DR
FastLED's autoresearch calls rpc.discover on the device to fetch its JSON-RPC schema, then validates expected methods against it via pydantic (currently breaks with 2 validation errors for RpcSchema: jsonrpc required, methods required — see bash autoresearch lpc845brk output in FastLED/FastLED#3339). The schema-validation logic is ad-hoc Python and lives only on the FastLED side.
This is a reusable component. Any other firmware project running fbuild that exposes a JSON-RPC surface would want the same "fetch + validate against expected" capability.
Why this matters
When a board firmware ships with a different schema shape than the test harness expects, today the failure is the cryptic pydantic error above — not "your firmware is missing the echo method." Centralizing the schema-validation logic in fbuild with a typed error surface produces actionable diagnostics.
Concrete output the FastLED LPC bring-up showed today:
🔍 Validating RPC commands against device schema...
[debug] Line 1: src/fl/remote/remote.cpp.hpp(151): INFO: Stored request ID for rpc.discover (id=
⚠️ Schema validation skipped: Failed to fetch RPC schema: 2 validation errors for RpcSchema
jsonrpc
Field required [type=missing, ...]
methods
Field required [type=missing, ...]
The user sees "validation failed" but not "what's missing." A first-class validator would say:
⚠️ Device schema mismatch:
Expected method 'echo' bound — NOT FOUND in device schema.
Expected method 'pinToggleRx' bound — present (signature: int(int, int, int, int) → string).
Device returned 7 methods total; harness expects 2.
Proposed shape
A new fbuild-rpc-validate crate (or Python module if fbuild prefers — TBD by maintainer) with:
pub struct RpcSchema {
pub jsonrpc: String,
pub methods: Vec<MethodDecl>,
}
pub struct MethodDecl {
pub name: String,
pub params: Vec<ParamType>,
pub returns: ReturnType,
}
pub fn fetch_schema(port: &mut dyn SerialPort) -> Result<RpcSchema>;
pub fn validate_against_expected(
actual: &RpcSchema,
expected_methods: &[&str],
) -> ValidationReport;Where ValidationReport carries the per-method status and renders the diagnostic above.
Acceptance criteria
-
fbuild-rpc-validatecrate (orfbuild.rpc_validatePython module). -
fetch_schema()round-trips therpc.discoverJSON-RPC call. -
validate_against_expected()produces a structured report with per-method status. - FastLED's autoresearch migrated to consume the new component.
- Unit tests cover: missing methods, extra methods, signature mismatch.
Out of scope
- Generating the expected-method list from FastLED's
examples/AutoResearch/AutoResearchLowMemory.hbind sites. The harness ships its own expected-list today; that's fine. - Implementing the
rpc.discoverdevice-side — that's the FastLED firmware's job; this issue is only the host validator.
Refs
- FastLED/fbuild#686 —
serial_probe+BOARD_FINGERPRINTS. Reuses the same connection primitives. - FastLED/fbuild#688 —
BootModeClassifier. Schema mismatch is a kind of "device is alive but in the wrong state" signal. - FastLED/FastLED#3339 — exhibits the broken validation behavior.
Filed from the audit fan-out on FastLED/FastLED#3339.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
feat(serial): rpc_validate — typed JSON-RPC schema validator (#698) (#…