feat(cleaner): per-item delete strategy via DeleteMethod contract - #26
Merged
Conversation
Path-only deletion couldn't express command/API reclaims (docker rmi, vendor prunes). ScanResult now carries an optional DeleteMethod (kind path/command/api + display + Run); the cleaner applies its protected/dry-run gates uniformly, then runs the method or falls back to trash/force. A method without Run is refused rather than falling back to path removal. VendorCleanup embeds the same DeleteMethod, so bulk and per-item reclaims share one execution contract. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013SX3vRs78zFYA2kTRZAtg6
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.
Summary
model.DeleteMethod(kindpath/command/api+ display string +Runclosure) expresses non-path reclaims per scan item;ScanResult.Deleteis optional and nil means path removal, so existing scanners are untouchedRunis refused instead of falling back — a misconfigured item can never delete a path its method didn't intendClean/CleanAllnow take acontext.Contextso command-based reclaims are cancellableVendorCleanupembeds the sameDeleteMethod— ecosystem-level bulk actions and per-item reclaims share one execution contractdocs/architecture.md, key decision line inCLAUDE.mdUnblocks #17 (per-item Docker image/volume reclaims) and #20 (vendor cleanup expansion).
Closes #16
Test plan
"delete":{"kind","display"}surfaces,Runnever serializes, nil omittedRuninvoked with path untouched (even under Force), dry-run and protected skipRun,Runerror propagation, nil-Runrefusal leaves path intact, mixed path/methodCleanAllgo test -count=1 ./...green across all packages;golangci-lint run0 issues; golden testdata unchanged (scan JSON output identical for existing scanners)clean --vendor-cleanup --dry-runprints the vendor command preview via the embeddedDisplay🤖 Generated with Claude Code
https://claude.ai/code/session_013SX3vRs78zFYA2kTRZAtg6