Skip to content

fix: only exclude confirmed jargon from candidate statistics - #246

Merged
EterUltimate merged 2 commits into
mainfrom
fix/jargon-confirm-filter-3.6.4
Aug 29, 2026
Merged

EterUltimate merged 2 commits into
mainfrom
fix/jargon-confirm-filter-3.6.4

Conversation

@EterUltimate

@EterUltimate EterUltimate commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

问题

修复 #245「黑话被收录后长时间无法解释」:候选统计的排除查询未区分确认状态,把 is_jargon IS NULL 的待确认词条一并排除,导致候选出现次数始终无法累加到推断阈值,黑话词条被收录后长期停留在待确认状态、无法触发含义推断。

修复

  • services/learning/jargon_learning.py:统计排除查询显式传入 only_confirmed=True,只排除已确认黑话;待确认候选继续参与统计,重复出现时正常累加 count,达到 3 次后触发含义推断。同步更新 _get_existing_jargon_terms() 方法说明。
  • services/core_learning/v2_learning_integration.py:V2 批处理路径应用相同过滤,避免启用 V2 学习时出现相同问题。

测试

  • 新增 tests/unit/test_jargon_learning.py,覆盖:查询正确传递 only_confirmed=True;旧版学习流程不再排除待确认候选;V2 黑话批处理流程使用相同的确认状态过滤。

Fixes #245

Summary by Sourcery

Fix jargon candidate tracking so pending entries remain eligible for repeated-occurrence counting and meaning inference.

Bug Fixes:

  • Ensure jargon candidate statistics exclude only confirmed jargon, allowing pending candidates to continue accumulating occurrences and reach meaning-inference thresholds in both learning paths.

Documentation:

  • Document the 3.6.4 release and update user-facing version references.

Tests:

  • Add unit coverage for confirmed-only filtering in legacy and V2 jargon learning flows.

Chores:

  • Bump the plugin, runtime package, Dashboard, and documentation versions to 3.6.4.

The statistics pre-filter exclusion query did not distinguish
confirmation state, so unconfirmed candidates (is_jargon IS NULL)
were excluded as well and their occurrence count never accumulated
toward the inference threshold, leaving collected jargon unexplained.

- pass only_confirmed=True in jargon_learning and the V2 batch path
- document that _get_existing_jargon_terms returns confirmed terms
- add unit tests covering both learning paths

Fixes #245
@sourcery-ai

sourcery-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Fix jargon candidate statistics by excluding only confirmed jargon entries in both legacy and V2 learning flows, allowing pending candidates to accumulate occurrences and reach meaning-inference thresholds; add regression coverage and release the changes as 3.6.4.

Sequence diagram for confirmed-only jargon candidate statistics

sequenceDiagram
    participant Learning as JargonLearning
    participant DB as Database
    participant Candidate as PendingCandidate
    participant Inference as MeaningInference

    Learning->>DB: get_recent_jargon_list(chat_id, limit, only_confirmed=True)
    DB-->>Learning: confirmed jargon terms
    Learning->>Candidate: accumulate repeated occurrences
    Candidate-->>Learning: count reaches threshold
    Learning->>Inference: infer meaning
Loading

File-Level Changes

Change Details Files
Restrict jargon exclusion during candidate mining to confirmed entries so pending candidates remain eligible for repeated accumulation and inference.
  • Pass only_confirmed=True when loading exclusion terms in the legacy learning path.
  • Update the helper documentation to describe confirmed-only results.
  • Add tests covering query arguments, pending-candidate eligibility, and candidate propagation to inference.
services/learning/jargon_learning.py
tests/unit/test_jargon_learning.py
Apply confirmed-only jargon filtering to the V2 batch-learning path.
  • Pass only_confirmed=True when loading terms before V2 candidate filtering.
  • Add an integration-level unit test verifying pending candidates are processed and saved with inferred meaning.
services/core_learning/v2_learning_integration.py
tests/unit/test_jargon_learning.py
Release the fix as version 3.6.4 and document the behavior change.
  • Add changelog notes for the bug fix, tests, and release.
  • Synchronize plugin, metadata, dashboard, README, and documentation versions.
CHANGELOG.md
__init__.py
metadata.yaml
README.md
README_EN.md
docs/README.md
web_src/package.json

Assessment against linked issues

Issue Objective Addressed Explanation
#245 Ensure pending jargon entries with is_jargon = NULL are not excluded from statistical candidate selection, so repeated occurrences can accumulate their count and reach the inference threshold.
#245 Apply the same confirmed-only exclusion behavior to the V2 jargon batch-learning path, preventing the bug when V2 learning is enabled.
#245 Add regression tests and update relevant documentation/version information for the fix.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the confirmation filter is wrong, pending terms could be promoted and their inferred meanings persisted as jargon records. Reverting would stop further processing but would not remove records already written; those records are bounded and can be corrected or recomputed.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@EterUltimate

Copy link
Copy Markdown
Collaborator Author

@sourcery-ai review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the filtering change is wrong, pending terms may be inferred and written as confirmed jargon or have their counts updated in the database. Reverting stops the new behavior, but records created or modified before the revert outlive it and would need manual cleanup or recomputation.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@EterUltimate
EterUltimate merged commit 6413229 into main Aug 29, 2026
19 checks passed
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