{"record":{"id":"a3b31f0310923c0d","repo":"paperclipai/paperclip","slug":"worktree-seed-lock-lockpath-is-stale-or-malform","errorCode":null,"errorMessage":"Worktree seed lock ${lockPath} is stale or malformed. Verify that no seed is running, then remove the stale lock and retry.","messagePattern":"Worktree seed lock (.+?) is stale or malformed\\. Verify that no seed is running, then remove the stale lock and retry\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2093,"sourceCode":"      if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n    }\n\n    const [rawOwner, lockStat] = await Promise.all([\n      fsPromises.readFile(lockPath, \"utf8\").catch(() => null),\n      fsPromises.stat(lockPath).catch(() => null),\n    ]);\n    const currentOwner = rawOwner ? parseWorktreeSeedLockOwner(rawOwner) : null;\n    const malformedLockIsStale = Boolean(\n      lockStat && Date.now() - lockStat.mtimeMs >= WORKTREE_SEED_LOCK_MALFORMED_STALE_MS,\n    );\n    if (currentOwner && !processIsAlive(currentOwner.pid)) {\n      throw new Error(\n        `Worktree seed lock ${lockPath} belongs to exited process ${currentOwner.pid}. `\n        + \"Verify that no seed is running, then remove the stale lock and retry.\",\n      );\n    }\n    if (!currentOwner && malformedLockIsStale) {\n      throw new Error(\n        `Worktree seed lock ${lockPath} is stale or malformed. `\n        + \"Verify that no seed is running, then remove the stale lock and retry.\",\n      );\n    }\n    await new Promise((resolve) => setTimeout(resolve, WORKTREE_SEED_LOCK_POLL_MS));\n  }\n}\n\nfunction startWorktreeSeedAttempt(configPath: string, now = new Date()): WorktreeSeedManifest {\n  const markers = resolveWorktreeSeedMarkerPaths(configPath);\n  const current = readWorktreeSeedManifest(configPath);\n  if (!current) throw new Error(`Worktree seed manifest does not exist at ${markers.manifest}.`);\n  const at = now.toISOString();\n  const next: WorktreeSeedManifest = {\n    ...current,\n    state: \"running\",\n    phase: \"pending\",\n    attemptId: randomUUID(),","sourceCodeStart":2075,"sourceCodeEnd":2111,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L2075-L2111","documentation":"Stale-lock diagnostic in the worktree seed lock: the lock file is unreadable or malformed and has exceeded the staleness age threshold, so it is treated as abandoned rather than honored; remove it after verifying no seed is running.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:1540 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify no seed is running, remove the stale or malformed lock file, and retry the seed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}