fix(server): add error logging, protocol version, and architecture docs

- Replace silent Entity::to_bits() fallbacks with tracing::error in
  observer.rs and interaction.rs (makes unregistered entities loud)
- Add PROTOCOL_VERSION constant to types.rs, use in observer snapshot
- Document single-observer assumption on NearbyInteractionBuffer
- Document proximity-only (no LOS) limitation on compute_nearby_interactions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 21:22:34 +01:00
co-authored by Claude Opus 4.6
parent e2f2f4e590
commit ba867564a8
3 changed files with 26 additions and 4 deletions
+12 -2
View File
@@ -20,8 +20,12 @@ pub(crate) const MID_RANGE: u32 = 5;
pub struct Interactable;
/// Compute nearby interactions for the player character.
/// For each visible entity in range, determines available verbs sorted by priority.
/// For each entity in range, determines available verbs sorted by priority.
/// Results are written to the NearbyInteractionBuffer for inclusion in ObserverSnapshot.
///
/// NOTE: Checks proximity only, not line-of-sight. The client filters
/// interaction prompts against visible entities. Server-side LOS filtering
/// is deferred until the interaction system can read the observer's visible set.
#[allow(clippy::type_complexity)]
pub fn compute_nearby_interactions(
player_query: Query<(&TilePosition, &KnowledgeGraph), With<PlayerCharacter>>,
@@ -130,7 +134,10 @@ pub fn compute_nearby_interactions(
let wire_id = registry
.to_stable(entity)
.map(|sid| sid.0)
.unwrap_or_else(|| entity.to_bits());
.unwrap_or_else(|| {
tracing::error!(?entity, "entity in interaction range but not in EntityRegistry");
entity.to_bits()
});
buffer.interactions.push(NearbyInteraction {
entity_id: wire_id,
@@ -148,6 +155,9 @@ pub fn compute_nearby_interactions(
/// Buffer for nearby interaction results, consumed by snapshot generation.
/// Field is private — use `take()` to drain results into the snapshot.
///
/// Global Resource — single-observer assumption (v0.1). D-009 multiplayer
/// will refactor the entire observer + interaction pipeline to per-entity.
#[derive(Resource, Debug, Default)]
pub struct NearbyInteractionBuffer {
interactions: Vec<NearbyInteraction>,