Files
git.stella-ops.org/docs/features/unchecked/policy/property-based-tests.md

2.8 KiB

Property-Based Tests (FsCheck)

Module

Policy

Status

IMPLEMENTED

Description

Property-based tests using FsCheck for canonical JSON determinism, SBOM/VEX ordering invariants, floating-point stability, digest computation determinism, smart-diff properties, and VEX lattice merge commutativity.

Implementation Details

  • DecayPropertyTests: src/Policy/__Tests/StellaOps.Policy.Determinization.Tests/PropertyTests/DecayPropertyTests.cs
    • FsCheck properties for DecayedConfidenceCalculator: monotonicity, bounds, floor enforcement, half-life correctness
    • Verifies: decay factor always in [0, 1], result always >= floor, older observations have lower scores
  • DeterminismPropertyTests: src/Policy/__Tests/StellaOps.Policy.Determinization.Tests/PropertyTests/DeterminismPropertyTests.cs
    • FsCheck properties for deterministic evaluation: same inputs produce same outputs
    • Verifies: ObservationDecay CalculateDecay is deterministic, content-addressed ID generation is stable
  • ObservationDecayTests: src/Policy/__Tests/StellaOps.Policy.Determinization.Tests/Models/ObservationDecayTests.cs
    • Unit tests for ObservationDecay model: Create, Fresh, WithSettings, CalculateDecay, CheckIsStale
  • DeterminizationResultTests: src/Policy/__Tests/StellaOps.Policy.Determinization.Tests/Models/DeterminizationResultTests.cs
    • Unit tests for DeterminizationResult model
  • DecayedConfidenceCalculatorTests: src/Policy/__Tests/StellaOps.Policy.Determinization.Tests/DecayedConfidenceCalculatorTests.cs
    • Unit tests for DecayedConfidenceCalculator: boundary values, half-life verification, floor enforcement
  • DeterminizationGateTests: src/Policy/__Tests/StellaOps.Policy.Engine.Tests/Gates/Determinization/DeterminizationGateTests.cs
    • Integration tests for DeterminizationGate in gate pipeline
  • DeterminizationPolicyTests: src/Policy/__Tests/StellaOps.Policy.Engine.Tests/Policies/DeterminizationPolicyTests.cs
    • Policy-level tests for determinization enforcement

E2E Test Plan

  • Run DecayPropertyTests; verify all FsCheck properties pass (monotonicity, bounds, floor, half-life)
  • Run DeterminismPropertyTests; verify deterministic evaluation property holds for 1000+ random inputs
  • Verify DecayedConfidenceCalculator boundary: baseConfidence=0.0 always returns floor
  • Verify DecayedConfidenceCalculator boundary: ageDays=0 always returns baseConfidence
  • Verify ObservationDecay.Fresh(now).CheckIsStale(now) == false
  • Verify decay monotonicity: older age always produces lower or equal score
  • Verify content-addressed ID generation produces same ID for identical inputs (1000 iterations)
  • Verify DeterminizationGate integration with DecayedConfidenceCalculator in gate pipeline
  • Verify all test suites pass in CI with frozen test clock (no time-dependent flakiness)