PAYG remap: format, parser, and conformance vectors for plan-billed models - #14
PAYG remap: format, parser, and conformance vectors for plan-billed models#14iceteaSA wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
|
Both P2s were real. Fixed in The Same for an all-zero I did not drop the leading clause, because that breaks something worse. Without The fix is at the override boundary instead. The last two matter as much as the first three: a schedule carrying a real rate beside a zero must still parse, so the guard is checked in both directions.
P3 — the corpus validators now aggregate failures instead of aborting at the first one, so a drifting fixture reports every missing, duplicated, and mis-contracted cell in one run. Both new guards were mutation-tested in two classes — deleted, and narrowed to check less — and each reddens a named vector. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Both correct. Fixed in The redundancy is real. I did not delete the helper — it is now public API as The doc comment now states why the leading /// §5.3's ALL-ZERO predicate for one parsed cost schedule.
///
/// At least one of `input` or `output` must be `Some(0)`, every present rate must be
/// `Some(0)`, and every tier rate must be zero. An all-`None` schedule is unpriced, not
/// zero; the leading `input`/`output` condition preserves that distinction.
That condition was proposed for removal in the previous review round. Without it, Note this is a predicate over one Second P3 — the coverage validator is now skipped once the count check has already failed, so a pure count drift reports as a count drift rather than as missing cells. The aggregation test was updated to match and still proves multiple independent failures are collected. |
models.dev publishes cost:{input:0,output:0} for plan-billed lanes - 486
models across 60 providers in the 2026-08-13 snapshot. Those zeros are
correct as marginal cost and useless for routing: a spend report that prices
plan usage at $0 cannot answer what a call would have cost on that platform
without the plan.
This adds the document format and parser that overlays the catalog with
sourced rates for those ids, plus the conformance vectors that define what a
correct overlay does.
What is here:
- PaygRemapDoc and the entry kinds, with an exact provider-qualified key
newtype that never falls back to a bare model name - that fallback silently
compares a reseller id against the origin provider's price
- a fallible parser with 12 error variants, all reachable and tested
- is_all_zero, the normative ALL-ZERO predicate, exported so consumers do not
each reimplement it
- a conformance runner generic over the join, with zero implementations of
that join in this crate
- two vector corpora under tests/golden/, following the pattern in
cortexkit-store-types and cortexkit-cache-core
What is deliberately absent: the classifier, and the canonical data document.
The failure taxonomy is still moving - it grew a third mode after one review
round, four matrix cells after another, and had its priced column
restructured after a third - so pinning it to this crate's semver surface is
premature. A cfg(test) reference implementation would be worse: as the only
executable join in the tree it becomes the de facto normative one. The crate
header says types and parsing only, no bundled data, so payg-remap.json is
not here either; both placement questions belong to the maintainer.
Two gates, and only one runs here. The parse gate is executed and proven: all
14 guards were mutation-tested in two classes - deleted, and narrowed to
check less - and each reddens a named vector. The classification suite is
complete and cell-referenced but does not execute here, because there is
nothing to execute it against; 17 of 31 mutation rows are shipped and unrun
until a classifier exists.
The narrowing class is why that distinction matters. A removal-only sweep
reported 14/14 green while five guards survived narrowing, every one correct,
load-bearing, and untested - including a provenance filter that had never
executed at all, because every vector omitted the field and the lookup
short-circuited before reaching it.
Each classification vector carries a cell reference naming the matrix cell it
derives from, and a constant CELL_CONTRACT table asserts every vector's
outcome against the matrix. A vector that contradicts its cited cell is then
catchable by reading rather than by execution.
Additive: no existing type, function, or test changes. The only deletion is
the version line, 0.2.0 to 0.3.0.
Refs cortexkit/astrocyte#3
|
A note on something adjacent that I am deliberately NOT changing here, since you may want it decided rather than discovered.
Adding The asymmetry is intentional and documented at the validator, but it is asymmetric, and there is a reasonable argument that a field named If you want |
|
Pushed What it is. A second date, distinct from Absent stays absent. When the field is missing it parses to Why it matters, measured rather than argued. OpenAI cut list prices on 2026-07-30 — Validation, and a deliberate asymmetry. No ordering constraint between the two dates: a rate can legitimately be observed before it takes effect, so requiring Three mutations run, all killed:
The middle one is the guard that matters — it is the exact defect the absent-stays-absent rule exists to prevent. 38 tests, clippy clean with |
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Both correct. Fixed in
The tautology is the finding worth dwelling on, because it was mine. I asked for that assertion, and it was empty: after Replaced with a test that discriminates, and verified by mutation rather than by passing. Defaulting the absent branch to None | Some(Value::Null) => return Ok(required_provenance(entry, id, "observed").ok()),reddens it by name: I reproduced that independently rather than taking the implementer's table, and it is worth saying why: the predecessor assertion also passed, and passing was exactly what made it invisible. A test that cannot fail reports coverage that does not exist, which is worse than having no test — the gap is real either way, but one of them tells you. Three mutations run on this commit, all killed:
39 tests, clippy clean. Note the Windows check on this PR is red from master rather than from this branch — |
PAYG remap: format, parser, and conformance vectors for plan-billed models
Refs cortexkit/astrocyte#3.
What this is
models.dev publishes
cost: {input: 0, output: 0}for plan-billed lanes — 486 modelsacross 60 providers in the 2026-08-13 snapshot. Those zeros are correct as marginal cost
and useless for routing: a spend report that prices plan usage at $0 cannot answer "what
would this call have cost on this platform without the plan", which is the question that
decides where work goes.
This adds a document format and parser that overlays the catalog with sourced rates for
those ids, plus conformance vectors that define what a correct overlay does.
It does NOT add a classifier. See "What is not here".
What is here
PaygRemapDocand friends — the document types, in a newpayg_remapmodule.payg_conformance.tests/golden/, following the pattern incortexkit-store-typesandcortexkit-cache-core.Additive: no existing type, function, or test changes. The only edit to
lib.rsis nineexport lines; the only deletion in the diff is the version bump to 0.3.0.
Override costs reuse the existing
CostSchedulerather than a parallel type, and rates gothrough the existing
decimal_str_to_nanos— one money representation, and the privatehelper stays private.
What is not here, deliberately
No classifier. Nothing in this crate takes a remap document plus a catalog and returns
an outcome. The classification rules are specified as a matrix and shipped as executable
vectors, but the join itself is not implemented here.
The failure taxonomy is still moving. It grew a third mode after one review round, gained
four matrix cells after another, and had its whole "priced" column restructured after a
third. A classifier in this crate would pin that taxonomy to this crate's semver surface
while it is still changing, and a
#[cfg(test)]reference implementation would be worse:as the only executable join in the tree it becomes the de facto normative one, because that
is what people copy.
So the runner is generic over
Fn(&PaygRemapDoc, &CatalogDoc, &PaygModelId) -> PaygOutcomeand this crate provides no value of that type. Whoever writes the classifier gets the whole
suite executable in one call. Where it should live is the open question on astrocyte#3.
No data document.
payg-remap.jsonis not in this PR. The crate header says "types andparsing only, NO bundled data", and I did not want to be the first exception. Where the
canonical document lives is a placement question that belongs with you.
Two gates, and only one of them runs here
The split is explicit:
DefaultguardThe parse gate is proven by mutation: each of the 14 guards was deleted and separately
narrowed, and each mutation reddens a named vector. The classification suite is complete
and cell-referenced but does not execute here, because there is nothing to execute it
against. Seventeen of the 31 mutation rows are shipped and unrun until a classifier exists.
What mutation testing found
The first pass ran every mutation as "delete the guard" and reported 14/14 reddened. An
independent reviewer then ran the narrowing class — leave the guard, make it check less —
and five guards survived:
omitted the field and the lookup short-circuited before reaching it
all_zeronarrowed to a single field survived, because no positive test proved it doesnot over-fire
schema: 0passedprovider/passedchained-targetcould not distinguish checking the target from checking the sourceAll five were correct, load-bearing code with no test behind them. They are pinned now.
The vectors also encode the resulting rule: a refusal predicate needs both directions, and
a negative vector that omits a field cannot pin a guard that validates the field's contents.
Vector design
Each classification vector carries a
cellreference naming the matrix cell it derivesfrom. A vector whose expected outcome contradicts its cited cell is then catchable by
reading, without executing anything — the matrix is the oracle. The well-formedness test
enforces that every reference resolves and that all 29 cells are covered exactly once.
29 rather than 20: the matrix prints 5 declarations × 4 source states, but the three
resolves_to"by target" cells each expand over the target's own four states.The test file's doc comment carries the obligation: any classifier implementation must
execute this suite through
run_vectors, and one that does not is nonconforming.Verification
The compile-fail doctest is the structural guard:
PaygRemapDocderives noDefaultandparsing is fallible with no infallible constructor, so
unwrap_or_default()does notcompile. That is deliberate — a remap document that silently defaults to empty would
reinstate every false zero it exists to remove.
Open questions for you
payg-remap.jsonlives, given the crate is deliberately data-free.DeclarationSupersededis acatalog-era transition — "this id started being priced" — and fusiform's diff pipeline
already computes that event. Related: a classification is only reproducible against the
catalog read it came from, so a consumer should record that read's
resolved_at_msrather than keying on
catalog_version, which advances on its own clock.Design notes, including the failure modes this cannot represent, are in the astrocyte#3
thread.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Adds a PAYG remap format, parser, and conformance vectors so plan‑billed models can be priced counterfactually. Previously plan lanes had $0 marginal cost; now an overlay supplies sourced rates or refusal rules with an optional effective_from (validated YYYY‑MM‑DD and accepted when null), and behavior does not change until a classifier consumes it.
payg_remapandpayg_conformancetocortexkit-model-catalog; exportsPayg*types,run_vectors,PaygOutcome,ResolvesToEntry,OverridesUnpricedEntry,NotSoldPerTokenEntry, and the normativeis_all_zero; bumps crate to0.3.0. Additive only.counterfactual: "same_platform_list", exactprovider/modelids, and provenance; validateseffective_from(YYYY‑MM‑DD) on entries and provider rules and accepts null; rejects unknown kinds, malformed ids, self/chainedresolves_to, overrides with no positive rate, inexact/negative rates,context_over_200koutsidetiers, and non‑string providerid_prefix; addsInvalidEffectiveFromto the error taxonomy. Golden parse vectors pin these guards.run_vectors(Fn(&PaygRemapDoc, &CatalogDoc, &PaygModelId) -> PaygOutcome)executes the outcome matrix; golden class vectors assert coverage and contract without shipping a classifier.Adoption
run_vectorsto validate outcomes.payg-remap.json.PaygRemapDochas noDefault.Written for commit 8be18d6. Summary will update on new commits.