Skip to content

W0: golden protocol transcripts - #183

Merged
nofuturekid merged 4 commits into
rebuildfrom
fix/175-w0-4-transcripts
Nov 13, 2026
Merged

nofuturekid merged 4 commits into
rebuildfrom
fix/175-w0-4-transcripts

Conversation

@nofuturekid

Copy link
Copy Markdown
Collaborator

Fixes #175

Stacked on #179 (branch fix/178-w0-1-proto-types): this PR's own commit is bfdc44e; the diff against #179 is only that commit. Merge #179 first.

What changed

Task 4 of the W0 plan, as written, no adaptations to the real tree were needed (all four files are new, nothing else is touched):

  • crates/obsbot-proto/tests/golden/session.jsonl: hello, a write with its pending state, a get, an action, a live-topic change, and requests for an unsupported device (> client lines, < daemon lines, # comments).
  • crates/obsbot-proto/tests/golden/errors.jsonl: one reply per error code, in the order of 4.1.
  • crates/obsbot-proto/tests/golden/hotplug.jsonl: plug, unplug, port: entry and the identity hand-over (devices with replaced_by, devices without the old entry, then state).
  • crates/obsbot-proto/tests/transcripts.rs: 6 tests.

The example camera is sn:EXAMPLE0000001 (model example, product fa01), the unsupported device is port:3-2.4 (product fa02). No golden file names another real product id; a test guards this.

No byte sent to a camera, no device access, no version change, no CHANGELOG line (tests only).

Verification

  • Before the golden files existed: cargo test -p obsbot-proto --test transcripts gave 3 passed, 3 failed (the_three_transcripts_exist, the_error_transcript_holds_every_error_code, the_hand_over_is_three_events_in_order).
  • With the files: test result: ok. 6 passed.
  • Mutations (each restored afterwards), each made exactly the expected test fail:
    • removed the busy line from errors.jsonl: the_error_transcript_holds_every_error_code
    • lowered a state rev in session.jsonl: revs_and_device_lists_follow_the_ordering_rules ("rev of sn:EXAMPLE0000001 went from 5 to 4")
    • state event for a device no list holds in hotplug.jsonl: revs_and_device_lists_follow_the_ordering_rules
    • removed replaced_by from hotplug.jsonl: the_hand_over_is_three_events_in_order
    • product id fa02 changed to 0001 in session.jsonl: golden_files_name_no_other_real_product_id
    • extra space in one reply line of session.jsonl: every_transcript_line_round_trips_byte_equal ("not byte-equal")
  • Gate: cargo fmt --check clean; cargo clippy --all-targets --locked -- -D warnings clean; cargo test --locked all green (workspace: 171 + 1 + 10 + 6 + 4 + 25 + 2 tests).

🤖 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 and others added 2 commits November 13, 2026 18:18
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>
…nd hand-over

Adds tests/golden/session.jsonl, errors.jsonl and hotplug.jsonl ("> " client
lines, "< " daemon lines, "#" comments) and tests/transcripts.rs. The test
round-trips every line byte for byte, checks that errors.jsonl holds the 12
error codes in the order of 4.1, that revs only go up per entry and a state
event names a listed device, that the hand-over is devices with replaced_by,
devices without the old entry, then state, and that no golden file names a
product id other than fef9 or the synthetic fa0x ids.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nofuturekid
nofuturekid force-pushed the fix/175-w0-4-transcripts branch from bfdc44e to 9be99f9 Compare November 13, 2026 17:18
@nofuturekid
nofuturekid merged commit 9be99f9 into rebuild Nov 13, 2026
21 checks passed
@nofuturekid
nofuturekid deleted the fix/175-w0-4-transcripts 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