Skip to main content

Module streaming_conformance

Module streaming_conformance 

Source
Available on crate feature test-utils and not (target_os=unknown and WebAssembly) only.
Expand description

Wire-sequence conformance scenarios for provider streaming pipelines.

The streaming sibling of rig-agent’s model_conformance: each scenario drives raw wire bytes (SSE or NDJSON) through a provider’s complete streaming path — bytes → decode → normalize → aggregated StreamingCompletionResponse — and asserts the StreamFinal contract table documented on that type. Scenarios state the contract; a per-provider ProviderWireFixture supplies the frames, since each wire format spells the same event differently.

Every sequence family here pins a shipped bug from the #2257 review rounds (rig-2257-code-review-findings-*.md); the per-scenario comments cite the specific finding.

Suites are expanded per wire family by streaming_conformance_suite!. Scenarios a wire cannot spell return an explicit ScenarioOutcome::Skipped that the macro cross-checks against the suite’s declared SuiteCapabilities — a skip is always visible and can never masquerade as a pass, so the executed count is exactly the declared grid minus the named skips (#2258 review, F8 corpus honesty).

Modules§

fixtures
Per-provider wire fixtures for the shared scenario set.

Structs§

BufferedBodyDriver
A buffered-body pipeline (the ChatGPT backend shape): the full SSE body is re-parsed after the fact and merged with the terminal response body.
DrainedStream
Everything the consumer observed from one full pipeline run: the yielded items in order, plus the aggregated choice and terminal record.
InterleavedReasoningFixture
The interleaving-boundary shape for a wire whose reasoning identity is a constant per-stream minted key: reasoning, an interleaved tool call, then more reasoning, which must aggregate as three ordered parts — never one merged item that misorders history on replay.
ProviderWireFixture
Per-provider wire frames for the shared scenario set.
RefusalFixture
Refusal frames and the text the pipeline must deliver for them.
ScenarioReport
Outcome of a passing wire-conformance scenario.
SuiteCapabilities
Streaming-relevant capability flags for one wire family’s conformance suite: which optional sequence shapes the wire can spell.
WireDriver
One provider’s full streaming pipeline over scripted wire chunks.

Enums§

ConformanceError
Typed failure from a wire-conformance scenario.
ScenarioOutcome
What a capability-gated scenario did: ran its assertions, or skipped because the wire family cannot spell the sequence shape.
WireInput
One scripted wire input frame.

Constants§

CANONICAL_SCENARIOS
The canonical fixture-driven scenario set every wire-family suite must expand — one named test each, compared against the macro’s emitted list by its suite_is_complete test (langchain’s anti-tamper precedent).
WIRE_FAMILIES
Every streaming wire family in the workspace. The workspace registry test (all_wire_families_have_conformance_suites) fails CI when any family lacks a streaming_conformance_suite! invocation naming it.

Functions§

assert_valid_event_stream
Executable stream-lifecycle validator (#2258 C1).
bare_terminal_after_only_unparseable_frames_fabricates_nothing
A bare terminal signal after only-unparseable frames must not fabricate a successful terminal record: the parse errors were already surfaced, and a default-usage terminal would dress the failure up as success.
check_gated_outcome
Enforce a capability-gated scenario’s outcome against the suite’s declared capability flag and its xfail list.
check_ungated_outcome
Enforce an always-runnable scenario’s result against the xfail list.
defective_known_event_surfaces_err
A known event whose payload is schema-defective must surface as an Err item (and the stream keeps consuming to the genuine terminal).
delta_less_choice_prelude_is_a_noop
A delta-less choice (the Azure prompt_filter_results prelude) must be a no-op — no error, no content, and the rest of the stream unaffected.
drain_openai_responses_websocket_eventswebsocket and non-target_family=wasm
Drain one OpenAI Responses websocket turn’s server events into everything a streaming consumer would observe, through the SAME decode state machine the production session drives (RawChoiceAccumulator + normalize_responses_stream).
event_frame
Build a typed-event fixture frame.
interleaved_constant_id_reasoning_preserves_order
On a constant-id wire (a boundary-minted per-stream reasoning id), other output closes the open reasoning item: thought → tool call → thought must aggregate as [Reasoning(first), ToolCall, Reasoning(second)] — two items in arrival order, never one merged item that misorders history on replay.
interleaved_reasoning_aggregates_to_one_item
Reasoning deltas interleaved with a tool call, then the item’s completed block, must aggregate to exactly one reasoning item carrying the block’s content.
interleaved_signed_full_reasoning_does_not_erase_prior_thought
On a constant-id wire whose completed reasoning block arrives as a signed full restatement (gemini thoughtSignature), a full block after interleaved output must not replace-and-discard the thought accumulated before the boundary: the choice keeps [Reasoning(first), ToolCall, Reasoning(second, signed)].
invalid_xfail_entries
xfail entries that do not name a canonical scenario or carry no reason.
malformed_frame_surfaces_err_and_terminal_still_completes
A malformed frame between valid content and the genuine terminal must surface as an Err item while the stream keeps consuming, so the terminal still completes it.
multi_part_same_id_reasoning_keeps_every_part
A reasoning item whose output_item.done carries several parts under one item id (summary parts, text, encrypted) must keep every part, in order — same-id sibling blocks append, they never replace each other.
ok_chunks
Build the chunk list for an all-delivered frame sequence.
reasoning_summary_deltas_are_superseded_without_duplication
Reasoning-summary deltas followed by the item’s full output_item.done block must aggregate to the summary exactly once — the full block supersedes its own deltas, never duplicates them.
refusal_frames_deliver_text_without_error
Refusal frames must deliver their text to the consumer without an error.
terminal_body_content_merges_per_kind
On the buffered-body pipeline (the ChatGPT backend), a terminal whose body carries text never seen as a delta must merge that text into the choice exactly once, and a body restating streamed deltas must not duplicate them.
transport_error_after_tool_call_yields_err_then_end
A transport failure after a fully-delivered tool call must yield the tool call, then the Err, then end — with no terminal record after the error.
transport_error_chunk
A scripted mid-stream transport failure chunk.
truncation_preserves_content_without_terminal
Truncation at every position — EOF before content, mid-text, mid-tool-args, after a fully-delivered tool call — must preserve delivered content and never produce a terminal record.
unknown_event_is_skipped
An event type the client does not know must be skipped without an error, and the stream must still complete.
usage_variants_are_reported_or_zero_sentinel
The genuine terminal must report the provider’s usage; a terminal without usage metrics must complete with the documented zero-usage sentinel rather than being suppressed or invented.
xfail_reason
The sanctioned reason for an expected-failure scenario, from xfail entries of the form "scenario_name: reason (finding reference)".

Type Aliases§

WireChunks
The wire frames a driver feeds into the provider’s pipeline. An Err chunk models a mid-stream transport failure.