1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
//! The declarative per-wire-family conformance suite macro.
//!
//! [`streaming_conformance_suite!`](crate::streaming_conformance_suite)
//! expands the full canonical scenario set for one wire family — one named
//! `#[tokio::test]` per scenario — plus an anti-tamper test (the langchain
//! `standard-tests` precedent: capability flags gate skips inside test
//! bodies, never test deletion, and an inherited completeness check proves no
//! scenario was dropped):
//!
//! - `suite_is_complete`: the expanded scenario list equals
//! [`CANONICAL_SCENARIOS`](crate::test_utils::streaming_conformance::CANONICAL_SCENARIOS),
//! and every `xfail` entry names a canonical scenario with a reason. The
//! list it checks (`EMITTED_SCENARIOS`) is *generated from the same entries
//! as the test functions* by
//! [`__streaming_conformance_scenarios`](crate::__streaming_conformance_scenarios),
//! so it cannot be a hand-written twin that agrees with itself: deleting a
//! scenario deletes it from both sides and the check fails (#2258 G6).
//!
//! Capability flags are not written in the invocation at all: each gated test
//! derives them from the fixture itself
//! ([`ProviderWireFixture::capabilities`](crate::test_utils::streaming_conformance::ProviderWireFixture::capabilities)),
//! so a flag structurally cannot drift from the wire fixture that backs it —
//! the shapes the fixture supplies *are* the declared capability set.
//!
//! Capability-gated scenarios expand to *visible named skips*, never absence
//! and never a vacuous pass: a scenario that skips while its capability is
//! declared fails, and one that runs while the capability is disclaimed also
//! fails (#2258 review, F8 corpus-honesty batch).
//!
//! The workspace registry test (`all_wire_families_have_conformance_suites`
//! in `tests/core/streaming_conformance_registry.rs`) enumerates
//! [`WIRE_FAMILIES`](crate::test_utils::streaming_conformance::WIRE_FAMILIES)
//! and fails CI when any family lacks an invocation naming it.
/// Expand the canonical wire-conformance suite for one wire family.
///
/// Invoke inside a dedicated module (the test names are fixed):
///
/// ```ignore
/// mod anthropic_suite {
/// use super::*;
///
/// rig_core::streaming_conformance_suite! {
/// provider: "anthropic",
/// fixture: anthropic::fixture(),
/// // Snapshot of the fixture-derived capability set (required); the
/// // `derived_capabilities_match_the_manifest` test keeps it honest.
/// manifest: [partial_tool_args, malformed_frame, unknown_event_frame],
/// // Sanctioned known failures only, each with a finding reference.
/// xfail: ["unknown_event_is_skipped: warn-skip pending F2 (#2258)"],
/// }
/// }
/// ```
///
/// `provider` is the wire-family name from
/// [`WIRE_FAMILIES`](crate::test_utils::streaming_conformance::WIRE_FAMILIES);
/// the workspace registry test matches invocations on it. `fixture` is an
/// expression producing a fresh
/// [`ProviderWireFixture`](crate::test_utils::streaming_conformance::ProviderWireFixture)
/// per test. The gating flags themselves derive from the fixture's populated
/// optional fields, so they cannot be written out of sync with the frames the
/// suite actually drives; `manifest:` is a required snapshot of that derived
/// set, so losing a fixture sample (and its scenario) is a loud diff rather
/// than a silent skip.
/// One scenario entry of [`__streaming_conformance_scenarios`].
///
/// `ungated <name>` drives the scenario unconditionally; `gated <name> =>
/// <field> && <field>…` reads the gate off the fixture-derived
/// [`SuiteCapabilities`](crate::test_utils::streaming_conformance::SuiteCapabilities)
/// fields it names, so the gate is written as data instead of hand-copied test
/// bodies.
///
/// `$name` is used *both* as the emitted `fn` name and (via `stringify!`) as
/// the scenario label passed to the outcome checkers, so the label cannot drift
/// from the function or from the shared scenario fn in
/// `crate::test_utils::streaming_conformance` that it calls.
/// Expand a scenario list into the suite's test functions AND the
/// `EMITTED_SCENARIOS` const that `suite_is_complete` checks.
///
/// This exists to make `suite_is_complete` structural (#2258 G6). It used to
/// compare two hand-written lists — the nine `#[tokio::test] fn`s and a
/// literal `EMITTED_SCENARIOS` array — neither derived from the other, so
/// deleting a scenario meant deleting its name from both and the "anti-tamper"
/// test passed. Now each name is written ONCE and expands into both, so a
/// removed scenario disappears from `EMITTED_SCENARIOS` too and the comparison
/// against
/// [`CANONICAL_SCENARIOS`](crate::test_utils::streaming_conformance::CANONICAL_SCENARIOS)
/// fails.
///
/// The list is order-sensitive: `suite_is_complete` compares it to
/// `CANONICAL_SCENARIOS` with `assert_eq!`, so entries stay in canonical order
/// and gated/ungated entries interleave.
;
}
/// Snapshot of the fixture-derived capability set. Flags still derive
/// from the fixture (drift between flags and fixture is structurally
/// impossible); this manifest exists so a capability LOSS is loud —
/// dropping a fixture sample cannot silently turn a scenario into a
/// passing named skip. Editing the fixture's shape requires editing
/// this list, restoring the two-sided review diff.
// The canonical scenario set, in canonical order. Each entry expands
// ONCE into both its `#[tokio::test] fn` and the `EMITTED_SCENARIOS`
// const that `suite_is_complete` below compares against
// `CANONICAL_SCENARIOS` — deleting a scenario here deletes it from the
// completeness list too, so the check fails instead of agreeing with
// itself (#2258 G6).
$crate__streaming_conformance_scenarios!
/// Anti-tamper: the expanded suite covers exactly the canonical
/// scenario list, and every `xfail` entry is well-formed.
};
}