Fission-AI/OpenSpec · error · Error

Archive rollback would overwrite a concurrent change at

Error message

Archive rollback would overwrite a concurrent change at ${snapshot.target}. The displaced spec was retained at ${snapshot.displacedPath}.

What it means

Rollback safety guard: while restoring snapshots after a failed archive, a retirement target reappeared at its path; overwriting it would destroy a concurrent change, so rollback stops and the displaced spec is preserved at the sibling backup path named in the message.

Solutions

  1. Manually reconcile the retained displaced backup with the reappeared spec
  2. Re-run the archive once the concurrent writer has stopped
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/core/archive.ts:911 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Fission-AI/OpenSpec@6926ccb18a (2026-08-25). Data as JSON: /api/errors/69f7126f2afd48c6. Report an issue: GitHub.

Appendix: source

Thrown at src/core/archive.ts:911

            outcome,
            ...(outcome === 'write' ? { expectedContent: Buffer.from(rebuilt) } : {}),
          };
        }
        throw error;
      }
    })
  );
}

async function restoreSpecSnapshots(snapshots: SpecSnapshot[]): Promise<void> {
  const errors: Error[] = [];
  for (const snapshot of [...snapshots].reverse()) {
    try {
      if (snapshot.outcome === 'retire') {
        if (snapshot.displacedPath !== undefined) {
          try {
            await fs.lstat(snapshot.target);
            throw new Error(
              `Archive rollback would overwrite a concurrent change at ${snapshot.target}. ` +
                `The displaced spec was retained at ${snapshot.displacedPath}.`
            );
          } catch (error) {
            if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
          }
          await fs.rename(snapshot.displacedPath, snapshot.target);
          snapshot.displacedPath = undefined;
          continue;
        }
        try {
          const current = await fs.lstat(snapshot.target);
          const unchangedSymlink =
            snapshot.symlink !== undefined &&
            current.isSymbolicLink() &&
            (await fs.readlink(snapshot.target)) === snapshot.symlink;
          // Re-read to confirm the target still holds the snapshot content; a
          // mismatch means a concurrent edit, and rollback throws below rather

View on GitHub (pinned to 6926ccb18a)