Skip to content

fix: avoid full-history downloads from Git revision expressions - #196784

Merged
steipete merged 4 commits into
mainfrom
steipete/fix-agent-git-rev-parse-2374
Nov 10, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/fix-agent-git-rev-parse-2374

Conversation

@steipete

@steipete steipete commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Follow-up to #196743: ordinary git rev-parse <missing-commit>:path and <missing-commit>^{tree} bypass revision preparation, allowing Git's noop promisor fetch to retransmit existing commit/tree history.

User Impact

Explicit content expressions use the existing negotiated missing-object fetch before native Git runs. ID-only expansion, optional defaults, metadata queries, offline probes, and implicit path arguments preserve native behavior. No configuration or migration is required.

Why This Change Was Made

The command dispatcher omitted ordinary rev-parse. The wrapper now lets offline native Git qualify its positional expressions in one batch. Valid expressions need one extra Git process, including a path whose blob is deliberately absent. On a miss, expressions are handled in order: qualify, acquire only necessary traversal roots through the existing owner, then qualify again before considering later arguments. This preserves Git's implicit transition from revisions to paths, instead of reproducing that parser in the wrapper.

Python subprocesses already inherit the installed shim through the exported agent PATH. The shared base checkout already resolves the same common Git directory as linked worktrees. This PR proves those paths without adding installation or detection mechanisms.

Evidence

Each command-shape case uses a fresh explicitly unshallowed blobless clone with a registered linked worktree and an origin-only commit. Python cases run through the actual createExecTool shell wrapper, a heredoc, and subprocess.run(["git", ...]), with cwd at the base clone root.

Requested check Before Final result
(a) Python → bare Git from base root show and cat-file -p <sha>:path already negotiate Pass through the installed PATH shim
(b) rev-parse <sha>:path 16 objects, no haves At most four objects, haves, correct blob OID
(b) rev-parse <sha>^{tree} 16 objects, no haves At most four objects, haves, correct tree OID
(b) cat-file -p <sha>:path Already bounded Pass with correct content
(c) Shared base root Already detected All Python cases pass at the root; linked-worktree controls retained

The final owner suite passes 2/2. Native regressions also preserve unused defaults, ID-only two-dot endpoints and exclusions, mixed ID/content endpoints, three-dot traversal, implicit paths, invalid suffixes, empty arguments, and paths containing spaces. Before repair, the unused-default, two-dot, and implicit-path regressions each failed with an unnecessary rejected fetch. A missing-root/invalid-path case proves the wrapper stops before fetching a later unavailable object. Marker collision is covered.

Independent Codex review of the final staged candidate is scoped-clean through P2. Runtime delta is +63 net lines; regression delta +64, with an exact scoped allocation and shared fixture setup. Growth delegates argument acceptance to Git while preserving ordered acquisition; regular commands reuse their existing batched root checks and negotiated fetch. No persistent cache, new configuration, dependency, or UI import.

A separate network-disabled Linux fixture has 20,001 commits, 140,064 trees, and 62,000 metadata paths representing 1.116 GB of logical content. It is explicitly unshallowed, blobless, and shared with a linked worktree. No production data was used. Git 2.47.3, five counterbalanced 250-call batches per arm plus A2 controls:

Present expression Baseline → final median wall Baseline → final CPU Peak child RSS
HEAD^{tree} 1.519 → 3.115 ms 1.481 → 3.033 ms Unchanged, 5,226,496 B
HEAD:path with promised blob absent 1.412 → 4.161 ms 1.345 → 3.683 ms Unchanged, 5,263,360 B

Both cases run one probe plus the original Git command, with zero fetches, unchanged packs, correct output, and the promised blob still absent. Added median cost is 1.596/2.749 ms; relative cost is +105%/+195%. A/A median drift is 0.290/0.088 ms, and tails are host-noisy; this is not a production btrfs latency claim. Minor faults rise about 195→392 and 190→388 per call. A separate Git-only allocator-interposition run measures cumulative requested allocation: tree 379→770 requests and 899,273→1,799,642 bytes; promised blob 313→719 requests and 218,515→1,169,478 bytes. Five counterbalanced 20-call batches plus A2 match exactly. The nine-entrypoint qualification probe passes (nine calls/549 bytes). This excludes shell allocations, mmap, and hidden libc paths; requested bytes are not live heap or RSS. The original million-object transfer proof from #196743 was reused, not repeated.

pnpm check:changed reports 33 production and 10 full-tree unused exports outside changed files. The canonical checker reproduces identical symbol sets on exact parent 47b0ce478c8141b52ec4631b4ddbe3d8b018ff21 (zero script findings). All other checks passed, including the final repetition. Five additional production/two full-tree entries originate in #196380 / 37a3b162a0c58aaceb1634aaef726d0e178a529c; unchanged findings and source attribution are documented in #196743. These are reported main regressions, not passing checks or noise. Earlier heads' CI was green.

Scope limit: optional rev-parse --default values and invocations containing newline arguments retain native handling and can still lazy-fetch. This follow-up protects the requested explicit revision forms and does not claim universal Git argument coverage.

Final-head CI run 42885010852, attempt 1, completed with one root failure: test-line ceiling in job 130071724878 (and aggregate 130077673436). CI tested merge 8b55bcb7f4425eeac0fdac47059e86ece31a27a4 of main a693086999a4180f99a5b41555dcb70685b0312a and this head. The merged tree has 6,635,240 test lines / 6,635,112 ceiling: 128 over. Exact main reproduces 6,635,176 / 6,635,048: the same 128 over. This PR's +64 lines and +64 scoped allocation leave the inherited debt unchanged. All other selected CI jobs pass.

The new main regression originates in #196346 / b91520c16b620adf2222b6f9aa245d61b3e0d139: +138 counted test lines without a grant consumed 10 lines of available slack, leaving 128 debt. Earlier #196680 debt had already been cleared; it is not the cause of this failure. Landing uses the authorized inherited-failure exception with exact-head evidence, while retaining the failed CI result.

ClawSweeper reviewed final head fa0b3d4d91aff6676ff577ea81d3a2edc95bfb7a with zero open items and no actionable findings. All three prior items were addressed by number in the re-review response.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 10, 2026
@steipete
steipete marked this pull request as ready for review November 10, 2026 18:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 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-10T19:28:10.629444Z fa0b3d4 New commits
ℹ️ 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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please review final candidate 38d47d2dbf017229aff376ce0659339a69936cf9, following up #196743. Native regressions cover Python bare-Git subprocesses from the shared base root, both missing-commit rev-parse content expressions, and metadata/offline passthrough. The full owner suite and independent Codex review passed; exact-parent attribution of unrelated local unused-export findings is being completed.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Prepare missing objects for Git rev-parse content expressions while preserving native revision, option, and path handling.

Example: Python invokes git rev-parse with an origin-only commit and file.txt in a shared blobless clone.

  • Before: The reported fixture downloads 16 objects without offering local history.
  • After: The wrapper negotiates with local history, downloads at most four objects, and returns the correct blob ID.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused repair with native behavior evidence and resolved prior findings; exact-head CI is not yet settled.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Supplied native shell/Git measurements and exec-tool Python subprocess results exercise the changed wrapper in unshallowed shared blobless clones, report negotiated missing-expression recovery with correct IDs, and retain fetch-free present-object and native argument controls.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agent Git content expressions can download already-present history instead of negotiating from local commits.
Reason: The maintainer-authored follow-up closes a demonstrated omission and explicitly records the common-path process cost and remaining scope limits.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current Git-wrapper omission, and the earlier findings are resolved; no new actionable defect was found, while exact-head CI remains unsettled.

Priority: P2
Reviewed head: fa0b3d4d91aff6676ff577ea81d3a2edc95bfb7a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway installs a PATH-based Git wrapper used by agent shell commands and inherited subprocesses; it prepares missing revision roots before forwarding the original arguments to native Git.

flowchart TD
  A[Agent exec command] --> B[Shell or Python subprocess]
  B --> C[Git PATH wrapper]
  C --> D[Offline native Git qualification]
  D --> E[Existing negotiated fetch owner]
  D --> F[Original native Git command]
  E --> F
Loading

Technical review

Best possible solution:

Extend the existing wrapper with native Git qualification and ordered root acquisition, retaining the documented optional-default and newline limits.

Do we have a high-confidence way to reproduce the issue?

Current main omits ordinary rev-parse preparation, and the supplied native Git comparison reports unnegotiated history transfer for missing content expressions; no target code was executed during this review.

Is this the best way to solve the issue?

The patch uses the existing fetch owner and delegates revision-versus-path acceptance to Git, addressing the earlier regressions without adding persistent state or configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0c5c4754c33d.

