Skip to content

Replace watchlist match reasons with MatchReason enum#60

Merged
wpak-ai merged 1 commit into
developfrom
feat/match-reason-enum
Jun 11, 2026
Merged

Replace watchlist match reasons with MatchReason enum#60
wpak-ai merged 1 commit into
developfrom
feat/match-reason-enum

Conversation

@henry0816191

@henry0816191 henry0816191 commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace bare "author" / "paper" match-reason strings with a typed MatchReason(str, Enum) in the watchlist match pipeline. Producers, PerUserMatches, and tests now use enum members; Slack tags use reason.value for display.

Changes

  • models.py: Add MatchReason (AUTHOR, PAPER); type PerUserMatches tuples as MatchReason.
  • storage.py: matches_for_users() emits MatchReason.AUTHOR / MatchReason.PAPER.
  • scout.py: notify_users() formats tags with reason.value (Python 3.14-safe).
  • Tests: test_monitor.py, test_scout.py, test_storage.py — imports and tuple literals updated.

Out of scope: DB watchlist entry_type strings and Slack watchlist UI labels.

Acceptance criteria

Criterion Status
MatchReason enum in models.py Done
PerUserMatches uses MatchReason Done
Producers emit enum members Done
Consumers use .value for display Done
Tests updated; no regressions Done (360 passed)
mypy — no new errors Done (3 pre-existing elsewhere)

Test plan

  • ./run cov — 360 passed, 94% coverage
  • ./run check in CI
  • PR approved by at least 1 reviewer

Related

Summary by CodeRabbit

  • Refactor

    • Internal match classification standardized to a structured enum, improving consistency of match-reason labels shown in watchlist notifications.
  • Tests

    • Test suite updated to validate the new match classification across monitoring and notification flows.

@henry0816191 henry0816191 requested a review from wpak-ai as a code owner June 11, 2026 15:11
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d790323-ec3c-4c6b-a303-2b08f5fd2ef8

📥 Commits

Reviewing files that changed from the base of the PR and between 5a6f574 and 44b8ebb.

📒 Files selected for processing (6)
  • src/paperscout/models.py
  • src/paperscout/scout.py
  • src/paperscout/storage.py
  • tests/test_monitor.py
  • tests/test_scout.py
  • tests/test_storage.py

📝 Walkthrough

Walkthrough

Replaces string match reasons with a new MatchReason enum, updates PerUserMatches typing, makes storage emit enum members, updates scout DM formatting to use reason.value, and adjusts tests to use the enum.

Changes

Match Reason Type Safety

Layer / File(s) Summary
MatchReason enum and PerUserMatches schema
src/paperscout/models.py
New MatchReason enum with AUTHOR and PAPER; PerUserMatches now stores `(Paper
Storage producer match reason emission
src/paperscout/storage.py
Import added for MatchReason; UserWatchlist.matches_for_users() emits MatchReason.AUTHOR/MatchReason.PAPER instead of string literals.
Scout notification formatting
src/paperscout/scout.py
notify_users() uses reason.value when composing paper-match and probe-hit bullets for Slack DMs.
Test fixtures and assertions
tests/test_monitor.py, tests/test_scout.py, tests/test_storage.py
Tests updated to import MatchReason and construct/assert PerUserMatches using enum members rather than raw string literals.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • cppalliance/paperscout#25: Earlier refactor that introduced/moved PerUserMatches, related to this PR's tuple-shape/type changes.

Suggested reviewers

  • wpak-ai

Poem

🐰 I swapped the bare strings for enum light,
Now reasons are typed and notifications right.
No stray typos hopping in the night,
MatchReason keeps the match tag bright.
Hoppy PR—typed and tight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: introducing a MatchReason enum to replace string-based match reasons.
Description check ✅ Passed The description includes summary, detailed changes across all modified files, acceptance criteria, and test plan as required by the template.
Linked Issues check ✅ Passed All objectives from issue #57 are met: MatchReason enum added [models.py], PerUserMatches types updated [models.py], producers emit enum members [storage.py], consumers use .value [scout.py], tests updated [test files], type checking clean [reported].
Out of Scope Changes check ✅ Passed All changes are directly related to replacing string match reasons with the MatchReason enum. No out-of-scope modifications detected in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/match-reason-enum

Comment @coderabbitai help to get the list of available commands and usage tips.

@henry0816191

Copy link
Copy Markdown
Collaborator Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@henry0816191

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@wpak-ai wpak-ai merged commit ee54b2b into develop Jun 11, 2026
10 checks passed
@wpak-ai wpak-ai deleted the feat/match-reason-enum branch June 11, 2026 20:12
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.

Replace bare string match reasons with MatchReason enum

2 participants