feat(runtime): first-entry conductor sequences local-player world entry

Cutover slice C3a: the resumable transaction that dissolves the C3
flip's circularity finding. RuntimeLocalPlayerFirstEntryState drives the
local player's complete entry in retail's own order — authored-mover
preparation (the makeObject/set_description shape analog, via a pure
no-submit extraction TryPrepareAuthoredMover), the publication chain's
off-canonical Prepare + atomic body Commit against the residence's exact
placement token, the Evaluate/CommitActivation enter-world analog, the
Place-receipt acknowledgement as that act's virtualized completion, and
only then the executor's FIFO drain (retail: enter_world at 93824
strictly precedes ProcessObjectNetBlobs at 93831). Five stages, eight
typed statuses, exactly-once per stage under retry, no second token
copies, and an acknowledge-stage discriminator that separates
not-yet-FIFO-head (retryable) from authority-moved (typed abandonment) —
a mid-flight delete can no longer strand a retry-forever entry.

The residence retirement notification becomes an ordered multicast
(snapshot-iterated per the event-stream precedent), the lifetime
constructs the conductor with a late-bind Publication seam (transactional
unbound failure — no mutation before the throw), deletion/reset converge
the conductor automatically through the same choke points as the
executor, and its active count is in the ownership snapshot and
IsConverged. Dormant: no production Advance caller; GameRuntime binding
is C3c's first act.

Reviewed: retail-conformance PASS (the stage order verified
step-for-step against retail's entry sequence; the live-controller-on-
abandonment invariant proven structurally enforced and retail-correct —
retail has no entry-flow rollback) + architecture/adversarial PASS after
one fix round (acknowledge-stage authority discrimination; the wiring
fold; two prescribed pre-C3c hardenings). Runtime 948/948; complete
Release solution green across all nine projects.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-02 09:43:15 +02:00
parent 874d94bf34
commit 960373df2e
6 changed files with 1816 additions and 29 deletions

View file

