Skip to content

🤖 fix: clean up devtools.jsonl on archive/remove and reap orphaned session dirs#3733

Merged
ThomasK33 merged 1 commit into
mainfrom
devtools-372a
Jul 16, 2026
Merged

🤖 fix: clean up devtools.jsonl on archive/remove and reap orphaned session dirs#3733
ThomasK33 merged 1 commit into
mainfrom
devtools-372a

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

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.jsonl files 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.json at all (left behind by crashed or partially-failed removals).

Implementation

  • DevToolsService.removeWorkspaceData(workspaceId): drops in-memory run/step state and deletes the on-disk devtools.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 existing appendToFile existence guards. Runs even when debug logging is disabled, so files written while logging was on still get cleaned.
  • WorkspaceService.archive() calls it best-effort after archivedAt is 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).
  • Startup sweeps in WorkspaceService.initialize() (next to the existing orphan-scratch-workdir reaper):
    • Orphan session dirs: deletes ~/.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 fresh findWorkspace() re-check guard against racing workspace creation.
    • Retroactive devtools sweep: deletes devtools.jsonl for currently-archived workspaces, healing archives that predate archive-time cleanup and any archive-time cleanup failures.
  • Wired via a narrow setDevToolsService() setter in coreServices (same pattern as setTaskService). Chat history, plans, and archive snapshots are untouched.

Validation

End-to-end dogfood with real Config + DevToolsService + WorkspaceService on 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's devtools.jsonl leaving only chat.jsonl.

Risks

  • Deletion sweeps are the main risk surface. Mitigations: orphan reaping requires a strict config load (throwOnError), a 24h grace window, and a per-directory fresh config re-check immediately before rm; devtools cleanup only ever touches devtools.jsonl.
  • Severity if wrong: loss of debug logs (low; regenerable) or, guarded against as above, session data of a brand-new workspace.

Generated with mux • Model: anthropic:claude-fable-5 • Thinking: xhigh • Cost: $13.32

…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 -->
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: b87e9bf42a

ℹ️ 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".

@ThomasK33 ThomasK33 added this pull request to the merge queue Jul 16, 2026
Merged via the queue into main with commit 0890eb0 Jul 16, 2026
23 of 24 checks passed
@ThomasK33 ThomasK33 deleted the devtools-372a branch July 16, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant