# Knowledge Graph Data Model — D-041 # Per-entity bevy_ecs Component with BTreeMap storage. # Confidence hierarchy, knowledge state, knowledge source, event-driven updates. vars: { color-bg: "#2a3040" color-stroke: "#333340" color-text: "#c8d0e0" color-accent: "#c8d8f0" color-dim: "#1a1e24" } KnowledgeGraph: KnowledgeGraph { shape: sql_table entity_knowledge: BTreeMap fact_knowledge: BTreeMap } EntityKnowledge: EntityKnowledge { shape: sql_table stable_id: StableId(u64) {constraint: foreign_key} confidence: KnowledgeConfidence state: KnowledgeState source: KnowledgeSource last_observed_tick: u64 } FactKnowledge: FactKnowledge { shape: sql_table fact_id: FactId {constraint: primary_key} confidence: KnowledgeConfidence state: KnowledgeState source: KnowledgeSource last_observed_tick: u64 } KnowledgeConfidence: KnowledgeConfidence { shape: sql_table direct: Direct — currently in LOS knows_details: KnowsDetails — actionable (secret tier) knows_of: KnowsOf — involved in Y (real tier) suspects: Suspects — something off (surface tier) } KnowledgeState: KnowledgeState { shape: sql_table active: Active — believed true contradicted: Contradicted — conflict detected (Sprint 3+) stale: Stale — aged beyond threshold (Sprint 3+) } KnowledgeSource: KnowledgeSource { shape: sql_table direct_observation: DirectObservation heard: Heard told_by: ToldBy (Sprint 3+) inferred: Inferred (Sprint 3+) background: Background } EntityRegistry: EntityRegistry { shape: sql_table stable_to_entity: BTreeMap entity_to_stable: BTreeMap } KnowledgeEventQueue: KnowledgeEventQueue\n(bevy_ecs Resource) { shape: queue style.fill: ${color-dim} style.stroke: ${color-accent} style.font-color: ${color-text} } KnowledgeGraph -> EntityKnowledge: "contains many" KnowledgeGraph -> FactKnowledge: "contains many" EntityKnowledge -> KnowledgeConfidence: "uses" EntityKnowledge -> KnowledgeState: "uses" EntityKnowledge -> KnowledgeSource: "uses" FactKnowledge -> KnowledgeConfidence: "uses" FactKnowledge -> KnowledgeState: "uses" FactKnowledge -> KnowledgeSource: "uses" EntityKnowledge -> EntityRegistry: "StableId lookup" { style.stroke: ${color-accent} style.stroke-dash: 4 } KnowledgeEventQueue -> KnowledgeGraph: "drained each tick\n→ writes components" { style.stroke: ${color-accent} }