Files
git.stella-ops.org/docs/features/checked/policy/time-travel-replay-engine.md
2026-02-14 09:11:48 +02:00

2.9 KiB

Time-Travel Replay Engine

Module

Policy

Status

IMPLEMENTED

Description

Re-evaluation of any historical decision using only snapshot content and recorded execution contract, producing match/mismatch reports with deterministic comparison.

Implementation Details

  • ReplayEngine: src/Policy/__Libraries/StellaOps.Policy/Replay/ReplayEngine.cs (sealed class implements IReplayEngine)
    • ReplayAsync(ReplayRequest) replays historical decisions using frozen snapshot inputs
    • Pipeline: load snapshot -> verify snapshot integrity -> resolve frozen inputs -> execute evaluation -> compare with original -> generate report
    • Frozen inputs prevent time-dependent drift (no network fetch, no live data)
    • Duration tracking for performance analysis
  • ReplayRequest: src/Policy/__Libraries/StellaOps.Policy/Replay/ReplayRequest.cs
    • ArtifactDigest, SnapshotId (content-addressed), OriginalVerdictId
    • ReplayOptions: CompareWithOriginal=true, AllowNetworkFetch=false, GenerateDetailedReport=true, ScoreTolerance=0.001
  • ReplayResult: src/Policy/__Libraries/StellaOps.Policy/Replay/ReplayResult.cs
    • MatchStatus: ExactMatch, MatchWithinTolerance, Mismatch, NoComparison, ReplayFailed
    • DeltaReport: Summary, FieldDeltas, FindingDeltas, SuspectedCauses
  • VerdictComparer: src/Policy/__Libraries/StellaOps.Policy/Replay/VerdictComparer.cs -- deterministic verdict comparison
  • ReplayReport: src/Policy/__Libraries/StellaOps.Policy/Replay/ReplayReport.cs -- detailed report generation
  • KnowledgeSourceResolver: src/Policy/__Libraries/StellaOps.Policy/Replay/KnowledgeSourceResolver.cs -- resolves snapshot sources to frozen data
  • KnowledgeSnapshotManifest: src/Policy/__Libraries/StellaOps.Policy/Snapshots/KnowledgeSnapshotManifest.cs
    • Content-addressed snapshots enable time-travel to any historical state
    • Sources with Epoch and Digest for point-in-time data resolution
  • SnapshotAwarePolicyEvaluator: src/Policy/__Libraries/StellaOps.Policy/Snapshots/SnapshotAwarePolicyEvaluator.cs
    • Evaluates policy using only pinned snapshot inputs (no live data)

E2E Test Plan

  • Replay decision from 30 days ago using its snapshot; verify ExactMatch (deterministic)
  • Replay decision with modified snapshot source; verify Mismatch with SuspectedCauses
  • Replay with AllowNetworkFetch=false; verify no external calls made during replay
  • Verify ReplayResult.Duration tracks execution time
  • Replay with missing snapshot; verify ReplayFailed with descriptive error
  • Replay with ScoreTolerance=0.01; introduce minor floating-point drift; verify MatchWithinTolerance
  • Verify DeltaReport.FieldDeltas shows exact field-level differences for Mismatch
  • Verify DeltaReport.FindingDeltas shows finding-level changes (Added/Removed/Modified)
  • Replay multiple historical decisions; verify each produces correct MatchStatus
  • Verify snapshot integrity check runs before replay execution