Skip to content

Database Schema

Schema reference for all three Massu AI databases - CodeGraph, Data, and Memory


Database Schema

Massu AI uses three SQLite databases, each serving a distinct purpose. All databases use WAL mode for concurrent read performance.

Database Overview

DatabaseModulePurposeAccess
CodeGraph DBgetCodeGraphDb()Vanilla CodeGraph data (files, nodes, edges)Read-only
Data DBgetDataDb()Import edges, tRPC mappings, sentinel registryRead-write
Memory DBgetMemoryDb()Session memory, observations, analytics, audit trailRead-write

CodeGraph Database (Read-Only)

This database is populated by the CodeGraph MCP server and contains the raw code analysis data. Massu AI reads from it but never writes to it.

files

ColumnTypeDescription
pathTEXTFile path relative to project root
languageTEXTProgramming language
sizeINTEGERFile size in bytes

nodes

ColumnTypeDescription
idINTEGERNode ID
file_pathTEXTFile containing the node
nameTEXTSymbol name
kindTEXTNode type (function, class, interface, etc.)
start_lineINTEGERStarting line number
end_lineINTEGEREnding line number

edges

ColumnTypeDescription
source_idINTEGERSource node ID
target_idINTEGERTarget node ID
typeTEXTEdge type (calls, imports, extends, etc.)

Data Database

Contains Massu AI-specific indexed data: import edges, tRPC mappings, and the Sentinel feature registry.

massu_imports

ColumnTypeDescription
source_fileTEXTImporting file path
target_fileTEXTImported file path
imported_namesTEXT (JSON)Array of imported symbol names

massu_trpc_procedures

ColumnTypeDescription
idINTEGERProcedure ID
router_nameTEXTRouter name
procedure_nameTEXTProcedure name
procedure_typeTEXT"query" or "mutation"
router_fileTEXTRouter file path
has_ui_callerINTEGER1 if any UI component calls this

massu_trpc_call_sites

ColumnTypeDescription
procedure_idINTEGERFK to massu_trpc_procedures
fileTEXTCalling file path
lineINTEGERLine number of call
call_patternTEXTThe call pattern (e.g., api.orders.getById.useQuery)

massu_sentinel

ColumnTypeDescription
idINTEGERFeature ID
feature_keyTEXTUnique key (e.g., orders.create)
titleTEXTHuman-readable title
domainTEXTBusiness domain
subdomainTEXTSubdomain
statusTEXTplanned, active, deprecated, removed
priorityTEXTP0, P1, P2, P3
portalTEXTPortal scope

massu_sentinel_components

ColumnTypeDescription
feature_idINTEGERFK to massu_sentinel
file_pathTEXTComponent file path
roleTEXTprimary, supporting, shared

massu_sentinel_changelog

ColumnTypeDescription
feature_idINTEGERFK to massu_sentinel
session_idTEXTSession that made the change
change_typeTEXTType of change
descriptionTEXTWhat changed
timestampTEXTISO timestamp

Memory Database

Contains cross-session memory, observability data, analytics, and audit trails.

sessions

ColumnTypeDescription
session_idTEXTUnique session identifier
statusTEXTactive, completed, abandoned
branchTEXTGit branch at session start
plan_fileTEXTLinked plan file path
task_idTEXTLinked task identifier
created_atTEXTISO timestamp

observations

ColumnTypeDescription
idINTEGERObservation ID
session_idTEXTFK to sessions
typeTEXTObservation type
titleTEXTShort description
descriptionTEXTFull description
importanceINTEGER1-10 importance score
files_involvedTEXT (JSON)Array of file paths
plan_itemTEXTLinked plan item
vr_typeTEXTVerification type (for vr_check)
created_at_epochINTEGERUnix timestamp

observations_fts

FTS5 virtual table for full-text search across observations.

user_prompts

ColumnTypeDescription
session_idTEXTFK to sessions
prompt_numberINTEGERSequential prompt number
prompt_textTEXTFull prompt text

session_summaries

ColumnTypeDescription
session_idTEXTFK to sessions
requestTEXTOriginal request
completedTEXTWhat was completed
failed_attemptsTEXTWhat failed
plan_progressTEXT (JSON)Plan item completion status

conversation_turns

