Repository navigation
fix: keep session writes responsive during workspace cleanup - #202874
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: needs maintainer review before merge. What this changesThis PR moves bulk workspace cleanup into existing bounded background execution owners so session filesystem operations remain responsive. Example: Replace a 62,000-file projection while injecting a one-second unlink stall.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review The recorded performance-owner acceptance resolves the previous decision item; no actionable findings remain on the reviewed head. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherManaged-workspace owners request deletion of disposable or interrupted checkout trees, await completion, and then reuse paths or finish reconciliation. flowchart TD
A[Workspace lifecycle owners] --> B[Native filesystem owner]
B --> C[Shared two-child budget]
C --> D[Supervised removal child]
D --> E[Completion receipt]
E --> A
F[Session requests] --> G[Gateway filesystem pool]
Technical reviewBest possible solution: Use the existing bounded filesystem child for bulk cleanup while preserving path-reuse ordering, rollback custody, and best-effort staging cleanup. Do we have a high-confidence way to reproduce the issue? Current-main source retains the shared-pool removal path, and the supplied baseline campaign demonstrates filesystem-worker saturation and delayed session operations; no target code was executed during this review. Is this the best way to solve the issue? The change is the smallest complete owner cutover: it reuses existing supervision and concurrency limits, removes duplicate template-removal logic, and avoids a detached cleanup lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 951befe82d5d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +18, Docs +4, Other +506. Total +530 across 17 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. 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 HistoryReview history (3 earlier review cycles)Reviewed November 20, 2026, 11:42 PM ET / November 21, 2026, 04:42 UTC (Revision 4). |
Use the existing bounded filesystem child for materialized checkpoint trees. Preserve awaited best-effort cleanup and extend the real materialization regression. Mock the cleanup subprocess in the simulated Windows Git environment contract test.
|
@clawsweeper review Please review final code head 0084711. Bulk template, checkout, restore, and checkpoint staging cleanup now uses the existing bounded native child; the missing-registration eviction fallback stays synchronous inside its existing Git worker. Focus on lifecycle/authority preservation and shared-pool isolation. Local Codex review is clean and 157 focused tests pass. Full-size synthetic performance evidence and exact-head CI are still pending; this remains a draft until those gates and performance-owner acceptance are complete. |
|
🦞👀 Re-review progress:
|
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. |
Keep PR acquisition pause checks and cleanup-failure injection on the native removal boundary. Restrict the deferred capture fixture to retired capture artifacts so checkpoint payload cleanup can settle.
|
@clawsweeper re-review Please review final head The PR body now includes the completed 62k-file/48.06 GiB synthetic campaign, five A/B pairs, A/A controls, injected unlink occupancy, CPU/allocation costs, and limitations. Production/proof sources are unchanged from measured head |
|
🦞👀 Re-review progress:
|
|
Item 1 — resolved by the performance owner's recorded acceptance in the PR body. Lead decision by the Team perf-loop lead (an agent acting under Peter's standing unattended instruction), not Peter's. The lead explicitly accepts the reported cleanup-wall, allocation, and CPU-tail costs and the source-mode measurement limitations for the demonstrated Gateway pool isolation and foreground latency improvement. Compiled-release startup was not measured. The accepted ownership boundary is unchanged: bounded child removal, awaited projection replacement, and materialized result cleanup. Exact-head CI run 44865486075 is green. No code changed after that proof. @clawsweeper re-review Please verify the recorded acceptance and clear the single decision item on final head |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…w#202874) * fix: keep session writes responsive during workspace cleanup * test: make bulk cleanup measurements reuse synthetic fixtures * fix: isolate checkpoint staging cleanup Use the existing bounded filesystem child for materialized checkpoint trees. Preserve awaited best-effort cleanup and extend the real materialization regression. Mock the cleanup subprocess in the simulated Windows Git environment contract test. * test: observe bulk cleanup through its native owner Keep PR acquisition pause checks and cleanup-failure injection on the native removal boundary. Restrict the deferred capture fixture to retired capture artifacts so checkpoint payload cleanup can settle.
* fix: keep agent temporary files in owned scratch * fix: preserve sandbox temp access and queued isolation custody (cherry picked from commit f91bc99) Release adaptation: keep the staged #202815 Git shim implementation and independently assert both Git shim execution and writable owned temp in its merged Docker/Podman fixture. Use the beta.3 isolated custody configuration (896f33d52174), not ambient sandbox inventory. Companions: #193677 scratch expiry owner is present (99ba844); #202815 is present-equivalent (7d33d1a). #202122 is independent Git/scratch clone reclamation, #202428 is CLI history ownership, #202644 is host file-write authority, and #202874 is workspace cleanup scheduling; none prerequisite. Other later same-path commits concern separate template, sandbox, prompt, sharing, or run-lifecycle policy; see the lane companion audit. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a4070bc5b669308210b62a0b80b92c16af768b34)
What Problem This Solves
Recursive template and checkout cleanup can occupy all four default libuv filesystem workers in the Gateway. Slow unlinks then delay unrelated session filesystem operations. Route bulk tree removal through the existing native filesystem child owner and its shared two-child budget.
User Impact
Session filesystem operations retain access to the Gateway pool during bulk cleanup. Cleanup remains awaited before path reuse, preserving rollback/error behavior. No configuration, schema, cache, or threadpool-size change.
Why This Change Was Made
The owner cutover covers template replacement/install debris, partial clone rollback, initial projection replacement, exact-restore staging, and materialized checkpoint results. Missing-registration eviction already runs in the Git worker and now removes synchronously there. Normal/orphan GC already uses paced child deletion; copy rollback/provision cleanup already runs inside its worker/child. Container cleanup stays with the engine. Bounded single-file/empty-directory cleanup stays local. Worker bundle installation is a separate follow-up, not part of this managed-workspace path.
The duplicate template removal helper disappears. Production delta: 29 additions / 27 deletions, net +2 LOC; the additional staged-result import accounts for growth. No new helper or service. Rename-aside is unnecessary for isolation and would require a new detached cleanup lifecycle for immediately reused paths; retired checkpoint captures retain their existing lifecycle.
Evidence
Two existing real-flow regressions reject recursive main-process cleanup: generated template install debris and materialized checkpoint scratch. Each fails before its fix and passes afterward. The initial 157 focused tests passed. CI then exposed three stale cleanup test seams: PR acquisition observation, publication cleanup failure injection, and a retired-capture gate accidentally blocking newly migrated payload cleanup. The repair targets the native owner/artifact and preserves guest-resume, rollback, warning, and recovery-ref assertions. All six failing cases now pass locally (163 focused cases passed across the lane).
Independent Codex reviews of production, proof harness, staged-owner cutover, and the test repairs are scoped-clean at P0–P2; reviewers did not run tests. ClawSweeper reviewed head
008471117c3a2e9bd0e1e207627fb540c72e1847with zero findings. Final test-only head is4dec9dc37d00597b5746024a978b93fb4b0a820e. Exact-head CI run 44865486075 is green, including the aggregate gate. ClawSweeper reviewed that head with zero code findings and one decision item. The performance-owner acceptance is now recorded below; a re-review is requested to close that item before native landing.pnpm check:changed --stagedcompleted for production and the test repair. The final test repair's one redundant string conversion was removed; targeted lint/format pass. Only inherited dead-export findings remain. Exact parent2b5f1a88ba81e03d51010065c836f48490ebb498reproduces the same five production/three full-tree findings. Introducing PRs: #202654 (prepareGatewayPublicationTransportV1), #201615 (canReadApprovalSession,authorizeSessionPermissionModeChange), #202534 (checkSessionWorkspaceFileLinks, and removal of the last external productionopenSessionWorkspaceManagedArtifactconsumer). These are reported main regressions, not ignored noise. The normal PR CI run 44862605420 passed its other planned checks and failed only the test seams above; manual run 44861883514 additionally planned/reproduced the dead-export failure.Synthetic scale result
Final head changes only three test/support files relative to the measured head. Measured on frozen production/proof head
008471117c3a2e9bd0e1e207627fb540c72e1847: real Gateway WebSocketsessions.patchand Gateway async file writes during real projection replacement. Fresh 62,000-file / 1,142,784,000-byte trees per sample. Synthetic database: 48.06 GiB, 5,000 session records, 271,424 transcript events across 1,724 sessions. No production data. APFS with injected slow unlink, not a btrfs result. Two warmups, two A/A controls, five serial interleaved A/B pairs, then the injected pair. Startup/fixture construction are outside timing; normal background integrity verification remained active. Source-mode Node child startup is included.The acceptance rule was recorded before measurement: injected bulk-removal occupancy must become zero Gateway pool workers, with patch/file-write maxima below 250 ms; adverse cost movements above 20% require explicit performance-owner acceptance.
Injected one-second stall: patch maximum 1,441.92 → 13.89 ms; filesystem-write maximum 1,388.41 → 4.75 ms. Trace: four Gateway TIDs overlap for 1.00 s before; one child TID blocks afterward, with zero delayed Gateway TIDs. Bulk-removal occupancy 4/4 → 0/4. The candidate's ten no-removal control patches had a 28.24 ms maximum (4.33 ms median), versus 13.89 ms maximum (4.58 ms median) during removal. This passes the declared injected acceptance rule.
A/A aa1: owner 7482.11 ms; Gateway CPU 18950.30 ms; main CPU 1404.57 ms; allocation 165.32 MB; patch max 4704.39 ms; write max 4562.01 ms; control max 5460.82 ms; load [35.4375, 29.8876953125, 25.32080078125].
A/A aa2: owner 2500.33 ms; Gateway CPU 8446.70 ms; main CPU 1040.30 ms; allocation 147.73 MB; patch max 1171.61 ms; write max 1123.80 ms; control max 2560.50 ms; load [24.85205078125, 28.60009765625, 25.3876953125].
Measured A/B load ranges: [9.8798828125, 22.68603515625]
The p95 above is nearest-rank across five per-run values (therefore the maximum); individual request distributions are retained in the measurement output. One normal candidate patch reached 964.97 ms while its fs-write maximum was 13.04 ms; it remains in the table. Isolation does not eliminate shared-disk or other session latency. A/A controls expose substantial host/startup-maintenance variation; no samples were discarded from the declared campaign.
ACCEPTED — Lead decision by the Team perf-loop lead (an agent acting under Peter's standing unattended instruction), not Peter's.
The lead accepts cleanup wall +78% (2.37→4.23 s, background, awaited only before path reuse), main V8 allocation +81% and main CPU p95 +38% (largely the ~10× more foreground patches that now complete instead of queuing behind pool-blocking unlinks), and main+child allocation +411% (≈0.5 GB in three short-lived source-mode removal children). Compiled-release startup is expected to be cheaper and was not measured. Median total CPU fell 4%. The recorded CPU-tail costs and source-mode limitations are accepted in exchange for bulk-removal Gateway pool occupancy 4/4→0/4 and patch/fs-write maxima 1,442/1,388 ms→13.9/4.7 ms during cleanup. This is the performance-owner decision for landing this PR.
The canonical synthetic seed failed its final WAL checkpoint after committed writes. The retained database passed independent read-only
quick_check; canonical checkpoint/close succeeded, and the benchmark used normal Gateway admission/integrity checking. It is a partially populated synthetic seed, not a claim that the originally requested logical transcript byte target completed. Earlier setup failures and concurrent-seed diagnostic profiles are excluded from this primary campaign and retained in the lane report.Rerun the committed workload using synthetic inputs only:
The driver can generate synthetic inputs when reuse options are omitted; large seeding is expensive. On Linux compile the hook with
cc -shared -fPIC -o "$PROOF/delay.so" scripts/perf/bulk-unlink-delay.c -ldland pass that library. The driver selectsLD_PRELOAD/DYLD_INSERT_LIBRARIESand fixesUV_THREADPOOL_SIZE=4only in disposable proof processes.