2.9 KiB
2.9 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| graph/flowgraph-class | Implement FlowGraph class skeleton wrapping graphology DirectedGraph | completed |
|
moderate | medium | phase | implementation |
Description
Create the FlowGraph class that wraps a graphology DirectedGraph and enforces DAG invariants. This is the core data class. At this stage, implement the constructor, generic type parameters, the _graph instance, the graph getter, FlowGraphOptions, and the _edgeKey() helper. Construction factory methods come in dependent tasks.
Acceptance Criteria
src/graph/construction.tsexportsFlowGraphclass (orsrc/graph/index.tsif preferred, matching source structure)- Class has type parameters:
NodeAttrs extends TSchema,EdgeAttrs extends TSchema - Constructor creates internal
graphology.DirectedGraphwith options{ type: "directed", multi: false, allowSelfLoops: false } FlowGraphOptionsinterface:type?: "directed",multi?: false,allowSelfLoops?: falseget graph(): DirectedGraphreturns the underlying graphology instance_edgeKey(source, target): stringproduces deterministic keys${source}->${target}addNode(key, attrs)— adds node, throwsDuplicateNodeErroron duplicateremoveNode(key)— removes node and edges, throwsNodeNotFoundErrorif missingupdateNode(key, attrs)— partial merge of attributes, throwsNodeNotFoundErrorif missinghasNode(key): booleangetNodeAttributes(key): NodeAttrs— throwsNodeNotFoundErrorif missingaddEdge(source, target, attrs?)— throwsNodeNotFoundErrorfor missing endpoints,CycleErrorif edge creates cycle,DuplicateEdgeErrorif edge existsremoveEdge(source, target)— no-op if edge doesn't existhasEdge(source, target): booleangetEdgeAttributes(source, target): EdgeAttrs— throws if edge doesn't existnodes(): string[],edges(): string[],order: number,size: numberforEachNode(callback),forEachEdge(callback)predecessors(nodeId),successors(nodeId)delegating tograph.inNeighbors/graph.outNeighbors- Static construction methods (
fromSpecs,fromCallEvents,fromJSON) are stubs (throw "not implemented") - Re-exported from
src/graph/index.tsandsrc/index.ts - Unit tests: constructor, node operations, edge operations, cycle detection on addEdge
References
- docs/architecture/flowgraph-api.md — FlowGraph class full API surface, delegation model
- docs/architecture/schema.md — edge key convention
- docs/architecture/error-handling.md — throwing contract for mutations
Notes
To be filled by implementation agent
Summary
To be filled on completion