feat: Add clear orphans command - #243
Conversation
Confidence Score: 4/5The PR is not yet safe to merge because malformed metadata can abort cleanup and temporarily unavailable sources can still lose their cached indexes. The type-validation reply reports the metadata issue fixed, but calling Files Needing Attention: src/semble/cli.py, tests/test_cli.py Reviews (2): Last reviewed commit: "fix: Validate root_path type when cleari..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Pringled
left a comment
There was a problem hiding this comment.
@jedijashwa LGTM, thanks for contributing! We'll include this in the next release 😄
Closes #236
Adds a
semble clear orphanssubcommand along the lines suggested in the issue: it walks the sha-named cache entries, readsroot_pathfrom each metadata.json, only considers entries whose dir name matches the cache key for the resolvedroot_path(which filters out git-URL entries), and removes the ones whose path no longer exists. Prints each cleared path, or "No orphaned indexes found".I pulled the hashing out of
find_index_from_cache_folderinto acache_keyhelper so the orphan check uses the same key computation instead of duplicating it. Ruff's complexity limit also made me split_run_clearinto per-type helpers.make test,make lint, andmake typecheckall pass. Also tested end to end against my real cache: indexed a scratch dir, deleted it, ransemble clear orphans, and it removed just that entry and nothing else. A second run prints the no-orphans message.