{"record":{"id":"694a2d2134c40e4c","repo":"Fission-AI/OpenSpec","slug":"archive-target-exists","errorCode":"archive_target_exists","errorMessage":"Archive '${path.basename(dest)}' already exists.","messagePattern":"Archive '(.+?)' already exists\\.","errorType":"exception","errorClass":"ArchiveBlockedError","httpStatus":null,"severity":"error","filePath":"src/core/archive.ts","lineNumber":491,"sourceCode":" */\nclass MoveDestinationRetainedError extends Error {}\nclass RetirementBackupsRetainedError extends Error {}\n\nasync function moveDirectory(\n  src: string,\n  dest: string,\n  options: {\n    verifyCopiedDestination?: (stagedSource: string) => Promise<void>;\n  } = {}\n): Promise<void> {\n  try {\n    await fs.rename(src, dest);\n  } catch (err: any) {\n    const code = err?.code;\n    // rename onto a non-empty directory: the destination was taken while the\n    // archive was running. Same condition the pre-flight check reports.\n    if (code === 'ENOTEMPTY' || code === 'EEXIST') {\n      throw new ArchiveBlockedError(\n        'archive_target_exists',\n        `Archive '${path.basename(dest)}' already exists.`\n      );\n    }\n    if (code === 'EPERM' || code === 'EXDEV') {\n      const stagedSource = path.join(path.dirname(src), `.openspec-move-${randomUUID()}`);\n      try {\n        await fs.rename(src, stagedSource);\n      } catch (stageError) {\n        throw new Error(\n          `Could not safely stage ${src} before the fallback archive copy ` +\n            `(${stageError instanceof Error ? stageError.message : String(stageError)}). ` +\n            'No fallback copy was attempted.'\n        );\n      }\n      let destIsOurs = false;\n      let stagedFingerprint: string;\n      try {","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/archive.ts#L473-L509","documentation":"Error \"Archive '${path.basename(dest)}' already exists.\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/core/archive.ts:491 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}