Snapshot for release 2026.10.19.1 (internal fa7a8f6)

This commit is contained in:
Tom Bohar 2026-10-19 09:11:20 -04:00
commit 44074df011
110 changed files with 8017 additions and 291 deletions

View file

@ -82,6 +82,41 @@ internal static partial class Program
DrainBounds();
DrainCombatHoldsInventory();
DrainSweepRetriesAfterOverflow();
DrainReachesItemsBehindTheEvaluationBudget();
}
// Review fix 2026-10-18: more than MaxEvaluatedPerTick items waiting (here the pack waits through
// combat) used to leave the newest ones, at the end of the list, unlooked-at for as long as the
// earlier ones kept waiting. The drain now resumes where it stopped.
private static void DrainReachesItemsBehindTheEvaluationBudget()
{
_case = "drain round robin";
const uint Chest = 0x80000B00, Loot = 0x80000B01;
var w = new FakeWorld { Now = 1_000_000, Warm = true };
var d = new AutoIdDrain(w);
int pack = AutoIdDrain.MaxEvaluatedPerTick + 88;
for (uint i = 1; i <= pack; i++) { w.Snapshot[0x8000D000 + i] = (Me, 0); d.Offer(0x8000D000 + i, w.Now - 10_000); }
w.Snapshot[Loot] = (Chest, 0); d.Offer(Loot, w.Now - 10_000); // newest: last in the list
AutoIdDrain.Context Fight() => new()
{
Now = w.Now, Mode = AutoIdMode.Limited, PlayerId = Me, OpenContainer = Chest, OpenedAtMs = w.Now - 5_000,
SettleUntilMs = 0, LoginCompleteAtMs = 1, CombatBusy = true,
};
d.Tick(Fight(), 0);
Check(d.PendingCount == pack + 1, $"first tick: the pack waits, the chest item is behind the budget (pending {d.PendingCount})");
Check(!w.Sent.Any(s => s.Id == Loot), "first tick: the chest item was not reached yet");
for (int k = 0; k < 4; k++) { w.Now += 100; d.Tick(Fight(), 0); }
Check(w.Sent.Any(s => s.Id == Loot), "within a few ticks the chest item is reached and sent although the pack keeps waiting");
Check(!w.Sent.Any(s => (s.Id & 0xFFFFF000) == 0x8000D000), "while the pack, in combat, sent nothing");
Check(d.PendingCount == pack, $"and the waiting pack is all still pending (pending {d.PendingCount})");
// Every pack item is looked at in turn: end the fight and they all go out.
AutoIdDrain.Context Calm() => new()
{
Now = w.Now, Mode = AutoIdMode.Limited, PlayerId = Me, OpenContainer = 0, OpenedAtMs = 0,
SettleUntilMs = 0, LoginCompleteAtMs = 1, CombatBusy = false,
};
for (int k = 0; k < 4000 && d.PendingCount > 0; k++) { w.Now += 100; d.Tick(Calm(), 0); }
Check(d.PendingCount == 0, $"after combat the whole backlog drains (pending {d.PendingCount})");
}
// The pack is created at login, before the snapshot is warm; it must still go out.

View file

@ -20,6 +20,7 @@
AutoIdDrain.cs the AutoId backlog against a fake world: login sweep, cold snapshot,
refused sends kept, bounds
IdRequester.cs the engine-send marker that tags every engine 0xC8
DumpBudget.cs the full OOM dump needs free space and a cap on dumps across clients
PumpGuards.cs TickAll's own steps are caught (logged once, then counted); the hang
report names the plugin call the pump is inside
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
@ -48,6 +49,7 @@
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\CrashExitRule.cs" Link="Engine\CrashExitRule.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\AutoIdPolicy.cs" Link="Engine\AutoIdPolicy.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\AutoIdDrain.cs" Link="Engine\AutoIdDrain.cs" />
<Compile Include="..\..\src\RynthCore.Engine\DumpBudget.cs" Link="Engine\DumpBudget.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Net\IdRequester.cs" Link="Engine\IdRequester.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Plugins\PumpGuards.cs" Link="Engine\PumpGuards.cs" />
</ItemGroup>

View file

