feat: add cache prune-scores to drop outdated match results - #18
Merged
Merged
Conversation
Removes job_matches rows that no longer reflect the current scoring setup so the next search or `assess` recomputes them. Until now bumping matching.PROMPT_VERSION left the old rows in place with no way to clear them short of wiping the whole cache. prune-scores drop rows whose prompt_version differs prune-scores --stale-cv also drop rows belonging to any CV but the latest prune-scores --orphans also drop rows whose job is gone from job_cache Counts are previewed and confirmed before deletion (--yes skips the prompt). The three conditions can match the same row, so each is reported separately next to a de-duplicated total. Verified on the test database, which held 4 match_v9:zh rows: the command reported 4 and left the table empty. On the real cache the no-arg form correctly reports nothing to clean (all rows are match_v11:zh) while --stale-cv identifies 309 rows from previous CVs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012DbPx4FbswofbGn41anE1q
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.
清单最后一项。#15 / #16 / #17 把评分统一到了
job_matches(按(job_id, cv_hash)归属,带prompt_version),但一直没有清理过时行的手段——bumpmatching.PROMPT_VERSION之后,旧行会留在库里,除非cache clear整个清空。用法
删除前先预览计数并要求确认。三个条件可能命中同一行,因此分类计数与去重后的
total分开报告。实现
cache.prune_job_matches(*, prompt_version, keep_cv_hash, drop_orphans, dry_run)返回各分类计数 +total+deleted。条件独立启用;一个条件都不启用时是 no-op(不会误删全表)。CLI 先dry_run=True拿预览,确认后再实际执行。验证
单测 6 个(
TestPruneJobMatches):dry-run 不删除、只删过时版本、--stale-cv可选、孤儿行仅在请求时删除、重叠行在total里只算一次、无条件时 no-op。全量 241 passed。真实数据库端到端:
正式库的 309 条我没有删——那是历史 CV 的评分,是否保留由你决定。
🤖 Generated with Claude Code
https://claude.ai/code/session_012DbPx4FbswofbGn41anE1q