feat(runtime): define borrowed views commands and ordered events
Establish the J1 presentation-independent contract with instance-scoped clocks and generations, immutable borrowed views, typed generation-gated commands, normalized ordered diagnostics, and teardown acknowledgements. Route graphical startup plus press-time selection, movement, and combat through focused App adapters over the exact existing owners without adding a queue or mirrored world. Validated by the Release solution build, 13 Runtime tests, 3,838 App tests with three existing skips, and the complete 8,424-test Release suite with five existing skips. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
afebbe3eca
commit
854d9e9cd1
21 changed files with 2594 additions and 44 deletions
62
src/AcDream.Runtime/RuntimeGeneration.cs
Normal file
62
src/AcDream.Runtime/RuntimeGeneration.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
namespace AcDream.Runtime;
|
||||
|
||||
/// <summary>
|
||||
/// Identifies one exact client-session generation. Default is the
|
||||
/// pre-session generation and remains a valid compare token.
|
||||
/// </summary>
|
||||
public readonly record struct RuntimeGenerationToken(ulong Value)
|
||||
{
|
||||
public static RuntimeGenerationToken Initial => default;
|
||||
|
||||
public RuntimeGenerationToken Next() => new(checked(Value + 1UL));
|
||||
|
||||
public override string ToString() => Value.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public enum RuntimeLifecycleState
|
||||
{
|
||||
Constructed,
|
||||
Stopped,
|
||||
Starting,
|
||||
InWorld,
|
||||
Stopping,
|
||||
Faulted,
|
||||
Disposed,
|
||||
}
|
||||
|
||||
public readonly record struct RuntimeLifecycleSnapshot(
|
||||
RuntimeGenerationToken Generation,
|
||||
RuntimeLifecycleState State,
|
||||
uint PlayerGuid,
|
||||
bool HasTransport);
|
||||
|
||||
[Flags]
|
||||
public enum RuntimeTeardownStage
|
||||
{
|
||||
None = 0,
|
||||
CommandsInert = 1 << 0,
|
||||
InboundDetached = 1 << 1,
|
||||
TransportDisposed = 1 << 2,
|
||||
HostReset = 1 << 3,
|
||||
Complete = CommandsInert | InboundDetached | TransportDisposed | HostReset,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A generation-scoped acknowledgement. A caller may retry only the missing
|
||||
/// suffix; completed teardown stages never replay.
|
||||
/// </summary>
|
||||
public readonly record struct RuntimeTeardownAcknowledgement(
|
||||
RuntimeGenerationToken RetiredGeneration,
|
||||
RuntimeGenerationToken CurrentGeneration,
|
||||
RuntimeCommandStatus Status,
|
||||
RuntimeTeardownStage CompletedStages,
|
||||
Exception? Error = null)
|
||||
{
|
||||
public bool IsComplete =>
|
||||
Status == RuntimeCommandStatus.Accepted
|
||||
&&
|
||||
(CompletedStages & RuntimeTeardownStage.Complete)
|
||||
== RuntimeTeardownStage.Complete
|
||||
&& Error is null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue