fix(compiler): dedup fanned-out finality UNION branches - #252
Merged
Conversation
- 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
force-pushed
the
fix/finality-fanout-dedup
branch
from
July 28, 2026 09:34
cca3f53 to
bfe67c3
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #251 — builds on the
_build_dedupedextraction from that PR._build_finality_unionbuilt every finality UNION branch (one per realization, e.g. final/provisional) as a flatGROUP BYwith no fanout protection at all — neither dedup for additive measures nor the reject-if-corrupting safety floor for non-additive ones._build_finality_union: additive + fanout →DISTINCT ONdedup (via new_build_dedup_inner, extracted from_build_deduped); non-additive + fanout →FanoutUnsafe.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 analogpytest tests/compiler/test_finality.py tests/compiler/test_composite_finality.py— existing finality tests unaffected (non-fanout case)pytest tests/— full suite greenruff check . && ruff format --check ./mypy canonic/🤖 Generated with Claude Code