Fixes #1675
_parse_dedupe_response validated is_duplicate and duplicate_id, but passed confidence through untouched: "nan" became nan, "inf" became inf, -3 and 99 stayed out of range. The prompt documents "confidence is a number between 0 and 1" (dedupe.py:133) and the value reaches callers and %.2f logging, where NaN defeats every comparison it meets.
A non-finite or out-of-range answer now lands in the documented range: NaN (unordered, so nothing can be decided from it) becomes 0.0, and a finite value is clamped to [0, 1].
Validation: pytest tests/test_dedupe_decisions.py -q -> 25 passed, with the new parametrised cases covering nan, inf, -inf, -3, 99, "0.5" and 0.42.
| input | before | after |
|---|---|---|
"nan" | nan | 0.0 |
"inf" | inf | 1.0 |
-3 | -3.0 | 0.0 |
99 | 99.0 | 1.0 |
"0.5", 0.42 | unchanged | unchanged |
ruff check + format clean. The model's answer is untrusted input at a parser boundary, which is why this is a validation fix rather than a prompt tweak.
[Medium impact] This PR appears safe to merge.
Summary
_parse_dedupe_responsenow keepsconfidencewithin its documented range.No actionable issues found. Tests were reviewed but not run.
Reviews (1) · Last reviewed commit: "fix(report): keep a dedupe confidence in..." · Reviewed by Greptile