Skip to content

fix: avoid full-history downloads for missing Git commits - #196618

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-lazy-fetch-commit-closure-after-unshallow-20260919
Nov 10, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-lazy-fetch-commit-closure-after-unshallow-20260919

Conversation

@steipete

@steipete steipete commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated full-history downloads when repository tools or managed repair acquire missing Git commits in full-history partial clones. Related: #194577.

User Impact

Missing commit acquisition reuses resident history before comparisons or checkout read trees. Local-only readiness probes preserve their existing failure/delegation contracts. Recovery from corrupt ancestry remains supported. No configuration, cache, schema, or migration is added.

Why This Change Was Made

Git's native promisor lazy fetch does not negotiate common history, so requesting a missing commit can download its complete reachable commit/tree closure. Comparison tools now share negotiated acquisition through the existing Git revision owner. Installer and evidence helpers reach their explicit fetches; local-only probes stay offline.

Managed repair uses a physically present commit from its existing inventory, including inside temporary metadata without refs. It checks only the requested missing IDs afterward and retains one unnegotiated fallback when incomplete ancestry prevents repair. Cancellation, timeout, uncertain cleanup, and authority failures remain terminal.

The scripts/pr checkout and hosted-CI owners already received this fix in #194577 and remain unchanged. CI's ensure-base-commit deliberately uses depth/deepen recovery, which would be inappropriate for shared full-history worktrees. Existing frozen-tooling inventories already include the shared revision module; no parallel helper or inventory was introduced.

Evidence

Native regressions fail before the fixes and pass afterward. All 22 repair tests, 255 installer/evidence tests, 202 acquisition-consumer tests, and 14 selected local-probe tests passed (counts overlap). The existing PR checkout regression also passes. Independent review identified the missing-ancestor case; its native regression now verifies the retained fallback. No simulator run is claimed for the one-line iOS Git change.

Five interleaved pairs exercise actual project refresh/repair on an explicitly unshallowed blobless fixture with 80,000 commits and 560,000 trees:

Metric Before After
Received objects 640,008 8
Pack bytes 34,737,708 465
Median / p95 owner wall 4,629 / 4,951 ms 457 / 461 ms
Median native CPU 4,490 ms 50 ms
Median native peak RSS 234.7 MB 10.6 MB
Median exact V8 allocation 39.8 MB 35.8 MB
Git commands 17 18

Five A/A pairs show 0.019% wall drift. JS thread CPU median changes 53.84→54.60 ms; observed p95 changes 54.89→65.57 ms. The extra command verifies only requested IDs to preserve corruption recovery. Native CPU includes the local server; RSS is not cumulative native allocation.

The committed raw-restore workload separately proves 640,009 objects / 34,737,773 bytes → 9 objects / 530 bytes when a negotiated commit fetch precedes restore. Packet traces show the subsequent restore wants only a blob. An isolated single-pair check on actual OpenClaw history confirms 1,014,940 objects / 291,582,168 bytes → 28 objects / 205,372 bytes. These local macOS fixtures establish the mechanism and owner costs, not WAN, database, btrfs, or whole-Gateway latency.

Production growth is 50 lines: one shared acquisition owner replaces the old private resolver, remaining entry points use it, and bounded verification preserves corrupt-ancestry repair. The 148 ratcheted regression lines plus 7 installer-fixture lines prove native negotiation and local-only contracts; the shared scalar remains unchanged. Benchmarks extend existing workloads.

