You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ltm-finding: truncate-before-filter can drop partition-dominant loops #310
rank_and_filter() truncates discovered loops to MAX_LOOPS (200) before partition-aware contribution filtering.
Why this is a problem
LTM interpretation is partition-scoped: loops should be compared within cycle partitions. Global pre-truncation can drop loops that are dominant in small partitions but globally below rank 200, violating partition-local dominance semantics.
Literature / algorithm alignment
Reference and design docs emphasize partition-scoped comparison for relative contribution. Global truncation before partition-aware retention introduces cross-partition interference.
The risk is already acknowledged inline at lines 833-836:
NOTE: This truncation happens before partition-aware filtering. A loop
dominant in a small partition but globally ranked below 200th could be
truncated. In practice MAX_LOOPS is generous enough that this is
extremely unlikely.
truncate(MAX_LOOPS) -> 200 (now applies to contribution-significant loops only)
Assign IDs
Re-sort
Why this is strictly an improvement
Cost: negligible. The filter pass is already O(n x steps); applying it to a few hundred extra raw discovery candidates before truncation is in the noise.
Correctness: a loop dominant in a 5-loop secondary partition (e.g. >= 0.1% of that partition's total |score|) is retained even when its global rank is well below 200. The point of partition-aware filtering is exactly to give small partitions their own threshold space; truncating first defeats that purpose.
Edge cases
Filter result < 200 loops: truncation is a no-op. Correct.
Filter result > 200 loops: truncation cuts at the boundary, but every retained loop has already passed the contribution threshold, so the truncation only drops above-threshold but lower-ranked loops. That matches the paper's "top N" prescription (Eberlein & Schoenberg 2020, Section 7).
Suggested test
Add a unit test in ltm_finding.rs::tests that constructs a synthetic discovery result with:
One large partition (250+ loops)
One small partition (5 loops with high partition-relative contribution but low global avg |score|)
Assert all 5 small-partition loops survive under filter-then-truncate. The same fixture against the current truncate-then-filter implementation should drop some of them, demonstrating the regression risk this protects against.
File references
Current implementation: src/simlin-engine/src/ltm_finding.rs:848-917
Fixed in PR #668 (merged as f9f850d), together with #543 (same function). rank_and_filter now applies the partition-aware MIN_CONTRIBUTION retention filter before any global cap, then ranks by partition-relative importance, then truncates to MAX_LOOPS — so a partition-dominant loop globally ranked below the cap survives. Deterministic content-based tie-breaking; a MaxLoopsGuard test-only override (the #515 pattern) keeps fixtures tiny. Pinned by test_rank_and_filter_310_partition_dominant_survives_cap (red-verified).
Activity
doc: refresh LTM tech-debt entries after triage of open issues
bpowers commentedon May 9, 2026
Concrete proposal: filter-then-truncate
Adding implementation-level detail to complement the original report.
Current order (
src/simlin-engine/src/ltm_finding.rs:848-917)truncate(MAX_LOOPS)-> 200>= MIN_CONTRIBUTION = 0.1%)The risk is already acknowledged inline at lines 833-836:
Proposed reorder
truncate(MAX_LOOPS)-> 200 (now applies to contribution-significant loops only)Why this is strictly an improvement
Edge cases
Suggested test
Add a unit test in
ltm_finding.rs::teststhat constructs a synthetic discovery result with:Assert all 5 small-partition loops survive under filter-then-truncate. The same fixture against the current truncate-then-filter implementation should drop some of them, demonstrating the regression risk this protects against.
File references
src/simlin-engine/src/ltm_finding.rs:848-917LTM hardening: close out the top tracked gaps from epic #488 (#668)
bpowers commentedon Jun 2, 2026
Fixed in PR #668 (merged as f9f850d), together with #543 (same function). rank_and_filter now applies the partition-aware MIN_CONTRIBUTION retention filter before any global cap, then ranks by partition-relative importance, then truncates to MAX_LOOPS — so a partition-dominant loop globally ranked below the cap survives. Deterministic content-based tie-breaking; a MaxLoopsGuard test-only override (the #515 pattern) keeps fixtures tiny. Pinned by test_rank_and_filter_310_partition_dominant_survives_cap (red-verified).