Repository navigation
fix(content): move Option-B fast-path flags from env vars to DB config (ImsConfig) - #2061
Merged
Merged
Conversation
…nfig Move the three Content Option-B feature flags (CONTENT_DELTA_WRITE_ENABLED, CONTENT_DELTA_READ_ENABLED, CONTENT_DELTA_SKIP_CARRYFORWARD) off process.env onto ImsConfig key/value rows (content.delta.write / .read / .skipCarryForward), read through a new cached, fail-safe resolver. - srv/lib/content-delta-flags.js: 60s-TTL warm cache (mirrors ngds-autosend), synchronous fail-open getters isDeltaWrite/Read/SkipCarryForward (default false, never block/throw on the hot path), async refreshContentDeltaFlags() plus bustContentDeltaFlagsCache(). - Warm on boot in srv/server.js (fail-open). - Replace all process.env.CONTENT_DELTA_* reads across content-store, content-publish-session, chrome-shell, admin-service, jobs/cleanup, jobs/embedding-reconciliation, embedding-pipeline, embedding-stats. - registry.js: add kind:'db' (ImsConfig-backed); resolve.js resolves it live. - AdminService.setContentDeltaFlags / getContentDeltaFlags actions (busts cache). - srv-qa cp list: add srv/lib/content-delta-flags.js. - Tests: new content-delta-flags.test.js; convert env-setting delta tests to seed ImsConfig plus warm cache.
This was referenced Aug 28, 2026
Merged
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.
Why
The three Option-B content fast-path flags —
CONTENT_DELTA_WRITE_ENABLED,CONTENT_DELTA_READ_ENABLED,CONTENT_DELTA_SKIP_CARRYFORWARD— were read directly fromprocess.env(16 sites) and declaredkind:'env'in the feature-flag registry. Env flags are set viacf set-envand silently dropped on every blue-green MTA deploy (new-idleapps start from the descriptor, not the old app's runtime env), which reverted the PROD fast path during the 1.20.0 deploy and forced a manual multi-step re-activation. Feature flags must be DB-configurable (standing rule; matchesngds-autosend).What
Move the three flags to the
ImsConfigkey/value table, read through a cached, fail-safe resolver. Allprocess.env.CONTENT_DELTA_*reads removed — no env fallback. They're now data, so they survive every deploy.srv/lib/content-delta-flags.js— mirrors thengds-autosend.jscached-DB-flag pattern. One warm cache (all 3 keys in a single SELECT), 60s TTL. Synchronous gettersisDeltaWrite()/isDeltaRead()/isDeltaSkipCarryForward()return the last-known boolean immediately and kick off a non-blocking background refresh when stale — never block, never throw. Fail-safe default false (legacy path) so a cold cache or DB error never silently enables delta reads/writes.refreshContentDeltaFlags()(fail-safe) +bustContentDeltaFlagsCache(). Keys:content.delta.write,content.delta.read,content.delta.skipCarryForward.srv/server.js— warms the cache in theservedbootstrap (fail-open).content-store.js,content-publish-session.js,chrome-shell.js,admin-service.js,jobs/{cleanup,embedding-reconciliation}.js,embedding-pipeline.js,embedding-stats.js— exact boolean semantics preserved (incl. the!== 'true'→!isDeltaSkipCarryForward()inversion in the publish carry-forward gate).registry.js— the 3 entries flippedkind:'env'→ newkind:'db'(ImsConfig-backed;resolve.jsresolves it live); env fields dropped.AdminService.setContentDeltaFlags(write, read, skipCarryForward)(per-flag upsert, busts cache) +getContentDeltaFlags(),@requires: 'Admin'(same as the NGDS kill-switch).content-delta-flags.jsadded to.deploy/mta.yamltutorials-srv-qa(transitive dep of content-store.js et al.).test/unit/content-delta-flags.test.js(defaults, read, TTL cache, bust, DB-error fail-safe); the 3 existing env-driven delta tests converted to seedImsConfig. Verified:cds compileclean,grep process.env.CONTENT_DELTA_ srv/empty, 18 delta tests + adjacent suites green.Rollout after merge/deploy
ImsConfigupsert) — they persist across deploys.cf set-env CONTENT_DELTA_*vars currently on PRODtutorials-srv/tutorials-srv-qa(the stopgap that restored the fast path tonight) so DB is the single source of truth.Notes
kind:'env'registry flags the same way.await refreshContentDeltaFlags()if we want instant toggle effect.