From 8d7bee9346e26650ba718a68b5a513496eda4648 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 22 Sep 2026 19:13:12 +0200 Subject: [PATCH] Delete the retired hand-written mutation harness from this branch Operator ruling, 2026-09-22: "Better to have nothing than a harness that punishes refactoring." Removes scripts/mutate-dotnet.ps1 and every scripts/*.entries.ps1 mutation-entry file for CultNet selection (networking, mesh, caching, fix-batch-2). Also drops the two live code comments in tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs that cited entry ids (MESH-KEY-Loosening, MESH-DEFAULT-Loosening), rewording them to describe the rule instead of the retired harness. Mutation testing now uses Stryker.NET on the cut's diff, run by Soul. Co-Authored-By: Claude Sonnet 5 --- ...tate-cultnet-selection-caching.entries.ps1 | 107 ----- ...te-cultnet-selection-fixbatch2.entries.ps1 | 33 -- .../mutate-cultnet-selection-mesh.entries.ps1 | 91 ---- ...e-cultnet-selection-networking.entries.ps1 | 392 ------------------ scripts/mutate-dotnet.ps1 | 230 ---------- 5 files changed, 853 deletions(-) delete mode 100644 scripts/mutate-cultnet-selection-caching.entries.ps1 delete mode 100644 scripts/mutate-cultnet-selection-fixbatch2.entries.ps1 delete mode 100644 scripts/mutate-cultnet-selection-mesh.entries.ps1 delete mode 100644 scripts/mutate-cultnet-selection-networking.entries.ps1 delete mode 100644 scripts/mutate-dotnet.ps1 diff --git a/scripts/mutate-cultnet-selection-caching.entries.ps1 b/scripts/mutate-cultnet-selection-caching.entries.ps1 deleted file mode 100644 index 53d75601..00000000 --- a/scripts/mutate-cultnet-selection-caching.entries.ps1 +++ /dev/null @@ -1,107 +0,0 @@ -# Entries for scripts/mutate-dotnet.ps1: CultNet typed selection, Cut 1, commit 0 - the cache's public -# read surface (docs/cultnet-selection-cut.md, section 6, D8/D10/D11). Target: -# src/GameCult.Caching/CultCache.cs. Test project: tests/GameCult.Caching.Tests. - -@( - @{ - Id = 'CACHE-D8-Revert' - Rule = 'D8/S22: IsNumeric is derived from the closed CLR numeric set; a decimal-typed member must be numeric.' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.IsNumericAgreesForANullableNumericMemberAndADecimalMember' - Old = "typeof(int), typeof(uint), typeof(long), typeof(ulong),`n typeof(float), typeof(double), typeof(decimal)" - New = "typeof(int), typeof(uint), typeof(long), typeof(ulong),`n typeof(float), typeof(double)" - }, - @{ - Id = 'CACHE-D8-Loosening' - Rule = 'D8/S22: a string-typed member must not be treated as numeric.' - Mutant = 'loosening' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.IsNumericIsFalseForAStringAlias' - Old = "var underlying = Nullable.GetUnderlyingType(type) ?? type;`n return NumericClrTypes.Contains(underlying);" - New = 'return true;' - }, - @{ - Id = 'CACHE-D10-Revert' - Rule = 'D10: two differently-named members sharing one index alias are refused by name at registration.' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.DuplicateIndexAliasOnTwoDifferentlyNamedMembersIsRefusedByName' - Old = " // D10: two differently-named members that independently declare the same index alias. A`n // hiding member sharing one slot is already caught above; this is two distinct members whose`n // alias map entry (BuildDescriptor's indexAccessors) would otherwise collide silently.`n foreach (var group in keyed`n .Select(entry => (Entry: entry, Alias: ResolveIndexAlias(entry.Member)))`n .Where(pair => pair.Alias != null)`n .GroupBy(pair => pair.Alias, StringComparer.Ordinal)`n .Where(group => group.Select(pair => pair.Entry.Member.Name).Distinct().Count() > 1)`n .OrderBy(group => group.Key, StringComparer.Ordinal))`n {`n var pair = group.Take(2).ToArray();`n rejections.Add(DuplicateIndexAliasMessage(type.Name, Qualified(pair[0].Entry.Member), Qualified(pair[1].Entry.Member), group.Key!));`n }`n" - New = '' - }, - @{ - Id = 'CACHE-D10-Loosening' - Rule = 'D10: the collision groups by IndexAlias, not by Member.Name (which would refuse nothing HiddenMemberMessage does not already refuse).' - Mutant = 'loosening' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.DuplicateIndexAliasOnTwoDifferentlyNamedMembersIsRefusedByName' - Old = '.GroupBy(pair => pair.Alias, StringComparer.Ordinal)' - New = '.GroupBy(pair => pair.Entry.Member.Name, StringComparer.Ordinal)' - }, - @{ - Id = 'CACHE-D11-Revert' - Rule = 'D11: a dictionary reference is walked as edges keyed by CultRecordRef, not skipped as an unrecognised many-shape.' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.ReferencesOfEnumeratesADictionaryReferenceAsEdgesCarryingItsValues' - Old = 'if (TryGetDictionaryRefTypes(memberType, out var keyProperty, out var valueProperty))' - New = 'if (false && TryGetDictionaryRefTypes(memberType, out var keyProperty, out var valueProperty))' - }, - @{ - Id = 'CACHE-D11-Loosening' - Rule = 'D11/S19: a dictionary reference edge carries its value as payload, not null (two entries with different payload bytes must compare unequal).' - Mutant = 'loosening' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.ReferencesOfEnumeratesADictionaryReferenceAsEdgesCarryingItsValues' - Old = 'results.Add((reference.Key, valueProperty.GetValue(entry)));' - New = 'results.Add((reference.Key, (object?)null));' - }, - # Q-J (docs/cultnet-selection-cut.md section 2 "Numbers", 2026-09-22): the row side's canonical - # decimal rendering. The map named these five mutants explicitly; the fifth ("a row rendered - # through float64") is this campaign's, the other four are the door's (networking entries file). - @{ - Id = 'CACHE-QJ-IntegerFloat64-Revert' - Rule = 'Q-J: an integer renders its exact decimal, never through double - a long past 2^53 must not round.' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.TryGetIndexNumberRendersALongPast2Pow53ExactlyNotThroughFloat64' - Old = '_ => CanonicalizeDecimalDigits(Convert.ToString(raw, CultureInfo.InvariantCulture)!)' - New = '_ => CanonicalizeDecimalDigits(Convert.ToDouble(raw, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture))' - }, - @{ - Id = 'CACHE-QJ-DecimalTrailingZeros-Revert' - Rule = 'Q-J: a decimal renders with its trailing fractional zeros stripped.' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.TryGetIndexNumberStripsTrailingZerosFromADecimal' - Old = "fractionPart = fractionPart.TrimEnd('0');" - New = '' - }, - @{ - # R-D (docs/cultnet-selection-cut.md, Self's rulings for the Cut 1 fix batch): a double/float - # renders as its exact decimal expansion (RenderExactDouble/RenderExactFloat via BigInteger), - # never .NET's shortest round-trip form - the two runtimes' shortest forms round a tie the - # opposite way at some values (394/200k f32, 48/200k f64 in the parity vectors). This anchor - # replaces the pre-R-D CACHE-QJ-ExponentExpansion-Revert, whose ExpandScientificNotation callee - # R-D deleted outright. - Id = 'CACHE-RD-ExactExpansion-Revert' - Rule = 'R-D: a double renders its exact decimal expansion via RenderExactDouble/BigInteger, not .NET''s shortest round-trip ToString().' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.TryGetIndexNumberRewritesADoublesExponentNotationToPositionalDigits' - Old = 'double d => double.IsNaN(d) || double.IsInfinity(d) ? null : RenderExactDouble(d),' - New = 'double d => double.IsNaN(d) || double.IsInfinity(d) ? null : CanonicalizeDecimalDigits(d.ToString(CultureInfo.InvariantCulture)),' - }, - @{ - Id = 'CACHE-QJ-NaNInfinity-Revert' - Rule = 'Q-J: a NaN or infinite member matches no comparison - TryGetIndexNumber must answer false, not a garbage rendering of the value.' - Mutant = 'revert' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.TryGetIndexNumberReturnsFalseForNaNAndInfinity' - Old = 'double d => double.IsNaN(d) || double.IsInfinity(d) ? null : RenderExactDouble(d),' - New = 'double d => RenderExactDouble(d),' - }, - @{ - # R-D loosening: RenderExactDecimal's fraction-digit placement is off by one (a plausible - # fencepost slip in the BigInteger-to-string split), so every rendered fraction is 10x too - # large - still "exact-looking" digits, still no exponent, but the wrong value. Caught by the - # same test's pinned exact string for 1e-7's nearest double. - Id = 'CACHE-RD-FractionSplit-Loosening' - Rule = 'R-D: RenderExactDecimal splits the digit string at exactly fractionDigits from the right - not fractionDigits-1, which would shift the whole fractional rendering by a power of ten.' - Mutant = 'loosening' - Killer = 'FullyQualifiedName=GameCult.Caching.Tests.CultDocumentSelectionSurfaceTests.TryGetIndexNumberRewritesADoublesExponentNotationToPositionalDigits' - Old = 'var splitAt = digits.Length - fractionDigits;' - New = 'var splitAt = digits.Length - fractionDigits + 1;' - } -) diff --git a/scripts/mutate-cultnet-selection-fixbatch2.entries.ps1 b/scripts/mutate-cultnet-selection-fixbatch2.entries.ps1 deleted file mode 100644 index a8d322b2..00000000 --- a/scripts/mutate-cultnet-selection-fixbatch2.entries.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -# Entries for scripts/mutate-dotnet.ps1: CultNet typed selection, Cut 1, commit 2 fix batch -# (docs/cultnet-selection-cut.md, Self's rulings 2026-09-22). Targets the dead-identity-code deletion -# in src/GameCult.Networking/CultNetDatabaseSubscriptionServer.cs (S2-2): Reconcile must still walk -# its diff when the request stays authorized (not gated on DemandActive changing), and its add loop -# must still fire. Test project: tests/GameCult.Networking.Tests. - -@( - @{ - Id = 'NET-RECONCILE-EarlyReturn-Loosening' - Rule = 'Reconcile walks the delivered/added diff whenever it runs; it must not early-return merely because request-level authorization (and so DemandActive) has not changed - per-record authorization can still have moved.' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetDatabaseSubscriptionServer.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.NetworkingTests.DatabaseSubscriptionServer_Reconcile_FlipsPerRecordAuthorizationWithoutChangingRequestAuthority' - Old = 'if (!_projections.TryGetValue(key, out var projection)) return; - var authorized = _authorizeRequest?.Invoke(request, key.Peer) != false;' - New = 'if (!_projections.TryGetValue(key, out var projection)) return; - var authorized = _authorizeRequest?.Invoke(request, key.Peer) != false; - if (projection.DemandActive == authorized) return;' - }, - @{ - Id = 'NET-RECONCILE-AddLoop-Revert' - Rule = 'Reconcile''s add loop sends an upsert (added: true) for every key in the new snapshot that was not already delivered.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetDatabaseSubscriptionServer.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.NetworkingTests.DatabaseSubscriptionServer_Reconcile_FlipsPerRecordAuthorizationWithoutChangingRequestAuthority' - Old = 'foreach (var current in next.BySourceRecordKey) - { - if (!projection.DeliveredBySourceRecordKey.ContainsKey(current.Key)) - SendUpsert(key.Peer, key.Id, current.Value, added: true); - }' - New = '' - } -) diff --git a/scripts/mutate-cultnet-selection-mesh.entries.ps1 b/scripts/mutate-cultnet-selection-mesh.entries.ps1 deleted file mode 100644 index 23363195..00000000 --- a/scripts/mutate-cultnet-selection-mesh.entries.ps1 +++ /dev/null @@ -1,91 +0,0 @@ -# Entries for scripts/mutate-dotnet.ps1: CultNet typed selection, Cut 1, commit 2 fix batch -# (docs/cultnet-selection-cut.md, sections 4/7/11). Targets: src/GameCult.Mesh/CultMesh.cs -# (ReadDocumentFromSnapshotResponse's one exact read) and src/GameCult.Mesh/CultMeshSnapshots.cs -# (ResolveDefaultSelection's "no schema filter when keys are given" rule). Test project: -# tests/GameCult.Mesh.Tests. -# -# Every entry below carries its own File, so this runs as one invocation with both -Target paths. -# -# There are two loosening entries here (MESH-DEFAULT-Loosening and MESH-KEY-Loosening); the header -# above this line previously miscounted them as "two of three" (S2-9/S2-10). Both were genuine -# weaker readings of the rule they sit beside and both SURVIVED against the pre-fix-batch fixtures, -# because nothing in tests/GameCult.Mesh.Tests exercised an explicit empty (non-null) recordKeys -# array or a record-key case variation. CultMeshStreamingTests.cs now carries -# FetchDocumentsAsync_WithExplicitEmptyRecordKeys_StillDefaultsToOwnSchema (MESH-DEFAULT) and the -# case-variant-key block appended to DocumentHandle_ReadsRemotePeerSnapshotsAsTypedDocuments -# (MESH-KEY); both mutants below now die. - -@( - @{ - Id = 'MESH-DEFAULT-Revert' - Rule = 'ResolveDefaultSelection: an explicit non-empty recordKeys with no schemaIds means no schema filter, not the document type''s own schema.' - Mutant = 'revert' - File = 'src/GameCult.Mesh/CultMeshSnapshots.cs' - Killer = 'FullyQualifiedName=GameCult.Mesh.Tests.CultMeshStreamingTests.SnapshotEndpoint_ProvidesTypedHandlesAndSchemaAliases' - Old = 'var cleanedKeys = Clean(recordKeys); - var schemas = schemaIds != null - ? Clean(schemaIds) - : (cleanedKeys != null ? null : new[] { descriptor.SchemaId });' - New = 'var cleanedKeys = Clean(recordKeys); - var schemas = schemaIds != null ? Clean(schemaIds) : new[] { descriptor.SchemaId };' - }, - @{ - Id = 'MESH-DEFAULT-Loosening' - Rule = 'ResolveDefaultSelection: the no-schema-filter branch triggers on a non-empty (post-cleaning) recordKeys, not merely a non-null one - an explicit empty recordKeys array still defaults to the document type''s own schema (docs/cultnet-selection-cut.md, S2-7/rule 1''s v0 lowering).' - Mutant = 'loosening' - File = 'src/GameCult.Mesh/CultMeshSnapshots.cs' - Killer = 'FullyQualifiedName=GameCult.Mesh.Tests.CultMeshStreamingTests.FetchDocumentsAsync_WithExplicitEmptyRecordKeys_StillDefaultsToOwnSchema' - Old = 'cleanedKeys != null ? null : new[] { descriptor.SchemaId }' - New = 'recordKeys != null ? null : new[] { descriptor.SchemaId }' - }, - @{ - Id = 'MESH-KEY-Revert' - Rule = 'ReadDocumentFromSnapshotResponse: a candidate must name this recordKey - the one exact read never returns a record under the wrong key.' - Mutant = 'revert' - File = 'src/GameCult.Mesh/CultMesh.cs' - Killer = 'FullyQualifiedName=GameCult.Mesh.Tests.CultMeshStreamingTests.DocumentHandle_ReadsRemotePeerSnapshotsAsTypedDocuments' - Old = 'if (!string.Equals(candidate.RecordKey, recordKey, StringComparison.Ordinal)) - continue;' - New = '' - }, - @{ - Id = 'MESH-KEY-Loosening' - Rule = 'ReadDocumentFromSnapshotResponse: the recordKey match is exact (ordinal), not case-insensitive.' - Mutant = 'loosening' - File = 'src/GameCult.Mesh/CultMesh.cs' - Killer = 'FullyQualifiedName=GameCult.Mesh.Tests.CultMeshStreamingTests.DocumentHandle_ReadsRemotePeerSnapshotsAsTypedDocuments' - Old = 'if (!string.Equals(candidate.RecordKey, recordKey, StringComparison.Ordinal))' - New = 'if (!string.Equals(candidate.RecordKey, recordKey, StringComparison.OrdinalIgnoreCase))' - }, - @{ - Id = 'MESH-FOREIGN-Revert' - Rule = 'ReadDocumentFromSnapshotResponse: a foreign/runtime-generated schema id at the right recordKey still matches when its payload''s embedded schema (read by the registry''s shared resolver, now CultNetDocumentRegistry.PayloadMatchesSchema after the R-L rename of TryReadSchemaVersion back to internal) alias-matches the caller''s own descriptor.' - Mutant = 'revert' - File = 'src/GameCult.Mesh/CultMesh.cs' - Killer = 'FullyQualifiedName=GameCult.Mesh.Tests.CultMeshStreamingTests.DocumentHandle_ReadsRemotePeerSnapshotsAsTypedDocuments' - Old = 'else if (byPayload == null && CultNetDocumentRegistry.PayloadMatchesSchema(candidate.Payload, descriptor)) - byPayload = candidate;' - New = '' - }, - @{ - # R-F (docs/cultnet-selection-cut.md, Self's rulings for the Cut 1 fix batch): the door is - # inside select in both runtimes, and Mesh's EnsureV0Compatible runs the declaration-independent - # half of it (CultNetSelectionValidation.ValidateShape) before its own v0 transport refusals, so - # Keys=[]/[""] is refused there too instead of silently lowering to "every key". - Id = 'MESH-RF-Door-Revert' - Rule = 'R-F: EnsureV0Compatible runs the door (ValidateShape) before its own v0 term refusals, so Keys=[] is refused there, not only inside CultNetSelectionEvaluator.Select.' - Mutant = 'revert' - File = 'src/GameCult.Mesh/CultMeshSnapshots.cs' - Killer = 'FullyQualifiedName=GameCult.Mesh.Tests.CultMeshSnapshotOptionsTests.FetchSnapshotAsync_RefusesAnEmptyKeysListBeforeTouchingTheClient' - Old = 'if (selection == null) - return; - // The door runs first (docs/cultnet-selection-cut.md, R-F): Mesh has no descriptor list to - // check field/role reachability against, but the declaration-independent half of the door - - // an empty or blank-only schemas/keys list, an unrecognised projection - applies here just - // as it does inside CultNetSelectionEvaluator.Select, so Keys=[]/[""] is refused rather than - // silently lowered to "every key". - CultNetSelectionValidation.ValidateShape(selection);' - New = 'if (selection == null) - return;' - } -) diff --git a/scripts/mutate-cultnet-selection-networking.entries.ps1 b/scripts/mutate-cultnet-selection-networking.entries.ps1 deleted file mode 100644 index 19ddb2c7..00000000 --- a/scripts/mutate-cultnet-selection-networking.entries.ps1 +++ /dev/null @@ -1,392 +0,0 @@ -# Entries for scripts/mutate-dotnet.ps1: CultNet typed selection, Cut 1, commits 1-2 - the evaluator -# and D4's schema-identity collapse. Targets: -# src/GameCult.Networking/CultNetSelectionEvaluator.cs (S3/S5/S7/S16/S18) and -# src/GameCult.Networking/CultNetDatabase.cs (D4's fourth matcher). Every entry below carries its own -# File now, so this runs as one invocation with both -Target paths. Test project: -# tests/GameCult.Networking.Tests. -# -# Not exhaustive of S1-S23: this covers order, cursor freshness, the one negation, numeric boundaries -# and the reference_outside_target refusal. S1/S2/S6/S23 are pinned by tests but not yet mutation-run -# here; S9/S10-S15 (subscription reconcile, v0 lowering, cross-runtime) and S19/S21/S22 (cache layer) -# are covered elsewhere or not yet (see the Hands report for commit 1). - -@( - @{ - Id = 'NET-S3-Revert' - Rule = 'S3: order reverses under descending.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorOrdersByOrdinalThenIdentityAndReverses' - Old = 'var ordered = (selection.Descending' - New = 'var ordered = (false' - }, - @{ - Id = 'NET-S5-Stale-Revert' - Rule = 'S5: a cursor from a moved asOf is refused cursor_stale.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorRefusesAStaleCursorAndAMismatchedSelection' - Old = 'if (cursor.AsOf != asOf)' - New = 'if (false)' - }, - @{ - Id = 'NET-S5-Stale-Loosening' - Rule = 'S5: staleness compares equality, not only "cursor is newer than the current asOf".' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorRefusesAStaleCursorAndAMismatchedSelection' - Old = 'if (cursor.AsOf != asOf)' - New = 'if (cursor.AsOf > asOf)' - }, - @{ - Id = 'NET-S5-Invalid-Revert' - Rule = 'S5: a cursor whose digest does not match this selection is refused cursor_invalid.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorRefusesAStaleCursorAndAMismatchedSelection' - Old = "if (cursor.Digest != CultNetSelectionCursor.ComputeDigest(selection))`n throw new CultNetSelectionCursorException(`"cursor_invalid`", `"The cursor's selection digest does not match this selection.`");" - New = '' - }, - @{ - Id = 'NET-S7-Revert' - Rule = 'S7: cited { exists } is honoured, not ignored.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorNegatedIncomingEdgeIsTheOnlyNegation' - Old = 'candidates = candidates.Where(row => incoming.Contains(row.Key.Value) == exists);' - New = 'candidates = candidates.Where(row => incoming.Contains(row.Key.Value) || true);' - }, - @{ - Id = 'NET-S7-Loosening' - Rule = 'S7: exists:true and exists:false must answer opposite sets, not the same test inverted twice.' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorNegatedIncomingEdgeIsTheOnlyNegation' - Old = 'candidates = candidates.Where(row => incoming.Contains(row.Key.Value) == exists);' - New = 'candidates = candidates.Where(row => incoming.Contains(row.Key.Value) != exists);' - }, - @{ - Id = 'NET-S16-Le-Revert' - Rule = 'S16: le includes the equal boundary.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorComparesNumbersAtTheBoundaryForEachOfTheFourOperators' - Old = 'CultNetSelectionOperator.Le => cmp <= 0,' - New = 'CultNetSelectionOperator.Le => cmp < 0,' - }, - @{ - Id = 'NET-S16-Ge-Revert' - Rule = 'S16: ge includes the equal boundary.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorComparesNumbersAtTheBoundaryForEachOfTheFourOperators' - Old = 'CultNetSelectionOperator.Ge => cmp >= 0,' - New = 'CultNetSelectionOperator.Ge => cmp > 0,' - }, - @{ - Id = 'NET-S18-Revert' - Rule = 'D9/S18: an edge naming a row outside its reference''s declared target refuses the selection.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionEvaluatorTests.EvaluatorRefusesAnEdgeOutsideItsDeclaredTarget' - Old = 'throw new CultNetSelectionReferenceOutsideTargetException(from.Descriptor.SchemaId, from.Key.Value, role, to.Descriptor.SchemaId, to.Key.Value);' - New = 'return;' - }, - @{ - # S2-3 (docs/cultnet-selection-cut.md, Self's rulings 2026-09-22, commit 2 fix batch): - # CreateShardSnapshotResponse no longer carries its own schema/key filter at all - it went - # through CultNetSelectionEvaluator.SelectPage, with the shard's own row filter as the only - # thing this method still owns. NET-D4-FourthMatcher-Revert's original anchor - # ("requestedSchemaIds != null && !CultNetSchemaAliasMatching.MatchesAny(...)") was the private - # loop this fix batch deleted, not merely refactored; the schema-matching mutants it proved are - # now covered by this file's CultNetSelectionEvaluator.cs entries (NET-S1/S2 etc.) plus - # tests/GameCult.Networking.Tests.NetworkingTests.CultNetDatabase_ShardAndNonShardSnapshot_*. - # This entry now proves the one thing CreateShardSnapshotResponse still owns: the shard - # membership check. - Id = 'NET-D4-ShardMembership-Revert' - Rule = 'CreateShardSnapshotResponse''s row filter still enforces shard membership (shard.Matches), even though schema/key filtering is now entirely the evaluator''s.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetDatabase.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.NetworkingTests.CultNetDatabase_ShardAndNonShardSnapshot_AgreeOnUnfilteredRequest' - Old = '!string.IsNullOrWhiteSpace(key.Value) && shard.Matches(descriptor.SchemaId, key);' - New = '!string.IsNullOrWhiteSpace(key.Value);' - } - # - # Q-J (docs/cultnet-selection-cut.md section 2 "Numbers", 2026-09-22): the door's canonical-decimal - # grammar (CultNetSelection.cs) and the comparator that reads it (CultNetSelectionEvaluator.cs's - # CompareNumber, via CultNetCanonicalNumber.Compare). CultNetCanonicalNumberTests pins Compare - # directly with more cases than the entries below exercise; every entry here is one the map named. - @{ - Id = 'NET-QJ-Door-Regex-Revert' - Rule = 'Q-J: the door refuses a non-canonical number spelling (+1, 1.0, 01, 1e3) rather than accepting it.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName~CultNetSelectionEvaluatorTests.ValidationRefusesNonCanonicalNumberSpellings' - Old = 'if (!CultNetCanonicalNumber.IsCanonical(field.Number))' - New = 'if (false)' - }, - @{ - Id = 'NET-QJ-Door-NegativeZero-Revert' - Rule = 'Q-J: "-0" is excluded even though the regex alone matches it - IsCanonical checks it explicitly.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName~CultNetSelectionEvaluatorTests.ValidationRefusesNonCanonicalNumberSpellings' - Old = 'value != null && value != "-0" && CanonicalRegex.IsMatch(value);' - New = 'value != null && CanonicalRegex.IsMatch(value);' - }, - @{ - Id = 'NET-QJ-Compare-IntegerLength-Revert' - Rule = 'Q-J: the comparator checks the integer part''s length before its digits - "100" > "99" even though ''1'' < ''9'' as a bare character.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetCanonicalNumberTests.CompareOrdersByIntegerPartLengthBeforeDigits' - Old = " if (integerLeft.Length != integerRight.Length)`n return sign * (integerLeft.Length < integerRight.Length ? -1 : 1);`n`n" - New = '' - }, - @{ - Id = 'NET-QJ-Compare-Lexicographic-Revert' - Rule = 'Q-J: the comparator is not a lexicographic compare of the whole string ("10" must not be less than "9").' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetCanonicalNumberTests.CompareOrdersByMagnitudeNotLexicographically' - Old = 'var (negativeLeft, integerLeft, fractionLeft) = Decompose(left);' - New = 'return string.CompareOrdinal(left, right); var (negativeLeft, integerLeft, fractionLeft) = Decompose(left);' - }, - @{ - Id = 'NET-QJ-Compare-Sign-Revert' - Rule = 'Q-J: the comparator orders a negative value below a positive one of the same magnitude.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetCanonicalNumberTests.CompareOrdersNegativeBelowPositive' - Old = 'if (negativeLeft != negativeRight)' - New = 'if (false)' - }, - # - # Cut 1 fix batch, second Hands pass (docs/cultnet-selection-cut.md, "Not done, sent to a second - # Hands"): mutation entries for the C# rules R-A/B/C/D/E/F/G/H/J/L the first pass (7903853..3d32c67) - # fixed but proved only by regression tests, plus S9 (D6) which had no test at all. Killers below are - # tests/GameCult.Networking.Tests.CultNetSelectionFixBatchTests.cs (new file, this pass), - # NetworkingTests.cs (two new RUDP round-trip tests, this pass) and the pre-existing - # SelectionParityVectorTests.cs / CultNetSelectionPageTests.cs where those already pin the rule. - # - @{ - # R-A: both C# servers register v1 listeners. Revert = unregister the subscription server's, - # which S9's own test also depends on - if this listener is gone, that test's subscribe message - # is never answered at all and the test times out. - Id = 'NET-RA-SubscribeListener-Revert' - Rule = 'R-A: CultNetDatabaseSubscriptionServer registers a v1 subscribe listener, not only a v0 one.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetDatabaseSubscriptionServer.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.NetworkingTests.DatabaseSubscriptionServer_SubscribesV1AndReconcilesAHopBearingSelectionWhenTheCiterChanges' - Old = '_server.OnCultNet(_subscribeV1);' - New = '' - }, - # NET-RA-SnapshotListener-Revert (unregistering CultNetDatabaseServer's v1 snapshot listener) is not - # here: CultNetDatabaseServer pairs only with Server (the LiteNetLib/TCP-secured production - # construction site), and no existing test in this suite drives Server's real client/listener - # dispatch for CultNetDatabaseServer at all - every existing test (this pass's included) calls - # CreateSelectionResponse/CreateSnapshotResponse directly. A revert of that OnCultNet registration - # line is therefore not yet reached by this suite - a real gap in wire-level coverage for the - # snapshot path, not a fixture-tunable one; the subscription server's equivalent registration is - # covered below (NET-RA-SubscribeListener-Revert) because CultNetDatabaseSubscriptionServer does - # accept RudpCultNetSchemaServer and this pass's S9 test drives it over the real wire. - @{ - # Loosening: a v1 request is answered, but through a selection quietly lowered to v0's two - # allowlists - fields/cites/cited/projection silently dropped instead of honoured, the exact - # "answers v1 through v0 lowering" shortcut R-A rules out. - Id = 'NET-RA-Snapshot-V0Lowering-Loosening' - Rule = 'R-A: a v1 snapshot request is answered against its own full Selection, not a v0-shaped lowering that drops fields/cites/cited/projection.' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetDatabaseServer.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.NetworkingTests.CultNetDatabaseServer_AnswersV1SnapshotRequestRespectingItsFields' - Old = ' request.Selection, - ordinalOf: (schemaId, key) => _database.LastWriteSequence(schemaId, key) ?? 0,' - New = ' new CultNetSelection { Schemas = request.Selection.Schemas, Keys = request.Selection.Keys }, - ordinalOf: (schemaId, key) => _database.LastWriteSequence(schemaId, key) ?? 0,' - }, - @{ - # S9/D6: a hop-bearing selection must run the full reconcile diff on every change, not the - # single-row fast path - a change to the citer (not the page row itself) must still surface. - Id = 'NET-S9-HopFastPath-Revert' - Rule = 'D6/S9: Watch routes a hop-bearing selection to Reconcile on every change; it must not fall through to the single-row fast path.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetDatabaseSubscriptionServer.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.NetworkingTests.DatabaseSubscriptionServer_SubscribesV1AndReconcilesAHopBearingSelectionWhenTheCiterChanges' - Old = ' // D6: cites/cited are set-dependent - a change to row B can change whether row A - // matches - so a hop-bearing selection runs the full diff-against-delivered - // reconcile on every change instead of the single-row fast path. - if (request.Selection.HasHop) - { - Reconcile(key, request); - return; - } -' - New = '' - }, - @{ - # R-B: edges are anchored to the row the hop direction actually reports against, not always to - # the citer - the pre-fix bug filtered every edge by "is the citer (From) on the page", even - # under `cited`, where the page rows are the cited (To) rows. - Id = 'NET-RB-CitedAnchor-Revert' - Rule = 'R-B: a cited edge is anchored to the cited row (To), not the citer (From) - the direction-blind pre-fix anchor.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_AnchorsCitedEdgesToTheCitedRowAndOrdersThemByFromThenRole' - Old = 'foreach (var edge in citedEdges) edges.Add((edge, edge.To));' - New = 'foreach (var edge in citedEdges) edges.Add((edge, edge.From));' - }, - @{ - # R-B loosening: the order rule is page-row order then (from, role, to) in code-point order - - # dropping the (from, role, to) tie-break still groups edges by their anchor row correctly (a - # plausible partial fix) but no longer orders two edges anchored to the same row. - Id = 'NET-RB-EdgeOrder-Loosening' - Rule = 'R-B: two edges anchored to the same page row are ordered by (from, role, to) in code-point order, not left in row-supply order.' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_AnchorsCitedEdgesToTheCitedRowAndOrdersThemByFromThenRole' - Old = ' return full.Edges - .Where(pair => pageRowIndex.ContainsKey(pair.Anchor.Key.Value)) - .OrderBy(pair => pageRowIndex[pair.Anchor.Key.Value]) - .ThenBy(pair => pair.Edge.From.Descriptor.SchemaId, CultNetCodePointComparer.Instance) - .ThenBy(pair => pair.Edge.From.Key.Value, CultNetCodePointComparer.Instance) - .ThenBy(pair => pair.Edge.Role, CultNetCodePointComparer.Instance) - .ThenBy(pair => pair.Edge.To.Descriptor.SchemaId, CultNetCodePointComparer.Instance) - .ThenBy(pair => pair.Edge.To.Key.Value, CultNetCodePointComparer.Instance) - .Select(pair => pair.Edge) - .ToArray();' - New = ' return full.Edges - .Where(pair => pageRowIndex.ContainsKey(pair.Anchor.Key.Value)) - .OrderBy(pair => pageRowIndex[pair.Anchor.Key.Value]) - .Select(pair => pair.Edge) - .ToArray();' - }, - @{ - # R-C: the row tiebreak (schemaId, then key) uses code-point order everywhere, not UTF-16 - # code-unit ("ordinal") order - the two disagree on astral-vs-BMP key comparisons. - Id = 'NET-RC-RowTiebreak-Revert' - Rule = 'R-C: the ascending row tiebreak compares the record key by code-point order (CultNetCodePointComparer), not UTF-16 code-unit order.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_OrdersAstralKeysByCodePointNotUtf16CodeUnit' - Old = 'matched.OrderBy(row => row.Ordinal).ThenBy(row => row.Descriptor.SchemaId, CultNetCodePointComparer.Instance).ThenBy(row => row.Key.Value, CultNetCodePointComparer.Instance))' - New = 'matched.OrderBy(row => row.Ordinal).ThenBy(row => row.Descriptor.SchemaId, CultNetCodePointComparer.Instance).ThenBy(row => row.Key.Value, StringComparer.Ordinal))' - }, - @{ - # R-C loosening: the row order itself is fixed (kills the revert above), but the cursor position - # search still compares by UTF-16 code-unit order - a plausible partial fix that forgets the - # cursor half, which desyncs a page walk over an astral/BMP key boundary. - Id = 'NET-RC-CursorPosition-Loosening' - Rule = 'R-C: the cursor position compare uses code-point order matching the row tiebreak, not UTF-16 code-unit order.' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_CursorPositionUsesCodePointOrderMatchingTheRowTiebreak' - Old = 'var schema = CultNetCodePointComparer.Instance.Compare(row.Descriptor.SchemaId, cursor.SchemaId); - return schema != 0 ? schema : CultNetCodePointComparer.Instance.Compare(row.Key.Value, cursor.RecordKey);' - New = 'var schema = string.CompareOrdinal(row.Descriptor.SchemaId, cursor.SchemaId); - return schema != 0 ? schema : string.CompareOrdinal(row.Key.Value, cursor.RecordKey);' - }, - @{ - # R-E: cites.target.schemaId is matched through the alias matcher, same as `schemas` - not an - # exact SchemaId string compare a schema alias could never satisfy. - Id = 'NET-RE-AliasMatcher-Revert' - Rule = 'R-E: MatchesCitation compares a cites target through CultNetSchemaAliasMatching, not an exact SchemaId string compare.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_MatchesCitesTargetThroughTheAliasMatcher' - Old = 'if (!CultNetSchemaAliasMatching.Matches(citation.Target.SchemaId, resolved.Descriptor))' - New = 'if (resolved.Descriptor.SchemaId != citation.Target.SchemaId)' - }, - @{ - # R-E: an unmatched cites.target.schemaId is refused at the door (this pass added the check - - # docs/cultnet-selection-cut.md named it but the first fix-batch pass never wrote it), never - # answered with a silently empty page by MatchesCitation's own "not found" continue. - Id = 'NET-RE-DoorRefusesUnmatchedTarget-Revert' - Rule = 'R-E: Validate refuses a cites.target.schemaId that matches no declared schema.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Validation_RefusesACitesTargetSchemaThatMatchesNoDeclaredSchema' - Old = 'if (!allDescriptors.Any(descriptor => CultNetSchemaAliasMatching.Matches(selection.Cites.Target!.SchemaId, descriptor))) - throw new CultNetSelectionInvalidException("cites.target.schemaId", selection.Cites.Target!.SchemaId, $"selection.cites.target.schemaId \"{selection.Cites.Target!.SchemaId}\" does not match any declared schema.");' - New = '' - }, - @{ - # R-E loosening: the door reuses `reachable` (Fields validation's own Schemas-filtered set) - # instead of the full declared-schema set - a cites target is a separate structural reference, - # not itself constrained by the selection's own Schemas allowlist, so this wrongly refuses a - # valid target whose schema sits outside that filter. - Id = 'NET-RE-DoorTargetReachableOnly-Loosening' - Rule = 'R-E: the door resolves cites.target.schemaId against every declared schema, not only the selection''s own Schemas-filtered reachable set.' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetSelection.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Validation_ResolvesACitesTargetSchemaEvenWhenNotInTheSelectionsOwnSchemasFilter' - Old = 'if (!allDescriptors.Any(descriptor => CultNetSchemaAliasMatching.Matches(selection.Cites.Target!.SchemaId, descriptor)))' - New = 'if (!reachable.Any(descriptor => CultNetSchemaAliasMatching.Matches(selection.Cites.Target!.SchemaId, descriptor)))' - }, - @{ - # R-F: the door is inside Select/EvaluateAll unconditionally - the pre-fix code took a - # validate:true/false flag that let a caller skip it. - Id = 'NET-RF-DoorInsideSelect-Revert' - Rule = 'R-F: EvaluateAll validates the selection before matching anything - no public evaluation path can skip the door.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_SelectValidatesFirstAndNeverAnswersAnInvalidSelection' - Old = 'selection.Validate(registry.AllDescriptors.ToArray());' - New = '' - }, - @{ - # R-G: SelectPage/Page reports the selection''s whole matching count (TotalMatched), not the - # page''s own row count (C5). Already regression-tested by CultNetSelectionPageTests; this entry - # is that rule''s mutation coverage. - Id = 'NET-RG-TotalMatched-Revert' - Rule = 'R-G/C5: Evaluation.TotalMatched is the selection''s whole matching count, not this page''s row count.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionPageTests.CreateSelectionResponse_ReportsTotalMatchedNotPageLength' - Old = 'return new Evaluation { Rows = page, Edges = pageEdges, NextCursor = nextCursor, TotalMatched = ordered.Count };' - New = 'return new Evaluation { Rows = page, Edges = pageEdges, NextCursor = nextCursor, TotalMatched = page.Length };' - }, - @{ - # R-H: every string and list in the cursor digest is length-prefixed, closing the delimiter- - # ambiguous collisions Soul named (Keys=["a,b"] vs ["a","b"]; a field's Values=["a|b"] vs - # ["a","b"]). Revert reproduces a single-separator-joined digest (comma), which the keys half of - # the killer test catches; the loosening below reproduces the exact pipe-joined case Soul named, - # which only the field-values half catches. - Id = 'NET-RH-Digest-CommaJoin-Revert' - Rule = 'R-H: AppendList length-prefixes each entry and the list itself, rather than joining entries with one separator that can appear inside an entry.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.ComputeDigest_DoesNotCollideOnDelimiterAmbiguousKeysOrFieldValues' - Old = ' var ordered = (values ?? Array.Empty()).OrderBy(v => v, CultNetCodePointComparer.Instance).ToArray(); - sb.Append(ordered.Length).Append('':''); - foreach (var value in ordered) - AppendString(sb, value);' - New = ' sb.Append(string.Join(",", (values ?? Array.Empty()).OrderBy(v => v, CultNetCodePointComparer.Instance)));' - }, - @{ - Id = 'NET-RH-Digest-PipeJoin-Loosening' - Rule = 'R-H: the exact collision Soul named - a separator-joined digest using "|" still collides Values=["a|b"] with Values=["a","b"].' - Mutant = 'loosening' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.ComputeDigest_DoesNotCollideOnDelimiterAmbiguousKeysOrFieldValues' - Old = ' var ordered = (values ?? Array.Empty()).OrderBy(v => v, CultNetCodePointComparer.Instance).ToArray(); - sb.Append(ordered.Length).Append('':''); - foreach (var value in ordered) - AppendString(sb, value);' - New = ' sb.Append(string.Join("|", (values ?? Array.Empty()).OrderBy(v => v, CultNetCodePointComparer.Instance)));' - }, - @{ - # R-J: any_of on a numeric alias compares TryGetIndexNumber's canonical rendering, not the - # string getter's culture-dependent ToString() (which renders exponent notation for a large - # float, never matching the canonical decimal form a caller would send). - Id = 'NET-RJ-NumericAnyOf-Revert' - Rule = 'R-J: any_of on a numeric alias compares the canonical rendering (TryGetIndexNumber), not the raw string getter.' - Mutant = 'revert' - File = 'src/GameCult.Networking/CultNetSelectionEvaluator.cs' - Killer = 'FullyQualifiedName=GameCult.Networking.Tests.CultNetSelectionFixBatchTests.Evaluator_AnyOfOnANumericAliasComparesTheCanonicalRenderingNotToString' - Old = ' var isNumeric = descriptor.DeclaredMembers.Any(member => member.IndexAlias == field.Index && member.IsNumeric); - var value = isNumeric - ? (descriptor.TryGetIndexNumber(document, field.Index, out var numeric) ? numeric : null) - : (descriptor.TryGetIndexValue(document, field.Index, out var raw) ? raw : null);' - New = ' var value = descriptor.TryGetIndexValue(document, field.Index, out var raw) ? raw : null;' - } -) diff --git a/scripts/mutate-dotnet.ps1 b/scripts/mutate-dotnet.ps1 deleted file mode 100644 index 1ccfd9bf..00000000 --- a/scripts/mutate-dotnet.ps1 +++ /dev/null @@ -1,230 +0,0 @@ -# Generic mutation runner for dotnet/NUnit suites - the CultNet selection campaign's counterpart to -# tools/eureka-mutations.ps1, whose Invoke-Cargo parses `cargo test` output and appends `-- --exact -# `, and is therefore not usable against `dotnet test`. This is not scripts/mutate-cultmesh.mjs -# either - that file is the QUIC campaign's, live and dirty in this tree, and per -# docs/cultnet-selection-cut.md section 10 this campaign adds its entries in its own file rather than -# editing the QUIC campaign's targets. -# -# One copy serves every dotnet target in this campaign (and, once proven out, any future one): pass -# -Target, -TestProject and -Entries. Same discipline as the cargo harness: every entry is a byte-exact -# splice against one anchor that must match exactly once, restored from the original bytes (never from -# git) with a SHA-256 check per target, a sidecar (.mutation-original) protects a hard kill -# mid-mutation, and M0 proves the read/write path round-trips and the unmutated suite is green before -# any entry runs. -# -# powershell -File scripts/mutate-dotnet.ps1 ` -# -Target src\GameCult.Caching\CultCache.cs ` -# -TestProject tests\GameCult.Caching.Tests\GameCult.Caching.Tests.csproj ` -# -Entries scripts\mutate-cultnet-selection-caching.entries.ps1 ` -# -ControlFilter 'FullyQualifiedName~CultDocumentSelectionSurfaceTests' -# -# -Target one or more files entries mutate, relative to the repo root. An entry with no `File` -# uses the sole target; an entry with more than one target names each edit's `File`. -# -TestProject the .csproj `dotnet test` runs. One project per invocation; entries needing another -# project are a separate run (as networking and caching already are). -# -Entries a .ps1 that returns an array of `@{ Id; Rule; Mutant; Killer; Old; New; File? }` (or -# `Edits = @(@{ File; Old; New }, ...)` for a multi-file entry). `Killer` is the -# `dotnet test --filter` value for the one test that must fail under this mutant. -# -ControlFilter the `dotnet test --filter` M0 runs to prove the suite is green unmutated. Defaults to -# running the whole project. -# -Repo repo root -Target/-TestProject/-Entries are relative to. Defaults to this script's -# parent's parent (scripts/..). -# -# Exit code: 0 when every entry's mutant was KILLED, non-zero otherwise (SURVIVED or NO VERDICT). - -param( - [Parameter(Mandatory = $true)] [string[]] $Target, - [Parameter(Mandatory = $true)] [string] $TestProject, - [Parameter(Mandatory = $true)] [string] $Entries, - [string] $ControlFilter, - [string] $Repo -) - -$ErrorActionPreference = 'Stop' - -# R-L: an entry's `File` (from -Entries, often written with forward slashes) is looked up against the -# $targets dictionary keyed by -Target's own spelling. A bare string-key mismatch ("a\b.cs" vs -# "a/b.cs") doesn't throw at the lookup - $targets[$file] just silently returns $null - so the crash -# happens one call later, deep inside a .NET path/string API, as a null-argument error that reads -# nothing like "unknown target". Normalizing both sides to '/' up front turns that into either a -# clean match or an honest "Target ... does not exist" at line 99, never a null-argument surprise. -function Normalize-TargetPath([string]$path) { $path -replace '\\', '/' } -$Target = @($Target | ForEach-Object { Normalize-TargetPath $_ }) - -$repo = if ($Repo) { (Resolve-Path -LiteralPath $Repo).Path } else { (Resolve-Path (Join-Path $PSScriptRoot '..')).Path } -$testProjectPath = Join-Path $repo $TestProject -$utf8 = [System.Text.UTF8Encoding]::new($false) - -function Read-Bytes([string]$path) { [System.IO.File]::ReadAllBytes($path) } -function Get-BytesHash([byte[]]$bytes) { - ([System.Security.Cryptography.SHA256]::Create().ComputeHash($bytes) | ForEach-Object { $_.ToString('x2') }) -join '' -} -function Write-Text([string]$path, [string]$text) { - [System.IO.File]::WriteAllBytes($path, [byte[]]($utf8.GetPreamble() + $utf8.GetBytes($text))) -} -function Get-SidecarPath([string]$path) { "$path.mutation-original" } - -function Run-Tests([string]$filter) { - $args = @('test', $testProjectPath, '-c', 'Debug', '--nologo') - if ($filter) { $args += @('--filter', $filter) } - # A test-host crash (e.g. S2-1's disposed-socket race on a background poll thread) can write to - # stderr; under PowerShell 5.1, `2>&1` on a native command wraps each stderr line in a - # NativeCommandError, and with the script's own $ErrorActionPreference = 'Stop' that becomes a - # terminating error that would otherwise throw the whole run away. Run this one call under - # 'Continue' and catch anything that still throws, so a host crash is captured as output and - # classified as NO VERDICT by the caller instead of aborting every remaining entry. - $previousPreference = $ErrorActionPreference - $ErrorActionPreference = 'Continue' - $crashed = $false - try { - $output = & dotnet @args 2>&1 | Out-String - } - catch { - $output = "$_" - $crashed = $true - } - finally { - $ErrorActionPreference = $previousPreference - } - Write-Host $output - $passedMatch = [regex]::Match($output, 'Passed:\s+(\d+)') - $failedMatch = [regex]::Match($output, 'Failed:\s+(\d+)') - $compiled = -not ($output -match 'error CS\d+') - $passedLine = $output -match 'Passed!' - $failedLine = $output -match 'Failed!' - [pscustomobject]@{ - Compiled = $compiled - Crashed = $crashed - Green = (-not $crashed) -and $compiled -and $passedLine -and -not $failedLine -and $passedMatch.Success -and [int]$passedMatch.Groups[1].Value -ge 1 - Passed = if ($passedMatch.Success) { [int]$passedMatch.Groups[1].Value } else { 0 } - Failed = if ($failedMatch.Success) { [int]$failedMatch.Groups[1].Value } else { 0 } - } -} - -$targets = @{} -foreach ($file in $Target) { - $path = Join-Path $repo $file - if (-not (Test-Path -LiteralPath $path)) { throw "Target $file does not exist." } - $targets[$file] = $path -} - -# --- Repair a run that died mid-mutation, for every target ------------------- - -foreach ($file in $Target) { - $sidecar = Get-SidecarPath $targets[$file] - if (Test-Path -LiteralPath $sidecar) { - $original = Read-Bytes $sidecar - [System.IO.File]::WriteAllBytes($targets[$file], $original) - Remove-Item -LiteralPath $sidecar -Force - Write-Host "Repaired: a previous run left $sidecar; $($targets[$file]) restored from it and the sidecar removed." - } -} - -# --- M0: no-op control, every target ----------------------------------------- - -Write-Host '--- M0: no-op control' -$originalBytes = @{} -$originalHash = @{} -foreach ($file in $Target) { - $path = $targets[$file] - $bytes = Read-Bytes $path - $hash = Get-BytesHash $bytes - $text = $utf8.GetString($bytes) - $reencoded = [byte[]]($utf8.GetPreamble() + $utf8.GetBytes($text)) - if ((Get-BytesHash $reencoded) -ne $hash) { - throw "harness broken: $file does not round-trip through the UTF-8 read/write path byte for byte. Nothing was written and no entry ran." - } - $sidecar = Get-SidecarPath $path - [System.IO.File]::WriteAllBytes($sidecar, $bytes) - try { - Write-Text $path $text - if ((Get-BytesHash (Read-Bytes $path)) -ne $hash) { - throw "harness broken: writing $file back through the harness path changed its bytes." - } - } - finally { - [System.IO.File]::WriteAllBytes($path, $bytes) - if ((Get-BytesHash (Read-Bytes $path)) -ne $hash) { throw "RESTORE FAILED after M0 for $file; original SHA-256 $hash is kept in $sidecar." } - Remove-Item -LiteralPath $sidecar -Force - } - $originalBytes[$file] = $bytes - $originalHash[$file] = $hash - Write-Host "M0: $file decoded, re-encoded and rewritten, bytes unchanged (SHA-256 $hash)" -} -$control = Run-Tests $ControlFilter -if (-not $control.Green) { - throw "harness broken: the suite is not green unmutated (compiled=$($control.Compiled) passed=$($control.Passed) failed=$($control.Failed)). No entry ran." -} -Write-Host "M0: green, $($control.Passed) passed" - -# --- Load entries -------------------------------------------------------------- - -$entriesPath = Join-Path $repo $Entries -$mutations = & $entriesPath -if (-not $mutations -or @($mutations).Count -lt 1) { throw "$Entries`: no mutations." } - -# --- Entries ----------------------------------------------------------------- - -$exitCode = 0 -foreach ($mutation in $mutations) { - if (-not $mutation.Id) { throw 'An entry has no Id.' } - if (-not $mutation.Killer) { throw "$($mutation.Id): no Killer." } - $edits = if ($mutation.ContainsKey('Edits')) { @($mutation.Edits) } else { @(@{ File = $mutation.File; Old = $mutation.Old; New = $mutation.New }) } - if ($edits.Count -lt 1) { throw "$($mutation.Id): no edits." } - - Write-Host "--- $($mutation.Id) ($($mutation.Mutant)): $($mutation.Rule)" - $texts = @{} - $files = @($edits | ForEach-Object { if ($_.File) { Normalize-TargetPath $_.File } elseif ($Target.Count -eq 1) { $Target[0] } else { throw "$($mutation.Id): an edit names no File and there is more than one target." } } | Select-Object -Unique) - foreach ($file in $files) { $texts[$file] = $utf8.GetString($originalBytes[$file]) } - - foreach ($edit in $edits) { - $file = if ($edit.File) { Normalize-TargetPath $edit.File } else { $Target[0] } - $text = $texts[$file] - $eol = if ($text.Contains("`r`n")) { "`r`n" } else { "`n" } - $old = ($edit.Old -replace "`r`n", "`n") - $normalized = $text -replace "`r`n", "`n" - $count = 0 - $at = $normalized.IndexOf($old, [System.StringComparison]::Ordinal) - while ($at -ge 0) { $count++; $at = $normalized.IndexOf($old, $at + 1, [System.StringComparison]::Ordinal) } - if ($count -ne 1) { throw "$($mutation.Id): anchor matches $count times in $file, expected exactly 1." } - $newValue = if ($null -ne $edit.New) { $edit.New } else { '' } - $mutatedNormalized = $normalized.Replace($old, ($newValue -replace "`r`n", "`n")) - $texts[$file] = $mutatedNormalized -replace "`n", $eol - } - - foreach ($file in $files) { [System.IO.File]::WriteAllBytes((Get-SidecarPath $targets[$file]), $originalBytes[$file]) } - $verdict = 'NO VERDICT' - try { - foreach ($file in $files) { Write-Text $targets[$file] $texts[$file] } - $run = Run-Tests $mutation.Killer - if ($run.Crashed) { $verdict = 'NO VERDICT (test host crashed)' } - elseif (-not $run.Compiled) { $verdict = 'NO VERDICT (did not compile)' } - elseif ($run.Failed -ge 1) { $verdict = 'KILLED' } - else { $verdict = 'SURVIVED' } - } - catch { - # Not yet reached by Run-Tests itself (it no longer throws on a host crash), but a defensive - # backstop: any other exception during this entry's run is recorded and the campaign continues - # rather than aborting every remaining entry, never labeled "unreachable". - Write-Host "NO VERDICT: $($mutation.Id) - test run threw: $_" - $verdict = 'NO VERDICT (harness exception)' - } - finally { - foreach ($file in $files) { - [System.IO.File]::WriteAllBytes($targets[$file], $originalBytes[$file]) - if ((Get-BytesHash (Read-Bytes $targets[$file])) -ne $originalHash[$file]) { - Write-Host "RESTORE FAILED: $($targets[$file]) not restored; original SHA-256 $($originalHash[$file]) kept in $(Get-SidecarPath $targets[$file])." - throw "restore failed for $($mutation.Id)" - } - Remove-Item -LiteralPath (Get-SidecarPath $targets[$file]) -Force - } - } - Write-Host "$($mutation.Id): $verdict" - if ($verdict -ne 'KILLED') { $exitCode = 1 } -} - -$final = Run-Tests $ControlFilter -if (-not $final.Green) { throw "post-run sanity check: the suite is not green after restore (passed=$($final.Passed) failed=$($final.Failed))." } -Write-Host "Final: green, $($final.Passed) passed" - -exit $exitCode