Skip to content

Handle non-finite issue similarity in the canonical deduplication formatter #3453

Description

@stranske

Why

Canonical source repair for the accepted user-filed delivery issue stranske/Ready#561. At main 9a16cbf, scripts/langchain/issue_dedup.py:219 clamps and rounds scores without validating finiteness. Reproduction confirms NaN raises ValueError and positive infinity misleadingly renders 100%. The script is copy-delivered to Ready by .github/sync-manifest.yml:618; Ready AGENTS.md requires the correction to land in Workflows first.

Scope

Implement Ready #561's existing non-finite similarity contract in its canonical Workflows source and focused test suite. This issue routes already accepted work to the owning repository. Ready #561 stays open for downstream sync and consumer acceptance.

Non-Goals

  • Do not change FAISS construction, score selection, similarity thresholds or finite-score semantics.
  • Do not edit consumer copies directly or manage generated sync PRs in this implementation.
  • Scaffold-only completion does NOT count: catching ValueError without a math.isfinite guard and meaningful regression tests does not deliver this issue.

Tasks

  • Guard _format_similarity in scripts/langchain/issue_dedup.py with math.isfinite and return 0% for NaN and either infinity.
  • Extend tests/scripts/test_issue_dedup.py with non-finite helper and comment rendering cases and finite clamping and rounding regressions.
  • Verify the existing copy delivery entry for scripts/langchain/issue_dedup.py in .github/sync-manifest.yml and record Ready [Follow-up] Unmet criteria from PR #560 #561's remaining consumer sync in the PR.

Acceptance Criteria

  • python3 -m pytest tests/scripts/test_issue_dedup.py tests/scripts/test_issue_dedup_smoke.py -q -o addopts='' exits 0; tests prove NaN and both infinities render 0%, public comments retain issue links, and finite scores preserve clamping and rounding. Capture command and results in the PR body.
  • python3 -c "from scripts.langchain.issue_dedup import _format_similarity; assert _format_similarity(float('nan')) == '0%'" exits 0; capture result in the PR body.
  • Deliberate-break gate: remove the math.isfinite guard in scripts/langchain/issue_dedup.py, run python3 -m pytest tests/scripts/test_issue_dedup.py -k nonfinite -q -o addopts='' and confirm NaN and infinity failures; restore exact source and rerun the full focused suite successfully. Capture both outcomes in the PR body.

Implementation Notes

The existing manifest delivery is copy, directly from the canonical script; no duplicate template or new mapping is needed. Existing focused suite is tests/scripts/test_issue_dedup.py rather than the consumer tests/test_main.py. Before fix with new regression cases: 2 failed (NaN and positive infinity), 12 passed. Delivery owner for the consumer sync is Maint 71 after the source PR merges; Ready #561 remains open until its named consumer gate passes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:normalNormal-priority weekly repo-review worktestingSynthesized from ChatGPT import for testing

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions