2.6 KiB
2.6 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| drift/bridge-functions | Create bridge.ts with moduleToDbSchema, validateNode, validateEdge | pending |
|
moderate | medium | component | implementation |
Description
Create the bridge between TypeBox Modules and database row values. The moduleToDbSchema() function projects a graph type Module to DB row values for the metagraph tables. The validateNode() and validateEdge() functions validate data against Module entries.
This is Phase 2 of the metagraph-module.md implementation path.
Per the spec, moduleToDbSchema() takes a TModule and returns a DbSchema with:
graphType: DbGraphTypeRow— name from Module name, config from Config entrynodeTypes: DbNodeTypeRow[]— one per*Nodeentry, name = entry name minus suffixedgeTypes: DbEdgeTypeRow[]— one per*Edgeentry, with constraint data from*EdgeConstraintsentries
The function must enforce the entry naming convention (*Node, *Edge, Config, *EdgeConstraints, *Enum, BaseNode, BaseEdge) and throw on:
- Entries with unrecognized suffixes (bare names are treated as shared types, not DB rows)
*EdgeConstraintsentries referencing edge types not in the Module*EdgeConstraintswith emptyallowedSourceTypesANDallowedTargetTypes- Module without a
Configentry
Acceptance Criteria
src/graphs/bridge.tsexists withmoduleToDbSchema(),validateNode(),validateEdge()exportsmoduleToDbSchema()accepts aTModuleand returnsDbSchemawithgraphType,nodeTypes,edgeTypesmoduleToDbSchema()enforces naming convention: entries ending inNodebecome node type rows, entries ending inEdgebecome edge type rows,Configbecomes the graph type configmoduleToDbSchema()throws on missing Config, unrecognized bare entry suffixes, empty EdgeConstraints, EdgeConstraints referencing nonexistent edge typesvalidateNode(module, entryName, data)returnsboolean—trueif data passesValue.Checkagainst the resolved Module entry,falseif invalid, throws ifentryNamedoesn't match an*NodeentryvalidateEdge(module, entryName, data)same pattern for*Edgeentriessrc/graphs/mod.tsre-exports frombridge.tsdeno check mod.tspasses
References
- docs/architecture/metagraph-module.md — "Bridge Functions" and "DB Persistence Bridge" sections
- docs/architecture/decisions/014-dereferenced-entry-schemas.md
- docs/architecture/decisions/016-naming-convention-for-module-entries.md
Notes
To be filled by implementation agent
Summary
To be filled on completion