Skip to content

Logical bugfix bundle — monitor seed, health JSON, diff ordering #30

@henry0816191

Description

@henry0816191

Problem

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.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions