feat: classify onboarding-generated topics into existing categories - #3292
Open
byteclimber wants to merge 1 commit into
Open
byteclimber wants to merge 1 commit into
byteclimber wants to merge 1 commit into
Conversation
Onboarding-generated prompts previously arrived under the dimension-root `category` tag with no sub-category assignment, since `category` is an open, customer-authored dimension with no fixed taxonomy to select from (unlike `intent`/`type`). This left every onboarding prompt uncategorized until a human manually re-tagged it. Add server-side AI classification of onboarding topics against the brand's existing top-level categories, reusing the intent-classification plumbing (`createIntentClassifier`) with a per-run categorySpec built from that run's candidate category list: - `category-taxonomy.js`: system-prompt builder and response validator for topic-to-category classification. Requires an explicit `NO_MATCH` sentinel rather than forcing a pick, and rejects any category name outside the candidate list as a hallucination (`invalid_value`) rather than silently accepting it. Uses a stricter confidence floor (0.7) than intent classification (0.5), since a wrong category mints a durable, customer-visible sub-category tag. - `category-classification.js`: `classifyTopicCategories`, mirroring `classifyPromptIntents`'s fail-open ladder (budget skip-gate, Azure- not-configured fallback) simplified for the small per-run topic count (<=5 topics, single classify pass, no retry). - `markets-subworkspace.js`: `generateAndAttachPrompts` now preserves topic->prompts grouping instead of flattening immediately, fetches the brand's existing category children, classifies each topic, and creates/resolves a matched topic as a sub-category tag (best-effort, fail-open at every layer: reading existing categories, classifying, and creating each sub-category tag all fall back to leaving affected topics uncategorized without blocking the write). Fail-open by construction: when Azure OpenAI isn't configured (the existing default in all current environments/tests), classification is skipped and prompts are written exactly as before -- the prompt tag-bucketing key extension (`type\0intent\0categoryTagId`, with categoryTagId defaulting to '') is byte-identical to the old key whenever no category is resolved. All 111 pre-existing markets-subworkspace tests pass unmodified; 2 new tests cover the happy-path match+tag-creation and the fail-open path when sub-category creation fails. Full repo suite (18889 tests) passes. Implements the plan in adobe/serenity-docs#479, addressing adobe/serenity-docs#44. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
Onboarding-generated prompts previously arrived under the dimension-root
categorytag with no sub-category assignment:categoryis an open,customer-authored dimension (unlike
intent/type, which have fixedtaxonomies), so there was no existing vocabulary to classify against. This
left every onboarding prompt uncategorized until a human manually re-tagged
it — see adobe/serenity-docs#44.
This PR adds server-side AI classification of onboarding topics against the
brand's existing top-level categories, per the implementation plan in
adobe/serenity-docs#479.
Changes
category-taxonomy.js(new): system-prompt builder and responsevalidator for topic→category classification. Requires an explicit
NO_MATCHsentinel rather than forcing a pick, and rejects any categoryname outside the candidate list as a hallucination (
invalid_value)rather than silently accepting it. Confidence floor is
0.7(stricterthan intent classification's
0.5), since a wrong category mints adurable, customer-visible sub-category tag.
category-classification.js(new):classifyTopicCategories,mirroring
classifyPromptIntents's fail-open ladder (budget skip-gate,Azure-not-configured fallback), simplified for the small per-run topic
count (≤5 topics, single classify pass, no retry).
markets-subworkspace.js:generateAndAttachPromptsnow preservestopic→prompts grouping instead of flattening immediately, fetches the
brand's existing category children, classifies each topic, and
creates/resolves a matched topic as a sub-category tag. Every step is
best-effort and fails open: reading existing categories, classifying, and
creating each sub-category tag all fall back to leaving affected topics
uncategorized without blocking the prompt write.
Safety / backward compatibility
environments/tests), classification is skipped and prompts are written
exactly as before — the prompt tag-bucketing key extension
(
type\0intent\0categoryTagId, withcategoryTagIddefaulting to'')is byte-identical to the old key whenever no category is resolved.
markets-subworkspacetests pass unmodified; 2 newintegration tests cover the happy-path match+tag-creation and the
fail-open path when sub-category tag creation fails.
tsctype-check and ESLintare clean on all touched/new files.
Out of scope (tracked as follow-ups per the plan)
Refs: adobe/serenity-docs#44, adobe/serenity-docs#479
Change Management