up
Some checks failed
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Policy Simulation / policy-simulate (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-12-13 09:37:15 +02:00
parent e00f6365da
commit 6e45066e37
349 changed files with 17160 additions and 1867 deletions

View File

@@ -1,6 +1,5 @@
using System.Security.Cryptography;
using System.Text.Json;
using System.Text.RegularExpressions;
using FluentAssertions;
using Xunit;
@@ -55,29 +54,47 @@ public class CorpusFixtureTests
}
[Fact]
public void ExpectFilesContainRequiredFields()
public void GroundTruthFilesContainRequiredFields()
{
var manifestPath = Path.Combine(CorpusRoot, "manifest.json");
var manifest = JsonDocument.Parse(File.ReadAllBytes(manifestPath)).RootElement.EnumerateArray().ToArray();
var required = new[] { "id", "language", "state", "score" };
var idRegex = new Regex(@"^id:\s*(?<id>.+)$", RegexOptions.Multiline);
const string expectedSchemaVersion = "reachbench.reachgraph.truth/v1";
var allowedVariants = new[] { "reachable", "unreachable" };
foreach (var entry in manifest)
{
var id = entry.GetProperty("id").GetString()!;
var language = entry.GetProperty("language").GetString()!;
var expectPath = Path.Combine(CorpusRoot, language, id, "expect.yaml");
File.Exists(expectPath).Should().BeTrue($"{id} missing expect.yaml");
var text = File.ReadAllText(expectPath);
var truthPath = Path.Combine(CorpusRoot, language, id, "ground-truth.json");
File.Exists(truthPath).Should().BeTrue($"{id} missing ground-truth.json");
foreach (var field in required)
using var truthDoc = JsonDocument.Parse(File.ReadAllBytes(truthPath));
truthDoc.RootElement.GetProperty("schema_version").GetString().Should().Be(expectedSchemaVersion, $"{id} ground-truth schema_version mismatch");
truthDoc.RootElement.GetProperty("case_id").GetString().Should().Be(id, $"{id} ground-truth case_id must match manifest id");
var variant = truthDoc.RootElement.GetProperty("variant").GetString();
variant.Should().NotBeNullOrWhiteSpace($"{id} ground-truth must set variant");
allowedVariants.Should().Contain(variant!, $"{id} variant must be reachable|unreachable");
truthDoc.RootElement.TryGetProperty("paths", out var pathsProp).Should().BeTrue($"{id} ground-truth must include paths");
pathsProp.ValueKind.Should().Be(JsonValueKind.Array, $"{id} paths must be an array");
if (string.Equals(variant, "reachable", StringComparison.Ordinal))
{
text.Should().Contain($"{field}:", $"{id} expect.yaml missing '{field}:'");
pathsProp.GetArrayLength().Should().BeGreaterThan(0, $"{id} reachable ground-truth should include at least one path");
}
var match = idRegex.Match(text);
match.Success.Should().BeTrue($"{id} expect.yaml should include matching id");
match.Groups["id"].Value.Trim().Should().Be(id, $"{id} expect.yaml id must match manifest id");
foreach (var path in pathsProp.EnumerateArray())
{
path.ValueKind.Should().Be(JsonValueKind.Array, $"{id} each path must be an array");
path.GetArrayLength().Should().BeGreaterThan(0, $"{id} each path must contain at least one symbol");
foreach (var segment in path.EnumerateArray())
{
segment.ValueKind.Should().Be(JsonValueKind.String, $"{id} path segments must be strings");
segment.GetString().Should().NotBeNullOrWhiteSpace($"{id} path segments must be non-empty strings");
}
}
}
}
}

View File

@@ -0,0 +1,56 @@
using System.Text.Json;
using FluentAssertions;
using Xunit;
namespace StellaOps.Reachability.FixtureTests;
public sealed class FixtureCoverageTests
{
private static readonly string RepoRoot = ReachbenchFixtureTests.LocateRepoRoot();
private static readonly string ReachabilityRoot = Path.Combine(RepoRoot, "tests", "reachability");
private static readonly string CorpusRoot = Path.Combine(ReachabilityRoot, "corpus");
private static readonly string SamplesPublicRoot = Path.Combine(ReachabilityRoot, "samples-public");
[Fact]
public void CorpusAndPublicSamplesCoverExpectedLanguageBuckets()
{
var corpusLanguages = ReadManifestLanguages(Path.Combine(CorpusRoot, "manifest.json"));
corpusLanguages.Should().Contain(new[] { "dotnet", "go", "python", "rust" });
var samplesLanguages = ReadManifestLanguages(Path.Combine(SamplesPublicRoot, "manifest.json"));
samplesLanguages.Should().Contain(new[] { "csharp", "js", "php" });
}
[Fact]
public void CorpusManifestIsSorted()
{
var keys = ReadManifestKeys(Path.Combine(CorpusRoot, "manifest.json"));
keys.Should().NotBeEmpty("corpus manifest should have entries");
keys.Should().BeInAscendingOrder(StringComparer.Ordinal);
}
private static string[] ReadManifestLanguages(string manifestPath)
{
File.Exists(manifestPath).Should().BeTrue($"{manifestPath} should exist");
using var doc = JsonDocument.Parse(File.ReadAllBytes(manifestPath));
return doc.RootElement.EnumerateArray()
.Select(entry => entry.GetProperty("language").GetString())
.Where(language => !string.IsNullOrWhiteSpace(language))
.Select(language => language!)
.Distinct(StringComparer.Ordinal)
.OrderBy(language => language, StringComparer.Ordinal)
.ToArray();
}
private static string[] ReadManifestKeys(string manifestPath)
{
File.Exists(manifestPath).Should().BeTrue($"{manifestPath} should exist");
using var doc = JsonDocument.Parse(File.ReadAllBytes(manifestPath));
return doc.RootElement.EnumerateArray()
.Select(entry => $"{entry.GetProperty("language").GetString()}/{entry.GetProperty("id").GetString()}")
.ToArray();
}
}

View File

@@ -32,7 +32,7 @@ public sealed class ReachabilityReplayWriterTests
new("zastava", "cas://trace/1", "FFEE", DateTimeOffset.Parse("2025-10-15T09:00:00Z", CultureInfo.InvariantCulture)) // duplicate once normalized
};
var writer = new ReachabilityReplayWriter();
var writer = new StellaOps.Scanner.Reachability.ReachabilityReplayWriter();
writer.AttachEvidence(manifest, graphs, traces);
manifest.Reachability.Should().NotBeNull();
@@ -52,10 +52,12 @@ public sealed class ReachabilityReplayWriterTests
public void AttachEvidence_DoesNotCreateSectionWhenEmpty()
{
var manifest = new ReplayManifest();
var writer = new ReachabilityReplayWriter();
var writer = new StellaOps.Scanner.Reachability.ReachabilityReplayWriter();
writer.AttachEvidence(manifest, Array.Empty<ReachabilityReplayGraph>(), Array.Empty<ReachabilityReplayTrace>());
manifest.Reachability.Should().BeNull();
manifest.Reachability.AnalysisId.Should().BeNull();
manifest.Reachability.Graphs.Should().BeEmpty();
manifest.Reachability.RuntimeTraces.Should().BeEmpty();
}
}