You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three correctness gaps called out in the bugfix plan: (1) after seed() + first poll_once(), probe hits from run_cycle() are never passed to notify_callback, so genuinely new discoveries on a restart with existing DB are dropped while cold first-deploy silence is correct; (2) _extra_health_fields exposes a misleading probe_hit_rate; (3) diff_snapshots sorts new_papers but not updated_papers, producing unstable ordering for logs/UI.
Acceptance Criteria
§1 Seed / restart notifications (monitor.py)
At the top of seed(), before any work, set had_prior_state = state.last_poll > 0 or len(state.get_all_discovered()) > 0 (or equivalent using existing ProbeState API).
seed() returns probe hits from prober.run_cycle() (or [] if ISO probe disabled) together with had_prior_state (dataclass or tuple).
Remove redundant for hit in hits: state.mark_discovered(hit.url) in seed() if run_cycle() already persists every hit (verify in sources.py).
Update seed() docstring per plan: first-run gathers state; seed-time notifications are only emitted from poll_once when had_prior_state is true.
In poll_once’s if not self._seeded branch: if had_prior_state, filter recent_hits / old_hits like the steady-state path, asyncio.to_thread(matches_for_users, [], recent_hits), build PollResult with empty diff, probe_hits=recent_hits, dp_transitions=[], per_user_matches=..., and call notify_callback when set; if not had_prior_state, keep today’s silent first poll (empty PollResult, no callback).
Tests in tests/test_monitor.py: cold DB → first poll does not call notify_callback for seed probe hits; DB with prior poll or at least one discovered URL → recent seed hits do flow to notify_callback; update any test that assumed notify never runs on first poll.
§4 Health JSON (__main__.py)
Rename probe_hit_rate to probe_success_rate (or fix numerator to include hit_no_lm) per plan; denominator aligned with definition; comment updated.
§6 Optional diff ordering (monitor.py)
Sort updated_papers in diff_snapshots the same way as new_papers (e.g. by date desc, then id); add or adjust a test in tests/test_monitor.py.
Problem
Three correctness gaps called out in the bugfix plan: (1) after
seed()+ firstpoll_once(), probe hits fromrun_cycle()are never passed tonotify_callback, so genuinely new discoveries on a restart with existing DB are dropped while cold first-deploy silence is correct; (2)_extra_health_fieldsexposes a misleadingprobe_hit_rate; (3)diff_snapshotssortsnew_papersbut notupdated_papers, producing unstable ordering for logs/UI.Acceptance Criteria
§1 Seed / restart notifications (
monitor.py)seed(), before any work, sethad_prior_state = state.last_poll > 0 or len(state.get_all_discovered()) > 0(or equivalent using existingProbeStateAPI).seed()returns probe hits fromprober.run_cycle()(or[]if ISO probe disabled) together withhad_prior_state(dataclass or tuple).for hit in hits: state.mark_discovered(hit.url)inseed()ifrun_cycle()already persists every hit (verify insources.py).seed()docstring per plan: first-run gathers state; seed-time notifications are only emitted frompoll_oncewhenhad_prior_stateis true.poll_once’sif not self._seededbranch: ifhad_prior_state, filterrecent_hits/old_hitslike the steady-state path,asyncio.to_thread(matches_for_users, [], recent_hits), buildPollResultwith empty diff,probe_hits=recent_hits,dp_transitions=[],per_user_matches=..., and callnotify_callbackwhen set; if nothad_prior_state, keep today’s silent first poll (emptyPollResult, no callback).tests/test_monitor.py: cold DB → first poll does not callnotify_callbackfor seed probe hits; DB with prior poll or at least one discovered URL → recent seed hits do flow tonotify_callback; update any test that assumed notify never runs on first poll.§4 Health JSON (
__main__.py)probe_hit_ratetoprobe_success_rate(or fix numerator to includehit_no_lm) per plan; denominator aligned with definition; comment updated.§6 Optional diff ordering (
monitor.py)updated_papersindiff_snapshotsthe same way asnew_papers(e.g. bydatedesc, thenid); add or adjust a test intests/test_monitor.py.Implementation Notes
Coordinate with issue_09.md (Last-Modified / probe), issue_04.md (
Paper.from_index_entry), issue_05.md and issue_07.md for remaining plan §3 and §5 items. Resolving all week_3 issues including this one closes the full paperscout_bugfix_bundle_27f91caa.plan.md.References
src/paperscout/monitor.py,src/paperscout/__main__.py,tests/test_monitor.py