Skip to content

fix(drift): discount CALLS-layer tangle by unresolved_ratio (#244)#253

Merged
zaebee merged 1 commit into
mainfrom
feat/issue-244-tangle-calls-discount
Jun 14, 2026
Merged

fix(drift): discount CALLS-layer tangle by unresolved_ratio (#244)#253
zaebee merged 1 commit into
mainfrom
feat/issue-244-tangle-calls-discount

Conversation

@zaebee

@zaebee zaebee commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #244 (colleague-review note 1 from PR #241). PatternFingerprint.tangle_ratio now fades the CALLS layer by the confidence discount clip(1 − unresolved_ratio) before the max():

calls_discount = max(0.0, min(1.0 - self.unresolved_ratio, 1.0))
return max(tangle_mass(self.t_imports), calls_discount * tangle_mass(self.t_calls))

t_calls is a census over resolved intra-domain CALLS only, so a domain whose calls are mostly raw/unresolved — plus one resolved mutual triple — could read a high calls-tangle (tangle_mass ≈ 0.67 from a single 201) and trip the hard hygiene gate on thin evidence. This mirrors the existing drift-distance treatment (_clip_discount / _score_v2), which already fades the calls layer for exactly this reason. The IMPORTS layer (always resolved) is never discounted.

Why it's safe

The discount can only lower calls-tangle, so it can never push a green domain red — the max: 0.25 threshold stays valid and no re-measurement is needed.

  • Self-drift verified: cgis drift on the self-graph → 0 tangle gate_failed (unchanged).
  • Full suite green (1060), ruff + mypy strict clean, doc-coverage 99.6%.

Tests

  • calls-tangle discounted by unresolved_ratio (mesh + 0.5 unresolved → 0.5);
  • fully-unresolved calls fade to 0 (cannot trip the gate);
  • IMPORTS layer not discounted (regression guard);
  • fully-resolved calls unchanged (regression guard).

Residual (deliberately not in scope)

This fixes the mostly-unresolved case (issue option 1). It does not address a domain with few but fully-resolved mutual calls (unresolved_ratio = 0 → discount = 1 → full calls-tangle from one triple) — that's issue option 2 (a minimum-triad-count floor). Left out per YAGNI: it needs its own magic-number calibration, the common case is the unresolved one, and self-drift is safe regardless. Easy to add later if a real domain hits it.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

🤖 Generated with Claude Code

tangle_ratio fades the CALLS layer by clip(1 - unresolved_ratio) before the
max(), mirroring the drift-distance path (_clip_discount / _score_v2). t_calls
is a census over RESOLVED intra-domain calls only, so a sparse/mostly-unresolved
call graph with one resolved mutual triple could read a high calls-tangle and
trip the hard gate on thin evidence. The IMPORTS layer (always resolved) is
never discounted. Discount only lowers calls-tangle, so the 0.25 threshold and
self-drift safety are unchanged (verified: cgis-self 0 tangle gate_failed).

Closes #244.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements a confidence discount for the CALLS layer in the tangle_ratio calculation, addressing issue #244. The CALLS layer is now faded by 1 - unresolved_ratio (clipped between 0.0 and 1.0) to prevent sparse or mostly-unresolved call graphs from over-reporting calls-tangle. Unit tests have been added to verify this discounting behavior, ensuring that the IMPORTS layer remains unaffected and that the discount behaves correctly under various unresolved ratios. No review comments were provided, so there is no additional feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@zaebee zaebee merged commit 119e5b3 into main Jun 14, 2026
3 checks passed
@zaebee zaebee deleted the feat/issue-244-tangle-calls-discount branch June 14, 2026 17:06
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.

tangle_ratio: discount the CALLS layer by unresolved_ratio (false gate_failed on sparse calls)

1 participant