55 lines
3.0 KiB
Markdown
55 lines
3.0 KiB
Markdown
---
|
|
id: host/graphology
|
|
name: Implement GraphologyHostConfig — render ujsx template to graphology DAG
|
|
status: completed
|
|
depends_on:
|
|
- component/operation
|
|
- component/sequential
|
|
- component/parallel
|
|
- component/conditional
|
|
- component/map
|
|
- graph/flowgraph-class
|
|
- schema/edge-attrs
|
|
scope: broad
|
|
risk: high
|
|
impact: phase
|
|
level: implementation
|
|
---
|
|
|
|
## Description
|
|
|
|
Implement the `GraphologyHostConfig` that renders a ujsx workflow template (`UNode` tree) into a graphology `DirectedGraph` DAG. This is the structural analysis rendering path — it validates templates by producing a DAG that can be checked for cycles, type compatibility, and topological ordering.
|
|
|
|
## Acceptance Criteria
|
|
|
|
- [ ] `src/host/graphology.ts` exports `GraphologyHostConfig` implementing ujsx `HostConfig<WorkflowTag, GraphNode, GraphContext>`
|
|
- [ ] `WorkflowTag: "operation" | "sequential" | "parallel" | "conditional" | "map"`
|
|
- [ ] `GraphNode`: `{ key: string; attributes: OperationNodeAttrs | TemplateNodeAttrs }`
|
|
- [ ] `GraphContext`: `{ graph: DirectedGraph; parentStack: string[]; operationRegistry?: OperationRegistry }`
|
|
- [ ] `createRootContext`: creates fresh `DirectedGraph` with DAG constraints, empty parentStack
|
|
- [ ] `createInstance("operation", props, ctx)`: adds graph node with `OperationNodeAttrs`, returns `GraphNode`
|
|
- [ ] `createInstance` for structural containers: returns `GraphNode` with synthetic key `__${tag}_${counter++}`, no graph node created (containers are transparent)
|
|
- [ ] `appendChild` for Sequential children: creates sequential edges between consecutive siblings (manages `parentStack`)
|
|
- [ ] `appendChild` for Parallel children: no inter-child edges, pushes parallel group marker for successor connections
|
|
- [ ] `appendChild` for Conditional: creates conditional edge with `dataFlow: true`
|
|
- [ ] Edge attributes include `edgeType` and `dataFlow` inference (conservative strategy: conditional always dataFlow: true, sequential with result references → dataFlow: true, otherwise dataFlow: false)
|
|
- [ ] `finalizeInstance`: cleans up parentStack after container children are rendered
|
|
- [ ] `removeChild`: removes edge between parent and child (structural containers are transparent)
|
|
- [ ] `removeChildFromHost`: removes child node from graph and all attached edges
|
|
- [ ] Cycle detection after rendering: if `hasCycle()` returns true, throw `CycleError`
|
|
- [ ] Re-exported from `src/host/index.ts`
|
|
- [ ] Integration tests: render Sequential → assert node/edge structure, render Parallel → assert no inter-child edges, render Conditional → assert conditional edges with dataFlow, nested compositions, cycle detection
|
|
|
|
## References
|
|
|
|
- docs/architecture/host-configs.md — GraphologyHostConfig full specification
|
|
- docs/architecture/workflow-templates.md — edge creation rules, root node handling, template→DAG conversion
|
|
- docs/architecture/schema.md — TemplateEdgeAttrs, dataFlow inference
|
|
|
|
## Notes
|
|
|
|
> To be filled by implementation agent
|
|
|
|
## Summary
|
|
|
|
> To be filled on completion |