fix(worthiness): preserve a configured min_score of 0 - #603
Conversation
Walkthrough
ChangesWorthiness configuration
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`_as_float(...) or DEFAULT_MIN_SCORE` swallowed a legitimate min_score: 0 (an explicit "never defer") and rewrote it to the 0.4 default, conflating unset/unparseable/zero. fall back only when the value is absent or unparseable, matching every other numeric config loader in the codebase.
75bc032 to
8fe527a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/vouch/worthiness.py`:
- Around line 213-218: Update _as_float() to reject bool values before float
conversion, returning None so load configuration falls back to
DEFAULT_MIN_SCORE. Add regression coverage verifying YAML min_score values off
and on both use the default.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 142cf342-c8e9-4b01-bbd6-037a6b0a90de
📒 Files selected for processing (2)
src/vouch/worthiness.pytests/test_worthiness.py
Disabled coderabbit review
summary
worthiness.load_configbuildsmin_scorewith_as_float(raw.get("min_score")) or DEFAULT_MIN_SCORE._as_floatreturns0.0for a configuredmin_score: 0, and0.0 or 0.4is0.4— so a kb that setsworthiness.min_score: 0inconfig.yamlsilently gets the default instead. theorconflates three distinct inputs — unset, unparseable, and the legitimate value zero — and rewrites the last one.min_score: 0is a meaningful, distinct setting (compute worthiness but never let the threshold defer a claim — unlikescorer: off, which computes nothing), so it should be honored verbatim. the existing contract testtest_load_config_parses_blockalready asserts a configured0.6is honored; this restores the same rule for0.the sibling
admission.pyuses the identical_as_float(...) or DEFAULTidiom but is unaffected only because its default is0.0(a no-op); every other numeric config loader (enrich,session_split,compile,retrieval_events,inbox) preserves a legitimate zero. worthiness is the lone outlier.fix
fall back to
DEFAULT_MIN_SCOREonly when the value is absent or unparseable (is not None), not when it is a real0.0.test
test_load_config_preserves_zero_min_scorewritesmin_score: 0and asserts the loaded value is0.0; it fails on the current code (loads0.4) and passes with the fix.validation
make checkgreen:ruff check src tests,mypy src(no issues, 116 files),pytest tests/ --ignore=tests/embeddings(all pass).Summary by CodeRabbit
Bug Fixes
0are now preserved instead of being replaced by the default.Tests