Files
git.stella-ops.org/docs/features/checked/libraries/evidence-graph-with-validation.md
2026-02-14 09:11:48 +02:00

37 lines
2.8 KiB
Markdown

# Evidence Graph with Validation
## Module
__Libraries
## Status
VERIFIED
## Description
Evidence graph model with pre-traversal validation, cycle detection, and policy integration.
## Implementation Details
- **EvidenceGraph**: `src/__Libraries/StellaOps.Resolver/EvidenceGraph.cs` -- immutable record with `ImmutableArray<Node> Nodes` and `ImmutableArray<Edge> Edges` (both sorted by ID for determinism); content-addressed `GraphDigest` computed via `CanonicalJsonSerializer.SerializeWithDigest`; factory method `Create(nodes, edges)` sorts collections; `AddNode`/`AddEdge` return new immutable instances; `GetInboundEdges`/`GetOutboundEdges` for graph traversal; `NodeIds`/`EdgeIds` lazy computed sorted arrays
- **GraphValidation**: `src/__Libraries/StellaOps.Resolver/GraphValidation.cs` -- `DefaultGraphValidator` combining cycle detection and implicit data detection; `TarjanCycleDetector` (Tarjan's SCC algorithm, excludes `IsCycleCut` edges from adjacency); `DefaultImplicitDataDetector` catches dangling edge sources/destinations, duplicate NodeIds, duplicate EdgeIds; `GraphValidationResult` record with `IsValid`, `Cycles`, `Errors`, `Warnings`, `ImplicitDataViolations`; `CycleInfo` record with CycleNodes and optional CutEdge; `ImplicitDataViolation` record; `InvalidGraphException` for validation failures
- **DeterministicResolver**: `src/__Libraries/StellaOps.Resolver/DeterministicResolver.cs` -- 4-phase resolution: (1) Validate graph via `IGraphValidator`, (2) Compute traversal order via `IGraphOrderer`, (3) Evaluate each node with `ITrustLatticeEvaluator` using predecessor verdicts, (4) Compute final digest via `IFinalDigestComputer`; `ResolutionResult` with TraversalSequence, Verdicts, GraphDigest, PolicyDigest, FinalDigest, ResolvedAt, ResolverVersion
- **TopologicalGraphOrderer**: `src/__Libraries/StellaOps.Resolver/TopologicalGraphOrderer.cs` -- deterministic topological sort for traversal ordering
- **ResolutionVerifier**: `src/__Libraries/StellaOps.Resolver/ResolutionVerifier.cs` -- verifies resolution results for integrity
- **Source**: Feature matrix scan
## E2E Test Plan
- [ ] Verify EvidenceGraph.Create sorts nodes and edges deterministically
- [ ] Test GraphDigest is content-addressed and changes when nodes/edges change
- [ ] Verify TarjanCycleDetector finds cycles and identifies IsCycleCut edges
- [ ] Test DefaultImplicitDataDetector catches dangling edges and duplicate IDs
- [ ] Verify DeterministicResolver produces identical ResolutionResult for same inputs
- [ ] Test 4-phase resolution: validate, order, evaluate, digest
- [ ] Verify immutability: AddNode/AddEdge return new graph instances without mutating original
- [ ] Test InvalidGraphException contains validation error details
## Verification
- **Verified**: 2026-02-13T20:30:00Z
- **Run**: run-001
- **Tier**: Tier 2d (Library/Internal)
- **Verdict**: PASS