Skip to content

W0: protocol 2 types in obsbot-proto - #179

Merged
nofuturekid merged 1 commit into
rebuildfrom
fix/178-w0-1-proto-types
Nov 13, 2026
Merged

nofuturekid merged 1 commit into
rebuildfrom
fix/178-w0-1-proto-types

Conversation

@nofuturekid

Copy link
Copy Markdown
Collaborator

Fixes #178

Task 1 of docs/superpowers/plans/2026-11-13-obsbot4linux-w0-contracts.md.

What changed

  • New crate crates/obsbot-proto (serde, serde_json, schemars): ids, values, description (types and builders), state (State, Patch, path helpers), message (Request with from_line, Reply, Event, ErrorBody, ErrorCode), and stubs for client, validate (holding Refusal) and schema.
  • Root Cargo.toml: member crates/obsbot-proto; workspace dependencies obsbot-proto and schemars = "1.2". Cargo.lock gains schemars and its dependencies.
  • tests/types.rs with tests/golden/types.jsonl: every golden line round-trips byte for byte through its type (24 type names).
  • Files are the plan's code, put in place unchanged. No camera I/O, no version change, no CHANGELOG line (no user-visible change).

Adaptations to the plan

  • Root Cargo.toml lists its members explicitly (no crates/* glob), so "crates/obsbot-proto" was added to members. serde and serde_json were already in [workspace.dependencies] in the plan's form. No other adaptation was needed.

Verification

  • Before the types existed: cargo test -p obsbot-proto --test types failed to compile (unresolved Verb, Support, ... ), as the plan expects.
  • cargo test -p obsbot-proto: 10 unit tests (ids 2, values 4, state 4) and 4 tests in tests/types.rs pass.
  • Whole workspace cargo test --locked: all pass (171 + 25 + 10 + 4 + 2 + 1 tests).
  • cargo fmt --check: clean. cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • Forward compatibility: unknown Support, SettingType, Unit, ErrorCode values and an unknown event type parse (additive_values_from_a_newer_daemon_still_parse).
  • Mutation checks (code broken, test seen to fail, code restored):
    • values::number no longer writes integral numbers as integers: integral_numbers_are_written_without_a_fraction and rounding_removes_float_noise fail.
    • catch-all Support::Other made #[serde(skip)] instead of #[serde(untagged)]: every_golden_line_round_trips_byte_equal and additive_values_from_a_newer_daemon_still_parse fail.

Contract note (spec 10.1): these types are the protocol 2 contract; later tasks and tracks build on them without changing them.

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>
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