↑↓ to navigate Enter to open "…" all these words ANDOR to combine

Architecture Decision Record

ADR-031: Config-Driven Feature Flags with Dual-Surface Enforcement

Status

Accepted (2026-06-27). Revised 2026-08-18 (a targeting-context accessor is now registered, so the built-in Targeting and Percentage filters give consistent per-user bucketing across replicas; the last Trade-offs entry is narrowed accordingly. See the Revision (2026-08-18) at the end). Revised 2026-08-31 (the targeting identifier is the JWT sub claim read through FindUserIdValue(), not a user_id claim; the Revision section is corrected accordingly).

Revised 2026-09-11 (the flag-debt trade-off is closed on the framework side: [FeatureFlag] declares a flag's lifetime, removal date and owner, FeatureFlagRegistry reports a host's own inventory, and two fitness rules behind FeatureFlagLifecycleTestsBase fail the build for an undeclared flag or a temporary one past its date; adoption is per repo, like every other fitness base. See the Revision (2026-09-11) at the end.)

Revised 2026-10-01 (the disabled response is 404 but not anonymous: the edge writes its own "Feature not available" ProblemDetails and the CQRS failure carries the Feature.Disabled code; the Decision and Rationale describe the bodies as they are. See the Revision (2026-10-01) at the end.)

Revised 2026-10-06: the CQRS disabled failure no longer names the flag; its message is the generic wording the edge handler uses, and clients branch on the Feature.Disabled code. See the Revision (2026-10-06) at the end. Revised 2026-10-21: anchors refreshed after the DisabledFeatureHandler statement moved down one line. Revised 2026-10-26: the last Trade-offs entry now states that AddAPI wires the targeting context unconditionally and that only the Targeting filter is sticky per user (the Percentage filter is random per evaluation, so the 2026-08-18 sentence above holds for Targeting only), and the flag-debt entry records that all four repos adopt the lifecycle gate.

Revised 2026-11-07: the targeting context adds the group tenant:<tenantId> when the request has resolved a tenant, so a Targeting audience can turn a flag on per tenant. See the Revision (2026-11-07) at the end.

Revised 2026-11-08 (MMCA.Common v1.281.0): stored overrides can be layered over the configuration (AddReloadableFeatureFlags), so a kill switch flips without a new revision; configuration stays the default and the answer whenever the overrides cannot be loaded. See the Revision (2026-11-08) at the end. Revised 2026-11-23: the command FeatureGate decorator sits directly inside ViewAs rather than outermost, a stored override can define a flag configuration never mentions, and the override snapshot key carries the owning service as well as the data source; anchors refreshed.

Context

The apps need to decouple release from deploy: ship code dark, flip a kill switch, or roll a feature out to a percentage of users without a redeploy. A flag has to be enforceable at two different points of the request path (the HTTP edge (an MVC action) and inside the CQRS pipeline (a command or query)) because a feature can be reachable from either. ADR-014 already places a FeatureGate decorator at the outer end of the command/query pipeline (outermost for queries, directly inside ViewAs for commands), but it only decides the decorator ordering; it does not decide the provider, the controller-edge surface, the disabled-response convention, or the rollout filters. This ADR records those.

Decision

