{"record":{"id":"03261cda2c72ec47","repo":"ruvnet/ruflo","slug":"unsupported-policy-state-version-string-parsed-v","errorCode":null,"errorMessage":"unsupported-policy-state-version:${String(parsed.version)}","messagePattern":"unsupported-policy-state-version:(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/policy-runtime.ts","lineNumber":174,"sourceCode":"    const file = join(resolve(projectRoot), relative);\n    if (!existsSync(file)) continue;\n    const content = readFileSync(file, 'utf8');\n    const section = content.match(/(?:^|\\n)\\[policy\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[[^\\]]+\\]|\\s*$)/)?.[1];\n    const mode = section?.match(/(?:^|\\n)\\s*mode\\s*=\\s*\"(legacy|observe|enforce)\"/)?.[1];\n    if (mode) configured = mode as PolicyState['mode'];\n  }\n  return configured;\n}\n\nexport function loadPolicyState(projectRoot = process.cwd()): PolicyState {\n  const target = paths(projectRoot);\n  if (!existsSync(target.state)) {\n    verifyStateAnchor(projectRoot, undefined);\n    return createLegacyCompatibleState(detectLegacyCapabilities(projectRoot));\n  }\n  const parsed = JSON.parse(readFileSync(target.state, 'utf8')) as PolicyState;\n  if (parsed.version !== 1 || !Array.isArray(parsed.rules) || !Array.isArray(parsed.receipts)) {\n    throw new Error(`unsupported-policy-state-version:${String(parsed.version)}`);\n  }\n  verifyStateAnchor(projectRoot, parsed);\n  return parsed;\n}\n\nexport async function autoMigratePolicyStateIfNeeded(projectRoot = process.cwd()): Promise<{\n  migrated: boolean;\n  statePath?: string;\n  mode?: PolicyState['mode'];\n}> {\n  const target = paths(projectRoot);\n  if (existsSync(target.state)) {\n    const configured = configuredPolicyMode(projectRoot);\n    const current = loadPolicyState(projectRoot);\n    if (configured && current.configuredMode !== configured) {\n      await withPolicyTransaction(projectRoot, (engine) => engine.setConfiguredMode(configured));\n    }\n    return { migrated: false, statePath: target.state, mode: loadPolicyState(projectRoot).mode };","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/policy-runtime.ts#L156-L192","documentation":"loadPolicyState() read a persisted policy state file whose version number is not one this runtime knows how to interpret. The unsupported version is embedded in the message; the state stays unread rather than being misparsed by an incompatible schema.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/services/policy-runtime.ts:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Migrate the policy state to a supported version","Use a CLI version compatible with the stored policy state version"],"exampleFix":"Migrate the policy state to a supported version, or use a CLI version that understands the stored state version.","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}