chore(simulation): address review suggestions — comments and minor fixes
- monologue.rs: tracing::warn on unrecognized trigger in fallback arm - disclosure.rs: borrow-sequencing comment, first() simplification note - trait_modifiers.rs: delegate parse_confidence to KnowledgeConfidence::try_from - npc_knowledge_transfer.rs: fix misleading "draw randomly" comment, document one-directional transfer behavior - graph.rs: document intentional no-retrigger after contradiction - dialogue.rs: explain entity grant guardrail asymmetry (D-079) - knowledge/mod.rs: document one-tick monologue lag from system ordering - poi_discovery.rs: document D-079 carve-out for direct KG write Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -293,6 +293,9 @@ pub fn process_unprompted_disclosure(
|
||||
let npc_sid = sid_opt?.0;
|
||||
|
||||
// Gate 2: candidate pool non-empty.
|
||||
// Takes highest-priority candidate (sorted by confidence desc,
|
||||
// then recency desc in derive_disclosure_candidates). Full Layer 4
|
||||
// line selection with variety tracking is deferred to #172.
|
||||
let fact_id = candidates.candidates.first()?.clone();
|
||||
|
||||
// Gate 3: NPC→player trust >= Surface.
|
||||
@@ -404,6 +407,10 @@ pub fn process_unprompted_disclosure(
|
||||
}
|
||||
|
||||
// 3. Update NPC cooldown state.
|
||||
// Note: re-queries npc_query mutably after the read pass above. This is
|
||||
// safe because the read pass only borrows shared refs and completes before
|
||||
// this point. The two-phase pattern (read → select winner → write) avoids
|
||||
// holding a mutable borrow during iteration.
|
||||
if let Ok((_, _, _, _, _, _, _, mut cooldown)) = npc_query.get_mut(winner.entity) {
|
||||
cooldown.per_fact_history.insert(winner.fact_id.clone());
|
||||
cooldown.npc_cooldown_until = current_tick + NPC_COOLDOWN_TICKS;
|
||||
|
||||
@@ -189,17 +189,12 @@ impl TraitModifierConfig {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Parse a confidence string from YAML config to enum value.
|
||||
/// Delegates to `KnowledgeConfidence::try_from` (which accepts both
|
||||
/// camelCase and underscore forms) rather than duplicating the match.
|
||||
fn parse_confidence(s: &str) -> Option<KnowledgeConfidence> {
|
||||
match s {
|
||||
"suspects" => Some(KnowledgeConfidence::Suspects),
|
||||
"knows_of" => Some(KnowledgeConfidence::KnowsOf),
|
||||
"knows_details" => Some(KnowledgeConfidence::KnowsDetails),
|
||||
"direct" => Some(KnowledgeConfidence::Direct),
|
||||
_ => {
|
||||
tracing::warn!("Unknown confidence level in trait config: {:?}", s);
|
||||
None
|
||||
}
|
||||
}
|
||||
KnowledgeConfidence::try_from(s).map_err(|e| {
|
||||
tracing::warn!("Unknown confidence level in trait config: {}", e);
|
||||
}).ok()
|
||||
}
|
||||
|
||||
/// Convert a `PersonalityTrait` to its lowercase YAML key.
|
||||
|
||||
Reference in New Issue
Block a user