ColumnTypeDescription
session_idTEXTFK to sessions
turn_numberINTEGERSequential turn number
user_promptTEXTUser message
assistant_responseTEXTAssistant response (max 10K chars)
tool_calls_summaryTEXT (JSON)Summary of tool calls
tool_call_countINTEGERNumber of tool calls

audit_log

ColumnTypeDescription
idINTEGERAudit entry ID
session_idTEXTSession context
event_typeTEXTcode_change, rule_enforced, approval, commit
actorTEXTai, human, hook, agent
model_idTEXTAI model used
file_pathTEXTAffected file
change_typeTEXTcreate, edit, delete
approval_statusTEXTauto_approved, human_approved, pending
timestampTEXTISO timestamp

quality_scores

ColumnTypeDescription
session_idTEXTFK to sessions
scoreINTEGER0-100 quality score
breakdownTEXT (JSON)Category breakdown

developer_expertise

ColumnTypeDescription
developer_idTEXTDeveloper identifier
moduleTEXTModule name
expertise_scoreINTEGER0-100 expertise score
session_countINTEGERSessions touching this module
last_activeTEXTLast activity timestamp

Python Intelligence Tables (Data Database)

These tables are populated by the Python Code Intelligence indexer (massu_sync with Python enabled). They live in the Data Database alongside the existing TypeScript/JavaScript tables.

massu_py_imports

Stores Python import edges between files, enabling cross-file dependency analysis.

ColumnTypeDescription
idINTEGERPrimary key (autoincrement)
source_fileTEXTFile that contains the import statement
target_fileTEXTResolved file being imported (absolute or relative)
import_typeTEXTabsolute, relative, from_absolute, or from_relative
imported_namesTEXT (JSON)Array of symbol names imported
lineINTEGERLine number of the import statement

massu_py_meta

Stores metadata about the Python index state, used to track freshness and incremental rebuild.

ColumnTypeDescription
keyTEXTMetadata key (primary key, e.g., last_build_time, file_count, root)
valueTEXTMetadata value

massu_py_routes

Stores FastAPI route endpoint definitions discovered during indexing.

ColumnTypeDescription
idINTEGERRoute ID (primary key)
fileTEXTFile path containing the route definition
methodTEXTHTTP method (GET, POST, PUT, DELETE, PATCH)
pathTEXTURL path pattern (e.g., /users/{user_id})
function_nameTEXTPython function name implementing the route
dependenciesTEXT (JSON)Array of FastAPI Depends() dependency names
request_modelTEXTPydantic request body model class name (if declared)
response_modelTEXTPydantic response model class name (if declared)
is_authenticatedINTEGER1 if route uses an auth dependency
lineINTEGERLine number of the route decorator

massu_py_route_callers

Stores frontend call sites that invoke Python backend routes, enabling cross-language coupling analysis.

ColumnTypeDescription
idINTEGERCaller edge ID (primary key)
route_idINTEGERFK to massu_py_routes
frontend_fileTEXTFrontend file making the HTTP call
lineINTEGERLine number of the call site
call_patternTEXTThe call pattern matched at the call site

massu_py_models

Stores SQLAlchemy ORM model class definitions including columns and relationships.

ColumnTypeDescription
idINTEGERModel ID (primary key)
class_nameTEXTPython class name
table_nameTEXTMapped database table name
fileTEXTFile path containing the model class
lineINTEGERLine number of the class definition
columnsTEXT (JSON)Array of column definitions {name, type, nullable, primary_key}
relationshipsTEXT (JSON)Array of relationship definitions {name, target, kind}
foreign_keysTEXT (JSON)Array of foreign key definitions

massu_py_fk_edges

Stores foreign key relationships between SQLAlchemy models, enabling relational schema analysis.

ColumnTypeDescription
idINTEGERFK edge ID (primary key)
source_tableTEXTTable name of the model containing the foreign key
source_columnTEXTColumn name holding the foreign key value
target_tableTEXTTarget database table name
target_columnTEXTTarget column (typically the primary key)

massu_py_migrations

Stores Alembic migration metadata for tracking schema change history.

ColumnTypeDescription
idINTEGERMigration record ID (primary key)
revisionTEXTAlembic revision identifier (unique)
down_revisionTEXTParent revision (null for the base migration)
fileTEXTPath to the Alembic migration script
descriptionTEXTHuman-readable migration description
operationsTEXT (JSON)Array of operation summaries {op, table, details}
is_headINTEGER1 if this is the current head revision