Skip to content

fix: stop repeated cold fork fetches from empty workspaces - #197229

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-empty-source-fork-fetch-loop-20260919
Nov 11, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-empty-source-fork-fetch-loop-20260919

Conversation

@steipete

@steipete steipete commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Large fork PR imports from an empty workspace can repeatedly download their entire commit/tree history, hit the command timeout, and leave temporary packs instead of making progress.

User Impact

An unbound conversation importing a PR now reuses an accessible registered project identified by the PR's base repository, including fork heads. An already-bound empty workspace without retained history gets project-session guidance before the cold fetch; existing files, published work and prepared imports remain intact. Unknown or inaccessible projects retain the existing import path.

Successful commit acquisitions retain a Git ref for later negotiation, and commit-fetch timeouts explain the project-workspace or standalone depth-limited-clone remedy. Epoch-zero roots no longer appear to be decades-stale project bases. Interrupted-pack cleanup remains with the existing lease-checked Linux maintenance owner; this change does not delete packs on timeout.

Why This Change Was Made

PR adoption always selected an empty source despite having inspected the authoritative base repository. Separately, by-SHA publication fetches suppressed FETCH_HEAD and retained no ref, leaving completed transfers unavailable to negotiation for subsequent missing commits. Reuse the project access/custody owners and the existing filtered transport; retain fetched refs in the source repository even when transport metadata is temporary.

This deliberately preserves existing workspace bindings instead of adding unowned foreign alternates after allocation. There is no schema change, configuration option, new cache, or new cleanup mechanism. Runtime production delta is +96 lines: the necessary growth supplies shared project selection, bounded cold-source guidance, retained refs and actionable diagnostics. This does not overlap #195404's separate initial-import file-count repair.

Evidence

Native owner fixture: 20,001 commits, 140,064 trees, 62,000 stable paths / 1.116 GB logical content, reused from prior synthetic proof. Five interleaved A/B trials and five A2 controls, Git 2.56.0 / Node 26.12.1, macOS and local file transport. No production data, session database, live service or deployment. This measures the actual fetch owner, not whole-session latency or production filesystem/network behavior.

Missing successor acquisition Before After
Received objects / pack bytes 160,067 / 8,667,962 1 / 181
Owner wall median / observed p95 1005.610 / 1019.274 ms 137.026 / 141.201 ms
Native CPU median 3160 ms 90 ms
JS CPU median 7.509 ms 7.717 ms
Sampled JS allocation median 976,776 B 992,064 B
Native peak RSS median 69,828,608 B 27,525,120 B

A/A wall drift is -0.24%; JS CPU +2.77% and sampled allocation +1.57% remain explicit costs. Two owner Git commands / one fetch in either arm. Every candidate advertises the prior fork SHA. The first cold acquisition remains 160,066 objects in every arm and is excluded from successor timing. Repeating an identical already-present SHA already takes the offline presence fast path; this proves progress for subsequent missing commits. Reproduce with scripts/perf/empty-source-fork-fixture.py and scripts/perf/publication-fetch-measure.ts --sequential-fork --allocation.

All 141 non-skipped focused tests have passing proof; one existing skip remains. Red-on-parent regressions cover project selection, retained refs, cold-fetch guidance, timeout guidance and synthetic-root warnings. The full seven-file run was followed by a 10-case authority rerun after adapting three transport observers to the source OID in a refspec. No assertions or authority checks were weakened. The expanded authenticated project-adoption case takes 5.4 seconds; acquisition suite is 23.6 seconds. Existing preparation/branch suites remain slower native Git and lifecycle proof. No changed production module is imported by the Control UI. The exact +208 test-line allocation covers the new regressions and coherent acquisition-suite extraction.

Final Codex autoreview is scoped-clean through P2 against parent eafa24743a53d8079c32be72fb3c8ae4222e78ca. pnpm check:changed completed with exit 2: two test-callback implicit-any errors, now fixed and verified by the exact gateway-methods TypeScript check, plus the inherited dead-export failure below. Core/scripts lint, formatting, production/script types and all remaining guards passed. Targeted test-file lint also passed. The full command is not represented as green. The canonical dead-export failure reproduces identically on that exact parent: 57 production / 32 full-tree / 0 script findings across 20 unchanged owner files. Newly identified main regressions are #196767 (23 Knowledge exports), #196991 (two Telegram widget exports), and #196388 (three OpenClaw ID exports); the remaining 29 have the earlier #196854 lane's causal attribution. These are reported main defects, not passing checks.

