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>
53 lines
1.8 KiB
Rust
53 lines
1.8 KiB
Rust
//! Knowledge graph module (D-041).
|
|
//!
|
|
//! Implements information boundaries (D-010 principle 2): every piece of
|
|
//! state is tagged with who knows it. Per-entity KnowledgeGraph component
|
|
//! tracks what each entity knows about others and the world.
|
|
|
|
use bevy_app::prelude::*;
|
|
use bevy_ecs::prelude::*;
|
|
|
|
pub mod content_registry;
|
|
pub mod events;
|
|
pub mod graph;
|
|
pub mod registry;
|
|
pub mod types;
|
|
|
|
pub use content_registry::ContentEntityRegistry;
|
|
pub use events::{
|
|
ContradictionDetectedEvent, ContradictionDetectedQueue, InteractionType, KnowledgeEvent,
|
|
KnowledgeEventQueue, KnowledgeEventType, ProcessedEntityGrant, ProcessedFactGrant,
|
|
ProcessedKnowledgeGrant,
|
|
};
|
|
pub use graph::KnowledgeGraph;
|
|
pub use registry::{EntityRegistry, StableEntityId};
|
|
pub use types::*;
|
|
|
|
/// Knowledge system plugin.
|
|
/// Registers resources and systems for knowledge graph processing.
|
|
pub struct KnowledgePlugin;
|
|
|
|
impl Plugin for KnowledgePlugin {
|
|
fn build(&self, app: &mut App) {
|
|
use crate::tick_phases::TickPhase;
|
|
|
|
app.init_resource::<KnowledgeEventQueue>()
|
|
.init_resource::<ContradictionDetectedQueue>()
|
|
.init_resource::<EntityRegistry>()
|
|
.init_resource::<ContentEntityRegistry>()
|
|
.init_resource::<DecayThresholds>()
|
|
// Knowledge phase: process events and decay.
|
|
// One-tick lag from snapshot is intentional — contradiction monologue
|
|
// and relationship shifts read as natural reaction delay (~0.1s).
|
|
.add_systems(
|
|
Update,
|
|
(
|
|
events::process_knowledge_events,
|
|
events::decay_knowledge.after(events::process_knowledge_events),
|
|
)
|
|
.in_set(TickPhase::Knowledge),
|
|
);
|
|
tracing::debug!("KnowledgePlugin initialized");
|
|
}
|
|
}
|