@ -37,6 +37,10 @@ internal static partial class Program
TransitionDiagonalAndBorderWalksNeverHold();
TransitionTwoLandblockJumpHolds();
TransitionDrainHoldThenStopsSurvive();
TransitionValveOpensAfterMaxHold();
TransitionValveStuckPortalAndReset();
TransitionGateDisabledNeverHolds();
TransitionValveIgnoresShortTransitions();
AddressSpaceFold();
@ -266,6 +270,104 @@ internal static partial class Program
Check(!s.InTransition(9000 + WorldTransitionState.SettleMs), "window ends");
}
// The safety valve (review 2026-10-18): a character that keeps reading dead (Health 0 after a
// revive) must not freeze every queued action for good.
private static void TransitionValveOpensAfterMaxHold()
{
_case = "valve dead forever";
var s = Started();
long t = 2000;
var e = s.Sample(t, true, false, 0x00AE);
Check((e & WorldTransitionState.Edge.Died) != 0 && !s.Overridden, "dead: gate held, valve shut");
Check(s.Decide(t, 1500, false) == WorldTransitionState.Verdict.Hold, "an action queued before is held");
int overrideEdges = 0;
long openedAt = 0;
for (t += 1000; t <= 2000 + WorldTransitionState.MaxHoldMs + 10_000; t += 1000)
{
e = s.Sample(t, true, false, 0x00AE); // still reading dead
if ((e & WorldTransitionState.Edge.GateOverride) != 0) { overrideEdges++; openedAt = t; }
if (t < 2000 + WorldTransitionState.MaxHoldMs)
Check(s.InTransition(t) && !s.Overridden, $"held before the bound (t={t})");
}
Check(overrideEdges == 1, $"exactly one override edge, got {overrideEdges}");
Check(openedAt == 2000 + WorldTransitionState.MaxHoldMs, $"opens at the bound, got {openedAt - 2000} ms");
Check(s.Overridden && s.Overrides == 1, "valve open, counted once");
long now = t;
Check(!s.InTransition(now), "open: nothing is in transition any more");
Check(s.RawInTransition(now), "(the raw state still says dead)");
Check(s.Decide(now, now - 10, false) == WorldTransitionState.Verdict.Run, "new work runs");
Check(s.Decide(now, 1500, false) == WorldTransitionState.Verdict.Drop, "work queued during the hold is dropped as stale, like after any transition");
Check(s.Decide(now, 1500, true) == WorldTransitionState.Verdict.Run, "a stop queued during the hold still runs");
// The character does come back later: the raw transition ends, and the valve re-arms.
s.Sample(now + 1000, false, false, 0x00AE);
Check(s.Overridden, "revived, but the settle window is still running: still open");
s.Sample(now + 1000 + WorldTransitionState.SettleMs, false, false, 0x00AE);
Check(!s.Overridden && !s.RawInTransition(now + 1000 + WorldTransitionState.SettleMs), "settled: valve re-armed");
var d = s.Sample(now + 20_000, true, false, 0x00AE);
Check((d & WorldTransitionState.Edge.Died) != 0 && s.InTransition(now + 20_000), "the next death holds again");
Check(s.HeldForMs(now + 20_000) == 0, "held-for restarts from the new transition");
}
private static void TransitionValveStuckPortalAndReset()
{
_case = "valve stuck portal";
var s = Started();
s.Sample(2000, false, true, 0x00AE);
long t = 2000;
bool opened = false;
for (; t < 2000 + WorldTransitionState.MaxHoldMs + 5000; t += 500)
if ((s.Sample(t, false, true, 0x00AE) & WorldTransitionState.Edge.GateOverride) != 0) opened = true;
Check(opened && !s.InTransition(t) && s.Overrides == 1, "a portal flag that never clears opens the gate once");
// Exiting the portal ends it.
s.Sample(t, false, false, 0x00AE);
s.Sample(t + WorldTransitionState.SettleMs + 1, false, false, 0x00AE);
Check(!s.Overridden, "re-armed after the transition ends");
}
private static void TransitionGateDisabledNeverHolds()
{
_case = "gate disabled";
var s = Started();
s.Enabled = false;
s.Sample(2000, true, false, 0x00AE);
Check(s.RawInTransition(2000) && !s.InTransition(2000), "dead, gate off: not in transition");
Check(!s.CheckHolding(2000) && s.LastBlockedMs == 0, "nothing held, nothing recorded");
Check(s.Decide(2000, 1900, false) == WorldTransitionState.Verdict.Run, "work runs through a death");
Check(s.Decide(2000, 1900, true) == WorldTransitionState.Verdict.Run, "and stops too");
long late = 2000 + WorldTransitionState.MaxHoldMs + 1000;
s.Sample(late, true, false, 0x00AE);
Check(s.Overrides == 1, "the valve counter still counts (only information while the gate is off)");
s.Enabled = true;
s.Sample(late + 1000, true, false, 0x00AE);
Check(!s.InTransition(late + 1000), "turned on again while the valve is open: stays open until the transition ends");
}
private static void TransitionValveIgnoresShortTransitions()
{
_case = "valve short transitions";
var s = Started();
long t = 2000;
// 40 deaths/portals in a row, each well under the bound, each followed by a quiet spell.
for (int i = 0; i < 40; i++)
{
s.Sample(t, true, false, 0x00AE);
t += 20_000;
s.Sample(t, false, true, 0x00AE);
t += 20_000;
s.Sample(t, false, false, 0x00AE);
t += WorldTransitionState.SettleMs + 1000;
s.Sample(t, false, false, 0x00AE);
t += 10_000;
}
Check(s.Overrides == 0, $"transitions that end on their own never trip it, got {s.Overrides}");
// A death straight into a portal without a gap is ONE continuous transition.
var u = Started();
u.Sample(2000, true, false, 0x00AE);
u.Sample(2000 + 60_000, false, true, 0x00AE);
var edges = u.Sample(2000 + 125_000, false, true, 0x00AE);
Check((edges & WorldTransitionState.Edge.GateOverride) != 0, "dead then portaling without a gap: one transition, valve opens at the bound");
}
private static void TransitionLandblockJumpWithoutPortalHolds()
{
_case = "transition jump";

View file

@ -21,6 +21,8 @@ internal static partial class Program
RequestIdNeverMergesIntoAHeldEntry();
ReleasedDataKeptSoRecreateSkips();
ReleasedDataStaleOnLongAbsenceIsDroppedAtRecreate();
DumpBudgetRules();
ReleasedDataExpiresAndServerDeleteEvicts();
TeleportMessageStartsTheWindow();
@ -267,13 +269,84 @@ internal static partial class Program
// Client release (BeingDeleted): AppraisalHooks.OnClientRelease
if (!keep.OnRelease(50, t + 60_000)) cache.Remove(50);
elig.OnClientRelease(50);
// Re-created 5 minutes later: AutoIdService.Enqueue (MarkLive, then the decision)
keep.Forget(50);
var d = elig.OnCreate(50, t + 5 * 60_000, cache.Contains(50));
Check(d == AutoIdEligibility.CreateDecision.SkipRecent, $"re-created within 10 min with the data kept: skipped ({d})");
// Re-created 30 s later (out of view and back): AutoIdService.Enqueue (MarkLive, then the decision)
if (keep.TakeLive(50, t + 90_000)) cache.Remove(50);
var d = elig.OnCreate(50, t + 90_000, cache.Contains(50));
Check(d == AutoIdEligibility.CreateDecision.SkipRecent, $"re-created soon after the release with the data kept: skipped ({d})");
Check(elig.SkippedRecentTotal == 1, $"SkippedRecentCount moves (got {elig.SkippedRecentTotal})");
}
/// <summary>
/// Review fix 2026-10-18: data kept since a release ReleasedObjectRetention.StaleAfterMs ago or
/// more is dropped when the object is re-created (the client sent no updates meanwhile, so a
/// stack count could be minutes old), and the re-create is appraised again.
/// </summary>
private static void ReleasedDataStaleOnLongAbsenceIsDroppedAtRecreate()
{
_case = "release stale";
var cache = new HashSet<uint>();
var keep = new ReleasedObjectRetention();
var elig = new AutoIdEligibility();
long t = 1000;
elig.OnCreate(60, t, cache.Contains(60));
elig.OnSent(60, t + 100);
cache.Add(60);
if (!keep.OnRelease(60, t + 1000)) cache.Remove(60);
elig.OnClientRelease(60);
Check(keep.IsReleased(60), "released: kept");
// 5 minutes later it comes back.
long back = t + 1000 + 5 * 60_000;
bool stale = keep.TakeLive(60, back);
Check(stale, "re-created 5 min after the release: its kept data is stale");
if (stale) cache.Remove(60); // AppraisalHooks.MarkLive evicts it
Check(!keep.IsReleased(60), "and it is current again");
var d = elig.OnCreate(60, back, cache.Contains(60));
Check(d == AutoIdEligibility.CreateDecision.Appraise, $"the re-create is a candidate again ({d})");
// Exactly at the bound, and just under it.
var k2 = new ReleasedObjectRetention();
k2.OnRelease(1, 10_000); k2.OnRelease(2, 10_000);
Check(!k2.TakeLive(1, 10_000 + ReleasedObjectRetention.StaleAfterMs - 1), "just under StaleAfterMs: kept");
Check(k2.TakeLive(2, 10_000 + ReleasedObjectRetention.StaleAfterMs), "at StaleAfterMs: stale");
Check(!k2.TakeLive(3, 99_999), "never released: not stale");
Check(!k2.TakeLive(2, 99_999_999), "and a second create finds nothing to expire");
}
/// <summary>DumpBudget: the full OUT OF MEMORY dump needs room on the volume and a cap across clients.</summary>
private static void DumpBudgetRules()
{
_case = "dump budget";
const long GB = 1024L * 1024 * 1024, MB = 1024L * 1024;
long est = DumpBudget.EstimateFullDumpBytes(3 * GB);
Check(est == 3 * GB + DumpBudget.FullDumpOverheadBytes, "the estimate is the private bytes plus the overhead");
Check(DumpBudget.EstimateFullDumpBytes(0) == DumpBudget.FallbackProcessBytes + DumpBudget.FullDumpOverheadBytes,
"unknown size: the 32-bit maximum");
Check(DumpBudget.Evaluate(100 * GB, est, 0, 0) == DumpVerdict.Full, "plenty of room, no other dumps: full");
Check(DumpBudget.Evaluate(-1, est, 0, 0) == DumpVerdict.LowDisk, "free space unknown: not full");
Check(DumpBudget.Evaluate(est + DumpBudget.MinFreeAfterFullDump - 1, est, 0, 0) == DumpVerdict.LowDisk,
"one byte short of leaving the margin free: low disk");
Check(DumpBudget.Evaluate(est + DumpBudget.MinFreeAfterFullDump, est, 0, 0) == DumpVerdict.Full, "exactly the margin: full");
Check(DumpBudget.Evaluate(2 * GB, est, 0, 0) == DumpVerdict.LowDisk, "a nearly full disk: small dump instead");
// N clients hitting the OOM box together: placeholders count, so only a few get a full dump.
int full = 0;
int count = 0;
long bytes = 0;
for (int client = 0; client < 10; client++)
{
if (DumpBudget.Evaluate(500 * GB, est, count, bytes) == DumpVerdict.Full) { full++; count++; bytes += 0; /* a placeholder is empty */ }
}
Check(full == DumpBudget.MaxFullDumpsAllPids, $"10 clients at once: {DumpBudget.MaxFullDumpsAllPids} full dumps at most, got {full}");
Check(DumpBudget.Evaluate(500 * GB, est, 2, 12 * GB) == DumpVerdict.TooManyBytes, "two dumps already at 12 GB: the bytes cap");
Check(DumpBudget.Evaluate(500 * GB, est, DumpBudget.MaxFullDumpsAllPids, 1 * MB) == DumpVerdict.TooManyDumps, "the count cap");
Check(DumpBudget.Evaluate(1 * GB, est, DumpBudget.MaxFullDumpsAllPids, 0) == DumpVerdict.LowDisk, "low disk is reported first");
Check(DumpBudget.SmallDumpAllowed(DumpBudget.SmallDumpMinFree) && !DumpBudget.SmallDumpAllowed(DumpBudget.SmallDumpMinFree - 1)
&& !DumpBudget.SmallDumpAllowed(-1), "the small dump needs its own margin, and not an unknown disk");
}
private static void ReleasedDataExpiresAndServerDeleteEvicts()
{
_case = "release expiry";