Schema Keys
Schema keys are hierarchical identifiers that classify every piece of knowledge in Contox. They follow a path-based naming convention (root/category/subcategory) and serve as the organizational backbone for the brain document, memory items, and contexts.
Naming Convention
Schema keys use forward-slash-separated segments, always starting with root/:
root/category
root/category/subcategory
- All segments are lowercase
- Use hyphens for multi-word segments (e.g.,
backend/api) - Maximum depth is typically 2--3 levels
- The
rootprefix is always present
Full Taxonomy
Contox defines 30 canonical schema keys, organized into three categories: domain keys (where in the project), package keys (which package), and type keys (what kind of knowledge).
Domain Keys
These classify knowledge by its location in the project architecture:
| Schema Key | Description |
|---|---|
root/stack | Dependencies, frameworks, configs, package.json |
root/data | Database schema, Prisma, migrations, seed data |
root/perf | Indexes, caching, query optimization |
root/auth | Authentication, sessions, tokens (cross-cutting) |
root/security | CORS, CSP, rate limiting, RBAC, encryption |
root/infra | CI/CD, Docker, deployment scripts, .github |
root/testing | Tests, mocks, fixtures, e2e |
root/docs | README, guides, documentation |
root/other | Miscellaneous / unclassifiable |
Backend Keys
| Schema Key | Description |
|---|---|
root/backend/api | API endpoints, controllers, route handlers |
root/backend/services | Business logic, server-side libraries |
Frontend Keys
| Schema Key | Description |
|---|---|
root/frontend/auth | Frontend auth flows, login/signup |
root/frontend/ui | General UI, styling, theming |
root/frontend/components | Reusable components |
root/frontend/routes | Pages, routes, layouts |
root/frontend/state | Redux, Zustand, Context, stores |
root/frontend/hooks | Custom React hooks |
root/frontend/lib | Frontend utilities, helpers |
root/frontend/stores | Dedicated store files |
root/frontend/types | TypeScript types, interfaces |
Package Keys
| Schema Key | Description |
|---|---|
root/cli | CLI package |
root/mcp | MCP server package |
root/vscode | VS Code extension package |
Type Keys
Used when no clear domain applies -- these classify by knowledge type:
| Schema Key | Description |
|---|---|
root/decisions | Architectural decisions |
root/conventions | Coding conventions, style rules |
root/architecture | Architecture notes, design patterns |
root/journal | Implementation journal entries |
root/bugs | Bug fixes, workarounds |
root/todo | Pending tasks, known issues |
root/codemap | Codebase structure from scan |
Extended Hierarchy (Brain Schema)
The brain schema defines additional keys for engineering layers beyond the core 29 enrichment keys. These are used in the static brain schema for organizing the knowledge graph:
root/
cortex
stack/
database, environment, deployment
api/
auth, core, integrations
frontend/
ui, pages, hooks, design, components, routes, state, lib, stores, types
backend/
auth, logic, integrations, api, services
packages/
mcp, cli, plugin, vscode
conventions
decisions
todo
bugs
journal
sessions
contracts/
auth, brain-endpoint, entries, populate, search, links, compaction
runbooks/
brain-5xx, populate-stuck, search-low-recall, drafts-never-approved, audit-mismatch, appwrite-throttling
ops
security
governance
quality
performance
patterns
flows
schema
adrs
Schema Key Resolution
Schema keys are assigned through two mechanisms depending on the event type:
LLM-Based Resolution (Primary)
For mcp_save and vscode_capture events, the LLM (Mistral) picks from the canonical enum of 30 schema keys during enrichment. The system prompt includes the full taxonomy with descriptions, and the JSON schema enforces that only valid keys are emitted.
Deterministic Resolution (Fallback)
For auto_save and scan events (or when the LLM output is invalid), schema keys are inferred from file paths using prefix-matching rules:
// Path prefix → schema key (first match wins)
'src/app/api/' → 'root/backend/api'
'src/components/' → 'root/frontend/components'
'src/hooks/' → 'root/frontend/hooks'
'src/stores/' → 'root/frontend/stores'
'packages/cli/' → 'root/cli'
'packages/mcp-server/' → 'root/mcp'
'.github/' → 'root/infra'
'package.json' → 'root/stack'
When file-based resolution fails, the system falls back to a type-based mapping:
| Item Type | Fallback Schema Key |
|---|---|
Decision | root/decisions |
Convention | root/conventions |
BugFix | root/bugs |
Todo | root/todo |
ArchitectureNote | root/architecture |
ImplementationFact | root/journal |
CodeMapNode | root/codemap |
Normalization
LLM-generated schema keys are validated and normalized before storage. The normalizer handles:
- Exact matches against the canonical set
- Case normalization (lowercasing)
- Missing
root/prefix (auto-prepended) - Over-deep keys (truncated to 2 or 3 levels)
- Complete fallback to
root/otherif nothing matches
Tiers and Brain Layers
Schema keys interact with the tier system to control brain inclusion:
| Tier | Brain Layer | Strategy |
|---|---|---|
| Tier 1 | Layer 1 (Active Knowledge) | Always loaded. For critical, recent, high-importance items. |
| Tier 2 | Layer 2 (Reference Knowledge) | Loaded on demand. For stable, high-confidence knowledge. |
| Tier 3 | Layer 3 (Archive) | Excluded from brain. Available via search. |
Note that tier assignment is not solely based on the schema key -- it also considers the item's recency, importance, confidence, and status. See Brain Assembly for the full classification logic.
Section Ordering in Brain
When the brain document is assembled, Layer 2 items are grouped by their schema key prefix (first two segments) and displayed in a fixed order:
- Decisions
- Conventions
- Architecture
- Stack
- Data Layer
- Authentication
- Security
- Backend
- Frontend
- Performance
- Implementation Journal
- Bug Fixes
- Todo / Pending
- CLI
- MCP Server
- VS Code Extension
- Infrastructure
- Testing
- Documentation
- Code Map
- Other