{"record":{"id":"ce375379b856fb4a","repo":"affaan-m/ECC","slug":"refusing-to-trust-managed-install-state-at-plan","errorCode":null,"errorMessage":"Refusing to trust managed install-state at ${plan.installStatePath}: target identity does not match the current Kimi install plan.","messagePattern":"Refusing to trust managed install-state at (.+?): target identity does not match the current Kimi install plan\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"scripts/lib/multi-harness-setup.js","lineNumber":155,"sourceCode":"    currentFingerprint.exists !== expectedFingerprint.exists\n    || currentFingerprint.sha256 !== expectedFingerprint.sha256\n  ) {\n    throw new Error(\n      `Refusing to overwrite an unowned or changed install-state at ${plan.installStatePath}. `\n      + 'Re-run the guided preview and review the existing state before retrying.'\n    );\n  }\n}\n\nfunction assertPriorInstallStateMatchesPlan(state, plan) {\n  const target = state.target || {};\n  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","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/multi-harness-setup.js#L137-L173","documentation":"assertPriorInstallStateMatchesPlan compares the target identity (id, target, kind) recorded inside an existing managed install-state file against the current Kimi install plan's adapter identity. A mismatch means the state file was written by a different target/adapter, so trusting its destination list could delete or overwrite unrelated files. The installer refuses to trust it.","triggerScenarios":"Running a guided Kimi install whose plan (adapter id/target/kind) differs from the identity recorded in an existing install-state file at plan.installStatePath — e.g. changing install kind or target while an old state file remains.","commonSituations":"Upgrading or reconfiguring the installer so adapter id/kind changed; pointing the installer at a different target while the old state file persists at the same path; hand-copied state files between machines.","solutions":["Remove or archive the old install-state file if you are confident it belongs to a different, abandoned install","Restore the original plan/target that matches the recorded identity and uninstall through it first","Re-run the guided preview after cleaning up so a fresh, matching state file is created"],"exampleFix":"// before: state written for kind 'user', plan now kind 'project'\napplySetup(newPlan) // throws identity mismatch\n// after\nfs.rmSync(oldInstallStatePath) // old install uninstalled/cleaned\nconst plan = previewSetup(newRequest)\napplySetup(plan)","handlingStrategy":"try-catch","validationCode":"const state = readInstallState(plan.installStatePath)\nif (state && (state.target.id !== plan.adapter.id || state.target.kind !== plan.adapter.kind)) {\n  throw new Error('Existing install-state belongs to a different target; clean up first')\n}","typeGuard":"const stateMatchesPlan = (state, plan) =>\n  state?.target?.id === plan.adapter?.id &&\n  state?.target?.target === plan.adapter?.target &&\n  state?.target?.kind === plan.adapter?.kind","tryCatchPattern":"try {\n  applySetup(plan)\n} catch (err) {\n  if (err.message.includes('target identity does not match')) {\n    // uninstall via the original target or remove the stale state file after review\n    cleanupStaleInstall(plan.installStatePath)\n    const fresh = previewSetup(plan.request)\n    applySetup(fresh.plan)\n  } else throw err\n}","preventionTips":["Uninstall through the original installer configuration before changing adapter id/target/kind","Keep one install-state path per target configuration","Diff the recorded state identity against your plan before upgrading installers"],"tags":["install-state","safety","identity-mismatch"],"backgroundTag":"checksum-mismatch","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}