Skip to main content

CODITECT Database Schema

Architecture: Two-Database (ADR-089) Engine: SQLite 3 with FTS5 full-text search Updated: 2026-01-20

Two-Database Architecture (ADR-089)

CODITECT uses two separate databases to separate platform data from customer data:

DatabaseLocationPurposeAccess
platform.dbcontext-storage/platform.dbComponent data (H.P.001-AGENTS, H.P.003-SKILLS, H.P.002-COMMANDS)Read-only
context.dbcontext-storage/context.dbCustomer data (sessions, messages, decisions)Read/write

platform.db (Component Data)

CategoryTablesRow Count
Components42,306
Capabilities144,431
Triggers116,635
Relationships210,513
Embeddings1-
FTS Support4-
Total13 tables~74K rows

Populated by: python3 H.P.004-SCRIPTS/component-indexer.py

context.db (Customer Data)

CategoryTablesViewsRow Count
Messages & Context81279,711
Knowledge Extraction5412,577
Document Index414,348
Project Management661,364
Learning System80158,359
Token Usage14568
Workspace103
FTS Support480-
System22-
Total~129 tables19 views~456K rows

Note: Component tables (components, capabilities, triggers, etc.) have been moved to platform.db as of 2026-01-20.


Quick Start

# Database location
context-storage/context.db

# Auto-created on first /cx or /cxq command
/cx # Populates database
/cxq # Queries database

1. Messages & Context

messages

Primary message store for extracted session content.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTUnique identifier
hashTEXTUNIQUE NOT NULLSHA256 content hash for deduplication
contentTEXTNOT NULLFull message content
roleTEXTNOT NULL'user', 'assistant', or 'system'
source_typeTEXT'jsonl' or 'export'
source_fileTEXTOriginal file path
session_idTEXTClaude Code session ID
checkpointTEXTAssociated checkpoint name
timestampTEXTWhen message occurred
extracted_atTEXTWhen extracted to database
content_lengthINTEGERCharacter count
has_codeBOOLEANContains code blocks
has_markdownBOOLEANContains markdown formatting
agent_contextTEXTJSON: Agent-specific context
tool_useTEXTJSON: Tool invocation data
tool_resultTEXTJSON: Tool result with status
export_metadataTEXTJSON: Export header metadata

Indexes: role, timestamp, session_id, source_type, content_length, tool_status, export_model FTS: messages_fts (content, role) Row Count: 30,609

entries

Comprehensive entry store for all 6 Claude Code entry types (ADR-025).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
hashTEXTUNIQUE NOT NULLContent hash
entry_typeTEXTNOT NULLuser, assistant, system, summary, queue-operation, file-history-snapshot
uuidTEXTEntry UUID
parent_uuidTEXTParent entry UUID
logical_parent_uuidTEXTLogical parent UUID
session_idTEXTSession identifier
agent_idTEXTAgent identifier
slugTEXTEntry slug
cwdTEXTWorking directory
git_branchTEXTGit branch
versionTEXTClaude Code version
timestampTEXTEntry timestamp
extracted_atTEXTExtraction timestamp
is_sidechainBOOLEANDEFAULT FALSEIs sidechain entry
is_metaBOOLEANDEFAULT FALSEIs meta entry
user_typeTEXTUser type
contentTEXTEntry content
roleTEXTEntry role
raw_jsonTEXTNOT NULLOriginal JSON
source_fileTEXTSource file path
source_lineINTEGERSource line number

Indexes: entry_type, uuid, parent_uuid, session_id, agent_id, timestamp, role FTS: entries_fts Row Count: 247,792

embeddings

Vector embeddings for semantic search.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
message_idINTEGERUNIQUE NOT NULL, FK messages
embeddingBLOBNOT NULLVector embedding data
modelTEXTNOT NULLEmbedding model used
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Row Count: 0 (unpopulated)

entries_embeddings

Vector embeddings for entries semantic search.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
entry_idINTEGERFK entries
embeddingBLOBNOT NULLVector embedding
modelTEXTNOT NULLEmbedding model
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Row Count: 0 (unpopulated)

