From efec6f22d54293901b09d71f3a25d9288ea279bb Mon Sep 17 00:00:00 2001 From: funman300 Date: Wed, 29 Apr 2026 04:05:26 +0000 Subject: [PATCH] fix(engine): resolve StatsUpdate system-set scheduling cycle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update_stats_on_new_game and handle_forfeit ran .before(GameMutation) while being inside StatsUpdate. win_summary_plugin constrains cache_win_data.before(StatsUpdate), which forces the entire StatsUpdate set to run after GameMutation — creating an unsolvable cycle that panicked Bevy 0.18's schedule solver at startup. Only update_stats_on_win (post-GameMutation) belongs in StatsUpdate. The pre-GameMutation systems still run before GameMutation but outside the set, so external .before(StatsUpdate)/.after(StatsUpdate) constraints remain consistent. Co-Authored-By: Claude Sonnet 4.6 --- solitaire_engine/src/stats_plugin.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/solitaire_engine/src/stats_plugin.rs b/solitaire_engine/src/stats_plugin.rs index 4ffdc33..d3a54c1 100644 --- a/solitaire_engine/src/stats_plugin.rs +++ b/solitaire_engine/src/stats_plugin.rs @@ -82,12 +82,14 @@ impl Plugin for StatsPlugin { .add_message::() .add_message::() // record_abandoned must read `move_count` BEFORE handle_new_game - // clobbers it with a fresh game. + // clobbers it with a fresh game. These are NOT in StatsUpdate because + // StatsUpdate (as a set) is ordered after GameMutation by external + // constraints (win_summary_plugin: cache_win_data.before(StatsUpdate)), + // and a system cannot be both inside a set and individually before a + // set-level ordering constraint. .add_systems( Update, - update_stats_on_new_game - .before(GameMutation) - .in_set(StatsUpdate), + update_stats_on_new_game.before(GameMutation), ) .add_systems( Update, @@ -95,7 +97,7 @@ impl Plugin for StatsPlugin { ) .add_systems( Update, - handle_forfeit.before(GameMutation).in_set(StatsUpdate), + handle_forfeit.before(GameMutation), ) .add_systems(Update, toggle_stats_screen.after(GameMutation)); }