Skip to main content

krabka_macros/
lib.rs

1//! Derive macros for the krabka broker.
2//!
3//! `krabka-macros` turns one annotated declaration into code that the broker
4//! would otherwise write out by hand two or three times. It is built on
5//! [`moxy`], which supplies the token, syntax-tree, attribute-parsing and
6//! template layers.
7
8//!
9//! # `RegisterMetrics`
10//!
11//! `#[derive(RegisterMetrics)]` goes on a struct of `prometheus-client` metric
12//! handles. It adds two private methods to the struct:
13//!
14//! - `fn unregistered() -> Self` constructs every field: with
15//!   `Default::default()`, with a histogram over `buckets`, or with the `new`
16//!   expression.
17//! - `fn register(&self, registry: &mut Registry)` registers a clone of every
18//!   field that is not `skip`, in field order. The order of the fields is the
19//!   order of the families in the text exposition.
20//!
21//! Each field takes one optional `#[metric(...)]` attribute:
22//!
23//! - `help = "..."` — the help text. Every registered field needs one.
24//! - `name = "..."` — the registered name. The default is the field name with
25//!   a trailing `_total` removed, because `prometheus-client` appends `_total`
26//!   to the name of a counter itself.
27//! - `buckets = EXPR` — construct a `Histogram` over `EXPR`. On a
28//!   `Family<_, Histogram>` field, construct the family so that each of its
29//!   histograms uses `EXPR`.
30//! - `new = EXPR` — construct the field with `EXPR`.
31//! - `skip` — construct the field, but do not register it.
32//!
33//! ```ignore
34//! #[derive(krabka_macros::RegisterMetrics)]
35//! struct Metrics {
36//!     #[metric(help = "Records received")]
37//!     records_total: Counter,
38//!     #[metric(help = "Request latency in seconds", buckets = [0.001, 0.01, 0.1])]
39//!     latency_seconds: Family<ApiLabel, Histogram>,
40//! }
41//! ```
42//!
43//! # `human_units`
44//!
45//! `#[human_units]` goes on a file-config struct, above its
46//! `#[derive(Deserialize, Serialize, JsonSchema)]`. Each field typed
47//! `Option<Time>`, `Option<ByteSize>` or `Option<Ratio>` (under any path
48//! prefix) gets two attributes:
49//!
50//! - `#[serde(default, with = "krabka_units::serde_units::human::option_X")]`,
51//!   so that the TOML file writes the value as a string with a unit, such as
52//!   `"5s"` or `"1MiB"`. `default` is left out when the field already has a
53//!   serde `default`.
54//! - `#[schemars(with = "Option<crate::file_config::schema_units::X>")]`, so
55//!   that the JSON Schema names the unit in its `format`.
56//!
57//! A field with its own serde `with`, `deserialize_with` or `serialize_with`
58//! keeps its codec and gets neither attribute. Every other field passes through
59//! unchanged.
60//!
61//! ```ignore
62//! #[krabka_macros::human_units]
63//! #[derive(Deserialize, Serialize, JsonSchema)]
64//! struct FileTimeouts {
65//!     request_timeout: Option<Time>,
66//!     segment_bytes: Option<ByteSize>,
67//! }
68//! ```
69//!
70//! # `dispatch_table!`
71//!
72//! `dispatch_table! { ... }` goes in the broker's dispatch registry module. It
73//! reads sections of `CamelCase` Kafka api names, each a label, a colon, and
74//! comma-separated entries closed by `;`:
75//!
76//! ```ignore
77//! krabka_macros::dispatch_table! {
78//!     context: Metadata, AddPartitionsToTxn => crate::txn::handlers::add_partitions_to_txn::handle;
79//!     sync_context: DescribeConfigs;
80//!     typed: ListGroups;
81//!     typed_group: Heartbeat;
82//!     typed_sync: DescribeAcls;
83//!     typed_infallible: ListConfigResources;
84//!     auth: CreateDelegationToken;
85//!     telemetry: PushTelemetry;
86//! }
87//! ```
88//!
89//! From each name, such as `CreateAcls`, it derives the adapter
90//! `create_acls_adapter`, the `ApiKey::CreateAcls` variant, the request module
91//! `krabka_protocol::owned::create_acls_request` and its `CreateAclsRequest`
92//! type. The handler is `crate::handlers::create_acls::handle` unless the entry
93//! names another with `=> path`.
94//!
95//! - `context` and `sync_context` adapters call
96//!   `handler(broker, version, body, ctx)` on the raw body; a `sync_context`
97//!   handler returns its result instead of a future. A handler that needs the
98//!   request's correlation id reads it from the context.
99//! - `typed` adapters decode the request, await
100//!   `handler(broker, request, version, ctx)` for a
101//!   `Result<Response, BrokerError>`, and encode the response with
102//!   `crate::handlers::encode_response`. `typed_group` adapters do the same
103//!   but decode through `crate::handlers::decode_group_request`.
104//! - `typed_sync` adapters decode the request, call
105//!   `handler(broker, &request, version, ctx)` for a
106//!   `Result<Response, BrokerError>` without awaiting it, encode the response,
107//!   and wrap the result in a ready future. `typed_infallible` adapters do the
108//!   same for a handler that returns the `Response` itself.
109//! - `telemetry` adapters pass a `TelemetryContext` and wrap a synchronous
110//!   result.
111//! - `auth` entries generate no adapter: the hand-written `<name>_adapter`
112//!   must be in scope.
113//! - `typed_own_span` generates the `typed` adapter without the span below,
114//!   for a handler that keeps a `#[tracing::instrument]` of its own.
115//!
116//! Every other generated adapter runs the decode, the handler and the encode
117//! inside an `info` span named `handle_<snake_name>`, with `api = "<Name>"`,
118//! `version` and, for the `context`, `sync_context` and `telemetry` sections,
119//! `req_bytes = body.len()`. On `Err` it emits, inside that span, the event
120//! `#[tracing::instrument(err)]` would: `ERROR` with `error` set to the
121//! error's `Display`. The expansion calls `::tracing`, so the calling crate
122//! depends on it, and `BrokerError` implements `Display`.
123//!
124//! It then emits `fn register_dispatch_table(registry: &mut DispatchRegistry)`,
125//! which registers every entry at the request schema's `FLEXIBLE_MIN` and
126//! panics on a duplicate registration. The expansion names `Broker`,
127//! `ApiVersion`, `CorrelationId`, `RequestContext`, `TelemetryContext`,
128//! `BoxFuture`, `Bytes`, `BrokerError`, `ApiKey`, `DispatchEntry` and
129//! `DispatchRegistry` unqualified, so the calling module imports them.
130//!
131//! # `throttle_probes!`
132//!
133//! `throttle_probes! { ... }` is an expression for the KIP-219 throttle-echo
134//! audit: an array of `(API_KEY, probe as Probe)`, one per entry, keyed by the
135//! response module's generated `API_KEY`. Its sections are `throttled` (the
136//! response has `throttle_time_ms`, which the probe sets to `SENTINEL`),
137//! `unthrottled` (it has none), and `legacy_split: Name = version`, whose
138//! probe encodes the `kafka_3_6_2` response below `version`. The probes call
139//! `position`, `ApiVersion`, `ThrottlePosition`, `SENTINEL` and `Probe` from
140//! the calling module.
141//!
142//! ```ignore
143//! let probes: BTreeMap<_, _> = krabka_macros::throttle_probes! {
144//!     throttled: Metadata, ListOffsets;
145//!     unthrottled: SaslHandshake;
146//!     legacy_split: Produce = 3, Fetch = 4;
147//! }
148//! .into_iter()
149//! .collect();
150//! ```
151//!
152//! # `RuntimeOverlay`
153//!
154//! `#[derive(RuntimeOverlay)]` goes on a clap argument group whose fields
155//! overlay the same-named fields of a config struct. The struct names that
156//! config with `#[overlay(target = Type)]`. The derive adds
157//! `pub(crate) fn copy_into(&self, target: &mut Type)`, which assigns every
158//! field in field order:
159//!
160//! - by default, `target.f = self.f`, so the field must be `Copy`;
161//! - with `#[overlay(refined)]`, `target.f = self.f.map(|value| value.into_value())`,
162//!   for an `Option` of a refined newtype;
163//! - with `#[overlay(clone)]`, `target.f.clone_from(&self.f)`;
164//! - with `#[overlay(skip)]`, not at all.
165//!
166//! A field that the target lacks, or whose type differs, fails to compile.
167//!
168//! ```ignore
169//! #[derive(clap::Args, krabka_macros::RuntimeOverlay)]
170//! #[overlay(target = RuntimeFileConfig)]
171//! struct RuntimeArgs {
172//!     cleaner_interval: Option<Time>,
173//!     #[overlay(refined)]
174//!     num_partitions: Option<PositiveI32>,
175//! }
176//! ```
177//!
178//! # `krabka_env`
179//!
180//! `#[krabka_env]` goes on a clap argument struct, above its
181//! `#[derive(clap::Args)]`. Each field without an `#[arg(...)]` of its own gets
182//! `#[arg(long, env = "KRABKA_<FIELD>", ...)]`, where `<FIELD>` is the field
183//! name in upper case and the rest follows from the field type:
184//!
185//! | Field type | Added argument |
186//! |---|---|
187//! | `Option<Time>` | `value_parser = krabka_units::parse::positive_time` |
188//! | `Option<ByteSize>` | `value_parser = krabka_units::parse::positive_byte_size` |
189//! | `Option<Ratio>` | `value_parser = krabka_units::parse::positive_ratio` |
190//! | `Option<PositiveCount>` | `value_parser = krabka_broker::config_value::parse_positive_count` |
191//! | `Option<PositiveI16>`, `I32`, `I64` | the matching `parse_positive_*` |
192//! | `Option<u32>` | `value_parser = clap::value_parser!(u32).range(1..)` |
193//! | `Option<i64>` | `value_parser = clap::value_parser!(i64).range(0..)` |
194//! | `Option<bool>` | `action = clap::ArgAction::Set` |
195//! | `Option<i16>`, `Option<i32>`, `Option<String>`, `Option<PathBuf>` | none |
196//!
197//! The type is matched as written, so a field of any other type, or of one
198//! of these that needs another parser, keeps its own `#[arg(...)]`. Doc
199//! comments stay where they are and remain the help text.
200//!
201//! `#[krabka_env(prefix = "BENCH_")]` puts every variable under that prefix in
202//! place of `KRABKA_`, so the field `tls_ca_path` reads `BENCH_TLS_CA_PATH`.
203//! A field whose variable is not its name under the prefix keeps its own
204//! `#[arg(...)]`.
205//!
206//! # `RefinedNewtype`
207//!
208//! `#[derive(RefinedNewtype)]` goes on a tuple struct with one field, the value
209//! a `refined_type` rule checks. It adds `new(value) -> Result<Self, E>`, which
210//! validates through the rule, and a `#[must_use] const` getter that returns
211//! the value. Both take the struct's visibility. One `#[refined(...)]`
212//! attribute configures it:
213//!
214//! - `rule(<type>)` — the `refined_type` rule, such as `GreaterU32<0>`.
215//!   Required. It goes in parentheses because a generic type does not parse
216//!   after `=`.
217//! - `getter = name` — the getter's name. The default is `into_value`.
218//! - `string_error` — `new` returns `String`, the rule's error text, rather
219//!   than `refined_type::result::Error<T>`.
220//! - `label = "..."` — with `string_error`, `new` returns
221//!   `"<label>: <rule error>"`.
222//! - `default = EXPR` — implement `Default` as `Self::new(EXPR)`, which panics
223//!   when `EXPR` breaks the rule.
224//! - `from_str` — implement `FromStr` with `Err = String`: the field type's
225//!   own `parse`, then `new`, each error as its text.
226//! - `display` — implement `Display` as the field's.
227//! - `parse_fn = name` — add a free `fn name(&str) -> Result<Self, String>`
228//!   that parses the way `from_str` does.
229//! - `quantity = ByteSize`, `Time` or `Frequency` — the field is a whole
230//!   number of bytes, milliseconds or Hz, and `new` takes the `krabka_units`
231//!   quantity. It refuses a fraction, an infinity, or a count the field type
232//!   cannot hold with `"<label>: must be a whole number of <unit> that fits in
233//!   <field type>"`, then hands the count to the rule. It implies
234//!   `string_error`, adds `TryFrom<quantity>` through `new`, makes `from_str`
235//!   parse with `krabka_units::parse` and `display` print the quantity's
236//!   `human()` text, and makes `default` take a quantity.
237//! - `quantity_getter = name` — with `quantity`, add a getter that returns the
238//!   value as its quantity.
239//!
240//! ```ignore
241//! #[derive(Clone, Copy, krabka_macros::RefinedNewtype)]
242//! #[refined(rule(GreaterU32<0>), string_error, label = "fetch miss limit", getter = get,
243//!           default = 3, from_str, display)]
244//! pub struct FetchMissLimit(u32);
245//!
246//! #[derive(Clone, Copy, krabka_macros::RefinedNewtype)]
247//! #[refined(rule(GreaterI32<0>), quantity = ByteSize, label = "fetch max", getter = bytes,
248//!           quantity_getter = size, default = mebibytes(8), from_str, display)]
249//! pub struct FetchMax(i32);
250//! ```
251//!
252//! # `PrimitiveCmp`
253//!
254//! `#[derive(PrimitiveCmp)]` goes on a tuple struct with one field. It
255//! implements `PartialEq` and `PartialOrd` between the struct and the field's
256//! type in both directions, so that `Seq(3) == 3_u64` and `2_u64 < Seq(3)`
257//! compile.
258//!
259//! # `EnumStr`
260//!
261//! `#[derive(EnumStr)]` goes on an enum whose variants each stand for one
262//! fixed text, such as a metric label value or a config value. It adds a
263//! `#[must_use] const fn as_str(self) -> &'static str` with the enum's
264//! visibility. The method takes `&self` when any variant has fields, which
265//! its arm matches with `{ .. }` or `(..)`. One optional `#[enum_str(...)]`
266//! attribute on the enum configures it:
267//!
268//! - `case = "..."` — how a variant name becomes its text: `"snake_case"`,
269//!   `"kebab-case"`, `"lowercase"` or `"UPPERCASE"`. Without it the text is
270//!   the variant name unchanged.
271//! - `as_str = name` — the method's name.
272//! - `parse` or `parse = name` — add `fn parse(&str) -> Option<Self>`, under
273//!   that name, over the unit variants.
274//! - `all` — add `const ALL: [Self; N]`, every variant in declaration order.
275//!   Every variant must be a unit variant.
276//! - `label_value` — implement `prometheus_client`'s `EncodeLabelValue` as the
277//!   text. The crate must depend on `prometheus-client`.
278//!
279//! A variant's own `#[enum_str(...)]` takes `name = "..."`, its text in place
280//! of the cased name, and `alias = "..."` or `alias("...", "...")`, further
281//! text that `parse` accepts.
282//!
283//! ```ignore
284//! #[derive(Clone, Copy, krabka_macros::EnumStr)]
285//! #[enum_str(case = "snake_case", as_str = config_name, parse = from_config_name)]
286//! pub enum AssignorKind {
287//!     Auto,
288//!     #[enum_str(alias = "highly-available")]
289//!     HighlyAvailable,
290//! }
291//! ```
292//!
293//! # `FieldDefaults`
294//!
295//! `#[derive(FieldDefaults)]` goes on a struct with named fields in place of a
296//! hand-written `impl Default` that only fills each field with a fixed
297//! expression. Each field takes one optional `#[default(EXPR)]` attribute and
298//! starts as `EXPR`; a field without one starts as `Default::default()`. The
299//! expression is evaluated each time `default()` runs, so it may call
300//! functions, and it is written out as given, so it must name what it uses in
301//! the scope of the struct. The derive adds no bounds: a generic struct
302//! writes the bounds its fields need on the struct itself.
303//!
304//! The name differs from `Default` because the standard derive owns the bare
305//! name and its own `#[default]` attribute on enum variants. Do not derive
306//! both on one struct.
307//!
308//! ```ignore
309//! #[derive(krabka_macros::FieldDefaults)]
310//! pub struct FreezeConfig {
311//!     #[default(Duration::from_secs(30))]
312//!     pub poll_interval: Duration,
313//!     #[default(true)]
314//!     pub enabled: bool,
315//!     pub owners: Vec<String>,
316//! }
317//! ```
318//!
319//! # `cli_main!`
320//!
321//! `cli_main!(path)` goes at the top level of an operator binary's
322//! `main.rs`, in place of its `main`. It expands to a `#[tokio::main]`
323//! `async fn main()` that installs a `tracing_subscriber::fmt()` subscriber
324//! filtered by `RUST_LOG`, or at `info` when `RUST_LOG` is unset or does not
325//! parse, and writes to stderr. stdout stays the binary's own, so a report that
326//! a script parses, such as `krabka-restore --report json`, holds no log lines.
327//! It then awaits `path::run_from_args(std::env::args_os())` and exits the
328//! process with the `i32` it returns. Any arguments after the path, such as
329//! `flavor = "multi_thread"`, go to `#[tokio::main(...)]` unchanged. The
330//! binary depends on `tokio` with its `macros` feature and on
331//! `tracing-subscriber`.
332//!
333//! ```ignore
334//! krabka_macros::cli_main!(krabka_restore, flavor = "multi_thread");
335//! ```
336//!
337//! # Group timings and epoch values
338//!
339//! `#[derive(GroupTimingConfig)]` adds `for_group` and the test-only
340//! `assigning_at_once` constructor to a membership config. Its named timing
341//! fields and bounds remain visible on the struct. Select the stored keys with
342//! `#[group_timing(session = KEY, heartbeat = KEY, assignment = KEY)]`.
343//! The implementation uses the broker's existing group timing parser and bounds.
344//!
345//! `#[derive(GroupLifecycle)]` adds epoch changes, session expiry queries, and
346//! member eviction to a group state. Select its existing policy with
347//! `#[group_lifecycle(protocol = "consumer" | "share" | "streams")]`.
348//! Consumer and share groups get assignment delay checks; consumer and streams
349//! groups get rebalance fencing. A successful streams epoch change marks the
350//! group dirty. All removals call the state's own `remove_member` method.
351//!
352//! `#[derive(FlexibleEpochValue)]` adds the version-zero epoch codec to a
353//! named struct with an `i32` epoch followed by an `i64` tagged value.
354//! `#[epoch_value(record = "RecordName")]` supplies the decoding error name.
355//! A zero tagged value is omitted on encode and restored on decode.
356//!
357//! `#[flexible_value(record = "KafkaRecord")]` goes on an inherent impl with
358//! private `encode_fields(self or &self, buf: &mut BytesMut)` and
359//! `decode_fields(buf: &mut &[u8]) -> Result<Self, BrokerError>` methods.
360//! It retains those methods and adds the public framed codecs. The field
361//! methods keep wire order explicit; the encoder retains its receiver ownership.
362//!
363//! `#[derive(KafkaUuid)]` adds display, parsing, and string serde to a UUID
364//! wrapper. It calls the declaration's existing `encode`, `decode`, and
365//! `KafkaUuidError` helpers. Display retains the formatter's padding rules.
366//!
367//! # Handler admission
368//!
369//! `#[voter_admission(request = TYPE, api = KEY, gate = FUNCTION, refusals = EXPR)]`
370//! goes on an ordinary async `handle(broker, version, req_bytes, ctx)` function.
371//! It runs the shared voter prelude before the operation body and returns early
372//! for an encoded refusal. The body retains its original tokens and scopes.
373//!
374//! `share_state_handler!(Request, Response, TopicRow, PartitionRow, serve)`
375//! declares a share-state handler. A denied request returns an error row for
376//! every requested partition in request order. An allowed request calls `serve`
377//! with the share coordinator and a fresh metadata snapshot.
378//!
379//! # Storage methods
380//!
381//! `#[derive(SparseIndex)]` adds the existing loader and file operations to a
382//! sparse index. `#[sparse_index(kind = "offset" | "time")]` selects its raw
383//! entry layout and I/O target. The loader retains its monotonic-entry checks.
384//! `#[index_open]` adds the same tracing span to other ordinary index loaders.
385//!
386//! `#[remote_operation]` traces an ordinary remote-storage SPI method. Its
387//! existing method name selects the span level and fields. It retains the
388//! native method body, parameter names, and synchronous signature.
389//!
390//! `#[model_type]` attaches the existing proof and runtime derives to an
391//! ordinary struct or enum. `proof(...)` and `runtime(...)` replace only the
392//! selected derive list, preserving its path order and the declaration tokens.
393//!
394//! `#[sendfile_cfg]` gates one ordinary item with the fetch path's shared
395//! platform predicate. Apply it separately to imports, exports and methods.
396//!
397//! `#[decode_dispatch(request = TYPE, binding(req))]` decodes a request before
398//! the handler's native body. `binding(mut req)` retains an owned mutable
399//! request. `decoded_dispatch!` accepts the same explicit function, with
400//! `[request = TYPE, binding(req)]` after its parameters and before its return type.
401//!
402//! `#[extension_wire(name = "SPAN", api = "API", level = "info")]` adapts an
403//! ordinary operation with broker, owned request, version and context parameters.
404//! It emits the raw five-argument entry point and traces both decoding and the
405//! native operation. `"debug"` retains the marker API's tracing level.
406//!
407//! `worm_object_set!` emits one ordered admission rule for its `Model` and
408//! `Runtime` declarations. Function headers and count observations stay native;
409//! proof projections remain inside the caller's Pearlite scope.
410//!
411//! # Direct runtime and response tables
412//!
413//! `set_runtime!` applies optional fields in table order. Each group names a
414//! validator. `plain` assigns directly; `duration` validates positive time
415//! and converts it to `Duration`. A mapping selects a different target field,
416//! and `in` supplies the validator's range argument. An absent field retains
417//! the target value. A validation error stops later assignments.
418//!
419//! ```ignore
420//! krabka_macros::set_runtime! {
421//!     runtime => config;
422//!     plain: enabled;
423//!     duration: heartbeat_interval;
424//!     in_range: max_size => group.max_size in 1..=1000;
425//! }
426//! ```
427//!
428//! `response_errors!` implements the caller's error traits for external
429//! protocol types. Its four sections are `response`, `code_response`, `row`
430//! and `resource_row`. Each section contains type paths separated by commas
431//! inside braces. A resource row also implements `ErrorRow`, so
432//! each resource type is listed once. The traits remain in the caller's scope.
433//!
434//! `metric_registry_fixture!(metrics, output, guard; expect("encode"))`
435//! renders directly into the named bindings. The caller retains the registry
436//! lock until it drops `guard`. Use `unwrap()` to select that result policy.
437//!
438//! `broker_config! { pub struct BrokerConfig { ... } }` constructs the broker
439//! config in one expansion. The fields stay in declaration order with their
440//! original tokens, documentation and attributes. It adds `Debug` and `Clone`.
441//!
442//! `#[membership_defaults]` goes before `FieldDefaults` on a membership config.
443//! It assigns the shared defaults to the six named session and heartbeat
444//! fields. An existing default on one of those fields is an input error.
445//!
446//! `#[derive(ShareStateValue)]` writes scalar fields in declaration order,
447//! followed by state batches and the delivery-count tag. The existing batch,
448//! version and tag helpers retain their byte layouts and validation. Supply
449//! method documentation with `#[share_state(encode_doc = "...", decode_doc = "...")]`.
450//!
451//! `#[derive(FlexibleArrayValue)]` wraps one `Vec` field in version-zero
452//! framing. `#[array_value(record = "RecordName", encode = writer, decode = reader)]`
453//! selects the existing array callbacks and decoding error name.
454//!
455//! `tagged_wire!` and `unthrottled_wire!` construct exhaustive struct values.
456//! Both supply an empty tagged-field set; the second supplies zero throttle.
457//! Every remaining field stays required. Struct updates with `..` are refused,
458//! and field expressions retain their original tokens and evaluation order.
459
460use {
461    moxy::{
462        ast::{ItemEnum, ItemStruct, ParseError},
463        token::TokenStream,
464    },
465    proc_macro::TokenStream as NativeTokenStream,
466};
467
468mod api_names;
469mod async_write_delegate;
470mod auth_fixtures;
471mod background_controllers;
472mod bound_start_fixture;
473mod broker_config;
474mod cli_main;
475mod cli_support;
476mod config_table;
477mod connection_policy;
478mod container_fixtures;
479mod cross_storage_fixtures;
480mod decode_dispatch;
481mod deterministic_random;
482mod dispatch;
483mod enum_str;
484mod extension_wire;
485mod field_defaults;
486mod fixtures;
487mod flexible_array_value;
488mod flexible_epoch_value;
489mod flexible_value;
490mod gcs_fields;
491mod group_lifecycle;
492mod group_timing_config;
493mod human_units;
494mod kafka_uuid;
495mod krabka_env;
496mod legacy_fixtures;
497mod membership_defaults;
498mod meta;
499mod metrics;
500mod model_type;
501mod named_acl_gates;
502mod network_fixtures;
503mod newtype_styles;
504mod node_endpoints;
505mod object_ops;
506mod object_store_config;
507mod object_store_delegate;
508mod otlp_exporters;
509mod prelude;
510mod primitive_cmp;
511mod produce_fixtures;
512mod projection_identity;
513mod raft_fixtures;
514mod refined_newtype;
515mod remote_metadata_fixtures;
516mod remote_operation;
517mod replay_member_maps;
518mod response_encoding;
519mod runtime_assignments;
520mod runtime_overlay;
521mod runtime_policy_fields;
522mod s3_fields;
523mod sendfile_cfg;
524mod sendfile_match;
525mod share_state_handler;
526mod share_state_value;
527mod sparse_index;
528mod throttle_probes;
529mod timer_hooks;
530mod timestamped_batch;
531mod topic_filter;
532mod transport_errors;
533mod value_framing;
534mod voter_admission;
535mod wire_codec_helpers;
536mod wire_codes;
537mod wire_fixtures;
538mod wire_state_batch;
539mod wire_values;
540mod worm_object_set;
541
542/// Append the shared topic, topic-id and partition setters of Produce fixtures.
543#[moxy::attribute]
544pub fn share_produce_parameters(
545    meta: TokenStream,
546    item: TokenStream,
547) -> Result<TokenStream, ParseError> {
548    wire_fixtures::share_produce_parameters(meta, item)
549}
550
551/// Share sparse-window and nonnegative base/floor preconditions between timestamp kernels.
552#[moxy::attribute]
553pub fn retained_timestamp_bounds(
554    floor: TokenStream,
555    item: NativeTokenStream,
556) -> Result<NativeTokenStream, ParseError> {
557    let expanded = wire_fixtures::retained_timestamp_bounds(floor, item.into())?;
558    // Creusot captures and MIR bindings must share one identifier context.
559    Ok(expanded
560        .to_string()
561        .parse()
562        .expect("valid timestamp bounds expansion"))
563}
564
565/// Derives `unregistered` and `register` for a struct of metric handles. The
566/// crate documentation lists the field attributes.
567#[moxy::derive(RegisterMetrics, attributes(metric))]
568pub fn register_metrics(item: ItemStruct) -> Result<TokenStream, ParseError> {
569    metrics::expand(item)
570}
571
572// Keep implementations in their own modules and document each adapter below.
573
574/// Give a scalar id transparent JSON, primitive comparisons and integer conversions.
575#[moxy::attribute]
576pub fn scalar_id(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
577    newtype_styles::scalar_id(meta, item)
578}
579
580/// Gives a test scalar the shared display, conversion, value, and default traits.
581#[moxy::attribute]
582pub fn test_scalar(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
583    newtype_styles::test_scalar(meta, item)
584}
585
586/// Share the lowercase hex display and serde identity of byte newtypes.
587#[moxy::attribute]
588pub fn hex_bytes_identity(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
589    newtype_styles::hex_bytes_identity(meta, item)
590}
591
592/// Gives every `Option<Time>`, `Option<ByteSize>` and `Option<Ratio>` field of
593/// a file-config struct its human-unit serde codec and schema marker. The
594/// crate documentation describes the expansion.
595#[moxy::attribute(name = "human_units")]
596pub fn human_units(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
597    human_units::expand(meta, item)
598}
599
600/// Derives `new`, a getter, and optionally `Default`, `FromStr`, `Display`, a
601/// free parse function and whole-unit quantity conversions for a tuple newtype
602/// over a `refined_type` rule. The crate documentation lists the
603/// `#[refined(...)]` arguments.
604#[moxy::derive(RefinedNewtype, attributes(refined))]
605pub fn refined_newtype(item: ItemStruct) -> Result<TokenStream, ParseError> {
606    refined_newtype::expand(item)
607}
608
609/// Derives `PartialEq` and `PartialOrd` in both directions between a tuple
610/// newtype and the type of its one field.
611#[moxy::derive(PrimitiveCmp)]
612pub fn primitive_cmp(item: ItemStruct) -> Result<TokenStream, ParseError> {
613    primitive_cmp::expand(item)
614}
615
616/// Generates the broker's dispatch adapters and `register_dispatch_table`
617/// from one table of api names. The crate documentation describes the table.
618///
619/// # Errors
620///
621/// Rejects input outside this macro's syntax.
622#[cfg_attr(not(test), moxy::function)]
623pub fn dispatch_table(tokens: TokenStream) -> Result<TokenStream, ParseError> {
624    dispatch::expand(tokens)
625}
626
627/// Expands to the throttle-echo audit's `[(API_KEY, Probe); N]` array from one
628/// table of api names. The crate documentation describes the table.
629///
630/// # Errors
631///
632/// Rejects input outside this macro's syntax.
633#[cfg_attr(not(test), moxy::function)]
634pub fn throttle_probes(tokens: TokenStream) -> Result<TokenStream, ParseError> {
635    throttle_probes::expand(tokens)
636}
637
638/// Derives `copy_into`, which copies each field of a clap argument group onto
639/// the same-named field of its `#[overlay(target = Type)]`. The crate
640/// documentation lists the field attributes.
641#[moxy::derive(RuntimeOverlay, attributes(overlay))]
642pub fn runtime_overlay(item: ItemStruct) -> Result<TokenStream, ParseError> {
643    runtime_overlay::expand(item)
644}
645
646/// Gives every field of a clap argument struct without an `#[arg(...)]` a
647/// `--long` flag, a `KRABKA_<FIELD>` environment variable (under another
648/// prefix with `prefix = "..."`), and the value parser its type implies. The
649/// crate documentation lists the types.
650#[moxy::attribute(name = "krabka_env")]
651pub fn krabka_env(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
652    krabka_env::expand(meta, item)
653}
654
655/// Derives `as_str`, and optionally a parse function, `ALL` and
656/// `EncodeLabelValue`, for an enum whose variants each stand for one text.
657/// The crate documentation lists the `#[enum_str(...)]` arguments.
658#[moxy::derive(EnumStr, attributes(enum_str))]
659pub fn enum_str(item: ItemEnum) -> Result<TokenStream, ParseError> { enum_str::expand(item) }
660
661/// Derives `Default` from each field's `#[default(EXPR)]`, or
662/// `Default::default()` for a field without one. The crate documentation
663/// describes the expansion.
664#[moxy::derive(FieldDefaults, attributes(default))]
665pub fn field_defaults(item: ItemStruct) -> Result<TokenStream, ParseError> {
666    field_defaults::expand(item)
667}
668
669/// Derive clamped per-group timings and immediate-assignment test defaults.
670#[moxy::derive(GroupTimingConfig, attributes(group_timing))]
671pub fn group_timing_config(item: ItemStruct) -> Result<TokenStream, ParseError> {
672    group_timing_config::expand(item)
673}
674
675/// Derive group transitions with the selected protocol's existing lifecycle policy.
676#[moxy::derive(GroupLifecycle, attributes(group_lifecycle))]
677pub fn group_lifecycle(item: ItemStruct) -> Result<TokenStream, ParseError> {
678    group_lifecycle::expand(item)
679}
680
681/// Derive display, parsing, and string serde using the caller's Kafka UUID codec.
682#[moxy::derive(KafkaUuid)]
683pub fn kafka_uuid(item: ItemStruct) -> Result<TokenStream, ParseError> { kafka_uuid::expand(item) }
684
685/// Derive the sparse index's existing loader and file operations.
686#[moxy::derive(SparseIndex, attributes(sparse_index))]
687pub fn sparse_index(item: ItemStruct) -> Result<TokenStream, ParseError> {
688    sparse_index::expand(item)
689}
690
691/// Apply the shared index-open tracing span to an ordinary loader method.
692#[moxy::attribute]
693pub fn index_open(
694    meta: NativeTokenStream,
695    item: NativeTokenStream,
696) -> Result<NativeTokenStream, ParseError> {
697    sparse_index::index_open(meta, item)
698}
699
700/// Trace an ordinary remote-storage operation with its segment identity.
701#[moxy::attribute]
702pub fn remote_operation(
703    meta: NativeTokenStream,
704    item: NativeTokenStream,
705) -> Result<NativeTokenStream, ParseError> {
706    remote_operation::expand(meta, item)
707}
708
709/// Attach the selected proof and runtime derives to an ordinary model declaration.
710#[moxy::attribute]
711pub fn model_type(
712    meta: NativeTokenStream,
713    item: NativeTokenStream,
714) -> Result<NativeTokenStream, ParseError> {
715    model_type::expand(meta, item)
716}
717
718/// Keep an ordinary item on the platforms supported by the sendfile fetch path.
719#[moxy::attribute]
720pub fn sendfile_cfg(
721    meta: NativeTokenStream,
722    item: NativeTokenStream,
723) -> Result<NativeTokenStream, ParseError> {
724    sendfile_cfg::expand(meta, item)
725}
726
727/// Decode the selected request before an ordinary raw dispatch function's body.
728#[moxy::attribute]
729pub fn decode_dispatch(
730    meta: NativeTokenStream,
731    item: NativeTokenStream,
732) -> Result<NativeTokenStream, ParseError> {
733    decode_dispatch::expand(&meta.into(), item)
734}
735
736/// Decode a request using bracketed metadata after the function parameters.
737#[moxy::function]
738pub fn decoded_dispatch(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
739    decode_dispatch::expand_function(tokens)
740}
741
742/// Emit the ordered WORM object-set rule around an explicit runtime or proof header.
743#[moxy::function]
744pub fn worm_object_set(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
745    worm_object_set::expand(tokens)
746}
747
748/// Adapt an explicitly typed extension operation to its decoded and traced raw entry point.
749#[moxy::attribute]
750pub fn extension_wire(
751    meta: NativeTokenStream,
752    item: NativeTokenStream,
753) -> Result<NativeTokenStream, ParseError> {
754    extension_wire::expand(&meta.into(), item)
755}
756
757/// Derive the controller adapter's three background-task trait implementations.
758/// The struct has `handle` and `node_id` fields, plus `holds_leadership` and
759/// `submit` methods. The derive delegates to the existing metadata source.
760#[moxy::derive(BackgroundControllers)]
761pub fn background_controllers(item: ItemStruct) -> Result<TokenStream, ParseError> {
762    background_controllers::expand(item)
763}
764
765/// Apply the existing retry and client options to an object-store builder expression.
766/// Accepts `connection_policy!(builder_expression, config_identifier)` and uses
767/// the caller's `retry_config`, `client_options`, and `ClientOptions` helpers.
768#[moxy::function]
769pub fn connection_policy(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
770    connection_policy::expand(tokens)
771}
772
773/// Declare wire constants and their ordered release, trunk, and private guard tables.
774/// Accepts `release TABLE { NAME = -1; } trunk TABLE { ... } private TABLE { ... }`.
775/// Each section emits public i16 constants and a private test-only `NamedCode` table.
776#[moxy::function]
777pub fn wire_codes(tokens: NativeTokenStream) -> Result<TokenStream, ParseError> {
778    wire_codes::expand(&tokens.into())
779}
780
781/// Implement transport selection for a typed OTLP exporter method declaration.
782/// Accepts an ordinary `fn method(&self) -> Result<SpanExporter, TelemetryError>;`
783/// declaration, or the same signature with `LogExporter`, inside `OtlpConfig`.
784#[moxy::function]
785pub fn otlp_exporter(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
786    otlp_exporters::expand(tokens)
787}
788
789/// Emit fixed ACL gates from `name: Group(operation, parameter)` or
790/// `name: Cluster(operation)` declarations, using the caller's audited ACL helper.
791#[moxy::function]
792pub fn named_acl_gates(tokens: NativeTokenStream) -> Result<TokenStream, ParseError> {
793    named_acl_gates::expand(&tokens.into())
794}
795
796/// Supply `Allow` or `Deny` to the shared topic-selection helper while keeping
797/// the function's five parameter types and names explicit.
798#[moxy::attribute]
799pub fn topic_filter(
800    meta: NativeTokenStream,
801    item: NativeTokenStream,
802) -> Result<NativeTokenStream, ParseError> {
803    topic_filter::expand(meta.into(), item)
804}
805
806/// Emit explicit request/response codec and context helper declarations directly.
807/// For example: `encode_request(Request); decode_response(Response); test_context ["test"];`.
808/// Add `version [EXPR];` to pin the codecs, or omit it to accept a version per call.
809#[moxy::function]
810pub fn wire_codec_helpers(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
811    wire_codec_helpers::expand(tokens)
812}
813
814/// Derive endpoint projections into the wire types listed by `node_endpoints(targets(...))`.
815#[moxy::derive(NodeEndpoints, attributes(node_endpoints))]
816pub fn node_endpoints(item: ItemStruct) -> Result<TokenStream, ParseError> {
817    node_endpoints::expand(item)
818}
819
820/// Derive read/write share-state batch conversions with their existing ownership directions.
821/// `#[wire_state_batch(read = ReadBatch, write = WriteBatch)]` selects both target types.
822#[moxy::derive(WireStateBatch, attributes(wire_state_batch))]
823pub fn wire_state_batch(item: ItemStruct) -> Result<TokenStream, ParseError> {
824    wire_state_batch::expand(item)
825}
826
827/// Derive member-map replay methods for the selected consumer, share, or streams protocol.
828/// Select the protocol with `#[replay_member_maps(protocol = "consumer")]`, `"share"`, or `"streams"`.
829#[moxy::derive(ReplayMemberMaps, attributes(replay_member_maps))]
830pub fn replay_member_maps(item: ItemStruct) -> Result<TokenStream, ParseError> {
831    replay_member_maps::expand(item)
832}
833
834/// Add flexible value framing around explicitly ordered private field codecs.
835#[moxy::attribute]
836pub fn flexible_value(
837    meta: NativeTokenStream,
838    item: NativeTokenStream,
839) -> Result<NativeTokenStream, ParseError> {
840    flexible_value::expand(&meta.into(), item)
841}
842
843/// Add the shared timing defaults before `FieldDefaults` derives the config constructor.
844#[moxy::attribute]
845pub fn membership_defaults(
846    meta: TokenStream,
847    item: TokenStream,
848) -> Result<TokenStream, ParseError> {
849    membership_defaults::expand(meta, item)
850}
851
852/// Derive the version-zero epoch codec with an optional i64 value in tag zero.
853#[moxy::derive(FlexibleEpochValue, attributes(epoch_value))]
854pub fn flexible_epoch_value(item: ItemStruct) -> Result<TokenStream, ParseError> {
855    flexible_epoch_value::expand(item)
856}
857
858/// Derive the existing share-state value codecs from their ordered fields.
859#[moxy::derive(ShareStateValue, attributes(share_state))]
860pub fn share_state_value(item: ItemStruct) -> Result<TokenStream, ParseError> {
861    share_state_value::expand(item)
862}
863
864/// Derive version-zero framing around one array field's existing leaf codecs.
865#[moxy::derive(FlexibleArrayValue, attributes(array_value))]
866pub fn flexible_array_value(item: ItemStruct) -> Result<TokenStream, ParseError> {
867    flexible_array_value::expand(item)
868}
869
870/// Implement the shared error traits for external protocol response and row types.
871#[moxy::function]
872pub fn response_errors(tokens: NativeTokenStream) -> Result<TokenStream, ParseError> {
873    response_encoding::expand(&tokens.into())
874}
875
876/// Check share-state admission and construct denial rows in request order.
877#[moxy::function]
878pub fn share_state_handler(tokens: NativeTokenStream) -> Result<TokenStream, ParseError> {
879    share_state_handler::expand(&tokens.into())
880}
881
882/// Run voter admission before the explicit handler's operation body.
883#[moxy::attribute]
884pub fn voter_admission(
885    meta: NativeTokenStream,
886    item: NativeTokenStream,
887) -> Result<NativeTokenStream, ParseError> {
888    voter_admission::expand(meta, item)
889}
890
891/// Generate the flat broker configuration declaration with its shared derives.
892#[moxy::function]
893pub fn broker_config(tokens: NativeTokenStream) -> Result<TokenStream, ParseError> {
894    broker_config::expand(&tokens.into())
895}
896
897/// Construct an exhaustive wire value with an empty tagged-field set.
898#[moxy::function]
899pub fn tagged_wire(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
900    wire_values::expand_native(tokens, false)
901}
902
903/// Construct an exhaustive response with zero throttle and empty tagged fields.
904#[moxy::function]
905pub fn unthrottled_wire(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
906    wire_values::expand_native(tokens, true)
907}
908
909/// Apply optional runtime fields in table order through their named validators.
910#[moxy::function]
911pub fn set_runtime(tokens: NativeTokenStream) -> Result<TokenStream, ParseError> {
912    runtime_assignments::expand(&tokens.into())
913}
914
915/// Expands to an operator binary's `main`: tracing setup, then
916/// `std::process::exit` with what the named crate's `run_from_args` returns.
917/// The crate documentation describes the expansion.
918///
919/// # Errors
920///
921/// Rejects input outside this macro's syntax.
922#[cfg_attr(not(test), moxy::function)]
923pub fn cli_main(tokens: TokenStream) -> Result<TokenStream, ParseError> { cli_main::expand(tokens) }
924
925/// Generate the bounded exhaustive Stateright runner under the supplied function name.
926///
927/// # Errors
928///
929/// Rejects input outside this macro's syntax.
930#[cfg_attr(not(test), moxy::function)]
931pub fn bounded_bfs(tokens: TokenStream) -> Result<TokenStream, ParseError> {
932    fixtures::bounded_bfs(tokens)
933}
934
935/// Generate the single-topic delete request fixture with a five-second timeout.
936///
937/// # Errors
938///
939/// Rejects input outside this macro's syntax.
940#[cfg_attr(not(test), moxy::function)]
941pub fn delete_topic_request(tokens: TokenStream) -> Result<TokenStream, ParseError> {
942    fixtures::delete_topic_request(tokens)
943}
944
945/// Generate the compacted-batch test projection under the supplied struct name.
946///
947/// # Errors
948///
949/// Rejects input outside this macro's syntax.
950#[cfg_attr(not(test), moxy::function)]
951pub fn compacted_batch(tokens: TokenStream) -> Result<TokenStream, ParseError> {
952    fixtures::compacted_batch(tokens)
953}
954
955/// Generate the benchmark's Kafka record-batch builder under the supplied function name.
956///
957/// # Errors
958///
959/// Rejects input outside this macro's syntax.
960#[cfg_attr(not(test), moxy::function)]
961pub fn record_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
962    fixtures::record_batch(tokens)
963}
964
965/// Prepend the common bucket, prefix, redacted credentials and endpoint fields to a GCS config.
966/// Select `file` or `runtime` to preserve that configuration's field documentation.
967#[moxy::attribute(name = "gcs_fields")]
968pub fn gcs_fields(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
969    gcs_fields::expand(meta, item)
970}
971
972/// Generate action-to-message/log/timer adaptation inside a simulation impl.
973///
974/// # Errors
975///
976/// Rejects input outside this macro's syntax.
977#[cfg_attr(not(test), moxy::function)]
978pub fn simulation_actions(tokens: TokenStream) -> Result<TokenStream, ParseError> {
979    fixtures::simulation_actions(tokens)
980}
981/// Generate the shared simulation bus routing and replication preconditions.
982///
983/// # Errors
984///
985/// Rejects input outside this macro's syntax.
986#[cfg_attr(not(test), moxy::function)]
987pub fn simulation_transport(tokens: TokenStream) -> Result<TokenStream, ParseError> {
988    fixtures::simulation_transport(tokens)
989}
990/// Generate simulation leader heartbeats with the caller's interval.
991///
992/// # Errors
993///
994/// Rejects input outside this macro's syntax.
995#[cfg_attr(not(test), moxy::function)]
996pub fn simulation_heartbeat(tokens: TokenStream) -> Result<TokenStream, ParseError> {
997    fixtures::simulation_heartbeat(tokens)
998}
999/// Generate a saturating CI benchmark scenario with a caller-supplied name and size.
1000///
1001/// # Errors
1002///
1003/// Rejects input outside this macro's syntax.
1004#[cfg_attr(not(test), moxy::function)]
1005pub fn benchmark_scenario_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1006    fixtures::benchmark_scenario(tokens)
1007}
1008
1009/// Generate the benchmark report's representative latency percentiles.
1010///
1011/// # Errors
1012///
1013/// Rejects input outside this macro's syntax.
1014#[cfg_attr(not(test), moxy::function)]
1015pub fn benchmark_latency_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1016    fixtures::benchmark_latency(tokens)
1017}
1018
1019/// Generate the synthetic S3 archive config used by argument-mapping assertions.
1020///
1021/// # Errors
1022///
1023/// Rejects input outside this macro's syntax.
1024#[cfg_attr(not(test), moxy::function)]
1025pub fn s3_archive_config_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1026    fixtures::s3_archive_config(tokens)
1027}
1028
1029/// Delegate unchanged metadata-log operations through `self.inner`, before `async_trait`.
1030#[moxy::attribute(name = "metadata_log_delegate")]
1031pub fn metadata_log_delegate(
1032    meta: TokenStream,
1033    item: TokenStream,
1034) -> Result<TokenStream, ParseError> {
1035    fixtures::metadata_log_delegate(meta, item)
1036}
1037
1038/// Generate the finished remote-segment lookup assertions shared by manager fixtures.
1039///
1040/// # Errors
1041///
1042/// Rejects input outside this macro's syntax.
1043#[cfg_attr(not(test), moxy::function)]
1044pub fn remote_segment_check(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1045    fixtures::remote_segment_check(tokens)
1046}
1047
1048/// Add the shared runtime policy fields before TOML or CLI field derives.
1049#[moxy::attribute(name = "runtime_policy_fields")]
1050pub fn runtime_policy_fields(
1051    meta: TokenStream,
1052    item: TokenStream,
1053) -> Result<TokenStream, ParseError> {
1054    runtime_policy_fields::expand(meta, item)
1055}
1056
1057/// Generate the shared simulation event adapter inside a harness impl.
1058///
1059/// # Errors
1060///
1061/// Rejects input outside this macro's syntax.
1062#[cfg_attr(not(test), moxy::function)]
1063pub fn simulation_step(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1064    fixtures::simulation_step(tokens)
1065}
1066
1067/// Generate the shared two-partition metadata topic fixture.
1068///
1069/// # Errors
1070///
1071/// Rejects input outside this macro's syntax.
1072#[cfg_attr(not(test), moxy::function)]
1073pub fn snapshot_topic_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1074    fixtures::snapshot_topic(tokens)
1075}
1076
1077/// Generate the timestamped record-batch fixture used by local and remote read tests.
1078///
1079/// # Errors
1080///
1081/// Rejects input outside this macro's syntax.
1082#[cfg_attr(not(test), moxy::function)]
1083pub fn timestamped_batch(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1084    timestamped_batch::expand(tokens)
1085}
1086
1087/// Generate a producer batch builder with the caller's exact record value expression.
1088///
1089/// # Errors
1090///
1091/// Rejects input outside this macro's syntax.
1092#[cfg_attr(not(test), moxy::function)]
1093pub fn producer_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1094    wire_fixtures::producer_batch(tokens)
1095}
1096
1097/// Generate a one-topic `CreateTopics` request builder with explicit sizes and timeout.
1098///
1099/// # Errors
1100///
1101/// Rejects input outside this macro's syntax.
1102#[cfg_attr(not(test), moxy::function)]
1103pub fn create_topic_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1104    wire_fixtures::create_topic(tokens)
1105}
1106
1107/// Generate the consumer Fetch request fixture for partition zero with a 1 MiB limit.
1108///
1109/// # Errors
1110///
1111/// Rejects input outside this macro's syntax.
1112#[cfg_attr(not(test), moxy::function)]
1113pub fn consumer_fetch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1114    wire_fixtures::consumer_fetch(tokens)
1115}
1116
1117/// Generate the initial single-replica metadata partition record builder.
1118///
1119/// # Errors
1120///
1121/// Rejects input outside this macro's syntax.
1122#[cfg_attr(not(test), moxy::function)]
1123pub fn single_replica_partition_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1124    wire_fixtures::single_replica_partition(tokens)
1125}
1126
1127/// Generate the version-zero control-marker key and value fixture encoders.
1128///
1129/// # Errors
1130///
1131/// Rejects input outside this macro's syntax.
1132#[cfg_attr(not(test), moxy::function)]
1133pub fn control_marker_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1134    wire_fixtures::control_marker(tokens)
1135}
1136
1137/// Generate a topic record builder for one partition and one replica.
1138///
1139/// # Errors
1140///
1141/// Rejects input outside this macro's syntax.
1142#[cfg_attr(not(test), moxy::function)]
1143pub fn topic_record_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1144    wire_fixtures::topic_record(tokens)
1145}
1146
1147/// Generate the loopback ephemeral-port helper used by container tests.
1148///
1149/// # Errors
1150///
1151/// Rejects input outside this macro's syntax.
1152#[cfg_attr(not(test), moxy::function)]
1153pub fn ephemeral_port_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1154    wire_fixtures::ephemeral_port(tokens)
1155}
1156
1157/// Generate projection-based Eq and Hash, and optionally Debug, for model state.
1158///
1159/// # Errors
1160///
1161/// Rejects input outside this macro's syntax.
1162#[cfg_attr(not(test), moxy::function)]
1163pub fn projection_identity(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1164    projection_identity::expand(tokens)
1165}
1166
1167/// Generate the shared `MinIO` process/readiness helpers under the supplied module name.
1168///
1169/// # Errors
1170///
1171/// Rejects input outside this macro's syntax.
1172#[cfg_attr(not(test), moxy::function)]
1173pub fn minio_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1174    container_fixtures::expand(tokens)
1175}
1176
1177/// Start a SCRAM client exchange while preserving its private handshake phase type.
1178///
1179/// # Errors
1180///
1181/// Rejects input outside this macro's syntax.
1182#[cfg_attr(not(test), moxy::function)]
1183pub fn scram_client_first(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1184    auth_fixtures::scram_client_first(tokens)
1185}
1186
1187/// Generate the independent four-state remote-segment transition oracle.
1188///
1189/// # Errors
1190///
1191/// Rejects input outside this macro's syntax.
1192#[cfg_attr(not(test), moxy::function)]
1193pub fn remote_segment_transition_matrix(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1194    fixtures::remote_segment_transition_matrix(tokens)
1195}
1196
1197/// Generate a tracing capture layer with an explicit mutex poison policy.
1198///
1199/// # Errors
1200///
1201/// Rejects input outside this macro's syntax.
1202#[cfg_attr(not(test), moxy::function)]
1203pub fn capture_layer_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1204    fixtures::capture_layer(tokens)
1205}
1206
1207/// Add the selected direct `ObjectStore` delegates to an implementation.
1208#[moxy::attribute(name = "object_store_delegate")]
1209pub fn object_store_delegate(
1210    meta: TokenStream,
1211    item: TokenStream,
1212) -> Result<TokenStream, ParseError> {
1213    object_store_delegate::expand(meta, item)
1214}
1215
1216/// Generate remote metadata lifecycle fixtures with an explicit timestamp policy.
1217///
1218/// # Errors
1219///
1220/// Rejects input outside this macro's syntax.
1221#[cfg_attr(not(test), moxy::function)]
1222pub fn remote_segment_fixtures(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1223    remote_metadata_fixtures::segment(tokens)
1224}
1225
1226/// Generate the independent missing-partition metadata assertions.
1227///
1228/// # Errors
1229///
1230/// Rejects input outside this macro's syntax.
1231#[cfg_attr(not(test), moxy::function)]
1232pub fn remote_metadata_missing(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1233    remote_metadata_fixtures::missing(tokens)
1234}
1235
1236/// Generate the direct flush and shutdown delegates for a tuple write wrapper.
1237///
1238/// # Errors
1239///
1240/// Rejects input outside this macro's syntax.
1241#[cfg_attr(not(test), moxy::function)]
1242pub fn async_write_delegate(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1243    async_write_delegate::expand(tokens)
1244}
1245
1246/// Generate a model transition's signature and cloned state before its body.
1247#[moxy::function(name = "model_transition")]
1248pub fn model_transition(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1249    fixtures::model_transition(tokens)
1250}
1251
1252/// Append the shared object-store retry and HTTP timeout fields.
1253#[moxy::attribute(name = "object_store_config")]
1254pub fn object_store_config(
1255    meta: TokenStream,
1256    item: TokenStream,
1257) -> Result<TokenStream, ParseError> {
1258    object_store_config::expand(meta, item)
1259}
1260
1261/// Expand the object-store file-upload method before async trait processing.
1262#[moxy::attribute(name = "object_ops")]
1263pub fn object_ops(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1264    object_ops::expand(meta, item)
1265}
1266
1267/// Match inline writes and conditionally available sendfile regions.
1268#[moxy::function(name = "sendfile_match")]
1269pub fn sendfile_match(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1270    sendfile_match::expand_native(tokens)
1271}
1272
1273/// Generate timer registration and completion helpers with caller-specific messages.
1274///
1275/// # Errors
1276///
1277/// Rejects input outside this macro's syntax.
1278#[cfg_attr(not(test), moxy::function)]
1279pub fn timer_hooks(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1280    timer_hooks::expand(tokens)
1281}
1282
1283/// Generate the SCRAM proof XOR fixture without imposing extra length checks.
1284///
1285/// # Errors
1286///
1287/// Rejects input outside this macro's syntax.
1288#[cfg_attr(not(test), moxy::function)]
1289pub fn scram_client_proof_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1290    auth_fixtures::scram_client_proof(tokens)
1291}
1292
1293/// Generate a single-partition Produce fixture with explicit request settings.
1294///
1295/// # Errors
1296///
1297/// Rejects input outside this macro's syntax.
1298#[cfg_attr(not(test), moxy::function)]
1299pub fn single_partition_produce_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1300    produce_fixtures::single_partition_produce(tokens)
1301}
1302
1303/// Generate a manual Kafka request-frame fixture with explicit header inputs.
1304///
1305/// # Errors
1306///
1307/// Rejects input outside this macro's syntax.
1308#[cfg_attr(not(test), moxy::function)]
1309pub fn request_frame_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1310    network_fixtures::request_frame(tokens)
1311}
1312
1313/// Generate deterministic patterned bytes for framing tests and benchmarks.
1314///
1315/// # Errors
1316///
1317/// Rejects input outside this macro's syntax.
1318#[cfg_attr(not(test), moxy::function)]
1319pub fn patterned_bytes_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1320    network_fixtures::patterned_bytes(tokens)
1321}
1322
1323/// Generate the distinctive proposal UUID shared by signing golden fixtures.
1324///
1325/// # Errors
1326///
1327/// Rejects input outside this macro's syntax.
1328#[cfg_attr(not(test), moxy::function)]
1329pub fn break_glass_golden_id(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1330    network_fixtures::break_glass_golden_id(tokens)
1331}
1332
1333/// Literal Kafka 4.3.1 principal bytes: alice or bob, token flag.
1334///
1335/// # Errors
1336///
1337/// Rejects input outside this macro's syntax.
1338#[cfg_attr(not(test), moxy::function)]
1339pub fn jvm_principal_golden(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1340    network_fixtures::jvm_principal_golden(tokens)
1341}
1342
1343/// Generate a response frame prefix independently of production framing.
1344///
1345/// # Errors
1346///
1347/// Rejects input outside this macro's syntax.
1348#[cfg_attr(not(test), moxy::function)]
1349pub fn frame_prefix_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1350    network_fixtures::frame_prefix(tokens)
1351}
1352
1353/// Generate the independent file-region byte reader used by wire comparisons.
1354///
1355/// # Errors
1356///
1357/// Rejects input outside this macro's syntax.
1358#[cfg_attr(not(test), moxy::function)]
1359pub fn file_region_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1360    network_fixtures::file_region(tokens)
1361}
1362
1363/// Expand the common I/O, TLS and SASL error variants at their original position.
1364#[moxy::attribute(name = "transport_errors")]
1365pub fn transport_errors(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1366    transport_errors::expand(meta, item)
1367}
1368
1369/// Generate a voter-set fixture whose endpoints and directory IDs remain empty.
1370///
1371/// # Errors
1372///
1373/// Rejects input outside this macro's syntax.
1374#[cfg_attr(not(test), moxy::function)]
1375pub fn empty_endpoint_voters(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1376    raft_fixtures::empty_endpoint_voters(tokens)
1377}
1378
1379/// Generate the one-record leader-epoch batch fixture.
1380///
1381/// # Errors
1382///
1383/// Rejects input outside this macro's syntax.
1384#[cfg_attr(not(test), moxy::function)]
1385pub fn epoch_record_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1386    raft_fixtures::epoch_record_batch(tokens)
1387}
1388
1389/// Generate the epoch-cache `LogView` delegation used by Raft simulations.
1390///
1391/// # Errors
1392///
1393/// Rejects input outside this macro's syntax.
1394#[cfg_attr(not(test), moxy::function)]
1395pub fn epoch_log_view(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1396    raft_fixtures::epoch_log_view(tokens)
1397}
1398
1399/// Derive a TOML table's schema and value traits with an explicit unknown-key policy.
1400#[moxy::attribute(name = "config_table")]
1401pub fn config_table(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1402    config_table::expand(meta, item)
1403}
1404
1405/// Match record payloads with file-region arms only on supported platforms.
1406#[moxy::function(name = "records_payload_match")]
1407pub fn records_payload_match(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1408    sendfile_match::records_payload_native(tokens)
1409}
1410
1411/// Generate the canonical compressed legacy record used by policy tests.
1412///
1413/// # Errors
1414///
1415/// Rejects input outside this macro's syntax.
1416#[cfg_attr(not(test), moxy::function)]
1417pub fn legacy_policy_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1418    legacy_fixtures::policy(tokens)
1419}
1420
1421/// Generate keyed fixture records with explicit count and value size.
1422///
1423/// # Errors
1424///
1425/// Rejects input outside this macro's syntax.
1426#[cfg_attr(not(test), moxy::function)]
1427pub fn keyed_record_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1428    network_fixtures::keyed_record_batch(tokens)
1429}
1430
1431/// Add the shared generic argv signature to a command-line entry point.
1432#[moxy::attribute(name = "argv_entrypoint")]
1433pub fn argv_entrypoint(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1434    cli_support::argv_entrypoint(meta, item)
1435}
1436
1437/// Add bootstrap-server and subcommand fields before deriving a CLI parser.
1438#[moxy::attribute(name = "bootstrap_cli_fields")]
1439pub fn bootstrap_cli_fields(
1440    meta: TokenStream,
1441    item: TokenStream,
1442) -> Result<TokenStream, ParseError> {
1443    cli_support::bootstrap_cli_fields(meta, item)
1444}
1445
1446/// Generate a duration-parser check over each caller's literal cases.
1447///
1448/// # Errors
1449///
1450/// Rejects input outside this macro's syntax.
1451#[cfg_attr(not(test), moxy::function)]
1452pub fn duration_cases_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1453    cli_support::duration_cases(tokens)
1454}
1455
1456/// Generate a sorted directory-tree fixture with the caller's path projection.
1457///
1458/// # Errors
1459///
1460/// Rejects input outside this macro's syntax.
1461#[cfg_attr(not(test), moxy::function)]
1462pub fn directory_tree_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1463    cli_support::directory_tree(tokens)
1464}
1465
1466/// Generate a CLI entry point with the caller's documentation.
1467///
1468/// # Errors
1469///
1470/// Rejects input outside this macro's syntax.
1471#[cfg_attr(not(test), moxy::function)]
1472pub fn parsed_cli_entrypoint(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1473    cli_support::parsed_cli_entrypoint(tokens)
1474}
1475
1476/// Generate a duration-parser test from explicit literal cases.
1477///
1478/// # Errors
1479///
1480/// Rejects input outside this macro's syntax.
1481#[cfg_attr(not(test), moxy::function)]
1482pub fn duration_parser_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1483    cli_support::duration_parser_fixture(tokens)
1484}
1485
1486/// Generate bootstrap parser tests from accepted and refused arguments.
1487///
1488/// # Errors
1489///
1490/// Rejects input outside this macro's syntax.
1491#[cfg_attr(not(test), moxy::function)]
1492pub fn bootstrap_parser_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1493    cli_support::bootstrap_parser_fixture(tokens)
1494}
1495
1496/// Generate the shared snapshot fixture over an on-disk metadata log.
1497///
1498/// # Errors
1499///
1500/// Rejects input outside this macro's syntax.
1501#[cfg_attr(not(test), moxy::function)]
1502pub fn snapshot_node_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1503    cli_support::snapshot_node_fixture(tokens)
1504}
1505
1506/// Connect a CLI client with the caller's identity and refusal exit code.
1507///
1508/// # Errors
1509///
1510/// Rejects input outside this macro's syntax.
1511#[cfg_attr(not(test), moxy::function)]
1512pub fn connect_cli_client(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1513    cli_support::connect_cli_client(tokens)
1514}
1515
1516/// Generate the temporary metadata and data directories used by format tests.
1517///
1518/// # Errors
1519///
1520/// Rejects input outside this macro's syntax.
1521#[cfg_attr(not(test), moxy::function)]
1522pub fn format_directories_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1523    cli_support::format_directories_fixture(tokens)
1524}
1525
1526/// Generate the explicit topic map used by WAL capture fixtures.
1527///
1528/// # Errors
1529///
1530/// Rejects input outside this macro's syntax.
1531#[cfg_attr(not(test), moxy::function)]
1532pub fn wal_capture_topic_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1533    remote_metadata_fixtures::wal_capture_topic_fixture(tokens)
1534}
1535
1536/// Generate a CLI flag's name, environment and default-value projection.
1537///
1538/// # Errors
1539///
1540/// Rejects input outside this macro's syntax.
1541#[cfg_attr(not(test), moxy::function)]
1542pub fn flag_metadata_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1543    cli_support::flag_metadata_fixture(tokens)
1544}
1545
1546/// Generate a listener bind retry with an explicit caller timeout.
1547///
1548/// # Errors
1549///
1550/// Rejects input outside this macro's syntax.
1551#[cfg_attr(not(test), moxy::function)]
1552pub fn bind_retry_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1553    cli_support::bind_retry_fixture(tokens)
1554}
1555
1556/// Generate bound-listener configuration or startup with the caller's diagnostics.
1557///
1558/// # Errors
1559///
1560/// Rejects input outside this macro's syntax.
1561#[cfg_attr(not(test), moxy::function)]
1562pub fn bound_start_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1563    bound_start_fixture::expand(tokens)
1564}
1565
1566/// Generate directory-assignment requests with explicit broker and partition identities.
1567///
1568/// # Errors
1569///
1570/// Rejects input outside this macro's syntax.
1571#[cfg_attr(not(test), moxy::function)]
1572pub fn assignment_dirs_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1573    bound_start_fixture::assignment_dirs(tokens)
1574}
1575
1576/// Render a metric registry into caller-named bindings while retaining its lock guard.
1577///
1578/// # Errors
1579///
1580/// Rejects input outside this macro's syntax.
1581#[cfg_attr(not(test), moxy::function)]
1582pub fn metric_registry_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1583    bound_start_fixture::metric_registry(tokens)
1584}
1585
1586/// Generate indexed WORM segment metadata with an explicit segment-id namespace.
1587///
1588/// # Errors
1589///
1590/// Rejects input outside this macro's syntax.
1591#[cfg_attr(not(test), moxy::function)]
1592pub fn worm_segment_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1593    remote_metadata_fixtures::worm_segment(tokens)
1594}
1595
1596/// Generate the started remote-segment fixture with an explicit metadata crate.
1597///
1598/// # Errors
1599///
1600/// Rejects input outside this macro's syntax.
1601#[cfg_attr(not(test), moxy::function)]
1602pub fn remote_started_segment(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1603    remote_metadata_fixtures::remote_started_segment(tokens)
1604}
1605
1606/// Generate a SCRAM user request preserving optional and ordered user lists.
1607///
1608/// # Errors
1609///
1610/// Rejects input outside this macro's syntax.
1611#[cfg_attr(not(test), moxy::function)]
1612pub fn scram_users_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1613    bound_start_fixture::scram_users(tokens)
1614}
1615
1616/// Generate the first matching record header decoder with an explicit UTF-8 policy.
1617///
1618/// # Errors
1619///
1620/// Rejects input outside this macro's syntax.
1621#[cfg_attr(not(test), moxy::function)]
1622pub fn record_header_text(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1623    fixtures::record_header_text(tokens)
1624}
1625
1626/// Generate the shared dead-letter metric observations with caller-selected types.
1627///
1628/// # Errors
1629///
1630/// Rejects input outside this macro's syntax.
1631#[cfg_attr(not(test), moxy::function)]
1632pub fn share_dlq_meters(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1633    fixtures::share_dlq_meters(tokens)
1634}
1635
1636/// Generate exported segment paths with an explicit snapshot and lazy epoch projection.
1637///
1638/// # Errors
1639///
1640/// Rejects input outside this macro's syntax.
1641#[cfg_attr(not(test), moxy::function)]
1642pub fn export_segment_data_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1643    network_fixtures::export_segment_data(tokens)
1644}
1645
1646/// Keep partition-spawn wrappers on one shared parameter list.
1647#[moxy::attribute(name = "partition_spawn_parameters")]
1648pub fn partition_spawn_parameters(
1649    meta: TokenStream,
1650    item: NativeTokenStream,
1651) -> Result<NativeTokenStream, ParseError> {
1652    network_fixtures::partition_spawn_parameters(meta, item)
1653}
1654
1655/// Generate a checkpoint writer with a caller-selected failure kind.
1656///
1657/// # Errors
1658///
1659/// Rejects input outside this macro's syntax.
1660#[cfg_attr(not(test), moxy::function)]
1661pub fn epoch_checkpoint_failure(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1662    network_fixtures::epoch_checkpoint_failure(tokens)
1663}
1664
1665/// Generate a JVM checkpoint decoder fixture with explicit bytes, name and image.
1666///
1667/// # Errors
1668///
1669/// Rejects input outside this macro's syntax.
1670#[cfg_attr(not(test), moxy::function)]
1671pub fn jvm_checkpoint_dump_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1672    network_fixtures::jvm_checkpoint_dump(tokens)
1673}
1674
1675/// Compose a compile-time Java string-producer probe with shared imports and setup.
1676///
1677/// # Errors
1678///
1679/// Rejects input outside this macro's syntax.
1680#[cfg_attr(not(test), moxy::function)]
1681pub fn java_string_producer_source(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1682    network_fixtures::java_string_producer(tokens)
1683}
1684
1685/// Define a wall-clock reader preserving caller attributes and overflow behavior.
1686///
1687/// # Errors
1688///
1689/// Rejects input outside this macro's syntax.
1690#[cfg_attr(not(test), moxy::function)]
1691pub fn epoch_millis_fn(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1692    network_fixtures::epoch_millis(tokens)
1693}
1694
1695/// Gate original items or expressions on the supported sendfile platforms.
1696#[moxy::function(name = "sendfile_platform")]
1697#[expect(
1698    clippy::unnecessary_wraps,
1699    reason = "Moxy's proc_macro adapter requires a Result-returning entry point"
1700)]
1701pub fn sendfile_platform(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1702    Ok(network_fixtures::sendfile_platform(tokens))
1703}
1704
1705/// Generate a test authorizer while retaining the original policy body tokens.
1706#[moxy::function(name = "test_authorizer")]
1707pub fn test_authorizer(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1708    network_fixtures::test_authorizer(tokens)
1709}
1710
1711/// Generate checked Unix-millisecond fixtures with explicit panic contexts.
1712///
1713/// # Errors
1714///
1715/// Rejects input outside this macro's syntax.
1716#[cfg_attr(not(test), moxy::function)]
1717pub fn unix_millis_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1718    bound_start_fixture::unix_millis(tokens)
1719}
1720
1721/// Generate a Vec request frame with the caller's checked length-prefix type.
1722///
1723/// # Errors
1724///
1725/// Rejects input outside this macro's syntax.
1726#[cfg_attr(not(test), moxy::function)]
1727pub fn vector_request_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1728    bound_start_fixture::vector_request(tokens)
1729}
1730/// Generate the independent eight-row supported-feature oracle.
1731///
1732/// # Errors
1733///
1734/// Rejects input outside this macro's syntax.
1735#[cfg_attr(not(test), moxy::function)]
1736pub fn supported_features_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1737    cross_storage_fixtures::supported_features_fixture(tokens)
1738}
1739
1740/// Generate supported-feature rows from explicit wire bounds.
1741///
1742/// # Errors
1743///
1744/// Rejects input outside this macro's syntax.
1745#[cfg_attr(not(test), moxy::function)]
1746pub fn supported_feature_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1747    cross_storage_fixtures::supported_feature_fixture(tokens)
1748}
1749/// Generate finalized-feature rows from explicit wire levels.
1750///
1751/// # Errors
1752///
1753/// Rejects input outside this macro's syntax.
1754#[cfg_attr(not(test), moxy::function)]
1755pub fn finalized_feature_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1756    cross_storage_fixtures::finalized_feature_fixture(tokens)
1757}
1758/// Generate the record input used by byte-limit tests.
1759///
1760/// # Errors
1761///
1762/// Rejects input outside this macro's syntax.
1763#[cfg_attr(not(test), moxy::function)]
1764pub fn record_limit_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1765    cross_storage_fixtures::record_limit_fixture(tokens)
1766}
1767/// Generate keyed compaction batches with explicit producer state and timestamp.
1768///
1769/// # Errors
1770///
1771/// Rejects input outside this macro's syntax.
1772#[cfg_attr(not(test), moxy::function)]
1773pub fn compaction_record_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1774    cross_storage_fixtures::compaction_record_fixture(tokens)
1775}
1776/// Project registration feature bounds into an ordered map.
1777///
1778/// # Errors
1779///
1780/// Rejects input outside this macro's syntax.
1781#[cfg_attr(not(test), moxy::function)]
1782pub fn registration_feature_projection(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1783    cross_storage_fixtures::registration_feature_projection(tokens)
1784}
1785/// Generate the validated connection dispatch-capacity parser.
1786///
1787/// # Errors
1788///
1789/// Rejects input outside this macro's syntax.
1790#[cfg_attr(not(test), moxy::function)]
1791pub fn dispatch_capacity_parser(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1792    cli_support::dispatch_capacity_parser(tokens)
1793}
1794
1795/// Share S3 endpoint and credential fields with the original configuration documentation.
1796#[moxy::attribute]
1797pub fn s3_fields(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1798    s3_fields::expand(meta, item)
1799}
1800
1801/// Define a named `SplitMix64` step that advances the caller's stream state.
1802/// Placement shuffles and benchmark byte streams share the exact same arithmetic.
1803///
1804/// # Errors
1805///
1806/// Rejects input outside this macro's syntax.
1807#[cfg_attr(not(test), moxy::function)]
1808pub fn splitmix64_step(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1809    deterministic_random::splitmix64_step(tokens)
1810}
1811
1812/// Generate an independent compression-byte oracle with a named codec level.
1813///
1814/// # Errors
1815///
1816/// Rejects input outside this macro's syntax.
1817#[cfg_attr(not(test), moxy::function)]
1818pub fn compression_bytes_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1819    cross_storage_fixtures::compression_bytes_fixture(tokens)
1820}
1821
1822mod reaper_task;
1823mod record_strings;
1824mod seed_member_maps;
1825mod sweep_loop;
1826
1827/// Snapshot member metadata and assignments using the protocol's explicit target body.
1828#[moxy::function]
1829pub fn snapshot_member_maps(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1830    seed_member_maps::snapshot(tokens)
1831}
1832
1833/// Restore member epochs before the protocol's explicit assignment body.
1834#[moxy::function]
1835pub fn hydrate_member_epochs(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1836    seed_member_maps::hydrate(tokens)
1837}
1838
1839/// Declare request string traversal in field order, with optional native traversal bodies.
1840#[moxy::function]
1841pub fn record_strings(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1842    record_strings::expand(tokens)
1843}
1844
1845/// Run an explicit sweep body with the selected cadence and shutdown body.
1846#[moxy::function]
1847pub fn sweep_loop(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1848    sweep_loop::expand(tokens)
1849}
1850
1851/// Schedule an ordinary transaction sweep and retain its caller's shutdown event.
1852#[moxy::attribute]
1853pub fn reaper_task(
1854    meta: NativeTokenStream,
1855    item: NativeTokenStream,
1856) -> Result<NativeTokenStream, ParseError> {
1857    reaper_task::expand(meta, item)
1858}
1859
1860mod archive_rows;
1861mod authorization_refusal;
1862mod broker_test_setup;
1863mod described_group_rows;
1864mod forwardable_requests;
1865mod freeze_refusal_rules;
1866mod group_record_key;
1867mod handler_wire_fixtures;
1868mod model_properties;
1869mod model_runner;
1870mod quorum_epoch_wire;
1871mod reconciliation_fields;
1872mod reconciliation_operations;
1873mod reconciliation_projection;
1874mod request_test_identity;
1875mod scheduled_loads;
1876mod share_fixture_schemas;
1877mod share_refusal_matrix;
1878mod share_state_constructors;
1879mod share_state_operation;
1880mod share_state_results;
1881mod simulation_message;
1882
1883/// Declare forwardable API keys and decode each embedded body with its selected request type.
1884#[moxy::function]
1885pub fn forwardable_requests(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1886    forwardable_requests::expand(&input.into()).map(Into::into)
1887}
1888/// Add the selected common projection fields around the visible protocol-specific fields.
1889#[moxy::attribute]
1890pub fn reconciliation_fields(
1891    meta: NativeTokenStream,
1892    item: NativeTokenStream,
1893) -> Result<NativeTokenStream, ParseError> {
1894    reconciliation_fields::expand(&meta.into(), item)
1895}
1896/// Run share-offset refusal cases with direct startup, identity, assertions and shutdown.
1897#[moxy::function]
1898pub fn share_refusal_matrix(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1899    share_refusal_matrix::expand(input)
1900}
1901/// Derive projection construction from the member declaration's visible fields.
1902#[moxy::derive(ReconciliationMember, attributes(reconciliation))]
1903pub fn reconciliation_member(item: ItemStruct) -> Result<TokenStream, ParseError> {
1904    reconciliation_projection::member(item)
1905}
1906
1907/// Encode and parse a visible group-record key enum with explicit version constants.
1908#[moxy::derive(GroupRecordKey, attributes(group_key))]
1909pub fn group_record_key(item: ItemEnum) -> Result<TokenStream, ParseError> {
1910    group_record_key::expand(item)
1911}
1912
1913/// Implement partition routing from a visible simulation message declaration.
1914#[moxy::derive(PartitionMessage)]
1915pub fn partition_message(item: ItemStruct) -> Result<TokenStream, ParseError> {
1916    simulation_message::expand(item)
1917}
1918
1919/// Adapt the external quorum-epoch request types listed at the caller.
1920#[moxy::function]
1921pub fn quorum_epoch_requests(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1922    quorum_epoch_wire::requests(&input.into()).map(Into::into)
1923}
1924
1925/// Map native voter listeners to the selected quorum wire endpoint type.
1926#[moxy::function]
1927pub fn voter_endpoints(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1928    quorum_epoch_wire::voter_endpoints(input)
1929}
1930
1931/// Supply the common quorum-epoch response layout under an explicit function signature.
1932#[moxy::function]
1933pub fn quorum_epoch_encoder(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1934    quorum_epoch_wire::encoder(input)
1935}
1936
1937/// Encode a typed authorization refusal with its optional native message expression.
1938#[moxy::function]
1939pub fn authorization_refusal(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1940    authorization_refusal::expand(input)
1941}
1942
1943/// Share an exhaustive freeze mutation inventory under explicit runtime and logical headers.
1944#[moxy::function]
1945pub fn freeze_refusal_rules(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1946    freeze_refusal_rules::expand(input)
1947}
1948
1949/// Construct the fixed empty ACL matching filter for the selected external request type.
1950#[moxy::function]
1951pub fn empty_match_acl_filter(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1952    handler_wire_fixtures::empty_match_acl_filter(&input.into()).map(Into::into)
1953}
1954
1955/// Compare a delegation-token refusal with the full selected wire response.
1956#[moxy::function]
1957pub fn token_refusal_result(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1958    handler_wire_fixtures::token_refusal_result(&input.into()).map(Into::into)
1959}
1960
1961/// Construct an external share-state request from visible field expressions.
1962#[moxy::function]
1963pub fn share_state_request(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1964    share_state_constructors::expand(input)
1965}
1966
1967/// Associate share-state response schemas with the listed request types.
1968#[moxy::function]
1969pub fn share_fixture_schemas(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1970    share_fixture_schemas::expand(&input.into()).map(Into::into)
1971}
1972
1973/// Adapt the listed external response rows to the partition-result trait.
1974#[moxy::function]
1975pub fn share_partition_results(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1976    described_group_rows::partition_results(&input.into()).map(Into::into)
1977}
1978
1979/// Run native share-state partition operations concurrently while preserving request order.
1980#[moxy::function]
1981pub fn share_state_results(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1982    share_state_results::expand(input)
1983}
1984
1985/// Add shared active-state admission and reply handling to a visible async method.
1986#[moxy::attribute]
1987pub fn share_state_operation(
1988    meta: NativeTokenStream,
1989    item: NativeTokenStream,
1990) -> Result<NativeTokenStream, ParseError> {
1991    share_state_operation::expand(&meta.into(), item)
1992}
1993
1994/// Derive group projection construction and epoch checks from its visible fields.
1995#[moxy::derive(ReconciliationGroup, attributes(reconciliation))]
1996pub fn reconciliation_group(item: ItemStruct) -> Result<TokenStream, ParseError> {
1997    reconciliation_projection::group(item)
1998}
1999
2000/// Derive heartbeat conversion from a visible reconciliation action enum.
2001#[moxy::derive(ReconciliationAction)]
2002pub fn reconciliation_action(item: ItemEnum) -> Result<TokenStream, ParseError> {
2003    reconciliation_projection::action(item)
2004}
2005
2006/// Observe a projected model epoch using its visible epoch field and violation ledger.
2007#[moxy::derive(ModelEpochLedger)]
2008pub fn model_epoch_ledger(item: ItemStruct) -> Result<TokenStream, ParseError> {
2009    reconciliation_projection::epoch(item)
2010}
2011
2012/// Build ordered model properties around their original native oracle blocks.
2013#[moxy::function]
2014pub fn model_properties(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2015    model_properties::expand(input)
2016}
2017
2018/// Run a model with explicit search bounds and pinned state counts.
2019#[moxy::function]
2020pub fn model_runner(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2021    model_runner::expand(input)
2022}
2023
2024/// Rebuild a reconciliation group around explicit native setup and projection operations.
2025#[moxy::function]
2026pub fn rebuild_reconciliation_group(
2027    input: NativeTokenStream,
2028) -> Result<NativeTokenStream, ParseError> {
2029    reconciliation_operations::rebuild(input)
2030}
2031
2032/// Apply an explicit member action and project the resulting reconciliation state.
2033#[moxy::function]
2034pub fn reconciliation_next_state(
2035    input: NativeTokenStream,
2036) -> Result<NativeTokenStream, ParseError> {
2037    reconciliation_operations::next_state(input)
2038}
2039
2040/// Emit reconciliation action scheduling with explicit caller predicates and extensions.
2041#[moxy::function]
2042pub fn reconciliation_actions(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2043    reconciliation_operations::actions(input)
2044}
2045
2046/// Retain the broker handle and directory before native readiness operations.
2047#[moxy::function]
2048pub fn broker_test_setup(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2049    broker_test_setup::expand(input)
2050}
2051
2052/// Retain principal and peer values for an explicitly selected borrowed request context.
2053#[moxy::function]
2054pub fn request_test_identity(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2055    request_test_identity::expand(input)
2056}
2057
2058/// Join the visible task collection in order and log its selected failure message.
2059#[moxy::derive(ScheduledLoads, attributes(scheduled_loads))]
2060pub fn scheduled_loads(item: ItemStruct) -> Result<TokenStream, ParseError> {
2061    scheduled_loads::expand(item)
2062}
2063
2064/// Implement group-describe row access for an explicit table of external response types.
2065#[moxy::function]
2066pub fn described_group_rows(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2067    described_group_rows::expand(&input.into()).map(Into::into)
2068}
2069
2070/// Generate one annotated archive-validation walk with coherent proof bindings.
2071#[moxy::function(name = "validate_archive_rows")]
2072pub fn validate_archive_rows(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2073    let expanded = archive_rows::expand(tokens.into())?;
2074    // Creusot matches logical captures to MIR locals by identifier context.
2075    // Reparse the complete function together so generated and supplied annotations
2076    // share the same context as the local bindings they describe.
2077    Ok(expanded
2078        .to_string()
2079        .parse()
2080        .expect("valid archive walk expansion"))
2081}
2082
2083#[cfg(test)]
2084mod export_contract_tests {
2085    use {super::*, assert2::assert};
2086
2087    type Expand = fn(TokenStream) -> Result<TokenStream, ParseError>;
2088    struct FunctionMacro {
2089        name: &'static str,
2090        expand: Expand,
2091    }
2092    const FUNCTION_MACROS: [FunctionMacro; 81] = [
2093        FunctionMacro {
2094            name: "dispatch_table",
2095            expand: dispatch_table,
2096        },
2097        FunctionMacro {
2098            name: "throttle_probes",
2099            expand: throttle_probes,
2100        },
2101        FunctionMacro {
2102            name: "cli_main",
2103            expand: cli_main,
2104        },
2105        FunctionMacro {
2106            name: "bounded_bfs",
2107            expand: bounded_bfs,
2108        },
2109        FunctionMacro {
2110            name: "delete_topic_request",
2111            expand: delete_topic_request,
2112        },
2113        FunctionMacro {
2114            name: "compacted_batch",
2115            expand: compacted_batch,
2116        },
2117        FunctionMacro {
2118            name: "record_batch_fixture",
2119            expand: record_batch_fixture,
2120        },
2121        FunctionMacro {
2122            name: "simulation_actions",
2123            expand: simulation_actions,
2124        },
2125        FunctionMacro {
2126            name: "simulation_transport",
2127            expand: simulation_transport,
2128        },
2129        FunctionMacro {
2130            name: "simulation_heartbeat",
2131            expand: simulation_heartbeat,
2132        },
2133        FunctionMacro {
2134            name: "benchmark_scenario_fixture",
2135            expand: benchmark_scenario_fixture,
2136        },
2137        FunctionMacro {
2138            name: "benchmark_latency_fixture",
2139            expand: benchmark_latency_fixture,
2140        },
2141        FunctionMacro {
2142            name: "s3_archive_config_fixture",
2143            expand: s3_archive_config_fixture,
2144        },
2145        FunctionMacro {
2146            name: "remote_segment_check",
2147            expand: remote_segment_check,
2148        },
2149        FunctionMacro {
2150            name: "simulation_step",
2151            expand: simulation_step,
2152        },
2153        FunctionMacro {
2154            name: "snapshot_topic_fixture",
2155            expand: snapshot_topic_fixture,
2156        },
2157        FunctionMacro {
2158            name: "timestamped_batch",
2159            expand: timestamped_batch,
2160        },
2161        FunctionMacro {
2162            name: "producer_batch_fixture",
2163            expand: producer_batch_fixture,
2164        },
2165        FunctionMacro {
2166            name: "create_topic_fixture",
2167            expand: create_topic_fixture,
2168        },
2169        FunctionMacro {
2170            name: "consumer_fetch_fixture",
2171            expand: consumer_fetch_fixture,
2172        },
2173        FunctionMacro {
2174            name: "single_replica_partition_fixture",
2175            expand: single_replica_partition_fixture,
2176        },
2177        FunctionMacro {
2178            name: "control_marker_fixture",
2179            expand: control_marker_fixture,
2180        },
2181        FunctionMacro {
2182            name: "topic_record_fixture",
2183            expand: topic_record_fixture,
2184        },
2185        FunctionMacro {
2186            name: "ephemeral_port_fixture",
2187            expand: ephemeral_port_fixture,
2188        },
2189        FunctionMacro {
2190            name: "projection_identity",
2191            expand: projection_identity,
2192        },
2193        FunctionMacro {
2194            name: "minio_fixture",
2195            expand: minio_fixture,
2196        },
2197        FunctionMacro {
2198            name: "scram_client_first",
2199            expand: scram_client_first,
2200        },
2201        FunctionMacro {
2202            name: "remote_segment_transition_matrix",
2203            expand: remote_segment_transition_matrix,
2204        },
2205        FunctionMacro {
2206            name: "capture_layer_fixture",
2207            expand: capture_layer_fixture,
2208        },
2209        FunctionMacro {
2210            name: "remote_segment_fixtures",
2211            expand: remote_segment_fixtures,
2212        },
2213        FunctionMacro {
2214            name: "remote_metadata_missing",
2215            expand: remote_metadata_missing,
2216        },
2217        FunctionMacro {
2218            name: "async_write_delegate",
2219            expand: async_write_delegate,
2220        },
2221        FunctionMacro {
2222            name: "timer_hooks",
2223            expand: timer_hooks,
2224        },
2225        FunctionMacro {
2226            name: "scram_client_proof_fixture",
2227            expand: scram_client_proof_fixture,
2228        },
2229        FunctionMacro {
2230            name: "single_partition_produce_fixture",
2231            expand: single_partition_produce_fixture,
2232        },
2233        FunctionMacro {
2234            name: "request_frame_fixture",
2235            expand: request_frame_fixture,
2236        },
2237        FunctionMacro {
2238            name: "patterned_bytes_fixture",
2239            expand: patterned_bytes_fixture,
2240        },
2241        FunctionMacro {
2242            name: "break_glass_golden_id",
2243            expand: break_glass_golden_id,
2244        },
2245        FunctionMacro {
2246            name: "jvm_principal_golden",
2247            expand: jvm_principal_golden,
2248        },
2249        FunctionMacro {
2250            name: "frame_prefix_fixture",
2251            expand: frame_prefix_fixture,
2252        },
2253        FunctionMacro {
2254            name: "file_region_fixture",
2255            expand: file_region_fixture,
2256        },
2257        FunctionMacro {
2258            name: "empty_endpoint_voters",
2259            expand: empty_endpoint_voters,
2260        },
2261        FunctionMacro {
2262            name: "epoch_record_batch_fixture",
2263            expand: epoch_record_batch_fixture,
2264        },
2265        FunctionMacro {
2266            name: "epoch_log_view",
2267            expand: epoch_log_view,
2268        },
2269        FunctionMacro {
2270            name: "legacy_policy_fixture",
2271            expand: legacy_policy_fixture,
2272        },
2273        FunctionMacro {
2274            name: "keyed_record_batch_fixture",
2275            expand: keyed_record_batch_fixture,
2276        },
2277        FunctionMacro {
2278            name: "duration_cases_fixture",
2279            expand: duration_cases_fixture,
2280        },
2281        FunctionMacro {
2282            name: "directory_tree_fixture",
2283            expand: directory_tree_fixture,
2284        },
2285        FunctionMacro {
2286            name: "parsed_cli_entrypoint",
2287            expand: parsed_cli_entrypoint,
2288        },
2289        FunctionMacro {
2290            name: "duration_parser_fixture",
2291            expand: duration_parser_fixture,
2292        },
2293        FunctionMacro {
2294            name: "bootstrap_parser_fixture",
2295            expand: bootstrap_parser_fixture,
2296        },
2297        FunctionMacro {
2298            name: "snapshot_node_fixture",
2299            expand: snapshot_node_fixture,
2300        },
2301        FunctionMacro {
2302            name: "connect_cli_client",
2303            expand: connect_cli_client,
2304        },
2305        FunctionMacro {
2306            name: "format_directories_fixture",
2307            expand: format_directories_fixture,
2308        },
2309        FunctionMacro {
2310            name: "wal_capture_topic_fixture",
2311            expand: wal_capture_topic_fixture,
2312        },
2313        FunctionMacro {
2314            name: "flag_metadata_fixture",
2315            expand: flag_metadata_fixture,
2316        },
2317        FunctionMacro {
2318            name: "bind_retry_fixture",
2319            expand: bind_retry_fixture,
2320        },
2321        FunctionMacro {
2322            name: "bound_start_fixture",
2323            expand: bound_start_fixture,
2324        },
2325        FunctionMacro {
2326            name: "assignment_dirs_fixture",
2327            expand: assignment_dirs_fixture,
2328        },
2329        FunctionMacro {
2330            name: "metric_registry_fixture",
2331            expand: metric_registry_fixture,
2332        },
2333        FunctionMacro {
2334            name: "worm_segment_fixture",
2335            expand: worm_segment_fixture,
2336        },
2337        FunctionMacro {
2338            name: "remote_started_segment",
2339            expand: remote_started_segment,
2340        },
2341        FunctionMacro {
2342            name: "scram_users_fixture",
2343            expand: scram_users_fixture,
2344        },
2345        FunctionMacro {
2346            name: "record_header_text",
2347            expand: record_header_text,
2348        },
2349        FunctionMacro {
2350            name: "share_dlq_meters",
2351            expand: share_dlq_meters,
2352        },
2353        FunctionMacro {
2354            name: "export_segment_data_fixture",
2355            expand: export_segment_data_fixture,
2356        },
2357        FunctionMacro {
2358            name: "epoch_checkpoint_failure",
2359            expand: epoch_checkpoint_failure,
2360        },
2361        FunctionMacro {
2362            name: "jvm_checkpoint_dump_fixture",
2363            expand: jvm_checkpoint_dump_fixture,
2364        },
2365        FunctionMacro {
2366            name: "java_string_producer_source",
2367            expand: java_string_producer_source,
2368        },
2369        FunctionMacro {
2370            name: "epoch_millis_fn",
2371            expand: epoch_millis_fn,
2372        },
2373        FunctionMacro {
2374            name: "unix_millis_fixture",
2375            expand: unix_millis_fixture,
2376        },
2377        FunctionMacro {
2378            name: "vector_request_fixture",
2379            expand: vector_request_fixture,
2380        },
2381        FunctionMacro {
2382            name: "supported_features_fixture",
2383            expand: supported_features_fixture,
2384        },
2385        FunctionMacro {
2386            name: "supported_feature_fixture",
2387            expand: supported_feature_fixture,
2388        },
2389        FunctionMacro {
2390            name: "finalized_feature_fixture",
2391            expand: finalized_feature_fixture,
2392        },
2393        FunctionMacro {
2394            name: "record_limit_fixture",
2395            expand: record_limit_fixture,
2396        },
2397        FunctionMacro {
2398            name: "compaction_record_fixture",
2399            expand: compaction_record_fixture,
2400        },
2401        FunctionMacro {
2402            name: "registration_feature_projection",
2403            expand: registration_feature_projection,
2404        },
2405        FunctionMacro {
2406            name: "dispatch_capacity_parser",
2407            expand: dispatch_capacity_parser,
2408        },
2409        FunctionMacro {
2410            name: "splitmix64_step",
2411            expand: splitmix64_step,
2412        },
2413        FunctionMacro {
2414            name: "compression_bytes_fixture",
2415            expand: compression_bytes_fixture,
2416        },
2417    ];
2418
2419    #[test]
2420    fn function_macros_keep_their_empty_input_contract() {
2421        let accepted: Vec<_> = FUNCTION_MACROS
2422            .into_iter()
2423            .filter_map(|entry| {
2424                (entry.expand)(TokenStream::new())
2425                    .is_ok()
2426                    .then_some(entry.name)
2427            })
2428            .collect();
2429        // Dispatch and throttle tables permit zero entries; fixtures need arguments.
2430        assert!(accepted == ["dispatch_table", "throttle_probes"]);
2431    }
2432}
2433
2434mod verified_index;
2435
2436/// Declare a verified binary-search cursor over named index entries.
2437#[moxy::function]
2438pub fn sorted_index_cursor(input: TokenStream) -> Result<TokenStream, ParseError> {
2439    verified_index::cursor(input)
2440}
2441
2442/// Declare a verified last-predecessor lookup over named index entries.
2443#[moxy::function]
2444pub fn index_floor_lookup(input: TokenStream) -> Result<TokenStream, ParseError> {
2445    verified_index::floor(input)
2446}
2447
2448/// Add the contract of a remote finished-segment selection.
2449#[moxy::attribute]
2450pub fn finished_selection(
2451    meta: NativeTokenStream,
2452    item: NativeTokenStream,
2453) -> Result<NativeTokenStream, ParseError> {
2454    verified_index::finished(meta, item)
2455}
2456
2457/// Add the shared domain and proof annotations of a round-robin site lemma.
2458#[moxy::attribute]
2459pub fn round_robin_site_lemma(
2460    meta: NativeTokenStream,
2461    item: NativeTokenStream,
2462) -> Result<NativeTokenStream, ParseError> {
2463    verified_index::site(meta, item)
2464}
2465
2466mod fixture_methods;
2467mod group_record_flush;
2468mod unit_schema;
2469
2470/// Describe a visible human-unit schema marker.
2471#[moxy::derive(UnitSchema, attributes(unit_schema))]
2472pub fn unit_schema(item: ItemStruct) -> Result<TokenStream, ParseError> {
2473    unit_schema::expand(item)
2474}
2475
2476/// Append the shared metadata forwarding methods to an authorizer implementation.
2477#[moxy::attribute]
2478pub fn delegate_authorizer(
2479    meta: NativeTokenStream,
2480    item: NativeTokenStream,
2481) -> Result<NativeTokenStream, ParseError> {
2482    fixture_methods::authorizer(meta, item)
2483}
2484
2485/// Append missing-read behavior to an explicit remote-log implementation.
2486#[moxy::attribute]
2487pub fn missing_remote_reads(
2488    meta: NativeTokenStream,
2489    item: NativeTokenStream,
2490) -> Result<NativeTokenStream, ParseError> {
2491    fixture_methods::remote(meta, item)
2492}
2493
2494/// Preserve the visible flush body inside the shared group-log append boundary.
2495#[moxy::attribute]
2496pub fn flush_group_records(
2497    meta: NativeTokenStream,
2498    item: NativeTokenStream,
2499) -> Result<NativeTokenStream, ParseError> {
2500    group_record_flush::expand(meta, item)
2501}
2502
2503mod handler_wire_rows;
2504
2505/// Build offset-fetch rows for an explicit table of wire schemas.
2506#[moxy::function]
2507pub fn offset_fetch_rows(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2508    handler_wire_rows::offset_fetch_rows(&input.into()).map(Into::into)
2509}
2510
2511/// Build a share-group refusal with the caller's owned fields.
2512#[moxy::function]
2513pub fn share_group_denial(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2514    handler_wire_rows::share_group_denial(&input.into()).map(Into::into)
2515}
2516
2517/// Project acknowledgement batches while preserving the native expression.
2518#[moxy::function]
2519pub fn acknowledgement_batches(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2520    handler_wire_rows::acknowledgement_batches(input)
2521}
2522
2523mod coordinator_fixtures;
2524
2525/// Declare heartbeat fixtures with named status observations.
2526#[moxy::function]
2527pub fn heartbeat_status(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2528    coordinator_fixtures::heartbeat(&input.into()).map(Into::into)
2529}
2530
2531/// Preserve native key-boundary observations in generated coordinator tests.
2532#[moxy::function]
2533pub fn member_key_boundaries(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2534    coordinator_fixtures::key_boundaries(input)
2535}
2536
2537/// Schedule explicit commit changes and preserve caller-owned async actions.
2538#[moxy::function]
2539pub fn schedule_commit_changes(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2540    coordinator_fixtures::commit_changes(input)
2541}
2542
2543mod bounded_unit_modules;
2544
2545/// Declare concrete bounded human-unit serde modules from one flat table.
2546#[moxy::function]
2547pub fn bounded_unit_modules(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2548    bounded_unit_modules::expand(&input.into()).map(Into::into)
2549}
2550
2551mod fixture_constructors;
2552
2553/// Declare fixture constructors from the existing election, supervisor and quota domains.
2554#[moxy::function]
2555pub fn fixture_constructors(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2556    fixture_constructors::expand(&input.into()).map(Into::into)
2557}
2558
2559mod wire_test_driver;
2560
2561/// Declare wire drivers that call the existing socket and framing helpers.
2562#[moxy::function]
2563pub fn wire_test_driver(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2564    wire_test_driver::expand(&input.into()).map(Into::into)
2565}
2566
2567mod replication_target_guard;
2568
2569/// Acquire the local replication target with the original caller-level drop behavior.
2570#[moxy::function]
2571pub fn replication_target_guard(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2572    replication_target_guard::expand(&input.into()).map(Into::into)
2573}
2574
2575mod share_test_drivers;
2576
2577/// Declare a first share fetch through the existing client helper.
2578#[moxy::function]
2579pub fn share_first_fetch(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2580    share_test_drivers::acquisition(&input.into()).map(Into::into)
2581}
2582
2583/// Declare a share-consumption driver with native caller operations.
2584#[moxy::function]
2585pub fn share_consumption_driver(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2586    share_test_drivers::consumption(input)
2587}
2588
2589mod index_seed_helpers;
2590
2591/// Declare typed sparse-index fixture helpers with explicit index and key types.
2592#[moxy::function]
2593pub fn index_seed_helpers(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2594    index_seed_helpers::expand(&input.into()).map(Into::into)
2595}
2596
2597/// Route `(broker, context, request, version; operation, refusal)` through the
2598/// controller listener, continuing with the request or returning its completed dispatch.
2599#[moxy::function]
2600pub fn controller_request(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2601    handler_wire_rows::controller_request(input)
2602}
2603
2604mod config_alter_handler;
2605
2606/// Declare the shared configuration handler with explicit wire and audit policies.
2607#[moxy::function]
2608pub fn config_alter_handler(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2609    config_alter_handler::expand(&input.into()).map(Into::into)
2610}
2611
2612mod fixture_expressions;
2613
2614/// Verify a guard response and return its typed value.
2615#[moxy::function]
2616pub fn guard_response(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2617    fixture_expressions::guard_response(&input.into()).map(Into::into)
2618}
2619
2620/// Read the evicted local segment state with the declared retention policy.
2621#[moxy::function]
2622pub fn evicted_local_segments(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2623    fixture_expressions::evicted_segments(&input.into()).map(Into::into)
2624}
2625
2626/// Apply reassignment fields in the caller's explicit expression order.
2627#[moxy::function]
2628pub fn reassignment_fields(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2629    fixture_expressions::reassignment(input)
2630}
2631
2632mod share_request_identity;
2633
2634/// Resolve a share request identity before entering the native handler body.
2635#[moxy::attribute]
2636pub fn share_request_identity(
2637    meta: NativeTokenStream,
2638    item: NativeTokenStream,
2639) -> Result<NativeTokenStream, ParseError> {
2640    share_request_identity::expand(meta.into(), item)
2641}
2642
2643mod group_fixture_tables;
2644mod partition_gate;
2645mod private_dispatch_table;
2646mod string_mutations;
2647
2648/// Declare partition authorization gates with explicit actions.
2649#[moxy::function]
2650pub fn partition_gate(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2651    partition_gate::expand(&input.into()).map(Into::into)
2652}
2653
2654/// Declare private request adapters and their registration table.
2655#[moxy::function]
2656pub fn private_dispatch_table(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2657    private_dispatch_table::expand(&input.into()).map(Into::into)
2658}
2659
2660/// Declare required and optional string mutation cases.
2661#[moxy::function]
2662pub fn string_mutations(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2663    string_mutations::expand(&input.into()).map(Into::into)
2664}
2665
2666/// Declare member identity fixtures with explicit schema fields.
2667#[moxy::function]
2668pub fn member_identity_fixtures(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2669    group_fixture_tables::member_identity(input)
2670}
2671
2672/// Declare required-topic traversal for a topology schema.
2673#[moxy::function]
2674pub fn required_topics(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2675    group_fixture_tables::required_topics(&input.into()).map(Into::into)
2676}
2677
2678mod token_dispatch;
2679
2680/// Adapt an owned delegation-token handler to negotiated wire dispatch.
2681#[moxy::attribute]
2682pub fn token_dispatch(
2683    meta: NativeTokenStream,
2684    item: NativeTokenStream,
2685) -> Result<NativeTokenStream, ParseError> {
2686    token_dispatch::expand(meta.into(), item)
2687}