Relationships between sessions.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
session_aTEXTNOT NULLFirst session ID
session_bTEXTNOT NULLSecond session ID
relationshipTEXTNOT NULLcontinues, references, supersedes, fixes
notesTEXTAdditional context
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Row Count: 635

summaries

Session summaries extracted from Claude Code.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
entry_idINTEGERFK entries
summary_textTEXTNOT NULLSummary content
leaf_uuidTEXTUNIQUEUUID reference

FTS: summaries_fts Row Count: 675

message_threading

Message threading relationships.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
entry_idINTEGERFK entries
uuidTEXTMessage UUID
parent_uuidTEXTParent UUID
logical_parent_uuidTEXTLogical parent

session_insights

Session analytics and insights.

ColumnTypeConstraintsDescription
session_idTEXTNOT NULL
insight_typeTEXTNOT NULLsummary, topic, etc.
contentTEXTJSON insight data

2. Knowledge Extraction

decisions

Extracted architectural and design decisions.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
message_idINTEGERFK messagesSource message
project_pathTEXTProject context
decision_typeTEXTNOT NULLarchitecture, technology, api, database, testing, deployment, security, general
decisionTEXTNOT NULL, UNIQUEDecision text
rationaleTEXTReasoning
alternatives_consideredTEXTOther options
confidenceREALDEFAULT 0.5Confidence score (0-1)
tagsTEXTJSON tags array
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Indexes: decision_type, project_path, created_at, confidence FTS: decisions_fts Row Count: 1,856

code_patterns

Reusable code patterns extracted from sessions.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
message_idINTEGERFK messagesSource message
languageTEXTNOT NULLProgramming language
pattern_nameTEXTNOT NULLPattern identifier
pattern_typeTEXTtest, async, class, error_handling, database, api, imports, general
codeTEXTNOT NULL, UNIQUECode snippet
descriptionTEXTPattern description
tagsTEXTJSON tags
usage_countINTEGERDEFAULT 1Times used
last_usedTEXTDEFAULT CURRENT_TIMESTAMP
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Indexes: language, pattern_type, pattern_name, usage_count, created_at Row Count: 10,246

error_solutions

Cached error signatures with proven solutions.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
error_hashTEXTUNIQUEError signature hash
error_typeTEXTNOT NULLError, TypeError, ValueError, etc.
error_signatureTEXTNOT NULLError message pattern
error_contextTEXTSurrounding context
solutionTEXTNOT NULLSolution description
solution_codeTEXTCode fix
languageTEXTProgramming language
success_countINTEGERDEFAULT 1Successful uses
failure_countINTEGERDEFAULT 0Failed attempts
last_usedTEXTDEFAULT CURRENT_TIMESTAMP
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Indexes: error_type, error_hash, language FTS: errors_fts Row Count: 475

knowledge_graph

Entity relationship graph (schema ready, unpopulated).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
source_entity_idINTEGERFK knowledge_entities
target_entity_idINTEGERFK knowledge_entities
relationship_typeTEXTRelationship type
confidenceREALConfidence score
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Row Count: 0

knowledge_entities

Named entities for knowledge graph (schema ready, unpopulated).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
entity_typeTEXTNOT NULLEntity category
nameTEXTNOT NULLEntity name
descriptionTEXTEntity description
metadataTEXTJSON metadata
created_atTEXTDEFAULT CURRENT_TIMESTAMP

Row Count: 0


3. Components

components

Framework component registry (H.P.001-AGENTS, H.P.002-COMMANDS, H.P.003-SKILLS, H.P.004-SCRIPTS, H.P.005-HOOKS, H.P.006-WORKFLOWS).

