Introducing a new way to review your PRs.

Read the announcement

aprilnea / openlogi

⚡️A native, local-first alternative to Logitech Options+, written in Rust 🦀 — remap buttons, DPI, and SmartShift over HID++. No account, no telemetry.

View on GitHub

25 documents · Updated Nov 23, 2026

docs / fixture-profiles-and-validation

Fixture profiles and validation

The fixture crate defines host-free, privacy-safe assets for repeatable device tests. A semantic profile describes the expected device shape, optional HID cassettes describe protocol evidence, and a manifest joins them through stable synthetic identities. The crate checks that these claims agree before tools or device tests use the fixture.

The wider fixture flow is described in Fixture workflows. Device behavior that consumes these assets is described in Device domain runtime, discovery is described in HID device discovery, and the user-facing verification path is described in Command-line interface.

Fixture asset model

The fixture model separates expected device state from raw protocol evidence. This lets semantic tests use a profile without transport data while replay tests add cassettes only for operations that need fixed request and response exchanges.

Semantic profile

The semantic profile is a host-independent description of one synthetic device set. It states the receiver-backed inventory, direct devices, standalone raw-HID devices, route capabilities, and setting behavior. A profile therefore gives tests a stable device view before any transport is opened.

Each route has a complete setting contract. A setting can be unsupported, supported with an initial value, or supported without a current value. The contract covers pointer, wheel, backlight, Fn-lock, report rate, Easy-Switch, press force, Disable Keys, lighting, and standalone-light behavior. Backlight state can also preserve its duration control. Newer setting fields can default to unsupported so older schema-v1 profiles remain readable. Validation checks that these claims agree with the inventory and that any supplied values are usable. Profile data uses one supported schema version and rejects unknown fields so a misspelled or unrecognized claim cannot silently change the device model.

References: crates/…/schema.rs• L49-65 crates/…/schema.rs• L122-216 crates/…/schema.rs• L234-255 crates/…/schema.rs• L647-749

HID cassette

An HidCassette is a named set of request and response exchanges for one logical replay channel. It preserves the report shape and request match rule needed to replay a read-only operation. A matched write may have no response in the asset schema, but complete fixture verification still requires enough evidence to inspect the case safely.

The cassette model supports exact matching for HID++ 1.0 traffic and a narrow HID++ 2.0 match that ignores only the software-ID nibble. It also checks report width and request-response correlation before a cassette can support a complete fixture. Cassette fields reject unknown schema members, and reports use a fixed lowercase hexadecimal form when stored in an asset.

References: crates/…/schema.rs• L771-816 crates/…/schema.rs• L845-882 crates/…/schema.rs• L884-936 crates/…/schema.rs• L962-997

Fixture manifest

The manifest is the contract that joins one profile to its optional cassettes. It records a stable fixture ID, the profile ID, named cases, and an identity ledger. The ledger names receiver and device principals, gives each principal typed synthetic identities, and records the exact profile or cassette locations where those identities must occur.

Each case states its receiver or device relationship and replay channel. This keeps traffic for one receiver slot or direct device separate from every other principal. A profile-only fixture is valid when it has no cases.

References: crates/…/manifest.rs• L12-30 crates/…/manifest.rs• L33-58 crates/…/manifest.rs• L61-69 crates/…/manifest.rs• L191-235

Synthetic identity model

Synthetic identities replace private hardware values with stable values that preserve the shape and links needed by tests. The same logical principal keeps one value across its profile fields and cassette exchanges, while typed identity forms prevent one kind of identity from being mistaken for another.

Identity representations

The identity policy covers receiver UIDs, receiver serials, device unit IDs, device serials, and raw-HID profile identities. Each form has a fixed tag or format and a nonzero ordinal from 1 through 255. A Unifying receiver has two linked forms: a binary serial used in protocol traffic and an uppercase hexadecimal route value used in the profile.

The manifest may place one representation in more than one asset location, but one value cannot identify two principals. This makes identity links testable without retaining real hardware data or relying on a separate sanitization claim.

