{"record":{"id":"85b5053c0d4b2bc7","repo":"paperclipai/paperclip","slug":"refusing-terminal-workspace-cleanup-because-the-gi","errorCode":null,"errorMessage":"Refusing terminal workspace cleanup because the git status could not be verified","messagePattern":"Refusing terminal workspace cleanup because the git status could not be verified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/execution-workspaces.ts","lineNumber":1461,"sourceCode":"            pullRequestStateUnknown = true;\n          }\n        }\n        if (mergedPullRequest) break;\n      }\n    }\n\n    return {\n      deliveryState: deriveExecutionWorkspaceDeliveryState({\n        sourceIssueTerminal,\n        mergedPullRequest,\n        pullRequestStateUnknown,\n        isMergedIntoBase: git?.isMergedIntoBase ?? null,\n      }),\n      sourceIssueTerminal,\n      subtreeTerminal,\n      cooldownAnchor,\n      workspaceDirty: Boolean(git?.hasDirtyTrackedFiles || git?.hasUntrackedFiles),\n      workspaceHeadSha,\n    };\n  }\n\n  async function assertTerminalCleanupGitStateUnchanged(\n    workspace: ExecutionWorkspaceRow,\n    expectedHeadSha: string | null,\n  ) {\n    if (workspace.providerType !== \"git_worktree\") return;\n    const workspacePath = readNullableString(workspace.providerRef) ?? readNullableString(workspace.cwd);\n    if (!workspacePath || !expectedHeadSha) {\n      throw new Error(\"Refusing terminal workspace cleanup because the expected git HEAD is unknown\");\n    }\n\n    const [current, currentHeadSha, currentBranchName] = await Promise.all([\n      inspectGitCloseReadiness(toExecutionWorkspace(workspace)),\n      readGitStdout([\"rev-parse\", \"HEAD\"], workspacePath).catch(() => null),\n      readGitStdout([\"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], workspacePath).catch(() => null),\n    ]);","sourceCodeStart":1443,"sourceCodeEnd":1479,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/execution-workspaces.ts#L1443-L1479","documentation":"Fail-closed safety check in assertTerminalCleanupGitStateUnchanged: re-inspecting the worktree (inspectGitCloseReadiness) failed (statusInspectionSucceeded false), so the current git status could not be verified against the state recorded at delivery verification. Terminal cleanup of an unverifiable worktree is refused.","triggerScenarios":"Thrown at server/src/services/execution-workspaces.ts:1455 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify git is available and the worktree is readable so status can be checked, then retry cleanup."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}