Handle removed/orphaned worktrees gracefully (registry↔filesystem drift) — a missing worktree dir should not break ingest
flower-ops · submitted 4 days ago
detail
What they reported
Worktrees get removed in many normal scenarios (worktree-manager remove, manual rm, merged+cleaned branches), leaving the worktree DB row orphaned — registry↔filesystem drift. Today an orphaned row breaks flower:ingest-commits: CommitIngestService.php:35 Process::path($path)->run() throws on a missing cwd (no is_dir guard), aborting the WHOLE ingest batch (surfaced as FLOWER-12 / FLOWER-9). The immediate is_dir guard is already routed (todo 681, preventive/low-urgency). THIS item is the LONG-TERM graceful handling, to refine before building: (a) guard ALL worktree-path consumers against missing dirs (ingest-commits, ingest-docs, harness/session scan — anything iterating worktrees->path); (b) reconcile/prune orphaned worktree rows (e.g. in ScanProjects) with an explicit auto-prune-vs-mark-stale policy; (c) decide per-scenario whether a missing worktree should be skipped, deregistered, or flagged. Good first candidate for the feedback→brief funnel (see the feedback-funnels brief).
context
Structured context
{
"scope": "long-term graceful handling; refine before build",
"routed": {
"target": "brief",
"brief_id": 140,
"authority": "operator_approval",
"routed_at": "2026-07-03T13:20:04+00:00",
"routed_by": "operator:mike",
"project_id": 16,
"approved_at": "2026-07-04T03:21:17+00:00",
"approved_by": "operator:mike",
"approval_status": "approved",
"default_project_id": 16,
"needs_operator_approval": false
},
"related_sentry": [
"FLOWER-12",
"FLOWER-9"
],
"promotion_ledger": [
{
"at": "2026-07-03T13:20:04+00:00",
"action": "brief_created",
"target": "brief",
"brief_id": 140,
"actor_ref": "operator:mike",
"cycle_key": "2026070313"
},
{
"at": "2026-07-04T03:21:17+00:00",
"action": "approved",
"target": "brief",
"brief_id": 140,
"actor_ref": "operator:mike"
},
{
"at": "2026-07-04T08:53:09+00:00",
"action": "source_brief_completed",
"target": "brief",
"brief_id": 140,
"actor_ref": "flower-140-orphaned-worktrees-worker"
}
],
"immediate_fix_spec": 1025,
"immediate_fix_todo": 681
}promoted · work
Linked brief
state · operator override
Lifecycle
- created
- 4d ago
- triaged
- 2d ago
- resolved
- 1d ago
- resolved by
- flower-140-orphaned-worktrees-worker
resolution
Brief #140: Feedback #27: Handle removed/orphaned worktrees gracefully (registry↔filesystem drift) — a missing worktree dir should not break ingest