Files
git.stella-ops.org/docs/features/unchecked/libraries/unified-deterministic-resolver.md

2.9 KiB

Unified Deterministic Resolver (DeterministicResolver)

Module

__Libraries

Status

IMPLEMENTED

Description

Full deterministic resolver with 4-phase resolution (validate, order, evaluate, digest), immutable evidence graph with content-addressed GraphDigest, Tarjan's SCC cycle detection, implicit data detection, and integration with trust lattice engine. Guarantees pure evaluation with no IO in the compute phase.

Implementation Details

  • DeterministicResolver: src/__Libraries/StellaOps.Resolver/DeterministicResolver.cs -- ResolveAsync(graph, evaluator, context) orchestrates 4-phase resolution: Phase 1 Validate(graph) runs cycle detection and implicit data detection; Phase 2 OrderNodes(graph) produces deterministic topological ordering; Phase 3 EvaluatePure(orderedNodes, evaluator, context) evaluates each node with predecessor verdicts (no IO); Phase 4 computes final resolution digest from all node verdicts; uses PureEvaluationContext to enforce runtime purity
  • EvidenceGraph: src/__Libraries/StellaOps.Resolver/EvidenceGraph.cs -- immutable record with sorted Nodes (IReadOnlyList) and Edges (IReadOnlyList); GraphDigest (content-addressed via CanonicalJsonSerializer.SerializeWithDigest); AddNode(node) and AddEdge(edge) return new immutable instances; nodes and edges sorted for deterministic digest
  • GraphValidation: src/__Libraries/StellaOps.Resolver/GraphValidation.cs -- DefaultGraphValidator combining TarjanCycleDetector (Tarjan's SCC algorithm with IsCycleCut edge exclusion) and DefaultImplicitDataDetector (detects dangling edges, duplicate IDs); TarjanCycleDetector uses index/lowlink tracking, stack-based DFS, reports strongly connected components with >1 node as cycles
  • RuntimePurity: src/__Libraries/StellaOps.Resolver/Purity/RuntimePurity.cs -- PureEvaluationContext with CreateStrict() (all prohibited accessors) and Create(injectedNow, envVars) (deterministic providers); ProhibitedTimeProvider, ProhibitedNetworkAccessor, ProhibitedFileSystemAccessor, ProhibitedEnvironmentAccessor all throw AmbientAccessViolationException; InjectedTimeProvider and InjectedEnvironmentAccessor for deterministic evaluation
  • Source: Feature matrix scan

E2E Test Plan

  • Verify DeterministicResolver.ResolveAsync produces deterministic results for same graph
  • Test Phase 1: Validate detects cycles via Tarjan's SCC and reports them
  • Verify Phase 2: OrderNodes produces stable topological ordering
  • Test Phase 3: EvaluatePure runs without IO access (PureEvaluationContext enforced)
  • Verify Phase 4: final resolution digest is content-addressed and deterministic
  • Test EvidenceGraph is immutable (AddNode/AddEdge return new instances)
  • Verify GraphDigest changes when any node or edge changes
  • Test DefaultImplicitDataDetector catches dangling edges and duplicate node IDs