{"record":{"id":"40ffd609a3392aba","repo":"affaan-m/ECC","slug":"refusing-to-trust-managed-install-state-at-plan-40ffd6","errorCode":null,"errorMessage":"Refusing to trust managed install-state at ${plan.installStatePath}: recorded install-state path does not match the current install-state path.","messagePattern":"Refusing to trust managed install-state at (.+?): recorded install-state path does not match the current install-state path\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/multi-harness-setup.js","lineNumber":118,"sourceCode":"  const adapter = plan.adapter || {};\n  if (\n    target.id !== adapter.id\n    || target.target !== adapter.target\n    || target.kind !== adapter.kind\n  ) {\n    throw new Error(\n      `Refusing to trust managed install-state at ${plan.installStatePath}: `\n      + 'target identity does not match the current Kimi install plan.'\n    );\n  }\n  if (!pathsMatch(target.root, plan.targetRoot)) {\n    throw new Error(\n      `Refusing to trust managed install-state at ${plan.installStatePath}: `\n      + 'recorded root does not match the current install root.'\n    );\n  }\n  if (!pathsMatch(target.installStatePath, plan.installStatePath)) {\n    throw new Error(\n      `Refusing to trust managed install-state at ${plan.installStatePath}: `\n      + 'recorded install-state path does not match the current install-state path.'\n    );\n  }\n}\n\nfunction readOwnedDestinations(plan, dependencies) {\n  if (!plan.installStatePath) {\n    return { destinations: new Set(), stateFingerprint: { exists: false, sha256: null } };\n  }\n  try {\n    assertSafeInstallOperation(plan, { destinationPath: plan.installStatePath });\n  } catch (error) {\n    throw new Error(`Refusing to trust managed install-state path: ${error.message}`);\n  }\n  if (!fs.existsSync(plan.installStatePath)) {\n    return { destinations: new Set(), stateFingerprint: { exists: false, sha256: null } };\n  }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/multi-harness-setup.js#L100-L136","documentation":"Thrown by assertPriorInstallStateMatchesPlan when the install-state's recorded target.installStatePath (canonicalized) does not equal the current plan.installStatePath. This is a self-referential integrity check: the state file must point to itself at the exact path ECC is reading it from. A mismatch implies the state was moved/renamed or two state files are cross-referencing, so its ownership claims are not trustworthy.","triggerScenarios":"Fires when pathsMatch(target.installStatePath, plan.installStatePath) is false. Occurs if the install-state file was relocated (renamed, moved into a different .claude subdir), if plan.installStatePath is computed from a different home/project layout than when the state was written, or if a state file was copied from another project without updating its self-reference.","commonSituations":"Renaming the project's .claude directory or moving the state file; a custom homeDir/projectRoot passed to createManagedPlan that yields a different installStatePath than the original run; copying another project's install-state as a template; ECC version change that altered the installStatePath layout.","solutions":["Remove the install-state at plan.installStatePath and re-run the preview so the self-reference is written for the current path.","If you pass custom homeDir/projectRoot to createManagedPlan, keep them identical between preview and apply.","Never copy install-state files between projects; let ECC generate them.","Confirm plan.installStatePath matches the file you actually want to trust."],"exampleFix":"// before: state copied from another project, self-reference points elsewhere\n// state.target.installStatePath = '/other/project/.claude/install-state.json'\n// plan.installStatePath        = '/this/project/.claude/install-state.json'\nawait applyMultiHarnessPlan(plan); // throws [283]\n\n// after: regenerate state in place\nfs.rmSync(plan.installStatePath, { force: true });\nconst plan2 = await createMultiHarnessPlan(req);\nawait applyMultiHarnessPlan(plan2);","handlingStrategy":"validation","validationCode":"const fs = require('fs'); const path = require('path');\nfunction assertStateSelfReferenceMatches(statePath) {\n  if (!fs.existsSync(statePath)) return;\n  const state = JSON.parse(fs.readFileSync(statePath, 'utf8'));\n  const recorded = path.resolve(state.target && state.target.installStatePath || '');\n  if (recorded !== path.resolve(statePath)) {\n    throw new Error(`Install-state self-reference ${recorded} != ${statePath}; regenerate the state in place.`);\n  }\n}\nassertStateSelfReferenceMatches(plan.installStatePath);","typeGuard":"null","tryCatchPattern":"try {\n  await applyMultiHarnessPlan(plan);\n} catch (err) {\n  if (/recorded install-state path does not match/.test(err.message)) {\n    fs.rmSync(plan.installStatePath, { force: true });\n    const fresh = await createMultiHarnessPlan(plan.request);\n    await applyMultiHarnessPlan(fresh);\n  } else throw err;\n}","preventionTips":["Never copy install-state files between projects or directories.","Keep homeDir/projectRoot arguments identical between preview and apply.","Do not rename the .claude directory or move the state file after install.","If you change the installStatePath layout, discard old state files."],"tags":["install-state","self-reference","ownership","path-canonicalization","kimi"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}