Conversation
0659ace to
d5dc53b
Compare
|
This PR will trigger a minor release when merged. |
There was a problem hiding this comment.
Hey @cwjwisse,
⚠ Degraded review - no spec document was found for this change (searched the PR links, the touched repos' docs, the architecture/guidelines docs, and linked Jira). This review covers code-level quality but could not validate the change against an agreed design, so confidence is reduced. Add a spec link (PR template section 4) and re-request review for a full-confidence pass.
Verdict: Request changes - one input-validation gap in the type guard.
Complexity: LOW - small diff, single package.
Changes: Adds an optional quotaOverrides parameter to TierClient.createEntitlement so callers can persist a non-default prompt quota on new entitlements (2 files).
Must fix before merge
- [Important] Array passes the
typeof === 'object'type guard and spreads numeric keys into quotas -packages/spacecat-shared-tier-client/src/tier-client.js:188(details inline)
Non-blocking (3): minor issues and suggestions
- nit: No test for
nullpassed explicitly asquotaOverrides(bypasses the default parameter, exercises the falsy branch differently from strings) -packages/spacecat-shared-tier-client/test/tier-client.test.js - suggestion: Consider an allowlist of recognized quota keys rather than open spread, so typos and unexpected keys do not silently persist garbage into the data layer. Today the only overridable key is
llmo_trial_prompts; a tight contract is cheaper to enforce now than later when callers depend on the loose one. - suggestion: Narrow the JSDoc
@param {object}to@param {{llmo_trial_prompts?: number}}so IDE consumers see which keys are valid.
Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 2m 28s | Cost: $3.93 | Commit: 9455e5645ce884511c2127a1001f49b3f170d1bb
If this code review was useful, please react with 👍. Otherwise, react with 👎.
| tier, | ||
| quotas: { | ||
| llmo_trial_prompts: 200, | ||
| // Only merge a real object; a non-object (string/null) would spread garbage keys. |
There was a problem hiding this comment.
issue (blocking): Array passes the typeof === 'object' type guard.
typeof [] === 'object' is true in JavaScript. Spreading an array like [500] into the quotas object produces { 0: 500, llmo_trial_prompts: 200, llmo_trial_prompts_consumed: 0 } - silently corrupt data written to the persistence layer.
The existing non-object test covers strings, but arrays slip through.
Fix: Tighten the guard to also reject arrays:
...(quotaOverrides && typeof quotaOverrides === 'object' && !Array.isArray(quotaOverrides) ? quotaOverrides : {}),Add a test case passing [500] as quotaOverrides and asserting it falls back to the defaults.
There was a problem hiding this comment.
Fixed in 7d6858b — tightened the guard with !Array.isArray(quotaOverrides) so arrays (and null) fall back to the defaults instead of spreading numeric keys, and added tests passing [500] and explicit null. Also narrowed the JSDoc to {llmo_trial_prompts?: number}.
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>
9455e56 to
7d6858b
Compare
There was a problem hiding this comment.
Hey @cwjwisse,
⚠ Degraded review - no spec document was found for this change (searched the PR links, the touched repos' docs, the architecture/guidelines docs, and linked Jira). This review covers code-level quality but could not validate the change against an agreed design, so confidence is reduced. Add a spec link (PR template section 4) and re-request review for a full-confidence pass.
Verdict: Approve - prior blocking finding addressed, no new issues.
Complexity: LOW - small diff, single package.
Changes: Adds an optional quotaOverrides parameter to TierClient.createEntitlement so callers can persist a non-default prompt quota on new entitlements (2 files).
Non-blocking (3): minor issues and suggestions
- nit: The inline comment block (tier-client.js:189-192) is four lines explaining a three-line expression that the JSDoc already documents thoroughly. Consider trimming to a single line. -
packages/spacecat-shared-tier-client/src/tier-client.js:189 - suggestion: No test for an explicitly empty object
{}asquotaOverrides. It is a no-op under the current spread logic, but an explicit test would close the last interesting equivalence class and guard against future regressions. -packages/spacecat-shared-tier-client/test/tier-client.test.js - suggestion: Consider narrowing accepted keys to a recognized set (allowlist) as the feature matures and additional callers adopt
quotaOverrides. Today the spread accepts any key from the caller-supplied object. For an internal library with a single trusted caller this is acceptable, but an allowlist would prevent unrecognized properties from persisting silently if the caller surface grows.
Previously flagged, now resolved
- Array passes
typeof === 'object'type guard - fixed with!Array.isArray(quotaOverrides)guard and tests for[500]andnull. - No test for explicit
null- test added. - JSDoc narrowed from
{object}to{{llmo_trial_prompts?: number}}.
Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 1m 40s | Cost: $2.78 | Commit: 7d6858bc2eaaed6f5b666b8ebe0427d6a91863d0
If this code review was useful, please react with 👍. Otherwise, react with 👎.
1. Abstract
Adds an optional
quotaOverridesparameter toTierClient.createEntitlementso a caller can store a non-default prompt quota when a new entitlement is created.2. Reasoning
createEntitlement(tier)hardcodesquotas.llmo_trial_prompts: 200on 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 read200, 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 = {}).llmo_trial_prompts) wins.llmo_trial_prompts_consumedis pinned to0after the merge — a brand-new entitlement has consumed nothing, so it is never caller-overridable.quotaOverridesis ignored (defends the shared-library boundary).tier→ default{}→ byte-for-byte identical behavior.4. Required information
7. Test plan
llmo_trial_prompts_consumednot overridable; a non-object override ignored; the existing-entitlement path ignores overrides. Ran the package unit tests + lint locally.8. Deployment & merge order
@adobe/spacecat-shared-tier-clientminor (1.7.0).spacecat-fulfillment-workerPR https://github.com/adobe/spacecat-fulfillment-worker/pull/657 (which pins1.7.0) pass CI / deploy. Order: this PR → release → worker PR feat: tracing fetch timeout #657.🤖 Generated with Claude Code