Skip to content

feat(cleaner): per-item delete strategy via DeleteMethod contract - #26

Merged
ohing504 merged 1 commit into
mainfrom
feat/delete-strategy
Jul 17, 2026
Merged

feat(cleaner): per-item delete strategy via DeleteMethod contract#26
ohing504 merged 1 commit into
mainfrom
feat/delete-strategy

Conversation

@ohing504

Copy link
Copy Markdown
Owner

Summary

  • model.DeleteMethod (kind path/command/api + display string + Run closure) expresses non-path reclaims per scan item; ScanResult.Delete is optional and nil means path removal, so existing scanners are untouched
  • cleaner applies its protected/dry-run gates uniformly across strategies, then delegates to the attached method or falls back to trash/force; a method without Run is refused instead of falling back — a misconfigured item can never delete a path its method didn't intend
  • Clean/CleanAll now take a context.Context so command-based reclaims are cancellable
  • VendorCleanup embeds the same DeleteMethod — ecosystem-level bulk actions and per-item reclaims share one execution contract
  • docs: new "Deletion Strategy" section in docs/architecture.md, key decision line in CLAUDE.md

Unblocks #17 (per-item Docker image/volume reclaims) and #20 (vendor cleanup expansion).

Closes #16

Test plan

  • new model tests: strategy resolution (nil → path), JSON shape — "delete":{"kind","display"} surfaces, Run never serializes, nil omitted
  • new cleaner tests: method Run invoked with path untouched (even under Force), dry-run and protected skip Run, Run error propagation, nil-Run refusal leaves path intact, mixed path/method CleanAll
  • go test -count=1 ./... green across all packages; golangci-lint run 0 issues; golden testdata unchanged (scan JSON output identical for existing scanners)
  • manual clean --vendor-cleanup --dry-run prints the vendor command preview via the embedded Display

🤖 Generated with Claude Code

https://claude.ai/code/session_013SX3vRs78zFYA2kTRZAtg6

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
@ohing504
ohing504 merged commit 661aa44 into main Jul 17, 2026
3 checks passed
@ohing504
ohing504 deleted the feat/delete-strategy branch July 17, 2026 15:57
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.

삭제전략 추상화 (path/command/api Deleter 계약)

1 participant