Final combined independent Codex review is clean through P2. Changed-check formatting, typechecks, script/core lint, and other guards pass; the final check retains inherited export findings and two extension test max-lines failures. Both line-limit errors reproduce on exact parent d553516036b6a44707c51f86a7c3922e2dd52b3c: Crabbox 1062 lines and Tlon 1024 lines. Threshold-crossing commits are dbcbb79c5c96e (#188802, 937→1010; #188981 later raises it to 1062) and 5b46d3b7dde8 (#177536, 795→1028; #189510 later reduces it to 1024). Before/after introducing-commit source replay passes/fails the unchanged 1000-line rule respectively. These remain main regressions for follow-up, not passing checks. The unused-export failure reproduces identically on exact parent d553516036b6a44707c51f86a7c3922e2dd52b3c (34 production / 13 full-tree findings). These are main checker regressions; causal groups include #192552, #196207, #196252, #191326, #139911, #190205, #132716, #129184, #190544, #191513, #196472, and a7436c8b4a93b. Five sidebar exports remain live through computed consumers and need Knip projection repair, not blind deletion. No changed owner is among the findings.

Exact-head CI run 42803057639 completed with one failing test: sessions.create fences clone Git effects when its identity is allowed at the authorization assertion in server.sessions.create.clone-identity.e2e.test.ts:176. The same case fails on exact main parent d553516036b6a44707c51f86a7c3922e2dd52b3c using its own built runtime (1 failed / 5 skipped; 58.39 seconds). #196206 (97e91a16d636c) introduced default managed-worktree preparation after authenticated clone without carrying the selected project credential into the default-base remote probe. Those owners and the test are identical at CI's main parent c6fc5bd784b5b; the missing-object repair path is not reached by this healthy clone. This is a newly identified main regression requiring follow-up. The CI aggregate retains its failure; all other primary CI jobs passed or were intentionally skipped.

Separate CodeQL/security and precise-scan workflows hit GitHub installation API limits during setup/upload. Only their failed jobs were retried after diagnosing those logs; both attempt 2 runs passed. ClawSweeper reviewed final head 300cb03df826772fe122db56e1492a41d2261030 with zero findings and zero open items (review). Native pinned admin admission landed this exact head as 0ebc9d5ccd9c7b240356ba276f613e348057c3b7 with the documented inherited-only test exception; failed CI remains recorded as failed (completion receipt).

Reuse resident history in partial-clone comparisons and managed ref-tip repair. Keep local availability probes offline and preserve bounded recovery for missing ancestors. Native regressions cover negotiated acquisition, offline contracts, and both repair transports.
@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.

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: L labels Nov 10, 2026
@steipete
steipete marked this pull request as ready for review November 10, 2026 10:54
@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-10T10:58:17.877214Z 300cb03 Draft marked ready
ℹ️ 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR negotiates missing Git commits before reading their trees while keeping local availability checks offline.

Example: Repair a missing commit in an unshallowed blobless clone containing 80,000 commits.

  • Before: The reported production-owner workload receives 640,008 objects totaling 34,737,708 pack bytes.
  • After: The same workload receives 8 objects totaling 465 pack bytes.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair with real production-boundary transport evidence and no identified patch defect; the exact-head CI gate remains red.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The public evidence exercises the actual project-refresh and repair owners with native Git over local file transport, reports five interleaved before/after pairs on an unshallowed blobless fixture, and records sharply reduced object transfer; native regressions separately cover both repair transports and missing-ancestor fallback.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Repository operations can download already-resident commit and tree history again, delaying work and expanding the shared object store.
Reason: The measured transfer reduction is substantial, the direction is maintainer-authored, and existing acquisition, offline, and recovery contracts remain intact.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses remaining history-download amplification on current main, and no actionable patch defect was found; CI still needs resolution.

Priority: P2
Reviewed head: 300cb03df826772fe122db56e1492a41d2261030

Before merge

None.

Findings

None.

Agent review details

How this fits together

Repository comparison scripts resolve revisions before inspecting trees, while managed worktree and project-refresh owners repair missing objects through their existing Git transports.

flowchart TD
  A[Comparison scripts] --> B[Git revision owner]
  B --> C[Local commit probe]
  C --> D[Negotiated origin fetch]
  E[Managed project refresh] --> F[Missing object repair]
  F --> D
  F --> G[Bounded corruption fallback]
  D --> H[Resident Git object store]
  G --> H
Loading

Technical review

Best possible solution:

Use the existing revision and repair owners for negotiated acquisition, preserving offline probes and bounded corrupt-ancestry recovery.

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

Current-main source exposes the unnegotiated acquisition paths, and the PR supplies native before/after production-owner measurements and regression results; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch addresses acquisition before tree reads, removes the old private resolver, and reuses existing repair inventory without adding a cache or competing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 41b677a0131f.

Provenance checked

  • Synthetic merge comparison base keeps the original intent (8b29ff5: Use the synthetic merge's first parent to avoid including unrelated base-branch movement in PR checks.)
  • Shared repository-script implementation keeps the original intent (c70aee2: Keep implementation contracts at their owning scripts and eliminate handwritten declaration sidecars.)
  • Missing-tip repair transport changes intended behavior with a stated reason (290266a: Recover physically missing ref tips without losing local branches or worktree HEADs, while preserving bounded execution and caller authority.)
  • Commit-pinned installer acquisition keeps the original intent (8fefe23: Resolve locally available full commit IDs or explicitly fetch the exact commit before detached checkout.)
  • Release target readiness keeps the original intent (18dd70c: Acquire release targets through named client-pushed refs because bare-SHA acquisition can fail for GitHub-created commits.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 290266a adds src/infra/git-repository-repair.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 290266a77959; files: src/infra/git-repository-repair.ts)
  • Mason Huang: Raw commit 8b29ff5 adds scripts/lib/merge-head-diff-base.mjs:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8b29ff5f1691; files: scripts/lib/merge-head-diff-base.mjs)
  • Vincent Koc: Raw commit 63f265c adds scripts/lib/merge-head-diff-base.mjs:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 63f265c0ddb9; files: scripts/lib/merge-head-diff-base.mjs)

PR surface

Source +11, Tests +155, Docs +9, Other +158. Total +333 across 25 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 29 18 +11
Tests 6 176 21 +155
Docs 2 10 1 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 16 216 58 +158
Total 25 431 98 +333

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 net +50 lines; tests and test fixtures net +155 lines. Production growth consolidates acquisition and retains corruption recovery; native regressions cover distinct repair transports, offline contracts, installer acquisition, and comparison behavior.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Avoids substantial redundant Git transfer, CPU, and memory costs in partial-clone comparison and recovery workflows.
  • 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.

Rank-up moves

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

  • Have the CI owner classify the session-cloning test failure and restore the required checks after the GitHub rate-limit failures.

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 10, 2026, 6:12 AM ET / 11:12 UTC.

@steipete
steipete merged commit 0ebc9d5 into main Nov 10, 2026
301 of 311 checks passed
@steipete
steipete deleted the steipete/perf-micro-lazy-fetch-commit-closure-after-unshallow-20260919 branch November 10, 2026 11:20
@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
…6618)

Reuse resident history in partial-clone comparisons and managed ref-tip repair. Keep local availability probes offline and preserve bounded recovery for missing ancestors. Native regressions cover negotiated acquisition, offline contracts, and both repair transports.
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
Backport of 0ebc9d5.

Release adaptation: only resident-tip negotiation and availability retry in repair owner plus its worktree/project regression. Exclude CI, release, installer and performance changes.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 47ed5b471cf71f9b37c60c12a67c058b586d120c)
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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