Skip to content

fix(worktrees): partial-clone removal times out scanning promisor packs - #200299

Merged
steipete merged 1 commit into
mainfrom
codex/worktree-snapshot-promisor-proof
Nov 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/worktree-snapshot-promisor-proof

Conversation

@steipete

@steipete steipete commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes managed-worktree cleanup aborting after 120 seconds when a large partial clone has unfetched HEAD blobs. Related: #188525, #189288.

Between 13:55 and 15:06 PST on November 16 (release 344cc75d), cleanup failed 16 times across 16 checkouts, every 2–3 minutes after no earlier failures that day, under sustained btrfs I/O pressure, with approximately 360 promisor pack files, another 53 new packs, and a 10 GB temporary pack. Each failure spent approximately 120.4 seconds in snapshot preparation before preserving the checkout and deferring an otherwise repeatable failure for 1–2 hours. Concurrent preparations recorded 110–141 seconds waiting for allocation/reservation; five conversations waited 2–2.5 minutes for a first reply. Those overlapping timings do not establish the lease holder.

User Impact

Removal hydrates missing HEAD contents directly and requires local custody before snapshotting, without scanning unrelated promisor packs. Failed hydration, remaining missing objects, corruption, and lost removal authority still preserve the checkout. Worktrees without missing objects retain their existing path. No configuration, timeout, schema, worker, or lazy-import boundary changes.

Why This Change Was Made

The snapshot owner ran rev-list --missing=allow-promisor before the existing batch hydrator. Git initializes promisor membership by scanning every promisor pack; --max-count=1 does not bound that work. The fix deletes this classification and uses the existing selected-promisor batch fetch, transport isolation, and Git mutation admission from #188525. An offline --missing=print --max-count=1 HEAD census then requires no remaining missing objects before capture. Its work follows the selected commit's contents rather than unrelated promised pack contents.

Data safety depends on recoverability, not historical promise membership. A remote can serve an exact object ID even if that blob was originally authored locally. Fetch success alone is insufficient: the clean-snapshot fast path can otherwise publish HEAD without reading unchanged blobs. The new offline census closes that gap; capture retains its existing offline dirty/index validation and authority gates. Missing unpromised data that cannot be recovered still preserves the checkout. The retained unpromised-object maintenance fixture now expects one attempted fetch rather than zero; its byte preservation, backoff, and eventual repair assertions are unchanged.

Allocation investigation: ordinary removal acquires only core:managed-worktrees:mutation/<id> (service.ts:717, allocation.ts:73), while creation uses core:managed-worktrees:create/capacity (allocation.ts:58). The whole-pack proof did not enter the ref-mutation queue (git.ts:215). Its content slot is shared with snapshot/content reads, while preparation has a separate worker lane (git-worker.ts:150). However, global allocation owners can retain their lease while awaiting that checkout: withWorktreeAllocationLease nests the checkout lease (allocation.ts:62), including restore (service.ts:866) and removed-name reuse (service.ts:489). Rollback directly snapshots under global allocation ownership (service.ts:367, service.ts:395), and count-cap enforcement invokes snapshotting eviction under that lease (capacity-owner.ts:313, capacity-owner.ts:185, eviction.ts:108); eviction supplies its own five-second cancellation signal (eviction.ts:99). The restore/rollback ownership interval includes checkout acquisition and native settlement, not a fixed short critical section. STOP for Goal 2: separating those responsibilities requires a broader capacity/lease redesign, so lease scope is unchanged under the requested escape hatch. The incident's exact holder is not identifiable from the supplied timing lines alone.

Simplification: one hydration owner remains; the whole-pack classification is removed. Production delta: −8 lines. Net test delta: +22 lines, one added table case and one extended existing case, no new suite. Acceptance: promised removal/restoration succeeds with a synthetic stalled whole-pack command, exactly one real batch fetch, and zero global membership scans; unsuccessful or incomplete hydration preserves checkout bytes and registry custody. This is a work-count/behavior regression, not a production latency benchmark.

