Skip to content

feat(api): credit dimensions on the credit_schema API shape - #3217

Draft
charlietlamb wants to merge 3 commits into
charlie/dim-modelfrom
charlie/dim-api
Draft

feat(api): credit dimensions on the credit_schema API shape#3217
charlietlamb wants to merge 3 commits into
charlie/dim-modelfrom
charlie/dim-api

Conversation

@charlietlamb

@charlietlamb charlietlamb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Layer 2 of the credit dimensions stack — the API surface.

Goalcredit_schema items accept dimensions / multipliers with API naming (credit_cost), strict like the rest of the item, and everything that copies or compares a schema item carries them.

What's here

  • creditRateCard.ts: ApiCreditDimensionSchema, ApiCreditMultiplierSchema on the .strict() item base; tier refinement shared with rows.
  • Converters: one arm each in apiCreditSchemaItemToDb / dbCreditSchemaItemToApi (feature overrides, plan items and agent types inherit).
  • Legacy V0 shapes bail rather than emit credit_cost: undefined: apiCreditSchemaToV0, toApiFeature.
  • Comparators compare the rules structurally (record order is not semantic): diffFeatureV1 and hasCreditRateCardChanged are the two separate cache-clear lanes (catalogV2 vs features.update); entsAreSame is customize.
  • atmn CLI: compose model + both transforms + compare normalizers, so pull/push round-trips dimensions instead of wiping them.

Verify

  • cd server && bun ts
  • unit: tests/unit/features/credit-dimensions-api.test.ts + credit-rate-card-cache, shared/diffFeatureV1, catalogV2/comparators/entsAreSame
  • cd packages/atmn && bun test src/lib/transforms

OpenAPI derives from the zod schemas, so the contract picks the fields up without edits.


Summary by cubic

Adds named dimensions and multipliers to credit_schema items with API credit_cost naming, so credit pricing rules round-trip through API, DB, SDK, and atmn. Legacy V0 shapes bail instead of emitting unsupported dimension data.

  • Strict validation covers flat and graduated dimension rates, match values, and multiplier adjustments.
  • diffFeatureV1, hasCreditRateCardChanged, and entsAreSame detect rule changes while ignoring record order.
  • atmn pull, push, and diff normalization preserve dimensions and multipliers instead of dropping them.

Written for commit 64dee86. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
checkout Ignored Ignored Sep 2, 2026 4:49pm UTC
landing-page Ignored Ignored Sep 2, 2026 4:49pm UTC

Request Review

credit_schema items accept named dimensions and multipliers with API
naming; both converters round-trip them. Legacy V0 shapes cannot
represent them and bail. All three schema comparators (diffFeatureV1,
hasCreditRateCardChanged, entsAreSame) compare the rules structurally so
both cache-clear lanes and customize see edits. The atmn CLI carries them
through pull/push instead of wiping them.
…nistic stringify

One rate converter per direction serves rows and dimensions in both the
shared converters and the atmn transforms. The API reuses the model's
match and dimension-name schemas. deterministicStringify moves to shared
so creditDimensionRulesEqual and hashJson use the same implementation.
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