This commit is contained in:
StellaOps Bot
2025-12-09 00:20:52 +02:00
parent 3d01bf9edc
commit bc0762e97d
261 changed files with 14033 additions and 4427 deletions

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using StellaOps.Signals.Models;
using StellaOps.Signals.Services;
using Xunit;
public class ReachabilityFactDigestCalculatorTests
{
[Fact]
public void Compute_ReturnsDeterministicDigest_ForEquivalentFacts()
{
var factA = new ReachabilityFactDocument
{
CallgraphId = "cg-1",
Subject = new ReachabilitySubject { Component = "demo", Version = "1.0.0" },
SubjectKey = "demo|1.0.0",
EntryPoints = new List<string> { "svc.main", "app.main" },
States = new List<ReachabilityStateDocument>
{
new() { Target = "a", Reachable = true, Confidence = 0.9, Bucket = "runtime", Weight = 0.45, Path = new List<string> { "app.main", "a" }, Evidence = new ReachabilityEvidenceDocument { RuntimeHits = new List<string> { "a" } } },
new() { Target = "b", Reachable = false, Confidence = 0.3, Bucket = "unreachable", Weight = 0.1, Path = new List<string> { "app.main", "b" } }
},
RuntimeFacts = new List<RuntimeFactDocument>
{
new() { SymbolId = "a", HitCount = 2 }
},
Metadata = new Dictionary<string, string?>(StringComparer.Ordinal) { { "tenant", "tenant-default" } },
ComputedAt = DateTimeOffset.Parse("2025-12-09T00:00:00Z")
};
var factB = new ReachabilityFactDocument
{
CallgraphId = "cg-1",
Subject = new ReachabilitySubject { Component = "demo", Version = "1.0.0" },
SubjectKey = "demo|1.0.0",
EntryPoints = new List<string> { "app.main", "svc.main" }, // reversed
States = new List<ReachabilityStateDocument>
{
new() { Target = "b", Reachable = false, Confidence = 0.3, Bucket = "unreachable", Weight = 0.1, Path = new List<string> { "app.main", "b" } },
new() { Target = "a", Reachable = true, Confidence = 0.9, Bucket = "runtime", Weight = 0.45, Path = new List<string> { "app.main", "a" }, Evidence = new ReachabilityEvidenceDocument { RuntimeHits = new List<string> { "a" } } }
},
RuntimeFacts = new List<RuntimeFactDocument>
{
new() { SymbolId = "a", HitCount = 2 }
},
Metadata = new Dictionary<string, string?>(StringComparer.Ordinal) { { "tenant", "tenant-default" } },
ComputedAt = DateTimeOffset.Parse("2025-12-09T00:00:00Z")
};
var digestA = ReachabilityFactDigestCalculator.Compute(factA);
var digestB = ReachabilityFactDigestCalculator.Compute(factB);
Assert.StartsWith("sha256:", digestA, StringComparison.Ordinal);
Assert.Equal(digestA, digestB);
}
}