Evidence

  • Red on base f947bdc94981e299fe26b5a71af8bfdd4e7ac125: node scripts/run-vitest.mjs src/agents/worktrees/service.removal-safety.test.ts --maxWorkers=1 -t 'removal \((promisor|incomplete)\)' → 2 failed / 20 skipped. The first failure is caused by the synthetic whole-pack timeout; the second resolves { removed: true } rather than preserving missing blobs. The second table label was subsequently shortened from incomplete to noop; fixture behavior is unchanged.
  • Green: node scripts/run-vitest.mjs src/agents/worktrees/service.removal-safety.test.ts src/agents/worktrees/service.removal-budget.test.ts src/agents/worktrees/service.capacity.test.ts src/agents/worktrees/service.remove-lease.test.ts --maxWorkers=1 → 85 passed: 52 infra cases (208.38 seconds) and 33 removal-budget cases (61.49 seconds), 296.24 seconds total wall time including worker preparation/verification. This retains real Git partial clones, one-batch hydration, transport-denied byte-for-byte restore, unavailable/unpromised/corrupt-object preservation, removal authority, backoff, and allocation-capacity contracts. These existing files exceed 30 seconds because they exercise native Git, worker settlement, and persisted registry/removal custody; the regression adds no suite or product startup.
  • Targeted typecheck: node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/agents/worktrees/service.removal-safety.test.ts","src/agents/worktrees/service.removal-budget.test.ts"]' → agents-tools passed. It initially caught missing synthetic result metadata; adding timeoutMs: 0 corrected the fixture type without changing behavior.
  • Targeted run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json on all three TypeScript files, pnpm format:check on all four files, and git diff --check passed. Worker and lazy-import boundaries are unchanged, so no build-boundary change is claimed.
  • Shared autoreview, Codex engine, complete local candidate against f947bdc94981e, P0–P2: scoped-clean, no accepted/actionable findings. Final review includes the fixture metadata correction; unchanged hydration, snapshot inventory, isolated transport, Git execution, and worker owners were supplied as context. Pr-simplify retained the existing hydration owner and removed the redundant classification path.
  • Exact-head CI 43978838698, head 9c7a93e2f44cc2e0937e39dd0289b19275f743fa: completed success, 74 jobs (45 successful / 29 skipped), no failures or cancellations. No CI reruns or repair pushes. The baseline-ratchet job took 16 minutes 47 seconds; its final result was success. No inherited-failure exception was used. Native review/preparation and accepted auto-merge reconciled the exact attempted head as merged, commit b220220905f2bd2d38ccfd95b0e6983a9cce5bd7.

Fetch missing HEAD objects through the existing promisor hydrator, then require an offline census with no missing objects before capture. Preserve failed and incomplete hydration, including the clean-snapshot fast path. Avoid the whole-pack promisor membership proof. Release-note context: partial-clone cleanup no longer aborts on a repository-wide promisor scan.
@clawsweeper

clawsweeper Bot commented Nov 16, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 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-16T23:25:11.990024Z 9c7a93e 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Nov 16, 2026
@steipete
steipete enabled auto-merge (squash) November 16, 2026 23:38
@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. labels Nov 16, 2026
@steipete
steipete merged commit b220220 into main Nov 16, 2026
141 of 143 checks passed
@steipete
steipete deleted the codex/worktree-snapshot-promisor-proof branch November 16, 2026 23:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…enclaw#200299)

Fetch missing HEAD objects through the existing promisor hydrator, then require an offline census with no missing objects before capture. Preserve failed and incomplete hydration, including the clean-snapshot fast path. Avoid the whole-pack promisor membership proof. Release-note context: partial-clone cleanup no longer aborts on a repository-wide promisor scan.
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…00299)

Fetch missing HEAD objects through the existing promisor hydrator, then require an offline census with no missing objects before capture. Preserve failed and incomplete hydration, including the clean-snapshot fast path. Avoid the whole-pack promisor membership proof. Release-note context: partial-clone cleanup no longer aborts on a repository-wide promisor scan.

(cherry picked from commit b220220)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit d8322bec025b2274daefd1e348680cb706f23d7c)
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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant