restart notify, probe_success_rate, diff sort#44
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors scheduler seeding to return probe hits plus a prior-state flag and conditionally emit seed notifications on restart; renames health metric to ChangesSeed restart notifications, metrics, and ordering bugfix bundle
Sequence Diagram(s)sequenceDiagram
participant PollOnce
participant Scheduler.seed
participant ProbeState
participant DB
participant notify_callback
PollOnce->>Scheduler.seed: call seed()
Scheduler.seed->>ProbeState: read last_poll & discovered_present?
Scheduler.seed->>Scheduler.seed: prober.run_cycle() -> probe_hits
Scheduler.seed-->>PollOnce: return SeedResult(probe_hits, had_prior_state)
alt had_prior_state == false
PollOnce-->>PollOnce: return empty PollResult (cold start)
else had_prior_state == true
PollOnce->>DB: matches_for_users(recent_hits) (blocking)
PollOnce->>notify_callback: invoke with PollResult(probe_hits=recent_hits, per_user_matches=...)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/paperscout/monitor.py`:
- Around line 170-173: The code updates `_last_successful_poll` and
`_last_probe_stats` immediately after `seed_result = await self.seed()` which
can mark a poll successful even if subsequent steps like
`self.matches_for_users(...)` or `self.notify_callback(...)` fail; move the
bookkeeping (assignments to `_last_successful_poll` and `_last_probe_stats`) to
the very end of the restart-first-poll path—i.e., after `matches_for_users` and
`notify_callback` have completed without error—to ensure only fully completed
polls are recorded; apply the same relocation in the other restart-first-poll
occurrences (the blocks around the other two sites referenced) so all three code
paths set those fields only after successful notification and matching.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 76ad56dd-a2d4-4f5e-9aa2-0012f80529c1
📒 Files selected for processing (4)
src/paperscout/__main__.pysrc/paperscout/monitor.pytests/test_health.pytests/test_monitor.py
Summary
Changes
monitor.py
SeedResult; seed() captures had_prior_state before work; first poll_once() branch for restart notify; shared sort key for new/updated papers
main.py
probe_success_rate in /health extra fields
tests/test_monitor.py
Cold start vs restart notify tests; updated_papers sort test; test_seed_marks_discovered updated for run_cycle-only discovery
tests/test_health.py
Fixture key renamed to probe_success_rate
Breaking change (operators): /health JSON field probe_hit_rate is now probe_success_rate with a corrected definition. Update any dashboards or alerts that read the old name.
Test plan
uv run pytest tests/test_monitor.py tests/test_health.py -q (50 passed)
uv run pytest tests/ -q (318 passed, 2 skipped)
Manual: restart with populated DB (last_poll / discovered_urls); confirm first poll notifies only for recent seed probe hits, not cold deploy noise
Related issues
close #30
Summary by CodeRabbit
Improvements
Tests