fix(simulation): address PR #10 review — plugin wiring, stale reset, warnings

- Register KnowledgePlugin in main.rs and game_loop test (Tyre critical)
- Add KnowledgeGraph component to player spawn (Tyre critical)
- Reset Stale -> Active on fresh direct observation (Hoshe warning)
- Make registry/queue non-optional in emit_observation_events (Tyre/Hoshe)
- Add tracing::warn for missing EntityRegistry entries (Hoshe warning)
- Replace HashSet with Vec for small entity ID lookups (Hoshe suggestion)
- Add const static assertion for KnowledgeConfidence ordering (Hoshe)
- Add is_empty() and known_facts_iter() to KnowledgeGraph (Tyre)
- Add decay_skips_non_minute_ticks and observe_resets_stale tests (Hoshe)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 01:06:33 +01:00
co-authored by Claude Opus 4.6
parent a68a3ef429
commit 3115c7a84c
6 changed files with 113 additions and 15 deletions
+4 -9
View File
@@ -4,7 +4,6 @@
//! Runs after compute_observer_snapshot, before process_knowledge_events.
use bevy_ecs::prelude::*;
use std::collections::HashSet;
use crate::bridge::types::*;
use crate::knowledge::{
@@ -21,15 +20,11 @@ use crate::simulation::time::SimulationTime;
pub fn emit_observation_events(
time: Res<SimulationTime>,
buffer: Res<SnapshotBuffer>,
registry: Option<Res<EntityRegistry>>,
registry: Res<EntityRegistry>,
observer_query: Query<(Entity, &KnowledgeGraph), With<PlayerCharacter>>,
event_queue: Option<ResMut<KnowledgeEventQueue>>,
mut event_queue: ResMut<KnowledgeEventQueue>,
entity_positions: Query<&TilePosition>,
) {
let (Some(registry), Some(ref mut event_queue)) = (registry, event_queue) else {
return; // Knowledge system not wired up
};
let Some(snapshot) = &buffer.snapshot else {
return;
};
@@ -38,8 +33,8 @@ pub fn emit_observation_events(
return;
};
// Build set of currently visible entity IDs from snapshot (excluding player)
let visible_entity_ids: HashSet<u64> = snapshot
// Collect visible entity IDs (Vec — linear search is faster at 5-20 entities)
let visible_entity_ids: Vec<u64> = snapshot
.entities
.iter()
.filter(|e| !matches!(e.kind, EntityKind::Player))