Repository navigation
W0: generate schema/protocol-2.json with a stale test - #180
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>
obsbot_proto::schema::protocol_schema builds the draft 2020-12 schema (oneOf Request and ServerMessage, $defs including Description) from the protocol types; schema_text is the file content. tests/schema.rs fails when schema/protocol-2.json is missing or differs, and rewrites it when OBSBOT_REGENERATE is set. A second test checks that $defs holds every envelope, the description types and all 12 error codes. Fixes #174 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
nofuturekid
force-pushed
the
fix/174-w0-3-schema
branch
from
November 13, 2026 17:18
40e31f4 to
272ac35
Compare
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 #174
Stacked on #179 (W0 task 1, protocol types): the diff against that branch is one commit. Land #179 first.
W0 task 3 of docs/superpowers/plans/2026-11-13-obsbot4linux-w0-contracts.md, put in place as the plan gives it.
What changed
crates/obsbot-proto/src/schema.rs:protocol_schema()(draft 2020-12,oneOfRequest and ServerMessage,$defsincluding Description) andschema_text()(pretty JSON, final newline), replacing the stub.crates/obsbot-proto/tests/schema.rs:schema_file_is_currentcompares the file and rewrites it whenOBSBOT_REGENERATEis set;schema_names_every_envelope_and_the_description_formatchecks$defsfor Request, Reply, Event, ErrorBody, ErrorCode, Device, Description, Setting, Action, State and that ErrorCode holds all 12 codes.schema/protocol-2.json: generated (1001 lines).No CHANGELOG line: nothing a user sees. No camera I/O, no byte sent to a device.
Adaptations to the plan
None needed. The stub
schema.rsand theschemarsdependency from task 1 were as the plan expects. The plan's known trap (mkdir -p schemabefore the first regenerate) was applied. Step 2 (expected failure) applied as written: with the task 1 stub in place the test file does not compile (E0432, unresolved importsprotocol_schemaandschema_text).Verification
cargo test -p obsbot-proto --test schema:2 passed.schema/protocol-2.json:schema_file_is_currentFAILED, the other passed;schema/protocol-2.jsondeleted:schema_file_is_currentFAILED;$defs: both tests FAILED.$defsof the generated file: Action, Description, Device, ErrorBody, ErrorCode, Event, Reply, Request, State and the rest of the plan's list;ErrorCodeenum lists exactly the 12 codes (protocol, invalid, unknown_device, unsupported, unsupported_device, out_of_range, conflict, unavailable, asleep, busy, camera, internal) plus the forward-compatible catch-all string.cargo fmt --checkclean,cargo clippy --all-targets --locked -- -D warningsclean,cargo test --lockedall green (whole workspace).