Custom Types

Define domain-specific entry types with schema validation in kb.yaml.

Pyrite entries are typed. Each type defines fields with validation rules, so your knowledge base enforces structure automatically.

Defining types

Types are defined in your kb.yaml file:

name: legal-research
kb_type: generic
types:
  case:
    description: "Legal case or proceeding"
    fields:
      jurisdiction:
        type: select
        options: [federal, state, international]
      status:
        type: select
        options: [active, decided, appealed, settled]
      filing_date:
        type: date
      parties:
        type: list
        items:
          type: text

Field types

TypeDescription
textFree text string
numberNumeric value
dateDate (YYYY-MM-DD)
datetimeDate and time
checkboxBoolean true/false
selectSingle choice from options list
multi-selectMultiple choices from options list
object-refReference to another entry by ID
listArray of typed items
tagsTag list

Schema versioning

Types support versioning for safe schema evolution:

types:
  case:
    version: 2
    fields:
      methodology:
        type: text
        required: true
        since_version: 2  # required for new entries, warning-only for legacy

Entries track their schema version in _schema_version frontmatter. Use pyrite schema migrate to apply registered migrations — it produces a reviewable git diff.

# See what changed between versions
pyrite schema diff --kb=research

# Apply migrations
pyrite schema migrate --kb=research

Built-in types

Ten entry types ship out of the box: note, person, organization, event, document, topic, relationship, timeline, collection, qa_assessment.

All entries support aliases for alternate names that resolve in wikilinks and autocomplete.