The first exact-head CI run (43028008473) found one additional stale fault injector in github-publication-history.test.ts: it expected a standalone SHA and therefore missed the new refspec. This was a PR-caused test failure, reproduced locally, then fixed without weakening the fault-injection assertion. All 15 history cases pass after correction. A matching base-refresh fetch counter was corrected too, and its native recovery case passes. Production code and measurement inputs are unchanged; Final-head CI run 43032652923 passed on b90fdbd.

The project handoff now has stronger in-process proof through the shipped performSessionGitHubPreparation handler. Real authenticated requester grants, project access, registry custody, native Git allocation, role mutation/invalidation, rollback and session binding demonstrate: an accessible canonical base uses project Git storage; a restricted requester receives no private project files/alternates/binding; revocation during visibility lookup prevents allocation; revocation after allocation prevents binding and rolls back; earlier conversation files remain readable only to their owner. All four adoption cases pass. This replaces the weaker internal-requester fixture. GitHub responses, container setup and PR-content import remain synthetic; this is not a live Gateway/model or Team run.

Landed as f5d0c194fcd1726fc5823adf031cedff480cb702 from exact head b90fdbd86a75ac2e4b0697993b37f3c06ab56bf2. Final CI passed (59 successful jobs, 27 skipped), and ClawSweeper revision 2 has zero open items and no findings/security concern.

@clawsweeper

clawsweeper Bot commented Nov 11, 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 gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Nov 11, 2026
@steipete
steipete marked this pull request as ready for review November 11, 2026 13:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T13:52:50.570674Z b90fdbd 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 head 49c389f, especially canonical PR-base project access/custody, retained Git negotiation refs, and the existing-empty-workspace recovery path. Focused regression proof and synthetic A/B/A controls are recorded in the PR body.

@clawsweeper

clawsweeper Bot commented Nov 11, 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses accessible registered-project history for PR imports, retains fetched commits for subsequent negotiation, and adds cold-fetch recovery guidance.

Example: Acquire a missing fork successor in the supplied 20,001-commit native Git fixture.

  • Before: The successor fetch receives 160,067 objects totaling 8,667,962 pack bytes.
  • After: The successor fetch advertises the retained predecessor and receives one object totaling 181 pack bytes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful and source-correct with the earlier finding resolved; proof is focused native and in-process coverage, and final-head CI remains pending.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): The previously required authority proof is supplied through performSessionGitHubPreparation with real requester, project-access, custody, native allocation, rollback and binding owners, with passing results reported publicly. GitHub responses, container setup and PR-content import remain synthetic. Native file-transport measurements separately exercise retained-ref successor acquisition; the inspected linked widget screenshots are unrelated and contribute no proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Large fork PR preparation can repeatedly download history, time out, and make no useful progress.
Reason: The maintainer-authored direction addresses measured wasted transfers through existing owners and explicitly preserves existing workspace bindings.

Merge readiness

✅ Ready for maintainer review

This PR addresses a concrete import failure that remains on main; the previous finding is fixed, and no new actionable defect was found.

Priority: P2
Reviewed head: b90fdbd86a75ac2e4b0697993b37f3c06ab56bf2

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway turns an inspected PR and current requester authority into a session-owned workspace, then acquires Git history and contents through the existing publication transport.

flowchart TD
  A[Conversation requests PR preparation] --> B[Inspect PR and requester authority]
  B --> C[Resolve accessible base project]
  C --> D[Allocate session workspace]
  D --> E[Revalidate and bind workspace]
  E --> F[Fetch and retain Git history]
  F --> G[Prepare PR contents]
Loading

Technical review

Best possible solution:

Keep project access, workspace custody, binding and Git acquisition with their existing owners while retaining successful transfers for reuse.

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

Current main always adopts an empty source and fetches absent commits without retaining a destination ref; the supplied native successor-acquisition measurements demonstrate the resulting repeated transfer without this review executing target code.

Is this the best way to solve the issue?

