Repository navigation
feat: expire disposable agent scratch after 24 hours - #193677
Conversation
Reuse hourly worktree maintenance with current live and queued checkout custody, bounded streaming deletion, and explicit expired artifact states. Scratch references do not protect files. No new scheduler, config, or database schema. Allocate 605 regression-test lines for TTL boundaries, live and queued custody, symlink refusal, resumable enumeration, pacing, and expired artifact transport and browser behavior.
|
🦞👀 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. |
Forward the worktree removal record through the existing pacing benchmark and use the canonical agent entries shape in custody fixtures.
Codex Review SummaryThis 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: a0f4a5fb1f
ℹ️ 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".
| isLive: () => isLive(root, ids), | ||
| })); | ||
| // Coverage has no checkout/run binding; unrelated activity is not a retention veto. | ||
| targets.push({ root: os.tmpdir(), kind: "coverage", isLive: () => false }); |
There was a problem hiding this comment.
Canonicalize the runtime temp root before admitting coverage cleanup
On macOS installations where os.tmpdir() returns a path under /var/folders, the /var → /private/var system alias makes this coverage target fail every pass: cleanScratch rejects any root whose rootReal differs from path.resolve(target.root). Consequently, expired runtime coverage directories are never cleaned on those installations. Canonicalize the trusted runtime temp root before constructing this target, while retaining symlink rejection for entries inside it.
Useful? React with 👍 / 👎.
|
Codex review: blocked before merge. What this changesThis PR expires disposable scratch after 24 hours and explains missing scratch files across artifact and Files transports. Example: An idle managed checkout contains .openclaw/tmp/proof/report.txt last modified 25 hours ago.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open: the maintainer-approved cleanup feature is useful, but coverage cleanup fails for aliased macOS temp paths and expiry errors omit recovery guidance. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway worktree maintenance combines registered checkout roots with current run and queue custody, removes eligible scratch through fs-safe, and exposes cleanup receipts and artifact availability to clients. flowchart TD
A[Hourly maintenance] --> B[Checkout inventory and run custody]
B --> C[Bounded scratch cleanup]
C --> D[Guarded filesystem removal]
C --> E[Cleanup receipt]
D --> F[Artifact and Files readers]
F --> G[Expiry messages and HTTP 410]
Technical reviewBest possible solution: Retain the existing maintenance architecture, canonicalize the trusted runtime temp root, and provide actionable expiry errors. Do we have a high-confidence way to reproduce the issue? The macOS failure follows directly from passing an aliased os.tmpdir() path into the canonical-root equality check; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? Reusing the maintenance scheduler, custody owners, guarded filesystem operations, and existing artifact transports is appropriate; the runtime-root admission needs a focused correction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bf0d53d5c17a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +707, Tests +605, Docs +2, Other +232. Total +1546 across 33 files. Added test files: 2. 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 Reviewed November 5, 2026, 2:24 PM ET / 19:24 UTC. |
Keep the strict worker download result aligned with its producer and preserve boundary denials for escaped scratch paths. Isolate scratch custody in the existing worker-free maintenance fixture. Existing regressions reproduce red before correction; all 203 affected tests pass after correction.
|
Merged via squash.
|
* feat: expire disposable agent scratch after 24 hours Reuse hourly worktree maintenance with current live and queued checkout custody, bounded streaming deletion, and explicit expired artifact states. Scratch references do not protect files. No new scheduler, config, or database schema. Allocate 605 regression-test lines for TTL boundaries, live and queued custody, symlink refusal, resumable enumeration, pacing, and expired artifact transport and browser behavior. * fix: align scratch maintenance validation callers Forward the worktree removal record through the existing pacing benchmark and use the canonical agent entries shape in custody fixtures. * fix: preserve scratch download boundary reasons across workers Keep the strict worker download result aligned with its producer and preserve boundary denials for escaped scratch paths. Isolate scratch custody in the existing worker-free maintenance fixture. Existing regressions reproduce red before correction; all 203 affected tests pass after correction.
* feat: expire disposable agent scratch after 24 hours Reuse hourly worktree maintenance with current live and queued checkout custody, bounded streaming deletion, and explicit expired artifact states. Scratch references do not protect files. No new scheduler, config, or database schema. Allocate 605 regression-test lines for TTL boundaries, live and queued custody, symlink refusal, resumable enumeration, pacing, and expired artifact transport and browser behavior. * fix: align scratch maintenance validation callers Forward the worktree removal record through the existing pacing benchmark and use the canonical agent entries shape in custody fixtures. * fix: preserve scratch download boundary reasons across workers Keep the strict worker download result aligned with its producer and preserve boundary denials for escaped scratch paths. Isolate scratch custody in the existing worker-free maintenance fixture. Existing regressions reproduce red before correction; all 203 affected tests pass after correction.
* 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
Long-lived managed worktrees and project checkouts accumulate disposable agent proof files and runtime coverage directories indefinitely.
User Impact
The existing hourly maintenance pass now deletes
.openclaw/tmpentries and runtimenode-coverage-*directories after 24 hours, measured from their newest file. Live or queued runs protect their checkout. Recorded artifacts and idle sessions do not protect scratch; save durable outputs elsewhere. Missing scratch artifacts explicitly display file expired (scratch cleaned after 24 h) when listed or opened, including previously issued download links.This is the release-note context: fixed 24-hour scratch disposal with visible expired-artifact states, without a new configuration option or scheduler.
Why This Change Was Made
Cleanup belongs to the existing worktree maintenance owner. It consumes current run and queue custody, refuses symlinks, streams bounded scans and deletions, resumes directory enumeration across passes, and pauses after each 128 removals. Its receipt/status includes removed entries and logical bytes, live skips, and deferrals. Runtime coverage has no checkout binding; unrelated activity does not indefinitely protect shared temporary coverage.
The smallest complete change includes cleanup, existing-custody integration, and every artifact read/open transport. Production grows by 713 lines for this new lifecycle and its visible outcome; no artifact index, database schema, retention configuration, or independent scheduler is introduced. A 616-line test allocation covers distinct TTL, liveness, boundary, enumeration, pacing, artifact transport/browser regressions, and maintenance/worker-transport fixture coverage. The shared test ceiling is unchanged.
Evidence
The artifact regression fails on the exact parent: after deletion, the original implementation still returns
report.txt. The candidate returns the explicit expired state. Focused backend tests, browser tests, and Files/image end-to-end checks exercise listing, preview, metadata, and HTTP 410 downloads. Before/after captures below contain synthetic data only.Final focused validation passed 130 tests across eight files, with earlier 204-test coverage of unchanged artifact/file/mailbox consumers; the canonical-config correction passed all eight custody tests again. Browser tests passed 5/5, and Files/image expiry end-to-end cases passed. Codex autoreview is clean through P2 for the full patch from
7786241c9ae4to93fbc5143e86its caller/config correction ata0f4a5fb1f1b, and the final CI corrections at9882d57b72e7.Initial CI exposed two task-caused gaps: the timer fixture left new scratch custody preparation real, and the strict worker download schema rejected the new boundary-denial reason. Both reproduce locally before correction. The fixture consumers now pass 188 tests across 11 files; all 15 repository download tests pass, including an escaped-scratch denial assertion. The Android job passed all 13 native tests and cleanup verification receipts but returned failure during teardown; its exact failing cleanup command is unresolved and is not classified as inherited. The new-head CI run passed, including both Android variants; the previous teardown failure is not claimed repaired or inherited.
pnpm check:changedcompleted on the full change and final correction. Production/test/script types, lint, formatting, SQLite worker/dialect/schema guards, and import checks pass. It retains only reproduced, attributed parent failures: 26 forbidden changelog self-attributions introduced byde04fbe0caa9(#193427), and four unused exports introduced by56753f7762a7(#193098) or made unused by the caller move ine0466ffe4d11(#193057). Both canonical checkers reproduce on exact parent7786241c9ae407660db2daabb2937f60d73f54ca; these are main regressions, not ignored PR failures. No affected owner or release record is changed here.The filesystem owner passed six timing, six allocation, and one CPU-profile run on 62,000 real synthetic files totaling 1.181 GB. Every run removed 708.66 MB, preserved fresh/live/outside files, and recorded zero errors. Five warm samples had median wall/CPU 86.112/40.526 seconds, including 29 seconds of intentional pacing; cumulative sampled allocation was 3.030 GB (including collected objects, not retained heap). The absent cleanup baseline reclaimed zero bytes. A/A variation reached 32.2% wall and 19.6% CPU on the shared host, so no speedup or precise throughput claim is made.
A separate real custody qualification used a 37,582,270,464-byte SQLite database with 5,000 populated/indexed sessions and real high-entropy transcript data. It skipped two live/queued worktrees, cleaned four eligible roots, then cleaned the remaining two after release. Across ten samples, 30 preparations plus 180,000 guard checks took median 130.582 ms wall / 189.465 ms process CPU; ten allocation controls measured 50.92 MB cumulative main-thread allocations. This is a combined preparation/check workload, not isolated preparation latency.
Final measurements use APFS. The granted remote host lacked btrfs support, and its lease ended before final-source replay; earlier ext4 results are initial-candidate evidence only. The two owner fixtures are separate, not one combined Gateway or btrfs test. Production btrfs throughput is not established. No production data or deployment was used; synthetic fixtures and the remote lease are cleaned up. Exact-head PR CI run 42098951349 passed at
9882d57b72e734dc9f9fa2895ea2126378e33995, including the required CI and security gates. Merged as99ba844a3cd59through the ordinary native workflow, without an admin exception.