Skip to content

Add DB-backed cleanup runs and cleanup items #244

@chubes4

Description

@chubes4

Goal

Replace filesystem cleanup plan workflows with DB-backed cleanup runs/items.

Scope

Add tables/repositories for:

  • datamachine_code_cleanup_runs
  • datamachine_code_cleanup_items

Required workflow

  • workspace cleanup plan --mode=<mode> creates a cleanup run and item rows.
  • workspace cleanup apply <run-id> schedules or applies rows by querying item state.
  • workspace cleanup status <run-id> aggregates item/job state.
  • workspace cleanup evidence <run-id> reads run/item/job evidence.
  • workspace cleanup resume <run-id> resumes pending/failed chunks.
  • workspace cleanup cancel <run-id> cancels pending items/jobs.

Data model expectations

Each cleanup item stores:

  • handle/worktree reference
  • planned action
  • current status
  • reason_code/reason
  • chunk/job ids
  • bytes reclaimed
  • bounded evidence JSON

Migration from current behavior

  • File-based --apply-plan=/path.json becomes an escape hatch only.
  • CLI help should stop documenting redirect-to-file as the normal path.
  • Data Machine job engine_data can store chunk-local payloads, but run/item state belongs in DMC tables.

Tests

  • Plan creates run/items.
  • Apply claims pending items and updates status.
  • Status/evidence aggregate item and child job state.
  • Retrying a run is idempotent.
  • No filesystem plan files are created.

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