Skip to content

v0.42.25.0 fix(pricing): unify chat-model pricing into one canonical source; add Opus 4.8 (#1819)#1827

Merged
garrytan merged 6 commits into
masterfrom
garrytan/fix-issue-1819
Jun 4, 2026
Merged

v0.42.25.0 fix(pricing): unify chat-model pricing into one canonical source; add Opus 4.8 (#1819)#1827
garrytan merged 6 commits into
masterfrom
garrytan/fix-issue-1819

Conversation

@garrytan

@garrytan garrytan commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes gbrain#1819 and unifies all chat-model pricing into one canonical source.

The bug (#1819): Opus 4.8 (models.aliases.opus) had no price on file, so cost guardrails silently failed — the gbrain dream budget meter let runs proceed unbounded (BUDGET_METER_NO_PRICING warn + skip), and gbrain skillopt --max-cost-usd fell back to a cheaper tier's rate and refused too late. Adds Opus 4.8 at $5/$25 so the caps enforce again.

The unification: prices were hand-copied across five budget-gating tables and had drifted — one eval gate priced Opus 4.7 at a stale $15/$75 (3x high), and Gemini 2.0 Flash disagreed between two tables. All chat-model prices now live in one canonical table (src/core/model-pricing.ts); the Anthropic bare-key view, the takes-quality fail-closed allowlist, the contradictions cost-tracker, the cross-modal eval panel, and the skillopt preflight all derive from it. Cross-table drift is now structurally impossible.

Commits:

  • fix(pricing) — canonical CANONICAL_PRICING + canonicalLookup; derived views; consumers rewired; Opus 4.8 added; stale Opus 4.7 ($15/$75→$5/$25) and Gemini 2.0 Flash ($0.30/$1.20→$0.10/$0.40, verified) fixed; brainstorm/brain-score now price provider-prefixed ids.
  • docs — KEY_FILES.md entry for model-pricing.ts, CLAUDE.md "one canonical chat-pricing table" invariant, llms bundle regenerated.

Test Coverage

COVERAGE: 30/35 (86%)  — gate PASS (target 80%)
Fully covered: canonicalLookup (bare/colon/slash/nested-openrouter-miss/null),
  the drift guard (every derived view == canonical), opus-4-8 reachable across
  consumers, takes-quality fail-closed allowlist, S1A provider-prefixed pricing.
5 gaps: warn-only estimate paths + pre-existing untested consumer sites
  (orchestrator/skillopt/cross-modal estimate fns) — none touch the fail-closed
  gate or the drift guard.

Tests: new test/model-pricing.test.ts (integrity + canonicalLookup matrix + drift guard + S1A + import-cycle guard); updated anthropic-pricing.test.ts (opus-4-8 math) and eval-takes-quality-pricing.test.ts (opus-4-7 regression + opus-4-8). Full suite: 13,216 pass / 0 real failures.

Pre-Landing Review

SHIP — no CRITICAL. Enum/value completeness verified (opus-4-8 traced through every consumer). Applied doc-only auto-fixes: honest drift-guard framing (the guard is a re-hardcode trip-wire — drift is structurally impossible since views are derived), corrected a stale skillopt header comment, fixed a test-path reference.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Scope Drift

Scope Check: CLEAN — diff matches the #1819 intent + the unification approved in plan review (D1A/D2B/S1A/S2A/S3A).

Plan Completion

25 DONE, 2 CHANGED (S1A used canonicalLookup instead of a literal prefix-strip — equivalent; correction #7 message updated), 0 NOT DONE. All locked decisions delivered.

Adversarial review (always-on)

  • Claude subagent: SHIP. No bugs. Confirmed no OpenRouter-markup mispricing and no lost keys.
  • Codex: informational (never gates). Its "block" rested on training-era pricing (claimed Opus should be $15/$75 — contradicted by the repo's 2026-05-10 verification and skillopt: add Opus 4.8 to anthropic-pricing.ts (cost-cap silently no-ops) #1819), a pre-existing+intentional OpenRouter-miss (markup ≠ native, by design), and a display-layer staleness in gbrain providers recipe baselines (not consumed by any budget gate). None are regressions in this diff. Real follow-ups filed as TODOs.

TODOS

  • Completed: eval-contradictions duplicate ANTHROPIC_PRICING consolidation (this PR).
  • Filed (P2/P3 follow-ups): route budget-tracker through canonical for non-Anthropic; canonicalLookup case-insensitivity; getPricing id normalization; module-load-throw negative test; recipe display-layer pricing refresh.

Documentation

Docs synced to the canonical chat-pricing unification:

  • docs/architecture/KEY_FILES.md — added src/core/model-pricing.ts (canonical table); rewrote the anthropic-pricing.ts entry (was "single source of truth" → now a derived view); added the takes-quality derived-allowlist entry. Current-state only.
  • CLAUDE.md — new cross-cutting invariant: one canonical chat-pricing table; every other table derives from it, so drift is structurally impossible (pinned by test/model-pricing.test.ts).
  • docs/eval/SEARCH_MODE_METHODOLOGY.md — fixed a stale price-snapshot pointer to the canonical table.
  • llms-full.txt — regenerated (build-llms freshness test green).

Closes #1819

This PR delivers the fix from gbrain#1819 (add Opus 4.8 pricing) plus the pricing-source unification that prevents the underlying drift class.

Test plan

  • Full unit suite: 13,216 pass, 0 real failures (the 1 reported fail was cli.test.ts torn-reading VERSION/package.json mid-bump; passes 18/0 in isolation post-bump)
  • Targeted pricing tests: 88 pass; consumer suites (budget-tracker, takes-quality runner, brainstorm, skillopt): 343 pass
  • bun run typecheck clean; bun build --compile clean
  • Runtime sanity: estimateMaxCostUsd / canonicalLookup / getPricing all return correct $5/$25 for Opus 4.8

🤖 Generated with Claude Code

garrytan and others added 6 commits June 3, 2026 10:08
… Opus 4.8 (#1819)

Single canonical CANONICAL_PRICING table (src/core/model-pricing.ts) with
canonicalLookup; ANTHROPIC_PRICING and takes-quality MODEL_PRICING become
derived views. cost-tracker, cross-modal runner, skillopt preflight, brainstorm
orchestrator, and brain-score all source from it. Adds Opus 4.8 ($5/$25) so
--max-cost-usd and the dream-cycle budget meter enforce on 4.8 runs; fixes a
stale Opus 4.7 $15/$75 in the takes-quality gate and reconciles Gemini 2.0 Flash
to $0.10/$0.40. Because every table derives from canonical, cross-table price
drift is structurally impossible.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add KEY_FILES.md entries for src/core/model-pricing.ts (canonical
CANONICAL_PRICING + canonicalLookup) and refresh the now-derived
anthropic-pricing.ts + takes-quality-eval/pricing.ts entries to
current-state. Add the "one canonical chat-pricing table" cross-cutting
invariant to CLAUDE.md. Fix the stale model-price snapshot pointer in
SEARCH_MODE_METHODOLOGY.md (anthropic-pricing.ts -> model-pricing.ts).
Regenerate llms-full.txt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…1819

# Conflicts:
#	CHANGELOG.md
#	VERSION
#	package.json
…1819

# Conflicts:
#	CHANGELOG.md
#	VERSION
#	package.json
…1819

# Conflicts:
#	CHANGELOG.md
#	VERSION
#	package.json
@garrytan garrytan merged commit 9a0bae8 into master Jun 4, 2026
21 checks passed
mgunnin added a commit to mgunnin/gbrain that referenced this pull request Jun 5, 2026
* upstream/master:
  v0.42.26.0 docs(supabase): update connection-string setup to new UI + Transaction pooler (garrytan#1848) (garrytan#1875)
  v0.42.25.0 fix(pricing): unify chat-model pricing into one canonical source; add Opus 4.8 (garrytan#1819) (garrytan#1827)
  v0.42.24.0 fix(minions): route lock claim/renewLock through direct session pool (garrytan#1822)
mdcruz88 added a commit to mdcruz88/gbrain that referenced this pull request Jun 6, 2026
…wlist entries

DEFAULT_SLOTS A and C referenced models the gateway no longer accepts, so
both slots failed on every run and forced an INCONCLUSIVE verdict even when
the output was genuinely good:
  - Slot A: openai:gpt-4o was dropped from the OpenAI recipe chat allowlist.
  - Slot C: google:gemini-1.5-pro was retired by Google upstream.

Bump all three slots to current, allowlisted flagships (src/core/ai/recipes/):
  - Slot A: openai:gpt-4o            -> openai:gpt-5.2
  - Slot B: anthropic:claude-opus-4-7 -> anthropic:claude-opus-4-8
  - Slot C: google:gemini-1.5-pro    -> google:gemini-2.0-flash

claude-opus-4-8 was already in the canonical pricing table (PR garrytan#1827) but not
yet in the anthropic recipe's chat allowlist, so add it there to keep slot B
valid (claude-opus-4-7 retained for the many call sites that still default to
it). gpt-5.2 and gemini-2.0-flash are already allowlisted.

The original patch also edited an inline PRICING map in estimateCost(); PR
garrytan#1827 replaced that map with canonicalLookup() from src/core/model-pricing.ts,
so that hunk is obsolete and dropped on rebase. (Cost estimation for gpt-5.2
falls to the "no pricing on file" note since canonical pricing carries gpt-5
and gpt-5.5 but not gpt-5.2 — cosmetic, does not affect the run.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

skillopt: add Opus 4.8 to anthropic-pricing.ts (cost-cap silently no-ops)

1 participant