Skip to content

fix(discovery): union Models.dev metadata with provider evidence, not clobber - #1007

Draft
seonghobae wants to merge 8 commits into
mainfrom
fix/models-dev-metadata-field-union
Draft

fix(discovery): union Models.dev metadata with provider evidence, not clobber#1007
seonghobae wants to merge 8 commits into
mainfrom
fix/models-dev-metadata-field-union

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve provider-reported architecture, context_window, and max_output_tokens when a matching Models.dev record omits the corresponding field.
  • Prefer Models.dev for each modality or capacity field it actually reports.
  • Keep free-model classification Models.dev-authoritative, preserving ADR 0041's trust boundary.

Successor reconciliation

Protected main@60c562defc81fb1897fa97ebdb5bf8f69eae0c55 includes PR #1047 (17095dad706199a2e108ea6c20d7e6f1f5ac3b89) and PR #1048 (60c562defc81fb1897fa97ebdb5bf8f69eae0c55). This branch merged that main without force-push.

PR #1047 already supplies OpenRouter plus Models.dev composition and its privacy regression coverage. The earlier OpenRouter/ZDR status prose and bootstrap test were therefore removed from this PR. The remaining delta is limited to the independent metadata-union implementation, its focused regression test, and the changelog fragment.

Verification

  • uv run --group dev pytest -q tests/test_model_discovery.py tests/test_provider_bootstrap.py — 153 passed
  • uv run --group dev python -m compileall -q contextual_orchestrator/model_discovery.py — passed
  • git diff --check — passed

Current exact head: ef530306 on main@60c562de. Hosted exact-head checks and fresh robot review remain required before merge.

… clobber

_merge_models_dev_metadata unconditionally overwrote a matched row's
architecture/max_output_tokens/context_window with Models.dev's values even
when Models.dev had no modalities/limit data for that model, silently
discarding the provider's own already-discovered catalog evidence for
nothing. Reproduced live with a synthetic partial record, then fixed: these
capacity/modality fields are now a field-level union (Models.dev's value
wins only when Models.dev actually reports one; the provider's own value
survives otherwise). Cost (pricing/is_free) is intentionally left untouched
and stays exclusively Models.dev-sourced per ADR 0041's cost-safety
argument -- a compromised provider must never be able to self-report "free".

Also records live verification of two adjacent gaps that were already
correct on main and needed only regression coverage, not a fix:
- OpenRouter is already a live PROVIDER_MODEL_SOURCES entry feeding
  orchestrator/free with no provider-specific carve-out; verified live
  against the real OpenRouter API (566 models discovered, 10 correctly
  classified free).
- TaskOrchestrator._zdr_agent_allowed's `not zdr_required or has_zdr_tag`
  boolean makes it mathematically impossible for a non-ZDR-requiring pool to
  exclude a ZDR-capable agent; added an end-to-end regression test through
  bootstrap activation covering ZDR-capable free models from two provider
  families at once.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: b4d5b16e-45d9-40c5-9175-559f8a92de0c

📥 Commits

Reviewing files that changed from the base of the PR and between b2aff34 and bec466d.

📒 Files selected for processing (4)
  • CHANGELOG.d/models-dev-metadata-field-union.md
  • contextual_orchestrator/model_discovery.py
  • docs/planning/adrs/0041-generalize-models-dev-cost-classification.md
  • tests/test_model_discovery.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: b3563805-9247-4806-88de-d895c246a8ee

📥 Commits

Reviewing files that changed from the base of the PR and between 464da47 and b2aff34.

📒 Files selected for processing (5)
  • CHANGELOG.d/models-dev-metadata-field-union.md
  • contextual_orchestrator/model_discovery.py
  • docs/product-technical-gap-baseline.md
  • tests/test_model_discovery.py
  • tests/test_provider_bootstrap.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Models.dev 메타데이터 병합이 필드별 보존 방식으로 변경되었습니다. Models.dev가 값을 보고하지 않으면 제공자 카탈로그 값을 유지합니다. 무료 모델 풀의 ZDR 선택 동작에 대한 회귀 테스트와 라이브 검증 문서도 추가되었습니다.

Changes

모델 메타데이터 병합

