refactor(simulation): replace ad-hoc system ordering with TickPhase pipeline (#843)

10-phase linear pipeline: PreInput → Input → Movement → Simulation →
Economy → Storyteller → Snapshot → PostSnapshot → Knowledge → TickAdvance.

Each system assigned to exactly one phase via .in_set(TickPhase::X).
Cross-phase .after()/.before() eliminated — only intra-phase ordering
remains. Prevents schedule cycles by construction.

SimulationPlugin refactored into sub-plugins by domain:
  - InputPlugin (player actions, interactions, dialogue dispatch)
  - MovementPlugin (pathfinding, movement validation, spatial indexing)
  - SocialPlugin (conversations, sound, voice enrichment, follow state)
  - EconomyPlugin (tâtonnement tick, IPC query serving)
  - TimePlugin (chunk streaming, news ticker, tick advancement)

All other plugins (NPC, Knowledge, Perception, Storyteller, Settings,
Bridge) updated to use TickPhase assignments instead of cross-plugin
ordering constraints. BridgePlugin trimmed to bridge I/O concerns only.

Part A of #843. Parts B (multi-threaded executor) and C (background
workers) follow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 23:51:06 +02:00
co-authored by Claude Opus 4.6
parent d434235985
commit 47d4918cc8
15 changed files with 443 additions and 274 deletions
+18 -9
View File
@@ -20,21 +20,30 @@ pub struct PerceptionPlugin;
impl Plugin for PerceptionPlugin {
fn build(&self, app: &mut App) {
use crate::tick_phases::TickPhase;
app.init_resource::<interpretation::ObservationEventQueue>()
.init_resource::<query::VisibilityGeometry>()
.init_resource::<query::ActivePerceptionMode>()
// Simulation: anomaly detection (feeds monologue recognition chain)
.add_systems(
Update,
(
anomaly::clear_anomaly_markers.before(anomaly::detect_anomalies),
anomaly::detect_anomalies.before(observation::emit_observation_events),
cognitive_delay::process_cognitive_delay
.after(observation::emit_observation_events)
.before(crate::knowledge::events::process_knowledge_events),
interpretation::generate_observation_events
.after(observation::emit_observation_events)
.before(crate::knowledge::events::process_knowledge_events),
),
anomaly::clear_anomaly_markers,
anomaly::detect_anomalies
.after(anomaly::clear_anomaly_markers),
)
.in_set(TickPhase::Simulation),
)
// Knowledge: cognitive delay + observation interpretation
// (runs after PostSnapshot emit_observation_events, feeds process_knowledge_events)
.add_systems(
Update,
(
cognitive_delay::process_cognitive_delay,
interpretation::generate_observation_events,
)
.in_set(TickPhase::Knowledge),
);
tracing::debug!("PerceptionPlugin initialized");
}