Standardize on Microsoft.FeatureManagement, configured from the "FeatureManagement" configuration section and registered once in AddAPI (services.AddFeatureManagement() + services.AddSingleton<IDisabledFeaturesHandler, DisabledFeatureHandler>(), MMCA.Common.API/DependencyInjection.cs:108-110), with the built-in Percentage / TimeWindow / Targeting filters available for progressive rollout. The same flag name is enforced at two independent surfaces:

  • HTTP edge: [FeatureGate("X")] (Microsoft.FeatureManagement.Mvc) on a controller or action. When X is off, DisabledFeatureHandler returns an RFC 9457 ProblemDetails 404 ("Feature not available", MMCA.Common.API/FeatureManagement/DisabledFeatureHandler.cs:19-27). The body is built by hand, so it does not carry the ApiControllerBase.HandleFailure shape (title "Operation failed" plus an errors extension, MMCA.Common.API/Controllers/ApiControllerBase.cs:49-77, title at :67, errors at :72).
  • CQRS pipeline: a command/query implements IFeatureGated (exposing FeatureName). The FeatureGateQueryDecorator is the outermost query decorator, and the FeatureGateCommandDecorator sits directly inside ViewAsCommandDecorator, outside every other command decorator (ADR-014; MMCA.Common.Application/DependencyInjection.cs:158-159, :167). Each checks IFeatureManager.IsEnabledAsync(FeatureName) and, when off, short-circuits with Error.NotFoundError("Feature.Disabled", ...) (ErrorType.NotFound) before any authorization, logging, caching, validation, or transaction work. A command from a view-as caller is refused by ViewAs before the flag is checked, so that caller never reaches the disabled-feature answer.
  • Disabled = 404 (NotFound), never 403. Both surfaces return not-found rather than advertising a forbidden capability. The bodies still say a feature is off: the edge title reads "Feature not available", and the CQRS failure carries code Feature.Disabled with the generic message "The requested feature is not currently available." (the flag name is kept out of it; clients branch on the code), the same wording as the edge's Detail (MMCA.Common.Application/UseCases/Decorators/FeatureGateCommandDecorator.cs:61-63, FeatureGateQueryDecorator.cs:59-61).
  • Flag names are module constants (CatalogFeatures / SalesFeatures in Store, ConferenceFeatures / EngagementFeatures in ADC) that match keys in each service's "FeatureManagement" config, so a flag flips at config + restart, not at deploy (in a host that calls AddReloadableFeatureFlags, a stored override flips it on the next evaluation with no restart; see the Revision (2026-11-08)). The framework itself uses [FeatureGate] (e.g. the notification controllers), and the decorators ship with unit tests.

Rationale

  • Release decoupled from deploy. A kill switch or a percentage rollout becomes a configuration change, not a code change: the central reason feature management exists.
  • Two surfaces because the enforcement points see different request shapes. Gating both the edge and the handler with one flag name keeps controller and use case in agreement, so a disabled feature is unreachable from either entry instead of leaking through the one that was missed.
  • The 404 convention reuses the not-found status. The CQRS surface goes through the Result to ProblemDetails edge (ADR-013), whose errors extension serializes each error's Code and Message (MMCA.Common.API/Middleware/ErrorHttpMapping.cs:65-74); the MVC edge writes its own ProblemDetails. Both answer 404 rather than 403, so neither reveals a guarded capability, but neither body is identical to an ordinary not-found: each states that a feature is unavailable.

