Skip to content

feat(io-board-interface): CPU->MCU command-gate reference oracle + vectors - #70

Merged
makers-pet merged 1 commit into
makerspet:mainfrom
smailzhu:feat/command-gate-oracle
Sep 28, 2026
Merged

makers-pet merged 1 commit into
makerspet:mainfrom
smailzhu:feat/command-gate-oracle

Conversation

@smailzhu

Copy link
Copy Markdown
Contributor

What

A host-side reference oracle for the MCU ingress command gate, in a new
contributor folder contributions/io-board-interface/smailzhu/.

validate_command(message_type, version, payload) restates the firmware gate's
accept/reject decision in Python, backed by a language-neutral accept/reject
vector corpus.

Why

The firmware's gate rules (oomwoo_cpu_ingress_validate_frame) and the written
contract can drift silently. This makes the gate decisions explicit, versioned,
and testable — and the corpus is language-neutral so the firmware repo can later
run the same cases against the C gate.

Contents

  • tools/oomwoo_command_gate.py — validate_command + GateResult
  • conformance/command_gate_vectors_v1.json — 57 accept/reject vectors
  • conformance/generate_gate_vectors.py — regenerates; --check fails if stale
  • tests/test_command_gate.py — oracle-vs-corpus, schema, coverage, drift guard
  • README.md

Rules (mirror firmware)

Precedence: version → known type → direction → payload length → field values.
Reason codes: OK, BAD_VERSION, UNKNOWN_TYPE, WRONG_DIRECTION, WRONG_PAYLOAD_LENGTH, VALUE_OUT_OF_RANGE.

Design

  • Decoupled. Message structure (id, direction, struct_format) restated from
    protocol_v1.json; nothing imports another contributor's codec at runtime. A
    test drift-checks the message set + struct formats against the manifest.
  • No circular fixtures. Expected outcomes are authored by hand from the
    firmware rules — never computed by validate_command.
  • Scope. Decoded-frame command gate only. Not framing/CRC (that's the
    StreamDecoder), not the safety gate itself — a reference oracle.

CI

Adds two steps to the existing python job: generate_gate_vectors.py --check
and unittest discover over the new tests. Stdlib only, no new dependency.

Testing

6 tests pass locally (~0.04s); existing io-board-interface suite still green.
Verified green on fork CI.

Proposed follow-up

A consumer in makerspet/oomwoo-firmware that runs this same JSON against
oomwoo_cpu_ingress_validate_frame and asserts the C result matches each
vector's reason. That is what enforces cross-repo agreement; this PR ships the
oracle and corpus that make it possible.

…ctors

Add a host-side reference oracle for the MCU ingress command gate under a new
contributor folder (contributions/io-board-interface/smailzhu/):

- oomwoo_command_gate.py: validate_command() restating the firmware gate rules
  (version -> known type -> direction -> payload length -> field values), with
  the applicable oomwoo_cpu_ingress_result_t reason codes.
- command_gate_vectors_v1.json: 57 accept/reject vectors with expected outcomes
  authored by hand from the firmware rules (not computed by the oracle), so the
  test checks the oracle against independent fixtures.
- generate_gate_vectors.py --check keeps the corpus fresh.
- test_command_gate.py: oracle-vs-corpus, schema, coverage, and a drift guard
  that requires the message set + struct formats to match the contract manifest.

Decoupled: structure restated from protocol_v1.json; nothing imports another
contributor's codec at runtime. Scope is the decoded-frame command gate only
(no framing/CRC). A firmware consumer of the same JSON is proposed as follow-up.

Wired into the host CI python job (generate --check + unittest discover).
@makers-pet
makers-pet merged commit bbf953b into makerspet:main Sep 28, 2026
2 checks passed
@makers-pet

Copy link
Copy Markdown
Collaborator

Thank you!

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.

2 participants