@ -4,6 +4,7 @@ using AcDream.Core.Items;
using AcDream.Core.Net;
using AcDream.Core.Net.Messages;
using AcDream.Core.Physics;
using AcDream.Runtime.Gameplay;
using AcDream.Runtime.Physics;
namespace AcDream.Runtime.Entities;
@ -56,7 +57,14 @@ public readonly record struct RuntimeEntityObjectOwnershipSnapshot(
/// SAME underlying receipt stream - unlike ReplayFailureCount above,
/// this is NOT a diagnostic-only counter.
/// </summary>
int PendingCompletionReceiptCount = 0)
int PendingCompletionReceiptCount = 0,
/// <summary>
/// C3a/F2: outstanding <c>AcDream.Runtime.Gameplay.RuntimeLocalPlayerFirstEntryState</c>
/// tracked keys - dormant (no production caller of its own
/// <c>Advance</c>), but fully constructed/wired like every other owner
/// here, so its own ownership must converge to zero the same way.
/// </summary>
int LocalPlayerFirstEntryActiveCount = 0)
{
public bool IsConverged =>
IsDisposed
@ -78,6 +86,7 @@ public readonly record struct RuntimeEntityObjectOwnershipSnapshot(
&& InitialCreateResidenceLeaseCount == 0
&& InitialCreateExecutorProgressCount == 0
&& PendingCompletionReceiptCount == 0
&& LocalPlayerFirstEntryActiveCount == 0
&& StreamSubscriberCount == 0
&& PlacementStreamSubscriberCount == 0
&& PendingDispatchCount == 0
@ -157,6 +166,16 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
RegisterEntityWithInitialResidence(spawn, isLocalPlayer),
(canonical, version, spawn, replaceGeneration) =>
ApplyAcceptedSpawn(canonical, version, spawn, replaceGeneration));
// C3a/F2: dormant - no production caller of its own Advance - but
// constructed and wired exactly like the executor above so its
// ownership converges the same way. RuntimeLocalPlayerPhysicsPublicationState
// does not exist yet at this point (GameRuntime builds
// RuntimeLocalPlayerMovementState, then attaches its publication,
// only after this lifetime); BindPublication supplies it later.
LocalPlayerFirstEntry = new RuntimeLocalPlayerFirstEntryState(
InitialCreateResidences,
InitialCreateExecution,
Physics);
// Round 3 B3: every residence retirement path - not only the
// executor's own DiscardProgress calls - must converge the
// executor's progress AND its separately-tracked pending
@ -165,6 +184,12 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
// residence state referencing the executor type directly.
InitialCreateResidences.BindRetirementNotification(
key => InitialCreateExecution.DiscardProgress(key));
// C3a/F2: the SAME multicast retirement notification also reaps the
// first-entry conductor's tracked progress - see
// RuntimeInitialCreateResidenceState.BindRetirementNotification's
// updated doc comment for why this is now multicast.
InitialCreateResidences.BindRetirementNotification(
key => LocalPlayerFirstEntry.Forget(key));
// F2: reaps the executor's completion-receipt correlation entry
// exactly when a host acknowledges the ExecutorCompleted receipt it
// correlates - mirrors the residence-retirement binding immediately
@ -210,6 +235,16 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
RegisterEntityWithInitialResidence(spawn, isLocalPlayer),
(canonical, version, spawn, replaceGeneration) =>
ApplyAcceptedSpawn(canonical, version, spawn, replaceGeneration));
// C3a/F2: dormant - no production caller of its own Advance - but
// constructed and wired exactly like the executor above so its
// ownership converges the same way. RuntimeLocalPlayerPhysicsPublicationState
// does not exist yet at this point (GameRuntime builds
// RuntimeLocalPlayerMovementState, then attaches its publication,
// only after this lifetime); BindPublication supplies it later.
LocalPlayerFirstEntry = new RuntimeLocalPlayerFirstEntryState(
InitialCreateResidences,
InitialCreateExecution,
Physics);
// Round 3 B3: every residence retirement path - not only the
// executor's own DiscardProgress calls - must converge the
// executor's progress AND its separately-tracked pending
@ -218,6 +253,12 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
// residence state referencing the executor type directly.
InitialCreateResidences.BindRetirementNotification(
key => InitialCreateExecution.DiscardProgress(key));
// C3a/F2: the SAME multicast retirement notification also reaps the
// first-entry conductor's tracked progress - see
// RuntimeInitialCreateResidenceState.BindRetirementNotification's
// updated doc comment for why this is now multicast.
InitialCreateResidences.BindRetirementNotification(
key => LocalPlayerFirstEntry.Forget(key));
// F2: reaps the executor's completion-receipt correlation entry
// exactly when a host acknowledges the ExecutorCompleted receipt it
// correlates - mirrors the residence-retirement binding immediately
@ -263,6 +304,16 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
RegisterEntityWithInitialResidence(spawn, isLocalPlayer),
(canonical, version, spawn, replaceGeneration) =>
ApplyAcceptedSpawn(canonical, version, spawn, replaceGeneration));
// C3a/F2: dormant - no production caller of its own Advance - but
// constructed and wired exactly like the executor above so its
// ownership converges the same way. RuntimeLocalPlayerPhysicsPublicationState
// does not exist yet at this point (GameRuntime builds
// RuntimeLocalPlayerMovementState, then attaches its publication,
// only after this lifetime); BindPublication supplies it later.
LocalPlayerFirstEntry = new RuntimeLocalPlayerFirstEntryState(
InitialCreateResidences,
InitialCreateExecution,
Physics);
// Round 3 B3: every residence retirement path - not only the
// executor's own DiscardProgress calls - must converge the
// executor's progress AND its separately-tracked pending
@ -271,6 +322,12 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
// residence state referencing the executor type directly.
InitialCreateResidences.BindRetirementNotification(
key => InitialCreateExecution.DiscardProgress(key));
// C3a/F2: the SAME multicast retirement notification also reaps the
// first-entry conductor's tracked progress - see
// RuntimeInitialCreateResidenceState.BindRetirementNotification's
// updated doc comment for why this is now multicast.
InitialCreateResidences.BindRetirementNotification(
key => LocalPlayerFirstEntry.Forget(key));
// F2: reaps the executor's completion-receipt correlation entry
// exactly when a host acknowledges the ExecutorCompleted receipt it
// correlates - mirrors the residence-retirement binding immediately
@ -295,6 +352,7 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
{ get; }
internal RuntimeInitialCreateContinuationExecutor InitialCreateExecution
{ get; }
internal RuntimeLocalPlayerFirstEntryState LocalPlayerFirstEntry { get; }
public RuntimeEntityObjectOwnershipSnapshot CaptureOwnership()
{
@ -330,7 +388,8 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
parents.DeferredAcceptedRelationCount,
InitialCreateExecution.ReplayFailureCount,
InitialCreateExecution.LastReplayFailure is not null,
InitialCreateExecution.PendingCompletionReceiptCount);
InitialCreateExecution.PendingCompletionReceiptCount,
LocalPlayerFirstEntry.CaptureOwnership().ActiveCount);
}
public void BindEventContext(
@ -1674,6 +1733,7 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
RuntimeEntityRecord[] active = Entities.ActiveRecords.ToArray();
InitialCreateResidences.Clear();
InitialCreateExecution.DiscardAll();
LocalPlayerFirstEntry.DiscardAll();
Physics.CollisionReports.LeaveWorldBatch(active);
Physics.ResetSessionPhysics();
Entities.BeginSessionClear();