Skip to content

Run safe workspace cleanup automatically instead of relying on agents #255

@chubes4

Description

@chubes4

Problem

DMC declares recurring cleanup schedules, but the relevant cleanup tasks are disabled by default:

  • worktree_cleanup has default_enabled => false
  • workspace_retention_cleanup has default_enabled => false

On intelligence-chubes4, no scheduled workspace cleanup flow is active, so cleanup only happens when an agent/operator explicitly runs CLI commands. That means stale worktrees accumulate even though DMC has the cleanup machinery.

Agents should not have to remember to run cleanup. DMC owns worktree lifecycle and should keep the workspace healthy in the background.

Desired behavior

Local agent installs should have safe, recurring cleanup enabled by default, or an equivalent DMC-owned scheduler should run automatically.

The recurring task should only remove worktrees after DMC safety revalidation:

  • never primaries
  • never protected branches
  • never dirty worktrees unless an explicit operator force path is used
  • never worktrees with unpushed commits
  • only cleanup-eligible / merged / upstream-gone worktrees
  • artifact cleanup should remain reconstructable-only

Acceptance criteria

  • A fresh/local DMC agent install runs safe workspace cleanup without requiring agent chat-loop action.
  • The schedule is visible in Data Machine system health / schedule surfaces.
  • Disabled/destructive modes remain opt-in, but the safe retention path runs automatically.
  • Cleanup emits evidence so agents can summarize what happened without doing the cleanup manually.
  • Tests verify default setting/schedule behavior and task gating.

Notes

This may be a settings/defaults decision rather than a new engine. The important product behavior is: DMC should prevent stale worktree buildup outside the agent loop.

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (openai/gpt-5.5)
  • Used for: Inspecting the live schedule/task state and drafting the issue. Chris identified the ownership requirement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions