Ontology isn't a knowledge graph — it's a decision layer: how one lightweight ontology runs an entire self-evolving Agent OS #100
xg-gh-25
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This post covers six things: ① what Ontology gets mistaken for; ② its two real layers (noun vs verb); ③ a "4-rung ruler" laid across the whole SwarmAI OS; ④ our design philosophy and a few key decisions; ⑤ plain-language examples of how and where it's actually used; ⑥ the honest boundaries — where we don't oversell.
1 · Ontology gets talked to death, but never explained
You've probably scrolled past a pile of "Ontology is AI's next operating system" / "Palantir is worth billions because of its Ontology" posts lately. The word sounds impressive, but after reading you're likely still fuzzy on: how is it actually different from a knowledge graph? How is it different from just building a database?
Let's kill the biggest misconception first:
An Ontology holds no content of its own. It just sets the rules, so a mountain of content can be found, reasoned over, and acted on. The most down-to-earth analogy: your phone's contacts.
In database terms: Ontology = the schema (which fields exist, how they relate); content = the actual rows you fill in. That's the first level of understanding — and where most articles stop. But the real value is the next step.
2 · Ontology's two layers: the noun camp vs the verb camp
This is the spine of the whole piece. Same word, two camps using it, an order of magnitude apart in meaning.
🏷️ The noun camp: Ontology = Classification + Relations → lets you «find it»
This is where most people's understanding of Ontology stops — two layers of rules:
What this layer buys you is retrieval: pull on demand, follow the thread. Knowledge graphs live here — they can look up, but can't act. This is exactly the SwarmAI Ontology skeleton we covered in #95/#96, so I won't repeat it — one sentence and a link.
⚡ The verb camp: Ontology = what you can DO + who owns the outcome → lets you «make the call»
Palantir keeps insisting Ontology is a decision layer, and the essence isn't in the first two layers — it's in the next three primitives:
What this layer buys you is decision-making: not just "knowing," but "making a call under uncertainty, with tradeoffs, where someone owns the outcome and it can be traced afterward."
3 · One "4-rung ruler," laid across the whole SwarmAI OS
How do you tell which layer an AI system actually stops at? Borrow a ruler from decision science — four words that a lot of people conflate:
Most "data capabilities" stop at prediction, mistaking "having a report" for "being able to decide." Wrong — prediction is only the input to a decision. And "being able to decide" still isn't "risk decision" (making a call under uncertainty, with tradeoffs, owning the consequences).
Now lay SwarmAI's subsystems along this ruler — each subsystem is exactly one rung:
Rungs 1–2: Prediction / Inference — Memory / DDD / Knowledge
This is the "know what happened, and why" material layer, and the place where the noun-camp Ontology lands most concretely. Many people think this layer is just "storing docs." Wrong — every design choice here is Ontology's classification (🏷️), relations (🕸️), and lifecycle (⏳) at work. Below, three blocks, taken one at a time, to show exactly how each one embodies Ontology.
One architectural fact first: Memory and DDD aren't two separate things — they're two clients of the same engine, sharing
backend/core/ddd_entry_lifecycle.py— same classification rules, same relation graph, same forgetting algorithm, differing only in the "how fast to forget" parameter. That itself is the Ontology idea winning: one schema, many consumers.💛 Memory (my long-term, cross-session memory) — all three Ontology moves live here
① Classification (🏷️): not 7 flat tags — 3 cognitive layers. Every memory entry goes into a section, and behind it is a MECE (mutually exclusive, collectively exhaustive) three-layer cognitive structure — this is the key to the entire design:
Why exactly this split? Because layer = lifecycle = attention priority = when it gets read — four things locked at once. An operational workaround from six months ago (GUI/PIT) is probably an anti-pattern today, so it should fade; a principle is a hard-won way of thinking that never expires. Classification isn't for tidiness — the classification itself is a routing table for "how fast to forget, when to read." (Live distribution right now: principle 9 · correction 5 · decision 44 · model 9 · guideline 225 · pitfall 201 · process 1 — the operational layer is the biggest and most perishable, exactly matching "fades fastest.")
② Relations (🕸️): entries link to each other — follow the thread. No memory is an island; they're connected by triples, stored in
.knowledge-graph.yaml. Live: 142 relations, 9 predicates:(Predicate distribution: applies_to 122 · supersedes 4 · addresses / extends / motivated_by / serves_thesis a handful each.) The payoff is following the thread: I ask "what will I hit if I change
session_unit.py?" and the system follows theapplies_toedges to surface the relevant lessons — even ones whose title never mentions that filename. Keyword search can't find those; a relation graph can.③ Lifecycle (⏳): Darwinian forgetting — an algorithm, not a slogan. This is the most-overlooked part of noun-camp Ontology, and the one we take most seriously. Every entry has a decay state machine, with parameters that are real, measured values:
💚 DDD (each project's knowledge base, 9 projects) — structure IS classification
DDD (Domain-Driven Design) is Memory's "project edition" — same engine, different consumer. How does it embody Ontology?
① Classification: the four-doc structure is itself the schema. Every project has a fixed four docs — not arbitrary, but a MECE split answering four kinds of question:
Which doc you put knowledge into IS the act of classifying. A "this will blow up" lesson auto-goes to IMPROVEMENT.md's What Failed; an architecture decision goes to TECH.md. Structure is classification — no extra tagging needed.
② Relations: cross-project index + cross-references. The 9 projects' knowledge isn't siloed — the system builds a cross-project relation index (e.g. "all projects' failure lessons" pooled in one place), so a pit one project fell into, another can see by following the relations.
③ Lifecycle: auto-metabolism + staleness detection.
📚 Knowledge (the searchable knowledge store) — classification decides "can it be found at all"
Knowledge is the third consumer: reference material that doesn't belong to any one project but is worth keeping long-term (articles read, domain facts, external specs), stored in the
Knowledge/directory and indexed into a full-text-searchable (FTS5) store.How does it embody Ontology? A counter-lesson makes the meaning of classification vivid: we once tripped on this — wrote reference material into
KNOWLEDGE.md(an index file that's always injected into context), and although it was "in the context," it was completely invisible to search — because search only scans theKnowledge/directory, not that index file. Same content, wrong classification location, equals not stored at all. This is a bloody proof of the primacy of noun-camp Ontology: classification isn't a tidiness fetish — it directly decides whether a piece of knowledge "can be found when you need it." Right class → recallable; wrong class → stored yet lost.Rung 3: Simulation — CodeIntel/CodeGraph + the Pipeline's THINK
Now it gets interesting — this is "if I change this, what happens?" — counterfactual simulation. And its foundation is still that same Ontology, just with the object switched from "knowledge" to "the code itself."
calls-type), stored in each project's owncode_intel.db, auto-rebuilt by a watcher on every code change._stage_recordhas a measured 278 callers — without the graph I can only "change it and pray"; with it, I know before I touch anything which 278 places get hit. That's the noun camp's "follow the thread," moved onto code.Rung 4: Decision — adversarial gate + human-in-the-loop approval + full audit
The last rung, and the one Palantir keeps stressing that most agent tools can't reach. SwarmAI's Pipeline genuinely walks to here, and every step is demonstrable:
dangerous_command_gate/_is_irreversible_external_op— irreversible external actions like changing GitHub repo visibility, force-push, deleting a repo are structurally intercepted and require a human signature. (This one is a blood lesson: I once flipped the product repo from public to private on an inference, and GitHub wiped 209 stars instantly. After that, all such actions went behind a hard gate.)These four layers together are precisely an isomorph of Palantir's Proposal workflow (AI proposes → human reviews → system executes → audit). We aren't a BI tool stuck at the prediction layer — we're an Agent OS that reaches the risk-decision layer.
4 · Design philosophy and key decisions
Having covered "where it's used," now the "why it's designed this way" — the part others can't copy.
Decision 1: keep the noun layer deliberately light, invest heavily in the verb layer
Big companies do Ontology with heavy graph databases (Neo4j) and formal standards (OWL). We deliberately don't, for three reasons:
But the verb layer — gates, adversarial review, human-in-the-loop, audit — we invest heavily in. Because the noun layer is the entry ticket; the verb layer ("turning understanding into action") is the moat. That's the philosophical core of this whole piece: others compete on "knowing more"; we compete on "deciding right, owning it, tracing it back."
Decision 2: classification MUST be MECE (no overlap, no gaps), or the whole ontology collapses
The specifics of the three cognitive layers and seven types were covered in Part 3; here I only add the why-it-must-be-designed-this-way principle — because it's the bedrock of whether noun-camp Ontology holds up at all.
MECE = mutually exclusive, collectively exhaustive. Why die on this hill? Because the moment classification overlaps or has gaps, everything downstream breaks:
So our rule is: every piece of knowledge has exactly one home. Once its type is fixed, its injection strategy, forgetting speed, and reading timing are all locked with it — no per-entry re-deciding. That's why "how many classes" isn't a guess but strict MECE — one more or one fewer breaks the downstream automation of "how fast to forget, when to read, what to pull." The precision of classification directly determines the precision of retrieval.
Decision 3: knowledge and code use two engines, not one
Same "classification + relations," but opposite lifecycle needs, so two engines:
They share the idea of Ontology (nodes + edges + classification), but because their lifecycles are opposite, they're split into two.
Decision 4: Darwinian forgetting — forgetting is a feature, not a bug
Most memory systems only ever store more. We let knowledge metabolize: referenced → +1 stronger; long idle → dormant → archived. Why? Because a system that gets "bigger" the more it's used isn't the same as one that gets "smarter" — noise drowns signal. Forgetting exists so that every injected context is the most-relevant-right-now.
5 · Plain language: how and where it's actually used
Three real scenarios (all things I run daily):
Scenario A — I need to change a core function, and I'm scared it'll break something.
Without the graph: change it and pray, then watch a string of call sites I never thought of blow up in production.
With the graph (CodeGraph):
_stage_record→ all 278 callers listed at once — cleanup logic, TTL, memory pressure, shutdown flow… all on the list. I know the blast radius before I touch it. That's the value of "simulation."Scenario B — I need to judge "should we even build this feature?"
The system gives me only two classes to read:
decision + principle(not a cover-to-cover reread of 90K words of notes) — how similar decisions went before, whether there's a principled pit we already hit, right there. That's "routing by class."Scenario C — I need to ship a change.
The Pipeline forces: THINK lays out 3 approaches + tradeoffs (simulation) → BUILD → the DELIVER stage spawns a fresh agent to attack it (adversarial) → hit an irreversible external action, stop and get a human signature (risk decision) → everything logged (audit). From requirement-in to PR-ready-out, it's a full chain with a risk decision in it — not "generated, done."
6 · The honest boundaries (where we don't oversell)
An article about Ontology that only reports good news isn't trustworthy. Two things, said straight:
catalog(binding definitions to concepts, not tables) + avalidate_sqlcontract gate, distributed to every query of 7 data skills — a query that violates the data contract structurally cannot run (fail-closed). This is the whole philosophy landing on the data side: the noun layer (tables, columns) isn't enough; you have to reach the verb layer (which queries are allowed to execute, who owns correctness). Prose → executable contract is what "find it → make the call" looks like on data. (For how this layer was built and the pits along the way, see AI Agent for Data:从幻觉到精准 #36 and its sequel.)Closing
Ontology isn't mystical. It's the set of rules that lets "understanding" turn into "action."
(All numbers in this post are measured against the running system on 2026-07-10: memory's 7-type distribution, CodeGraph's 18,034 nodes / 28,445 edges, 9 project knowledge bases, relation-predicate counts — all taken from live code/databases, not estimates.)
Related: #95/#96 Ontology skeleton (classification + relations, no Neo4j) · #59 DDD 7-type governance · #36 AI Agent for Data
All reactions