{"record":{"id":"11b8c33f68ccda63","repo":"ruvnet/ruflo","slug":"cannot-enable-flag-dependency-dep-is-no","errorCode":null,"errorMessage":"Cannot enable '${flag}': dependency '${dep}' is not enabled","messagePattern":"Cannot enable '(.+?)': dependency '(.+?)' is not enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/feature-flags.ts","lineNumber":188,"sourceCode":"  isEnabled(flag: keyof FeatureFlags): boolean {\n    // Check override first\n    if (this.overrides.has(flag)) {\n      return this.overrides.get(flag)!;\n    }\n    return this.flags[flag];\n  }\n\n  /**\n   * Enable a feature\n   */\n  enable(flag: keyof FeatureFlags, runtime: boolean = true): void {\n    const previousValue = this.isEnabled(flag);\n\n    // Check dependencies\n    const info = FEATURE_FLAG_DEFINITIONS[flag];\n    for (const dep of info.dependencies) {\n      if (!this.isEnabled(dep)) {\n        throw new Error(\n          `Cannot enable '${flag}': dependency '${dep}' is not enabled`\n        );\n      }\n    }\n\n    if (runtime) {\n      this.overrides.set(flag, true);\n      this.sources.set(flag, 'runtime');\n    } else {\n      this.flags[flag] = true;\n      this.sources.set(flag, 'config');\n    }\n\n    if (!previousValue) {\n      this.emit('flag-changed', { flag, previousValue, newValue: true });\n    }\n  }\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/feature-flags.ts#L170-L206","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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).","Or enable via config with the full dependency closure included, so the manager sees all flags at once.","Write a small helper that topologically sorts your desired flags before calling enable().","In tests, enable the base feature (enableSONA/enableAgentDB) in beforeEach before dependent flags."],"exampleFix":"// before\nmanager.enable('enableTrajectoryLearning'); // throws: enableSONA not enabled\n\n// after\nmanager.enable('enableSONA');\nmanager.enable('enableTrajectoryLearning');","handlingStrategy":"validation","validationCode":"function enableWithDeps(mgr: FeatureFlagManager, flag: keyof FeatureFlags): void {\n  for (const dep of FEATURE_FLAG_DEFINITIONS[flag].dependencies) {\n    if (!mgr.isEnabled(dep)) enableWithDeps(mgr, dep);\n  }\n  if (!mgr.isEnabled(flag)) mgr.enable(flag);\n}","typeGuard":"function canEnable(mgr: FeatureFlagManager, flag: keyof FeatureFlags): boolean {\n  return FEATURE_FLAG_DEFINITIONS[flag].dependencies.every((d) => mgr.isEnabled(d));\n}","tryCatchPattern":"try {\n  mgr.enable(flag);\n} catch (e) {\n  if (/dependency '.*' is not enabled/.test((e as Error).message)) {\n    // enable deps first (enableSONA, enableAgentDB, ...), then retry\n  }\n  throw e;\n}","preventionTips":["Enable base flags (enableSONA, enableAgentDB) before advanced ones at startup.","Encode the dependency closure in your config so ordering never matters.","In tests, reset and re-enable the full flag set in beforeEach."],"tags":["feature-flags","dependencies","configuration","ordering"],"backgroundTag":"feature-flag-dependency","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}