Skip to content

feat(memoir): optional per-memoir ontology for concept types and relations - #554

Open
pszymkowiak wants to merge 1 commit into
developfrom
feat/memoir-ontology
Open

pszymkowiak wants to merge 1 commit into
developfrom
feat/memoir-ontology

Conversation

@pszymkowiak

Copy link
Copy Markdown
Contributor

Why

Several agents writing into one memoir each invent their own types (svc, service, microservice) and read relations differently, so the graph stops answering reliably. This is the shared-vocabulary part of ontology-driven knowledge graphs (OWL/SHACL), without a triplestore or inference engine.

What

  • icm-core: Ontology { types, require_type, relations } and RelationRule (from:relation:to, * = any type, or just relation). A concept's type is its type:<name> label. Includes validate_concept, validate_link and ontology_violations.
  • icm-store (SQLite): nullable memoirs.ontology JSON column (added by migration, SCHEMA_VERSION 1 → 2). add_concept, update_concept and add_link return InvalidInput when a row breaks the memoir's ontology. Postgres and OpenSearch still don't support memoirs (feat(store): support pluggable storage backends (beyond SQLite) #301).
  • CLI: icm memoir ontology set|show|check|clear. set lists existing rows that break the new ontology and keeps them. check exits 1 if any row breaks it.
  • MCP: new icm_memoir_set_ontology tool. icm_memoir_show prints the ontology.

A memoir without an ontology behaves exactly as before.

icm memoir ontology set -m ops --types service,incident,deploy --require-type \
  --relations 'incident:caused_by:deploy,service:depends_on:service,*:related_to:*'

Tests

  • core: parsing, type checks, domain/range checks, old JSON without ontology still deserializes
  • store: round-trip/clear, rejected concepts/links/retyping, free-form memoir unchanged
  • MCP: end-to-end set → reject → accept → clear
  • schema fingerprint updated

Ran locally: the targeted tests and clippy -D warnings (SQLite, no embeddings). CI runs the full suite.

…tions

A memoir can now declare the concept types it accepts (carried by
type:<name> labels) and the relations allowed between them, written as
from:relation:to with * for any type. add_concept, update_concept and
add_link reject rows that break it. Memoirs without an ontology keep the
free-form behaviour.

- icm-core: Ontology, RelationRule, validation and ontology_violations
- icm-store (SQLite): memoirs.ontology JSON column, SCHEMA_VERSION 2
- CLI: icm memoir ontology set|show|check|clear
- MCP: icm_memoir_set_ontology; icm_memoir_show prints the ontology
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant