Skip to content

W0: validator for set, do and get, and the description self-check - #181

Merged
nofuturekid merged 2 commits into
rebuildfrom
fix/173-w0-2-validator
Nov 13, 2026
Merged

nofuturekid merged 2 commits into
rebuildfrom
fix/173-w0-2-validator

Conversation

@nofuturekid

Copy link
Copy Markdown
Collaborator

Fixes #173

Stacked on #179 (branch fix/178-w0-1-proto-types); the diff on top of it is two files. The base stays rebuild.

What changed

Task 2 of docs/superpowers/plans/2026-11-13-obsbot4linux-w0-contracts.md, exactly as written:

  • crates/obsbot-proto/src/validate.rs replaces the stub: leaves, validate_set, validate_do, validate_get, check_value (Fit::Write, Fit::State) and check_description. One refusal order for the whole request: invalid, unsupported, out_of_range, conflict, asleep, then path order. Refusal is kept as the stub had it.
  • crates/obsbot-proto/tests/validate.rs: 9 table tests.

No camera I/O, no change to anything that is sent to a camera. No CHANGELOG line (no user-visible change).

Adaptations to the plan

None. The plan's code was put in place unchanged; no path or edit of the plan differed from the real tree for this task. (Step 2, the compile failure of the test against the stub, was not run separately; the mutations below prove the tests can fail.)

Verification

  • cargo test -p obsbot-proto --test validate: 9 passed.
  • Acceptance rows: valid, wrong type, out of range, read-only, unknown path, path of another model, requires not met and met in the same patch, asleep ignored and unknown (set_table, asleep_ignored_is_refused_only_while_asleep); Review Focus rows: float noise on a stepped value accepted, a range as an array invalid, malformed paths unsupported, a component path in get unsupported; check_description_finds_broken_descriptions checks eight listed flaws.
  • Gate: cargo fmt --check clean; cargo clippy --all-targets --locked -- -D warnings clean; cargo test --locked (workspace): all green, 0 failed, 0 ignored.
  • Mutations (code broken, test run, code restored):
    • step tolerance 1e-6 set to 0: set_table fails on row "float noise on a stepped value";
    • OutOfRange ranked after Conflict: set_table fails on "out_of_range wins over conflict";
    • validate_get also accepts a component of a leaf: get_accepts_leaves_groups_and_daemon_fields_only fails;
    • destructive-confirm check removed: do_table fails on "destructive with confirm false";
    • requires check removed in validate_set: set_table and asleep_ignored_is_refused_only_while_asleep fail.

🤖 Generated with Claude Code

nofuturekid and others added 2 commits November 13, 2026 17:54
Adds the crate crates/obsbot-proto with the protocol 2 envelopes
(request, reply, event, error), the device and description types with
their builders, state and patch types with path helpers, the id and
value helpers, and stubs for client, validate (holding Refusal) and
schema. Maps are sorted, integral numbers are written without a
fraction, and public enums carry a catch-all variant so additive values
of a newer daemon still parse.

tests/types.rs round-trips every line of tests/golden/types.jsonl byte
for byte through its type.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…-check

validate_set, validate_do and validate_get check a request against a device
description and its state before anything reaches the camera. One refusal
order for the whole request: invalid, unsupported, out_of_range, conflict,
asleep, then path order. check_value covers Fit::Write and Fit::State;
check_description reports the flaws of an inconsistent description.

Fixes #173

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nofuturekid nofuturekid added the enhancement New feature or request label Nov 13, 2026
@nofuturekid
nofuturekid merged commit dd1c18d into rebuild Nov 13, 2026
21 checks passed
@nofuturekid
nofuturekid deleted the fix/173-w0-2-validator branch November 13, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant