🤖 fix: clean up devtools.jsonl on archive/remove and reap orphaned session dirs#3733
Merged
Conversation
…ssion dirs
DevTools debug logs (devtools.jsonl) were never pruned, accumulating tens of
GiB across archived workspaces, and session directories orphaned by crashed
or partially-failed removals lingered forever.
- DevToolsService.removeWorkspaceData(): drops in-memory state and deletes
the on-disk devtools.jsonl, serialized behind pending appends.
- WorkspaceService.archive(): removes DevTools data once archivedAt is
durable (best-effort; worst case after unarchive is an empty DevTools panel).
- WorkspaceService.remove(): also drops in-memory DevTools state (the file
already died with the session directory).
- Startup sweeps in WorkspaceService.initialize():
- delete session dirs with no config entry at all (24h mtime grace window
plus a fresh findWorkspace re-check guard against creation races; legacy
"<project>-<workspace>" session IDs are preserved),
- delete devtools.jsonl for already-archived workspaces, retroactively
healing archives that predate archive-time cleanup.
---
_Generated with `mux` • Model: `anthropic:claude-fable-5` • Thinking: `xhigh`_
<!-- mux-attribution: model=anthropic:claude-fable-5 thinking=xhigh -->
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DevTools debug logs (
devtools.jsonl) are now deleted when a workspace is archived or removed, and startup sweeps reclaim disk from orphaned session directories and from workspaces archived before this cleanup existed.Background
A disk audit found ~57.7 GiB of
devtools.jsonlfiles across 442 archived workspaces (mux never pruned these; the worst case after unarchive is an empty DevTools panel), plus 96 orphaned session directories whose workspaces no longer exist in~/.mux/config.jsonat all (left behind by crashed or partially-failed removals).Implementation
DevToolsService.removeWorkspaceData(workspaceId): drops in-memory run/step state and deletes the on-diskdevtools.jsonl. The deletion serializes behind pending appends via the existing per-workspace write queue, and deleting the in-memory entry makes stale queued appends no-ops via the existingappendToFileexistence guards. Runs even when debug logging is disabled, so files written while logging was on still get cleaned.WorkspaceService.archive()calls it best-effort afterarchivedAtis durably persisted — archive never fails because of log cleanup.WorkspaceService.remove()additionally drops in-memory DevTools state (the file already dies with the session directory).WorkspaceService.initialize()(next to the existing orphan-scratch-workdir reaper):~/.mux/sessions/<id>directories with no config entry. Safety rails: config read failures are never treated as an empty reference set (no mass deletion), legacy<project>-<workspace>session IDs are preserved for un-migrated entries, and a 24h mtime grace window plus a freshfindWorkspace()re-check guard against racing workspace creation.devtools.jsonlfor currently-archived workspaces, healing archives that predate archive-time cleanup and any archive-time cleanup failures.setDevToolsService()setter incoreServices(same pattern assetTaskService). Chat history, plans, and archive snapshots are untouched.Validation
End-to-end dogfood with real
Config+DevToolsService+WorkspaceServiceon a temp root:initialize()shrank an archived workspace 8.1M→4K (chat kept), removed a 4.1M stale orphan, spared a fresh orphan;archive()then dropped the live workspace'sdevtools.jsonlleaving onlychat.jsonl.Risks
throwOnError), a 24h grace window, and a per-directory fresh config re-check immediately beforerm; devtools cleanup only ever touchesdevtools.jsonl.Generated with
mux• Model:anthropic:claude-fable-5• Thinking:xhigh• Cost:$13.32