73 lines
2.9 KiB
C#
73 lines
2.9 KiB
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace AcDream.App.Tests.World;
|
|
|
|
/// <summary>
|
|
/// The create-authority drift probes in the expectation-item 6/8 tests
|
|
/// (LiveEntityHydrationControllerTests + LiveEntityCreateSupersessionRecoveryTests)
|
|
/// hand-call <c>record.Canonical.AdvanceCreateAuthority()</c> as an HONEST
|
|
/// MODEL of the executor drain's advance — the SOLE remaining production
|
|
/// site that advances create authority for an existing incarnation. A
|
|
/// nested production OnCreate can no longer produce that drift:
|
|
/// post-residence ExistingGeneration registration is description-only
|
|
/// (RuntimeEntityObjectLifetime gates the advance on
|
|
/// <c>!beginInitialResidence</c>) and <c>ConsumeExecuted</c> removes the
|
|
/// completed residence entry at Released, closing the FIFO-adoption path
|
|
/// (empirically confirmed: the restored nested-OnCreate probe produced no
|
|
/// drift and no CreateSupersessionRecovery). This pin flags the model as
|
|
/// STALE if the production site ever moves or loses the advance — the
|
|
/// item 6/8 probes must be re-derived from wherever it goes.
|
|
/// </summary>
|
|
public sealed class CreateAuthorityDriftModelSourcePinTests
|
|
{
|
|
[Fact]
|
|
public void HandCalledDriftProbe_StillModelsTheExecutorDrainAdvance()
|
|
{
|
|
string executor = ReadRuntimeSource(
|
|
"Entities",
|
|
"RuntimeInitialCreateContinuationExecutor.cs");
|
|
|
|
// Exactly one production advance, and it lives inside the
|
|
// WeenieDescription drain stage the probes model.
|
|
Assert.Single(
|
|
Regex.Matches(executor, @"_entities\.AdvanceCreateAuthority\(")
|
|
.Cast<Match>());
|
|
Assert.Matches(
|
|
new Regex(
|
|
@"private bool ApplyWeenieDescriptionAction[\s\S]{0,6000}?"
|
|
+ @"_entities\.AdvanceCreateAuthority\(canonical\);"),
|
|
executor);
|
|
|
|
// The registration-time advance stays gated OFF the residence
|
|
// route — the reason a nested production OnCreate cannot reach the
|
|
// modeled drift.
|
|
string lifetime = ReadRuntimeSource(
|
|
"Entities",
|
|
"RuntimeEntityObjectLifetime.cs");
|
|
Assert.Matches(
|
|
new Regex(
|
|
@"if \(!beginInitialResidence\)\s*"
|
|
+ @"Entities\.AdvanceCreateAuthority\(retained\);"),
|
|
lifetime);
|
|
}
|
|
|
|
private static string ReadRuntimeSource(params string[] relativePath)
|
|
{
|
|
DirectoryInfo? directory = new(AppContext.BaseDirectory);
|
|
while (directory is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(directory.FullName, "AcDream.slnx")))
|
|
{
|
|
return File.ReadAllText(Path.Combine(
|
|
directory.FullName,
|
|
"src",
|
|
"AcDream.Runtime",
|
|
Path.Combine(relativePath)));
|
|
}
|
|
|
|
directory = directory.Parent;
|
|
}
|
|
|
|
throw new DirectoryNotFoundException("Could not find AcDream.slnx.");
|
|
}
|
|
}
|