Repository navigation
fix: stop recursive Git shims from exhausting agent sandboxes - #202815
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1d6ad27ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. What this changesPrepare stable native Git bindings for host and container launchers so forwarding scripts cannot recursively re-enter the agent Git wrapper. Example: A forwarding Git script restores PATH=/state/tmp/agent-git:/home/agent/bin:/usr/bin:/bin before invoking git.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a concrete runtime recursion path that remains on main; both prior findings are resolved, and no new actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway startup prepares the host Git launcher; Docker and Podman preparation bind container-native Git, and agent commands pass through the wrapper to native Git. flowchart TD
A[Gateway startup] --> B[Shared launcher installer]
B --> C[Host Git launcher]
B --> D[Read-only container launcher]
E[Container preparation] --> F[Prepared temporary script]
D --> F
C --> G[Native Git]
F --> G
Technical reviewBest possible solution: Retain the shared installer and stable native binding, including safe missing-target recovery and executable container delivery that sources noexec storage. Do we have a high-confidence way to reproduce the issue? Current-main lookup permits a forwarding script to restore the wrapper directory and re-enter it; supplied capped reproductions establish process exhaustion, while this read-only review independently verified the source path. Is this the best way to solve the issue? The change fixes executable selection at preparation, shares generation across host and container callers, and preserves upgrade-stable symlinks without adding a nesting sentinel or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c30d95148e24. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +76, Tests +140, Docs +13, Other +145. Total +374 across 13 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)Reviewed November 20, 2026, 9:47 PM ET / November 21, 2026, 02:47 UTC (Revision 3). |
|
Addressed the one open item in the latest review on head
The environment-budget decision is eliminated: both proposed environment names and the sentinel were removed. The installer writes the binding directly into each host/container launcher; the budget stays at the unchanged base value 462. Native Git remains the target through normal calls. Under a verified 64-process cgroup, the base forwarding chain exhausts the cap; the new forwarding chain succeeds, safe missing-path recovery skips the wrapper alias, and missing native Git exits 127 with an actionable error. The PR body contains the refreshed behavior and btrfs timing/CPU/allocation evidence. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Addressed the one open item from revision 2 on final head
Actual backend proof now passes for ordinary and private execution with a read-only workspace/root, default noexec Codex also caught private preparation utilities depending on the workload PATH. All installer utilities now use @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#202815) * fix: stop recursive Git shims from exhausting agent sandboxes * fix: bind agent Git launchers to stable native paths * fix: keep prepared sandbox Git executable on noexec mounts
* fix: stop recursive Git shims from exhausting agent sandboxes * fix: bind agent Git launchers to stable native paths * fix: keep prepared sandbox Git executable on noexec mounts (cherry picked from commit b8de11e) Release adaptation: Resolve sandbox import context and retain the baseline PATH-oriented transport fixture. Test native Git binding and non-executable prepared scripts without importing the separate read-only-workspace temporary-directory policy.: Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 99549941ae356962358c61d7c88c6a40f73a8041) (cherry picked from commit 13911bfc241d8d30c25bf1ed1e9e36160cc68b22)
* fix: keep agent temporary files in owned scratch * fix: preserve sandbox temp access and queued isolation custody (cherry picked from commit f91bc99) Release adaptation: keep the staged #202815 Git shim implementation and independently assert both Git shim execution and writable owned temp in its merged Docker/Podman fixture. Use the beta.3 isolated custody configuration (896f33d52174), not ambient sandbox inventory. Companions: #193677 scratch expiry owner is present (99ba844); #202815 is present-equivalent (7d33d1a). #202122 is independent Git/scratch clone reclamation, #202428 is CLI history ownership, #202644 is host file-write authority, and #202874 is workspace cleanup scheduling; none prerequisite. Other later same-path commits concern separate template, sandbox, prompt, sharing, or run-lifecycle policy; see the lane companion audit. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a4070bc5b669308210b62a0b80b92c16af768b34)
What Problem This Solves
The agent Git wrapper removes only its own directory from PATH before rediscovering
git. A user forwarding shim can restore that directory and repeatedly re-enter the wrapper, exhausting a sandbox's process and memory limits. #202798 fixed recursive test fixtures; the product owner still needed repair.User Impact
Host, Docker, Podman, and private persistent Docker launchers now bake in a validated stable absolute native Git path during preparation. Realpath validates candidates; script shims and their symlink aliases are skipped without execution. Calls use the prepared path. Package-manager symlink upgrades keep working, and a missing path triggers one safe resolution attempt before an actionable error.
Normal nested Git calls keep working. Credentials, egress, identity, history/projection policy, and maintenance flags stay unchanged. No new environment variables, configuration, cache, or schema; the environment-name budget remains 462. The canonical-path binding and nesting sentinel from the first revision have been removed.
Why This Change Was Made
One installer owns host and container launcher generation. It lives in a small sibling module to keep the runtime script within the existing source-size cap; the extracted command and launcher bytes are identical. Containers prepare from the read-only mounted source; private children install after configured setup. The executable PATH launcher stays on that resource mount and sources its prepared script from
/tmpin the same shell, preserving defaultnoexecmounts and read-only workspaces. Preparation utilities usecommand -p, so a restricted workload PATH cannot hidemkdirormktemp. Installation preserves the existing 0755 directory mode. The fetch-failure regression now fails native Git's upload-pack transport rather than replacing Git through PATH.Production grows by 76 lines for preparation, missing-target recovery, and container startup integration; the per-call PATH loop and environment handoffs are removed. The separate history-lock work in #199982 is untouched.
Evidence
The current bounded regression fails on exact unchanged parent
f247afced37d159af27f7f019b950b6c696c125dbecause the forwarding shim is executed. It passes with this repair. Unbounded-cycle reproduction ran only under hard caps (macOS RLIMIT_NPROC and Linuxpids.max=64): base exhausts the cap; the repaired forwarding chain completes. Recovery skips a wrapper alias and returns 127 when no native Git exists. The upgrade regression replaces the native target and then removes the prepared path; both cases work without re-preparation, including shell-special characters in the path.Actual Docker backend proof covers ordinary and private persistent execution with
workspaceAccess="ro", a read-only root, defaultnoexec/tmp, and configured setup that exits 0. The native-Git control attempts transport for a missing-object probe; the mounted wrapper stays offline and creates no packs. The prior revision reproduces exit 126 on direct execution fromnoexecstorage. A private absolute command with a restricted PATH reproduced exit 127 before the utility-path repair and now exits 0. Task containers were removed. Final five-file focused tests pass: 85 on Node, 83 on Bun, with two existing broker skips covered by Node. Full-diff Codex autoreview after the renderer extraction is scoped-clean at P0–P2.pnpm check:changedis green on the final source, including unchanged environment budget 462/462 and the source-size gate. Exact-head CI and ClawSweeper zero-item review remain required.Host generated-launcher measurements use a synthetic btrfs repository with 62,000 files / 1.116 GB, native Git 2.39.5, five alternating A/B pairs of 1,000 calls and five A/A pairs. No production data. Allocation runs use separate five-pair 100-call batches; instrumented timings are discarded.
git --versiongit rev-parse --verify HEADAllocation calls fall 488.29→431.29 and 647.29→598.29, with exact A/A matches. Counts cover malloc/calloc/realloc requests and amortized batch-shell overhead, excluding mmap/live RSS; the allocation-only interposer substitutes fork for vfork to isolate counters.
A/A wall medians: version 0.80959/0.83234 ms; probe 0.98134/1.03084 ms. CPU controls: 0.81020/0.83330 and 0.98481/1.03589 ms. The small probe gain is within A/A variation; this establishes no added median overhead, not a production speedup claim. This owner never reads session or agent databases. Reproduction scripts are in
scripts/perf/agent-git-wrapper*.The host launcher is byte-identical after the container delivery repair. A separate final-container run uses the same btrfs fixture and paired method. Paired median wall/CPU deltas are −0.00484/−0.00083 ms for version calls and −0.19845/−0.19190 ms for revision probes. Separate version medians are 0.89468→0.90874 ms wall and 0.89723→0.91167 ms CPU; that positive difference is smaller than the A/A variation (wall 0.95091/0.87510 ms). Both summaries are reported: the noisy version sample supports no demonstrated regression, not a precise speedup. Probe medians are 1.38057→1.18212 ms wall and 1.38454→1.19263 ms CPU. Container allocation requests fall 323,454→306,740 B and 343,727→316,746 B; calls fall 488.29→437.29 and 647.29→575.29, with exact A/A allocation matches.
ClawSweeper correctly found the noexec delivery regression, and Codex found preparation utilities depending on the workload PATH; both are repaired with actual Docker proof. The earlier budget-growth failure is eliminated. No inherited-failure exception is requested.