Skip to content

feat: search result feedback loop with grab detection#80

Closed
menottim wants to merge 3 commits intofeat/search-loop-intelligencefrom
feat/search-feedback-loop
Closed

feat: search result feedback loop with grab detection#80
menottim wants to merge 3 commits intofeat/search-loop-intelligencefrom
feat/search-feedback-loop

Conversation

@menottim
Copy link
Copy Markdown
Owner

@menottim menottim commented Mar 1, 2026

Summary

  • FeedbackCheckService: polls Sonarr/Radarr command statuses after search runs to detect grabs
  • Scheduled feedback: one-shot APScheduler job fires 15 min after search completion (configurable)
  • Grab tracking: updates LibraryItem.grabs_confirmed and last_grab_at on confirmed grabs
  • Metadata enrichment: search_metadata entries annotated with grab_confirmed flag

New files

  • src/splintarr/services/feedback.py — FeedbackCheckService
  • tests/unit/test_feedback.py — 10 tests

Test plan

  • 113 passed (10 new feedback + 103 existing)
  • Manual: trigger search, wait 15 min, verify command statuses polled
  • Manual: verify LibraryItem grabs_confirmed incremented

🤖 Generated with Claude Code

@menottim menottim force-pushed the feat/search-loop-intelligence branch from e4b29cd to 5f00065 Compare March 1, 2026 02:06
menottim and others added 3 commits February 28, 2026 18:07
Introduces the search-result feedback loop service that polls Sonarr/Radarr
command statuses after searches to determine whether content was grabbed.
Updates LibraryItem.record_grab() on confirmed grabs and enriches
SearchHistory.search_metadata with grab_confirmed flags.

Includes 10 unit tests covering: missing history/instance, no searchable
commands, Sonarr/Radarr grab confirmed/unconfirmed, incomplete commands,
client exceptions with partial results, and invalid metadata handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds _execute_feedback_check method to SearchScheduler that creates a
DB session and delegates to FeedbackCheckService. In execute_queue(),
schedules a one-shot APScheduler job after successful search runs with
searches_triggered > 0, delayed by feedback_check_delay_minutes (default
15min) to allow time for downloads to complete before checking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents SQLAlchemy session from being left in invalid state after
a failed commit in _save_metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@menottim menottim force-pushed the feat/search-feedback-loop branch from 59d341b to 959bfcf Compare March 1, 2026 02:07
@menottim
Copy link
Copy Markdown
Owner Author

menottim commented Mar 1, 2026

Code review

Found 1 issue:

  1. Three log statements in the feedback check path are missing the required instance_id context field, even though instance_id is in scope at each call site. CLAUDE.md says "Always include relevant correlation fields: instance_id for any instance-scoped operation" and "queue_id for search queue operations".

    • _execute_feedback_check logs feedback_check_execution_failed with history_id but omits the instance_id parameter:

      except Exception as e:
      logger.error("feedback_check_execution_failed", history_id=history_id, error=str(e))
      finally:

    • execute_queue logs feedback_check_schedule_failed with only error, omitting both queue_id and instance_id which are in scope:

      except Exception as e:
      logger.warning("feedback_check_schedule_failed", error=str(e))

    • check_search_results logs feedback_check_command_failed with command_id but omits instance_id:

      logger.warning(
      "feedback_check_command_failed",
      command_id=command_id,
      error=str(e),
      )
      entry["grab_confirmed"] = None # unknown

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@menottim
Copy link
Copy Markdown
Owner Author

menottim commented Mar 1, 2026

Code reviewed and verified. Already merged to main via local merge (dec886d). Tests pass with no regressions (80 pre-existing failures, 663 passed). One logging issue noted in review comment — missing instance_id context fields on 3 log statements.

@menottim menottim closed this Mar 1, 2026
@menottim menottim deleted the feat/search-feedback-loop 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