Skip to content

Add cortexkit-provider-usage: shared wire types for the quota usage.get payload#5

Merged
ualtinok merged 1 commit into
masterfrom
qta/provider-usage-types
Jul 19, 2026
Merged

Add cortexkit-provider-usage: shared wire types for the quota usage.get payload#5
ualtinok merged 1 commit into
masterfrom
qta/provider-usage-types

Conversation

@ualtinok

@ualtinok ualtinok commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

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.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Introduces cortexkit-provider-usage, a shared serde-only crate for the quota usage.get JSON, so all consumers use the same wire shape and avoid drift. Adds the crate to the workspace; no behavior changes.

  • New Features

    • New crate cortexkit-provider-usage with ProviderUsage, Usage, RateWindow, ExtraWindow, AccountInfo, SavedResets, CreditExpiry.
    • Serde-only with camelCase fields and optional field omission; documents banked-reset behavior (usedPercent vs rawUsedPercent), but does not enforce policy.
    • Wire-shape tests via serde_json; workspace updated to include the crate.
  • Migration

    • ai-provider-quota: re-export these types; wire output remains identical.
    • Other consumers (ALF router, astrocyte, CK quota renderer): switch imports to cortexkit-provider-usage when convenient; no logic changes expected.

Written for commit 0ef4536. Summary will update on new commits.

Review in cubic

…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.
@ualtinok
ualtinok merged commit 8067cf8 into master Jul 19, 2026
7 checks passed
@ualtinok
ualtinok deleted the qta/provider-usage-types branch July 19, 2026 21:14
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.

1 participant