ColumnTypeConstraintsDescription
idTEXTPRIMARY KEYComponent identifier
typeTEXTNOT NULLagent, command, skill, script, hook, workflow, workflow-json
nameTEXTNOT NULLDisplay name
versionTEXTComponent version
statusTEXTDEFAULT 'operational'operational, active, draft, archived, deprecated
pathTEXTNOT NULLFile path
categoryTEXTCategory
subcategoryTEXTSubcategory
descriptionTEXTComponent description
complexityTEXTDEFAULT 'medium'Complexity level
maturityTEXTDEFAULT 'production'Maturity level
confidenceREALDEFAULT 0.5Documentation confidence
documentation_qualityTEXTDEFAULT 'partial'complete, comprehensive, partial, stub
content_hashTEXTContent hash for change detection
indexed_atTEXTLast indexed
created_atTEXTDEFAULT CURRENT_TIMESTAMP
updated_atTEXTDEFAULT CURRENT_TIMESTAMP
llm_providerTEXTA2A: LLM provider (anthropic-claude)
llm_modelTEXTA2A: Model (sonnet, opus, haiku)
llm_temperatureREALDEFAULT 0.7A2A: Temperature
llm_max_tokensINTEGERDEFAULT 4096A2A: Max tokens
tools_listTEXTA2A: JSON array of tools
a2a_schemaTEXTA2A: Schema version
token_budget_recommendedINTEGERDEFAULT 0Recommended token budget
token_budget_maximumINTEGERDEFAULT 0Maximum token budget
invocation_methodTEXTTask, direct, etc.
parallel_safeINTEGERDEFAULT 1Boolean: can run in parallel
vendor_nameTEXTVendor name
vendor_urlTEXTVendor URL

Indexes: type, category, status, llm_model, llm_provider, type_status, active FTS: component_search Row Count: 2,069

capabilities

Component capabilities and tags.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
component_idTEXTFK components ON DELETE CASCADE
capabilityTEXTNOT NULLCapability description
capability_typeTEXTNOT NULLprimary, tag, domain, action

Indexes: component_id, capability_type Row Count: 40,311

component_relationships

Inter-component relationships.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
source_idTEXTFK components ON DELETE CASCADE
target_idTEXTTarget component
relationship_typeTEXTNOT NULLinvokes, invoked_by, alternative, complement
notesTEXTAdditional notes

Indexes: source_id, target_id Row Count: 8,873

component_frontmatter

Parsed YAML frontmatter from component files.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
component_idTEXTFK components
frontmatterTEXTRaw YAML
parsed_jsonTEXTParsed JSON

FTS: component_frontmatter_fts Row Count: 775

component_composability

A2A orchestration mappings.

ColumnTypeDescription
idINTEGERPRIMARY KEY
orchestrator_idTEXTOrchestrator component
member_idTEXTMember component
roleTEXTRole in composition

component_embeddings

Semantic embeddings for component search.

ColumnTypeDescription
idINTEGERPRIMARY KEY
component_idTEXTFK components
embeddingBLOBVector embedding
modelTEXTEmbedding model

component_usage_stats

Component usage tracking.

ColumnTypeDescription
component_idTEXTPRIMARY KEY
invocation_countINTEGERTimes invoked
last_invokedTEXTLast invocation

component_schema_info

Schema versioning for components.

ColumnTypeDescription
versionTEXTSchema version
updated_atTEXTLast update

4. Document Index

doc_index

Indexed documentation across all workspaces.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
doc_hashTEXTUNIQUE NOT NULLDocument hash
doc_typeTEXTNOT NULLmarkdown, claude_md, etc.
titleTEXTNOT NULLDocument title
file_pathTEXTNOT NULLRelative path
absolute_pathTEXTFull path
submoduleTEXTSubmodule name
categoryTEXTDocument category
subcategoryTEXTSubcategory
tagsTEXTJSON tags
content_hashTEXTContent hash
word_countINTEGERDEFAULT 0Word count
line_countINTEGERDEFAULT 0Line count
has_code_blocksBOOLEANDEFAULT FALSEContains code
has_mermaidBOOLEANDEFAULT FALSEContains diagrams
frontmatterTEXTYAML frontmatter
first_headingTEXTFirst heading
summaryTEXTDocument summary
created_atTEXTCreation date
modified_atTEXTLast modified
indexed_atTEXTDEFAULT CURRENT_TIMESTAMP
workspace_idTEXTWorkspace ID
workspace_nameTEXTWorkspace name

