Refactor code structure and optimize performance across multiple modules

This commit is contained in:
StellaOps Bot
2025-12-26 20:03:22 +02:00
parent c786faae84
commit b4fc66feb6
3353 changed files with 88254 additions and 1590657 deletions

View File

@@ -6,11 +6,13 @@
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class CycleDetectionTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GraphWithMarkedCycleCutEdge_IsValid()
{
// CYCLE-9100-016: Graph with marked cycle-cut edge passes validation
@@ -33,7 +35,8 @@ public class CycleDetectionTests
Assert.True(result.IsValid, $"Expected valid graph. Errors: {string.Join(", ", result.Errors)}");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GraphWithUnmarkedCycle_ThrowsInvalidGraphException()
{
// CYCLE-9100-017: Graph with unmarked cycle throws exception
@@ -57,7 +60,8 @@ public class CycleDetectionTests
Assert.Contains(result.Errors, e => e.Contains("Cycle detected without IsCycleCut edge"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GraphWithMultipleCycles_AllMarked_IsValid()
{
// CYCLE-9100-018: Multiple cycles, all marked
@@ -84,7 +88,8 @@ public class CycleDetectionTests
Assert.True(result.IsValid);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GraphWithMultipleCycles_OneUnmarked_HasError()
{
// CYCLE-9100-019: Multiple cycles, one unmarked
@@ -112,7 +117,8 @@ public class CycleDetectionTests
Assert.Single(result.Errors.Where(e => e.Contains("Cycle detected")));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CycleDetection_IsDeterministic()
{
// CYCLE-9100-020: Property test - deterministic detection
@@ -142,7 +148,8 @@ public class CycleDetectionTests
}
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CycleCutEdge_IncludedInGraphDigest()
{
// CYCLE-9100-021: Cycle-cut edges affect graph digest

View File

@@ -7,6 +7,7 @@
using System.Text.Json;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class DeterministicResolverTests
@@ -15,7 +16,8 @@ public class DeterministicResolverTests
private readonly IGraphOrderer _orderer = new TopologicalGraphOrderer();
private readonly ITrustLatticeEvaluator _evaluator = new DefaultTrustLatticeEvaluator();
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Run_SameInputTwice_IdenticalFinalDigest()
{
// RESOLVER-9100-020: Replay test
@@ -31,7 +33,8 @@ public class DeterministicResolverTests
Assert.Equal(result1.TraversalSequence.Length, result2.TraversalSequence.Length);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Run_ShuffledNodesAndEdges_IdenticalFinalDigest()
{
// RESOLVER-9100-021: Permutation test
@@ -60,7 +63,8 @@ public class DeterministicResolverTests
Assert.Equal(result1.FinalDigest, result2.FinalDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Run_IsIdempotent()
{
// RESOLVER-9100-022: Idempotency property test
@@ -76,7 +80,8 @@ public class DeterministicResolverTests
Assert.Equal(result2.FinalDigest, result3.FinalDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Run_TraversalSequence_MatchesTopologicalOrder()
{
// RESOLVER-9100-023: Traversal order test
@@ -106,7 +111,8 @@ public class DeterministicResolverTests
"Root should appear before at least one child in traversal");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ResolutionResult_CanonicalJsonStructure()
{
// RESOLVER-9100-024: Snapshot test for canonical JSON

View File

@@ -6,11 +6,13 @@
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class EdgeIdTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EdgeId_ComputedDeterministically()
{
// EDGEID-9100-015: EdgeId computed deterministically
@@ -25,7 +27,8 @@ public class EdgeIdTests
Assert.Equal(64, edgeId1.Value.Length); // SHA256 hex
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EdgeId_OrderingConsistentWithStringOrdering()
{
// EDGEID-9100-016: EdgeId ordering is consistent
@@ -43,7 +46,8 @@ public class EdgeIdTests
Assert.Equal(sorted1, sorted2);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GraphHash_ChangesWhenEdgeAddedOrRemoved()
{
// EDGEID-9100-017: Graph hash changes with edge changes
@@ -63,7 +67,8 @@ public class EdgeIdTests
Assert.NotEqual(graph2.GraphDigest, graph3.GraphDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EdgeDelta_CorrectlyIdentifiesChanges()
{
// EDGEID-9100-018: Delta detection identifies changes
@@ -86,7 +91,8 @@ public class EdgeIdTests
Assert.Empty(delta.ModifiedEdges);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EdgeId_IsIdempotent()
{
// EDGEID-9100-019: Property test - idempotent computation

View File

@@ -7,6 +7,7 @@
using System.Text.Json;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class FinalDigestTests
@@ -15,7 +16,8 @@ public class FinalDigestTests
private readonly IGraphOrderer _orderer = new TopologicalGraphOrderer();
private readonly ITrustLatticeEvaluator _evaluator = new DefaultTrustLatticeEvaluator();
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void FinalDigest_IsDeterministic()
{
// DIGEST-9100-018: Same inputs → same digest
@@ -29,7 +31,8 @@ public class FinalDigestTests
Assert.Equal(result1.FinalDigest, result2.FinalDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void FinalDigest_ChangesWhenVerdictChanges()
{
// DIGEST-9100-019: FinalDigest changes when any verdict changes
@@ -53,7 +56,8 @@ public class FinalDigestTests
Assert.Equal(64, result1.FinalDigest.Length);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void FinalDigest_ChangesWhenGraphChanges()
{
// DIGEST-9100-020: FinalDigest changes when graph changes
@@ -76,7 +80,8 @@ public class FinalDigestTests
Assert.NotEqual(result1.FinalDigest, result2.FinalDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void FinalDigest_ChangesWhenPolicyChanges()
{
// DIGEST-9100-021: FinalDigest changes when policy changes
@@ -97,7 +102,8 @@ public class FinalDigestTests
Assert.NotEqual(result1.FinalDigest, result2.FinalDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerificationApi_CorrectlyIdentifiesMatch()
{
// DIGEST-9100-022: Verification API works
@@ -116,7 +122,8 @@ public class FinalDigestTests
Assert.Empty(verification.Differences);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerificationApi_CorrectlyIdentifiesMismatch()
{
// DIGEST-9100-022 continued: Verification API detects mismatch
@@ -137,7 +144,8 @@ public class FinalDigestTests
Assert.NotEmpty(verification.Differences);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void FinalDigest_IsCollisionResistant()
{
// DIGEST-9100-024: Property test - different inputs → different digest

View File

@@ -6,11 +6,13 @@
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class GraphValidationTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void NfcNormalization_ProducesConsistentNodeIds()
{
// VALID-9100-021: NFC normalization produces consistent NodeIds
@@ -28,7 +30,8 @@ public class GraphValidationTests
Assert.Equal(nodeId1, nodeId2);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EdgeReferencingNonExistentNode_Detected()
{
// VALID-9100-022
@@ -45,7 +48,8 @@ public class GraphValidationTests
Assert.Contains(violations, v => v.ViolationType == "DanglingEdgeDestination");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void DuplicateNodeIds_Detected()
{
// VALID-9100-023
@@ -64,7 +68,8 @@ public class GraphValidationTests
Assert.Contains(violations, v => v.ViolationType == "DuplicateNodeId");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void DuplicateEdgeIds_Detected()
{
// VALID-9100-024
@@ -86,7 +91,8 @@ public class GraphValidationTests
Assert.Contains(violations, v => v.ViolationType == "DuplicateEdgeId");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ValidGraph_PassesAllChecks()
{
// VALID-9100-027
@@ -106,7 +112,8 @@ public class GraphValidationTests
Assert.Empty(result.Errors);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void NfcNormalization_IsIdempotent()
{
// VALID-9100-028: Property test - NFC is idempotent
@@ -121,7 +128,8 @@ public class GraphValidationTests
Assert.Equal(normalized2, normalized3);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EmptyGraph_IsValid()
{
var graph = EvidenceGraph.Empty;

View File

@@ -7,11 +7,13 @@
using StellaOps.Resolver.Purity;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class RuntimePurityTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ProhibitedTimeProvider_ThrowsOnAccess()
{
// PURITY-9100-021
@@ -20,7 +22,8 @@ public class RuntimePurityTests
Assert.Throws<AmbientAccessViolationException>(() => _ = provider.Now);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ProhibitedEnvironmentAccessor_ThrowsOnAccess()
{
// PURITY-9100-024
@@ -29,7 +32,8 @@ public class RuntimePurityTests
Assert.Throws<AmbientAccessViolationException>(() => accessor.GetVariable("PATH"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void InjectedTimeProvider_ReturnsInjectedTime()
{
// PURITY-9100-025
@@ -39,7 +43,8 @@ public class RuntimePurityTests
Assert.Equal(injectedTime, provider.Now);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void InjectedEnvironmentAccessor_ReturnsInjectedValues()
{
var vars = new Dictionary<string, string> { { "TEST_VAR", "test_value" } };
@@ -49,7 +54,8 @@ public class RuntimePurityTests
Assert.Null(accessor.GetVariable("NONEXISTENT"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void PureEvaluationContext_StrictMode_ThrowsOnAmbientAccess()
{
var context = PureEvaluationContext.CreateStrict();
@@ -57,7 +63,8 @@ public class RuntimePurityTests
Assert.Throws<AmbientAccessViolationException>(() => _ = context.InjectedNow);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void PureEvaluationContext_WithInjectedValues_WorksCorrectly()
{
var injectedTime = DateTimeOffset.Parse("2025-12-24T12:00:00Z");
@@ -66,7 +73,8 @@ public class RuntimePurityTests
Assert.Equal(injectedTime, context.InjectedNow);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void AmbientAccessViolationException_ContainsDetails()
{
var ex = new AmbientAccessViolationException("Time", "Attempted DateTime.Now access");
@@ -76,7 +84,8 @@ public class RuntimePurityTests
Assert.Contains("Time", ex.Message);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void FullResolution_CompletesWithoutAmbientAccess()
{
// PURITY-9100-027: Integration test

View File

@@ -24,6 +24,7 @@
<ItemGroup>
<ProjectReference Include="..\StellaOps.Resolver\StellaOps.Resolver.csproj" />
<ProjectReference Include="../StellaOps.TestKit/StellaOps.TestKit.csproj" />
</ItemGroup>
</Project>

View File

@@ -7,11 +7,13 @@
using System.Text.Json;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Resolver.Tests;
public class VerdictDigestTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerdictDigest_IsDeterministic()
{
// VDIGEST-9100-016: Same verdict → same digest
@@ -24,7 +26,8 @@ public class VerdictDigestTests
Assert.Equal(verdict1.VerdictDigest, verdict2.VerdictDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerdictDigest_ChangesWhenStatusChanges()
{
// VDIGEST-9100-017: Digest changes with status
@@ -37,7 +40,8 @@ public class VerdictDigestTests
Assert.NotEqual(passVerdict.VerdictDigest, failVerdict.VerdictDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerdictDigest_ChangesWhenEvidenceChanges()
{
// VDIGEST-9100-018: Digest changes with evidence
@@ -51,7 +55,8 @@ public class VerdictDigestTests
Assert.NotEqual(verdict1.VerdictDigest, verdict2.VerdictDigest);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerdictDelta_CorrectlyIdentifiesChangedVerdicts()
{
// VDIGEST-9100-019: Delta detection identifies changed verdicts
@@ -95,7 +100,8 @@ public class VerdictDigestTests
Assert.Equal(nodeId2, delta.ChangedVerdicts[0].Old.Node);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerdictDelta_HandlesAddedRemovedNodes()
{
// VDIGEST-9100-020: Delta handles added/removed nodes
@@ -136,7 +142,8 @@ public class VerdictDigestTests
Assert.Equal(nodeId2, delta.RemovedVerdicts[0].Node);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VerdictDigest_ExcludesItselfFromComputation()
{
// VDIGEST-9100-021: Property test - no recursion