Skip to content

fix(worktrees): avoid E2BIG during isolated Git hydration - #197593

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-hydration-config-env-e2big-20260919
Nov 12, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-hydration-config-env-e2big-20260919

Conversation

@steipete

@steipete steipete commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes spawn E2BIG when managed-worktree hydration or native scripts/pr review-init prepares 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.directory scope, 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 E2BIG on exact parent b1a5641eabd8620a243da2b0c11a0a9758045b18: direct hydrateCommitObjects and a cold native scripts/pr review-init with 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.

Metric Baseline A1 A/A control A2 Fixed
Successful hydration 0/5 0/5 5/5
Fetch environment bytes 1,827,626 1,827,626 10,954
Config environment entries 20,022 20,022 7
Owner allocation median, MB 146.49 145.31 74.83
Owner CPU median, ms 539.5 482.1 481.2
Owner wall median / p95, ms 781.8 / 1120.4 757.3 / 876.3 1001.0 / 1481.1

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.ts now accepts --transport-base-file and --allow-failure for this comparison.

No changed module is imported by the Control UI. Follow-up: a separately observed agent-exec supervisor E2BIG is 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 18946d9dfd7aa9df8f640ccfc6b220d8e6d4c828 has 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 c7962d6a108ca4f3f46a76e254bf29a487e5145f establishes 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 PATH gh, 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 returned merged: 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. Unmodified scripts/pr review-init 197593 subsequently exited 0 on the real shared clone, using the retained official-main workflow 6f6bf91812cac3521c68b78425c721a91b144415. It created the native PR checkout at main 0950f7a77e9886e5a387fae1bdce22c1a180d538, 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.

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.
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling size: S labels Nov 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T06:43:46.466595Z 18946d9 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The reported launch environment reaches 1,827,626 bytes and hydration fails with E2BIG.
  • After: The reported environment falls to 10,954 bytes and all five candidate hydrations complete.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation is sound on inspection, with useful real-Git owner evidence but incomplete shipped-entry-point qualification; no persisted data migration is needed.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its native-Git owner benchmark reports successful hydration, while full shared-clone native setup remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Preparing a managed checkout can fail with spawn E2BIG when a shared clone accumulates thousands of Git config entries.
Reason: The maintainer-authored direction repairs an observed failure through the existing shared owner; the added flags are confined to benchmark tooling.

Regression provenance

Possible 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
Reviewed head: 18946d9dfd7aa9df8f640ccfc6b220d8e6d4c828

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A completed cold scripts/pr review-init against the reported large shared clone remains pending in the PR body.
Agent review details

How this fits together

Managed-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]
Loading

Technical review

Best 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

  • Isolated transport configuration changes intended behavior with a stated reason (43dae0b: Avoid unrelated-ref completeness scans while preserving effective transport settings and source-ref publication.)
  • Authenticated source transport keeps the original intent (ff392db: Carry the selected GitHub credential and current identity checks through default-base preparation.)
  • Native provisioning fixture keeps the original intent (387f698: Exercise managed source acquisition while preserving native Git policy, locks, and recovery ownership.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +24, Tests +44, Docs +5, Other +21. Total +94 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 29 5 +24
Tests 2 45 1 +44
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 2 24 3 +21
Total 6 103 9 +94

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Large shared clones can fail managed-worktree hydration and native PR provisioning, with impact limited to unusually large Git configuration inventories.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Large shared clones can fail managed-worktree hydration and native PR provisioning, with impact limited to unusually large Git configuration inventories.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record successful cold native PR provisioning on the large shared-clone scenario, with sensitive values redacted.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 12, 2026, 1:55 AM ET / 06:55 UTC.

@steipete
steipete merged commit 6f6bf91 into main Nov 12, 2026
155 of 162 checks passed
@steipete
steipete deleted the steipete/perf-micro-hydration-config-env-e2big-20260919 branch November 12, 2026 07:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant