Skip to content

feat(spec): versioned wire-contract spec (v1 as-is + v2 target)#25

Merged
mateusdemboski merged 2 commits into
mainfrom
feat/issue-18-spec
Jul 6, 2026
Merged

feat(spec): versioned wire-contract spec (v1 as-is + v2 target)#25
mateusdemboski merged 2 commits into
mainfrom
feat/issue-18-spec

Conversation

@mateusdemboski

Copy link
Copy Markdown
Collaborator

Summary

PR1 of #18 — the wire contract becomes a first-class, versioned artifact. No behavior change.

  • spec/v1/ — frozen snapshot of what 1.x firmware actually speaks: 17 JSON Schemas (2020-12), PROTOCOL.md with the transport-divergence table (HTTP GETs lack ok, dump/otaabort serial-only, dbbegin size ignored, DB POST always acks), fixtures authored from web_server.cpp/serial_proto.cpp source. Errata-only after merge.
  • spec/v2/ — the unified target contract: ok envelope on every reply, {ok,error,code} errors with a stable code enum, protocol: 2 handshake, GET /api/dump, read gains serial, dbdata acks written. Implemented by PR2 (feat!:).
  • spec/ts/ — Ajv validator (pnpm --dir spec/ts validate): schema-compile lint + every fixture validated + repo-root material_database.json checked. Verified red on bad fixture and broken $ref.
  • spec/scripts/capture_fixtures.py — re-captures fixtures from a live device (HTTP + serial), so the spec is pinned to reality, not folklore.
  • CI — new spec job; spec/** added to web/desktop filters; Node 22 → 26 everywhere; corepack enablepnpm/action-setup@v4 (corepack unbundled since Node 25).
  • Deleted stale .gitignore entries from the abandoned tools/gen_spec.py attempt.

Before merge

  • Re-capture v1 fixtures from a real 1.x device: python spec/scripts/capture_fixtures.py --version v1 --host <ip> --port <serial> (current fixtures are source-derived; capture is the machine proof)
  • pnpm --dir spec/ts validate green after capture

Verification

  • node spec/ts/scripts/validate.mjsspec OK: schemas compile, fixtures + material_database.json validate
  • Negative-tested: missing required field in fixture → FAIL exit 1; broken $ref → clean compile FAIL, no crash

Part of #18. Next: PR2 firmware v2 (api_core refactor + native contract test).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT

mateusdemboski and others added 2 commits July 6, 2026 19:10
Formalize the firmware wire contract as JSON Schema 2020-12 under spec/:
v1 pins current 1.x behavior verbatim (transport divergences documented,
frozen after merge), v2 defines the unified target contract (envelope on
every reply, stable error codes, protocol handshake field). Fixtures are
golden replies validated by Ajv in CI; spec/scripts/capture_fixtures.py
re-captures them from a live device. Bump CI to Node 26 and replace
corepack (unbundled since Node 25) with pnpm/action-setup.

Refs #18

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT
Replaces the source-derived v1 fixtures with actual 1.x firmware output
captured over HTTP (spoolid.local) and USB serial, per transport variant.
wifiSsid values are redacted; everything else is verbatim device output.

Refs #18

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT
@mateusdemboski

Copy link
Copy Markdown
Collaborator Author

v1 fixtures re-captured from a live device (HTTP via spoolid.local + USB serial): spec/status/config both transports, read ok + err-no-tag, dump (real tag: uid 1018EF5F). wifiSsid redacted. Write-path fixtures (write/configset/db/ota replies) stay source-derived — capture is read-only by design, no tag writes or flash ops. validate.mjs green. Both checklist items done.

@mateusdemboski mateusdemboski merged commit 7ed95b3 into main Jul 6, 2026
8 checks passed
@mateusdemboski mateusdemboski deleted the feat/issue-18-spec branch July 6, 2026 22:50
@mateusdemboski mateusdemboski restored the feat/issue-18-spec branch July 6, 2026 22:50
@mateusdemboski mateusdemboski deleted the feat/issue-18-spec branch July 6, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant