paperclipai/paperclip · error · Error

Worktree seed manifest target instance does not match the re

Error message

Worktree seed manifest target instance does not match the registered target instance.

What it means

Before seeding, ensureWorktreeSeeded resolves the registered target instance id from the target's paths (resolveWorktreeReseedTargetPaths) and compares it with the targetInstanceId stored in an existing seed manifest. A mismatch means the manifest on disk describes a different worktree instance than the one being seeded — stale markers copied from another worktree, or the worktree's identity changed underneath the markers. The manifest is diagnostic evidence only and never selects the source; identity mismatches abort.

Source

Thrown at cli/src/commands/worktree.ts:2314

    ?? nonEmpty(process.env.PAPERCLIP_COMPANY_ID)
    ?? undefined;
  if (!explicitSourceConfigPath && registeredBaseWorkspaceCwd && (!registeredProjectWorkspaceId || !expectedCompanyId)) {
    throw new Error(
      "Managed worktree seed registration is incomplete; project workspace and company bindings are required.",
    );
  }

  const targetRoot = path.dirname(path.dirname(configPath));
  const targetPaths = resolveWorktreeReseedTargetPaths({ configPath, rootPath: targetRoot });
  const registeredSeedSource = resolveRegisteredWorktreeSeedSource({
    registeredBaseWorkspaceCwd,
    explicitSourceConfigPath,
    targetConfigPath: configPath,
    expectedTargetInstanceId: targetPaths.instanceId,
  });

  if (initialManifest && initialManifest.targetInstanceId !== registeredSeedSource.targetInstanceId) {
    throw new Error("Worktree seed manifest target instance does not match the registered target instance.");
  }

  // Resolve all authority-bearing paths before creating the lock. The manifest is
  // agent-writable diagnostic evidence and never selects the source. A stale source
  // diagnostic is replaced under the lock from this server/operator registration.
  let canonicalSource = registeredSeedSource;
  mkdirSync(path.dirname(markers.lock), { recursive: true });
  const releaseLock = await acquireWorktreeSeedLock(markers.lock);
  try {
    // These checks deliberately happen under the cross-process lock. A second
    // service process waits for the first seed transaction, then observes the
    // verified manifest instead of cloning the same database concurrently.
    let manifest = readWorktreeSeedManifest(configPath);
    if (manifest?.state === "verified") {
      return { seeded: false, reason: "verified_manifest" };
    }
    if (!manifest && existsSync(markers.pending)) {
      const currentLegacyPending = readLegacyWorktreeSeedPendingMarker(markers.pending);

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Remove the stale manifest (and lock) markers for this worktree and re-run the seed so fresh markers are written
  2. Verify the worktree was not moved or copied with its markers; recreate the worktree properly if identity is ambiguous
  3. Re-register the worktree so registration and markers agree on the target instance
Defensive patterns

Strategy: validation

Validate before calling

const { instanceId } = resolveWorktreeReseedTargetPaths({ configPath, rootPath: targetRoot });
const manifest = readWorktreeSeedManifest(configPath);
if (manifest && manifest.targetInstanceId !== instanceId) {
  // stale markers from another worktree: clear them before seeding
  removeSeedMarkers(configPath);
}

Try / catch

Catch the mismatch, print both ids, remove the stale markers, and re-run the seed once.

Prevention

When it happens

Trigger: A pre-existing manifest whose targetInstanceId differs from the registered target — copying/moving a worktree dir (markers came along, instance id re-derived from new paths), a regenerated instance id, or markers restored from another worktree's backup.

Common situations: Copying a worktree directory to a new name/path; restoring marker files from a different worktree; instance id regeneration after re-registration.

Related errors


AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-21). Data as JSON: /api/errors/06b462b4ca7d9a3f. Report an issue: GitHub.