fix(windows): set GIT_CEILING_DIRECTORIES on sandbox git cwd check (#111) #186

Open
cfw34683 wants to merge 1 commit from cfw34683/Beanstalk:fix/windows-git-cwd-ceiling into main
Contributor

Follow-up to #180 (#111).

Summary

In WindowsSelfTest.cs, the git -C . rev-parse --git-dir working-directory check added in #180 runs inside the empty sandbox work directory without GIT_CEILING_DIRECTORIES. Because work is not a git repository, Git walks up parent folders looking for .git, leaves data_dir (for example E:\BeanstalkData), attempts to stat the drive root E:\ (which AppContainer intentionally cannot read), and fails with:

FAIL  git  git cannot read working directory: fatal: failed to stat '  E:/': Permission denied

Changes:

  • agent/Core/WindowsSelfTest.cs: add WinSelfTest.GitCeilingFor(string cwd) (pure string helper) and set GIT_CEILING_DIRECTORIES on cwdCheck so Git stops at the sandbox work folder while still verifying it can read the sandboxed working directory.
  • agent/tests/agent_core/WindowsChecks.cs: add unit tests for WinSelfTest.GitCeilingFor().

Verification

  • Windows 11 Pro (build 26300, RTX 3070 Ti, data_dir = E:\BeanstalkData):
    • Before (nightly-311-ccdfbdcf):
      FAIL  git  git cannot read working directory: fatal: failed to stat '  E:/': Permission denied
      recommended mode: none (appcontainer: failed or missing: git; ...)
      
    • After (built from this branch, tested live on desktop via "Test the sandbox"):
      --- mode appcontainer ---
        PASS  list_profile     your user folder cannot be listed: UnauthorizedAccessException: Access to the path '<home>' is denied.
        PASS  nul              NUL opens for reading and writing
        PASS  git              git version 2.56.0.windows.4 (git for the sandbox: the agent's MinGit 2.56.0.windows.4)
        => every check passed
      recommended mode: appcontainer (appcontainer: every check passed)
      
  • dotnet build agent/App --nologo and dotnet build agent/tests/agent_core -c Release --nologo: 0 warnings, 0 errors.
Follow-up to #180 (#111). ## Summary In `WindowsSelfTest.cs`, the `git -C . rev-parse --git-dir` working-directory check added in #180 runs inside the empty sandbox `work` directory without `GIT_CEILING_DIRECTORIES`. Because `work` is not a git repository, Git walks up parent folders looking for `.git`, leaves `data_dir` (for example `E:\BeanstalkData`), attempts to `stat` the drive root `E:\` (which AppContainer intentionally cannot read), and fails with: ``` FAIL git git cannot read working directory: fatal: failed to stat ' E:/': Permission denied ``` Changes: - `agent/Core/WindowsSelfTest.cs`: add `WinSelfTest.GitCeilingFor(string cwd)` (pure string helper) and set `GIT_CEILING_DIRECTORIES` on `cwdCheck` so Git stops at the sandbox work folder while still verifying it can read the sandboxed working directory. - `agent/tests/agent_core/WindowsChecks.cs`: add unit tests for `WinSelfTest.GitCeilingFor()`. ## Verification - **Windows 11 Pro (build 26300, RTX 3070 Ti, `data_dir = E:\BeanstalkData`):** - Before (`nightly-311-ccdfbdcf`): ``` FAIL git git cannot read working directory: fatal: failed to stat ' E:/': Permission denied recommended mode: none (appcontainer: failed or missing: git; ...) ``` - After (built from this branch, tested live on desktop via "Test the sandbox"): ``` --- mode appcontainer --- PASS list_profile your user folder cannot be listed: UnauthorizedAccessException: Access to the path '<home>' is denied. PASS nul NUL opens for reading and writing PASS git git version 2.56.0.windows.4 (git for the sandbox: the agent's MinGit 2.56.0.windows.4) => every check passed recommended mode: appcontainer (appcontainer: every check passed) ``` - `dotnet build agent/App --nologo` and `dotnet build agent/tests/agent_core -c Release --nologo`: **0 warnings, 0 errors**.
fix(windows): set GIT_CEILING_DIRECTORIES on sandbox git cwd check (#111)
Some checks are pending
CI / Coordinator tests (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Agent build and checks (pull_request) Blocked by required conditions
CI / Coordinator image (pull_request) Blocked by required conditions
e6afd77e8e
In WindowsSelfTest.ProbeGit(), the cwd check added in #180 runs 'git -C . rev-parse --git-dir' inside the empty sandbox work directory. Without GIT_CEILING_DIRECTORIES, Git walks up parent directories looking for .git, leaves data_dir (e.g., E:\BeanstalkData), tries to stat E:\ (which AppContainer intentionally cannot read), and fails with:
  fatal: failed to stat '  E:/': Permission denied

- Add WinSelfTest.GitCeilingFor(cwd) and set GIT_CEILING_DIRECTORIES on cwdCheck so git stops at the sandbox work folder while still verifying it can read the sandboxed working directory.
- Add unit tests for GitCeilingFor() in WindowsChecks.cs.

Assisted-by: Antigravity
Co-Authored-By: Antigravity <[email protected]>
Some checks are pending
CI / Coordinator tests (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Agent build and checks (pull_request) Blocked by required conditions
CI / Coordinator image (pull_request) Blocked by required conditions
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/windows-git-cwd-ceiling:cfw34683-fix/windows-git-cwd-ceiling'
git switch 'cfw34683-fix/windows-git-cwd-ceiling'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!186
No description provided.