feat(llmo): prompt-suggestion-schedules provisioning endpoint + trial→paid admin reaction#2848
Open
dzehnder wants to merge 1 commit into
Open
feat(llmo): prompt-suggestion-schedules provisioning endpoint + trial→paid admin reaction#2848dzehnder wants to merge 1 commit into
dzehnder wants to merge 1 commit into
Conversation
…rial→paid admin reaction Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Mysticat review failed: Claude CLI crashed (exit 1): stderr= stdout={"type":"result","subtype":"error_max_budget_usd","duration_ms":5,"duration_api_ms":1022486,"is_error":true,"num_turns":1,"stop_reason":null,"session_id":"45280d65-140e-40cc-8818-d82eea968a4a","total_cost_usd":17.23579465,"usage":{"input_tokens":0,"cache_creation_input_tokens":0,"cache_read_input_to |
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.
What
Adds a reusable per-site prompt-suggestion schedule provisioning endpoint and an admin-side trial→paid reaction, building on the tier gate landed in #2847.
POST /sites/:siteId/prompt-suggestion-schedulesisPayingLlmoSite— the caller may not supply a tier/isPaying. Only paying sites get recurring schedules; a non-paying site is a deliberate no-op (skipped: true,reason: 'not-paying'). The onboarding trial one-shot (submitJob) is intentionally NOT reused here:submitJobis not idempotent, so a re-provision/backfill endpoint must be paying-only. The underlyingcreateScheduleIS idempotent, so repeat calls are safe and already-existing schedules count as success.{ siteId, isPaying, skipped, allSucceeded, results }where each result is{ providerId, status, error? }(created/already-existed/submitted/failed). One pipeline failing never aborts the others.CAP_PROMPT_SUGGESTION_SCHEDULE_WRITEcapability with the standard dual-layer check (isAdminbypass, else freshhasS2SCapability).:siteIdis UUID-validated; the param is classified inFACS_NON_RESOURCE_PARAMS.Shared
ensurePromptSuggestionSchedulesmoduleisPayingLlmoSite,registerPromptSuggestionSchedule,ensurePromptSuggestionSchedules, andPROMPT_SUGGESTION_PIPELINESmoved fromllmo-onboarding.jsintosrc/support/prompt-suggestion-schedules.jsso the onboarding side-effect, the new endpoint, the entitlements reaction, and a future reconciler all share one implementation.llmo-onboarding.jsimports + re-exports them for backwards compatibility.ensurePromptSuggestionSchedulesnow returns a real per-pipeline result envelope ({ results, allSucceeded }) instead of an opaque sentinel.Entitlements trial→paid admin reaction
entitlements.createSiteEntitlementreads the prior tier beforecreateEntitlement; on an LLMO trial→paid transition it best-effort (re)provisions recurring schedules via the shared helper. Never fails the entitlement operation (mirrors the best-effort onboarding side-effect).Test fix (onboarding suite)
The move made the tier helpers a transitive dep of the onboarding controller. The prior test attempt mocked them tree-wide with esmock's 3rd (global) arg; that global state accumulates in
global.mockKeysand slowed every later esmock in the file past its mocha timeout — 25 onboarding tests hung. Fix:esmockOnboardingnow mocks the shared module at its own boundaries (TierClient+Entitlement) via a nested esmock and injects that mocked module as a local dep of the onboarding controller. The real schedule/tier logic still runs (socreateSchedule/submitJobassertions hold), with no global esmock state leaking between tests.Verification
test/controllers/llmo/llmo-onboarding.test.js— 165 passing, 0 failing (was 140 passing / 25 hanging).test/support/prompt-suggestion-schedules.test.js,test/controllers/llmo/prompt-suggestion-schedules.test.js,test/controllers/entitlements.test.js— all green.test/routes/{capability-constants,index,facs-capabilities}.test.js— green.npm run lintclean except the known-unrelated@adobe/spacecat-shared-ticket-clientunresolved-import error.npm run docs:lint— API description valid.Base note
This was authored against
feat/prompt-suggestion-tier(#2847). #2847 merged intomaintoday and its branch was deleted, so this PR targetsmainand the single commit was rebased--onto main(0 behind main). The #2847 dependency is satisfied bymain; drs-client 1.14.0 is still the intended runtime dependency (cadence literals are kept local until it lands — seeprompt-suggestion-schedules.js).Required follow-ups
entitlement.tier_changedtarget event.🤖 Generated with Claude Code