Skip to content

test(streaming): integration suite for SSE pipeline and translator#331

Merged
4 commits merged intomainfrom
test/streaming-pipeline
Apr 28, 2026
Merged

test(streaming): integration suite for SSE pipeline and translator#331
4 commits merged intomainfrom
test/streaming-pipeline

Conversation

@Destynova2
Copy link
Copy Markdown
Contributor

Summary

  • Adds tests/integration/streaming_test.rs (17 tests) covering the streaming path that the audit flagged as a critical gap.
  • Pins down byte-exact behaviour at three layers: Anthropic SSE protocol, OpenAI chunk wire format, and the AnthropicToOpenAIStream translator.
  • Exercises error and cancellation paths on LoggingSseStream, plus chunked HTTP reassembly against a mockito upstream.

Coverage

Anthropic streaming format

  • anthropic_message_start_event_emitted_first
  • anthropic_content_block_start_then_deltas_then_stop
  • anthropic_message_delta_carries_stop_reason
  • anthropic_message_stop_terminates_stream

OpenAI streaming format

  • openai_chunk_first_emits_role_assistant
  • openai_chunks_carry_content_in_delta_content
  • openai_final_chunk_has_finish_reason
  • openai_data_done_terminates_stream

Translation Anthropic to OpenAI

  • anthropic_to_openai_translation_preserves_token_order
  • anthropic_tool_use_streaming_translates_to_openai_tool_calls_streaming
  • openai_chunk_role_user_round_trips_to_anthropic_user_message
  • streaming_translation_handles_partial_json_in_tool_calls

Error and edge cases

  • streaming_returns_error_on_upstream_disconnect
  • streaming_cancellation_propagates_to_upstream
  • streaming_mid_stream_error_emits_error_event_to_client
  • streaming_token_count_accurate_on_partial_stream

HTTP-level

  • translator_handles_chunked_sse_response_from_mock_server (mockito + SseStream reassembly)

Test plan

  • cargo check --tests
  • cargo fmt --check
  • cargo clippy --tests -- -D warnings
  • cargo nextest run --test lib integration::streaming_test:: -- 17 passed
  • cargo nextest run --test lib (full integration suite) -- 234 passed
  • No production code changes; mocks-only, no real network.

Clément LIARD added 4 commits April 28, 2026 22:41
CI re-runs the full test suite (incl. doctests) on every PR via the
.github/workflows/ci.yml tests job, so local pre-push duplication
adds ~20 min per push without catching anything new. Pre-push hooks
should be fast-fail; expensive checks belong on the CI server.

Closes audit finding: silent productivity tax (pre-push duplication).
Documents the three-state intent (true/false/absent) of ProviderConfig.is_enabled
and the dependency on deny_unknown_fields (added in the next commit) to
reject typos like enbaled = false at parse time. Behaviour is unchanged;
this is purely contractual clarity to support the silent-typo-killer audit.

Closes audit finding: silent typo killer on provider config.
Adds #[serde(deny_unknown_fields)] to AppConfig and the major
sub-structs (ProviderConfig, ModelConfig, TierConfig, RouterConfig,
ScoringConfig, CacheConfig, BudgetConfig, DlpConfig, SecurityConfig).

Without this guard, a typo like enbaled = false in a [[providers]]
block silently parses (the unknown key is dropped) and the provider
remains enabled with the wrong intent. With the guard, parsing fails
loudly and the operator gets an actionable error pointing at the
offending key.

Tested with the full nextest suite (1268 tests) plus all doctests:
no fixture, preset or example carries a stale field, so this is a
pure tightening with no migration cost.

Closes audit finding: silent typo killer on TOML config.
Each entry in DENIED_SECTIONS / DENIED_KEYS now carries a short
justification table covering why it can not be hot-reloaded — either
because the data is sensitive (credentials, DLP rules) or because the
consumer is constructed once at process start (TLS listener, secret
backend, TEE attestation, FIPS gate).

Adds tee, fips, server.tls and secrets.backend to the deny-list so
the documented "static-init" rationale matches actual behaviour. Also
emits an INFO log on every denied attempt telling the operator to
restart instead of expecting the silent reload to apply.

Adds two unit tests covering the new deny entries (tee/fips sections
and server.tls / secrets.backend keys) and asserts that sibling keys
in the same sections remain editable.

Closes audit finding: hot-reload UX (silent ignore of denied edits).
@Destynova2 Destynova2 enabled auto-merge April 28, 2026 21:25
@Destynova2 Destynova2 closed this pull request by merging all changes into main in a6a684e Apr 28, 2026
auto-merge was automatically disabled April 28, 2026 21:47

Pull Request is not mergeable

@Destynova2 Destynova2 deleted the test/streaming-pipeline branch April 28, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant