Skip to content

Glossary

scarecr0w12 edited this page Jun 22, 2026 · 4 revisions

Glossary

DB-persisted term registry for CortexPrism, providing a centralized dictionary of domain terms with alias resolution and category filtering. Implemented in packages/ai/src/memory/glossary.ts with persistence via semantic_memory (__glossary__ category prefix).

Data Model

Each term has:

Field Type Description
Name (key) string Canonical term name, stored lowercase
definition string Term definition text
aliases string[] Alternative names for the same concept
category string Grouping category, default "general"

API

defineTerm()

defineTerm(name: string, definition: string, category?: string, aliases?: string[]): void

Registers a term in the in-memory map. The name is normalized to lowercase. Aliases are also lowercased.

defineTerm("RAG", "Retrieval-Augmented Generation — combines LLMs with external data retrieval", "ai-concepts", ["retrieval-augmented-generation"]);

lookupTerm()

lookupTerm(name: string): { name, definition, aliases, category } | null

Resolves a term by name or alias, case-insensitive. Returns null if not found.

Resolution order:

  1. Direct match against canonical name (lowercase)
  2. Scan all terms for matching alias

Returns the canonical name (original casing), definition, aliases, and category.

listTerms()

listTerms(category?: string): Array<{ name, definition, category }>

Lists all terms, optionally filtered by category. Returns simplified objects (no aliases in output).

getCategories()

getCategories(): string[]

Returns all unique categories in sorted order.

Storage

All terms are stored with DB persistence via semantic_memory (__glossary__ category prefix). All functions (defineTerm, lookupTerm, listTerms, getCategories) are async and load from the database. Terms survive restarts.

REST API

Method Path Description
POST /api/glossary Define a new term
GET /api/glossary List terms (query: ?category=)

Example: Define a Term

curl -X POST http://localhost:3000/api/glossary \
  -H "Content-Type: application/json" \
  -d '{"name":"A2A","definition":"Agent-to-Agent protocol for AI interop","category":"protocols","aliases":["agent2agent","a2a-protocol"]}'

See Also

Clone this wiki locally