Skip to content

fix(compiler): dedup fanned-out finality UNION branches - #252

Merged
mischuh merged 1 commit into
mainfrom
fix/finality-fanout-dedup
Jul 28, 2026
Merged

fix(compiler): dedup fanned-out finality UNION branches#252
mischuh merged 1 commit into
mainfrom
fix/finality-fanout-dedup

Conversation

@mischuh

@mischuh mischuh commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

Stacked on #251 — builds on the _build_deduped extraction from that PR.

  • _build_finality_union built every finality UNION branch (one per realization, e.g. final/provisional) as a flat GROUP BY with no fanout protection at all — neither dedup for additive measures nor the reject-if-corrupting safety floor for non-additive ones.
  • Each realization plans its own join graph to the requested dimensions independently, so one branch's topology can fan out even when the outer/global owner topology (already checked by the caller) does not.
  • Fanout is now computed per branch inside _build_finality_union: additive + fanout → DISTINCT ON dedup (via new _build_dedup_inner, extracted from _build_deduped); non-additive + fanout → FanoutUnsafe.
  • No changes needed in simple_additive.py/composite.py — both benefit automatically since the fix lives in the shared helper.

Test plan

  • pytest tests/compiler/test_finality_fanout.py — new: SQL structure (both branches dedup), executed-DuckDB numeric correctness, safety-floor regression, composite-metric analog
  • pytest tests/compiler/test_finality.py tests/compiler/test_composite_finality.py — existing finality tests unaffected (non-fanout case)
  • pytest tests/ — full suite green
  • ruff check . && ruff format --check . / mypy canonic/

🤖 Generated with Claude Code

Base automatically changed from fix/ratio-metric-fanout-inflation to main July 28, 2026 09:32
@mischuh mischuh self-assigned this Jul 28, 2026
- Compute fanout per realization branch in _build_finality_union
  instead of only for the outer owner topology
- Additive + fanout: DISTINCT ON dedup (via new _build_dedup_inner,
  extracted from _build_deduped); non-additive + fanout: FanoutUnsafe
- Add regression tests: SQL structure, executed DuckDB numeric check,
  safety-floor case, composite-metric analog
@mischuh
mischuh force-pushed the fix/finality-fanout-dedup branch from cca3f53 to bfe67c3 Compare July 28, 2026 09:34
@mischuh
mischuh merged commit 97523dd into main Jul 28, 2026
5 checks passed
@mischuh
mischuh deleted the fix/finality-fanout-dedup branch July 28, 2026 09:38
@mischuh mischuh mentioned this pull request Jul 28, 2026
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.

1 participant