ruvnet/ruflo · error

Cannot enable '${flag}': dependency '${dep}' is not enabled

Error message

Cannot enable '${flag}': dependency '${dep}' is not enabled

What it means

Thrown by FeatureFlagManager#enable (v3/@claude-flow/integration/src/feature-flags.ts:188) when you enable a flag whose FEATURE_FLAG_DEFINITIONS entry lists dependencies that are not currently enabled. For example enableTrajectoryLearning depends on enableSONA (and enableAgentDB / enableTrajectoryTracking for other flags), so enabling the dependent flag first is rejected to keep the flag graph consistent.

Source

Thrown at v3/@claude-flow/integration/src/feature-flags.ts:188

  isEnabled(flag: keyof FeatureFlags): boolean {
    // Check override first
    if (this.overrides.has(flag)) {
      return this.overrides.get(flag)!;
    }
    return this.flags[flag];
  }

  /**
   * Enable a feature
   */
  enable(flag: keyof FeatureFlags, runtime: boolean = true): void {
    const previousValue = this.isEnabled(flag);

    // Check dependencies
    const info = FEATURE_FLAG_DEFINITIONS[flag];
    for (const dep of info.dependencies) {
      if (!this.isEnabled(dep)) {
        throw new Error(
          `Cannot enable '${flag}': dependency '${dep}' is not enabled`
        );
      }
    }

    if (runtime) {
      this.overrides.set(flag, true);
      this.sources.set(flag, 'runtime');
    } else {
      this.flags[flag] = true;
      this.sources.set(flag, 'config');
    }

    if (!previousValue) {
      this.emit('flag-changed', { flag, previousValue, newValue: true });
    }
  }

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Enable dependencies first: check FEATURE_FLAG_DEFINITIONS[flag].dependencies and enable each (they are defined in feature-flags.ts lines ~45–112, e.g. enableSONA before enableTrajectoryLearning).
  2. Or enable via config with the full dependency closure included, so the manager sees all flags at once.
  3. Write a small helper that topologically sorts your desired flags before calling enable().
  4. In tests, enable the base feature (enableSONA/enableAgentDB) in beforeEach before dependent flags.

Example fix

// before
manager.enable('enableTrajectoryLearning'); // throws: enableSONA not enabled

// after
manager.enable('enableSONA');
manager.enable('enableTrajectoryLearning');
Defensive patterns

Strategy: validation

Validate before calling

function enableWithDeps(mgr: FeatureFlagManager, flag: keyof FeatureFlags): void {
  for (const dep of FEATURE_FLAG_DEFINITIONS[flag].dependencies) {
    if (!mgr.isEnabled(dep)) enableWithDeps(mgr, dep);
  }
  if (!mgr.isEnabled(flag)) mgr.enable(flag);
}

Type guard

function canEnable(mgr: FeatureFlagManager, flag: keyof FeatureFlags): boolean {
  return FEATURE_FLAG_DEFINITIONS[flag].dependencies.every((d) => mgr.isEnabled(d));
}

Try / catch

try {
  mgr.enable(flag);
} catch (e) {
  if (/dependency '.*' is not enabled/.test((e as Error).message)) {
    // enable deps first (enableSONA, enableAgentDB, ...), then retry
  }
  throw e;
}

Prevention

When it happens

Trigger: manager.enable('enableTrajectoryLearning') while enableSONA is still false; enabling a dependent flag in the wrong order during startup; dependencies enabled only via a config file while you enable the dependent flag at runtime (the manager cannot see intended-but-unapplied config).

Common situations: Bootstrapping code enabling features in one pass without ordering; selectively enabling advanced features in tests without their base feature; reading flag names from a list where the base flag is filtered out.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/11b8c33f68ccda63. Report an issue: GitHub.