mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-23 04:54:00 +01:00
fix: Recognize Git mount-boundary absence diagnostics in workspace checks (#21048)
> [!NOTE] > Opened by Prospector's automated issue-fix pipeline. A maintainer reviews and decides; nothing here merges on its own. > [!WARNING] > This change crosses a trust boundary. See Risks. ## Thinking Path - Issue #20525 reports a defect in paperclipai/paperclip. - Root cause, as the fixing agent read it: Both callers recognized only the ordinary Git absence diagnostic. Preserve the earlier exact boundary matcher and all existing exit, signal, environment, and filesystem checks. - This pull request: Recognize Git mount-boundary absence diagnostics in workspace checks ## What Changed - `server/src/services/git-mount-boundary-message.ts`: Retain the shared complete-diagnostic matcher, which rejects partial and appended output. - `server/src/services/managed-repository-checkout.ts`: Retain boundary recognition without changing ordinary-diagnostic behavior or fallback guards. - `server/src/services/heartbeat/workspaces.ts`: Retain boundary recognition and ancestor metadata inspection. - `server/src/__tests__/git-mount-boundary.test.ts`: Add root mount, CRLF, and embedded-line-break cases through both callers. Confirmed six failures with boundary recognition disabled; restored implementation passes this suite, both neighboring suites, and typecheck. ## Verification - Reproducing test(s), added in this PR: `server/src/__tests__/git-mount-boundary.test.ts` - They fail on the base commit and pass with the fix, each twice in a fresh sandbox. - The repository's compile command passes with the fix applied. - 10 existing test file(s) near the change passed. - The full test suite passes except for the 16 file(s) that already fail on the base commit. ## Risks - Written by an automated pipeline, not a person: review it as you would an outside contribution. - Risk tier of the touched paths: 2. - It crosses a trust boundary. Check each crossing against what the issue asked for, and against who asked: - validation (server/src/services/heartbeat/workspaces.ts:860): Broadens the accepted Git absence diagnostics to include the mount-boundary message when classifying a checkout failure as an expected non-repository result. - validation (server/src/services/managed-repository-checkout.ts:265): Allows the mount-boundary diagnostic to bypass a previously thrown Git error when plainTaskDirectory and the existing exit, signal, and environment conditions hold. ## Model Used - opus (Anthropic Claude, via Claude Code), writing and checking the change in an isolated sandbox. - opus (Anthropic Claude, via Claude Code), reviewing it independently. ## Linked Issues Fixes #20525 #20525 also mentions, without asking this fix for it: - Non-Git directories in close readiness. (The report explicitly identifies merged #19553 as handling 'a different caller'; this patch does not modify close readiness.) - Initial managed-clone readiness. (The report says '#2977 concerns initial managed-clone readiness, rather than this diagnostic matcher.') - CI jobs 131047332629 and 131040975860 fail; fix the change only if it causes the failures. (This earlier-round conditional comment supplies no demonstrated matcher defect. .github/workflows/pr-trusted.yml:1801-1804 asserts aggregate shard status, while server/src/services/tool-access/catalog/health.ts:222 reports MCP health failures; neither changed here. Historical job causation cannot be) A search of paperclipai/paperclip's open and closed pull requests found no other pull request that names #20525. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with 'Fixes: #' / 'Closes #' / 'Refs #' OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub '#NNN' / 'github.com/paperclipai/paperclip' URLs) - [ ] My branch name describes the change (e.g. 'docs/...', 'fix/...') and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge <!-- prospector:issue-fix v1 issue=20525 base=156453fe7c67 report=513d758246cb2ac5 --> Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
80f7989f4b
commit
8b7b2a0701
4 files changed
+91
-2
No files matched your search
@@ -0,0 +1,5 @@
|
||||
export function isGitMountBoundaryMessage(stderr: unknown): boolean {
|
||||
if (typeof stderr !== "string") return false;
|
||||
const match = /^fatal: not a git repository \(or any parent up to mount point [^\r\n]+\)\r?\nStopping at filesystem boundary \(GIT_DISCOVERY_ACROSS_FILESYSTEM not set\)\.\r?\n?$/.exec(stderr);
|
||||
return match?.[0] === stderr;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { retainCurrentWorkspaceSource } from "../workspace-source-lock.js";
|
||||
import { isGitMountBoundaryMessage } from "../git-mount-boundary-message.js";
|
||||
import { localWorkspaceSourcePaths } from "../execution-workspace-source-roots.js";
|
||||
import { effectiveProjectWorkspacePolicy } from "../project-workspace-provider.js";
|
||||
import { canonicalRepositoryRoot } from "../execution-workspace-source-roots.js";
|
||||
@@ -856,7 +857,8 @@ async function probeGitWorktreeBase(cwd: string) {
|
||||
// corruption and I/O failures must remain reportable in Sentry.
|
||||
const notRepository = failure.code === 128 && failure.signal == null &&
|
||||
typeof failure.stderr === "string" &&
|
||||
/^fatal: not a git repository \(or any of the parent directories\): \.git\r?\n?$/.test(failure.stderr) &&
|
||||
(/^fatal: not a git repository \(or any of the parent directories\): \.git\r?\n?$/.test(failure.stderr) ||
|
||||
isGitMountBoundaryMessage(failure.stderr)) &&
|
||||
!process.env.GIT_DIR && !process.env.GIT_WORK_TREE && !process.env.GIT_COMMON_DIR &&
|
||||
await hasNoGitMetadataInWorkspaceAncestors(cwd);
|
||||
return { isCheckout: false, notRepository };
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { retainCurrentWorkspaceSource } from "./workspace-source-lock.js";
|
||||
import { isGitMountBoundaryMessage } from "./git-mount-boundary-message.js";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { execFile as execFileCallback } from "node:child_process";
|
||||
@@ -261,7 +262,8 @@ export async function ensureManagedRepositoriesIgnored(cwd: string, options: { p
|
||||
} catch (error) {
|
||||
const failure = error as { code?: unknown; signal?: unknown; stderr?: unknown };
|
||||
if (options.plainTaskDirectory && failure.code === 128 && failure.signal == null &&
|
||||
failure.stderr === "fatal: not a git repository (or any of the parent directories): .git\n" &&
|
||||
(failure.stderr === "fatal: not a git repository (or any of the parent directories): .git\n" ||
|
||||
isGitMountBoundaryMessage(failure.stderr)) &&
|
||||
!process.env.GIT_DIR && !process.env.GIT_WORK_TREE && !process.env.GIT_COMMON_DIR) return;
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user