References: crates/…/identity.rs• L13-31 crates/…/identity.rs• L33-69 crates/…/identity.rs• L137-184 crates/…/manifest.rs• L146-189 crates/…/manifest.rs• L343-386

Protocol identity evidence

The protocol identity extractor reads supported read-only HID++ exchanges and locates identity fields in their responses. It learns feature mapping in exchange order so later device-information reads remain tied to the correct device. It also identifies whether a request addresses a receiver or a selected device route, which lets manifest checks compare protocol traffic with the declared principal.

The extractor fails closed when it cannot prove the traffic. Pairing traffic, writes, unknown identity features, malformed reports, broken request-response links, ambiguous feature mappings, and noncanonical values do not become fixture evidence. For unmatched reports on a shared HID node, it only claims a report could answer a request when the correlation rules allow that conclusion. This boundary keeps a cassette replayable and safe to share.

The protocol tests cover both identity classification and exclusion rules. They show that repeated device identity reads remain stable, receiver selectors do not become direct-device targets, and an unsupported identity function is rejected instead of being treated as harmless evidence.

References: crates/…/protocol_identity.rs• L65-129 crates/…/protocol_identity.rs• L131-209 crates/…/protocol_identity.rs• L257-320 crates/…/protocol_identity.rs• L377-420 crates/…/protocol_identity_tests.rs• L80-125 crates/…/protocol_identity_tests.rs• L209-250

Fixture generation model

Fixture generation starts with assets that are already privacy-safe. The profile and cassette contents remain the source of truth. Generation builds the manifest from them and then runs the same cross-asset checks required of a published fixture.

Asset assembly

FixtureManifest::from_assets validates the profile, creates principals from its routes and identities, and binds each cassette name to the profile route that it exercises. It then records the identity locations found in the profile and cassettes. A binding is valid only when each cassette has one profile route and that route resolves to one identity-bearing device principal.

This process preserves the difference between receiver-backed, direct, and raw-HID routes. It rejects a cassette when its identities are absent from the profile or when its request targets another device or receiver slot.

The asset flow moves from semantic claims and optional protocol evidence to a bound identity ledger and a verified fixture.

flowchart LR
    Profile[Semantic device profile] --> Validate[Schema validation]
    Cassette[Optional HID cassette set] --> Validate
    Validate --> Bind[Route and case binding]
    Bind --> Ledger[Identity ledger and exact occurrences]
    Ledger --> Verify[Cross-asset verification]
    Verify --> Fixture[Repeatable fixture]

References: crates/…/generate.rs• L16-50 crates/…/generate.rs• L53-142 crates/…/generate.rs• L216-249 crates/…/verify.rs• L26-64

Canonical synthetic fixture

The canonical fixture is a profile-only specimen embedded by the fixture crate. It covers a Bolt receiver with online and offline paired slots, a direct HID++ device, and a standalone raw-HID light. Its setting claims include both supported and unsupported controls so semantic mocks and projection tests share one stable device shape.

The canonical manifest has no cassette cases because it does not claim captured traffic. It still records every profile identity and its exact locations. This makes it a stable baseline for tests that need device topology, route identity, capabilities, and setting behavior without hardware or private capture data.

References: crates/…/lib.rs• L24-36 crates/…/profile.json• L1-5 crates/…/profile.json• L95-177 crates/…/profile.json• L179-315 crates/…/manifest.json• L1-6 crates/…/manifest.json• L113-161

Fixture verification model

Verification treats a fixture as a set of claims that must agree. It checks asset schemas first, then profile and case relationships, then privacy and identity counts, and finally cassette protocol evidence. A detailed result keeps these concerns separate so a failure identifies the kind of claim that broke.

Verification stages

The verification stages provide a simple model for diagnosing a rejected fixture:

  1. Schema checks versions, required values, unknown fields, route uniqueness, capability consistency, and report framing.
  2. Relationship checks the profile ID, case names, channels, route bindings, request targets, and principal ownership.
  3. Privacy checks canonical synthetic values and compares every declared identity occurrence with the values found in the profile and cassettes.
  4. Replay checks supported protocol exchanges, request matching, response links, and complete cassette evidence.

