Repository navigation
fix(collector): retire deleted worktrees instead of failing the git source - #83
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=gitevery 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,drigashowedstale: git (116h), so branch, dirty and commit info for every healthy repo was stale too.Risk and rollout
0008_worktree_scan_error.sql: additive, a nullable per-worktree scan-error column. A downgrade ignores it.Contract changes
None
Verified
internal/collectorandinternal/gitscanfor a deleted worktree, a directory without.git, a corrupted.gitpointer, and a healthy worktree updating alongside them. Each failed before the fix..backupcopy of the real database in a temporary data dir: zerocollector_source_failedwarnings, anddrigareports no stale git source.go testfor collector, gitscan, cleanup and store, plus theTZ=UTCruns.go vetpasses natively and for Linux and Windows.https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4