{"record":{"id":"a407012f3abd721f","repo":"affaan-m/ECC","slug":"refusing-to-overwrite-an-unowned-or-changed-instal","errorCode":null,"errorMessage":"Refusing to overwrite an unowned or changed install-state at ${plan.installStatePath}. Re-run the guided preview and review the existing state before retrying.","messagePattern":"Refusing to overwrite an unowned or changed install-state at (.+?)\\. Re-run the guided preview and review the existing state before retrying\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"scripts/lib/multi-harness-setup.js","lineNumber":140,"sourceCode":"}\n\nfunction operationIdentityMatches(stateOperation, plannedOperation) {\n  return [\n    'kind',\n    'moduleId',\n    'sourceRelativePath',\n    'strategy',\n    'scaffoldOnly',\n  ].every(field => stateOperation[field] === plannedOperation[field]);\n}\n\nfunction assertInstallStateUnchanged(plan, expectedFingerprint) {\n  const currentFingerprint = fingerprintFile(plan.installStatePath);\n  if (\n    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    );","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/multi-harness-setup.js#L122-L158","documentation":"assertInstallStateUnchanged fingerprints the install-state file and compares existence plus sha256 to the fingerprint recorded at preview time. A mismatch means the state file appeared, disappeared, or was modified between preview and apply, so the installer refuses to overwrite content it may not own. The user is told to re-run the guided preview and review the state.","triggerScenarios":"Calling the apply/confirm step with a stale expectedFingerprint while the install-state file at plan.installStatePath has been created, deleted, or edited since the preview was generated.","commonSituations":"Manually editing or deleting the install-state file between preview and apply; another install run modifying it; restoring the file from a backup with different bytes.","solutions":["Re-run the guided preview to generate a fresh plan and fingerprint, review the shown state, then apply","If you did not expect the change, inspect the install-state file to see who/what modified it before retrying","Delete the foreign install-state only if you are certain nothing else owns it, then re-run preview and apply"],"exampleFix":"// before: apply with stale preview fingerprint\napplySetup(stalePlan, staleFingerprint) // throws\n// after\nconst plan = previewSetup(request)\nconst fp = fingerprintOf(plan) // fresh from preview\napplySetup(plan, fp) // matches current state","handlingStrategy":"try-catch","validationCode":"const current = fingerprintFile(plan.installStatePath)\nif (current.exists !== expected.exists || current.sha256 !== expected.sha256) {\n  // state changed since preview — re-run preview before applying\n}","typeGuard":null,"tryCatchPattern":"try {\n  applySetup(plan, expectedFingerprint)\n} catch (err) {\n  if (err.message.includes('unowned or changed install-state')) {\n    const freshPlan = previewSetup(plan.request) // regenerate and review\n    applySetup(freshPlan.plan, freshPlan.fingerprint)\n  } else throw err\n}","preventionTips":["Always apply immediately after preview in the same workflow; never cache plans across sessions","Never hand-edit install-state files","Serialize installs with a lock so concurrent runs cannot change state between preview and apply"],"tags":["install-state","safety","fingerprint","concurrency"],"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"}