Indexes: workspace_id, workspace_name, doc_type, category, submodule, modified_at, indexed_at FTS: doc_search Row Count: 4,345

doc_embeddings

Document semantic embeddings.

ColumnTypeDescription
idINTEGERPRIMARY KEY
doc_idINTEGERFK doc_index
embeddingBLOBVector embedding
modelTEXTEmbedding model

workspace_registry

Registered workspace H.P.009-CONFIGurations.

ColumnTypeConstraintsDescription
workspace_idTEXTPRIMARY KEYUnique workspace ID
nameTEXTNOT NULLWorkspace name
workspace_typeTEXTmaster, submodule, standalone
root_pathTEXTRoot directory
doc_countINTEGERDEFAULT 0Document count
last_indexedTEXTLast index time

Row Count: 3


5. Project Management

work_items

Project work items (epics, features, tasks, subtasks).

ColumnTypeConstraintsDescription
idTEXTPRIMARY KEYWork item ID
typeTEXTNOT NULLepic, feature, task, subtask
titleTEXTNOT NULLItem title
descriptionTEXTDescription
acceptance_criteriaTEXTAcceptance criteria
project_idTEXTFK projects
sub_project_idTEXTFK sub_projects
parent_idTEXTFK work_items
sprint_idTEXTFK sprints
statusTEXTDEFAULT 'backlog'backlog, planned, in_progress, blocked, review, completed, cancelled
priorityINTEGERDEFAULT 50Priority (0-100)
sort_orderINTEGERDEFAULT 0Display order
estimate_pointsINTEGERStory points
estimate_hoursREALHour estimate
actual_hoursREALActual hours
assigneeTEXTAssigned to
labelsTEXTJSON labels
depends_onTEXTJSON dependency IDs
blocksTEXTJSON blocked IDs
created_atTEXTDEFAULT CURRENT_TIMESTAMP
updated_atTEXTDEFAULT CURRENT_TIMESTAMP
started_atTEXTStart time
completed_atTEXTCompletion time
due_dateTEXTDue date
source_fileTEXTSource file
source_lineINTEGERSource line

Indexes: type, parent_id, project_id, sub_project_id, sprint_id, status, assignee, due_date Row Count: 1,361

task_tracking

TodoWrite task status tracking (ADR-053).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
task_idTEXTNOT NULLTask identifier
task_descriptionTEXTTask description
sourceTEXTDEFAULT 'extraction'Source system
statusTEXTDEFAULT 'unknown'pending, in_progress, completed
started_atTEXTStart time
completed_atTEXTCompletion time
message_id_startINTEGERFirst message ID
message_id_endINTEGERLast message ID
session_export_fileTEXTExport file
outcomeTEXTTask outcome
outcome_scoreREALOutcome score
tool_success_countINTEGERDEFAULT 0Successful tool calls
tool_error_countINTEGERDEFAULT 0Failed tool calls
user_correctionsINTEGERDEFAULT 0User corrections
created_atTEXTDEFAULT datetime('now')
updated_atTEXTDEFAULT datetime('now')

Indexes: task_id, status Row Count: 713

projects

Top-level project definitions.

ColumnTypeDescription
idTEXTPRIMARY KEY
nameTEXTProject name
descriptionTEXTDescription
statusTEXTProject status

sub_projects

Sub-project definitions.

ColumnTypeDescription
idTEXTPRIMARY KEY
project_idTEXTFK projects
nameTEXTName
pathTEXTPath

sprints

Sprint definitions.

ColumnTypeDescription
idTEXTPRIMARY KEY
nameTEXTSprint name
start_dateTEXTStart date
end_dateTEXTEnd date
statusTEXTStatus
goalTEXTSprint goal

task_messages

Task-to-message relationships.

ColumnTypeDescription
idINTEGERPRIMARY KEY
task_idTEXTFK task_tracking
message_idINTEGERFK messages

6. Learning System

learning_modules