Provenance checked

  • Offline probes keeps the original intent (b6d8eb2: Prevent absent-object existence and ancestry probes from downloading history while preserving normal content hydration.)
  • Negotiated revision preparation keeps the original intent (83d8323: Prepare missing roots before shared-clone content reads because Git's lazy promisor fetch does not negotiate existing history.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit b6d8eb2 adds src/infra/agent-git-shim.ts:30 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b6d8eb287e08; files: src/infra/agent-git-shim.ts)

PR surface

Source +63, Tests +64, Docs 0, Other +2. Total +129 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 85 22 +63
Tests 1 90 26 +64
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 178 49 +129

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.

Review metrics

Metric Value Why it matters
Production versus regression growth Production +63 net lines; tests +64 net lines Growth keeps Git responsible for argument qualification and covers distinct fetch, option, range, and path boundaries in the existing suite.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Avoids unnecessary history transfers during agent Git reads in shared blobless clones, with limited workflow scope.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-10T18:09:04.096Z sha 38d47d2 :: needs changes before merge. :: [P2] Preserve unused --default operands during revision preparation
  • reviewed 2026-11-10T18:34:07.919Z sha cbb95a8 :: needs changes before merge. :: [P2] Preserve fetch-free expansion of ID-only revision ranges
  • reviewed 2026-11-10T18:51:02.665Z sha 2d75554 :: needs changes before merge. :: [P2] Stop preparing revisions after Git enters its path phase
  • reviewed 2026-11-10T19:31:28.966Z sha fa0b3d4 :: needs maintainer review before merge. :: none

Reviewed November 10, 2026, 2:37 PM ET / 19:37 UTC (Revision 5).

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed item 1 on cbb95a8b2bab4103c983120a0c0786138bfd7dda:

  1. Preserve unused --default operands: the existing option-operand parser now consumes --default and its value without treating that optional value as an explicit revision. The HEAD regression failed on the reviewed head with exit 2 and origin rejecting the zero OID; it now returns the native HEAD ID, with no packet trace. The Python case also proves an explicit missing content expression still negotiates when an unused default precedes it.

The repaired owner suite passes 2/2, including all original blob/tree, PATH, base-root, linked-worktree, and offline controls. Independent Codex review of the staged candidate is scoped-clean through P2. Runtime remains +5 net lines; tests are +44 with matching scoped allocation. The first head's CI was green; new-head CI and repeated local checks are running.

Native Git retains selection of optional defaults. An active missing --default remains an unprotected pre-existing lazy-fetch path; the body records this limit, and this follow-up claims the requested explicit revision forms only.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbb95a8b2b

ℹ️ 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".

Comment thread src/infra/agent-git-shim.ts Resolved
@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed both review rounds on 2d75554aa548fe49c6b72b57d9ff0e0cc84d43c8:

  1. Current item 1 — ID-only range expansion: endpoint classification now considers each endpoint independently. The unavailable zero-ID two-dot case failed on cbb95a8 with exit 2. No-fetch controls now pass for two-dot IDs, mixed ID/present-content endpoints, and exclusions; packet absence is asserted. Positive cases prove three-dot traversal and a missing content endpoint still negotiate, while its unavailable ID-only counterpart is never fetched. Exact output is checked. This also addresses the Codex inline range finding.
  2. Earlier item 1 — unused default: operand consumption and the native HEAD/no-fetch regression remain green. The Python missing-expression case with an unused default remains covered.

Final owner suite: 2/2 passed. Independent Codex review of the final staged candidate: scoped-clean through P2. Production remains +5 net lines. The body records the unchanged active-missing-default limitation and exact-parent attribution of unrelated dead exports. Prior-head green CI is not treated as final-head evidence.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 10, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Nov 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed all three review rounds on fa0b3d4d91aff6676ff577ea81d3a2edc95bfb7a:

  1. Current item 1 — implicit path phase: native batch qualification accepts valid expressions in one offline Git call. Ordered fallback lets Git determine when a rejected expression starts the path phase; it stops before later roots. The reported case failed on 2d75554 with exit 2. No-fetch controls now cover implicit files, invalid suffixes, empty arguments, and a marker-like earlier revision. Missing-root then invalid-path coverage proves acquisition does not continue past that boundary. The promised-blob benchmark proves valid paths are not mistaken for missing revisions.
  2. Earlier item 1 — ID-only endpoints: shared root extraction retains endpoint-specific content/traversal handling. ID-only controls and mixed/three-dot positive cases remain green. The fixed Codex inline thread is resolved.
  3. First item 1 — unused defaults: option-operand handling, the HEAD/no-fetch regression, and Python explicit content with an unused default remain green.

Final owner suite: 2/2 passed. Independent Codex review of the final staged candidate: scoped-clean through P2. Linux synthetic present-tree/promised-blob reads add 1.596/2.749 ms median, exactly one extra Git process, no fetches, and unchanged peak RSS. The body includes CPU, A/A controls, fixture limits, necessary +63 production lines, and the documented native-handling limits. Prior-head CI is not used as final-head evidence.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@steipete
steipete merged commit 9c0b1b4 into main Nov 10, 2026
157 of 161 checks passed
@steipete
steipete deleted the steipete/fix-agent-git-rev-parse-2374 branch November 10, 2026 19:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…claw#196784)

* fix: negotiate missing Git revision expressions before reads

* fix: preserve unused Git revision defaults

* fix: preserve ID-only Git revision endpoints

* fix: let Git identify revision path boundaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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