Skip to content

engine: test_rank_and_filter_truncates_to_max_loops builds 250 loops to trip production MAX_LOOPS=200 #667

Closed

Description

@bpowers

Problem

test_rank_and_filter_truncates_to_max_loops in src/simlin-engine/src/ltm_finding.rs (around line 3740) builds MAX_LOOPS + 50 = 250 FoundLoops to verify truncation against the production MAX_LOOPS = 200 threshold:

let stock_names: Vec<String> = (0..MAX_LOOPS + 50)
    .map(|i| format!("stock_{i:04}"))
    .collect();
let mut loops: Vec<FoundLoop> = (0..MAX_LOOPS + 50) ...

This violates the documented rule in docs/dev/rust.md ("Do not test production threshold gates by building fixtures large enough to trip them -- use a test-only override and a tiny fixture").

Why it's an easy fix now

The test-only override already exists: MaxLoopsGuard + MAX_LOOPS_OVERRIDE (the #[cfg(test)] thread-local consulted by effective_max_loops/max_loops_for_call) were added in commit 76db318. So the migration is trivial: wrap the test in a MaxLoopsGuard with a small cap (e.g. 3) and build a tiny fixture (cap + a few loops) instead of 250.

Severity

Low (pure test hygiene). The test is cheap today (<1ms), so this is not a test-time-budget problem -- it is a consistency-with-the-documented-pattern cleanup, and it future-proofs against the fixture cost scaling if MAX_LOOPS is ever raised.

Components affected

  • src/simlin-engine/src/ltm_finding.rs (test_rank_and_filter_truncates_to_max_loops)

Discovery context

Identified during an LTM-hardening session while reviewing the ltm_finding.rs test suite against the MaxLoopsGuard override that commit 76db318 introduced.

Activity

  1. added
    engine
    on Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enginetech debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions