Repository navigation
engine: defend ltm feeder slot pin and agg source slices - #787
Conversation
Two P3 defensive-code findings from PR #784's automated review, both hardening the phase's no-silent-wrong-numbers invariant. pin_iterated_dim_indices resolved slot pins first-match-by-name, so a degenerate square-source agg (iterated slot axes repeating a dim, e.g. SUM(cube[D1,D1,*] * frac[D1,D1]) inside an A2A-D1 body) pinned every occurrence of the duplicated dim to the FIRST slot part -- the off-diagonal slot [r1,r2] froze frac[r1,r1], a silently wrong score. This shape is reachable (the new ltm_unified_tests fixture demonstrated the wrong frozen row pre-fix). The pin now mirrors resolve_mismatched_index_position's uniqueness defense: an index naming a repeated dim returns None, which generate_iterated_feeder_to_agg_equation converts into the existing GH #743 unfreezable error -- the row is loudly skipped via emit_ltm_partial_equation_warning instead of emitted wrong. agg_sources' release-build fallback substituted the CANONICAL slice for an arrayed source missing from per_var, contradicting its own debug_assert; for a projection feeder (whose slice differs from canonical by design) that would mislabel the feeder as a co-source and corrupt the per-(row, slot) scores. The empty-slice alternative was rejected because an arrayed source with a scalar-shaped slice feeds the read_slice_rows arity-mismatch fallbacks with mismatched name grammars. agg_sources now returns None so the hoist is declined and the reference stays on the conservative Direct path -- the same inert degradation as the not-statically-describable carve-outs. The invariant is structurally guaranteed (collect_var_refs and collect_arrayed_source_slices walk the identical reference surface), so the decline is purely defensive and is pinned by a direct unit test.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #787 +/- ##
=======================================
Coverage 90.86% 90.87%
=======================================
Files 224 224
Lines 140812 140856 +44
=======================================
+ Hits 127955 128003 +48
+ Misses 12857 12853 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ReviewReviewed the diff focusing on the two hardening changes:
No findings. Overall correctness verdictCorrect. The fixes are minimal, defensive, and consistent with the codebase's no-silent-fallback discipline. The real reachable defect (square-source feeder slot pin) is addressed by mirroring |
Follow-up to #784 (supersedes #786, which conflicted because #784 was squash-merged and the old branch carried the pre-merge history). Fixes the two P3 findings #784's automated review surfaced after merge. Both harden the phase's no-silent-fallback discipline, and the first turned out to be a real reachable defect rather than defense-in-depth.
Feeder slot pinning on square-source aggs: a degenerate square-source reducer (
x[D1] = 1 + SUM(cube[D1,D1,*] * frac[D1,D1])) mints an agg withresult_dims == [D1, D1], andpin_iterated_dim_indicesresolved indices by first-match dim name -- every duplicated-dim index pinned to the first slot part, silently freezing the wrong source row on off-diagonal feeder scores (confident garbage, zero diagnostics). It now mirrorsresolve_mismatched_index_position's uniqueness defense: an ambiguous index bails to the existingUnfreezablePartialloud-skip channel (per-row warning, no score emitted). RED-verified pre-fix at both fixture and unit level; byte-identical for every non-repeated-dim shape by construction.agg_sourcesrelease-build fallback: the helper carried adebug_assertthat every arrayed reducer source has a per-var slice, then silently substituted the canonical slice in release if the invariant ever broke -- which would mislabel a projection feeder as a co-source and corrupt per-(row, slot) derivations. It now returnsOptionand declines the hoist entirely on a missing slice (the same inert conservative degradation as the dynamic-index carve-outs). The reviewer-suggested empty-slice fallback was rejected because an arrayed source wearing the scalar-feeder encoding would flow into the scalar-agg name grammar -- plausibly wrong rather than inert. The two AST walkers were audited as structurally symmetric, so the path is unreachable today; the defense now matches the asserted invariant.The remaining square-source hazards (co-source and agg-to-target halves still pin by dim name; phantom off-diagonal link scores reach link-level surfaces unwarned) are pre-existing and tracked as #785/#778, with the loop-score cascade gap as #780. Adversarial review of this commit: APPROVE, with the empirical co-source findings appended to #785.