Skip to content

feat: search loop scoring integration & tiered cooldowns#79

Closed
menottim wants to merge 3 commits intofeat/search-scoringfrom
feat/search-loop-intelligence
Closed

feat: search loop scoring integration & tiered cooldowns#79
menottim wants to merge 3 commits intofeat/search-scoringfrom
feat/search-loop-intelligence

Conversation

@menottim
Copy link
Copy Markdown
Owner

@menottim menottim commented Mar 1, 2026

Summary

  • Tiered cooldown service: replaces 24h in-memory cooldown with persistent DB-backed cooldowns varying by item age (6h to 7d) with exponential backoff on failures (capped at 14 days)
  • Search loop refactor: fetch all → score → sort → filter → search top N flow. Items scored by recency, attempts, and staleness with strategy-specific weights
  • Batch limits: max_items_per_run (default 50) truncates scored items
  • Search tracking: updates LibraryItem.search_attempts and last_searched_at after each search
  • Enhanced search log: entries now include score, score_reason, item_id, series_id

New files

  • src/splintarr/services/cooldown.py — tiered cooldown engine
  • tests/unit/test_cooldown.py — 29 tests

Test plan

  • 108 passed, 7 pre-existing errors (unchanged fixture issues)
  • Manual: verify items sorted by score in search log
  • Manual: verify tiered cooldowns respect item age
  • Manual: verify max_items_per_run limits search count

🤖 Generated with Claude Code

menottim and others added 3 commits February 28, 2026 18:05
Implement cooldown.py with adaptive and flat cooldown modes for search
items. Adaptive mode uses content age to determine base cooldown (6h for
<24h old, up to 7d for >1yr old) with exponential backoff on consecutive
failures, capped at 14 days. Flat mode uses a fixed configurable period.

Includes 29 unit tests covering all tiers, backoff, cap, and edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Refactor _search_paginated_records to use intelligent search ordering:
1. Fetch ALL pages into a flat list via new _fetch_all_records helper
2. Batch-load LibraryItem data from DB via _load_library_items
3. Score each item using compute_score() from the scoring engine
4. Sort by score descending (highest priority items first)
5. Filter out excluded and cooldown items
6. Truncate to queue.max_items_per_run
7. Search remaining items, updating LibraryItem.search_attempts

Replace in-memory cooldown dict with DB-backed tiered cooldowns from
the cooldown service. Search log entries now include score, score_reason,
item_id, and series_id for better observability.

Update existing tests to work with the new flow (ExclusionService mock,
library item loading, queue config attributes).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
items_evaluated = total records from API (before filtering)
items_searched = items that passed scoring/filtering and were searched

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@menottim menottim force-pushed the feat/search-loop-intelligence branch from e4b29cd to 5f00065 Compare March 1, 2026 02:06
@menottim menottim deleted the branch feat/search-scoring March 1, 2026 02:07
@menottim menottim closed this Mar 1, 2026
@menottim menottim deleted the feat/search-loop-intelligence branch March 2, 2026 19:53
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.

1 participant