Flips the last remote classification (SetPosition: teleport-advanced and
cell-less) onto 4b-1's RuntimeRemotePlacementDriveController, runs retail's
teleport_hook before the placement, and deletes the legacy remote-teleport
machinery. Contract: docs/research/2026-08-04-c4-route-4b-3-contract.md.
Retail: MoveOrTeleport @0x00516330's branch @0x00516386 -> teleport_hook
@0x005163EF -> SetFlags(0x1012) @0x00516414 -> SetPosition @0x00516420 ->
return 1 @0x00516438. The hook @0x00514ED0 runs BEFORE the placement and
regardless of its outcome. Retail places this branch unconditionally, at any
distance and any contact state (arg4 is read only @0x0051638E, after the
branch) — which is what retires AP-137's cell-less enqueue-vs-place delta.
D1 — the classifier's cell-less input is now the PRE-merge committed cell.
Retail's predicate is `this_1->cell == 0`, the BODY's own cell at
MoveOrTeleport entry (this_1 is assigned from this @0x00516334). acdream fed
the POST-merge canonical.FullCellId, which RefreshSnapshot ->
RefreshDerivedState -> SetFullCell has already stamped with the accepted wire
cell; a zero wire cell fails validation into RejectedData first. The shipped
remote cell-less predicate was therefore dead code, not merely different from
remotePlacementRequired. Threaded via a builder overload; route 1's overload
is untouched. The graphical !IsSpatiallyVisible arm of
projectionRequiresTeleportHook is deleted — a presentation predicate with no
retail analogue that fired the teleport machinery on a routine hot path.
Deleted: RemoteTeleportController (605), RemoteTeleportPlacement (85),
RemoteShadowPlacementSynchronizer (49), their 1,709 lines of tests, the
remotePlacementRequired predicate, the TeleportHookRequired plumbing, the
legacy pre-operation ConstrainTo fallback, and the player arm's legacy
!IsGrounded fallback. Net -2,030 lines.
Structural fix (two independent Opus reviews, round 1 FAIL/FAIL): three of the
four MAJORs were one defect — OnPosition carried two parallel inline copies of
the routing tail (player-guid, NPC-guid) that had drifted. Extracted
RunRemoteArmTail (3 call sites) and ApplyWireAirborneLeftoverBookkeeping (2),
both branches now share one implementation.
A1 ToConstraintArm mapped AirborneSnap -> AirborneNoOperation, so the NPC
arm armed ConstrainTo ZERO times for an out-of-contact wire-grounded
creature — a regression this slice introduced while closing a
structurally identical hole. Now maps to NearInterpolate; switch made
total with a throwing default proven unreachable.
R1 D2's write-nothing shape existed on the player arm only; NPC packets
fell through and wrote the body. Retail makes no player/NPC distinction.
R2 report_collision_end(this,1) @0x00514F31 was bound to
ShadowObjects.Suspend, a port of a DIFFERENT retail function
(remove_shadows_from_cells) that teleport_hook never calls. Now routes
to RuntimeCollisionReportingState.LeaveWorld, which wraps the private
ForceEnd in an admission-blocking transaction so a DoCollisionEnd
callback cannot recreate the contact table.
R3/A2 A teleported NPC synthesized ServerVelocity from the teleport distance
(~1,000+ m/s) and planned a run cycle from it. Both the install and
RemoteServerControlledVelocityCycle.Apply now gate on !isTeleportRoute.
BISECT HAZARD — A1's fix is correct only BECAUSE R1 landed. AirborneSnap is
reachable wire-airborne on the NPC arm only while D2's shape is missing there.
Reverting R1 alone silently inverts A1 into the opposite divergence: arming
where retail returns 0. Revert both or neither.
Also in the velocity hunk: the NPC block's two !IsPlayerGuid(update.Guid)
guards were dropped when it was wrapped in `if (!isTeleportRoute)`. Safe — all
five exit paths of the enclosing IsPlayerGuid block return, so the predicate is
unconditionally false below it — but it was unremarked by both reviews.
Register: AP-137 REWRITTEN (not deleted) to the surviving acdream-only
divergences — null classification during the login window and Rejected*
through UnroutedCatchUp keep a row. AD-42's RemoteTeleportController citation
retired; AP-136/AP-138 writer lists corrected to the two surviving non-Position
rebucket writers; AP-138 gains the teleport arm as a second producer of the
visible-without-collision residual (retirement path remains #309). AP-135 is
untouched and its two airborne bookkeeping writes are preserved on both arms.
AP-131 does not retire; #276 does not close.
Proof obligation 1: ParkCollisionResidents' overlap throw stays unreachable —
the teleport arm adds packets to the same TryBeginExclusiveAuthoredPlacement
one-operation-per-key machinery the far arm uses, opens no new operation shape,
and every DeferredCell outcome cancels synchronously with
restoreCancelledPark: true. The guarded property remains
HasOldPrefixPlacementDebt's stall, not a throw (4b-1's B2 caveat stands).
Correction to an earlier claim: LiveEntityPresentationController's
_activePlacementOwners was NOT write-never at HEAD —
remotePlacementRequired -> BeginPlacement -> Begin -> BeginAuthoritativePlacement
was a live writer chain. It becomes write-never BECAUSE this slice deletes that
chain, which is why deleting the dead half is behaviour-preserving.
Probe: ACDREAM_PROBE_REMOTE_TELEPORT=1 emits one [remote-teleport] line per
routed arm (guid, cause, hook-ran, placement status). TEMPORARY, strip with the
probe family.
Carried, disclosed not fixed: no dedicated bidirectional collision-partner test
for R2 (the wiring, not LeaveWorld itself, is what lacks coverage); the
stress test's teleport step drives hand-written field assignments rather than
the canonical arm; the per-packet runTeleportHook closure allocation (network
path, not the resolve path Slice I's 0 B discipline governs — file before
route 5 adds a fourth call site). B2: IRuntimeCollisionReportObserver has zero
production implementations, so retail's bidirectional DoCollisionEnd half still
reaches no gameplay consumer — this fix closes the wrong-function binding, not
that nobody listens.
Complete Release suite MEASURED at 11,013 passed / 4 skipped / 0 failed
(baseline 11,027/4/0; net -14 = ~33 deleted test cases against ~19 added).
Neither known flake fired (#302 PortalProjectionTests GC-allocation, #308
NakEmissionTests wall-clock).
STILL OWED: the two-client connected gate, which MUST use an NPC/creature
teleport target. Both round-1 MAJORs lived on the NPC arm and the velocity
cycle early-returns for 0x50xxxxxx guids, so a player target structurally
cannot observe A1, A2, or R3.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
285 lines
12 KiB
C#
285 lines
12 KiB
C#
using System.Numerics;
|
|
using AcDream.Core.Net.Messages;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Runtime.Entities;
|
|
using AcDream.Runtime.Physics;
|
|
using AcDream.Runtime.Session;
|
|
|
|
namespace AcDream.Runtime.Tests.Physics;
|
|
|
|
/// <summary>
|
|
/// C4 route 4b-2: the arm-selection half of the remote far snap. Every route
|
|
/// here is produced by the REAL classifier from a real request, including the
|
|
/// negative cases the classifier genuinely emits from other entry points (a
|
|
/// local-player <c>SetPositionSimple</c>, a remote top-level Create) and which
|
|
/// the far arm must decline. Exactly ONE route is hand-shaped — the
|
|
/// flags/disposition mismatch in
|
|
/// <see cref="OwnsFarSnap_IsAStrictSubsetOfThePlacementOwnersPredicate"/>,
|
|
/// which no classifier path produces but a caller could express.
|
|
///
|
|
/// <para>
|
|
/// Each test was verified to discriminate by temporarily reverting the
|
|
/// corresponding guard in <see cref="RuntimeRemoteFarSnapPosition"/> and
|
|
/// confirming the matching test failed, then restoring it.
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed class RuntimeRemoteFarSnapPositionTests
|
|
{
|
|
private const uint Cell = 0x0101FFFFu;
|
|
|
|
[Fact]
|
|
public void OwnsFarSnap_TrueForTheRemoteFarBranch()
|
|
{
|
|
RuntimeAuthoritativePositionRoute far =
|
|
Classify(hasContact: true, playerDistance: 200f);
|
|
|
|
// Retail: player_distance >= 96f -> StopInterpolating @0x005163CB +
|
|
// SetPositionSimple @0x005163D9, whose arg3 != 0 builds flags 0x1012
|
|
// (Teleport|Slide|SendPositionEvent) @0x005162C4.
|
|
Assert.Equal(
|
|
RuntimeAuthoritativePositionDisposition.SetPositionSimple,
|
|
far.Disposition);
|
|
Assert.True(far.StopInterpolating);
|
|
Assert.True(RuntimeRemoteFarSnapPosition.OwnsFarSnap(far));
|
|
}
|
|
|
|
[Fact]
|
|
public void OwnsFarSnap_TrueExactlyAtTheRetailBoundary()
|
|
{
|
|
// Retail compares player_distance against 96f and takes the
|
|
// InterpolateTo branch only when strictly LESS (@0x00516393-@0x0051639E,
|
|
// the `x87_r7 < temp1` test). 96.0 itself is the far branch.
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(hasContact: true, playerDistance: 95.99f)));
|
|
Assert.True(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(hasContact: true, playerDistance: 96f)));
|
|
}
|
|
|
|
[Fact]
|
|
public void OwnsFarSnap_FalseForEveryOtherRemoteClassification()
|
|
{
|
|
// Near InterpolateTo @0x005163AF.
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(hasContact: true, playerDistance: 10f)));
|
|
// Airborne no-op @0x0051636D.
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(hasContact: false, playerDistance: 10f)));
|
|
// Cell-less: retail's `this_1->cell == 0` branch @0x00516386 —
|
|
// SetPosition, NOT the far snap. 4b-3 owns it.
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(hasContact: true, playerDistance: 200f, committedCellId: 0u)));
|
|
// Fresh TELEPORT_TS: the same @0x00516386 branch. 4b-3 owns it.
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(
|
|
hasContact: true,
|
|
playerDistance: 200f,
|
|
previousTeleport: 10,
|
|
acceptedTeleport: 11)));
|
|
// Rejections and "no classification at all".
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(
|
|
hasContact: true,
|
|
playerDistance: 200f,
|
|
disposition: PositionTimestampDisposition.Rejected)));
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(
|
|
Classify(hasContact: true, playerDistance: float.NaN)));
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(null));
|
|
}
|
|
|
|
/// <summary>
|
|
/// The disposition alone is not the discriminator: the classifier emits
|
|
/// <c>SetPositionSimple</c> for the LOCAL PLAYER's FORCE_POSITION branch
|
|
/// too (<c>RuntimeAuthoritativePositionRouteClassifier.cs:332</c>). Route
|
|
/// 4b-2 is a remote route; claiming that one would run a remote arm over
|
|
/// route 2's local-player transaction.
|
|
/// </summary>
|
|
[Fact]
|
|
public void OwnsFarSnap_FalseForTheLocalPlayerForcePositionRoute()
|
|
{
|
|
RuntimeAuthoritativePositionRoute force = ClassifyKind(
|
|
RuntimePositionEntityKind.LocalPlayer,
|
|
hasContact: true,
|
|
playerDistance: 200f,
|
|
disposition: PositionTimestampDisposition.ForcePosition);
|
|
|
|
Assert.Equal(
|
|
RuntimeAuthoritativePositionDisposition.SetPositionSimple,
|
|
force.Disposition);
|
|
Assert.Equal(
|
|
RuntimeSetPositionOperationKind.LocalAuthoritative,
|
|
force.OperationKind);
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(force));
|
|
}
|
|
|
|
/// <summary>
|
|
/// A REMOTE top-level initial Create is also <c>RemoteAuthoritative</c>;
|
|
/// it is excluded here by its disposition (<c>SetPosition</c>), which
|
|
/// route 4b-3 owns.
|
|
/// </summary>
|
|
[Fact]
|
|
public void OwnsFarSnap_FalseForARemoteTopLevelCreateRoute()
|
|
{
|
|
RuntimeAuthoritativePositionRoute create =
|
|
RuntimeAuthoritativePositionRouteClassifier.ClassifyCreate(
|
|
new RuntimeCreatePositionRouteRequest(
|
|
Authority(PositionTimestampDisposition.Apply, 10, 10),
|
|
RuntimePositionEntityKind.Remote,
|
|
RuntimeCreateResidenceKind.TopLevel,
|
|
new CreateObject.ServerPosition(
|
|
Cell, 10f, 20f, 30f, 1f, 0f, 0f, 0f),
|
|
default));
|
|
|
|
Assert.Equal(
|
|
RuntimeSetPositionOperationKind.RemoteAuthoritative,
|
|
create.OperationKind);
|
|
Assert.Equal(
|
|
PhysicsSetPositionFlags.Placement | PhysicsSetPositionFlags.Slide,
|
|
create.SetPositionFlags);
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(create));
|
|
}
|
|
|
|
/// <summary>
|
|
/// The invariant the <c>Teleport</c>-flag term actually carries:
|
|
/// <see cref="RuntimeRemoteFarSnapPosition.OwnsFarSnap"/> must be a strict
|
|
/// SUBSET of
|
|
/// <see cref="RuntimeRemotePlacementDriveController.OwnsPlacement"/>. The
|
|
/// far arm hands its route straight to that controller, so any route the
|
|
/// arm claims but the controller declines would execute
|
|
/// <c>StopInterpolating</c> and then silently do nothing
|
|
/// (<c>NotApplicable</c>) — a remote that stops tracking the server with
|
|
/// no diagnostic. The flags term is what keeps the two predicates
|
|
/// aligned; without it, the hand-shaped route below is claimed here and
|
|
/// declined there.
|
|
/// </summary>
|
|
[Fact]
|
|
public void OwnsFarSnap_IsAStrictSubsetOfThePlacementOwnersPredicate()
|
|
{
|
|
// Every route the real classifier produces.
|
|
foreach (RuntimeAuthoritativePositionRoute route in new[]
|
|
{
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
Classify(hasContact: true, playerDistance: 10f),
|
|
Classify(hasContact: false, playerDistance: 10f),
|
|
Classify(hasContact: true, playerDistance: 200f, committedCellId: 0u),
|
|
Classify(hasContact: true, playerDistance: float.NaN),
|
|
ClassifyKind(
|
|
RuntimePositionEntityKind.LocalPlayer,
|
|
hasContact: true,
|
|
playerDistance: 200f,
|
|
disposition: PositionTimestampDisposition.ForcePosition),
|
|
})
|
|
{
|
|
if (RuntimeRemoteFarSnapPosition.OwnsFarSnap(route))
|
|
{
|
|
Assert.True(
|
|
RuntimeRemotePlacementDriveController.OwnsPlacement(route));
|
|
}
|
|
}
|
|
|
|
// …and the shape a caller could construct that the classifier does
|
|
// not: the far disposition and operation kind with a Create's flags.
|
|
RuntimeAuthoritativePositionRoute mismatched =
|
|
Classify(hasContact: true, playerDistance: 200f) with
|
|
{
|
|
SetPositionFlags = PhysicsSetPositionFlags.Placement
|
|
| PhysicsSetPositionFlags.Slide,
|
|
};
|
|
Assert.False(
|
|
RuntimeRemotePlacementDriveController.OwnsPlacement(mismatched));
|
|
Assert.False(RuntimeRemoteFarSnapPosition.OwnsFarSnap(mismatched));
|
|
}
|
|
|
|
// ── Arm selection is total, and the leftovers are named ─────────────────
|
|
|
|
[Fact]
|
|
public void ResolveArm_MapsEveryRemoteClassificationToExactlyOneArm()
|
|
{
|
|
Assert.Equal(
|
|
RuntimeRemoteAcceptedPositionArm.AirborneNoOperation,
|
|
RuntimeRemoteFarSnapPosition.ResolveArm(
|
|
Classify(hasContact: false, playerDistance: 10f)));
|
|
Assert.Equal(
|
|
RuntimeRemoteAcceptedPositionArm.NearInterpolate,
|
|
RuntimeRemoteFarSnapPosition.ResolveArm(
|
|
Classify(hasContact: true, playerDistance: 10f)));
|
|
Assert.Equal(
|
|
RuntimeRemoteAcceptedPositionArm.FarSnapPlacement,
|
|
RuntimeRemoteFarSnapPosition.ResolveArm(
|
|
Classify(hasContact: true, playerDistance: 200f)));
|
|
|
|
// The acdream-only leftovers left in THIS arm after C4 route 4b-3
|
|
// moved the cell-less/fresh-teleport shapes onto the teleport arm
|
|
// (RuntimeRemoteTeleportPosition.OwnsTeleportPlacement — see that
|
|
// class's own tests). What remains: no classification at all, and
|
|
// the two rejections.
|
|
Assert.Equal(
|
|
RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp,
|
|
RuntimeRemoteFarSnapPosition.ResolveArm(
|
|
Classify(
|
|
hasContact: true,
|
|
playerDistance: 10f,
|
|
disposition: PositionTimestampDisposition.Rejected)));
|
|
Assert.Equal(
|
|
RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp,
|
|
RuntimeRemoteFarSnapPosition.ResolveArm(
|
|
Classify(hasContact: true, playerDistance: float.NaN)));
|
|
Assert.Equal(
|
|
RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp,
|
|
RuntimeRemoteFarSnapPosition.ResolveArm(null));
|
|
}
|
|
|
|
private static RuntimeAuthoritativePositionAuthority Authority(
|
|
PositionTimestampDisposition disposition,
|
|
ushort previousTeleport,
|
|
ushort acceptedTeleport) =>
|
|
new(
|
|
new RuntimeGenerationToken(7),
|
|
new RuntimeEntityKey(0x70000001u, 3),
|
|
PositionAuthorityVersion: 11UL,
|
|
AcceptedPositionSequence: 20,
|
|
previousTeleport,
|
|
acceptedTeleport,
|
|
disposition);
|
|
|
|
private static RuntimeAuthoritativePositionRoute Classify(
|
|
bool hasContact,
|
|
float playerDistance,
|
|
uint committedCellId = Cell,
|
|
ushort previousTeleport = 10,
|
|
ushort acceptedTeleport = 10,
|
|
PositionTimestampDisposition disposition =
|
|
PositionTimestampDisposition.Apply) =>
|
|
ClassifyKind(
|
|
RuntimePositionEntityKind.Remote,
|
|
hasContact,
|
|
playerDistance,
|
|
committedCellId,
|
|
previousTeleport,
|
|
acceptedTeleport,
|
|
disposition);
|
|
|
|
private static RuntimeAuthoritativePositionRoute ClassifyKind(
|
|
RuntimePositionEntityKind kind,
|
|
bool hasContact,
|
|
float playerDistance,
|
|
uint committedCellId = Cell,
|
|
ushort previousTeleport = 10,
|
|
ushort acceptedTeleport = 10,
|
|
PositionTimestampDisposition disposition =
|
|
PositionTimestampDisposition.Apply) =>
|
|
RuntimeAuthoritativePositionRouteClassifier.ClassifyAcceptedPosition(
|
|
new RuntimeAcceptedPositionRouteRequest(
|
|
Authority(disposition, previousTeleport, acceptedTeleport),
|
|
kind,
|
|
RuntimeAcceptedPositionSource.PositionEvent,
|
|
new CreateObject.ServerPosition(
|
|
Cell, 10f, 20f, 30f, 1f, 0f, 0f, 0f),
|
|
PlacementFrame: 0u,
|
|
PositionPackVelocity: Vector3.Zero,
|
|
committedCellId,
|
|
hasContact,
|
|
playerDistance,
|
|
UsePositionFromServer: false,
|
|
HasAnimations: false,
|
|
default));
|
|
}
|