Skip to content

gateway: filter discovery by exact price ranges - #513

Merged
sjungwon03 merged 1 commit into
mainfrom
feat/512-model-price-ranges
Oct 18, 2026
Merged

sjungwon03 merged 1 commit into
mainfrom
feat/512-model-price-ranges

Conversation

@sjungwon03

Copy link
Copy Markdown
Member

Summary

Closes #512
Refs #116

  • Add inclusive min_price/max_price/min_output_price/max_output_price filters to compatible model discovery, with official USD per million token units.
  • Reuse sparse decimal digits and BigInt positions for exact per-token comparisons and reversed-bound validation, including values beyond Number precision and underflow. Preserve accepted decimal spelling in fixed relative continuations.
  • Keep complete catalog capture/validation, enabled model/final-provider IAM, combined filters/sorts/paging and required private audit. Unknown pricing cannot match selected bounds; legacy/count price queries remain rejected.
  • Advance only the model-query pin to v4 with four complete optional official shapes, fresh provenance, previous digest reconstruction, independent field drift and stale-version/controlled CLI cases.

Plan: docs/plans/512-model-price-ranges.md
Contract: contracts/model-price-ranges.md

TDD and validation

  • Red: raw/installed SDK tests before implementation: 12 expected unsupported-query failures, one existing invalid-query pass. Independent query-schema tests against v3: 19 expected failures, 73 passing cases.
  • Green: eight focused raw/SDK price-order/price-range/benchmark-range/query-schema/controlled-CLI suites pass 168 tests.
  • Covers inclusive/equal/one-sided/free/missing prices, exact unit conversion, ignored discounts/overrides, a bounded independent integer oracle, precise fractional differences, 100-digit exponent equality, huge finite values, fresh IAM/catalog continuations, hidden malformed data, required failures and audit-time mutation/privacy.
  • Fresh fixed-host npm run compatibility:drift: all four selected subsets match. Request, response and count pins remain byte-identical to main.
  • Clean env -u NODE_NO_WARNINGS -u NODE_OPTIONS PATH="/home/ubuntu/.local/bin:$PATH" npm run check retry passed: 6,877 cases, 6,876 passed, one optional external PostgreSQL skip, zero failures/cancellations. Strict types, lint, planning/link/contract/fixture-secret checks and all four offline integrity checks passed. Evidence: /tmp/opengranter-512-check-retry.log.
  • First full run: zero assertion failures, one existing direct gateway shutdown test cancellation at its unchanged 15-second deadline under host contention. The unchanged complete PostgreSQL gateway-runtime suite passed all 19 cases in isolation. No timeout, warning suppression or runtime lifecycle change was made; complete clean retry evidence follows before delivery.
  • Fixture corrections during development: removed an incidental count-only no-store assumption from listing tests and supplied required benchmark indices in a combined-filter fixture. No runtime cache policy or metadata validation change was introduced for those fixture errors.

Source and limits

Official source: https://openrouter.ai/openapi.json, retrieved 2026-10-18.
Canonical source SHA-256: e14bcc1e02453bff8807cc79d03170ce7d229a9d0836e253ff49b764b8aa811d.
Query v4 projection SHA-256: aa9f1298d0c56d6d786499f859c3ee9062b2bc01407e2c9926bff1e85921ff62.

The bounded unsigned decimal syntax, 128-unit length, finite-input restriction and exact reversed-pair rejection are local restrictions, separate from the official optional number/null schemas. SDK numeric serialization can lose precision before transmission; accepted raw strings retain exact comparisons and continuation spelling. Prices may be stale/inaccurate and filtering does not calculate billed cost, apply overrides/discounts, refresh metadata or choose providers. No inference, credentials, limits, usage or database schema changes. Full #116 and unresolved #7 remain open.

Assisted-by: Codex
Signed-off-by: sjungwon03 sjungwon03@gmail.com

Compare published per-token base prices with inclusive per-million
bounds using sparse decimal positions. Preserve current IAM, audit
and paging controls and track the four official query shapes.

Closes #512
Refs #116
Assisted-by: Codex
Signed-off-by: sjungwon03 <sjungwon03@gmail.com>
@github-actions github-actions Bot added ai-review-requested Review requested from sjungwon03-ai type:feature Product capability labels Oct 18, 2026

@sjungwon03-ai sjungwon03-ai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review summary

Verdict: Approved

  • Reviewed: exact price-range parsing, matching, paging, and schema-pin coverage
  • Checks: GitHub Checks passed; local typecheck and 137 targeted tests passed

@sjungwon03
sjungwon03 merged commit 3fc2f15 into main Oct 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review-requested Review requested from sjungwon03-ai type:feature Product capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: filter model discovery by exact price ranges

2 participants