Layer / File(s) Summary
필드별 메타데이터 병합 및 회귀 테스트
contextual_orchestrator/model_discovery.py, tests/test_model_discovery.py, CHANGELOG.d/models-dev-metadata-field-union.md
Models.dev가 보고한 모달리티와 용량 값은 적용합니다. 값이 없으면 제공자의 architecture, context_window, max_output_tokens를 유지합니다. pricingis_free는 계속 Models.dev에서 가져옵니다.
기술 기준선 기록
docs/product-technical-gap-baseline.md
OpenRouter 발견 결과와 메타데이터 병합 규칙을 2026-09-02 라이브 검증 섹션에 기록합니다.

무료 모델 풀의 ZDR 검증

Layer / File(s) Summary
무료 풀 및 ZDR 전용 풀 테스트
tests/test_provider_bootstrap.py
orchestrator/free 풀에서는 ZDR 지원 여부와 관계없이 무료 모델을 포함합니다. zdr_only=True이면 ZDR 지원 모델만 선택하는지 검증합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to b2aff

This change prevents incomplete catalog metadata from erasing valid provider capability and capacity information while preserving existing pricing and privacy behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 Models.dev 메타데이터를 제공자 증거와 필드별로 병합하는 핵심 변경을 정확하고 간결하게 설명합니다.
Full details: Docstring Coverage

Explanation

Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/models-dev-metadata-field-union

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread contextual_orchestrator/model_discovery.py
Comment thread contextual_orchestrator/model_discovery.py
@seonghobae seonghobae added the bug Something isn't working label Sep 2, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Contributor Author

Routine staleness triage: this PR's base was behind current main (mergeable_state: behind, no real conflict). Fast-forwarded by merging origin/main into this branch (clean merge, no conflicts) and pushed directly (no force-push, no new PR).

Verification before push:

  • python -m pip install --require-hashes -r requirements.lock && python -m pip install --no-deps -e .
  • pytest tests/test_model_discovery.py tests/test_model_group.py tests/test_provider_bootstrap.py tests/test_provider_catalog_bootstrap.py tests/test_provider_catalog_store.py — 227 passed (this PR's own targeted suite)
  • pytest tests/test_rater_observation.py tests/test_rater_observation_criterion_binding.py tests/test_rater_observation_trusted_binding.py tests/test_review_gateway.py tests/test_review_gateway_credential_array.py tests/test_chat_model_capability_isolation.py — 86 passed (files touched by the incoming merge diff)

No source changes beyond the merge commit itself; fresh exact-head CI evidence is still required before merge per this repo's governance.


Generated by Claude Code

@seonghobae
seonghobae enabled auto-merge (squash) September 3, 2026 13:58
Remove OpenRouter and ZDR evidence already superseded by protected main.\n\nCommit-Message-Assisted-by: Codex

Signed-off-by: Seongho Bae <me@seonghobae.me>
Commit-Message-Assisted-by: Codex
Signed-off-by: Seongho Bae <me@seonghobae.me>
@opencode-agent
opencode-agent Bot disabled auto-merge September 4, 2026 11:23
…etadata-union

Signed-off-by: Seongho Bae <me@seonghobae.me>
Signed-off-by: Seongho Bae <me@seonghobae.me>
Signed-off-by: Seongho Bae <me@seonghobae.me>
@seonghobae

Copy link
Copy Markdown
Contributor Author

Adjudication evidence (host 1 session, 2026-09-06 KST; full report with commands in #1080). Nothing here closes, flips, or retargets anything — the decision is the opener's.

Contained in #1031. git merge-base --is-ancestor refs/pr/1007 refs/pr/1031 → yes; this PR's three-dot patch reverse-applies onto #1031's tree except one hunk, model_discovery.py:941, where #1031 (cd191b96) refined this PR's own line into model_npm = …; models_dev_npm = model_npm or provider_row.get("npm"). The CHANGELOG.d fragment, ADR 0041 amendment, union logic and both tests are byte-identical in #1031. Two refuters (uncovered hunks; lost artifacts) failed to refute this.

No closure needed if this lands first#1007#1031 is merge-tree clean and is the order the discovery cluster assumes. If #1031 lands first, this PR becomes superseded (re-check: apply --cached -R --check 1007.patch on origin/main should fail only at :941). Body cites head ef530306; actual head is bec466d2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants