Skip to content

Commit 52a0055

Browse files
committed
Grok backend proposal: proposed/ogit_dolce_spine.rs
1 parent 5a2bfe3 commit 52a0055

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
//! OGIT + DOLCE Canonical Ontology Spine for lance-graph-ontology
2+
//!
3+
//! This is a proposed foundation for the ontology crate.
4+
//! It aligns the existing OGIT spine scaffolding with DOLCE foundational categories.
5+
//! Goal: Provide strong cognitive/NARS grounding while keeping OGIT as the project canonical layer.
6+
7+
use std::collections::HashMap;
8+
9+
/// Core DOLCE-inspired categories (simplified for Rust embedding)
10+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11+
pub enum DolceCategory {
12+
/// Endurant - objects that persist through time (e.g. "Apple", "Person")
13+
Endurant,
14+
/// Perdurant - events/processes (e.g. "Eating", "ReasoningStep")
15+
Perdurant,
16+
/// Quality - properties/qualia (e.g. color, truth-value, emotional state)
17+
Quality,
18+
/// Abstract - non-spatio-temporal (e.g. numbers, types, NARS terms)
19+
Abstract,
20+
/// Particular - concrete instances
21+
Particular,
22+
}
23+
24+
/// OGIT Spine Node — the canonical internal representation
25+
#[derive(Debug, Clone)]
26+
pub struct OgitNode {
27+
pub id: String,
28+
pub ogit_type: String, // e.g. "ogit:Concept", "ogit:Event"
29+
pub dolce_category: DolceCategory, // Grounding in DOLCE
30+
pub labels: HashMap<String, String>, // Bilingual labels (en, de, ...)
31+
pub properties: HashMap<String, String>, // Arbitrary props
32+
pub truth_value: Option<(f32, f32)>, // NARS-style <f, c>
33+
pub qualia: Option<Vec<i8>>, // 8-dimensional emotional/qualia vector (for Firefly CONTEXT)
34+
}
35+
36+
/// Relation in the OGIT spine
37+
#[derive(Debug, Clone)]
38+
pub struct OgitRelation {
39+
pub id: String,
40+
pub relation_type: String, // e.g. "ogit:causes", "ogit:partOf"
41+
pub dolce_category: DolceCategory,
42+
pub source: String, // source node id
43+
pub target: String, // target node id
44+
pub properties: HashMap<String, String>,
45+
}
46+
47+
/// The main Ontology Spine — this is what should live in lance-graph-ontology/src/ontology/
48+
pub struct OgitDolceSpine {
49+
nodes: HashMap<String, OgitNode>,
50+
relations: HashMap<String, OgitRelation>,
51+
// Future: OWL import cache, DOLCE alignment table, etc.
52+
}
53+
54+
impl OgitDolceSpine {
55+
pub fn new() -> Self {
56+
Self {
57+
nodes: HashMap::new(),
58+
relations: HashMap::new(),
59+
}
60+
}
61+
62+
/// Create a new node grounded in both OGIT and DOLCE
63+
pub fn create_node(
64+
&mut self,
65+
id: String,
66+
ogit_type: String,
67+
dolce: DolceCategory,
68+
labels: HashMap<String, String>,
69+
) -> &OgitNode {
70+
let node = OgitNode {
71+
id: id.clone(),
72+
ogit_type,
73+
dolce_category: dolce,
74+
labels,
75+
properties: HashMap::new(),
76+
truth_value: None,
77+
qualia: None,
78+
};
79+
self.nodes.insert(id.clone(), node);
80+
self.nodes.get(&id).unwrap()
81+
}
82+
83+
/// Add NARS-style truth value + qualia (directly usable by Firefly Frame CONTEXT field)
84+
pub fn annotate_with_nars_context(&mut self, node_id: &str, f: f32, c: f32, qualia: Vec<i8>) {
85+
if let Some(node) = self.nodes.get_mut(node_id) {
86+
node.truth_value = Some((f, c));
87+
node.qualia = Some(qualia);
88+
}
89+
}
90+
91+
/// Example: Create a perdurant event (very useful for NARS + causal reasoning in Firefly)
92+
pub fn create_perdurant_event(&mut self, id: String, label_en: &str) -> &OgitNode {
93+
let mut labels = HashMap::new();
94+
labels.insert("en".to_string(), label_en.to_string());
95+
self.create_node(id, "ogit:Event".to_string(), DolceCategory::Perdurant, labels)
96+
}
97+
98+
// TODO: Add methods for:
99+
// - DOLCE alignment lookup table
100+
// - Export to OWL
101+
// - Import from OWL
102+
// - Mapping to Firefly Frame payload
103+
}
104+
105+
#[cfg(test)]
106+
mod tests {
107+
use super::*;
108+
109+
#[test]
110+
fn test_create_perdurant() {
111+
let mut spine = OgitDolceSpine::new();
112+
let node = spine.create_perdurant_event("evt:reasoning-42".to_string(), "NARS inference step");
113+
assert_eq!(node.dolce_category, DolceCategory::Perdurant);
114+
assert_eq!(node.ogit_type, "ogit:Event");
115+
}
116+
}

0 commit comments

Comments
 (0)