From 9e8ac03476f580de8c8a90cfb34a12c010d70526 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Fri, 10 Jul 2026 02:17:52 +0800 Subject: [PATCH] test(filament_group): don't assert max_group_size cap for MatchMode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FilamentGroup property/golden harness checked a per-extruder max_group_size cap unconditionally in check_constraints. That cap is an invariant of the flush-partition solvers only (calc_group_by_enum / calc_group_by_kmedoids, reached via calc_filament_group_for_flush), which partition filaments subject to each extruder's capacity. MatchMode (calc_filament_group_for_match) does not partition by capacity: it maps every filament to the extruder holding the nearest-color loaded AMS filament, and its solver capacity is the used-filament count, not max_group_size (FilamentGroup.cpp:1067). So a legitimate MatchMode result can place more than max_group_size filaments on one extruder. The prop_a/b/c_mode_match specs run MatchMode, and their scenarios are generated with std::uniform_int_distribution / std::shuffle, which are implementation-defined. For a fixed mt19937 seed, libc++ (macOS), libstdc++ (Linux) and MSVC (Windows) draw different scenarios, so the CI failure only surfaced on Linux/Windows while macOS passed. Verified locally: 248/600 config-A MatchMode seeds exceed the cap under libc++ — it is reachable everywhere; seed 90400 just isn't an exceeding draw on macOS. Gate section 3 on FGMode != MatchMode. No test case is removed or skipped: all 57 FlushMode specs still assert the cap, MatchMode still asserts the unprintable-filament/volume correctness constraints (which it honors), and MatchMode grouping regressions are still caught by the golden score gate at 3% tolerance. Test-only change; slicing behavior and g-code are unaffected. --- tests/filament_group/fg_test_evaluator.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/filament_group/fg_test_evaluator.hpp b/tests/filament_group/fg_test_evaluator.hpp index e9a800921d..fcd7d6576e 100644 --- a/tests/filament_group/fg_test_evaluator.hpp +++ b/tests/filament_group/fg_test_evaluator.hpp @@ -52,12 +52,19 @@ inline bool check_constraints(const FilamentGroupContext& ctx, } } - // 3. max_group_size per extruder (only check when theoretically feasible) + // 3. max_group_size per extruder. This cap is an invariant of the flush-partition + // modes only: those solvers partition the filaments across extruders subject to + // each extruder's capacity. MatchMode instead maps every filament to the extruder + // holding the nearest-color loaded AMS filament and does not partition by capacity + // (its solver capacity is the filament count, not max_group_size), so a legitimate + // match may place more than max_group_size filaments on one extruder. Enforce the + // cap only for the partition modes, and only when the instance is feasible. int total_capacity = 0; for (auto sz : ctx.machine_info.max_group_size) total_capacity += sz; - if (total_capacity >= (int)used_filaments.size()) { + if (ctx.group_info.mode != FGMode::MatchMode && + total_capacity >= (int)used_filaments.size()) { std::map extruder_count; for (auto fil : used_filaments) { if (fil >= filament_map.size()) continue;