tasks: add drift sync tasks to align source with architecture specs
This commit is contained in:
53
tasks/drift/bridge-functions.md
Normal file
53
tasks/drift/bridge-functions.md
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
id: drift/bridge-functions
|
||||
name: Create bridge.ts with moduleToDbSchema, validateNode, validateEdge
|
||||
status: pending
|
||||
depends_on:
|
||||
- drift/metagraph-module
|
||||
scope: moderate
|
||||
risk: medium
|
||||
impact: component
|
||||
level: 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 entry
|
||||
- `nodeTypes: DbNodeTypeRow[]` — one per `*Node` entry, name = entry name minus suffix
|
||||
- `edgeTypes: DbEdgeTypeRow[]` — one per `*Edge` entry, with constraint data from `*EdgeConstraints` entries
|
||||
|
||||
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)
|
||||
- `*EdgeConstraints` entries referencing edge types not in the Module
|
||||
- `*EdgeConstraints` with empty `allowedSourceTypes` AND `allowedTargetTypes`
|
||||
- Module without a `Config` entry
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] `src/graphs/bridge.ts` exists with `moduleToDbSchema()`, `validateNode()`, `validateEdge()` exports
|
||||
- [ ] `moduleToDbSchema()` accepts a `TModule` and returns `DbSchema` with `graphType`, `nodeTypes`, `edgeTypes`
|
||||
- [ ] `moduleToDbSchema()` enforces naming convention: entries ending in `Node` become node type rows, entries ending in `Edge` become edge type rows, `Config` becomes the graph type config
|
||||
- [ ] `moduleToDbSchema()` throws on missing Config, unrecognized bare entry suffixes, empty EdgeConstraints, EdgeConstraints referencing nonexistent edge types
|
||||
- [ ] `validateNode(module, entryName, data)` returns `boolean` — `true` if data passes `Value.Check` against the resolved Module entry, `false` if invalid, throws if `entryName` doesn't match an `*Node` entry
|
||||
- [ ] `validateEdge(module, entryName, data)` same pattern for `*Edge` entries
|
||||
- [ ] `src/graphs/mod.ts` re-exports from `bridge.ts`
|
||||
- [ ] `deno check mod.ts` passes
|
||||
|
||||
## 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
|
||||
Reference in New Issue
Block a user