Ontology Module - Clean-Room Knowledge Graph
Zero external dependencies. SQLite-based. Sovereign Stack compatible.
Status: โ INTEGRATED
Completed: 2026-04-27
Lines of code: ~1,100 (schema + engine + NL interface)
Test coverage: 7 query patterns verified
Files
| File | Lines | Purpose |
|---|---|---|
schema.sql |
97 | Database DDL + bootstrap data |
engine.py |
384 | Core CRUD, queries, export |
natural_language.py |
433 | NL interface, no Cypher/Gremlin |
README.md |
โ | This file |
Quick Start
cd /home/hoffmann_admin/.openclaw/shared/ontology
# Test the engine
python3 -c "from engine import OntologyEngine; e = OntologyEngine(); print(e.get_stats())"
# Test natural language queries
python3 -c "from natural_language import ask_ontology; print(ask_ontology('who works on icarus'))"
# CLI entry points
python3 -m ontology.engine stats
python3 -m ontology.engine query "what projects is socrates working on"
python3 -m ontology.engine export ~/Obsidian/Ontology
Verified Query Patterns
| Pattern | Example | Result |
|---|---|---|
| Projects involving | what projects is socrates working on |
๐ Icarus |
| Who works on | who works on icarus |
๐ฅ Socrates, Daedalus, Wadsworth |
| Entity lookup | who is wadsworth |
๐ chief_of_staff, glm-5.1:cloud |
| List by type | show all agents |
๐ Wadsworth, Socrates, Daedalus |
| Relations | relations of wadsworth |
๐ โ Matt, โ Icarus |
| Family | who is in the hoffmann family |
๐จโ๐ฉโ๐งโ๐ฆ Matt, Aundrea, Sully, Harper |
| Profile | tell me about matt |
๐ director, hoffmann family |
Bootstrap Data (Pre-loaded)
Board:
- person:matt โ Director
- agent:wadsworth โ Chief of Staff (glm-5.1:cloud)
- agent:socrates โ Backend Architect (kimi-k2.5:cloud)
- agent:daedalus โ UX Architect (deepseek-v4:cloud)
Family:
- person:aundrea โ Matt's spouse
- person:sully โ Son, 1st grade
- person:harper โ Daughter, pre-k
Projects:
- project:icarus โ Phase 5, family assistant
- project:costco_route โ Stable, shopping optimizer
- project:ontology โ Building, knowledge graph
Relations:
- serves, works_on, coordinates, child_of, spouse_of
Python API
from ontology.engine import OntologyEngine, get_engine
from ontology.natural_language import ask_ontology
# Direct CRUD
engine = OntologyEngine()
engine.add_entity("concept:ghost_bug", "concept", "Ghost Bug", {"severity": "critical"})
engine.add_relation("project:icarus", "concept:ghost_bug", "affected_by")
# Natural language
result = ask_ontology("what projects is wadsworth working on")
# Returns: "๐ Projects involving wadsworth:
# โข Icarus (phase_5)
# โข Ontology (building)"
# Export to Obsidian
engine.export_to_obsidian(Path("~/Obsidian/Ontology"))
Schema
Entities
id(PK):type:nameformat (e.g.,agent:wadsworth)type: person, agent, project, event, document, skill, system, location, organization, conceptname: Human-readable labelproperties: JSON flexible attributessource: Where we learned this (manual, system, inferred)confidence: 0.0-1.0 certaintycreated_at,updated_at: Timestamps
Relations
from_id,to_id,relation_type(composite PK)properties: JSON relation attributesconfidence: 0.0-1.0created_at: Timestamp
Observations
- Temporal facts about entities
entity_id,observation(text),observed_at,source,confidence
Obsidian Export
Generates Markdown files with wikilinks:
# Wadsworth
**Type:** agent
## Properties
- role: chief_of_staff
- model: glm-5.1:cloud
## Relations
- โ [[person:matt|Matt]] (serves)
- โ [[project:icarus|Icarus]] (coordinates)
Sovereign Stack Principles
- โ No cloud dependencies โ SQLite only
- โ No new graph DB โ Plain SQL, no Cypher/Gremlin
- โ Natural language โ No query language to learn
- โ Human-in-the-loop โ All modifications require explicit intent
- โ Exportable โ Plain text, Obsidian-compatible
- โ Clean-room โ Zero code from ClawHub skill
Integration Points
Wadsworth can use this for:
- Cross-referencing projects and agents
- Family member lookups (e.g., "who needs to know about Sully's field trip?")
- Contextual awareness (e.g., "Socrates worked on Icarus โ use backend patterns")
- Memory lineage (observations trace back to source)
Future extensions:
- Link to daily logs (memory/YYYY-MM-DD.md)
- Auto-extract entities from conversations
- Confidence decay for stale observations
- Temporal queries ("what was Socrates working on last month?")
License
Same as OpenClaw โ MIT or as specified by Director.
Clean-room implementation. 1,100 lines. Zero dependencies. Sovereign by design.