fix(simulation): address PR #42 review — 8 items from Hoshe and Tyre

1. Sound producers: document empty v0.1 pipeline explicitly (critical)
2. Routine tests: add ActiveSim to 3 tests that passed trivially
3. Rename _observer_pos → observer_pos (used at line 191)
4. Add FactionOnly positive test case (matching faction_id)
5. Fix stale doc comment "Current: 9" → 10 in ObserverSnapshot
6. Remove orphaned SimulationTier/LastInteraction/ScopeTag types
7. Add tracing::warn on FactionOnly non-numeric parse failure
8. Document Medium-range occlusion gap as TODO in audible_at
9. Insert SoundEventQueue in observer test setup_world

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 15:08:32 +01:00
co-authored by Claude Opus 4.6
parent 8e00db2b2d
commit 03c44bebaf
7 changed files with 51 additions and 115 deletions
+34 -1
View File
@@ -268,7 +268,17 @@ pub fn filter_by_access(
.entities
.get(&target_id)
.and_then(|k| k.known_attributes.get("faction_id"))
.and_then(|v| v.parse::<u64>().ok())
.and_then(|v| match v.parse::<u64>() {
Ok(id) => Some(id),
Err(_) => {
tracing::warn!(
target_id = target_id.0,
value = %v,
"FactionOnly: non-numeric faction_id attribute, denying access"
);
None
}
})
.is_some_and(|id| id == faction_id.0),
// RelationshipGated: observer must have a relationship score >= threshold.
@@ -713,4 +723,27 @@ mod tests {
"FactionOnly must block when faction attribute is not known"
);
}
#[test]
fn filter_by_access_faction_only_passes_with_matching_faction() {
let observer = StableId(1);
let target = StableId(2);
let mut kg = KnowledgeGraph::new();
// Observer knows target's faction via known_attributes
kg.observe_entity(target, make_position(5, 5), 10);
kg.entities
.get_mut(&target)
.unwrap()
.known_attributes
.insert("faction_id".into(), "99".into());
let faction = StableId(99);
let rule = ObserverAccess::FactionOnly(faction);
assert!(
filter_by_access(observer, target, &rule, &kg),
"FactionOnly must pass when observer knows the matching faction_id"
);
}
}