Module: RosettAi::FeatureFlags
- Defined in:
- lib/rosett_ai/feature_flags.rb
Overview
Environment-variable-based feature gating for experimental features.
Setting +RAI_EXPERIMENTAL=workflow,mcp+ enables only the listed features; all others remain hidden. Flags are parsed once at module load time into a frozen Set for O(1) membership checks.
Defined Under Namespace
Classes: ExperimentalFeatureError
Constant Summary collapse
- KNOWN_FLAGS =
All recognised experimental feature names. When a feature is promoted to stable, remove it from this set.
Set['workflow', 'mcp', 'comply', 'retrofit'].freeze
Class Method Summary collapse
-
.all_enabled ⇒ Set<String>
Returns the Set of currently active (enabled) flags.
-
.enabled?(feature) ⇒ Boolean
Returns true if the given feature is currently enabled.
-
.gate!(feature)
Raises ExperimentalFeatureError unless the given feature is enabled.
-
.reset!
Re-parses RAI_EXPERIMENTAL from the environment.
Class Method Details
.all_enabled ⇒ Set<String>
Returns the Set of currently active (enabled) flags.
63 64 65 |
# File 'lib/rosett_ai/feature_flags.rb', line 63 def all_enabled active_flags end |
.enabled?(feature) ⇒ Boolean
Returns true if the given feature is currently enabled.
44 45 46 |
# File 'lib/rosett_ai/feature_flags.rb', line 44 def enabled?(feature) active_flags.include?(feature.to_s) end |
.gate!(feature)
This method returns an undefined value.
Raises ExperimentalFeatureError unless the given feature is enabled. Used as a guard in CLI commands that are experimental.
54 55 56 57 58 |
# File 'lib/rosett_ai/feature_flags.rb', line 54 def gate!(feature) return if enabled?(feature) raise ExperimentalFeatureError, feature end |
.reset!
This method returns an undefined value.
Re-parses RAI_EXPERIMENTAL from the environment. Intended for test isolation only.
71 72 73 |
# File 'lib/rosett_ai/feature_flags.rb', line 71 def reset! @active_flags = nil end |