The patch repairs source selection and transfer retention at existing owners, preserves bound workspaces, and keeps interrupted-pack deletion with maintenance; the simplification review found no unnecessary production layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 04e941df2928.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3908a3e adds src/gateway/github-publication-git-transport.ts:195 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3908a3e46199; files: src/gateway/github-publication-git-transport.ts)

PR surface

Source +96, Tests +209, Docs +15, Other +163. Total +483 across 19 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 103 7 +96
Tests 8 372 163 +209
Docs 2 19 4 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 3 175 12 +163
Total 19 669 186 +483

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 Runtime production +96 lines; tests +208 lines Growth reuses existing owners and extends distinct acquisition, source-access, revocation and recovery contracts; no parallel manager or cache is introduced.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Repeated cold acquisitions can exhaust PR-preparation deadlines, with limited scope and existing workspace-preserving recovery.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • 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 (1 earlier review cycle)
  • reviewed 2026-11-11T13:36:04.510Z sha 49c389f :: needs real behavior proof before merge. :: [P2] Update the history fetch-failure interceptor for refspec arguments

Reviewed November 11, 2026, 8:55 AM ET / 13:55 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed all four “Before merge” items against b90fdbd:

  1. Real behavior proof. Replaced the internal-requester/no-op-authority fixture with the existing shipped-handler authority test. It uses authenticated operator clients, real requester grants, role writes/invalidation, project access, registry custody, native Git allocation, rollback and session binding. The private-source case proves no project binding, shared Git directory, alternates or project file is exposed (lines 845–870); the allowed case proves registered source/shared Git storage and preserved earlier files (lines 968–995). GitHub responses, container setup and PR-content import are synthetic external boundaries; this is in-process handler proof, not a live Gateway/model run.
  2. History fetch interceptor. The interceptor now matches the refspec's source OID (line 462), preserving both the injected-fault and unchanged-workspace assertions. The CI failure reproduced locally before the correction; all 15 history cases now pass. The matching base-refresh counter was also corrected and its native recovery case passes.
  3. Security attention. Actual role revocation while visibility lookup is awaited prevents allocation and leaves no worktree or session binding (lines 920–931). The handoff uses the current requester assertion at adoption line 173, through the existing allocation/custody guard, and at binding. No new security mechanism or relaxed check was added.
  4. Merge-risk proof. Actual role revocation after native project allocation is rejected before binding; the newly allocated worktree is rolled back (lines 933–947). Revocation after binding still prevents PR import (lines 949–965).

Validation: all four adoption cases pass; the expanded authority case takes 5.4 seconds. Targeted gateway test typecheck, lint, formatting, line-cap and test-line guards pass. Fresh Codex autoreview is scoped-clean through P2. Production and benchmark inputs are unchanged. Restoring the original handoff owners makes the expanded test fail because the old path never selects a project or reaches the visibility probe; that is not a claim of a baseline authorization bypass. The PR body records the proof limits and the fixed initial CI failure. Final-head CI is pending.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 11, 2026
@steipete
steipete merged commit f5d0c19 into main Nov 11, 2026
152 of 153 checks passed
@steipete
steipete deleted the steipete/perf-micro-empty-source-fork-fetch-loop-20260919 branch November 11, 2026 14:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…197229)

* fix: stop repeated cold fork fetches from empty workspaces

* test: recognize retained fetch refspecs in publication observers

* test: prove project adoption authority through the preparation handler
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Allow initial guest PR preparation from the recorded project's published
history while preserving unpublished work and original PR identity.

(cherry picked from commit 2757947)

Stable adaptation: preserve the existing linked-identity fixture; expand
its options type and allocate exactly 89 regression LF instead of 84.
Production and documentation patches are unchanged from the source.

Companions: #188785 is present-equivalent. Later #188784, #190223,
#190576, #190542, #195413, #197229, #197243, #199717, #195787,
#197510, #193664, #199851, #199864, #197656, #198851, #193873,
#197594, #189006, #188904, #194025, #196200, #192283, #189010,
#188816 and e0466ff are not prerequisites to this scoped repair;
retain their separate intake dispositions. No later PR-number mentions.

Proof: baseline 4 failed/20 passed through registered agent action;
fixed 41/41 across preparation, refresh and base-action suites.
Type-aware lint4, formatting5, docs MDX1419 and diff check pass.
No live GitHub or full release qualification claim.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant