Skip to content

fix(collector): retire deleted worktrees instead of failing the git source - #83

Merged
vishr merged 1 commit into
mainfrom
fix/git-source-gone-worktrees
Oct 30, 2026
Merged

vishr merged 1 commit into
mainfrom
fix/git-source-gone-worktrees

Conversation

@vishr

@vishr vishr commented Oct 30, 2026

Copy link
Copy Markdown
Member

What changed

The collector's git source no longer fails as a whole when a stored worktree's directory has been deleted or is no longer a git checkout. Such worktrees are retired and no longer polled, and they drop out of cleanup candidates. Any other per-worktree git error is recorded on that worktree and logged once per distinct error, while healthy worktrees keep updating.

Why

On a real Mac the service logged collector source failed ... source=git every pass, 1,215 times. The cause was worktrees under /private/tmp/ whose folders were gone (fatal: not a git repository). Because one failure failed the whole source, driga showed stale: git (116h), so branch, dirty and commit info for every healthy repo was stale too.

Risk and rollout

  • Migration 0008_worktree_scan_error.sql: additive, a nullable per-worktree scan-error column. A downgrade ignores it.
  • Nothing is written to agent settings, no new text is stored, and no process signalling.
  • Retiring follows existing conventions for removed rows. A worktree that reappears is picked up again by the scanner.

Contract changes

None

Verified

  • Regression tests in internal/collector and internal/gitscan for a deleted worktree, a directory without .git, a corrupted .git pointer, and a healthy worktree updating alongside them. Each failed before the fix.
  • Ran the fixed collector for 100 s on a .backup copy of the real database in a temporary data dir: zero collector_source_failed warnings, and driga reports no stale git source.
  • go test for collector, gitscan, cleanup and store, plus the TZ=UTC runs. go vet passes natively and for Linux and Windows.
  • I have accepted the CLA, or will when the bot asks on my first pull request.

https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4

…ource

Git keeps registrations for deleted checkouts, including directories whose
.git marker has disappeared. Skip those entries before enrichment and let
inventory reconciliation retire their store rows and cleanup candidates.

Keep status and log failures on the affected worktree, preserving its last
successful observation while healthy checkouts update and source freshness
advances. Persist scrubbed diagnostics and deduplicate logs by checkout and
distinct error, including across scanner restarts. Retry failed scans and
clear the diagnostic after recovery.

Add real Git regression tests for missing directories and markers, corrupt
gitdir pointers, healthy updates, cleanup exclusion, recovery, and log
suppression. The missing-marker and corruption cases failed before the fix.
Native and UTC package tests and native, Linux, and Windows vet checks pass.

Claude-Session: https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4
@vishr
vishr merged commit 1df5132 into main Oct 30, 2026
6 checks passed
@vishr
vishr deleted the fix/git-source-gone-worktrees branch October 30, 2026 15:46
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