Ontologies and taxonomies
What ontologies and taxonomies are, why the harness uses them instead of a list of blocked commands, and how a tool call travels through them.
The harness guards your agents with ontologies and taxonomies. Those words can sound academic, but the idea is simple, and it’s the reason the guardrails stay readable and hard to get around.
What the words mean
Taxonomy comes from the Greek taxis, “arrangement”, and nomia, “method”. It means a way of arranging things into groups.
- The best-known example is biology: a house cat is a cat, which is a mammal, which is an animal. Each step is a more general group.
- Library shelves, product categories in a web shop and folders on your disk are all taxonomies too.
In everyday terms: a taxonomy is a tree of kinds, from general to specific.
Ontology comes from the Greek on, “being”, and logia, “study”. Philosophers use it for the study of what exists. In computing it means a written-down description of the things in a domain and how they relate: what kinds of things there are, what each one means, and how they connect.
- A taxonomy only says “a force push is a kind of destructive command”.
- An ontology can also say what a destructive command is, what it requires, which rules apply to it, and how to recognise one.
In everyday terms: an ontology is a taxonomy with meaning attached. Every taxonomy is a small ontology; most ontologies contain a taxonomy at their core.
| Taxonomy | Ontology | |
|---|---|---|
| Answers | “What kind of thing is this?” | “What kind of thing is this, what does it mean, and how does it relate to the rest?” |
| Shape | a tree: general at the top, specific below | a tree plus extra links between the branches |
| In HerdHound | rdfs:subClassOf, skos:broader |
definitions (rdfs:comment), matchers (hh:match…), rules (hh:Rule, hh:requires, hh:seeAlso) |
The rest of this page shows what that looks like for agent guardrails.
A taxonomy: things sorted into kinds
A taxonomy sorts things into kinds, from general to specific. Every item sits under a broader one: it is a kind of that.
Risky action
├── Destructive command rm -rf, git push --force, DROP TABLE
├── Secret exposure
│ ├── Secret file read .env, *.pem, id_rsa
│ └── Secret in a commit git add .env
└── Infrastructure change terraform apply, kubectl delete
A force push is a destructive command, and a destructive command is a risky action. So a force push is a risky action too, without anyone having to say so. That inheritance is the whole trick.
An ontology: the kinds, plus what they mean
An ontology is a taxonomy with more said about each kind:
- a definition: what counts as a secret file, in words a person and an agent can read,
- relations: a commit requires tests first, a rule applies to a kind, a kind is see also another,
- how to recognise it: which tool calls are instances of it.
Together that gives a shared vocabulary for your domain. It is precise enough for a program to check, and plain enough for a person, or an agent, to understand.
Why the harness uses them
The obvious way to guard an agent is a list: block rm -rf, block git push --force, block reading .env. That works for a day. Then it falls apart:
| A flat list of blocked patterns | An ontology |
|---|---|
| One rule per pattern. Hundreds of patterns, hundreds of rules to keep in step. | Rules sit on kinds. One rule on risky action covers everything below it. |
| A new pattern needs its own new rule, or slips through. | A new pattern is a new narrower kind. The rules above already apply to it. |
The agent is told “blocked: rm\s+-rf”. It tries find -delete next. |
The agent is told “this is a destructive command, a kind of risky action: never delete recursively; ask the user”. It understands the intent, not just the pattern. |
| Recognising a call and deciding about it are tangled together. | Recognising (matchers on kinds) is separate from deciding (rules on kinds). You change one without breaking the other. |
| Each team writes its own list in its own format. | Turtle, RDF, OWL and SKOS are open standards. You can read, review, diff, reuse and visualise them with any tooling. |
Four things follow from that:
- Rules at the right height. Policies are written in the language of the policy (“no destructive commands”), not in regular expressions. They stay short as coverage grows.
- Agents that understand why. When a rule fires, the agent gets the concept, its definition and where to look next:
herdhound harness explain DestructiveCommand. Agents follow a rule much better when they can see what it protects, and they don’t go looking for the next command the list forgot. - One vocabulary, every session. The same ontology syncs to every container. The words you use in reviews are the words the agents are checked against.
- Changes you can review. An ontology is a text file. A pull request that adds “Secret in a commit is a kind of secret exposure” is easy to read and easy to question.
How a tool call travels through them
Say an agent runs git push --force origin main.
- Recognise. The hook checks the call against every kind that has matchers. Destructive command has
hh:matchTool "Bash"and anhh:matchInputpattern that matchesgit push --force. That’s a direct match. - Climb the taxonomy. Destructive command is a kind of risky action, so the call is also a risky action.
- Apply the rules. Two rules fire:
NoDestroy(deny) on destructive command,CareWithRisk(warn) on risky action.
- Decide. The strictest rule wins: deny. Claude Code blocks the call and shows the agent the reason, with the concepts to look up.
- Log. The call goes into the activity log with its concepts and decision, and you see it in the Harness view as it happens.
A rule can also look back. hh:requires makes a rule fire only if something has not happened yet in the session, for example “a commit asks you, unless running the tests came first”.
Try it on the homepage playground, which runs this example. To see what your own ontologies decide, use the command line:
herdhound harness classify Bash '{"command":"git push --force origin main"}'
Words you will meet
| Word | Meaning |
|---|---|
| Concept (or class) | A kind of thing: destructive command, secret file. Declared with owl:Class, rdfs:Class or skos:Concept. |
| Instance | One particular thing of that kind. For the harness, a tool call that matches the concept. |
| Broader / narrower | Up and down the taxonomy. rdfs:subClassOf and skos:broader point up; skos:narrower points down. |
| IRI | The full, unique name of a concept, like https://example.org/ops#DestructiveCommand. |
| Prefix | A short form for the start of IRIs: with @prefix ops: <https://example.org/ops#>, you write ops:DestructiveCommand. |
| Triple | One statement: subject, predicate, object. ops:ForcePush rdfs:subClassOf ops:DestructiveCommand . |
| Turtle | The text format the files are written in, one .ttl file per domain. |
| Rule | A hh:Rule: it applies to a concept and has a severity (deny, ask or warn) and a message. See the vocabulary. |
Designing your own
- Start from what worries you, not from commands. List the risks in plain words, group them, and only then add matchers.
- Keep it shallow. Two or three levels are usually enough. Each level should mean something a reviewer would recognise.
- Name kinds as nouns: secret file, not block env. A kind describes what something is; the rule decides what to do about it.
- Write the comments.
rdfs:commentis what agents read when they look a concept up. One clear sentence prevents most workarounds. - Rules on broad kinds, matchers on narrow ones. That way new matchers inherit the rules for free.
- Prefer warn and ask to start with. Watch the activity log for a while, then tighten the rules that turn out to matter.
- Use the built-in ontologies. HerdHound ships seven: ACID transactions, application security, clean code, code comments, harness protection, infrastructure as code and secrets. Read them, extend them, or delete the ones you don’t want (d in the Harness view).
Then let Ask AI interview you. It turns your answers into Turtle and checks the result.