fix(pricing): skip unusable exact price entries - #658
Merged
IvGolovach merged 1 commit intoJun 4, 2026
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Validation * Validation tier: Tier 2R - post-merge rebase correction for pricing lookup conflict with junhoyeo#614. * git diff --check origin/main...HEAD: PASS. * git diff --cached --check: PASS. * cargo fmt --all -- --check: PASS. * cargo test -p tokscale-core pricing::lookup::tests: PASS, 143 passed. * cargo clippy -p tokscale-core --all-targets -- -D warnings: PASS. * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - release workflow owns package version bumps. * Not run: full workspace cargo test - not required for selected validation tier; targeted lookup tests cover resolver behavior and mandatory remote CI will run on the final PR SHA. Rollback * git revert HEAD
IvGolovach
force-pushed
the
codex/pricing-safety-20260601
branch
from
June 4, 2026 21:40
efcba6c to
5d657da
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Exact lookup paths could return a
ModelPricingentry where every price field wasNone. That made the resolver stop early and report zero cost even when another pricing source had usable prices for the same model. The same resolver family also needed a guard against mapping unknown future Claude 4.x variants onto older lower-version Claude 4 rows, which can silently produce misleading cost estimates.Related issues: #548, #631.
Diff scope
crates/tokscale-core/src/pricing/lookup.rs: filters exact and provider-prefixed direct matches through the existing usable-pricing rules before returning them.crates/tokscale-core/src/pricing/lookup.rs: adds Claude 4.x minor-version guards so unrecognized future minor variants stay unknown instead of falling through to legacy lower-version pricing.crates/tokscale-core/src/pricing/lookup.rs: adds regression coverage for unusable exact entries, provider-prefixed fallback behavior, valid zero-price entries, and unknown future Claude minor variants.Branch integrity
main.a86e688d620939d2c973c6d5625baa815ea223d7.0 behind / 1 aheadagainstorigin/main.a86e688d620939d2c973c6d5625baa815ea223d7.origin/mainis an ancestor of this branch.Commit integrity
efcba6c32f1b7941f3b417e35a1eb5630431a5f0 fix(pricing): skip unusable exact price entries.Diff hygiene
git diff --name-status origin/main...HEAD: onlycrates/tokscale-core/src/pricing/lookup.rschanged.git diff --check origin/main...HEAD: PASS, no output.Validation mode and proof
Mode 2 — narrow runtime change, because the diff changes localized pricing lookup behavior and focused tests without touching migrations, auth, deployment tooling, or external service contracts.
Noneexact shadowing case and unknown Claude minor fallback tests failed before the implementation.cargo test -p tokscale-core pricing::lookup::tests -- --nocapture: PASS, 143 tests.cargo fmt --all -- --check: PASS, no output.git diff --check origin/main...HEAD: PASS, no output.Required remote gates
Pending — GitHub Actions and mergeability checks will run after the PR is opened.
Migration notes
Not applicable — no database migration changed.
Runtime safety
The change narrows resolver acceptance for unusable exact rows and preserves the existing finite-price validation path. It does not add external I/O, persistent state, concurrency, or new pricing data sources. No invariant regression introduced.
Documentation integrity
Not applicable — no docs, commands, or runbooks changed.
Rollback plan
Rollback: revert this PR. DB downgrade: not applicable. Data repair: not applicable. Operational caveats: reverting would restore early returns for unusable exact pricing rows and the older Claude minor-version fallback behavior.
Known residual risks
Remote CI and GitHub mergeability are pending until the PR is opened. The resolver intentionally treats unknown future Claude minor versions as unknown pricing rather than estimating from older lower-version rows.
Summary by cubic
Skip exact and derived matches that have no usable price fields, so the resolver falls back to a priced source instead of reporting zero cost. Unknown Claude 4.x minor variants now stay unpriced instead of degrading to Claude 4; explicit 0.0 prices remain valid.
LiteLLM,OpenRouter, andCursorto only return usable pricing; otherwise allow fallback.Written for commit 5d657da. Summary will update on new commits.