Make live OpenRouter streaming gate router-safe #138

Merged
lost-rob0t merged 2 commits from fix/46-router-safe-live-streaming into main 2026-08-21 01:17:14 +00:00
lost-rob0t commented 2026-08-21 01:12:47 +00:00 (Migrated from github.com)

Closes #46.

Problem

The live streaming gate conflated two things:

  1. whether OpenRouter successfully delivered a real incremental SSE stream; and
  2. whether whichever model openrouter/free selected obeyed the requested STREAM_OK sentinel.

A healthy free-router request can satisfy every transport invariant and still be routed to a model that answers differently. That is model-quality evidence, not a broken streaming runtime.

Change

  • keep the genuinely live request and the STREAM_OK prompt;
  • continue requiring provider identity, selected underlying model, HTTP 200, response_received, streaming metadata, non-empty final text, at least one incremental event, ordered delivered events, terminal done, finish reason, and usage shape;
  • when the requested model is exactly openrouter/free, treat sentinel compliance as non-blocking quality evidence;
  • when OPENROUTER_TEST_MODEL pins any non-router model, keep sentinel-sensitive acceptance;
  • log both stream_sentinel_required and stream_sentinel_compliant alongside the selected underlying model;
  • add policy regressions pinning free-router versus pinned-model behavior.

Reconciliation

The branch was merged forward onto current main after #116 landed. Final head 4bc03752fdf96f96b9ff85a6c21d8a07cf412f7f is mergeable and the PR remains a single-file live-gate change.

Exact-head validation

PASS on final head:

  • Tree-sitter FFI;
  • supported SWI runtime and fail-closed production static load;
  • deterministic PlUnit;
  • deterministic benchmark/conformance and deep-recursion suites;
  • credential-free CLI and persistence/restart checks;
  • REAL OpenRouter core suite, including live_chain_stream_openrouter;
  • REAL OpenRouter structured repair;
  • REAL OpenRouter benchmark;
  • REAL depth 0/1/2 recursion experiment;
  • one-command REAL RLM CLI smoke.

Live streaming evidence from the exact-head run:

  • requested model: openrouter/free;
  • selected underlying model: poolside/laguna-xs-2.1:free;
  • HTTP status: 200;
  • incremental events: 196;
  • terminal done event: true;
  • usage present: true;
  • sentinel required: false;
  • sentinel compliant: true.

The raw CI log preserves the selected underlying model and both sentinel-quality fields. A future healthy free-router route that ignores the sentinel will therefore stay observable without falsely failing the transport gate.

Non-goals

No fake provider, no credential changes, no provider-error weakening, and no relaxation of actual stream/termination assertions.

Closes #46. ## Problem The live streaming gate conflated two things: 1. whether OpenRouter successfully delivered a real incremental SSE stream; and 2. whether whichever model `openrouter/free` selected obeyed the requested `STREAM_OK` sentinel. A healthy free-router request can satisfy every transport invariant and still be routed to a model that answers differently. That is model-quality evidence, not a broken streaming runtime. ## Change - keep the genuinely live request and the `STREAM_OK` prompt; - continue requiring provider identity, selected underlying model, HTTP 200, response_received, streaming metadata, non-empty final text, at least one incremental event, ordered delivered events, terminal `done`, finish reason, and usage shape; - when the requested model is exactly `openrouter/free`, treat sentinel compliance as non-blocking quality evidence; - when `OPENROUTER_TEST_MODEL` pins any non-router model, keep sentinel-sensitive acceptance; - log both `stream_sentinel_required` and `stream_sentinel_compliant` alongside the selected underlying model; - add policy regressions pinning free-router versus pinned-model behavior. ## Reconciliation The branch was merged forward onto current `main` after #116 landed. Final head `4bc03752fdf96f96b9ff85a6c21d8a07cf412f7f` is mergeable and the PR remains a single-file live-gate change. ## Exact-head validation PASS on final head: - Tree-sitter FFI; - supported SWI runtime and fail-closed production static load; - deterministic PlUnit; - deterministic benchmark/conformance and deep-recursion suites; - credential-free CLI and persistence/restart checks; - REAL OpenRouter core suite, including `live_chain_stream_openrouter`; - REAL OpenRouter structured repair; - REAL OpenRouter benchmark; - REAL depth 0/1/2 recursion experiment; - one-command REAL RLM CLI smoke. Live streaming evidence from the exact-head run: - requested model: `openrouter/free`; - selected underlying model: `poolside/laguna-xs-2.1:free`; - HTTP status: 200; - incremental events: 196; - terminal done event: true; - usage present: true; - sentinel required: false; - sentinel compliant: true. The raw CI log preserves the selected underlying model and both sentinel-quality fields. A future healthy free-router route that ignores the sentinel will therefore stay observable without falsely failing the transport gate. ## Non-goals No fake provider, no credential changes, no provider-error weakening, and no relaxation of actual stream/termination assertions.
Sign in to join this conversation.
No description provided.