Skip to content

feat: Add clear orphans command - #243

Merged
Pringled merged 3 commits into
MinishLab:mainfrom
jedijashwa:clear-orphans
Aug 4, 2026
Merged

feat: Add clear orphans command#243
Pringled merged 3 commits into
MinishLab:mainfrom
jedijashwa:clear-orphans

Conversation

@jedijashwa

Copy link
Copy Markdown
Contributor

Closes #236

Adds a semble clear orphans subcommand along the lines suggested in the issue: it walks the sha-named cache entries, reads root_path from each metadata.json, only considers entries whose dir name matches the cache key for the resolved root_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_folder into a cache_key helper so the orphan check uses the same key computation instead of duplicating it. Ruff's complexity limit also made me split _run_clear into per-type helpers.

make test, make lint, and make typecheck all pass. Also tested end to end against my real cache: indexed a scratch dir, deleted it, ran semble clear orphans, and it removed just that entry and nothing else. A second run prints the no-orphans message.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The 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 .get() directly on decoded JSON leaves a concrete counterexample: a valid non-object document raises before the new root_path guard. The previously reported unavailable-source path also remains unchanged, with a failed existence check directly leading to cache deletion.

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

Comment thread src/semble/cli.py
Comment thread src/semble/cli.py Outdated
Comment thread src/semble/cli.py Outdated
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/semble/cache.py 100.00% <100.00%> (ø)
src/semble/cli.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pringled Pringled left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jedijashwa LGTM, thanks for contributing! We'll include this in the next release 😄

@Pringled
Pringled merged commit ca197f7 into MinishLab:main Aug 4, 2026
16 checks passed
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.

cache entries for deleted directories are never cleaned up

2 participants