# Stage: cleanup ## Purpose Remove eligible run data only after a successful publish, according to the workspace cleanup policy. Explicit session cleanup is a separate operator action. ## Authorization And Targets `workspace.cleanup_after_publish` enables automatic cleanup. It requires a succeeded upload and matching published run, commit, and pointer evidence. Cleanup confines deletion to that run and protects managed latest log/debug view targets and the original session-durable Notarius bundle. Subprocess state and caches are outside its scope. ## Execution And Resume Cleanup is idempotent and retries failed deletion without republishing. Retained protected files are intentional and do not trigger endless cleanup. Bounded runs ending before cleanup do not execute it. See [operations](../operations.md#cleanup). ## Implementation And Tests `internal/stage/cleanup_plan.go`, `cleanup.go`, `internal/fileops/cleanup.go` and their tests own authorization, protected targets, and confined deletion.