paperclipai/paperclip · error

Refusing terminal workspace cleanup because the git status…

Error message

Refusing terminal workspace cleanup because the git status could not be verified

What it means

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.

Solutions

  1. Verify git is available and the worktree is readable so status can be checked, then retry cleanup.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/services/execution-workspaces.ts:1455 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-08-18). Data as JSON: /api/errors/85b5053c0d4b2bc7. Report an issue: GitHub.

Appendix: source

Thrown at server/src/services/execution-workspaces.ts:1461

            pullRequestStateUnknown = true;
          }
        }
        if (mergedPullRequest) break;
      }
    }

    return {
      deliveryState: deriveExecutionWorkspaceDeliveryState({
        sourceIssueTerminal,
        mergedPullRequest,
        pullRequestStateUnknown,
        isMergedIntoBase: git?.isMergedIntoBase ?? null,
      }),
      sourceIssueTerminal,
      subtreeTerminal,
      cooldownAnchor,
      workspaceDirty: Boolean(git?.hasDirtyTrackedFiles || git?.hasUntrackedFiles),
      workspaceHeadSha,
    };
  }

  async function assertTerminalCleanupGitStateUnchanged(
    workspace: ExecutionWorkspaceRow,
    expectedHeadSha: string | null,
  ) {
    if (workspace.providerType !== "git_worktree") return;
    const workspacePath = readNullableString(workspace.providerRef) ?? readNullableString(workspace.cwd);
    if (!workspacePath || !expectedHeadSha) {
      throw new Error("Refusing terminal workspace cleanup because the expected git HEAD is unknown");
    }

    const [current, currentHeadSha, currentBranchName] = await Promise.all([
      inspectGitCloseReadiness(toExecutionWorkspace(workspace)),
      readGitStdout(["rev-parse", "HEAD"], workspacePath).catch(() => null),
      readGitStdout(["symbolic-ref", "--quiet", "--short", "HEAD"], workspacePath).catch(() => null),
    ]);

View on GitHub (pinned to 3f1d897a7c)