## Guard: the offline range default MUST mirror the live rack. ## ## `buildAllGunDrivers()` used to default `enableTmSelector = true`, so every ## default caller (`run_range`, `analyze_selector`, `test_power_selection`, ## `measure_power_policy`) spawned gun 13 (TMSelect) — a gun the shipped bot ## NEVER spawns (`EnableTmSelector = false` in ModularBot.nim). The shared ## `VirtualTracker` ring is order-sensitive: gun 13's extra 4 bullets/tick shift ## the ring head and permute every other gun's per-tick resolution order, which ## reorders the learning guns' observations and shifts their predictions. That is ## the exact confound the acceptance test was repaired for (commit 4cd5618, where ## closing gun 13's offline ready gate made the live/offline KNN traces ## byte-identical). ## ## Before the fix this file FAILS: the default replay resolves gun-13 bullets. ## After the fix it PASSES and the rack mirrors the shipped bot. ## ## Run: nim c -r --path:common_libs common_libs/tests/test_range_rack_parity.nim import std/[os] import gun_harness/offline_range import range_guns const fixturesDir = currentSourcePath().parentDir.parentDir.parentDir / "tools" / "fixtures" var failures = 0 proc check(name: string, ok: bool) = if ok: echo "PASS: ", name else: echo "FAIL: ", name; inc failures proc tmShots(drivers: seq[GunDriver], fx: Fixture): int = let reports = replayFixture(fx, drivers) for r in reports: if r.name == "TMSelect": return r.shots 0 proc main() = let path = fixturesDir / "drussgt_vs_ramfire.jsonl" if not fileExists(path): echo "SKIP: fixture missing: ", path quit(0) let fx = loadFixture(path) # 1. THE DEFECT: the default rack must NOT spawn the disabled TMSelect gun. check "default rack never spawns gun 13 (TMSelect)", tmShots(buildAllGunDrivers(), fx) == 0 # 2. The flag is live: asking for TMSelect explicitly DOES spawn it, so the # zero above is the gate and not a broken gun. check "enableTmSelector=true still spawns gun 13 (flag is live)", tmShots(buildAllGunDrivers(enableTmSelector = true), fx) > 0 # 3. The rack reports the live gun ids 0..13 (14 slots), so report indices are # stable whichever way the flag is set. check "driver count is 14 (gun ids 0..13)", buildAllGunDrivers().len == 14 if failures > 0: echo "\n", failures, " check(s) FAILED" quit(1) echo "\nAll range rack-parity checks passed." when isMainModule: main()