Skip to content

fix: detect and recover from corrupted git clones in plugin cache#14

Merged
gzb1128 merged 1 commit into
mainfrom
fix/corrupted-clone-recovery
Jun 12, 2026
Merged

fix: detect and recover from corrupted git clones in plugin cache#14
gzb1128 merged 1 commit into
mainfrom
fix/corrupted-clone-recovery

Conversation

@gzb1128

@gzb1128 gzb1128 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Problem

When a remote plugin git clone failed or was interrupted, the cache directory was left in a broken state (temp pack file, no refs, no working tree). Subsequent plugin install calls skipped re-cloning because the cache directory existed, so generateFallbackManifest created plugin.json from marketplace metadata and the symlink step silently linked 0 skills.

Changes

  • installer.gomaterializePlugin: validate cache integrity before skipping clone. Uses git.PlainOpen + repo.Head() to detect broken repos (handles packed-refs and detached HEAD correctly). Evicts corrupted cache with proper error handling.
  • installer.goisRepoHealthy: replaces the hand-rolled isValidGitRepo (which checked .git/refs/heads entries — broken for packed-refs repos).
  • version.gocloneGitSource: add post-clone validation (PlainOpen + Head()) to catch incomplete clones immediately. Clean up cache on any clone error to prevent broken state persisting.

Test plan

  • All existing tests pass (go test ./...)
  • Manually verified: removed broken superpowers cache, re-installed → 14 skills linked correctly
  • go vet passes

When a plugin git clone failed or was interrupted, the cache directory
was left in a broken state (temp pack file, no refs). Subsequent
installs skipped re-cloning because the directory existed, resulting in
zero skills being symlinked.

- Add isRepoHealthy() using git.PlainOpen + repo.Head() to validate
  cache integrity (handles packed-refs and detached HEAD correctly)
- Add post-clone validation in cloneGitSource to detect incomplete clones
- Clean up cache on clone failure to prevent broken state persisting
- Handle os.RemoveAll error when evicting corrupted cache
@gzb1128 gzb1128 merged commit 218c05e into main Jun 12, 2026
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