Files
flowgraph/tasks/graph-validation.md

39 lines
1.7 KiB
Markdown

---
id: graph/validation
name: Implement graph validation functions (validateSchema, validateGraph, validate)
status: completed
depends_on:
- graph/flowgraph-class
- error/hierarchy
scope: narrow
risk: low
impact: component
level: implementation
---
## Description
Implement the validation functions that check graph integrity. These never throw — they collect issues and return structured error arrays. This follows the returning (not throwing) contract per error-handling.md.
## Acceptance Criteria
- [ ] `validateSchema<NodeAttrs>(graph, NodeAttrsSchema): ValidationError[]` — checks each node's attributes against the TypeBox schema using `Value.Errors()`, returns `ValidationError[]`
- [ ] `validateGraph(graph): GraphValidationError[]` — checks for cycles, dangling references, orphan nodes, status inconsistencies; returns `GraphValidationError[]`
- [ ] `validate(graph): AnyValidationError[]` — runs both schema and graph validation, returns combined `AnyValidationError[]`
- [ ] All validation functions use the "collect all errors" pattern — never throw, never short-circuit
- [ ] `GraphValidationError` categories: `cycle` (with cycle paths), `dangling-reference` (with source/target), `orphan-node` (with node key), `status-inconsistency` (with node/parent status details)
- [ ] Unit tests: valid graph returns empty array, each category of error detected, multiple errors collected
## References
- docs/architecture/error-handling.md — validation result types, collecting errors
- docs/architecture/analysis.md — validateGraph, validate functions
- docs/architecture/flowgraph-api.md — validate convenience method
## Notes
> To be filled by implementation agent
## Summary
> To be filled on completion