feat!: unify wire protocol (v2 envelope, error codes, protocol field)#26
Merged
Conversation
Implements spec/v2: every reply on both transports carries ok (HTTP GETs included); errors gain a stable code enum; getspec//api/spec returns protocol: 2 for exact-match gating (older clients fall back to major.minor); dump becomes transport-universal via GET /api/dump; read exposes the tag serial; serial dbbegin now requires size and dbdata acks with written. All reply shapes move into a new apicore layer: pure shape::* fillers over plain structs (host-compilable, the only place JSON keys exist) and device-side gatherers. A PlatformIO native test runs the real shape builders on the host, dumps every reply to spec/v2/fixtures/generated/, and CI validates them against the schemas — firmware/schema drift now fails the build in either direction. BREAKING CHANGE: wire replies are additive on the wire, but the contract now requires the ok envelope everywhere and code on every error; clients should gate on the new protocol field. Refs #18 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR2 of #18 — firmware implements the v2 contract from
spec/v2/. Breaking (contract commitment; the wire itself is additive, existing 1.x clients keep working).Protocol v2:
okon every reply, both transports — includingGET /api/spec,/api/status,/api/config(the v1 drift this issue exists to fix){ok, error, code}with the stable code enum fromspec/v2/schemas/commongetspec//api/specreturnprotocol: 2(exact-match gate; major.minor fallback recognizes 1.x)GET /api/dump(was serial-only);readgainsserial; serialdbbeginnow requiressize(was silently ignored);dbdataacks{ok, written}Single owner per reply shape —
apicore:shape::*— pure fillers over plain structs, no Arduino headers, the only place JSON keys exist (api_core.cpp)fill*— device-side gatherers (api_core_device.cpp)web_server.cpp/serial_proto.cppcollapse to thin shells with zero JSON keysDrift is machine-enforced:
[env:native]+firmware/test/test_contract/compile the real shape builders on the host, dump every reply (incl. all 9 error codes) tospec/v2/fixtures/generated/, and CI validates them with Ajv. Verified: renamingserial→srlin C++ turns CI red (must have required property 'serial'), restore turns it green.Verification
pio test -e native -d firmware→ 7/7 pass;validate.mjsgreen over 20 generated fixturespio run -d firmware→ SUCCESS (ESP32-C3 target)After merge / before release
spec/v2/fixtures/viacapture_fixtures.py --version v2(transport-glue proof; shape proof is already in CI)@spoolid/core) lands — 2.0.0 must tag coherent firmware+web+desktopPart of #18. Next: PR3 shared TS package + client refactors.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT