Problem
Schema generation currently happens at runtime by walking inheritance chains, merging fields from parent→child, and computing column definitions on the fly. This requires:
- All parent classes to be registered
- Correct inheritance chain resolution
- Runtime field merging with conflict handling
This is the root cause of many issues — if the inheritance chain is wrong (#1001), the schema is wrong, and the migration crashes.
Proposed Solution
Move schema generation to build time:
- During
vite build (or smrt-prebuild), after AST scanning produces the manifest, also compute the fully resolved schema for each class
- The resolved schema includes all inherited fields already merged (no runtime merging needed)
- Store as
resolvedSchema alongside the manifest entry
- At runtime,
getSchemaForClass() simply reads the pre-computed schema — no inheritance walking, no field merging, no parent lookups
Manifest Extension
{
"objects": {
"VideoShot": {
"className": "VideoShot",
"extends": "Content",
"fields": { ... },
"resolvedSchema": {
"tableName": "contents",
"columns": {
"id": { "type": "TEXT", "primaryKey": true },
"title": { "type": "TEXT" },
"scriptText": { "type": "TEXT" },
...
},
"indexes": [...],
"dependencies": ["video_sequences", "scenes"]
}
}
}
}
Benefits
- Runtime schema generation becomes a simple lookup
- No dependency on correct inheritance chain resolution at runtime
- Build-time errors catch schema conflicts before deployment
- Significant startup performance improvement
Part of epic #1003.
Problem
Schema generation currently happens at runtime by walking inheritance chains, merging fields from parent→child, and computing column definitions on the fly. This requires:
This is the root cause of many issues — if the inheritance chain is wrong (#1001), the schema is wrong, and the migration crashes.
Proposed Solution
Move schema generation to build time:
vite build(orsmrt-prebuild), after AST scanning produces the manifest, also compute the fully resolved schema for each classresolvedSchemaalongside the manifest entrygetSchemaForClass()simply reads the pre-computed schema — no inheritance walking, no field merging, no parent lookupsManifest Extension
{ "objects": { "VideoShot": { "className": "VideoShot", "extends": "Content", "fields": { ... }, "resolvedSchema": { "tableName": "contents", "columns": { "id": { "type": "TEXT", "primaryKey": true }, "title": { "type": "TEXT" }, "scriptText": { "type": "TEXT" }, ... }, "indexes": [...], "dependencies": ["video_sequences", "scenes"] } } } }Benefits
Part of epic #1003.