Replace hardcoded subtraction chain with registry-driven decomposition#321
Draft
alexmojaki wants to merge 80 commits intomainfrom
Draft
Replace hardcoded subtraction chain with registry-driven decomposition#321alexmojaki wants to merge 80 commits intomainfrom
alexmojaki wants to merge 80 commits intomainfrom
Conversation
Replaces the hardcoded subtraction chain with Mobius inversion over the token unit containment poset. Only priced units participate in decomposition — unpriced units' tokens now correctly stay in the catch-all ancestor instead of being dropped at $0.
Google model input_price changed because unpriced audio tokens now correctly stay in the catch-all instead of being dropped at $0.
alexmojaki
commented
Mar 23, 2026
alexmojaki
commented
Mar 23, 2026
…h existing field name
…nd_provider_model on non-global
… principle earlier
…act global requirement
…ighten symmetric definition
…ter ancestor/join coverage
…scope, no new codegen, per-family wording, unit_families key
…utable, validates on mutation
…r dest validation, JS consistency fixes
…no unit names in validation
…cut module-level wrappers
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
prices/units.yml) as the single source of truth for token pricing unitsUsage,ModelPrice,calc_price/calcPricesignatures unchangedKey behavior change
When a unit (e.g.
input_audio_mtok) is NOT priced on a model, its tokens now stay in the catch-all ancestor (input_mtok) instead of being subtracted and priced at $0. This is a bugfix — one test dataset price changes (Google caching scenario).Architecture
prices/units.yml→make package-data→units_data.json(Python) +units-data.json(JS)UnitDefhas dimensions (direction, modality, cache); containment = dimension supersetcomputeLeafValues()uses(-1)^depth_diffMöbius coefficients to decompose overlapping usagecalc_price/calcPricebuilds the priced unit set fromModelPricefields, decomposes, sumsTest plan
🤖 Generated with Claude Code