Trade-offs

  • The two enforcement points must agree. A flag gated on the controller but not the handler (or vice versa) is a half-protected feature; no fitness rule asserts both are wired, so coherence is a convention/audit concern.
  • Flag debt. Every flag is a branch that must eventually be removed. The framework now ships the expiry check it used to lack ([FeatureFlag] plus two fitness rules; see the Revision (2026-09-11)), but the gate is adopted per repo: a repo that has not subclassed FeatureFlagLifecycleTestsBase still carries its flag debt uncounted. All four repos (Common, ADC, Store, Helpdesk) currently subclass it.
  • Per-service configuration. The same flag name must be present in each service that enforces it. A missing key resolves to disabled (IsEnabledAsync's default): fail-safe for a kill switch, but it will silently hide a feature you meant to ship if the key is forgotten. In a host that calls AddReloadableFeatureFlags, a stored override also defines a flag configuration never mentions: the evaluation path answers from the override before the configured provider is consulted (MMCA.Common.Infrastructure/FeatureFlags/StoredOverrideFeatureDefinitionProvider.cs:43-50, override branch :45-49; the enumeration path yields it too, :65-69), so a missing configuration key means off only while no override exists for it.
  • Only the Targeting filter is sticky per user. Filters are evaluated locally in each process. AddAPI registers CurrentUserTargetingContextAccessor through WithTargeting unconditionally (MMCA.Common.API/DependencyInjection.cs:108-109), so in a host that goes through AddAPI a Targeting-filter rollout gives a signed-in user the same answer across requests and replicas, keyed on the targeting id: the sub (or mapped NameIdentifier) claim, falling back to Identity.Name when a principal carries neither (MMCA.Common.API/FeatureManagement/CurrentUserTargetingContextAccessor.cs:121). An anonymous caller gets no user id, and its only group is the resolved tenant's, if any (:101-108), so it matches no named user or role; the accessor documents a targeted feature as off for anonymous callers unless the audience opts everyone in or names their tenant (:37-39). When the request has resolved a tenant, every caller also carries the group tenant:<tenantId> (see the Revision (2026-11-07)). The built-in Percentage filter never reads the targeting context: it activates on a random percentage at each evaluation, so a Percentage-filter flag can flip between requests for the same user. A rollout that must be sticky uses Targeting with a DefaultRolloutPercentage, not Percentage.

Revision (2026-08-18)

Progressive rollout is now usable, because the targeting context exists. The Decision above listed the Percentage / TimeWindow / Targeting filters as "available", and the last Trade-offs entry recorded the catch: without a targeting context wired, bucketing is evaluated per process, so a percentage rollout assigns a user differently on each replica and a user can see a feature appear and disappear between requests.

CurrentUserTargetingContextAccessor (MMCA.Common/Source/Presentation/MMCA.Common.API/FeatureManagement/CurrentUserTargetingContextAccessor.cs:54-55) implements ITargetingContextAccessor and is registered inside AddAPI as services.AddFeatureManagement().WithTargeting<CurrentUserTargetingContextAccessor>(), preceded by AddHttpContextAccessor() (MMCA.Common/Source/Presentation/MMCA.Common.API/DependencyInjection.cs:90-92, rationale at :84-89). It takes IHttpContextAccessor rather than the scoped ICurrentUserService precisely because WithTargeting registers the accessor as a singleton. UserId resolves to the JWT sub claim through user.FindUserIdValue(), falling back to Identity.Name (:86), and Groups accepts role claims under ClaimTypes.Role, "role" or "roles" (:76-82), so a rollout can target a role as well as a user. An unauthenticated or absent principal yields an empty context rather than an exception (:67-74), which keeps anonymous traffic evaluating to the flag's non-targeted result instead of failing. FindUserIdValue (MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/ClaimsPrincipalExtensions.cs:26-28) reads the raw sub claim (AuthClaimTypes.Subject, MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/AuthClaimTypes.cs:25) and falls back to the mapped ClaimTypes.NameIdentifier the JWT bearer handler produces, so targeting buckets on exactly the identifier CurrentUserService and the idempotency filter read.

No decorator changed. FeatureGateCommandDecorator still depends only on IFeatureManager and still calls IsEnabledAsync(featureGated.FeatureName) with no targeting argument (:20, :51); the targeting context is resolved inside the filter through the registered accessor. Both enforcement surfaces therefore inherit consistent bucketing with no change at either call site, which is the property that made this a registration-only change.

The Trade-offs entry above is narrowed, not removed: bucketing is now consistent across replicas for any host that goes through AddAPI, but it is only as consistent as the sub claim is stable, and a flag whose filter is configured without a targeting audience still behaves exactly as before.

ADR-014 (the decorator pipeline and the ordering that puts FeatureGate outermost for queries and directly inside ViewAs for commands, with Authorization registered directly inside it so a disabled feature does not leak which permission guards it), ADR-013 (the Result / Error and ProblemDetails edge the disabled responses reuse), ADR-019 / ADR-020 / ADR-021 / ADR-026 (the other opt-in, audit-the-inventory capabilities), ADR-020 (the role vocabulary the targeting accessor reads as Groups).

Revision (2026-09-11)

The expiry gap the Trade-offs recorded is closed. "The framework provides no expiry or staleness check" was true from this record's acceptance until now. What it cost was never the flag itself but the branch behind it: once a rollout finishes, the losing branch is unreachable code that no test, no coverage report and no reviewer is prompted to notice.

A flag declares its lifecycle on the constant. [FeatureFlag] (MMCA.Common/Source/Core/MMCA.Common.Shared/FeatureFlags/FeatureFlagAttribute.cs:32) takes a FeatureFlagLifetime (MMCA.Common/Source/Core/MMCA.Common.Shared/FeatureFlags/FeatureFlagLifetime.cs:9, Permanent at :15, Temporary at :21) and carries an optional Owner (FeatureFlagAttribute.cs:52) and a RemoveBy written as ISO yyyy-MM-dd (:46, the format constant at :35, the parser at :60). RemoveBy is required on a temporary flag and forbidden on a permanent one, which is what keeps a removal date meaningful rather than decorative.

The inventory is readable at runtime. FeatureFlagRegistry (MMCA.Common/Source/Core/MMCA.Common.Shared/FeatureFlags/FeatureFlagRegistry.cs:35) describes the public const string fields of every static *Features class in an assembly (:46, :64, the class test at :77, the field selection at :91) as FeatureFlagDescriptor records (:17) carrying field name, flag name, lifetime, removal date and owner, so an administration surface reporting a host's flags does not have to re-derive the *Features convention for itself.

Two fitness rules make it a build gate. ArchitectureRules.FeatureFlagsDeclareLifetime (MMCA.Common/Source/Hosting/MMCA.Common.Testing.Architecture/Rules/Governance/ArchitectureRules.FeatureFlags.cs:28) fails for a constant with no attribute (:42), for a permanent flag that sets RemoveBy (:46), and for a temporary flag whose date is missing or unparseable (:51). TemporaryFeatureFlagsAreNotPastRemoveBy (:70) fails for any temporary flag whose date has passed (:77), naming the flag, the date and the owner. The second rule is the dead-toggle detector: the red build is what tells you the rollout finished and the branch it chose between can go. Both are exposed as facts on FeatureFlagLifecycleTestsBase (MMCA.Common/Source/Hosting/MMCA.Common.Testing.Architecture/Bases/Governance/FeatureFlagLifecycleTestsBase.cs:10, the two facts at :20-:25, the architecture map at :12), whose Today is a protected virtual property (:18) so a repo can pin the judgement date rather than let the build's clock decide when a toggle goes red.

Adoption is per repo, and the framework annotates its own flags. Like every fitness base (ADR-058), the gate exists only where a repo subclasses it, so this closes the trade-off for an adopting repo and leaves it open for one that changes nothing; it is additive, and a consumer that adopts none of it keeps building exactly as before. The framework's own two flags are annotated Permanent (MMCA.Common/Source/Core/MMCA.Common.Shared/Notifications/NotificationFeatures.cs:11, MMCA.Common/Source/Core/MMCA.Common.Shared/Privacy/PrivacyFeatures.cs:11). The fix for a flag that goes red is to delete the flag and the branch it no longer chooses between, not to push the date out.

Revision (2026-10-01)

The disabled response is not-found, but not anonymous. The Decision and Rationale said both surfaces emit the HandleFailure not-found shape, so a disabled feature is indistinguishable from a nonexistent one. The code does not do that. DisabledFeatureHandler writes its own ProblemDetails with title "Feature not available" and no errors extension (MMCA.Common/Source/Presentation/MMCA.Common.API/FeatureManagement/DisabledFeatureHandler.cs:18-26), unlike HandleFailure's "Operation failed" body (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/ApiControllerBase.cs:50-58). The CQRS surface does go through HandleFailure, and BuildErrorsExtension (MMCA.Common/Source/Presentation/MMCA.Common.API/Middleware/ErrorHttpMapping.cs:61-69) serializes the Feature.Disabled code and the message "Feature '{FeatureName}' is not currently available." (MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/FeatureGateCommandDecorator.cs:57-59), so that response names the flag. The decision itself (404, never 403, at both surfaces) is unchanged; the Decision and Rationale bullets now describe the bodies as they are. The AddAPI registration anchor in the Decision is refreshed to DependencyInjection.cs:105-107.

Revision (2026-10-06)

  • The CQRS disabled failure no longer names the flag. The Revision (2026-10-01) quoted the message "Feature '{FeatureName}' is not currently available." and said that response names the flag. Both decorators now return Error.NotFoundError("Feature.Disabled", "The requested feature is not currently available.") (MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/FeatureGateCommandDecorator.cs:60-62, FeatureGateQueryDecorator.cs:59-61), the same wording as DisabledFeatureHandler's Detail (MMCA.Common/Source/Presentation/MMCA.Common.API/FeatureManagement/DisabledFeatureHandler.cs:22). The source comment (FeatureGateCommandDecorator.cs:56-58) records why: the message reaches the user verbatim, so the internal flag name stays out and clients branch on the code. The response is still not anonymous (the code and the edge title both say a feature is off); the Decision bullet now says so.
  • Current locations for facts recorded in the Revision (2026-08-18). The decorator's IFeatureManager parameter is at FeatureGateCommandDecorator.cs:22 (class at :20) and the IsEnabledAsync(featureGated.FeatureName) call at :53. AddHttpContextAccessor() is at MMCA.Common/Source/Presentation/MMCA.Common.API/DependencyInjection.cs:104 and AddFeatureManagement().WithTargeting<CurrentUserTargetingContextAccessor>() at :105-106, with the singleton rationale at :98-103. AuthClaimTypes.Subject ("sub") is at MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/AuthClaimTypes.cs:34.
  • Anchors in the live sections were re-verified against current source; BuildErrorsExtension is at ErrorHttpMapping.cs:62-70.

Revision (2026-10-21)

Re-verified against current source. The decision is unchanged: both surfaces answer 404, the edge writes its own "Feature not available" ProblemDetails, and both decorators return the generic Feature.Disabled failure that does not name the flag. Only the edge handler's anchor moved.

  1. Anchors re-verified against current source: the DisabledFeatureHandler result statement is at MMCA.Common/Source/Presentation/MMCA.Common.API/FeatureManagement/DisabledFeatureHandler.cs:19-27 (Title at :22, Detail at :23); the decorators' Error.NotFoundError("Feature.Disabled", ...) is at MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/FeatureGateCommandDecorator.cs:60-62 and FeatureGateQueryDecorator.cs:59-61; the AddAPI registration at DependencyInjection.cs:105-107, HandleFailure's body at ApiControllerBase.cs:50-58 and BuildErrorsExtension at ErrorHttpMapping.cs:62-70 are unchanged.

Revision (2026-10-26)

Re-verified against current source. The decision is unchanged: both surfaces answer 404, the edge writes its own "Feature not available" ProblemDetails, and both decorators return the generic Feature.Disabled failure. Two live Trade-offs entries moved to match source.

  1. The rollout trade-off no longer says "per-process out of the box". The Status recorded in 2026-08-18 that the last Trade-offs entry was narrowed, but only that Revision qualified it; the entry itself still said the rollout is per-process out of the box. AddAPI calls AddFeatureManagement().WithTargeting<CurrentUserTargetingContextAccessor>() unconditionally (MMCA.Common/Source/Presentation/MMCA.Common.API/DependencyInjection.cs:105-106, preceded by AddHttpContextAccessor() at :104), so the entry now states the residual limits instead. The per-user stickiness belongs to the Targeting filter alone: the built-in Percentage filter never reads the targeting context and activates "based on a random percentage" on each evaluation (Microsoft.FeatureManagement 4.8.0, pinned at MMCA.Common/Directory.Packages.props:32), so the Status sentence of 2026-08-18 ("the built-in Targeting and Percentage filters give consistent per-user bucketing") holds for Targeting only. The targeting id is the sub claim falling back to Identity.Name (MMCA.Common/Source/Presentation/MMCA.Common.API/FeatureManagement/CurrentUserTargetingContextAccessor.cs:86), and an anonymous caller gets an empty context (:67-74), which the accessor documents as leaving a targeted feature off unless the audience opts everyone in (:27-28).
  2. The lifecycle gate is adopted in all four repos. FeatureFlagLifecycleTestsBase is subclassed in MMCA.Common/Tests/Architecture/MMCA.Common.Architecture.Tests/Governance/FeatureFlagLifecycleTests.cs:13, MMCA.ADC/Tests/Architecture/MMCA.ADC.Architecture.Tests/Governance/FeatureFlagLifecycleTests.cs:9, MMCA.Store/Tests/Architecture/MMCA.Store.Architecture.Tests/Governance/FeatureFlagLifecycleTests.cs:9 and MMCA.Helpdesk/Tests/Architecture/MMCA.Helpdesk.Architecture.Tests/ArchitectureTests.cs:210. Adoption stays per repo; the flag-debt entry now records the current state.
  3. Anchors re-verified against current source: the decorators' IFeatureManager parameter at FeatureGateCommandDecorator.cs:22 and FeatureGateQueryDecorator.cs:22, IsEnabledAsync at :53 in both, and Error.NotFoundError at FeatureGateCommandDecorator.cs:60-62 and FeatureGateQueryDecorator.cs:59-61; DisabledFeatureHandler.cs:19-27 with Title at :22 and Detail at :23 (the :22 Detail anchor in the Revision (2026-10-06) is superseded by this one); AuthClaimTypes.Subject at AuthClaimTypes.cs:34; BuildErrorsExtension at ErrorHttpMapping.cs:62; the AddAPI registration at DependencyInjection.cs:105-107. The stale anchors inside the Revisions (2026-08-18) and (2026-10-01) stay as written, as does the :22 Detail anchor in the Revision (2026-10-06) superseded above; the rest of the Revision (2026-10-06) and the Revision (2026-10-21) carry current locations.

Revision (2026-11-07)

Tenant targeting. The two enforcement surfaces, the 404 answers and the lifecycle gate are unchanged; the targeting context gains one group.

  1. A resolved tenant becomes a targeting group. CurrentUserTargetingContextAccessor.GetContextAsync reads the request's scoped ITenantContext from HttpContext.RequestServices and, when it holds a non-blank TenantId, adds the group tenant:<tenantId> (MMCA.Common/Source/Presentation/MMCA.Common.API/FeatureManagement/CurrentUserTargetingContextAccessor.cs:99, :128-132). It is appended after the role groups for a signed-in caller (:110-117) and is the only group of an anonymous one (:101-108), so a request in tenant acme matches an audience group named tenant:acme whether or not the caller is signed in. The name is built by the public TenantGroup(tenantId) from TenantGroupPrefix = "tenant:" (:75, :83-87), so a test or an admin tool can produce the exact group string.
  2. No host changes. The accessor is the one AddAPI already registers (MMCA.Common.API/DependencyInjection.cs:104-106). A host without tenancy never registers or resolves a tenant, so no group is added (CurrentUserTargetingContextAccessor.cs:126-127), and the group only matters to an audience that names it. The tenant is the one ADR-073's resolution put on the request.
  3. The Trade-offs entry now names the tenant group and the current anchors (:121 for the targeting id, :101-108 for the anonymous context, :37-39 for the documented anonymous behavior). The accessor's own example targets a tenant with RolloutPercentage 100 (:53-55).

Revision (2026-11-08): stored overrides over configuration

Context. A flag's value came from configuration alone, so flipping a kill switch meant a new revision: the very deploy a kill switch exists to avoid. MMCA.Common v1.281.0 (MMCA.Common/CHANGELOG.md:19) adds an opt-in layer of stored overrides. The two enforcement surfaces, the 404 answers, the targeting context and the lifecycle gate are unchanged.

Decision.

  1. Overrides are a definition provider layered over the configured one. AddReloadableFeatureFlags(configuration, params Assembly[] flagAssemblies), called after AddAPI(), decorates the registered IFeatureDefinitionProvider and throws when none is registered yet (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/DependencyInjection.FeatureFlags.cs:47, :77-86). StoredOverrideFeatureDefinitionProvider answers a flag with a stored override from that override and every other flag from the configured provider, unchanged (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/StoredOverrideFeatureDefinitionProvider.cs:43-70). The FeatureGate decorators and [FeatureGate] keep calling IFeatureManager, so an override takes effect on the next evaluation with no restart (:16-18).
  2. An override is expressed with the built-in filters. On becomes AlwaysOn, off becomes no filter, and a percentage or a targeted audience becomes the targeting filter's audience, so a percentage stays sticky per user (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/FeatureFlagDefinitions.cs:13-17, :33-46).
  3. One snapshot, invalidated on write. The whole override table is one cache entry in the host's ICacheService, keyed by the owning data source under featureflags:overrides: (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/FeatureFlagOverrideSnapshot.cs:43-57), the PermissionGrantCache shape. Every set or clear invalidates it by prefix (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/FeatureFlagAdministrationService.cs:80, :99, :111-119). With the two-level cache the prefix invalidation replaces one generation token on the shared Redis (ADR-077), so a flip reaches every replica within seconds; on a memory-only host FeatureFlags:OverrideCacheSeconds (default 30, 1 to 3600) bounds how long another replica serves the old snapshot (FeatureFlagOverrideSnapshot.cs:16-23; MMCA.Common/Source/Core/MMCA.Common.Application/FeatureFlags/FeatureFlagOverrideSettings.cs:14-24). A failed invalidation after a committed write is logged and the write still succeeds (FeatureFlagAdministrationService.cs:19-23).
  4. Configuration answers when the overrides cannot be loaded. A load failure is logged as a Warning and every flag answers from configuration until the next load succeeds; cancellation is never swallowed (StoredOverrideFeatureDefinitionProvider.cs:75-95). The override layer is never more fragile than the configuration under it: a transient database error or an unapplied migration would otherwise fail every feature-gated command and query.
  5. Only declared flags can be overridden. The catalog is FeatureFlagRegistry.Describe over the assemblies the host passes (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/FeatureFlagCatalog.cs:17-20); any other name, including one configuration happens to carry, is refused with FeatureFlag.Undeclared (404) before anything is written (FeatureFlagAdministrationService.cs:15-17, :69-72, :88-91, :103-106). An override must name a flag some code reads, or it is a typo stored as data.
  6. Stored in the owning service's database, mapped only where enabled. FeatureFlagOverrides lives in the database FeatureFlags:DataSourceName names (FeatureFlagOverrideSettings.cs:26-31), and the call registers the model gate that maps it there and nowhere else (DependencyInjection.FeatureFlags.cs:36-40, :69-70; MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/DbContexts/ApplicationDbContext.cs:470, :1009). Clearing an override soft-deletes the row, so the audit fields record who cleared it.
  7. An administration surface behind features:manage. FeatureFlagsControllerBase (abstract, no route) lists each declared flag with its lifetime, owner, configured value, override and effective value, sets an override with a required Reason, and clears one (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/Administration/FeatureFlagsControllerBase.cs:37-38, :49, :68, :93; AdministrationPermissions.ManageFeatures, MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/Permissions/AdministrationPermissions.cs:33). The routeless FeatureFlagAdmin page shows one table across the flag sources given to AddFeatureFlagAdministrationUI(params string[] sources) (MMCA.Common/Source/Presentation/MMCA.Common.UI/DependencyInjection.cs:387), so a multi-service host shows every service's flags together.

Consequences.

  • A host opts in per service: the call, one FeatureFlagOverrides migration on that service's database (DesignTimeDbContextOptions.EnableFeatureFlagOverrides), the controller subclass and a page route behind features:manage (MMCA.Common/UPGRADING.md:72-88). A host that never calls it changes nothing.
  • MMCA.ADC adopts it on Conference and Engagement, with features:manage granted to Organizer only and one Feature flags page over both sources (MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.UI/DependencyInjection.cs:58-60).
  • An override outlives its reason: it is not time-boxed, and the page shows each active override with its Reason so a stale one is visible.
  • Rejected: Azure App Configuration (a paid service and a vendor dependency for a table the owning service can hold), and per-tenant override rows (targeting groups already cover tenants, see the Revision (2026-11-07)).

Revision (2026-11-23)

Re-verified against current source. The decision is unchanged: both surfaces answer 404, the edge writes its own "Feature not available" ProblemDetails, both decorators return the generic Feature.Disabled failure, and the override layer stays opt-in. Three facts moved and the live anchors were re-pointed.

  1. FeatureGate is outermost for queries only. The command chain registers ViewAsCommandDecorator after FeatureGateCommandDecorator, so ViewAs is outermost and FeatureGate sits directly inside it (MMCA.Common/Source/Core/MMCA.Common.Application/DependencyInjection.cs:158-159; the decorator's own doc says so at MMCA.Common/Source/Core/MMCA.Common.Application/UseCases/Decorators/FeatureGateCommandDecorator.cs:14-16). The query chain still ends with FeatureGateQueryDecorator (DependencyInjection.cs:167). The Context, Decision and Related sections now say so, and the Decision notes the consequence: a view-as caller's command is refused by ViewAs before the flag is read.
  2. A missing configuration key is off only while no override exists. With AddReloadableFeatureFlags, StoredOverrideFeatureDefinitionProvider answers a flag from its stored override before consulting the configured provider (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/StoredOverrideFeatureDefinitionProvider.cs:43-50, override branch :45-49) and also enumerates every stored override that configuration never mentions (:65-69). The per-service configuration Trade-offs entry now records it.
  3. The override snapshot is keyed by the owning service and the data source. The Revision (2026-11-08) says the entry is keyed by the owning data source under featureflags:overrides:. The key is featureflags:overrides:<service>:<DataSourceName>:all, where the service is the host's IHostEnvironment.ApplicationName, else the entry assembly name, else the literal host (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/FeatureFlags/FeatureFlagOverrideSnapshot.cs:53, :62, :66, :77-78; the resolver :85-94, host fallback :93), because two services on one Redis that keep the default FeatureFlags:DataSourceName would otherwise share one snapshot (:27-33). A write still invalidates that one prefix (:70-71). The memory-only staleness remarks are at :16-25.
  4. Anchors re-verified against current source: Error.NotFoundError("Feature.Disabled", ...) at FeatureGateCommandDecorator.cs:61-63 (class :21, IFeatureManager :23, IsEnabledAsync :54, the rationale comment :57-59) and FeatureGateQueryDecorator.cs:59-61 (IFeatureManager :22, IsEnabledAsync :53); the AddAPI registration at MMCA.Common/Source/Presentation/MMCA.Common.API/DependencyInjection.cs:107-110 (AddHttpContextAccessor :107, WithTargeting :108-109, DisabledFeatureHandler :110, singleton rationale :101-106); HandleFailure at ApiControllerBase.cs:49-77 (title :67, errors :72); BuildErrorsExtension at ErrorHttpMapping.cs:65-74; Microsoft.FeatureManagement and .AspNetCore 4.8.0 at MMCA.Common/Directory.Packages.props:99-100. For the Revision (2026-11-08): the FeatureFlagOverrides model gate is resolved at ApplicationDbContext.cs:437, applied at :537 and decided by ResolveFeatureFlagOverrideGate at :1083; AddFeatureFlagAdministrationUI(params string[] sources) is at MMCA.Common/Source/Presentation/MMCA.Common.UI/DependencyInjection.cs:456; v1.281.0 is at MMCA.Common/CHANGELOG.md:695 and its opt-in steps under MMCA.Common/UPGRADING.md:525 (the reloadable-feature-flags block at :562, steps :565-574). The stale anchors inside the earlier Revisions stay as written.