Skip to content

feat(serenity): extend async prompt classification to sub-workspace brands (#33) - #3075

Open
byteclimber wants to merge 1 commit into
mainfrom
feat/serenity-async-subworkspace
Open

feat(serenity): extend async prompt classification to sub-workspace brands (#33)#3075
byteclimber wants to merge 1 commit into
mainfrom
feat/serenity-async-subworkspace

Conversation

@byteclimber

@byteclimber byteclimber commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • serenity-docs#33 added an async CSV-import prompt-classification pipeline, but gated it to auth.mode !== 'subworkspace' — i.e. flat-mode brands only. Per the introducing PR (feat(serenity): wire runner mechanics for the deferred Semrush job runner (#186) #2920), subworkspace was deferred because it had extra dynamic-allocation headroom-guard logic that "wasn't safely portable in this pass."
  • That allocator (createHeadroomGuard, dynamic-allocation-active.js, resource-manager.js, resource-lock.js) has since been removed entirely (SITES-49206, fix(serenity): remove dormant Semrush AI allocator, §10.1/§10.2 (SITES-49206) #2995, merged 2026-08-13) — Semrush confirmed it no longer enforces AI project/prompt limits for LLMO workspaces at all, and the flag gating it was off in every environment anyway. There is nothing left to port.
  • Since flat mode is now the legacy state (every real customer — Adobe, NBA, Bark, Macy's, National Bank of Canada — has migrated to sub-workspace mode, and a dev-environment scan found zero flat-mode serenity-active brands), the async pipeline as merged was effectively dormant for real traffic.
  • This PR removes the auth.mode !== 'subworkspace' restriction in serenity.js's createPrompts, and teaches the worker (classify-prompts-job.js's createAndClassify) to resolve (geoTargetId, languageCode) slices to Semrush projects via a live listing (buildSliceProjectMap, mirroring the sync subworkspace handler handleCreatePromptsSubworkspace in prompts-subworkspace.js) instead of the flat-mode BrandSemrushProject DB mapping, when the job's metadata marks it subworkspace: true.
  • Job metadata gains subworkspace (distinct from the existing mode: 'create'|'reclassify' field, which is unrelated) and parentWorkspaceId.

Not in scope

  • No allocation/headroom-guard porting — that machinery no longer exists anywhere in this codebase, on either the sync or async path.
  • reclassifyExisting's self-requeue path needed no changes: it patches already-created prompts by projectId/promptId carried in each item, with no slice→project resolution step to branch on.

Test plan

  • test/controllers/serenity.test.js: inverted the "stays synchronous for subworkspace-mode brands" test into an enqueue assertion (enqueues a serenity-classify-prompts job for subworkspace-mode brands too), verifying the new subworkspace/parentWorkspaceId metadata fields; updated the existing flat-mode enqueue test's metadata assertion.
  • test/support/serenity/handlers/classify-prompts-job.test.js: added a subworkspace create-path test asserting the live-listing resolution path is used and the DB mapping (BrandSemrushProject.allByBrandId) is never consulted.
  • npm run lint, npm run type-check, full npm test (serenity.test.js + classify-prompts-job.test.js) pass.
  • Not tested end-to-end against live Semrush — no writable dev flat-or-subworkspace serenity brand was exercised in this session. Recommend a dev e2e pass (existing test/it/postgres/serenity.test.js IT suite plus a manual CSV-import against a subworkspace brand) before merge.

🤖 Generated with Claude Code

…rands (#33)

The CSV-import async job runner (serenity-docs#33) was gated to flat-mode
brands only, deferred because subworkspace create had extra dynamic-allocation
headroom-guard logic that wasn't safely portable at the time (#2920). That
allocator (createHeadroomGuard et al.) has since been removed org-wide
(SITES-49206, #2995) once Semrush confirmed it no longer enforces AI
project/prompt limits, so there is nothing left to port — extending async
routing to subworkspace-mode brands is now a pure routing change.

Removes the auth.mode !== 'subworkspace' restriction in serenity.js's
createPrompts, and teaches the worker's create path
(classify-prompts-job.js) to resolve slice->project via a live listing
(buildSliceProjectMap) instead of the BrandSemrushProject DB mapping when
the job metadata marks it subworkspace, mirroring prompts-subworkspace.js.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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