The verifier counts occurrences by principal, identity kind, and typed location. A missing value, extra value, or wrong route fails verification even when the report shape is valid.

References: crates/…/verify.rs• L73-115 crates/…/verify.rs• L122-160 crates/…/verify.rs• L493-581 crates/…/verify.rs• L717-741

On-disk fixture verification

The optional fs feature provides the strict filesystem boundary for fixture directories. It requires manifest.json and profile.json. A cases directory is needed only when the manifest declares cases. The directory name must match the manifest ID, and unexpected files, missing case files, symlinks, or mismatched cassette names fail before semantic verification. The CLI and corpus tests use this shared loader instead of defining their own directory rules.

openlogi fixture verify <DIRECTORY> reports schema, privacy, relationship, and replay results. A successful result proves fixture consistency and safe synthetic identity use. It does not prove that the modeled device is physically correct or that a live device behaves like the profile.

References: crates/…/fs.rs• L55-113 crates/…/fs.rs• L134-173 crates/…/verify.rs• L12-39 crates/…/verify.rs• L42-75 crates/…/verify.rs• L78-167 crates/…/verify.rs• L170-187

Repository corpus verification

The repository corpus is a reviewed set of sanitized specimens. Corpus discovery checks every specimen for the required asset set and rejects missing files, extra files, symlinks, invalid identities, and an empty corpus. The same checks also cover the embedded synthetic fixture when the package is tested without the workspace corpus.

Each recorded case represents a fixed read operation rather than a complete discovery session. Production operations consume the declared exchanges and compare their results with reviewed expectations. This makes the corpus useful for repeatable feature, control, battery, setting, and desktop projection tests without claiming support for physical writes, reconnects, or other behavior that the case does not record.

References: fixtures/README.md• L15-24 fixtures/README.md• L34-45

Repeatable device testing

Profiles give semantic mocks a stable device view. Cassettes add deterministic protocol evidence, while the device domain runtime supplies the mutable topology and transport behavior described by the profile. Together they let tests exercise inventory, route selection, settings, and recovery without depending on a host or physical device.

The fixture crate's default contracts stay free of file I/O, host access, and asynchronous work. The opt-in fs feature adds strict corpus loading for host tools and tests without changing the portable default. The canonical profile remains embedded, so packaged consumers can use it without a workspace-relative path.

The G512 specimen shows the split between semantic claims and operation evidence. Its direct USB profile reports lighting, Fn-lock, and report-rate support while marking battery, DPI, SmartShift, wheel, and backlight settings unsupported. Its seven long-report cases cover feature and control reads plus the reviewed unsupported reads. The fixture verifies those claims and exchanges, but it does not establish physical lighting, remapping, report-rate, or write behavior.

References: crates/…/lib.rs• L1-15 crates/…/lib.rs• L24-36 crates/…/Cargo.toml• L13-22 crates/…/Cargo.toml• L30-31 fixtures/README.md• L178-184 fixtures/…/profile.json• L5-68 fixtures/…/profile.json• L73-130 fixtures/…/manifest.json• L1-95

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep profile routes, manifest principals, and cassette case bindings aligned. A route that parses but resolves to no single principal cannot support a case.
  • Keep each new identity field mapped in the synthetic identity policy, protocol extractor, manifest occurrence model, and cross-asset verifier.
  • Keep the binary and profile forms of a Unifying receiver identity derived from the same value.
  • Keep profile capability claims aligned with setting support and with the distinction between HID++ routes and standalone raw-HID routes.
  • Keep cassette report support, request matching, and protocol correlation rules aligned with the transport behavior used by replay.
  • Keep the canonical fixture manifest's exact occurrence ledger aligned with every profile identity change.
  • Keep on-disk case names, manifest case names, cassette names, and case file names identical.
  • Keep all corpus consumers on the openlogi_fixture::fs loader so missing, extra, symlinked, and empty assets fail consistently.
  • Keep the optional fs feature boundary separate from the host-free default fixture contracts.
  • Keep schema fields and schema-version behavior aligned with every profile or cassette producer. Unknown fields must not become silent compatibility gaps.
  • Keep the default fixture contracts free of file I/O, host access, and asynchronous work so portable replay and CLI tooling can depend on them.
  • Keep reviewed corpus expectations aligned with each specimen's accepted case set. An excluded operation must not remain in the manifest or its identity ledger.

