The laser-wire crate, its command codes, typed CBOR and JSON contracts, validation, HTTP routes and client, and golden fixture corpus. Use for any change under wire or a native TypeScript wire port.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Wire Contract?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/laserdata-wire-contract)
---
name: wire-contract
description: The laser-wire crate, its command codes, typed CBOR and JSON contracts, validation, HTTP routes and client, and golden fixture corpus. Use for any change under wire or a native TypeScript wire port.
---
# laser-wire contract
Load [laser-sdk-overview](../laser-sdk-overview/SKILL.md) first. [docs/agdx.md](../../../docs/agdx.md) is the normative prose contract. [wire/README.md](../../../wire/README.md) is the public module reference.
## Contract boundary
`laser-wire` owns data and pure validation. It has no I/O, clock, randomness, Apache Iggy client, or async runtime. The optional `http-client` feature adds an async client over a caller-injected runtime-agnostic transport and still supports `wasm32-unknown-unknown`.
Rust is the executable source of wire truth. Python binds it. TypeScript implements it natively under `foreign/typescript/src/wire` and proves parity against the Rust fixture corpus. Go implements it natively under `foreign/go/wire`, and `foreign/go/wire/parity_test.go` checks its types against the Rust sources.
The contract includes binary managed commands, JSON HTTP views, headers, topics, command codes, version negotiation, structured backend capabilities, result codes, and limits. Application behavior and backend execution do not belong in this crate.
## Module map
- `codes` owns permanent command numbers, code classification, and independent operation versions.
- `hello` owns `OpVersions`, structured backend descriptors and capability sets, readiness, and topology announcement.
- `schema` owns logical schemas, SHA-256 fingerprints, tagged values, provenance field reservations, and recursive validation.
- `destination` owns the backend binding a projection writes to (`BackendBinding`, `BackendResourceId`).
- `arrow` owns Arrow IPC metadata, the frozen policy, limits, and rejection codes.
- `query` owns the operational target, DSL, typed parameters, offset paging, positional typed results, execution evidence, and errors.
- `control` and `browse` own projection, binding, writer-schema, and registry contracts.
- `authz` owns the stream scoping helpers `scoped_resource(stream, local)` (idempotent on a `stream:` name) and `split_scoped_resource(name)`, and `AuthzError::TenancyViolation` (maps to `invalid_argument`). `hello::feature::STREAM_TENANCY` is `1 << 13`, and `topics::stream_ops_topic(stream, surface)` names a stream's own ops topic. `KvScan`, `KvDeleteMany`, `GraphQuery`, `GraphNeighbors`, `ControlEnvelope`, and the schema browse requests carry `stream: Option<String>`, skipped when absent so older fixtures stay byte identical. `ChangeRecord.stream` names the stream of a change record. `ConsumerFilter.schema_stream` names the schema registry, and fork ids may be `stream:<s>/<local>`, percent-encoded in HTTP paths.
- The run band is gone from the wire: codes 1_000_700 to 1_000_703 are reserved and never reused, and `feature::AGENT_WORKFLOW` stays only as a retired bit. Session additions: `SessionList.{root, label_prefix}`, `SessionFlags.liveness_unknown`, `SessionInfo.held`, `SessionPage.rebuilding` (omitted when false), `SessionEvent.verified_actor`, `SessionPauseRequest`, `SessionParking`, and the display types `invalid`, `session.parked`, and `session.unparked`.
- `kv`, `fork`, `graph`, `batch`, and `authz` own their managed surfaces. `session` owns the seven stream-first session read requests (codes 1_000_710 to 1_000_716), `SessionReply`, the frontier, gap, and change types, `SessionError`, and `SessionHeartbeat`, whose optional `stream_generation` and `counts_for` let a reader ignore a heartbeat of a stream that was deleted and created again. The run registry band 1_000_700 to 1_000_703 is retired and never reused.
- `dispatch` (feature `cbor`) owns the session timeline `display_type` mapping, the reliable-consumer `classify`/`classify_generic` table, the control operation names, and the addressee filters with `ADDRESSEE_FILTER_NAME`, pinned by `fixtures/dispatch_cases.json`. `headers` owns the one `RecordHeaders` encoder, pinned by `header_block_envelope.json` and `header_block_generic.json`.
- `filter` owns consumer filters: `ConsumerFilter` and `FilterExpr` builders with record policies (`expr`), field paths, text matching, coercions, the filtered poll, the filtered wait (`AGDX_FILTERED_WAIT_CODE`, `FilteredWaitRequest`, `FilterOutcome::Ready`, announced by `FilterAnnounce.max_wait_ms`), acknowledgment, preview, and test types with their reason codes (`read`), the saved-filter catalog with named group policies (`GroupFilterSpec::Definition { name, filter }`, `validate_filter_name`), `FilterOwner`, `FilterSummary.owner` and `ListFilters.owner` (`catalog`), the typed header dictionary (`headers`), the codec decoders (`codecs`), and the evaluator (`eval`, feature `filter-eval`). `wire/fixtures/filter_eval_cases.json`, `wire/fixtures/filter_codec_cases.json`, and `wire/tests/filter_eval_corpus.rs` are the cross-language corpus every evaluator must reproduce.
- `agent`, `change`, `keys`, `mutation`, and `forward` own AGDX envelopes (with session bodies, context and state records, `SessionRef`, and `estimate_tokens`), change notifications, managed key records, mutation identity with its trusted `scope`, and forwarded commands with the server-stamped `ForwardedScope`.
- `headers`, `topics`, `content`, `limits`, and `result` own permanent dictionaries and shared result classification.
- `http` owns `/agdx/*` routes, parameters, JSON views, and `ErrorBody`.
- `http_client` owns the feature-gated typed client over an injected `Transport`. A non-2xx reply is `ClientError::Api` when the body decodes as `ErrorBody` and `ClientError::Status { status, body }` otherwise, and `ClientError::code` covers both.
- `framing`, `encoding`, and `codecs` own CBOR framing, byte-string helpers, and payload codec traits.
- `writer_schema` (feature `schema-decode`, enabled by `filter-eval` and the SDK `schema-codecs`) owns the one writer-schema lowering: Avro with logical annotations removed, Protobuf with schema field names, numeric enums, exact 64-bit integers, bytes as integer arrays and proto3 defaults present, behind the bounded pre-pass. The filter decoders, the SDK `CompiledSchema`, the typed topics and the managed projector all decode through it, and `wire/fixtures/writer_schema_cases.json` (generated by the SDK test `schema_codecs::tests::given_the_writer_schema_case_definitions_when_encoded_then_should_match_the_shared_corpus` under `AGDX_WIRE_FIXTURES_REGEN=1`) pins it in Rust, Python, TypeScript and the server. `SchemaSource::validate` holds the registry rules: 1 MiB, JSON nesting 64, JSON Schema draft 2020-12 only.
- `fixtures` embeds the golden corpus.
## Hard invariants
Bytes are the binary contract. Field names, serde attributes, enum representation, byte-string encoding, integer width, and command numbers cannot drift accidentally. Intentional pre-1.0 breaking changes update every consumer, fixture, binding, and implementation in the same stage while operation versions remain 1.
All payload byte fields use the shared CBOR byte-string adapters. A bare `Vec<u8>` serialized as an integer array is a contract bug.
Decode of untrusted bytes must return a typed error and never panic. The crate forbids unsafe code. Every new envelope belongs in deterministic robustness tests and the fuzz decoder.
Logical result rows are positional. `QueryResult.fields` is the schema and every `Row.values` array must have the same width and validate against its field type and nullability.
Provenance result fields are reserved exact ID and name pairs. They are allowed only at the top level of query result schemas. User schemas and nested structs cannot claim them.
The SDK checks Arrow metadata before publication. Managed ingestion must also parse the stream. Require self-containment, the expected schema fingerprint, stable dictionaries, microsecond timestamps, supported decimal widths and types, and configured limits.
Consistency is fail-not-downgrade. Query reply validation rejects a delivered consistency weaker than requested and rejects missing target evidence.
## Versioning
Named fields allow additive optional growth when readers can safely ignore it. Changed meaning, removed fields, or new executor-dispatched grammar is breaking and requires a coordinated package release across every consumer. The hello-negotiated surface slots and fenced-lease request family remain version 1.
`OpVersions` negotiates query, control, KV, fork, graph, filter, and agent support independently. Compare the command with its own version slot before sending. `KvLease`, `KvLeaseRenew`, `KvRelease`, and `KvCasFenced` require `KV_LEASE_OP_VERSION = 1` and `KV_FENCED_LEASES`.
Permanent u8 dictionaries use unknown-code passthrough where relay compatibility matters. Executor vocabularies such as comparison and aggregate functions remain exhaustive so every backend must handle a new variant explicitly.
## Fixture workflow
Every new public contract type and enum discriminant needs a Rust round-trip assertion. Cross-language public shapes also need TypeScript decode and byte-identical re-encode coverage. JSON HTTP views need canonical JSON fixtures. The `session_http_*.json` files pin every session read's HTTP body, including the change feed start and gap cases.
Regenerate with `just fixtures-regen` only for an intentional wire change. Review the byte diff, update `wire/src/fixtures.rs`, `wire/tests/wire_fixtures.rs`, the TypeScript fixture manifest and tests, robustness decoders, AGDX docs, Python bindings, TypeScript codecs, and API reports.
The fixture manifest is closed. Added or removed files fail TypeScript tests until explicitly classified and consumed.
## New command checklist
1. Allocate the code in `codes.rs` without renumbering an existing command.
2. Add request, reply, validation, and typed error shapes in the owning module.
3. Register the command pairing in `commands.rs`.
4. Add binary fixtures, constants assertions, robustness decode coverage, and TypeScript parity.
5. Add HTTP routes and views only when that surface is served over HTTP.
6. Update AGDX prose and the relevant language SDK accessors.
7. Run native, wasm, deny, fuzz, fixture, BDD, and package verification gates.
## Review focus
Reject defaults that broaden a query or weaken consistency. Reject malformed success data, missing target evidence, and confusion between public requests and committed state. Do not trust Arrow metadata without parsing its stream. Keep wire u64 and u128 values exact in TypeScript.
## Consumer-group filter ownership
Consumer group handles live under topics. Filter setup and revisions live under each group. Normal and advanced consumers use the group's policy and return all records for an authoritatively unbound group. Follow the consumer-filters skill for scan budgets, progress, cancellation, capability failures and cross-language test parity. Do not reintroduce a top-level filter service.