Skip to content

Cleanup planning and bounded safety scans regress on large workspaces #948

Description

@chubes4

Problem

The documented DB-backed cleanup path and all reviewed fallback scans are unusable on a 446-worktree workspace. The retention planner fails before returning a run ID, while bounded safety scans that previously completed quickly now run silently beyond three minutes.

This regresses the behavior addressed by #736, #631, and #384. In particular, #736 recorded bounded-cleanup-eligible-apply --limit=100 completing in roughly 5.5 seconds; the same bounded family now times out with only 15 candidates.

Environment

  • Workspace: /Users/chubes/Developer
  • Inventory: 53 primaries, 446 worktrees
  • Cleanup-eligible inventory rows: 15
  • Free disk: 58.8 GiB
  • No inventory-known dirty or unpushed blockers
  • Two stale filesystem locks were safely pruned before retrying; subsequent lock status reported zero stale locks

Reproduction

Planner fails without a run ID

studio wp datamachine-code workspace cleanup plan \
  --mode=retention \
  --include-artifacts \
  --limit=100 \
  --top=20 \
  --until-budget=2m \
  --format=json

Observed:

Error: Failed to create cleanup run.

No run ID, reason code, child error, or recovery command is returned.

Bounded cleanup-eligible review hangs

studio wp datamachine-code workspace worktree bounded-cleanup-eligible-apply \
  --dry-run --limit=15 --format=json

Observed: no output before a 180-second shell timeout.

Active/no-signal merged review hangs

studio wp datamachine-code workspace worktree active-no-signal-merged-apply \
  --dry-run --limit=100 --offset=0 --format=json

Observed: no output before a 180-second shell timeout.

Full cleanup review hangs

studio wp datamachine-code workspace worktree cleanup --dry-run --format=json

Observed: no output before a 180-second shell timeout.

Cheap workspace hygiene and bounded size inventory still return, proving the top-level inventory itself is readable. No destructive cleanup was applied.

Safety impact

The inventory includes open-PR worktrees marked cleanup_eligible, including Blocks Engine PR #659 and Static Site Importer PR #714. Operators therefore cannot safely substitute an inventory-only apply: fresh Git/PR revalidation is required, but every path providing it hangs. This pushes operators toward manual deletion or retaining hundreds of stale worktrees.

Expected

  • cleanup plan returns a persisted run ID or a structured creation failure with the owning job/database error.
  • Every bounded command honors --limit and returns partial evidence within a normal operator timeout.
  • Long GitHub/Git checks emit progress and a continuation cursor.
  • Per-repository auth/API failures degrade to explicit skipped rows instead of stalling the whole page.
  • Open PR worktrees remain protected even if lifecycle metadata says cleanup_eligible.

Acceptance criteria

  • Reproduce with 400+ registered worktrees and 15 cleanup-eligible rows.
  • bounded-cleanup-eligible-apply --dry-run --limit=15 returns within 30 seconds or returns a budgeted partial page.
  • active-no-signal-merged-apply --dry-run --limit=100 emits progress/continuation rather than remaining silent.
  • Planner creation errors include a stable reason code, underlying exception/job evidence, and retry command.
  • Tests cover unavailable GitHub App token exchange, slow GitHub responses, and mixed open/merged PR candidates without N-times credential retry amplification.
  • Existing dirty, unpushed, primary, containment, and open-PR protections remain fail-closed.

Related

AI assistance

  • AI assistance: Yes
  • Model: OpenAI GPT-5.6 Sol
  • Tool: OpenCode
  • Used for: command reproduction, duplicate search, safety analysis, and issue drafting

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