refactor(server): address PR #16 review feedback

Hoshe + Tyre review items:
- Use StableId consistently for wire entity_id (H4) across observer,
  observation, interpretation, and interaction systems
- Make NearbyInteractionBuffer.interactions private with take() (H1/H20)
- Add system ordering constraint for compute_nearby_interactions (H5)
- Panic on missing PlayerCharacter in input processing (H2)
- Remove redundant paused field from GameTime (Tyre8)
- Remove #[serde(default)] from nearby_interactions (H3)
- Change NearbyInteraction.distance from f32 to u32 (H8)
- Add sort stability for equal verb priorities (H6)
- Scope constants to pub(crate) (H7)
- Add debug_assert for last_observed_tick ordering (H10)
- Strengthen unregistered entity handling to debug_assert + error (H11)
- Document fractional tick accumulation (Tyre9)
- Extract collect_remembered_entities helper (Tyre2/H17)
- Add half_rate_no_drift_over_10000_frames test (H14)
- Add mid-range and deterministic sort tests (H15)
- Add fixture version assertion (H16)
- Regenerate msgpack fixtures for wire format changes

146 unit + 19 integration tests pass, zero clippy warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 20:14:35 +01:00
co-authored by Claude Opus 4.6
parent 458be0f621
commit 9943684f2c
19 changed files with 232 additions and 136 deletions
+10 -8
View File
@@ -33,8 +33,8 @@ pub fn emit_observation_events(
return;
};
// Collect visible entity IDs (Vec — linear search is faster at 5-20 entities)
let visible_entity_ids: Vec<u64> = snapshot
// Collect visible stable IDs (wire entity_id is now StableId, not Entity::to_bits())
let visible_stable_ids: Vec<u64> = snapshot
.entities
.iter()
.filter(|e| !matches!(e.kind, EntityKind::Player))
@@ -47,8 +47,11 @@ pub fn emit_observation_events(
continue;
}
// Look up the bevy Entity from the entity_id (which is Entity::to_bits())
let entity = Entity::from_bits(visible.entity_id);
// Convert wire StableId back to bevy Entity via registry
let stable_id = crate::knowledge::types::StableId(visible.entity_id);
let Some(entity) = registry.to_entity(&stable_id) else {
continue;
};
// Get tile position for knowledge tracking
if let Ok(pos) = entity_positions.get(entity) {
@@ -69,10 +72,9 @@ pub fn emit_observation_events(
continue;
}
// Check if this entity is still visible in the current snapshot
if let Some(entity) = registry.to_entity(stable_id) {
let entity_bits = entity.to_bits();
if !visible_entity_ids.contains(&entity_bits) {
// Check if this entity's StableId is still visible in the current snapshot
if !visible_stable_ids.contains(&stable_id.0) {
if let Some(entity) = registry.to_entity(stable_id) {
event_queue.push(KnowledgeEvent {
observer: observer_entity,
tick: time.tick,