Refactor SurfaceCacheValidator to simplify oldest entry calculation

Add global using for Xunit in test project

Enhance ImportValidatorTests with async validation and quarantine checks

Implement FileSystemQuarantineServiceTests for quarantine functionality

Add integration tests for ImportValidator to check monotonicity

Create BundleVersionTests to validate version parsing and comparison logic

Implement VersionMonotonicityCheckerTests for monotonicity checks and activation logic
This commit is contained in:
master
2025-12-16 10:44:00 +02:00
parent b1f40945b7
commit 4391f35d8a
107 changed files with 10844 additions and 287 deletions

View File

@@ -251,6 +251,102 @@ public sealed class SimpleJsonCallgraphParser : ICallgraphParser
return true;
}
private static bool TryParseFlatGraph(JsonElement root, out CallgraphParseResult result)
{
result = default!;
// Flat graph format: array of edges only, nodes derived from edge endpoints
if (root.ValueKind != JsonValueKind.Array)
{
return false;
}
var edges = new List<CallgraphEdge>();
var uniqueNodeIds = new HashSet<string>(StringComparer.Ordinal);
foreach (var edgeElement in root.EnumerateArray())
{
var source = GetString(edgeElement, "source", "from");
var target = GetString(edgeElement, "target", "to");
if (string.IsNullOrWhiteSpace(source) || string.IsNullOrWhiteSpace(target))
{
continue;
}
uniqueNodeIds.Add(source.Trim());
uniqueNodeIds.Add(target.Trim());
edges.Add(new CallgraphEdge
{
SourceId = source.Trim(),
TargetId = target.Trim(),
Type = GetString(edgeElement, "type", "kind") ?? "call",
Purl = GetString(edgeElement, "purl"),
SymbolDigest = GetString(edgeElement, "symbol_digest", "symbolDigest"),
Candidates = GetStringArray(edgeElement, "candidates"),
Confidence = GetNullableDouble(edgeElement, "confidence"),
Evidence = GetStringArray(edgeElement, "evidence")
});
}
if (edges.Count == 0)
{
return false;
}
var nodes = new List<CallgraphNode>();
foreach (var nodeId in uniqueNodeIds)
{
nodes.Add(new CallgraphNode { Id = nodeId, Name = nodeId, Kind = "function" });
}
result = new CallgraphParseResult(
nodes,
edges,
Array.Empty<CallgraphRoot>(),
"1.0",
"1.0",
null);
return true;
}
private static IReadOnlyList<CallgraphEntrypoint> ParseEntrypoints(JsonElement root)
{
if (!root.TryGetProperty("entrypoints", out var entrypointsEl) || entrypointsEl.ValueKind != JsonValueKind.Array)
{
return Array.Empty<CallgraphEntrypoint>();
}
var entrypoints = new List<CallgraphEntrypoint>(entrypointsEl.GetArrayLength());
var order = 0;
foreach (var ep in entrypointsEl.EnumerateArray())
{
var nodeId = GetString(ep, "nodeId", "node_id");
if (string.IsNullOrWhiteSpace(nodeId))
{
continue;
}
var kindStr = GetString(ep, "kind") ?? "unknown";
var phaseStr = GetString(ep, "phase") ?? "runtime";
var frameworkStr = GetString(ep, "framework") ?? "unknown";
entrypoints.Add(new CallgraphEntrypoint
{
NodeId = nodeId.Trim(),
Kind = Enum.TryParse<EntrypointKind>(kindStr, true, out var kind) ? kind : EntrypointKind.Unknown,
Phase = Enum.TryParse<EntrypointPhase>(phaseStr, true, out var phase) ? phase : EntrypointPhase.Runtime,
Framework = Enum.TryParse<EntrypointFramework>(frameworkStr, true, out var framework) ? framework : EntrypointFramework.Unknown,
Route = GetString(ep, "route"),
HttpMethod = GetString(ep, "httpMethod", "http_method"),
Source = GetString(ep, "source"),
Order = order++
});
}
return entrypoints;
}
private static IReadOnlyList<CallgraphRoot> ParseRoots(JsonElement root)
{
if (!root.TryGetProperty("roots", out var rootsEl) || rootsEl.ValueKind != JsonValueKind.Array)