Commit e1012ae
committed
fix(contract): loosen Fisher-z clamp ±0.999 → ±0.9999 so self-match reads ~1
`Distance::similarity_z` clamps the similarity away from ±1 to keep the
`atanh` (the `ln` term) finite. The bound was ±0.999, which made
`tanh(atanh(0.999)) = 0.999` the maximum value `cohort_similarity_z`
could ever return — so a perfect self-match read ~0.99899, and any
"self ≈ 1.0" assertion (`s > 0.999`) was unreachable.
±0.9999 keeps atanh finite (≈4.95) while letting a self-match round-trip
to ≈0.99986, which reads as "essentially identical". Pure numerical
guard, no semantic change for moderate similarities; the existing
distance tests (s=0.8 roundtrip, z=0.5 averaging, sign-only checks) are
unaffected. Fixes medcare-analytics graph_contract::cohort_similarity_z_
self_returns_one (latent — the lance-phase2-rbac suite had never
compiled in the dev env until protoc was installed this session).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYvNjD8M8LMNYbRy3gq2FP1 parent ddb6c84 commit e1012ae
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
0 commit comments