Skip to main content

laser_wire/
fixtures.rs

1// The golden corpus, embedded so a consumer (LaserData Cloud, the Iggy server, a port's
2// conformance suite) can assert against the exact canonical bytes in its own
3// CI without copying files.
4
5macro_rules! corpus {
6    ($($name:literal),+ $(,)?) => {
7        /// Every fixture in the corpus as `(file name, canonical bytes)`.
8        pub const ALL: &[(&str, &[u8])] = &[
9            $(($name, include_bytes!(concat!("../fixtures/", $name)))),+
10        ];
11    };
12}
13
14corpus!(
15    // The agent surface (DRAFT-grade until a real multi-agent application
16    // has bent the envelope: the `agent_invalid_*` negatives must fail
17    // `validate()` identically in every port).
18    "accepted_operation.json",
19    "agent_body_ref.bin",
20    "agent_card.bin",
21    "agent_chunk.bin",
22    "agent_chunk_open.bin",
23    "agent_chunk_terminal.bin",
24    "agent_command.bin",
25    "agent_command_signed.bin",
26    "agent_dead_letter.bin",
27    "agent_error.bin",
28    "agent_error_body.bin",
29    "agent_event.bin",
30    "agent_invalid_chunk_late_deadline.bin",
31    "agent_invalid_chunk_no_sequence.bin",
32    "agent_invalid_chunk_open_no_operation.bin",
33    "agent_invalid_command_no_correlation.bin",
34    "agent_invalid_error_last.bin",
35    "agent_invalid_event_task_state.bin",
36    "agent_invalid_response_channel.bin",
37    "agent_invalid_status_bad_operation.bin",
38    "agent_invalid_status_no_operation.bin",
39    "agent_list_page.bin",
40    "agent_must_understand.bin",
41    "agent_presence.bin",
42    "agent_record.bin",
43    "agent_reply_error.bin",
44    "agent_reply_list_page.bin",
45    "agent_reply_status.bin",
46    "agent_response.bin",
47    "agent_submit.bin",
48    "agent_signature.bin",
49    "agent_status_card.bin",
50    "agent_status_run_metadata.bin",
51    "agent_status_task.bin",
52    "authz_bind_roles.bin",
53    "authz_get_role_reply.bin",
54    "authz_history_reply.bin",
55    "authz_history_request.bin",
56    "authz_role.bin",
57    "authz_whoami_reply.bin",
58    "arrow_ipc_metadata.bin",
59    "arrow_ipc_policy.bin",
60    "backend_announce.bin",
61    "backend_announce_topology.bin",
62    "backend_announce_unavailable.bin",
63    "batch_reply.bin",
64    "batch_request.bin",
65    "browse_projections.json",
66    "browse_reply_decoded.bin",
67    "browse_reply_projections.bin",
68    "browse_reply_schema_registered.bin",
69    "browse_reply_schemas.bin",
70    "browse_schemas.json",
71    "capabilities.json",
72    "change_record.bin",
73    "checkpoint_mutation_replicated.bin",
74    "checkpoint_public_mutation_discriminants.bin",
75    "checkpoint_reply_destination.bin",
76    "checkpoint_reply_query_route.bin",
77    "checkpoint_request_public.bin",
78    "client_metadata_list.bin",
79    "client_metadata_query.bin",
80    "control_apply_binding.bin",
81    "control_drop_schema.bin",
82    "control_register_projection.bin",
83    "control_register_schema_avro.bin",
84    "control_register_schema_json.bin",
85    "control_register_schema_protobuf.bin",
86    "control_register_run_source.bin",
87    "control_remove_binding.bin",
88    "control_remove_run_source.bin",
89    "decode_record.bin",
90    "data_stack_string_discriminants.bin",
91    "destination_checkpoint_status.bin",
92    "destination_issue.json",
93    "destination_page.json",
94    "error_body.json",
95    "fold_snapshot.bin",
96    "fork_create.bin",
97    "fork_info.json",
98    "fork_put.bin",
99    "fork_reply_created.bin",
100    "forwarded_command.bin",
101    "forwarded_query.bin",
102    "graph_edge.bin",
103    "graph_edge_conversation.bin",
104    "graph_edge_sourced.bin",
105    "graph_neighbors.bin",
106    "graph_neighbors_conversation.bin",
107    "graph_node.bin",
108    "graph_node_conversation.bin",
109    "graph_node_sourced.bin",
110    "graph_query.bin",
111    "graph_query_conversation.bin",
112    "graph_reply.bin",
113    "graph_upsert.bin",
114    "hello_reply.bin",
115    "hello_reply_agent.bin",
116    "hello_reply_features.bin",
117    "kv_cas.bin",
118    "kv_cas_fenced.bin",
119    "kv_copy.bin",
120    "kv_get_barriered.bin",
121    "kv_lease.bin",
122    "kv_lease_renew.bin",
123    "kv_move.bin",
124    "kv_namespaces.bin",
125    "kv_page_view.json",
126    "kv_release.bin",
127    "kv_reply_committed.bin",
128    "kv_reply_leased.bin",
129    "kv_reply_namespaces.bin",
130    "kv_reply_page.bin",
131    "kv_reply_renewed.bin",
132    "kv_reply_stale.bin",
133    "kv_reply_version_conflict.bin",
134    "kv_scan.bin",
135    "kv_set.bin",
136    "key_record.bin",
137    "logical_schema.bin",
138    "logical_type_discriminants.bin",
139    "managed_request.bin",
140    "materialization_destination.bin",
141    "mutation_command.bin",
142    "query_envelope.bin",
143    "query_envelope_aggregate.bin",
144    "query_envelope_raw_sql.bin",
145    "query_envelope_read_your_writes.bin",
146    "query_envelope_text.bin",
147    "query_error_discriminants.bin",
148    "query_cancel.bin",
149    "query_page.bin",
150    "query_reply_err_stale.bin",
151    "query_reply_err_too_large.bin",
152    "query_reply_ok.bin",
153    "query_execution.json",
154    "query_result.json",
155    "query_route.bin",
156    "query_route_page.json",
157    "query_status.bin",
158    "query_status_reply.bin",
159    "register_schema_managed.bin",
160    "schema_def.json",
161    "start_policy_discriminants.bin",
162    "snapshot_page.json",
163    "table_file_page.json",
164    "table_metrics.json",
165    "table_schema_view.json",
166    "table_view.json",
167    "query_target_discriminants.bin",
168    "typed_value_discriminants.bin",
169);
170
171/// Canonical bytes of one fixture by name, or `None` if the name is unknown.
172pub fn bytes(name: &str) -> Option<&'static [u8]> {
173    ALL.iter()
174        .find(|(fixture, _)| *fixture == name)
175        .map(|(_, bytes)| *bytes)
176}
177
178/// Assert that `encoded` matches the canonical fixture byte-for-byte.
179/// Panics with a diff-friendly message on drift.
180pub fn assert_matches(name: &str, encoded: &[u8]) {
181    let golden = bytes(name).unwrap_or_else(|| panic!("unknown fixture `{name}`"));
182    assert_eq!(
183        encoded, golden,
184        "fixture `{name}` drifted from the canonical frame"
185    );
186}
187
188#[cfg(test)]
189mod tests {
190    #[test]
191    fn given_the_corpus_when_looked_up_then_should_resolve_known_names() {
192        assert!(super::bytes("hello_reply.bin").is_some());
193        assert!(super::bytes("nope.bin").is_none());
194    }
195}