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::{Span, 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    expanded
560        .to_string()
561        .parse()
562        .map_err(|_| ParseError::new(Span::call_site(), "invalid 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/// Find the earliest armed timer of a simulation's nodes.
1058///
1059/// # Errors
1060///
1061/// Rejects an empty crate path.
1062#[cfg_attr(not(test), moxy::function)]
1063pub fn simulation_earliest_timer(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1064    fixtures::simulation_earliest_timer(tokens)
1065}
1066
1067/// Generate the shared simulation event adapter inside a harness impl.
1068///
1069/// # Errors
1070///
1071/// Rejects input outside this macro's syntax.
1072#[cfg_attr(not(test), moxy::function)]
1073pub fn simulation_step(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1074    fixtures::simulation_step(tokens)
1075}
1076
1077/// Generate the shared two-partition metadata topic fixture.
1078///
1079/// # Errors
1080///
1081/// Rejects input outside this macro's syntax.
1082#[cfg_attr(not(test), moxy::function)]
1083pub fn snapshot_topic_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1084    fixtures::snapshot_topic(tokens)
1085}
1086
1087/// Generate the timestamped record-batch fixture used by local and remote read tests.
1088///
1089/// # Errors
1090///
1091/// Rejects input outside this macro's syntax.
1092#[cfg_attr(not(test), moxy::function)]
1093pub fn timestamped_batch(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1094    timestamped_batch::expand(tokens)
1095}
1096
1097/// Generate the expected fetch row of a refused partition.
1098///
1099/// # Errors
1100///
1101/// Rejects input outside this macro's syntax.
1102#[cfg_attr(not(test), moxy::function)]
1103pub fn refused_fetch_partition_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1104    wire_fixtures::refused_fetch_partition(tokens)
1105}
1106
1107/// Generate a producer batch builder with the caller's exact record value expression.
1108///
1109/// # Errors
1110///
1111/// Rejects input outside this macro's syntax.
1112#[cfg_attr(not(test), moxy::function)]
1113pub fn producer_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1114    wire_fixtures::producer_batch(tokens)
1115}
1116
1117/// Generate a one-topic `CreateTopics` request builder with explicit sizes and timeout.
1118///
1119/// # Errors
1120///
1121/// Rejects input outside this macro's syntax.
1122#[cfg_attr(not(test), moxy::function)]
1123pub fn create_topic_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1124    wire_fixtures::create_topic(tokens)
1125}
1126
1127/// Generate the consumer Fetch request fixture for partition zero with a 1 MiB limit.
1128///
1129/// # Errors
1130///
1131/// Rejects input outside this macro's syntax.
1132#[cfg_attr(not(test), moxy::function)]
1133pub fn consumer_fetch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1134    wire_fixtures::consumer_fetch(tokens)
1135}
1136
1137/// Generate the initial single-replica metadata partition record builder.
1138///
1139/// # Errors
1140///
1141/// Rejects input outside this macro's syntax.
1142#[cfg_attr(not(test), moxy::function)]
1143pub fn single_replica_partition_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1144    wire_fixtures::single_replica_partition(tokens)
1145}
1146
1147/// Generate the version-zero control-marker key and value fixture encoders.
1148///
1149/// # Errors
1150///
1151/// Rejects input outside this macro's syntax.
1152#[cfg_attr(not(test), moxy::function)]
1153pub fn control_marker_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1154    wire_fixtures::control_marker(tokens)
1155}
1156
1157/// Generate a topic record builder for one partition and one replica.
1158///
1159/// # Errors
1160///
1161/// Rejects input outside this macro's syntax.
1162#[cfg_attr(not(test), moxy::function)]
1163pub fn topic_record_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1164    wire_fixtures::topic_record(tokens)
1165}
1166
1167/// Generate the loopback ephemeral-port helper used by container tests.
1168///
1169/// # Errors
1170///
1171/// Rejects input outside this macro's syntax.
1172#[cfg_attr(not(test), moxy::function)]
1173pub fn ephemeral_port_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1174    wire_fixtures::ephemeral_port(tokens)
1175}
1176
1177/// Generate projection-based Eq and Hash, and optionally Debug, for model state.
1178///
1179/// # Errors
1180///
1181/// Rejects input outside this macro's syntax.
1182#[cfg_attr(not(test), moxy::function)]
1183pub fn projection_identity(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1184    projection_identity::expand(tokens)
1185}
1186
1187/// Generate the shared `MinIO` process/readiness helpers under the supplied module name.
1188///
1189/// # Errors
1190///
1191/// Rejects input outside this macro's syntax.
1192#[cfg_attr(not(test), moxy::function)]
1193pub fn minio_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1194    container_fixtures::expand(tokens)
1195}
1196
1197/// Start a SCRAM client exchange while preserving its private handshake phase type.
1198///
1199/// # Errors
1200///
1201/// Rejects input outside this macro's syntax.
1202#[cfg_attr(not(test), moxy::function)]
1203pub fn scram_client_first(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1204    auth_fixtures::scram_client_first(tokens)
1205}
1206
1207/// Generate the independent four-state remote-segment transition oracle.
1208///
1209/// # Errors
1210///
1211/// Rejects input outside this macro's syntax.
1212#[cfg_attr(not(test), moxy::function)]
1213pub fn remote_segment_transition_matrix(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1214    fixtures::remote_segment_transition_matrix(tokens)
1215}
1216
1217/// Generate a tracing capture layer with an explicit mutex poison policy.
1218///
1219/// # Errors
1220///
1221/// Rejects input outside this macro's syntax.
1222#[cfg_attr(not(test), moxy::function)]
1223pub fn capture_layer_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1224    fixtures::capture_layer(tokens)
1225}
1226
1227/// Add the selected direct `ObjectStore` delegates to an implementation.
1228#[moxy::attribute(name = "object_store_delegate")]
1229pub fn object_store_delegate(
1230    meta: TokenStream,
1231    item: TokenStream,
1232) -> Result<TokenStream, ParseError> {
1233    object_store_delegate::expand(meta, item)
1234}
1235
1236/// Generate remote metadata lifecycle fixtures with an explicit timestamp policy.
1237///
1238/// # Errors
1239///
1240/// Rejects input outside this macro's syntax.
1241#[cfg_attr(not(test), moxy::function)]
1242pub fn remote_segment_fixtures(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1243    remote_metadata_fixtures::segment(tokens)
1244}
1245
1246/// Generate the independent missing-partition metadata assertions.
1247///
1248/// # Errors
1249///
1250/// Rejects input outside this macro's syntax.
1251#[cfg_attr(not(test), moxy::function)]
1252pub fn remote_metadata_missing(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1253    remote_metadata_fixtures::missing(tokens)
1254}
1255
1256/// Generate the direct flush and shutdown delegates for a tuple write wrapper.
1257///
1258/// # Errors
1259///
1260/// Rejects input outside this macro's syntax.
1261#[cfg_attr(not(test), moxy::function)]
1262pub fn async_write_delegate(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1263    async_write_delegate::expand(tokens)
1264}
1265
1266/// Generate a model transition's signature and cloned state before its body.
1267#[moxy::function(name = "model_transition")]
1268pub fn model_transition(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1269    fixtures::model_transition(tokens)
1270}
1271
1272/// Append the shared object-store retry and HTTP timeout fields.
1273#[moxy::attribute(name = "object_store_config")]
1274pub fn object_store_config(
1275    meta: TokenStream,
1276    item: TokenStream,
1277) -> Result<TokenStream, ParseError> {
1278    object_store_config::expand(meta, item)
1279}
1280
1281/// Expand the object-store file-upload method before async trait processing.
1282#[moxy::attribute(name = "object_ops")]
1283pub fn object_ops(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1284    object_ops::expand(meta, item)
1285}
1286
1287/// Match inline writes and conditionally available sendfile regions.
1288#[moxy::function(name = "sendfile_match")]
1289pub fn sendfile_match(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1290    sendfile_match::expand_native(tokens)
1291}
1292
1293/// Generate timer registration and completion helpers with caller-specific messages.
1294///
1295/// # Errors
1296///
1297/// Rejects input outside this macro's syntax.
1298#[cfg_attr(not(test), moxy::function)]
1299pub fn timer_hooks(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1300    timer_hooks::expand(tokens)
1301}
1302
1303/// Generate the SCRAM proof XOR fixture without imposing extra length checks.
1304///
1305/// # Errors
1306///
1307/// Rejects input outside this macro's syntax.
1308#[cfg_attr(not(test), moxy::function)]
1309pub fn scram_client_proof_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1310    auth_fixtures::scram_client_proof(tokens)
1311}
1312
1313/// Generate a single-partition Produce fixture with explicit request settings.
1314///
1315/// # Errors
1316///
1317/// Rejects input outside this macro's syntax.
1318#[cfg_attr(not(test), moxy::function)]
1319pub fn single_partition_produce_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1320    produce_fixtures::single_partition_produce(tokens)
1321}
1322
1323/// Generate a manual Kafka request-frame fixture with explicit header inputs.
1324///
1325/// # Errors
1326///
1327/// Rejects input outside this macro's syntax.
1328#[cfg_attr(not(test), moxy::function)]
1329pub fn request_frame_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1330    network_fixtures::request_frame(tokens)
1331}
1332
1333/// Generate deterministic patterned bytes for framing tests and benchmarks.
1334///
1335/// # Errors
1336///
1337/// Rejects input outside this macro's syntax.
1338#[cfg_attr(not(test), moxy::function)]
1339pub fn patterned_bytes_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1340    network_fixtures::patterned_bytes(tokens)
1341}
1342
1343/// Generate the distinctive proposal UUID shared by signing golden fixtures.
1344///
1345/// # Errors
1346///
1347/// Rejects input outside this macro's syntax.
1348#[cfg_attr(not(test), moxy::function)]
1349pub fn break_glass_golden_id(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1350    network_fixtures::break_glass_golden_id(tokens)
1351}
1352
1353/// Literal Kafka 4.3.1 principal bytes: alice or bob, token flag.
1354///
1355/// # Errors
1356///
1357/// Rejects input outside this macro's syntax.
1358#[cfg_attr(not(test), moxy::function)]
1359pub fn jvm_principal_golden(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1360    network_fixtures::jvm_principal_golden(tokens)
1361}
1362
1363/// Generate a response frame prefix independently of production framing.
1364///
1365/// # Errors
1366///
1367/// Rejects input outside this macro's syntax.
1368#[cfg_attr(not(test), moxy::function)]
1369pub fn frame_prefix_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1370    network_fixtures::frame_prefix(tokens)
1371}
1372
1373/// Generate the independent file-region byte reader used by wire comparisons.
1374///
1375/// # Errors
1376///
1377/// Rejects input outside this macro's syntax.
1378#[cfg_attr(not(test), moxy::function)]
1379pub fn file_region_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1380    network_fixtures::file_region(tokens)
1381}
1382
1383/// Expand the common I/O, TLS and SASL error variants at their original position.
1384#[moxy::attribute(name = "transport_errors")]
1385pub fn transport_errors(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1386    transport_errors::expand(meta, item)
1387}
1388
1389/// Generate a voter-set fixture whose endpoints and directory IDs remain empty.
1390///
1391/// # Errors
1392///
1393/// Rejects input outside this macro's syntax.
1394#[cfg_attr(not(test), moxy::function)]
1395pub fn empty_endpoint_voters(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1396    raft_fixtures::empty_endpoint_voters(tokens)
1397}
1398
1399/// Generate the one-record leader-epoch batch fixture.
1400///
1401/// # Errors
1402///
1403/// Rejects input outside this macro's syntax.
1404#[cfg_attr(not(test), moxy::function)]
1405pub fn epoch_record_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1406    raft_fixtures::epoch_record_batch(tokens)
1407}
1408
1409/// Generate the epoch-cache `LogView` delegation used by Raft simulations.
1410///
1411/// # Errors
1412///
1413/// Rejects input outside this macro's syntax.
1414#[cfg_attr(not(test), moxy::function)]
1415pub fn epoch_log_view(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1416    raft_fixtures::epoch_log_view(tokens)
1417}
1418
1419/// Derive a TOML table's schema and value traits with an explicit unknown-key policy.
1420#[moxy::attribute(name = "config_table")]
1421pub fn config_table(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1422    config_table::expand(meta, item)
1423}
1424
1425/// Match record payloads with file-region arms only on supported platforms.
1426#[moxy::function(name = "records_payload_match")]
1427pub fn records_payload_match(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1428    sendfile_match::records_payload_native(tokens)
1429}
1430
1431/// Generate the canonical compressed legacy record used by policy tests.
1432///
1433/// # Errors
1434///
1435/// Rejects input outside this macro's syntax.
1436#[cfg_attr(not(test), moxy::function)]
1437pub fn legacy_policy_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1438    legacy_fixtures::policy(tokens)
1439}
1440
1441/// Generate keyed fixture records with explicit count and value size.
1442///
1443/// # Errors
1444///
1445/// Rejects input outside this macro's syntax.
1446#[cfg_attr(not(test), moxy::function)]
1447pub fn keyed_record_batch_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1448    network_fixtures::keyed_record_batch(tokens)
1449}
1450
1451/// Add the shared generic argv signature to a command-line entry point.
1452#[moxy::attribute(name = "argv_entrypoint")]
1453pub fn argv_entrypoint(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1454    cli_support::argv_entrypoint(meta, item)
1455}
1456
1457/// Add bootstrap-server and subcommand fields before deriving a CLI parser.
1458#[moxy::attribute(name = "bootstrap_cli_fields")]
1459pub fn bootstrap_cli_fields(
1460    meta: TokenStream,
1461    item: TokenStream,
1462) -> Result<TokenStream, ParseError> {
1463    cli_support::bootstrap_cli_fields(meta, item)
1464}
1465
1466/// Generate a duration-parser check over each caller's literal cases.
1467///
1468/// # Errors
1469///
1470/// Rejects input outside this macro's syntax.
1471#[cfg_attr(not(test), moxy::function)]
1472pub fn duration_cases_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1473    cli_support::duration_cases(tokens)
1474}
1475
1476/// Generate a sorted directory-tree fixture with the caller's path projection.
1477///
1478/// # Errors
1479///
1480/// Rejects input outside this macro's syntax.
1481#[cfg_attr(not(test), moxy::function)]
1482pub fn directory_tree_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1483    cli_support::directory_tree(tokens)
1484}
1485
1486/// Generate a CLI entry point with the caller's documentation.
1487///
1488/// # Errors
1489///
1490/// Rejects input outside this macro's syntax.
1491#[cfg_attr(not(test), moxy::function)]
1492pub fn parsed_cli_entrypoint(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1493    cli_support::parsed_cli_entrypoint(tokens)
1494}
1495
1496/// Generate a duration-parser test from explicit literal cases.
1497///
1498/// # Errors
1499///
1500/// Rejects input outside this macro's syntax.
1501#[cfg_attr(not(test), moxy::function)]
1502pub fn duration_parser_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1503    cli_support::duration_parser_fixture(tokens)
1504}
1505
1506/// Generate bootstrap parser tests from accepted and refused arguments.
1507///
1508/// # Errors
1509///
1510/// Rejects input outside this macro's syntax.
1511#[cfg_attr(not(test), moxy::function)]
1512pub fn bootstrap_parser_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1513    cli_support::bootstrap_parser_fixture(tokens)
1514}
1515
1516/// Generate the shared snapshot fixture over an on-disk metadata log.
1517///
1518/// # Errors
1519///
1520/// Rejects input outside this macro's syntax.
1521#[cfg_attr(not(test), moxy::function)]
1522pub fn snapshot_node_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1523    cli_support::snapshot_node_fixture(tokens)
1524}
1525
1526/// Connect a CLI client with the caller's identity and refusal exit code.
1527///
1528/// # Errors
1529///
1530/// Rejects input outside this macro's syntax.
1531#[cfg_attr(not(test), moxy::function)]
1532pub fn connect_cli_client(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1533    cli_support::connect_cli_client(tokens)
1534}
1535
1536/// Generate the temporary metadata and data directories used by format tests.
1537///
1538/// # Errors
1539///
1540/// Rejects input outside this macro's syntax.
1541#[cfg_attr(not(test), moxy::function)]
1542pub fn format_directories_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1543    cli_support::format_directories_fixture(tokens)
1544}
1545
1546/// Generate the explicit topic map used by WAL capture fixtures.
1547///
1548/// # Errors
1549///
1550/// Rejects input outside this macro's syntax.
1551#[cfg_attr(not(test), moxy::function)]
1552pub fn wal_capture_topic_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1553    remote_metadata_fixtures::wal_capture_topic_fixture(tokens)
1554}
1555
1556/// Generate a CLI flag's name, environment and default-value projection.
1557///
1558/// # Errors
1559///
1560/// Rejects input outside this macro's syntax.
1561#[cfg_attr(not(test), moxy::function)]
1562pub fn flag_metadata_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1563    cli_support::flag_metadata_fixture(tokens)
1564}
1565
1566/// Generate a listener bind retry with an explicit caller timeout.
1567///
1568/// # Errors
1569///
1570/// Rejects input outside this macro's syntax.
1571#[cfg_attr(not(test), moxy::function)]
1572pub fn bind_retry_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1573    cli_support::bind_retry_fixture(tokens)
1574}
1575
1576/// Generate bound-listener configuration or startup with the caller's diagnostics.
1577///
1578/// # Errors
1579///
1580/// Rejects input outside this macro's syntax.
1581#[cfg_attr(not(test), moxy::function)]
1582pub fn bound_start_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1583    bound_start_fixture::expand(tokens)
1584}
1585
1586/// Generate directory-assignment requests with explicit broker and partition identities.
1587///
1588/// # Errors
1589///
1590/// Rejects input outside this macro's syntax.
1591#[cfg_attr(not(test), moxy::function)]
1592pub fn assignment_dirs_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1593    bound_start_fixture::assignment_dirs(tokens)
1594}
1595
1596/// Render a metric registry into caller-named bindings while retaining its lock guard.
1597///
1598/// # Errors
1599///
1600/// Rejects input outside this macro's syntax.
1601#[cfg_attr(not(test), moxy::function)]
1602pub fn metric_registry_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1603    bound_start_fixture::metric_registry(tokens)
1604}
1605
1606/// Generate indexed WORM segment metadata with an explicit segment-id namespace.
1607///
1608/// # Errors
1609///
1610/// Rejects input outside this macro's syntax.
1611#[cfg_attr(not(test), moxy::function)]
1612pub fn worm_segment_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1613    remote_metadata_fixtures::worm_segment(tokens)
1614}
1615
1616/// Generate the started remote-segment fixture with an explicit metadata crate.
1617///
1618/// # Errors
1619///
1620/// Rejects input outside this macro's syntax.
1621#[cfg_attr(not(test), moxy::function)]
1622pub fn remote_started_segment(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1623    remote_metadata_fixtures::remote_started_segment(tokens)
1624}
1625
1626/// Generate a SCRAM user request preserving optional and ordered user lists.
1627///
1628/// # Errors
1629///
1630/// Rejects input outside this macro's syntax.
1631#[cfg_attr(not(test), moxy::function)]
1632pub fn scram_users_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1633    bound_start_fixture::scram_users(tokens)
1634}
1635
1636/// Generate the first matching record header decoder with an explicit UTF-8 policy.
1637///
1638/// # Errors
1639///
1640/// Rejects input outside this macro's syntax.
1641#[cfg_attr(not(test), moxy::function)]
1642pub fn record_header_text(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1643    fixtures::record_header_text(tokens)
1644}
1645
1646/// Generate the shared dead-letter metric observations with caller-selected types.
1647///
1648/// # Errors
1649///
1650/// Rejects input outside this macro's syntax.
1651#[cfg_attr(not(test), moxy::function)]
1652pub fn share_dlq_meters(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1653    fixtures::share_dlq_meters(tokens)
1654}
1655
1656/// Generate exported segment paths with an explicit snapshot and lazy epoch projection.
1657///
1658/// # Errors
1659///
1660/// Rejects input outside this macro's syntax.
1661#[cfg_attr(not(test), moxy::function)]
1662pub fn export_segment_data_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1663    network_fixtures::export_segment_data(tokens)
1664}
1665
1666/// Keep partition-spawn wrappers on one shared parameter list.
1667#[moxy::attribute(name = "partition_spawn_parameters")]
1668pub fn partition_spawn_parameters(
1669    meta: TokenStream,
1670    item: NativeTokenStream,
1671) -> Result<NativeTokenStream, ParseError> {
1672    network_fixtures::partition_spawn_parameters(meta, item)
1673}
1674
1675/// Generate a checkpoint writer with a caller-selected failure kind.
1676///
1677/// # Errors
1678///
1679/// Rejects input outside this macro's syntax.
1680#[cfg_attr(not(test), moxy::function)]
1681pub fn epoch_checkpoint_failure(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1682    network_fixtures::epoch_checkpoint_failure(tokens)
1683}
1684
1685/// Generate a JVM checkpoint decoder fixture with explicit bytes, name and image.
1686///
1687/// # Errors
1688///
1689/// Rejects input outside this macro's syntax.
1690#[cfg_attr(not(test), moxy::function)]
1691pub fn jvm_checkpoint_dump_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1692    network_fixtures::jvm_checkpoint_dump(tokens)
1693}
1694
1695/// Compose a compile-time Java string-producer probe with shared imports and setup.
1696///
1697/// # Errors
1698///
1699/// Rejects input outside this macro's syntax.
1700#[cfg_attr(not(test), moxy::function)]
1701pub fn java_string_producer_source(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1702    network_fixtures::java_string_producer(tokens)
1703}
1704
1705/// Define a wall-clock reader preserving caller attributes and overflow behavior.
1706///
1707/// # Errors
1708///
1709/// Rejects input outside this macro's syntax.
1710#[cfg_attr(not(test), moxy::function)]
1711pub fn epoch_millis_fn(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1712    network_fixtures::epoch_millis(tokens)
1713}
1714
1715/// Gate original items or expressions on the supported sendfile platforms.
1716#[moxy::function(name = "sendfile_platform")]
1717#[expect(
1718    clippy::unnecessary_wraps,
1719    reason = "Moxy's proc_macro adapter requires a Result-returning entry point"
1720)]
1721pub fn sendfile_platform(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1722    Ok(network_fixtures::sendfile_platform(tokens))
1723}
1724
1725/// Generate a test authorizer while retaining the original policy body tokens.
1726#[moxy::function(name = "test_authorizer")]
1727pub fn test_authorizer(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1728    network_fixtures::test_authorizer(tokens)
1729}
1730
1731/// Generate checked Unix-millisecond fixtures with explicit panic contexts.
1732///
1733/// # Errors
1734///
1735/// Rejects input outside this macro's syntax.
1736#[cfg_attr(not(test), moxy::function)]
1737pub fn unix_millis_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1738    bound_start_fixture::unix_millis(tokens)
1739}
1740
1741/// Generate a Vec request frame with the caller's checked length-prefix type.
1742///
1743/// # Errors
1744///
1745/// Rejects input outside this macro's syntax.
1746#[cfg_attr(not(test), moxy::function)]
1747pub fn vector_request_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1748    bound_start_fixture::vector_request(tokens)
1749}
1750/// Generate the independent eight-row supported-feature oracle.
1751///
1752/// # Errors
1753///
1754/// Rejects input outside this macro's syntax.
1755#[cfg_attr(not(test), moxy::function)]
1756pub fn supported_features_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1757    cross_storage_fixtures::supported_features_fixture(tokens)
1758}
1759
1760/// Generate supported-feature rows from explicit wire bounds.
1761///
1762/// # Errors
1763///
1764/// Rejects input outside this macro's syntax.
1765#[cfg_attr(not(test), moxy::function)]
1766pub fn supported_feature_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1767    cross_storage_fixtures::supported_feature_fixture(tokens)
1768}
1769/// Generate finalized-feature rows from explicit wire levels.
1770///
1771/// # Errors
1772///
1773/// Rejects input outside this macro's syntax.
1774#[cfg_attr(not(test), moxy::function)]
1775pub fn finalized_feature_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1776    cross_storage_fixtures::finalized_feature_fixture(tokens)
1777}
1778/// Generate the record input used by byte-limit tests.
1779///
1780/// # Errors
1781///
1782/// Rejects input outside this macro's syntax.
1783#[cfg_attr(not(test), moxy::function)]
1784pub fn record_limit_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1785    cross_storage_fixtures::record_limit_fixture(tokens)
1786}
1787/// Generate keyed compaction batches with explicit producer state and timestamp.
1788///
1789/// # Errors
1790///
1791/// Rejects input outside this macro's syntax.
1792#[cfg_attr(not(test), moxy::function)]
1793pub fn compaction_record_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1794    cross_storage_fixtures::compaction_record_fixture(tokens)
1795}
1796/// Project registration feature bounds into an ordered map.
1797///
1798/// # Errors
1799///
1800/// Rejects input outside this macro's syntax.
1801#[cfg_attr(not(test), moxy::function)]
1802pub fn registration_feature_projection(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1803    cross_storage_fixtures::registration_feature_projection(tokens)
1804}
1805/// Generate the validated client frame-size parser.
1806///
1807/// # Errors
1808///
1809/// Rejects input outside this macro's syntax.
1810#[cfg_attr(not(test), moxy::function)]
1811pub fn frame_max_parser(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1812    cli_support::frame_max_parser(tokens)
1813}
1814
1815/// Generate the validated connection dispatch-capacity parser.
1816///
1817/// # Errors
1818///
1819/// Rejects input outside this macro's syntax.
1820#[cfg_attr(not(test), moxy::function)]
1821pub fn dispatch_capacity_parser(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1822    cli_support::dispatch_capacity_parser(tokens)
1823}
1824
1825/// Share S3 endpoint and credential fields with the original configuration documentation.
1826#[moxy::attribute]
1827pub fn s3_fields(meta: TokenStream, item: TokenStream) -> Result<TokenStream, ParseError> {
1828    s3_fields::expand(meta, item)
1829}
1830
1831/// Define a named `SplitMix64` step that advances the caller's stream state.
1832/// Placement shuffles and benchmark byte streams share the exact same arithmetic.
1833///
1834/// # Errors
1835///
1836/// Rejects input outside this macro's syntax.
1837#[cfg_attr(not(test), moxy::function)]
1838pub fn splitmix64_step(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1839    deterministic_random::splitmix64_step(tokens)
1840}
1841
1842/// Generate an independent compression-byte oracle with a named codec level.
1843///
1844/// # Errors
1845///
1846/// Rejects input outside this macro's syntax.
1847#[cfg_attr(not(test), moxy::function)]
1848pub fn compression_bytes_fixture(tokens: TokenStream) -> Result<TokenStream, ParseError> {
1849    cross_storage_fixtures::compression_bytes_fixture(tokens)
1850}
1851
1852mod reaper_task;
1853mod record_strings;
1854mod seed_member_maps;
1855mod sweep_loop;
1856
1857/// Snapshot member metadata and assignments using the protocol's explicit target body.
1858#[moxy::function]
1859pub fn snapshot_member_maps(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1860    seed_member_maps::snapshot(tokens)
1861}
1862
1863/// Restore member epochs before the protocol's explicit assignment body.
1864#[moxy::function]
1865pub fn hydrate_member_epochs(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1866    seed_member_maps::hydrate(tokens)
1867}
1868
1869/// Declare request string traversal in field order, with optional native traversal bodies.
1870#[moxy::function]
1871pub fn record_strings(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1872    record_strings::expand(tokens)
1873}
1874
1875/// Run an explicit sweep body with the selected cadence and shutdown body.
1876#[moxy::function]
1877pub fn sweep_loop(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1878    sweep_loop::expand(tokens)
1879}
1880
1881/// Schedule an ordinary transaction sweep and retain its caller's shutdown event.
1882#[moxy::attribute]
1883pub fn reaper_task(
1884    meta: NativeTokenStream,
1885    item: NativeTokenStream,
1886) -> Result<NativeTokenStream, ParseError> {
1887    reaper_task::expand(meta, item)
1888}
1889
1890mod archive_rows;
1891mod authorization_refusal;
1892mod bench_harness;
1893mod broker_test_setup;
1894mod described_group_rows;
1895mod forwardable_requests;
1896mod freeze_refusal_rules;
1897mod group_record_key;
1898mod handler_wire_fixtures;
1899mod model_properties;
1900mod model_runner;
1901mod quorum_epoch_wire;
1902mod reconciliation_fields;
1903mod reconciliation_operations;
1904mod reconciliation_projection;
1905mod request_test_identity;
1906mod scheduled_loads;
1907mod share_fixture_schemas;
1908mod share_refusal_matrix;
1909mod share_state_constructors;
1910mod share_state_operation;
1911mod share_state_results;
1912mod simulation_message;
1913
1914/// Declare forwardable API keys and decode each embedded body with its selected request type.
1915#[moxy::function]
1916pub fn forwardable_requests(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1917    forwardable_requests::expand(&input.into()).map(Into::into)
1918}
1919/// Add the selected common projection fields around the visible protocol-specific fields.
1920#[moxy::attribute]
1921pub fn reconciliation_fields(
1922    meta: NativeTokenStream,
1923    item: NativeTokenStream,
1924) -> Result<NativeTokenStream, ParseError> {
1925    reconciliation_fields::expand(&meta.into(), item)
1926}
1927/// Run share-offset refusal cases with direct startup, identity, assertions and shutdown.
1928#[moxy::function]
1929pub fn share_refusal_matrix(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1930    share_refusal_matrix::expand(input)
1931}
1932/// Derive projection construction from the member declaration's visible fields.
1933#[moxy::derive(ReconciliationMember, attributes(reconciliation))]
1934pub fn reconciliation_member(item: ItemStruct) -> Result<TokenStream, ParseError> {
1935    reconciliation_projection::member(item)
1936}
1937
1938/// Encode and parse a visible group-record key enum with explicit version constants.
1939#[moxy::derive(GroupRecordKey, attributes(group_key))]
1940pub fn group_record_key(item: ItemEnum) -> Result<TokenStream, ParseError> {
1941    group_record_key::expand(item)
1942}
1943
1944/// Implement partition routing from a visible simulation message declaration.
1945#[moxy::derive(PartitionMessage)]
1946pub fn partition_message(item: ItemStruct) -> Result<TokenStream, ParseError> {
1947    simulation_message::expand(item)
1948}
1949
1950/// Adapt the external quorum-epoch request types listed at the caller.
1951#[moxy::function]
1952pub fn quorum_epoch_requests(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1953    quorum_epoch_wire::requests(&input.into()).map(Into::into)
1954}
1955
1956/// Map native voter listeners to the selected quorum wire endpoint type.
1957#[moxy::function]
1958pub fn voter_endpoints(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1959    quorum_epoch_wire::voter_endpoints(input)
1960}
1961
1962/// Supply the common quorum-epoch response layout under an explicit function signature.
1963#[moxy::function]
1964pub fn quorum_epoch_encoder(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1965    quorum_epoch_wire::encoder(input)
1966}
1967
1968/// Encode a typed authorization refusal with its optional native message expression.
1969#[moxy::function]
1970pub fn authorization_refusal(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1971    authorization_refusal::expand(input)
1972}
1973
1974/// Share an exhaustive freeze mutation inventory under explicit runtime and logical headers.
1975#[moxy::function]
1976pub fn freeze_refusal_rules(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1977    freeze_refusal_rules::expand(input)
1978}
1979
1980/// Construct the fixed empty ACL matching filter for the selected external request type.
1981#[moxy::function]
1982pub fn empty_match_acl_filter(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1983    handler_wire_fixtures::empty_match_acl_filter(&input.into()).map(Into::into)
1984}
1985
1986/// Compare a delegation-token refusal with the full selected wire response.
1987#[moxy::function]
1988pub fn token_refusal_result(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1989    handler_wire_fixtures::token_refusal_result(&input.into()).map(Into::into)
1990}
1991
1992/// Construct an external share-state request from visible field expressions.
1993#[moxy::function]
1994pub fn share_state_request(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
1995    share_state_constructors::expand(input)
1996}
1997
1998/// Associate share-state response schemas with the listed request types.
1999#[moxy::function]
2000pub fn share_fixture_schemas(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2001    share_fixture_schemas::expand(&input.into()).map(Into::into)
2002}
2003
2004/// Adapt the listed external response rows to the partition-result trait.
2005#[moxy::function]
2006pub fn share_partition_results(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2007    described_group_rows::partition_results(&input.into()).map(Into::into)
2008}
2009
2010/// Run native share-state partition operations concurrently while preserving request order.
2011#[moxy::function]
2012pub fn share_state_results(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2013    share_state_results::expand(input)
2014}
2015
2016/// Add shared active-state admission and reply handling to a visible async method.
2017#[moxy::attribute]
2018pub fn share_state_operation(
2019    meta: NativeTokenStream,
2020    item: NativeTokenStream,
2021) -> Result<NativeTokenStream, ParseError> {
2022    share_state_operation::expand(&meta.into(), item)
2023}
2024
2025/// Derive group projection construction and epoch checks from its visible fields.
2026#[moxy::derive(ReconciliationGroup, attributes(reconciliation))]
2027pub fn reconciliation_group(item: ItemStruct) -> Result<TokenStream, ParseError> {
2028    reconciliation_projection::group(item)
2029}
2030
2031/// Derive heartbeat conversion from a visible reconciliation action enum.
2032#[moxy::derive(ReconciliationAction)]
2033pub fn reconciliation_action(item: ItemEnum) -> Result<TokenStream, ParseError> {
2034    reconciliation_projection::action(item)
2035}
2036
2037/// Observe a projected model epoch using its visible epoch field and violation ledger.
2038#[moxy::derive(ModelEpochLedger)]
2039pub fn model_epoch_ledger(item: ItemStruct) -> Result<TokenStream, ParseError> {
2040    reconciliation_projection::epoch(item)
2041}
2042
2043/// Build ordered model properties around their original native oracle blocks.
2044#[moxy::function]
2045pub fn model_properties(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2046    model_properties::expand(input)
2047}
2048
2049/// Run a model with explicit search bounds and pinned state counts.
2050#[moxy::function]
2051pub fn model_runner(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2052    model_runner::expand(input)
2053}
2054
2055/// Rebuild a reconciliation group around explicit native setup and projection operations.
2056#[moxy::function]
2057pub fn rebuild_reconciliation_group(
2058    input: NativeTokenStream,
2059) -> Result<NativeTokenStream, ParseError> {
2060    reconciliation_operations::rebuild(input)
2061}
2062
2063/// Apply an explicit member action and project the resulting reconciliation state.
2064#[moxy::function]
2065pub fn reconciliation_next_state(
2066    input: NativeTokenStream,
2067) -> Result<NativeTokenStream, ParseError> {
2068    reconciliation_operations::next_state(input)
2069}
2070
2071/// Emit reconciliation action scheduling with explicit caller predicates and extensions.
2072#[moxy::function]
2073pub fn reconciliation_actions(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2074    reconciliation_operations::actions(input)
2075}
2076
2077/// Retain the broker handle and directory before native readiness operations.
2078#[moxy::function]
2079pub fn broker_test_setup(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2080    broker_test_setup::expand(input)
2081}
2082
2083/// Retain principal and peer values for an explicitly selected borrowed request context.
2084#[moxy::function]
2085pub fn request_test_identity(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2086    request_test_identity::expand(input)
2087}
2088
2089/// Join the visible task collection in order and log its selected failure message.
2090#[moxy::derive(ScheduledLoads, attributes(scheduled_loads))]
2091pub fn scheduled_loads(item: ItemStruct) -> Result<TokenStream, ParseError> {
2092    scheduled_loads::expand(item)
2093}
2094
2095/// `benches()` and `criterion_main!` for a benchmark suite's target paths.
2096///
2097/// `bench_main!(a, m::b)` runs each target in order. A target returns `()` or
2098/// a `Result`; the first error is printed under the target's path and exits
2099/// with status 1.
2100///
2101/// # Errors
2102///
2103/// Rejects input outside this macro's syntax.
2104#[moxy::function]
2105pub fn bench_main(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2106    bench_harness::main(&input.into()).map(Into::into)
2107}
2108
2109/// The recording harness of a benchmark suite that measures on after a
2110/// failure: `BenchResult`, `FirstError`, `run` and `report_failures`.
2111///
2112/// # Errors
2113///
2114/// Rejects any argument.
2115#[moxy::function]
2116pub fn bench_failures(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2117    bench_harness::failures(&input.into()).map(Into::into)
2118}
2119
2120/// Implement group-describe row access for an explicit table of external response types.
2121#[moxy::function]
2122pub fn described_group_rows(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2123    described_group_rows::expand(&input.into()).map(Into::into)
2124}
2125
2126/// Generate one annotated archive-validation walk with coherent proof bindings.
2127#[moxy::function(name = "validate_archive_rows")]
2128pub fn validate_archive_rows(tokens: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2129    let expanded = archive_rows::expand(tokens.into())?;
2130    // Creusot matches logical captures to MIR locals by identifier context.
2131    // Reparse the complete function together so generated and supplied annotations
2132    // share the same context as the local bindings they describe.
2133    expanded
2134        .to_string()
2135        .parse()
2136        .map_err(|_| ParseError::new(Span::call_site(), "invalid archive walk expansion"))
2137}
2138
2139#[cfg(test)]
2140mod export_contract_tests {
2141    use {super::*, assert2::assert};
2142
2143    type Expand = fn(TokenStream) -> Result<TokenStream, ParseError>;
2144    struct FunctionMacro {
2145        name: &'static str,
2146        expand: Expand,
2147    }
2148    const FUNCTION_MACROS: [FunctionMacro; 84] = [
2149        FunctionMacro {
2150            name: "dispatch_table",
2151            expand: dispatch_table,
2152        },
2153        FunctionMacro {
2154            name: "throttle_probes",
2155            expand: throttle_probes,
2156        },
2157        FunctionMacro {
2158            name: "cli_main",
2159            expand: cli_main,
2160        },
2161        FunctionMacro {
2162            name: "bounded_bfs",
2163            expand: bounded_bfs,
2164        },
2165        FunctionMacro {
2166            name: "delete_topic_request",
2167            expand: delete_topic_request,
2168        },
2169        FunctionMacro {
2170            name: "compacted_batch",
2171            expand: compacted_batch,
2172        },
2173        FunctionMacro {
2174            name: "record_batch_fixture",
2175            expand: record_batch_fixture,
2176        },
2177        FunctionMacro {
2178            name: "simulation_actions",
2179            expand: simulation_actions,
2180        },
2181        FunctionMacro {
2182            name: "simulation_transport",
2183            expand: simulation_transport,
2184        },
2185        FunctionMacro {
2186            name: "simulation_heartbeat",
2187            expand: simulation_heartbeat,
2188        },
2189        FunctionMacro {
2190            name: "benchmark_scenario_fixture",
2191            expand: benchmark_scenario_fixture,
2192        },
2193        FunctionMacro {
2194            name: "benchmark_latency_fixture",
2195            expand: benchmark_latency_fixture,
2196        },
2197        FunctionMacro {
2198            name: "s3_archive_config_fixture",
2199            expand: s3_archive_config_fixture,
2200        },
2201        FunctionMacro {
2202            name: "remote_segment_check",
2203            expand: remote_segment_check,
2204        },
2205        FunctionMacro {
2206            name: "simulation_step",
2207            expand: simulation_step,
2208        },
2209        FunctionMacro {
2210            name: "snapshot_topic_fixture",
2211            expand: snapshot_topic_fixture,
2212        },
2213        FunctionMacro {
2214            name: "timestamped_batch",
2215            expand: timestamped_batch,
2216        },
2217        FunctionMacro {
2218            name: "producer_batch_fixture",
2219            expand: producer_batch_fixture,
2220        },
2221        FunctionMacro {
2222            name: "create_topic_fixture",
2223            expand: create_topic_fixture,
2224        },
2225        FunctionMacro {
2226            name: "consumer_fetch_fixture",
2227            expand: consumer_fetch_fixture,
2228        },
2229        FunctionMacro {
2230            name: "single_replica_partition_fixture",
2231            expand: single_replica_partition_fixture,
2232        },
2233        FunctionMacro {
2234            name: "control_marker_fixture",
2235            expand: control_marker_fixture,
2236        },
2237        FunctionMacro {
2238            name: "topic_record_fixture",
2239            expand: topic_record_fixture,
2240        },
2241        FunctionMacro {
2242            name: "ephemeral_port_fixture",
2243            expand: ephemeral_port_fixture,
2244        },
2245        FunctionMacro {
2246            name: "projection_identity",
2247            expand: projection_identity,
2248        },
2249        FunctionMacro {
2250            name: "minio_fixture",
2251            expand: minio_fixture,
2252        },
2253        FunctionMacro {
2254            name: "scram_client_first",
2255            expand: scram_client_first,
2256        },
2257        FunctionMacro {
2258            name: "remote_segment_transition_matrix",
2259            expand: remote_segment_transition_matrix,
2260        },
2261        FunctionMacro {
2262            name: "capture_layer_fixture",
2263            expand: capture_layer_fixture,
2264        },
2265        FunctionMacro {
2266            name: "remote_segment_fixtures",
2267            expand: remote_segment_fixtures,
2268        },
2269        FunctionMacro {
2270            name: "remote_metadata_missing",
2271            expand: remote_metadata_missing,
2272        },
2273        FunctionMacro {
2274            name: "async_write_delegate",
2275            expand: async_write_delegate,
2276        },
2277        FunctionMacro {
2278            name: "timer_hooks",
2279            expand: timer_hooks,
2280        },
2281        FunctionMacro {
2282            name: "scram_client_proof_fixture",
2283            expand: scram_client_proof_fixture,
2284        },
2285        FunctionMacro {
2286            name: "single_partition_produce_fixture",
2287            expand: single_partition_produce_fixture,
2288        },
2289        FunctionMacro {
2290            name: "request_frame_fixture",
2291            expand: request_frame_fixture,
2292        },
2293        FunctionMacro {
2294            name: "patterned_bytes_fixture",
2295            expand: patterned_bytes_fixture,
2296        },
2297        FunctionMacro {
2298            name: "break_glass_golden_id",
2299            expand: break_glass_golden_id,
2300        },
2301        FunctionMacro {
2302            name: "jvm_principal_golden",
2303            expand: jvm_principal_golden,
2304        },
2305        FunctionMacro {
2306            name: "frame_prefix_fixture",
2307            expand: frame_prefix_fixture,
2308        },
2309        FunctionMacro {
2310            name: "file_region_fixture",
2311            expand: file_region_fixture,
2312        },
2313        FunctionMacro {
2314            name: "empty_endpoint_voters",
2315            expand: empty_endpoint_voters,
2316        },
2317        FunctionMacro {
2318            name: "epoch_record_batch_fixture",
2319            expand: epoch_record_batch_fixture,
2320        },
2321        FunctionMacro {
2322            name: "epoch_log_view",
2323            expand: epoch_log_view,
2324        },
2325        FunctionMacro {
2326            name: "legacy_policy_fixture",
2327            expand: legacy_policy_fixture,
2328        },
2329        FunctionMacro {
2330            name: "keyed_record_batch_fixture",
2331            expand: keyed_record_batch_fixture,
2332        },
2333        FunctionMacro {
2334            name: "duration_cases_fixture",
2335            expand: duration_cases_fixture,
2336        },
2337        FunctionMacro {
2338            name: "directory_tree_fixture",
2339            expand: directory_tree_fixture,
2340        },
2341        FunctionMacro {
2342            name: "parsed_cli_entrypoint",
2343            expand: parsed_cli_entrypoint,
2344        },
2345        FunctionMacro {
2346            name: "duration_parser_fixture",
2347            expand: duration_parser_fixture,
2348        },
2349        FunctionMacro {
2350            name: "bootstrap_parser_fixture",
2351            expand: bootstrap_parser_fixture,
2352        },
2353        FunctionMacro {
2354            name: "snapshot_node_fixture",
2355            expand: snapshot_node_fixture,
2356        },
2357        FunctionMacro {
2358            name: "connect_cli_client",
2359            expand: connect_cli_client,
2360        },
2361        FunctionMacro {
2362            name: "format_directories_fixture",
2363            expand: format_directories_fixture,
2364        },
2365        FunctionMacro {
2366            name: "wal_capture_topic_fixture",
2367            expand: wal_capture_topic_fixture,
2368        },
2369        FunctionMacro {
2370            name: "flag_metadata_fixture",
2371            expand: flag_metadata_fixture,
2372        },
2373        FunctionMacro {
2374            name: "bind_retry_fixture",
2375            expand: bind_retry_fixture,
2376        },
2377        FunctionMacro {
2378            name: "bound_start_fixture",
2379            expand: bound_start_fixture,
2380        },
2381        FunctionMacro {
2382            name: "assignment_dirs_fixture",
2383            expand: assignment_dirs_fixture,
2384        },
2385        FunctionMacro {
2386            name: "metric_registry_fixture",
2387            expand: metric_registry_fixture,
2388        },
2389        FunctionMacro {
2390            name: "worm_segment_fixture",
2391            expand: worm_segment_fixture,
2392        },
2393        FunctionMacro {
2394            name: "remote_started_segment",
2395            expand: remote_started_segment,
2396        },
2397        FunctionMacro {
2398            name: "scram_users_fixture",
2399            expand: scram_users_fixture,
2400        },
2401        FunctionMacro {
2402            name: "record_header_text",
2403            expand: record_header_text,
2404        },
2405        FunctionMacro {
2406            name: "share_dlq_meters",
2407            expand: share_dlq_meters,
2408        },
2409        FunctionMacro {
2410            name: "export_segment_data_fixture",
2411            expand: export_segment_data_fixture,
2412        },
2413        FunctionMacro {
2414            name: "epoch_checkpoint_failure",
2415            expand: epoch_checkpoint_failure,
2416        },
2417        FunctionMacro {
2418            name: "jvm_checkpoint_dump_fixture",
2419            expand: jvm_checkpoint_dump_fixture,
2420        },
2421        FunctionMacro {
2422            name: "java_string_producer_source",
2423            expand: java_string_producer_source,
2424        },
2425        FunctionMacro {
2426            name: "epoch_millis_fn",
2427            expand: epoch_millis_fn,
2428        },
2429        FunctionMacro {
2430            name: "unix_millis_fixture",
2431            expand: unix_millis_fixture,
2432        },
2433        FunctionMacro {
2434            name: "vector_request_fixture",
2435            expand: vector_request_fixture,
2436        },
2437        FunctionMacro {
2438            name: "supported_features_fixture",
2439            expand: supported_features_fixture,
2440        },
2441        FunctionMacro {
2442            name: "supported_feature_fixture",
2443            expand: supported_feature_fixture,
2444        },
2445        FunctionMacro {
2446            name: "finalized_feature_fixture",
2447            expand: finalized_feature_fixture,
2448        },
2449        FunctionMacro {
2450            name: "record_limit_fixture",
2451            expand: record_limit_fixture,
2452        },
2453        FunctionMacro {
2454            name: "compaction_record_fixture",
2455            expand: compaction_record_fixture,
2456        },
2457        FunctionMacro {
2458            name: "registration_feature_projection",
2459            expand: registration_feature_projection,
2460        },
2461        FunctionMacro {
2462            name: "dispatch_capacity_parser",
2463            expand: dispatch_capacity_parser,
2464        },
2465        FunctionMacro {
2466            name: "frame_max_parser",
2467            expand: frame_max_parser,
2468        },
2469        FunctionMacro {
2470            name: "simulation_earliest_timer",
2471            expand: simulation_earliest_timer,
2472        },
2473        FunctionMacro {
2474            name: "refused_fetch_partition_fixture",
2475            expand: refused_fetch_partition_fixture,
2476        },
2477        FunctionMacro {
2478            name: "splitmix64_step",
2479            expand: splitmix64_step,
2480        },
2481        FunctionMacro {
2482            name: "compression_bytes_fixture",
2483            expand: compression_bytes_fixture,
2484        },
2485    ];
2486
2487    #[test]
2488    fn function_macros_keep_their_empty_input_contract() {
2489        let accepted: Vec<_> = FUNCTION_MACROS
2490            .into_iter()
2491            .filter_map(|entry| {
2492                (entry.expand)(TokenStream::new())
2493                    .is_ok()
2494                    .then_some(entry.name)
2495            })
2496            .collect();
2497        // Dispatch and throttle tables permit zero entries; fixtures need arguments.
2498        assert!(accepted == ["dispatch_table", "throttle_probes"]);
2499    }
2500}
2501
2502mod verified_index;
2503
2504/// Declare a verified binary-search cursor over named index entries.
2505#[moxy::function]
2506pub fn sorted_index_cursor(input: TokenStream) -> Result<TokenStream, ParseError> {
2507    verified_index::cursor(input)
2508}
2509
2510/// Declare a verified last-predecessor lookup over named index entries.
2511#[moxy::function]
2512pub fn index_floor_lookup(input: TokenStream) -> Result<TokenStream, ParseError> {
2513    verified_index::floor(input)
2514}
2515
2516/// Add the contract of a remote finished-segment selection.
2517#[moxy::attribute]
2518pub fn finished_selection(
2519    meta: NativeTokenStream,
2520    item: NativeTokenStream,
2521) -> Result<NativeTokenStream, ParseError> {
2522    verified_index::finished(meta, item)
2523}
2524
2525/// Add the shared domain and proof annotations of a round-robin site lemma.
2526#[moxy::attribute]
2527pub fn round_robin_site_lemma(
2528    meta: NativeTokenStream,
2529    item: NativeTokenStream,
2530) -> Result<NativeTokenStream, ParseError> {
2531    verified_index::site(meta, item)
2532}
2533
2534mod fixture_methods;
2535mod group_record_flush;
2536mod unit_schema;
2537
2538/// Describe a visible human-unit schema marker.
2539#[moxy::derive(UnitSchema, attributes(unit_schema))]
2540pub fn unit_schema(item: ItemStruct) -> Result<TokenStream, ParseError> {
2541    unit_schema::expand(item)
2542}
2543
2544/// Append the shared metadata forwarding methods to an authorizer implementation.
2545#[moxy::attribute]
2546pub fn delegate_authorizer(
2547    meta: NativeTokenStream,
2548    item: NativeTokenStream,
2549) -> Result<NativeTokenStream, ParseError> {
2550    fixture_methods::authorizer(meta, item)
2551}
2552
2553/// Append missing-read behavior to an explicit remote-log implementation.
2554#[moxy::attribute]
2555pub fn missing_remote_reads(
2556    meta: NativeTokenStream,
2557    item: NativeTokenStream,
2558) -> Result<NativeTokenStream, ParseError> {
2559    fixture_methods::remote(meta, item)
2560}
2561
2562/// Preserve the visible flush body inside the shared group-log append boundary.
2563#[moxy::attribute]
2564pub fn flush_group_records(
2565    meta: NativeTokenStream,
2566    item: NativeTokenStream,
2567) -> Result<NativeTokenStream, ParseError> {
2568    group_record_flush::expand(meta, item)
2569}
2570
2571mod handler_wire_rows;
2572
2573/// Build offset-fetch rows for an explicit table of wire schemas.
2574#[moxy::function]
2575pub fn offset_fetch_rows(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2576    handler_wire_rows::offset_fetch_rows(&input.into()).map(Into::into)
2577}
2578
2579/// Build a share-group refusal with the caller's owned fields.
2580#[moxy::function]
2581pub fn share_group_denial(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2582    handler_wire_rows::share_group_denial(&input.into()).map(Into::into)
2583}
2584
2585/// Project acknowledgement batches while preserving the native expression.
2586#[moxy::function]
2587pub fn acknowledgement_batches(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2588    handler_wire_rows::acknowledgement_batches(input)
2589}
2590
2591mod coordinator_fixtures;
2592
2593/// Declare heartbeat fixtures with named status observations.
2594#[moxy::function]
2595pub fn heartbeat_status(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2596    coordinator_fixtures::heartbeat(&input.into()).map(Into::into)
2597}
2598
2599/// Preserve native key-boundary observations in generated coordinator tests.
2600#[moxy::function]
2601pub fn member_key_boundaries(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2602    coordinator_fixtures::key_boundaries(input)
2603}
2604
2605/// Schedule explicit commit changes and preserve caller-owned async actions.
2606#[moxy::function]
2607pub fn schedule_commit_changes(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2608    coordinator_fixtures::commit_changes(input)
2609}
2610
2611mod bounded_unit_modules;
2612
2613/// Declare concrete bounded human-unit serde modules from one flat table.
2614#[moxy::function]
2615pub fn bounded_unit_modules(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2616    bounded_unit_modules::expand(&input.into()).map(Into::into)
2617}
2618
2619mod fixture_constructors;
2620
2621/// Declare fixture constructors from the existing election, supervisor and quota domains.
2622#[moxy::function]
2623pub fn fixture_constructors(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2624    fixture_constructors::expand(&input.into()).map(Into::into)
2625}
2626
2627mod wire_test_driver;
2628
2629/// Declare wire drivers that call the existing socket and framing helpers.
2630#[moxy::function]
2631pub fn wire_test_driver(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2632    wire_test_driver::expand(&input.into()).map(Into::into)
2633}
2634
2635mod replication_target_guard;
2636
2637/// Acquire the local replication target with the original caller-level drop behavior.
2638#[moxy::function]
2639pub fn replication_target_guard(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2640    replication_target_guard::expand(&input.into()).map(Into::into)
2641}
2642
2643mod share_test_drivers;
2644
2645/// Declare a first share fetch through the existing client helper.
2646#[moxy::function]
2647pub fn share_first_fetch(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2648    share_test_drivers::acquisition(&input.into()).map(Into::into)
2649}
2650
2651/// Declare a share-consumption driver with native caller operations.
2652#[moxy::function]
2653pub fn share_consumption_driver(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2654    share_test_drivers::consumption(input)
2655}
2656
2657mod index_seed_helpers;
2658
2659/// Declare typed sparse-index fixture helpers with explicit index and key types.
2660#[moxy::function]
2661pub fn index_seed_helpers(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2662    index_seed_helpers::expand(&input.into()).map(Into::into)
2663}
2664
2665/// Route `(broker, context, request, version; operation, refusal)` through the
2666/// controller listener, continuing with the request or returning its completed dispatch.
2667#[moxy::function]
2668pub fn controller_request(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2669    handler_wire_rows::controller_request(input)
2670}
2671
2672mod config_alter_handler;
2673
2674/// Declare the shared configuration handler with explicit wire and audit policies.
2675#[moxy::function]
2676pub fn config_alter_handler(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2677    config_alter_handler::expand(&input.into()).map(Into::into)
2678}
2679
2680mod fixture_expressions;
2681
2682/// Verify a guard response and return its typed value.
2683#[moxy::function]
2684pub fn guard_response(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2685    fixture_expressions::guard_response(&input.into()).map(Into::into)
2686}
2687
2688/// Read the evicted local segment state with the declared retention policy.
2689#[moxy::function]
2690pub fn evicted_local_segments(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2691    fixture_expressions::evicted_segments(&input.into()).map(Into::into)
2692}
2693
2694/// Apply reassignment fields in the caller's explicit expression order.
2695#[moxy::function]
2696pub fn reassignment_fields(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2697    fixture_expressions::reassignment(input)
2698}
2699
2700mod share_request_identity;
2701
2702/// Resolve a share request identity before entering the native handler body.
2703#[moxy::attribute]
2704pub fn share_request_identity(
2705    meta: NativeTokenStream,
2706    item: NativeTokenStream,
2707) -> Result<NativeTokenStream, ParseError> {
2708    share_request_identity::expand(meta.into(), item)
2709}
2710
2711mod group_fixture_tables;
2712mod partition_gate;
2713mod private_dispatch_table;
2714mod string_mutations;
2715
2716/// Declare partition authorization gates with explicit actions.
2717#[moxy::function]
2718pub fn partition_gate(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2719    partition_gate::expand(&input.into()).map(Into::into)
2720}
2721
2722/// Declare private request adapters and their registration table.
2723#[moxy::function]
2724pub fn private_dispatch_table(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2725    private_dispatch_table::expand(&input.into()).map(Into::into)
2726}
2727
2728/// Declare required and optional string mutation cases.
2729#[moxy::function]
2730pub fn string_mutations(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2731    string_mutations::expand(&input.into()).map(Into::into)
2732}
2733
2734/// Declare member identity fixtures with explicit schema fields.
2735#[moxy::function]
2736pub fn member_identity_fixtures(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2737    group_fixture_tables::member_identity(input)
2738}
2739
2740/// Declare required-topic traversal for a topology schema.
2741#[moxy::function]
2742pub fn required_topics(input: NativeTokenStream) -> Result<NativeTokenStream, ParseError> {
2743    group_fixture_tables::required_topics(&input.into()).map(Into::into)
2744}
2745
2746mod token_dispatch;
2747
2748/// Adapt an owned delegation-token handler to negotiated wire dispatch.
2749#[moxy::attribute]
2750pub fn token_dispatch(
2751    meta: NativeTokenStream,
2752    item: NativeTokenStream,
2753) -> Result<NativeTokenStream, ParseError> {
2754    token_dispatch::expand(meta.into(), item)
2755}