Available learning modules.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
module_keyTEXTUNIQUE NOT NULLModule identifier
module_typeTEXTNOT NULLModule type
categoryTEXTNOT NULLCategory
titleTEXTNOT NULLDisplay title
descriptionTEXTDescription
difficulty_levelTEXTbeginner, intermediate, advanced
estimated_duration_minutesINTEGERTime estimate
prerequisite_modulesTEXTJSON prerequisites
learning_objectivesTEXTJSON objectives
content_pathTEXTContent file path
has_quizBOOLEANDEFAULT 0Has quiz
has_exerciseBOOLEANDEFAULT 0Has exercise
badge_idTEXTAssociated badge
sort_orderINTEGERDEFAULT 0Display order
is_activeBOOLEANDEFAULT 1Is active
created_atTEXTDEFAULT CURRENT_TIMESTAMP
updated_atTEXTDEFAULT CURRENT_TIMESTAMP

Indexes: module_type, category, difficulty_level, sort_order Row Count: 11

learning_users

User learning profiles (schema ready).

ColumnTypeDescription
idINTEGERPRIMARY KEY
user_idTEXTUser identifier
created_atTEXTRegistration date

Row Count: 0

learning_progress

User progress per module.

ColumnTypeDescription
idINTEGERPRIMARY KEY
user_idTEXTFK learning_users
module_keyTEXTFK learning_modules
statusTEXTnot_started, in_progress, completed
progress_percentREALCompletion percentage
started_atTEXTStart time
completed_atTEXTCompletion time

Row Count: 0

learning_badges

Available badges.

ColumnTypeDescription
idTEXTPRIMARY KEY
nameTEXTBadge name
descriptionTEXTDescription
iconTEXTIcon identifier

learning_achievements

User earned badges.

ColumnTypeDescription
idINTEGERPRIMARY KEY
user_idTEXTFK learning_users
badge_idTEXTFK learning_badges
earned_atTEXTEarned timestamp

learning_analytics_events

Learning event log.

ColumnTypeDescription
idINTEGERPRIMARY KEY
user_idTEXTUser identifier
event_typeTEXTEvent type
event_dataTEXTJSON event data
timestampTEXTEvent time

skill_learnings

Skill effectiveness tracking (Continual Learning System).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
session_idTEXTNOT NULLSession ID
skill_nameTEXTNOT NULLSkill identifier
outcomeTEXTOutcome description
effectiveness_scoreINTEGERScore (0-100)
errorsTEXTJSON errors
analyzed_atTEXTNOT NULLAnalysis timestamp

Unique: (session_id, skill_name) Row Count: 158,337

skill_improvements

Tracked skill improvements.

ColumnTypeDescription
idINTEGERPRIMARY KEY
skill_nameTEXTSkill identifier
improvementTEXTImprovement description
created_atTEXTTimestamp

7. Token Usage

token_usage

API call token tracking (ADR-005).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENT
message_idINTEGERFK messagesSource message
session_idTEXTNOT NULLSession ID
project_pathTEXTProject path
input_tokensINTEGERDEFAULT 0Fresh input tokens
output_tokensINTEGERDEFAULT 0Output tokens
cache_read_input_tokensINTEGERDEFAULT 0Cached tokens read
cache_creation_input_tokensINTEGERDEFAULT 0Tokens cached
cost_usdREALDEFAULT 0.0Actual cost
estimated_cost_usdREALEstimated cost
duration_msINTEGERDEFAULT 0API latency
modelTEXTModel used
timestampTEXTNOT NULLCall timestamp
indexed_atTEXTDEFAULT CURRENT_TIMESTAMP

Indexes: session_id, project_path, timestamp, model Row Count: 568


8. Views

Message & Session Views

ViewDescription
session_activityMessage counts and duration per session
sessions_by_topicSessions grouped by topic
today_activityActivity from last 24 hours

Knowledge Views

ViewDescription
knowledge_statsRow counts for all knowledge tables
recent_decisionsHigh-confidence decisions (7 days)
patterns_by_languageCode patterns by language
error_frequencyError types with occurrence counts

Component Views

ViewDescription
component_summaryComponents by type and status
docs_by_categoryDocuments by category

Project Views

