---
name: ontology
title: "Knowledge Ontology"
description: "Formal schema for the knowledge graph — entity types, predicates, inference rules. Agent-extensible."
category: _meta
status: active
triggers:
  - "ontology"
  - "add predicate"
  - "add entity type"
  - "knowledge schema"
  - "relationship types"
  - "what predicates"
  - "extend ontology"
---

# Knowledge Ontology

You manage the knowledge graph's formal schema. The ontology defines what kinds of things exist (entity types), how they can relate (predicates), and what can be inferred automatically (inference rules).

## Architecture

- **Engine** (`memory/ontology.py`): validation, inference, loading. Never edit this for vocabulary changes.
- **Vocabulary** (`skills/_meta/ontology/config/ontology.yaml`): all entity types, predicates, inference rules. This is what you extend.
- **This skill**: strategy for when and how to propose changes.

## When to Propose Ontology Extensions

1. **You see a pattern**: the same unnamed relationship appears 3+ times in extractions (e.g., "mentors", "competes_with", "funds")
2. **User describes a domain**: "I work in biotech" → propose domain entity types (compound, pathway, trial)
3. **Extraction falls back to `related_to`**: this means the ontology lacks the right predicate. After 3+ fallbacks with similar semantics, propose a specific predicate.
4. **User explicitly asks**: "add a predicate for mentoring relationships"

## How to Propose

1. Check fallbacks first: use `update_ontology` with `action: "get_fallbacks"` to see which predicates are hitting `related_to`
2. Explain what you've observed (the pattern, the gap)
3. Propose the specific addition with domain/range/cardinality
4. Ask user to approve
5. On approval, use `update_ontology` with `action: "add_predicate"` — this writes to YAML and reloads automatically

## Rules

- Never add predicates silently. Always explain and get approval.
- Prefer existing predicates over new ones. Check if `related_to`, `part_of`, `is_a` already cover it.
- Every predicate needs a clear domain and range. "anything → anything" is `related_to` — don't duplicate it.
- Inverse predicates come in pairs. If you add `mentors`, also add `mentored_by`.
- Entity types should be genuinely distinct, not synonyms. "company" and "organization" are the same thing.
- Inference rules must be logically sound. `collaborates_with → knows` is correct. `knows → collaborates_with` is not.
- Keep descriptions concise — they're injected into LLM prompts.

## Ontology Status Report

When asked about the ontology, report:
1. Entity types (count, list)
2. Predicates (count, grouped by domain)
3. Inference rules (what implies what)
4. Recent `related_to` fallbacks (candidates for new predicates)
5. Coverage gaps (domains with few predicates)
