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.

Examples:

Check if a feature is enabled

RosettAi::FeatureFlags.enabled?(:workflow) # => true if RAI_EXPERIMENTAL includes "workflow"

Gate a command (raises if not enabled)

RosettAi::FeatureFlags.gate!(:workflow)

Author:

  • hugo

  • claude

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

Class Method Details

.all_enabledSet<String>

Returns the Set of currently active (enabled) flags.

Returns:

  • (Set<String>)


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.

Parameters:

  • feature (Symbol, String)

    the feature flag name

Returns:

  • (Boolean)


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.

Parameters:

  • feature (Symbol, String)

    the feature flag name

Raises:



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