ViewDescription
project_progressProject completion metrics
sub_project_progressSub-project completion
epic_progressEpic completion metrics
sprint_burndownSprint burndown data
work_item_progressWork item completion
work_item_children_statsChild item statistics

Token Usage Views

ViewDescription
token_usage_by_sessionTokens per session
token_usage_by_projectTokens per project
token_usage_by_dateTokens per day
token_usage_by_modelTokens per model

9. FTS5 Full-Text Search Tables

FTS TableSourceSearchable Columns
messages_ftsmessagescontent, role
entries_ftsentriescontent, entry_type
decisions_ftsdecisionsdecision, rationale
errors_ftserror_solutionserror_signature, solution
summaries_ftssummariessummary_text
doc_searchdoc_indextitle, summary, tags
component_searchcomponentsname, description
component_frontmatter_ftscomponent_frontmatterfrontmatter

Each FTS table has supporting tables: *_H.P.009-CONFIG, *_data, *_docsize, *_idx


10. System Tables

TableDescription
_litestream_lockLitestream replication lock
_litestream_seqLitestream sequence tracking
sqlite_sequenceAuto-increment tracking
sqlite_stat1Query optimizer statistics

11. Entity Relationship Diagram

┌─────────────────────────────────────────────────────────────────────┐
│ CODITECT Context Database │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ CONVERSATION LAYER │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ entries │───▶│ summaries │ │ messages │ │token_usage│ │
│ │ 247,792 │ │ 675 │ │ 30,609 │ │ 568 │ │
│ └───────────┘ └───────────┘ └───────────┘ └───────────┘ │
│ │ │ │
│ ▼ ▼ │
│ KNOWLEDGE LAYER │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ decisions │ │ code_ │ │ error_ │ │ knowledge_│ │
│ │ 1,856 │ │ patterns │ │ solutions │ │ graph │ │
│ └───────────┘ │ 10,246 │ │ 475 │ │ (0) │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ │
│ COMPONENT LAYER │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │components │───▶│capabilities│ │component_ │ │component_ │ │
│ │ 2,069 │ │ 40,311 │ │relationships│ │frontmatter│ │
│ └───────────┘ └───────────┘ │ 8,873 │ │ 775 │ │
│ └───────────┘ └───────────┘ │
│ │
│ DOCUMENT LAYER │
│ ┌───────────┐ ┌───────────┐ │
│ │ doc_index │ │workspace_ │ │
│ │ 4,345 │ │ registry │ │
│ └───────────┘ │ 3 │ │
│ └───────────┘ │
│ │
│ PROJECT LAYER │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │work_items │ │ sprints │ │ projects │ │ task_ │ │
│ │ 1,361 │ │ (N) │ │ (N) │ │ tracking │ │
│ └───────────┘ └───────────┘ └───────────┘ │ 713 │ │
│ └───────────┘ │
│ │
│ LEARNING LAYER │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ learning_ │ │ skill_ │ │ learning_ │ │
│ │ modules │ │ learnings │ │ progress │ │
│ │ 11 │ │ 158,337 │ │ (0) │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘

12. Common Queries

Search Messages

SELECT * FROM messages
WHERE id IN (SELECT rowid FROM messages_fts WHERE messages_fts MATCH 'search term');

Find Components

SELECT id, name, type, description
FROM components
WHERE type = 'agent' AND status = 'operational';

Get Recent Decisions

SELECT * FROM recent_decisions LIMIT 10;

Token Usage Summary

SELECT * FROM token_usage_by_model;

Project Progress

SELECT * FROM project_progress;

13. Maintenance

Backup

./H.P.004-SCRIPTS/backup-context-db.sh

Optimize

VACUUM;
ANALYZE;

Rebuild FTS Index

INSERT INTO messages_fts(messages_fts) VALUES('rebuild');

Check Integrity

PRAGMA integrity_check;

Generated: 2026-01-06 Schema Version: 2.0.0 Related ADRs: ADR-020 (Context Extraction), ADR-021 (Context Query), ADR-025 (Comprehensive Entry Schema), ADR-053 (Cloud Sync)