Repository navigation
W0: validator for set, do and get, and the description self-check - #181
Merged
Merged
Conversation
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>
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.
Fixes #173
Stacked on #179 (branch
fix/178-w0-1-proto-types); the diff on top of it is two files. The base staysrebuild.What changed
Task 2 of
docs/superpowers/plans/2026-11-13-obsbot4linux-w0-contracts.md, exactly as written:crates/obsbot-proto/src/validate.rsreplaces the stub:leaves,validate_set,validate_do,validate_get,check_value(Fit::Write,Fit::State) andcheck_description. One refusal order for the whole request:invalid,unsupported,out_of_range,conflict,asleep, then path order.Refusalis 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.set_table,asleep_ignored_is_refused_only_while_asleep); Review Focus rows: float noise on a stepped value accepted, a range as an arrayinvalid, malformed pathsunsupported, a component path ingetunsupported;check_description_finds_broken_descriptionschecks eight listed flaws.cargo fmt --checkclean;cargo clippy --all-targets --locked -- -D warningsclean;cargo test --locked(workspace): all green, 0 failed, 0 ignored.1e-6set to0:set_tablefails on row "float noise on a stepped value";OutOfRangeranked afterConflict:set_tablefails on "out_of_range wins over conflict";validate_getalso accepts a component of a leaf:get_accepts_leaves_groups_and_daemon_fields_onlyfails;do_tablefails on "destructive with confirm false";requirescheck removed invalidate_set:set_tableandasleep_ignored_is_refused_only_while_asleepfail.🤖 Generated with Claude Code