fix(drs-prompt-generation): enforce v1-write ban under brandalf / brandalf_migration (LLMO-4743)#2479
Open
rainer-friederich wants to merge 4 commits into
Open
fix(drs-prompt-generation): enforce v1-write ban under brandalf / brandalf_migration (LLMO-4743)#2479rainer-friederich wants to merge 4 commits into
rainer-friederich wants to merge 4 commits into
Conversation
…ndalf_migration (LLMO-4743) Resolves the site -> org for incoming DRS prompt-generation jobs and skips the v1 LLMO config write (and the llmo-customer-analysis fan-out) whenever the org has brandalf=true OR brandalf_migration=true. Pre-flip must-have for the Adobe brandalf_migration cutover (LLMO-4587). The shared brandalf flag check is extracted to src/utils/feature-flags.js so the existing isBrandalfEnabled (used by llmo-customer-analysis for v2 onboarding) and the new isBrandalfOrMigrationEnabled (used here for the v1 write ban) share one fetcher. Fail-open on lookup or API errors so non-brandalf orgs keep working. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Collapse redundant brandalf gate: single early-return when the org is
brandalf-blocked instead of duplicate `if (brandalfBlocksV1)` checks.
- Include `drsJobId` in the new skip-path log messages, matching the
existing log style elsewhere in the file.
- Fix the `processes result for all sources` loop test which previously
re-mocked the handler without stubbing feature-flags.js — the gate was
hitting the real isBrandalfOrMigrationEnabled and only passing by
accident via fail-open. Now stubs both feature-flags.js and Site.findById
for the rebuilt context, and asserts the brandalf check actually runs.
- Add the missing test case for `source=onboarding, no onboarding_mode,
brandalf=true` per the PR's own DoD ("Tests cover both flags, both source
values, and both onboardingMode values").
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
This PR will trigger a patch release when merged. |
Contributor
Author
|
Self-review pass via three parallel code-reviewer agents (correctness, conventions, simplicity). Addressed in 8b11cba:
Skipped (with rationale):
After fixes: 112 tests passing, 100% coverage on |
igor-grubic
approved these changes
May 6, 2026
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.
Related Issues
Summary
Pre-flip must-have for the Adobe
brandalf_migrationcutover. Under the newpolicy v1 writes are forbidden and
charUpdaterdoes not run, so the S3mirror at
config/llmo/<siteId>/llmo-config.jsonmust be treated asread-only the moment an org has either
brandalf=trueorbrandalf_migration=true.Today
src/drs-prompt-generation/handler.js:159only gates the v1 write onsource !== "onboarding" || onboardingMode !== "v2". Any non-onboarding job(periodic regeneration, manual recovery, dashboard retriggers) for a
brandalf_migrationorg currently writes v1 unconditionally.What changed
src/utils/feature-flags.jsexporting:isBrandalfEnabled(orgId, env, log)— existing semantics (brandalf only),used by
llmo-customer-analysisfor v2 onboarding.isBrandalfOrMigrationEnabled(orgId, env, log)— new helper,brandalfORbrandalf_migration. Used by drs-prompt-generation forthe v1-write ban. Aligns with the DRS-side
is_brandalf_or_migration_enabledhelper from LLMO-4721.
false) onmissing env, non-ok response, or thrown error.
src/llmo-customer-analysis/handler.js— replaces its privateisBrandalfEnabledwith the imported one. Same call site, same semantics.src/drs-prompt-generation/handler.js:siteId→orgIdviaSite.findByIdand callsisBrandalfOrMigrationEnabledonce per invocation.writeConfigwhen the org is brandalf-gated, ANDllmo-customer-analysisfan-out for the same orgs.warns and writes v1 (preserves current behavior for non-brandalf orgs).
test/utils/feature-flags.test.js(14 cases) — full unit coverage.test/drs-prompt-generation/handler.test.js— 11 new gate testscovering both flags, both source values, both
onboardingModevalues,plus all fail-open edge cases.
test/audits/llmo-customer-analysis.test.js— refactored to mockfeature-flags.jsdirectly (cleaner than the prior fetch-call-orderingpattern). All 48 existing cases preserved.
Out of scope (covered elsewhere)
getConfigCdnProvider) and Reader 2 (cdn-logs-report) —deferred to LLMO-4715b post-flip.
llmo-customer-analysischange-detection diff) — split into asibling ticket.
Test plan
npx mocha 'test/audits/llmo-customer-analysis.test.js' 'test/utils/feature-flags.test.js' 'test/drs-prompt-generation/**/*.test.js'— 111 passingnpx eslinton touched files — cleanc8coverage for all touched files — 100% statements / branches / functions / lineswriteConfigcall lands and no fan-out fires🤖 Generated with Claude Code