Skills/ #agents/ #knowledge/ #productivity

ontology

Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linkin...

oswalpalash@oswalpalash

Install

Run this command against the local KakaHub registry.

$ openclaw install ontology --registry http://localhost:13001Download

README

--- name: ontology description: Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access. ---

Ontology

A typed vocabulary + constraint system for representing knowledge as a verifiable graph.

Core Concept

Everything is an **entity** with a **type**, **properties**, and **relations** to other entities. Every mutation is validated against type constraints before committing.

Entity: { id, type, properties, relations, created, updated } Relation: { from_id, relation_type, to_id, properties }

When to Use

| Trigger | Action | |---------|--------| | "Remember that..." | Create/update entity | | "What do I know about X?" | Query graph | | "Link X to Y" | Create relation | | "Show all tasks for project Z" | Graph traversal | | "What depends on X?" | Dependency query | | Planning multi-step work | Model as graph transformations | | Skill needs shared state | Read/write ontology objects |

Core Types

yaml# Agents & People
Person: { name, email?, phone?, notes? }
Organization: { name, type?, members[] }

# Work
Project: { name, status, goals[], owner? }
Task: { title, status, due?, priority?, assignee?, blockers[] }
Goal: { description, target_date?, metrics[] }

# Time & Place
Event: { title, start, end?, location?, attendees[], recurrence? }
Location: { name, address?, coordinates? }

# Information
Document: { title, path?, url?, summary? }
Message: { content, sender, recipients[], thread? }
Thread: { subject, participants[], messages[] }
Note: { content, tags[], refs[] }

# Resources
Account: { service, username, credential_ref? }
Device: { name, type, identifiers[] }
Credential: { service, secret_ref }  # Never store secrets directly

# Meta
Action: { type, target, timestamp, outcome? }
Policy: { scope, rule, enforcement }

Storage

Default: `memory/ontology/graph.jsonl`

jsonl{"op":"create","entity":{"id":"p_001","type":"Person","properties":{"name":"Alice"}}}
{"op":"create","entity":{"id":"proj_001","type":"Project","properties":{"name":"Website Redesign","status":"active"}}}
{"op":"relate","from":"proj_001","rel":"has_owner","to":"p_001"}

Query via scripts or direct file ops. For complex graphs, migrate to SQLite.

Append-Only Rule

When working with existing ontology data or schema, **append/merge** changes instead of overwriting files. This preserves history and avoids clobbering prior definitions.

Workflows

Create Entity

bashpython3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"alice@example.com"}'

Query

bashpython3 scripts/ontology.py query --type Task --where '{"status":"open"}'
python3 scripts/ontology.py get --id task_001
python3 scripts/ontology.py related --id proj_001 --rel has_task

Link Entities

bashpython3 scripts/ontology.py relate --from proj_001 --rel has_task --to task_001

Validate

bashpython3 scripts/ontology.py validate  # Check all constraints

Constraints

Define in `memory/ontology/schema.yaml`:

yamltypes:
  Task:
    required: [title, status]
    status_enum: [open, in_progress, blocked, done]
  
  Event:
    required: [title, start]
    validate: "end >= start if end exists"

  Credential:
    required: [service, secret_ref]
    forbidden_properties: [password, secret, token]  # Force indirection

relations:
  has_owner:
    from_types: [Project, Task]
    to_types: [Person]
    cardinality: many_to_one
  
  blocks:
    from_types: [Task]
    to_types: [Task]
    acyclic: true  # No circular dependencies

Skill Contract

Skills that use ontology should declare:

yaml# In SKILL.md frontmatter or header
ontology:
  reads: [Task, Project, Person]
  writes: [Task, Action]
  preconditions:
    - "Task.assignee must exist"
  postconditions:
    - "Created Task has status=open"

Planning as Graph Transformation

Model multi-step plans as a sequence of graph operations:

Plan: "Schedule team meeting and create follow-up tasks"

1. CREATE Event { title: "Team Sync", attendees: [p_001, p_002] } 2. RELATE Event -> has_project -> proj_001 3. CREATE Task { title: "Prepare agenda", assignee: p_001 } 4. RELATE Task -> for_event -> event_001 5. CREATE Task { title: "Send summary", assignee: p_001, blockers: [task_001] }

Each step is validated before execution. Rollback on constraint violation.

Integration Patterns

With Causal Inference

Log ontology mutations as causal actions:

python# When creating/updating entities, also log to causal action log
action = {
    "action": "create_entity",
    "domain": "ontology", 
    "context": {"type": "Task", "project": "proj_001"},
    "outcome": "created"
}

Cross-Skill Communication

python# Email skill creates commitment
commitment = ontology.create("Commitment", {
    "source_message": msg_id,
    "description": "Send report by Friday",
    "due": "2026-01-31"
})

# Task skill picks it up
tasks = ontology.query("Commitment", {"status": "pending"})
for c in tasks:
    ontology.create("Task", {
        "title": c.description,
        "due": c.due,
        "source": c.id
    })

Quick Start

bash# Initialize ontology storage
mkdir -p memory/ontology
touch memory/ontology/graph.jsonl

# Create schema (optional but recommended)
python3 scripts/ontology.py schema-append --data '{
  "types": {
    "Task": { "required": ["title", "status"] },
    "Project": { "required": ["name"] },
    "Person": { "required": ["name"] }
  }
}'

# Start using
python3 scripts/ontology.py create --type Person --props '{"name":"Alice"}'
python3 scripts/ontology.py list --type Person

References

  • `references/schema.md` — Full type definitions and constraint patterns
  • `references/queries.md` — Query language and traversal examples

Instruction Scope

Runtime instructions operate on local files (`memory/ontology/graph.jsonl` and `memory/ontology/schema.yaml`) and provide CLI usage for create/query/relate/validate; this is within scope. The skill reads/writes workspace files and will create the `memory/ontology` directory when used. Validation includes property/enum/forbidden checks, relation type/cardinality validation, acyclicity for relations marked `acyclic: true`, and Event `end >= start` checks; other higher-level constraints may still be documentation-only unless implemented in code.

Install resolver

