Skip to content

fix(discovery): stop blanket-excluding OpenRouter from serving on ZDR grounds - #951

Closed
seonghobae wants to merge 2 commits into
mainfrom
fix-openrouter-blanket-zdr-exclusion
Closed

fix(discovery): stop blanket-excluding OpenRouter from serving on ZDR grounds#951
seonghobae wants to merge 2 commits into
mainfrom
fix-openrouter-blanket-zdr-exclusion

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Why

Reported (in the org's product-loop session): OpenRouter contributes zero servable free models even though OPENROUTER_API_KEY is registered and OpenRouter's own catalog carries real, complete per-token pricing (unlike Bytez, which never reports pricing at all — separate, already-tracked gap in #940).

Root cause: PROVIDER_MODEL_SOURCES's openrouter entry has carried evidence_only=True since 952996ec ("fix(discovery): keep OpenRouter catalog evidence-only"). evidence_only=True means no OpenRouter model can ever become a serving agent — agent_from_discovered hard-refuses (raise ValueError("evidence-only model cannot become a serving agent")) and is_routable_discovered_model excludes it — regardless of that specific model's own ZDR status.

Traced the actual security history through the commit trail (721ae519, 588aef3, 984fe91, 6dcfc07, caab2ed, 952996ec):

  • The real, well-documented bug 721ae519 fixed ("fix(security): scope ZDR evidence to OpenRouter") was cross-provider evidence contamination: an earlier version matched OpenRouter's ZDR feed against every discovered provider's models by model-id suffix, so a different provider's model that merely shared a display name with an OpenRouter model could incorrectly inherit OpenRouter's ZDR attestation. That was correctly fixed by requiring an exact canonical id match — no more suffix matching. This fix is real, correct, and untouched by this PR.
  • 952996ec (empty commit body, no linked issue/design doc) is a separate, later, much broader change: it doesn't touch matching logic at all — it just adds evidence_only=True to OpenRouter's source, which bars the entire provider account from ever serving. There's no independent security rationale on record for this specific scope.
  • Worse, _apply_discovered_model_evidence's zdr_capable=not model.evidence_only and matches(model.model_id) meant OpenRouter's own rows — even ones OpenRouter's own exact-match ZDR feed attests as ZDR-capable — could never actually carry that evidence into a serving decision, since evidence_only=True zeroed it out before matches() even mattered.

ContextualWisdomLab/.github's own scripts/ci/zdr_policy.py (used by the central Strix/Noema/OpenCode review sidecar) was already built to consume this correctly: is_zdr_model() evaluates OpenRouter per exact "provider/model" route against the same /api/v1/endpoints/zdr feed, with full PROVIDER_ZDR_SCOPE/PROVIDER_CREDENTIAL_NAMES/PROVIDER_BASE_URLS entries for openrouter already in place. It never depended on this blanket exclusion — it was just never reachable, because contextual_orchestrator's own discovery layer never let an OpenRouter model become a servable candidate in the first place.

ZDR is per-route/model evidence — this repo already models it that way for every other provider (zdr_capable, supports_zero_data_retention, privacy:zdr/privacy:no_zdr tags) — not grounds to bar an entire provider account from serving.

What changed

  • Removed evidence_only=True from OpenRouter's PROVIDER_MODEL_SOURCES entry. No other source ever set it; is_routable_discovered_model/agent_from_discovered's evidence_only guard remains in place as general infrastructure for a genuinely evidence-only future source.
  • Updated the discover_all_models comment describing OpenRouter's role.
  • Updated 3 existing tests that asserted the old blanket-exclusion behavior (test_default_sources_request_openrouter_full_modality_catalog, test_enable_cheapest_activates_the_lowest_priced_discovered_agent, test_enable_cheapest_bootstraps_independent_provider_accounts) to assert the corrected behavior — OpenRouter now legitimately wins cheapest-price selection when it is in fact cheapest.
  • New regression test test_openrouter_free_zdr_verified_model_is_routable_and_servable: proves a free, ZDR-attested OpenRouter model is routable, serving-agent-eligible, and carries privacy:zdr — using the real production PROVIDER_MODEL_SOURCES entry, not a synthetic fixture.

Verification

  • RED-before-GREEN: stashed the production fix, confirmed the new regression test fails exactly on assert openrouter_source.evidence_only is False (i.e. it's True on unfixed code); restored the fix, confirmed it passes.
  • python -m pytest tests -q (deselecting the same pre-existing, unrelated fast_mlsirm environment gap noted in fix(discovery): bound OpenRouter free-model endpoint fan-out to one deadline #939): 2824 passed, 1 skipped.
  • interrogate contextual_orchestrator/model_discovery.py: 100%.

Scope note

Left _apply_discovered_model_evidence's not model.evidence_only guard in place — it's correct in the abstract (an evidence-only row can never serve regardless of its zdr_capable value, so gating zdr_capable computation on it is immaterial dead weight for such rows, not wrong), and now correctly inert for OpenRouter since evidence_only is False there.


Generated by Claude Code

… grounds

OpenRouter's ProviderModelSource has carried evidence_only=True since
952996e ("ZDR hardening"), meaning no OpenRouter model can ever
become a serving agent (agent_from_discovered hard-refuses;
is_routable_discovered_model excludes it) regardless of that specific
model's own ZDR status. Traced the actual security history: the real
bug 721ae51 fixed was cross-provider evidence *contamination* --
suffix-matching OpenRouter's ZDR feed against other providers' models
that merely shared a display name. That was correctly fixed by scoping
the match to exact canonical ids. 952996e's blanket evidence_only=True
is a separate, over-broad follow-up with no independent security
rationale on record (empty commit body) -- and it made OpenRouter's own
rows worse than before: _apply_discovered_model_evidence's
zdr_capable=not model.evidence_only and matches(...) meant an
OpenRouter model attested ZDR-capable by OpenRouter's own exact-match
feed still could never carry that evidence into a servable agent.

ZDR is per-route/model evidence (this repo's own zdr_capable field,
supports_zero_data_retention, and privacy:zdr/privacy:no_zdr tags
already model it that way for every other provider), not grounds to
bar an entire provider account from serving. ContextualWisdomLab/.github's
own zdr_policy.is_zdr_model already evaluates OpenRouter per exact
"provider/model" route against the same /api/v1/endpoints/zdr feed --
it was already built to consume honest per-model evidence and never
depended on this blanket exclusion.

Removes evidence_only=True from OpenRouter's PROVIDER_MODEL_SOURCES
entry. No other source ever set it, so is_routable_discovered_model /
agent_from_discovered's evidence_only guard remains in place as
general infrastructure for a genuinely evidence-only future source.

New regression test proves a free, ZDR-attested OpenRouter model is
now routable, serving-agent-eligible, and carries privacy:zdr --
RED confirmed against the pre-fix source (assertion on
evidence_only), GREEN after.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kj32ABZLZ2a6TPTyvYrRkg
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae seonghobae closed this Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #949 ("fix(discovery): route OpenRouter by model evidence", merged 8cd99f1), opened concurrently by another session. It removes the same evidence_only=True from OpenRouter's PROVIDER_MODEL_SOURCES entry — and goes further, adding apply_openrouter_spend_admission() to fail closed on paid OpenRouter routes without a verified positive credit balance (free routes and every other provider stay unconditionally admitted). That's a case this PR didn't cover: my fix only proved a free ZDR-attested OpenRouter model becomes servable, without addressing what should happen to paid OpenRouter rows once the provider is no longer blanket-excluded.

Closing without merging to avoid duplicating already-landed, more complete work.


Generated by Claude Code

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.

2 participants