Repository navigation
fix: bound background worktree deletion bursts - #202197
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f808753fa7
ℹ️ 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".
|
Addressed the hosted review's P1 finding in 1d31d20:
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
The final head is f19e348. Its only change from 1d31d20 is removing two redundant string conversions in the GC test mock; runtime code is identical. The failed lint check now passes, and all other changed-check lanes passed. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR bounds retired-worktree deletion bursts and routes orphan recovery through the same serialized cleanup queue. Example: Retire a synthetic checkout containing 62,000 files.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review The published final-head comparisons resolve the previous author hold, and this review found no actionable defects; CI remains red for the documented inherited docs failure. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherManaged-worktree removal preserves a recovery snapshot and unregisters the checkout; the cleanup child reclaims its retired files, while orphan GC recovers interrupted deletions. flowchart TD
A[Managed checkout removal] --> B[Snapshot and Git unregistration]
B --> C[Serialized deletion queue]
D[Orphan GC and permission repair] --> C
C --> E[Paced cleanup child]
F[Host IO pressure probe] --> E
E --> G[Retired files reclaimed]
Technical reviewBest possible solution: Retain the shared paced deletion owner and proceed through normal landing under the recorded inherited-CI exception. Do we have a high-confidence way to reproduce the issue? Current main exposes the whole-tree recursive deletion directly, and the supplied real-filesystem comparison demonstrates the burst; no target code was executed during this review. Is this the best way to solve the issue? The smallest complete fix is to pace the existing cleanup child and route orphan deletion through its existing queue, preserving snapshot, custody, and permission-repair behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 626527a745ad. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +83, Tests +104, Docs +9, Other +153. Total +349 across 9 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 19, 2026, 10:58 PM ET / November 20, 2026, 03:58 UTC (Revision 3). |
|
Addressed the latest review's only open item on unchanged final head
The final full @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* fix: pace retired worktree cleanup * fix: share paced deletion with orphan recovery * test: remove redundant cleanup target conversions
What Problem This Solves
Retiring a managed checkout handed its whole renamed tree to one recursive delete. On shared storage, that metadata burst can delay unrelated database persistence despite a low-priority subprocess and once-per-minute admission. Orphan GC could also rename and recursively delete a tree while paced cleanup was pending.
User Impact
Cleanup now limits unlink bursts and backs off on slow filesystem commits. Normal retirement and orphan recovery share the serialized deletion owner, including permission-repair retries. Snapshot preservation, live-run checks, owner custody, and Git checks remain intact. Background cleanup takes longer and uses more total CPU/allocation; foreground removal can still release the original checkout name promptly.
Why This Change Was Made
The existing child deletes at most 128 entries or 8 MiB apparent bytes, then requests a 100 ms pause. One indivisible oversized file occupies its own batch. It reuses the existing host-pressure probe between batches, including current/recent btrfs commit times, with five-second waits under pressure. The child has a separate 30-minute budget; foreground checkout timeouts are unchanged. A new SQLite telemetry channel or host-probe subsystem was unnecessary.
The 62k-file fixture completes in about 55 seconds with 489 pauses and 2.34 MB at most per ordinary burst. This makes the entry budget a practical starting point for background work; the 8 MiB guard also bounds larger-file mixtures. It is not a calibrated btrfs transaction or latency limit.
Snapshot inventory already runs in the Git worker.
snapshotMsis asynchronous elapsed wall time;isMainThreadidentifies the logging owner. No duplicate snapshot worker was added. Cumulative MAIN CPU spans many callbacks and is distinct from uninterrupted blocking.Evidence
Five final-head A/B pairs ran serially, with A/A controls and host load recorded. Cleanup uses 62,000 generated files × 18,432 bytes plus directories; service removal uses 50,000 dependency files × 22,000 bytes plus 2,388 tracked files. Setup is outside timing. With five samples, nearest-rank p95 is the observed maximum; it is not a production tail estimate. MB is decimal, allocation is total V8 allocation including instrumentation, not retained memory.
All candidate cleanup runs made 489 scheduled pauses, with observed durations 99.12–102.39 ms (median 102.08 ms). No retired cleanup directory remained after the service processes settled. The extra total CPU and allocation buy bounded work and byte accounting; this is not a throughput improvement. Final-code profiling placed active cleanup samples mostly in unlink and snapshot inventory in the Git worker; a native sample of the cleanup child observed a 35.2 MB physical footprint.
An earlier loaded-host sample is retained in the local report: cleanup took 99.93 s / 44.86 s CPU, with host load rising sharply. Its service removal had 2.42 s snapshot wall time but only 16.91 ms maximum event-loop delay. It is not included in this fresh final-head series and is not hidden as a passing performance claim.
Sanitized actual final worker report excerpt (the committed driver asserts complete deletion before writing this):
{ "files": 62000, "fileBytes": 18432, "entryCount": 62621, "elapsedMs": 56061.000542, "cpuMs": 6119.198, "allocatedBytes": 187561880, "maxBatchEntries": 128, "maxBatchBytes": 2340864, "pauses": 489 }Repeat with fresh cleanup outputs and
--reuse-fixture --report <new-name>.jsonfor service measurements. Baselines use the original cleanup worker via--worker <pinned-worker.ts>andOPENCLAW_BENCH_BASELINE_DIRfor the pinned removal/GC modules. All baseline files came from1ade2b7a8899ea45934f93e7ede48443dff7d515.119 focused owner tests passed; a separate expanded GC/custody run passed 96 tests (these run counts overlap). The pacing regression fails on the original worker, and the held-open retirement/GC regression fails on the preceding PR head. Both pass with the fix. Coverage includes filesystem entry/byte counters, synthetic slow-commit holds, oversized-file batches, symlink targets, real compiled subprocess deletion, permission repair, live-run refusal, owner custody, pending slots, and #202122 scratch-only re-arming. Existing host-pressure tests prove current/recent slow btrfs commits trigger pressure with zero PSI.
The final full
pnpm check:changedpassed. Independent Codex autoreview is scoped-clean through P2; the subsequent test-only commit removes two redundant string conversions without changing behavior. All five final-head measurement pairs are complete and published above. The hosted Codex orphan-GC finding has a code/proof response and is resolved. No changed runtime module is imported by Control UI, so its browser-test boundary is not crossed.This is APFS/macOS proof, not a Linux/btrfs latency experiment. Apparent bytes and entry counts do not bound physical delayed references or the size of a shared filesystem transaction. Pacing and the existing slow-commit brake mitigate bursts; they do not prove that the reported seven-second SQLite stall is eliminated. No live-service access, copied production data, configuration option, or schema change was used.
The separate generated SQLite file contains 5,000 session-shaped rows and occupies 37,621,940,224 bytes (35.04 GiB). It supplies passive storage scale on the same volume, not the production agent schema or an active 35 GiB database workload. No database commit-latency result is claimed.
Production delta: +112/−29, net +83 lines across three modules. Growth provides the bounded walker and one shared deletion queue; it removes the orphan recursive-delete bypass. There is no new cache, manager, schema, or public option.
Inherited CI Failure
Final head
f19e348802aad625f0b43419aca879a164970fe7, CI run 44666643767, attempt 1: 41 passed, 27 skipped, 2 failed. The only independent failure ischeck-docs; the other is its aggregate gate.security-fastpassed.All 18 release-note heading errors reproduce on exact CI main parent
c3d658254b0835eb1663067163adcde6b4620401, with the same failing file/config as tested merge756c046bbe58b208bafa8e2093d411e9d69590d8. They were introduced by #201913 (72702a3600f77f42f40b9387b3f353fa4a5fac1a). Later #202186/#202192 edits only add a count paragraph. This is a main regression requiring repair, not noise. The user explicitly authorized the pinned-head inherited-failure exception; the native evidence retains this failed CI verdict.