---
# MIF Base Ontology - Knowledge Triad Model
#
# This ontology defines the hierarchical namespace structure based on a
# general knowledge taxonomy: semantic (declarative knowledge), episodic
# (time-bound records), and procedural (how-to knowledge).
#
# Version: 1.0.0
# Last Updated: 2026-06-18

ontology:
  id: mif-base
  version: "1.0.0"
  description: "MIF base ontology with the general knowledge triad namespace hierarchy"
  schema_url: >-
    https://mif-spec.dev/schema/ontology/ontology.schema.json

# Knowledge Triad Namespace Hierarchy
#
# Three top-level namespaces based on knowledge kinds:
# - semantic: Facts, concepts, relationships (declarative knowledge)
# - episodic: Events, experiences, timelines (time-bound records)
# - procedural: Step-by-step processes (how-to knowledge)
#
# Each top-level has sub-namespaces for organization.
# Path format: _{top-level}/{sub-namespace}
# Example: _semantic/decisions, _episodic/incidents, _procedural/runbooks

namespaces:
  _semantic:
    description: "Facts, concepts, relationships - declarative knowledge"
    type_hint: semantic
    children:
      decisions:
        description: "Architectural choices with rationale"
        type_hint: semantic
      knowledge:
        description: "APIs, context, learnings, security - factual knowledge"
        type_hint: semantic
      entities:
        description: "Entity definitions - technologies, components, systems"
        type_hint: semantic
      preferences:
        description: "User preferences, settings, configuration choices"
        type_hint: semantic

  _episodic:
    description: "Events, experiences, timelines - time-bound records"
    type_hint: episodic
    children:
      incidents:
        description: "Production issues, outages, postmortems"
        type_hint: episodic
      sessions:
        description: "Debug sessions, work sessions, meeting notes"
        type_hint: episodic
      blockers:
        description: "Impediments, issues preventing progress"
        type_hint: episodic

  _procedural:
    description: "Step-by-step processes - how-to knowledge"
    type_hint: procedural
    children:
      runbooks:
        description: "Operational procedures, SOPs, playbooks"
        type_hint: procedural
      patterns:
        description: "Code conventions, best practices, testing strategies"
        type_hint: procedural
      migrations:
        description: "Migration steps, upgrade procedures, data transformations"
        type_hint: procedural

# Base entity types
# These are the fundamental knowledge types that all entities inherit from.
# Custom ontologies define domain-specific entity types with these as base.
entity_types: []

# Base traits
# Reusable mixins that can be composed into entity types.
traits:
  timestamped:
    description: "Adds creation and update timestamps"
    fields:
      created_at:
        type: string
        format: date-time
        description: "When the record was created"
      updated_at:
        type: string
        format: date-time
        description: "When the record was last updated"

  confidence:
    description: "Adds confidence score for freshness and validity tracking"
    fields:
      confidence:
        type: number
        description: "Confidence score (0.0-1.0)"

  provenance:
    description: "Adds source tracking"
    fields:
      source:
        type: string
        description: "Where this knowledge came from"
      author:
        type: string
        description: "Who captured this record"

# Base relationships
# Standard relationships that apply across all knowledge types.
relationships:
  relates_to:
    description: "General association between records"
    from: []
    to: []
    symmetric: true

  supersedes:
    description: "Newer record replaces older one"
    from: []
    to: []
    symmetric: false

  derived_from:
    description: "Record was derived from another"
    from: []
    to: []
    symmetric: false

# Discovery patterns for automatic namespace suggestion
discovery:
  enabled: true
  confidence_threshold: 0.8

  # Content patterns - matched against user prompts
  content_patterns:
    - pattern: "\\blet'?s use\\b|\\bdecided to\\b|\\bwe will use\\b"
      namespace: _semantic/decisions
    - pattern: "\\bgoing with\\b|\\bchose\\b|\\bpicked\\b"
      namespace: _semantic/decisions
    - pattern: "\\bthe plan is\\b|\\bour approach\\b"
      namespace: _semantic/decisions
    - pattern: "\\blearned that\\b|\\bturns out\\b|\\bTIL\\b"
      namespace: _semantic/knowledge
    - pattern: "\\brealized\\b|\\bthe fix was\\b|\\bthe solution\\b"
      namespace: _semantic/knowledge
    - pattern: "\\bdon'?t forget\\b|\\bremember this\\b"
      namespace: _semantic/knowledge
    - pattern: "\\bshould always\\b|\\balways use\\b"
      namespace: _procedural/patterns
    - pattern: "\\bconvention\\b|\\bbest practice\\b"
      namespace: _procedural/patterns
    - pattern: "\\bblocked by\\b|\\bstuck on\\b"
      namespace: _episodic/blockers
    - pattern: "\\boutage\\b|\\bincident\\b|\\bpostmortem\\b"
      namespace: _episodic/incidents
    - pattern: "\\brunbook\\b|\\bplaybook\\b|\\bSOP\\b"
      namespace: _procedural/runbooks

  # File patterns - matched against file paths being edited
  file_patterns:
    - pattern: "auth|login|session|jwt|oauth|token"
      namespaces:
        - _semantic/knowledge
        - _semantic/decisions
      context: authentication
    - pattern: "api|endpoint|route|controller|handler"
      namespaces:
        - _semantic/knowledge
        - _semantic/decisions
      context: API design
    - pattern: "db|database|model|schema|migration|sql"
      namespaces:
        - _semantic/decisions
        - _procedural/migrations
      context: database
    - pattern: "test|spec|mock|fixture"
      namespaces:
        - _procedural/patterns
      context: testing
    - pattern: "config|settings|env"
      namespaces:
        - _semantic/decisions
        - _semantic/knowledge
      context: configuration
    - pattern: "deploy|docker|kubernetes|helm|ci|cd"
      namespaces:
        - _procedural/runbooks
        - _semantic/decisions
      context: deployment
    - pattern: "security|encrypt|hash|sanitize"
      namespaces:
        - _semantic/knowledge
        - _semantic/decisions
      context: security
    - pattern: "service|component|module"
      namespaces:
        - _semantic/entities
        - _semantic/decisions
      context: components
