Add cortexkit-provider-usage: shared wire types for the quota usage.get payload#5
Merged
Merged
Conversation
…et payload Pure serde types (ProviderUsage, Usage, RateWindow, AccountInfo, SavedResets, CreditExpiry, ExtraWindow) extracted from ai-provider-quota's model.rs so every consumer of the usage.get wire — the quota module that produces it, ALF's router reads, astrocyte's capacity axis, and the ck quota renderer — compiles against one definition and the shape cannot drift without a shared-crate PR each side reviews. Shape, not policy: read-time transform semantics (the quota module's banked-reset relaxation, which zeroes used_percent and carries the provider truth in raw_used_percent) are producer behavior documented on the fields but not enforced by these types. serde-only, no logic; serde_json is a dev-dependency for the wire-shape tests. The reserved prepaid-Balance seam is intentionally NOT included (it was never populated and is wire-neutral); it joins this crate additively when the balance axis is designed. Follows the cortexkit-model-catalog precedent.
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.
Pure serde wire types (ProviderUsage, Usage, RateWindow, AccountInfo, SavedResets, CreditExpiry, ExtraWindow) extracted from ai-provider-quota's model.rs, following the cortexkit-model-catalog precedent (serde-only, no logic; serde_json dev-dep for wire-shape tests).
Why: the usage.get payload now has three+ consumers — the quota module (producer), ALF's router reads, astrocyte's capacity axis, and the ck quota renderer. A single shared definition means the shape can't drift without a PR every side reviews (this drift class bit the ck renderer twice: the ok-field filter and the rawUsedPercent addition).
Shape, not policy: read-time transform semantics (the quota module's banked-reset relaxation: used_percent zeroed + raw_used_percent carrying provider truth) are producer behavior documented on the fields but NOT enforced by these types.
Balance seam: intentionally NOT included — it was never populated and is wire-neutral; it joins this crate additively when the balance axis is designed.
Consumer-side swaps: ai-provider-quota rewires model.rs to a re-export (verified byte-identical wire, 358 tests + clippy + fmt green locally against a path dep); ck CLI swap SUBC will do post-publish; astrocyte ships v1 on a pinned mirror and swaps when convenient.
Publish is tag-driven per release.yml (cortexkit-provider-usage-v0.1.0) once merged.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Introduces
cortexkit-provider-usage, a shared serde-only crate for the quotausage.getJSON, so all consumers use the same wire shape and avoid drift. Adds the crate to the workspace; no behavior changes.New Features
cortexkit-provider-usagewithProviderUsage,Usage,RateWindow,ExtraWindow,AccountInfo,SavedResets,CreditExpiry.usedPercentvsrawUsedPercent), but does not enforce policy.serde_json; workspace updated to include the crate.Migration
ai-provider-quota: re-export these types; wire output remains identical.cortexkit-provider-usagewhen convenient; no logic changes expected.Written for commit 0ef4536. Summary will update on new commits.