feature_flags library
The Zuraffa feature-flag gateway (spec 030, issue #2066).
Public barrel for the feature-flag system: the gate vocabulary
(FeatureGate, FeatureGate.parse, FeatureGateType), the runtime
(FeatureFlagRuntime, Resolvers, ProviderContext), and the
.zfa.json config layer. Consuming apps import
package:zuraffa/feature_flags.dart — never the src/ paths.
Gate kinds: membership:<tier>, locale:<l1>,<l2>,
variant:<a|b>, custom:<name>, and — since issue #2066 —
platform:<os[,os…]>, which scopes a feature to the operating systems
the injected Resolvers.platform reports:
import 'dart:io';
import 'package:zuraffa/feature_flags.dart';
final gateway = FeatureFlagRuntime(
enabled: {'agent-access', 'managed-proxy'},
gates: {
'agent-access': [FeatureGate.parse('platform:macos')],
'managed-proxy': [FeatureGate.parse('platform:ios')],
},
resolvers: Resolvers(platform: () => Platform.operatingSystem),
);
if (gateway.isEnabled('agent-access')) {
// wire the agent endpoint — macOS only.
}
Classes
- FeatureFlag
- A declared feature flag: name, build-time enabled state, optional gates.
- FeatureFlagConfig
-
Parsed + validated
features:/flavors:configuration (spec 030 FR-001, FR-003). All validation failures throw FeatureConfigException with a message naming the offending item. - FeatureFlagProvider
-
A pluggable whole-feature resolver (FR-009). Return
nullto express "no opinion" — the runtime then falls back to the build-time default. - FeatureFlagRuntime
-
The runtime behind the generated
FeatureFlagsregistry. Static by default (build-time enabled set), dynamic through gates and providers. - FeatureGate
- A single parsed gate condition attached to a feature.
- ProviderContext
- Context handed to providers: user tier, locale, the resolved variant for the feature when a variant gate is declared, and the operating system the PlatformResolver reported (issue #2066).
- Resolvers
- Injectable resolver bundle.
Enums
- FeatureGateType
- Gate kinds supported by the feature-flag system.
Functions
-
isValidFeatureName(
String name) → bool - Valid feature name: alphanumeric plus hyphens (spec Assumption 2).
-
pascalToKebab(
String name) → String -
ProAnalytics->pro-analytics— maps a generated slice/entity name onto its feature-flag name so the generation pipeline can match a requested name against the disabled feature-set.
Typedefs
- CustomGateHandler = bool Function(ProviderContext context)
- Custom gate handler: receives a ProviderContext and decides the gate.
- LocaleResolver = String? Function()
-
Locale resolver (FR-007). Returns e.g.
en-USor null when unavailable. - MembershipResolver = String? Function()
-
Membership entitlement resolver (FR-006). Returns the current tier
(e.g.
free,pro) or null when unavailable. Apps wire their entitlements/subscription backend here. - PlatformResolver = String? Function()
-
Platform resolver (issue #2066): returns the host operating system
(e.g.
macos,ios) or null when unavailable. Apps wirePlatform.operatingSystemhere; tests wire an explicit value. -
VariantResolver
= String Function(String feature, List<
String> variants) - A/B variant picker (FR-008): given the feature and its declared variants, return the active variant for this session.
Exceptions / Errors
- FeatureConfigException
- Validation/parse failure. The message always names the offending item (feature, gate, or flavor) — US1.AC4 requires errors to name the unknown feature.