Closes#486. Scans a redeploy interrupted left broken cache entries
(an empty directory: "could not find repository"; a half-written
FETCH_HEAD: "corrupted loose reference file"), and every scheduled scan
of those targets failed after it.
- Before a fetch: FETCH_HEAD (every fetch writes it anew) and *.lock
files under .git are removed; a target's scans never overlap, so no
other git holds them.
- An entry that does not open as a repository with an origin is removed
and cloned again; a fetch that fails with a corruption-class error
(repository, reference, object database, object, index, checkout) does
the same, once, with a WARN naming tenant and target. Network and
remote errors still fail the scan, and the stored remote is still
checked before any fetch.
- Clones go into `.<name>.cloning-<uuid>` beside the entry and are renamed
into place, so an interrupted clone never leaves a half entry; leftovers
of an earlier one are removed.
- Tests: empty directory, garbage FETCH_HEAD and leftover locks, the
error classification, an atomic clone from a real repository with a
leftover temp dir, a failing clone leaving nothing; the existing
stored-remote recheck stays green.
- Staging test plan: check 14.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p