land: task-scratch-cleanup

Merged
AF
6h ago
+920-43

Accepted agent delivery; branch-keyed search descriptor included.


Summary by cubic

Reclaims finished bash task scratch directories only after their process groups exit, removed on a dedicated bounded worker, and drains vanished-checkout views in consecutive bounded passes with a visible backlog count.

  • Terminal task records keep their scratch until the process group disappears, including failed launches whose PTY group identity survives setup failure, and while any read-only schema probe reusing the launch sandbox is still running.
  • Scratch removal runs on a single process-wide worker with a capped queue, so deletion never blocks task locks, terminal completion notices, or watchdog timeouts.
  • Task records retain ownership of pending scratch until removal confirms, so persisted GC in another project cannot delete them even after the owning registry unloads.
  • The bounded scratch sweep ages terminal records as well as scratch, reclaiming older terminal task scratch while live bundles and just-finished sandboxes stay protected.
  • Vanished-checkout views are prioritized over other cache planes, with a remaining backlog count surfaced in sweep and health output; passes continue while progress lasts and stop when stalled or cancelled.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issue was established.

Summary

Finished bash tasks now release scratch after their process groups exit. Removal runs on a bounded worker while task records retain the information needed for retry.

  • Finished bash tasks release scratch after their processes and follow-up work end.
  • Vanished-checkout views drain first in consecutive bounded sweeps.

The earlier unnumbered watchdog finding is addressed: recursive scratch deletion now runs on the worker rather than under the task lock.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Task becomes terminal] --> B{Process group gone and hint finished?}
    B -->|No| C[Keep scratch and retry]
    B -->|Yes| D{Cleanup queue has room?}
    D -->|No| C
    D -->|Yes| E[Worker removes scratch]
    E --> F{Removal succeeded?}
    F -->|No| C
    F -->|Yes| G[Clear persisted scratch path]
    G --> H[Allow task retirement]

Reviews (3) · Last reviewed commit: "mason: preserve task scratch through ter..." · Reviewed by Greptile