Skip to content

feat: createEntitlement accepts optional quota overrides - #1914

Open
cwjwisse wants to merge 1 commit into
mainfrom
fix-tier-client-quota-override
Open

feat: createEntitlement accepts optional quota overrides#1914
cwjwisse wants to merge 1 commit into
mainfrom
fix-tier-client-quota-override

Conversation

@cwjwisse

@cwjwisse cwjwisse commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

1. Abstract

Adds an optional quotaOverrides parameter to TierClient.createEntitlement so a caller can store a non-default prompt quota when a new entitlement is created.

2. Reasoning

createEntitlement(tier) hardcodes quotas.llmo_trial_prompts: 200 on every new entitlement, so consumers can never persist the real contracted quota. Downstream, the ABV Semrush provisioning message and the stored LLMO entitlement therefore always read 200, even for a 1000-prompt offer. This change unblocks the fulfillment-worker sourcing the real contracted cap from the UPP event (companion PR).

3. High-level overview of the changes

  • createEntitlement(tier)createEntitlement(tier, quotaOverrides = {}).
  • On the new-entitlement path, the overrides are merged over the default quotas so a provided key (e.g. llmo_trial_prompts) wins.
  • llmo_trial_prompts_consumed is pinned to 0 after the merge — a brand-new entitlement has consumed nothing, so it is never caller-overridable.
  • A non-object quotaOverrides is ignored (defends the shared-library boundary).
  • The existing-entitlement path is unchanged: it updates the tier and returns without touching quotas, so overrides are ignored there (documented in the JSDoc; see the follow-up note in the companion PR).
  • Fully backward-compatible: every current caller passes only tier → default {} → byte-for-byte identical behavior.

4. Required information

7. Test plan

  • Unit tests cover: override applied on create; default preserved when omitted; llmo_trial_prompts_consumed not overridable; a non-object override ignored; the existing-entitlement path ignores overrides. Ran the package unit tests + lint locally.
  • No per-environment verification — this is a library. Correctness is exercised by the consumer (the worker PR) after this releases.

8. Deployment & merge order

🤖 Generated with Claude Code

createEntitlement(tier) hardcoded quotas.llmo_trial_prompts to 200 on every new
entitlement, so callers could not store the real contracted prompt quota. Add an
optional createEntitlement(tier, quotaOverrides = {}) that merges the overrides over
the default quotas on new-entitlement creation only. llmo_trial_prompts_consumed is
pinned to 0 (not caller-overridable) and a non-object override is ignored. Existing
callers passing only tier are byte-for-byte unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cwjwisse
cwjwisse force-pushed the fix-tier-client-quota-override branch from 0659ace to d5dc53b Compare September 7, 2026 13:02
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

This PR will trigger a minor release when merged.

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