{
  "artifact": {
    "downloadUrl": "/api/v1/download?slug=ontology&version=1.0.4&ownerHandle=oswalpalash",
    "format": "zip",
    "generated": true,
    "kind": "skillArchive",
    "sha256": "08a466389799007cbf3c4ca48b75876619109f0b2da9ec8c03d320e511d39ad4",
    "size": 8090
  },
  "owner": {
    "displayName": "oswalpalash",
    "handle": "oswalpalash",
    "id": "21226689-d29d-4f46-b19a-f49239b46ebb",
    "verified": false
  },
  "skill": {
    "displayName": "ontology",
    "latestVersion": "1.0.4",
    "license": "MIT-0",
    "name": "ontology",
    "ownerHandle": "oswalpalash",
    "slug": "ontology",
    "stats": {
      "downloads": 191609,
      "installs": 7239,
      "stars": 649
    },
    "summary": "Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linkin...",
    "tags": [
      "agents",
      "knowledge",
      "productivity",
      "Agent Memory"
    ],
    "type": "skill",
    "updatedAt": "2026-07-06T10:48:16.014Z"
  },
  "sourceHandoff": null,
  "version": {
    "checksum": null,
    "checksumAlgorithm": null,
    "id": "ea28a5b2-4ca2-478d-90b4-e22fa4dbc0a7",
    "publishedAt": "2026-03-11T17:19:19.725Z",
    "size": null,
    "version": "1.0.4",
    "artifactStorageKey": null,
    "changelog": "- Initial release of the ontology skill for typed, constraint-validated knowledge graphs.\n- Supports entity and relation CRUD, property and relation validation, and graph traversal for common types such as Person, Project, Task, Event, and Document.\n- Provides schema-driven constraints including required properties, enums, forbidden fields, cardinality, and acyclicity.\n- Enables multi-step planning and shared memory across skills via structured ontology objects.\n- Includes CLI tooling for creating, querying, linking, and validating graph data using JSONL storage.",
    "manifest": {
      "clawhub": {
        "tags": {
          "latest": "1.0.4"
        },
        "owner": "oswalpalash",
        "stats": {
          "stars": 649,
          "comments": 7,
          "installs": 7239,
          "versions": 4,
          "downloads": 191609
        },
        "topics": [
          "Agent Memory"
        ],
        "categories": [
          "agents",
          "knowledge",
          "productivity"
        ]
      },
      "install": "openclaw skills install @oswalpalash/ontology"
    },
    "readme": "---\nname: ontology\ndescription: Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on \"remember\", \"what do I know about\", \"link X to Y\", \"show dependencies\", entity CRUD, or cross-skill data access.\n---\n\n# Ontology\n\nA typed vocabulary + constraint system for representing knowledge as a verifiable graph.\n\n## Core Concept\n\nEverything is an **entity** with a **type**, **properties**, and **relations** to other entities. Every mutation is validated against type constraints before committing.\n\n```\nEntity: { id, type, properties, relations, created, updated }\nRelation: { from_id, relation_type, to_id, properties }\n```\n\n## When to Use\n\n| Trigger | Action |\n|---------|--------|\n| \"Remember that...\" | Create/update entity |\n| \"What do I know about X?\" | Query graph |\n| \"Link X to Y\" | Create relation |\n| \"Show all tasks for project Z\" | Graph traversal |\n| \"What depends on X?\" | Dependency query |\n| Planning multi-step work | Model as graph transformations |\n| Skill needs shared state | Read/write ontology objects |\n\n## Core Types\n\n```yaml\n# Agents & People\nPerson: { name, email?, phone?, notes? }\nOrganization: { name, type?, members[] }\n\n# Work\nProject: { name, status, goals[], owner? }\nTask: { title, status, due?, priority?, assignee?, blockers[] }\nGoal: { description, target_date?, metrics[] }\n\n# Time & Place\nEvent: { title, start, end?, location?, attendees[], recurrence? }\nLocation: { name, address?, coordinates? }\n\n# Information\nDocument: { title, path?, url?, summary? }\nMessage: { content, sender, recipients[], thread? }\nThread: { subject, participants[], messages[] }\nNote: { content, tags[], refs[] }\n\n# Resources\nAccount: { service, username, credential_ref? }\nDevice: { name, type, identifiers[] }\nCredential: { service, secret_ref }  # Never store secrets directly\n\n# Meta\nAction: { type, target, timestamp, outcome? }\nPolicy: { scope, rule, enforcement }\n```\n\n## Storage\n\nDefault: `memory/ontology/graph.jsonl`\n\n```jsonl\n{\"op\":\"create\",\"entity\":{\"id\":\"p_001\",\"type\":\"Person\",\"properties\":{\"name\":\"Alice\"}}}\n{\"op\":\"create\",\"entity\":{\"id\":\"proj_001\",\"type\":\"Project\",\"properties\":{\"name\":\"Website Redesign\",\"status\":\"active\"}}}\n{\"op\":\"relate\",\"from\":\"proj_001\",\"rel\":\"has_owner\",\"to\":\"p_001\"}\n```\n\nQuery via scripts or direct file ops. For complex graphs, migrate to SQLite.\n\n### Append-Only Rule\n\nWhen working with existing ontology data or schema, **append/merge** changes instead of overwriting files. This preserves history and avoids clobbering prior definitions.\n\n## Workflows\n\n### Create Entity\n\n```bash\npython3 scripts/ontology.py create --type Person --props '{\"name\":\"Alice\",\"email\":\"alice@example.com\"}'\n```\n\n### Query\n\n```bash\npython3 scripts/ontology.py query --type Task --where '{\"status\":\"open\"}'\npython3 scripts/ontology.py get --id task_001\npython3 scripts/ontology.py related --id proj_001 --rel has_task\n```\n\n### Link Entities\n\n```bash\npython3 scripts/ontology.py relate --from proj_001 --rel has_task --to task_001\n```\n\n### Validate\n\n```bash\npython3 scripts/ontology.py validate  # Check all constraints\n```\n\n## Constraints\n\nDefine in `memory/ontology/schema.yaml`:\n\n```yaml\ntypes:\n  Task:\n    required: [title, status]\n    status_enum: [open, in_progress, blocked, done]\n  \n  Event:\n    required: [title, start]\n    validate: \"end >= start if end exists\"\n\n  Credential:\n    required: [service, secret_ref]\n    forbidden_properties: [password, secret, token]  # Force indirection\n\nrelations:\n  has_owner:\n    from_types: [Project, Task]\n    to_types: [Person]\n    cardinality: many_to_one\n  \n  blocks:\n    from_types: [Task]\n    to_types: [Task]\n    acyclic: true  # No circular dependencies\n```\n\n## Skill Contract\n\nSkills that use ontology should declare:\n\n```yaml\n# In SKILL.md frontmatter or header\nontology:\n  reads: [Task, Project, Person]\n  writes: [Task, Action]\n  preconditions:\n    - \"Task.assignee must exist\"\n  postconditions:\n    - \"Created Task has status=open\"\n```\n\n## Planning as Graph Transformation\n\nModel multi-step plans as a sequence of graph operations:\n\n```\nPlan: \"Schedule team meeting and create follow-up tasks\"\n\n1. CREATE Event { title: \"Team Sync\", attendees: [p_001, p_002] }\n2. RELATE Event -> has_project -> proj_001\n3. CREATE Task { title: \"Prepare agenda\", assignee: p_001 }\n4. RELATE Task -> for_event -> event_001\n5. CREATE Task { title: \"Send summary\", assignee: p_001, blockers: [task_001] }\n```\n\nEach step is validated before execution. Rollback on constraint violation.\n\n## Integration Patterns\n\n### With Causal Inference\n\nLog ontology mutations as causal actions:\n\n```python\n# When creating/updating entities, also log to causal action log\naction = {\n    \"action\": \"create_entity\",\n    \"domain\": \"ontology\", \n    \"context\": {\"type\": \"Task\", \"project\": \"proj_001\"},\n    \"outcome\": \"created\"\n}\n```\n\n### Cross-Skill Communication\n\n```python\n# Email skill creates commitment\ncommitment = ontology.create(\"Commitment\", {\n    \"source_message\": msg_id,\n    \"description\": \"Send report by Friday\",\n    \"due\": \"2026-01-31\"\n})\n\n# Task skill picks it up\ntasks = ontology.query(\"Commitment\", {\"status\": \"pending\"})\nfor c in tasks:\n    ontology.create(\"Task\", {\n        \"title\": c.description,\n        \"due\": c.due,\n        \"source\": c.id\n    })\n```\n\n## Quick Start\n\n```bash\n# Initialize ontology storage\nmkdir -p memory/ontology\ntouch memory/ontology/graph.jsonl\n\n# Create schema (optional but recommended)\npython3 scripts/ontology.py schema-append --data '{\n  \"types\": {\n    \"Task\": { \"required\": [\"title\", \"status\"] },\n    \"Project\": { \"required\": [\"name\"] },\n    \"Person\": { \"required\": [\"name\"] }\n  }\n}'\n\n# Start using\npython3 scripts/ontology.py create --type Person --props '{\"name\":\"Alice\"}'\npython3 scripts/ontology.py list --type Person\n```\n\n## References\n\n- `references/schema.md` — Full type definitions and constraint patterns\n- `references/queries.md` — Query language and traversal examples\n\n## Instruction Scope\n\nRuntime instructions operate on local files (`memory/ontology/graph.jsonl` and `memory/ontology/schema.yaml`) and provide CLI usage for create/query/relate/validate; this is within scope. The skill reads/writes workspace files and will create the `memory/ontology` directory when used. Validation includes property/enum/forbidden checks, relation type/cardinality validation, acyclicity for relations marked `acyclic: true`, and Event `end >= start` checks; other higher-level constraints may still be documentation-only unless implemented in code.\n"
  }
}

Versions

VersionSizeUpdated1.0.4Not availableMar 11, 2026