Important failure modes

TriggerConsequenceGuard
A real or noncanonical identity enters a profile or cassetteThe fixture can expose private hardware data or fail to match its ledgerClassify every identity under the synthetic policy and reject noncanonical values
One synthetic value is assigned to two principalsReplay can attribute traffic to the wrong receiver or deviceRequire unique typed identity values in the manifest ledger
A cassette case points to the wrong route or slotA test can pass while exercising a different device than intendedCheck case relationships and protocol request targets during verification
A profile setting claims support that inventory capabilities do not advertiseSemantic tests model controls that the device cannot provideValidate setting support against route capabilities
A route declares a setting with an invalid initial valueA semantic mock starts with a state that the device model cannot representValidate DPI, report rate, Easy-Switch, backlight, and related typed setting values before assembly
A Unifying binary serial and profile route differReceiver traffic and profile settings refer to different receiversRequire the exact binary-to-uppercase-hex relation
A cassette uses an unknown identity feature, a write, or pairing trafficThe fixture includes evidence that the crate cannot prove safeFail closed in protocol identity inspection
A report has an unknown ID or wrong widthReplay cannot use the exchange reliablyValidate each report against its ID-defined width and channel support
A declared case file is missing or an undeclared file is presentThe on-disk corpus does not match the manifestApply strict directory and case-file checks before cross-asset verification
A corpus consumer bypasses the shared filesystem loaderOne tool can accept a corpus that another tool rejectsRoute corpus discovery and asset loading through the optional fs boundary
File-system loading becomes part of the default fixture contractPortable replay and published CLI tools gain an unwanted host dependencyKeep file loading behind the fs feature and keep default validation host-free
Verification passes and is treated as proof of physical behaviorTests can give false confidence about a real deviceTreat verification as semantic and replay consistency, not hardware validation

Key files

FileWhy to read it
crates/…/lib.rsDefines the public fixture boundary and the embedded canonical assets.
crates/…/Cargo.tomlStates the host-free default and the opt-in filesystem boundary that keeps fixture contracts portable.
crates/…/schema.rsDefines semantic profiles, setting support, cassettes, report support, and schema rules.
crates/…/manifest.rsDefines fixture cases, route principals, identity forms, and occurrence locations.
crates/…/identity.rsDefines canonical synthetic identity forms and their shared ordinal policy.
crates/…/protocol_identity.rsDefines which HID++ identity evidence is understood and which traffic fails closed.
crates/…/protocol_identity_tests.rsShows the protocol identity and request-target guarantees that protect cassette evidence.
crates/…/generate.rsShows how sanitized profiles and cassettes become an exact manifest.
crates/…/verify.rsShows the schema, relationship, privacy, and replay verification stages.
crates/…/fs.rsDefines the opt-in strict loader for fixture directories and corpora.
crates/…/tests.rsShows the loader's guarantees for exact assets, safe paths, symlinks, and non-empty corpora.
crates/…/profile.jsonShows the canonical synthetic topology and route setting coverage.
crates/…/manifest.jsonShows the canonical identity ledger and profile-only case model.
fixtures/README.mdDefines the reviewed corpus boundary, contribution rules, and limits of recorded operation evidence.
fixtures/…/profile.jsonShows a direct USB keyboard profile with supported and unsupported setting claims.
fixtures/…/manifest.jsonShows how the G512 cases bind to one direct-device principal and one synthetic unit identity.
fixtures/…/feature-table.jsonIllustrates a reviewed protocol case that supplies feature discovery evidence.
crates/…/verify.rsDefines the user-facing verification command and its relation to fixture loading.
crates/…/contribute.rsShows how a profile-only or cassette-backed contribution is assembled and verified.