Repository navigation
fix(worktrees): avoid E2BIG during isolated Git hydration - #197593
Conversation
Snapshot selected transport policy in a private temporary config file instead of expanding repository configuration into environment variables. Preserve conditional includes, protected safe.directory settings, isolated refs, and source-writer admission. Fixes hydration and native PR setup failing with E2BIG on large shared clones.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR moves isolated Git transport configuration from environment variables into a private temporary config file to prevent E2BIG. Example: Hydrate a missing blob in a shared clone containing 20,013 Git config entries.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete large-clone failure still present on main, and no introduced correctness defect was found; the required CI gate remains unresolved. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherManaged-worktree preparation and native PR provisioning use the shared isolated Git transport to fetch objects into the source object store while keeping temporary refs separate. flowchart TD
A[Worktree preparation or PR provisioning] --> B[Shared hydration and base fetch]
B --> C[Resolve source transport configuration]
C --> D[Private temporary Git config]
D --> E[Git fetch with fixed environment overrides]
E --> F[Shared source object store]
E --> G[Existing temporary transport cleanup]
Technical reviewBest possible solution: Keep configuration serialization in the existing isolated transport owner while preserving source configuration, writer admission, and settlement cleanup. Do we have a high-confidence way to reproduce the issue? Current main expands repository configuration into process environment entries, matching the reported exact-parent E2BIG failures; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch fixes the expansion at its shared producer, reuses existing quoting and cleanup owners, and retains two regressions for distinct execution boundaries without introducing another transport implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a14127f6814e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +24, Tests +44, Docs +5, Other +21. Total +94 across 6 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:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed November 12, 2026, 1:55 AM ET / 06:55 UTC. |
…97593) Prevent large shared clones from exporting every Git config entry into isolated hydration process environments. Preserve selected transport policy in a private temporary config file with fixed environment overrides and existing cleanup ownership. Regression provenance: openclaw#195505 introduced the environment transport; openclaw#197251 routed content hydration through it. Real 20k-config Gateway and native review-init regressions fail E2BIG before the fix and pass on the final head. Synthetic 62k-path proof reduces fetch environment bytes from 1,827,626 to 10,954; all five candidate hydrations succeed. Codex autoreview and final-head ClawSweeper: no actionable findings. Native CI: 17 passed, two platform skips; large-config case 20.022s. All applicable type/lint/docs/security checks pass. The sole CI red is inherited test-line debt 25, reproduced on exact main parent dc5e7b7 and introduced by openclaw#197543 (97741b2); this PR's 44 test lines have 44 allocation. Explicitly authorized maintainer bootstrap fallback: SHA-pinned synchronous REST squash via protected gh, because the main-anchored native bootstrap is broken by this bug. No native review/prepare success receipt is claimed. Real shared-clone review-init verification follows official-main publication.
What Problem This Solves
Fixes
spawn E2BIGwhen managed-worktree hydration or nativescripts/pr review-initprepares a checkout from a shared clone with thousands of Git configuration entries. The transport introduced in #195505 exported almost every effective config entry as environment variables; #197251 brought content hydration onto that path.User Impact
Large shared clones can hydrate missing contents and create PR worktrees without exceeding the operating system's process-launch limit. No new configuration, cache, or schema is introduced.
Why This Change Was Made
The isolated transport now selects the requested remote and effective transport policy, resolves conditional includes against the original checkout, and writes a private temporary Git config file. Only fixed overrides remain in the environment. Branch settings and unrelated remotes are omitted. System config and the original command-config transport remain disabled during isolated execution; the existing lifecycle owns cleanup, including uncertain process settlement.
This retains URL rewrites, credentials, protocol/HTTP settings, partial-clone metadata and protected
safe.directoryscope, while preserving source refs, shallow boundaries and source-writer admission. Runtime growth is 24 lines for file serialization; benchmark tooling grows 19 lines. The 44-line scoped test allocation funds two real regressions at distinct execution boundaries.Evidence
Both regressions fail with
E2BIGon exact parentb1a5641eabd8620a243da2b0c11a0a9758045b18: directhydrateCommitObjectsand a cold nativescripts/pr review-initwith a missing blob and 20,000 config entries. Native failure releases its operation lock. All 99 focused hydration, base-refresh and Git-repair tests pass after the fix (359.77s Vitest wall including cold compilation; test execution 63%). The retained real partial-clone native fixture executes hydration and git worktree add with the fix, but this overloaded Mac exceeds the unchanged 120s Vitest deadline (282.7s callback): this is not claimed as a local suite pass. Exact-head CI subsequently qualified that test at the normal deadline: the 20,000-entry native regression passed in 20.022s, both protected safe.directory cases passed in 11.075s/13.131s, and the suite finished 17 passed / two platform skips (200.65s total) in job 131020608353. The direct hydration regression passed in 244ms in the same job. A broader native-suite attempt was interrupted and joined cleanly; it is not counted as passing proof.Acceptance was recorded before comparison: all candidate runs must hydrate the requested blob, no launch environment may scale with the repository config inventory, and baseline/control failures must remain labeled failures. Synthetic fixture: 62,000 paths, 1,100,004,000 logical content bytes, 20,013 config entries, one distinct missing blob; five fresh-clone A1/A2/B triplets. No operator data or session database is used by this Git owner.
Argv remains about 232 bytes: the cause is environment expansion. Environment bytes fall 99.4%, measured allocation about 49%. Baseline wall/CPU measures failure before hydration, not equivalent successful work; no completion-latency speedup is claimed. A/A median drift is -3.1% wall, -10.6% CPU, -0.8% allocation on a busy shared Mac. APFS/native Git/file transport; this does not measure remote-network or btrfs latency. Size-only census instrumentation was excluded from the final timing/allocation runs. The existing
scripts/perf/worktree-size-measure.tsnow accepts--transport-base-fileand--allow-failurefor this comparison.No changed module is imported by the Control UI. Follow-up: a separately observed agent-exec supervisor
E2BIGis a different launch owner; its logs do not distinguish argv size from environment size, and this PR makes no claim to fix it.Landing and real-clone proof
Codex autoreview of the complete runtime/test diff against the pinned parent is scoped-clean through P2, with no actionable findings. The native regression retains a real partial clone so ordinary Git acquisition cannot satisfy the missing blob before the tested hydration boundary; no timeout was raised. The required pnpm check:changed completed all checks: every typecheck, lint, guard, import-cycle and dead-export scan passed; its one recorded failure was native-test formatting, corrected by the commit hook and verified with the exact six-file format command afterward. The final head
18946d9dfd7aa9df8f640ccfc6b220d8e6d4c828has a completed hosted Codex review with no findings and a completed ClawSweeper review with zero open items (review). Native default-deadline qualification is green on that exact head; real shared-clone setup now passes on the landed official-main workflow.Exact-head CI run 43169770421 fails only the test-lines baseline ratchet and its downstream gate; typechecks, lint, documentation and security checks pass. Build artifacts run 43169769933 passes. CI initially classifies the ratchet as new, but independent reproduction on its exact main parent
c7962d6a108ca4f3f46a76e254bf29a487e5145festablishes inherited debt: 6,670,879 test lines against ceiling 6,670,854, over by 25, exit 1. The unchanged checker read that exact tree through a private Git index. Introducing main regression: #197543 (3b13df5767c256222e8cd4ed8fea17c6b836b2aa) added 57 unallocated test lines, consuming 30 slack and creating 27 debt; #197484 removed two lines. This PR adds 44 test lines and 44 allocation, preserving the inherited 25-line debt. The new main regression is recorded for its owner; no allocation was inflated to mask it.The user explicitly authorized a maintainer fallback because the main-anchored native wrapper cannot consume this unlanded repair and fails before creating its PR worktree. Completed fallback at 2026-11-12T07:05:09Z, squash commit
6f6bf91812cac3521c68b78425c721a91b144415: used the documented prior-CI synchronous REST squash request through protected PATHgh, with an inspected JSON input file naming the full reviewed head,merge_method: "squash", and commit title/body. Independently verified live writer/admin capability, applicable rules, current PR head/mergeability, completed review and security gates, and the exact inherited failure before dispatch. The single request returnedmerged: true; an independent PR read confirmed the exact merged commit. The current main advance was verified as forward ancestry with a conflict-free merge tree before dispatch. This is an explicitly authorized bootstrap exception, not a claim that native review/prepare receipts exist or CI is green. Unmodifiedscripts/pr review-init 197593subsequently exited 0 on the real shared clone, using the retained official-main workflow6f6bf91812cac3521c68b78425c721a91b144415. It created the native PR checkout at main0950f7a77e9886e5a387fae1bdce22c1a180d538, fetched the exact PR head, wrote all review metadata, and released the operation lock. The clone still had 16,113 effective config entries / 1,298,027 raw bytes, against macOS ARG_MAX 1,048,576. No config inventory was removed or reduced.The real-clone acceptance run first encountered two separate disk-admission failures (895 MiB available / about 4.0 GiB required, then 4.1 GiB / about 5.7 GiB as other managed writes were reserved). Both failures released their operation locks. Disposable cache cleanup raised free space to 6.6 GiB; the unchanged command then passed. The wrapper also resolved an outdated tooling dependency through its normal frozen-install owner. No allocation limit, timeout, or safety reserve was changed.
Current-main native setup is repaired. Existing PR workflows remain pinned by design: #197561 retains source
4c04a9e952646a506b0d0cda4c197746ebfcca43, which predates this fix. Its owner still needs supported workflow recovery or its separately authorized landing fallback; this change does not silently rewrite retained workflow authority.