AutoId limit: AutoIdMode All/Limited/Off (default Limited), requester-tagged 0xC8s

A flight capture from one 26-minute session showed the client sending 3211 IdentifyObject
(0xC8) messages, most of everything it sent, because AutoId appraised every object the
client created. Bots already appraise at the point of use, so the background appraisals
are now limited.

AutoIdMode (engine.json "AutoIdMode", default Limited; /rc autoid all|limited|off, live
and saved; /rc autoid alone reports it):
  All      the old behaviour.
  Limited  only the selected target (fresh-cache skip), items in the container the
           player has open now, and items in the player's own inventory with nothing
           cached. The last two wait until the object is 2 s old and until 30 s after a
           world transition's settle window ends (death, portal, teleport, landblock jump;
           walking into the next landblock never defers). A container opened after the
           settle ended is not deferred. Creatures, ground items, other players: never.
  Off      nothing, the selected target included.
Plugins' own RequestId calls are not limited; they still merge in the RequestId slot.

The decision is AutoIdPolicy (pure). AutoIdService now keeps a pending list on its drain
timer (waits for age/defer stay, skips leave), classifies each candidate from the PWD
snapshot (container / wielder / side pack owner, and the ground container from
ViewObjectContents), takes InventoryPutObjInContainer (0x0022) moves from the server
message stream, and rescans an opened container 2.5 s after the open.

Requester tagging: a thread-local EngineSendMarker around every engine RequestId call
(AutoId by class, plugin host API, the login self-identify, the Inventory panel hover).
A queued request carries its requester in PendingIdQueue and the main-thread drain
re-enters the marker around the real send. Only a marked send registers with the
flight recorder (FlightCapture.EngineSend, its own 64-entry table so bursts never evict
other engine calls), so its 0xC8 shows as [eng:autoid-target|autoid-container|
autoid-inventory|autoid-world|plugin|self|ui]; an unmarked 0xC8 stays [cli] and counts
as AC's or Decal's.

Per-minute log line "autoid 60s: ..." (its own line, not part of "hb #"): sends by
requester, cli, total, AutoId skips by reason (mode, age, defer, fresh), pending.

EngineSettings keeps upstream's MaxHotReloads, IltServerNames/IltHosts, ReportEndpoint
and CloseOnServerDisconnect next to AutoIdMode (owned keys, load and save).

Tests: EngineRobustnessTests (decision table against an independent expected function,
spot cases, defer window from WorldTransitionState inputs, classification, marker scopes
and thread-locality, requester through PendingIdQueue, heartbeat field names against the
launcher regex), FlightRecorderTests (identify tagging, foreign count, match window, burst),
EngineSettingsTests (AutoIdMode round trip, default left out). check_offthread_mutators.py:
DrainPending allow-listed like DrainTick (it only enqueues).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-10-10 23:09:15 -07:00
commit aaaa0a94b4
26 changed files with 1198 additions and 69 deletions

View file

@ -0,0 +1,254 @@
using RynthCore.Engine.Compatibility;
using RynthCore.Engine.Net;
using V = RynthCore.Engine.Compatibility.AutoIdPolicy.Verdict;
using C = RynthCore.Engine.Compatibility.AutoIdPolicy.Class;
namespace EngineRobustnessTests;
/// <summary>
/// AutoId limiting: the mode decision table, the post-transition defer, where an
/// object is, and the engine-send marker that tags every engine 0xC8.
/// </summary>
internal static partial class Program
{
private static void RunAutoIdLimitTests()
{
AutoIdDecisionTable();
AutoIdDecisionSpotCases();
AutoIdDeferWindow();
AutoIdClassify();
AutoIdModeParse();
IdMarkerScopes();
IdMarkerRidesTheQueue();
IdHeartbeatNames();
}
// ---- the decision table ---------------------------------------------------------
private static readonly long[] Ages = { 0, AutoIdPolicy.MinAgeMs - 1, AutoIdPolicy.MinAgeMs, 60_000 };
/// <summary>The rule as the spec states it, written out independently of AutoIdPolicy.Decide.</summary>
private static V Expected(AutoIdMode mode, C cls, long age, bool defer, bool openedAfter, bool fresh, bool cached)
{
if (mode == AutoIdMode.Off) return V.SkipMode;
if (mode == AutoIdMode.All) return cls == C.Target && fresh ? V.SkipFresh : V.Send;
bool young = age < AutoIdPolicy.MinAgeMs;
return cls switch
{
C.Target => fresh ? V.SkipFresh : V.Send,
C.Container => fresh ? V.SkipFresh : young ? V.WaitAge : defer && !openedAfter ? V.WaitDefer : V.Send,
C.Inventory => cached ? V.SkipFresh : young ? V.WaitAge : defer ? V.WaitDefer : V.Send,
C.Unknown => young ? V.WaitAge : V.SkipMode,
_ => V.SkipMode,
};
}
private static void AutoIdDecisionTable()
{
_case = "autoid decision table";
int rows = 0, wrong = 0;
foreach (AutoIdMode mode in Enum.GetValues<AutoIdMode>())
foreach (C cls in Enum.GetValues<C>())
foreach (long age in Ages)
foreach (bool defer in new[] { false, true })
foreach (bool opened in new[] { false, true })
foreach (bool cached in new[] { false, true })
foreach (bool fresh in new[] { false, true })
{
if (fresh && !cached) continue; // fresh implies cached
rows++;
V got = AutoIdPolicy.Decide(mode, cls, age, defer, opened, fresh, cached);
V want = Expected(mode, cls, age, defer, opened, fresh, cached);
if (got != want && wrong++ < 10)
Check(false, $"{mode} {cls} age={age} defer={defer} opened={opened} cached={cached} fresh={fresh}: want {want}, got {got}");
}
Check(wrong == 0, $"{wrong} of {rows} rows wrong");
Check(rows == 3 * 5 * 4 * 2 * 2 * 3, $"row count {rows}");
}
/// <summary>The same rules as named cases, so a mutation is easy to read off a failure.</summary>
private static void AutoIdDecisionSpotCases()
{
_case = "autoid spot cases";
const long Old = 10_000;
// Off: nothing at all, the selected target included.
Check(AutoIdPolicy.Decide(AutoIdMode.Off, C.Target, 0, false, false, false, false) == V.SkipMode, "off skips the target");
Check(AutoIdPolicy.Decide(AutoIdMode.Off, C.Container, Old, false, true, false, false) == V.SkipMode, "off skips an open container");
// All: the old behaviour.
Check(AutoIdPolicy.Decide(AutoIdMode.All, C.World, 0, true, false, false, false) == V.Send, "all sends a fresh-born world object, deferred or not");
Check(AutoIdPolicy.Decide(AutoIdMode.All, C.Target, 0, false, false, true, true) == V.SkipFresh, "all keeps the target fresh skip");
Check(AutoIdPolicy.Decide(AutoIdMode.All, C.Inventory, 0, false, false, false, true) == V.Send, "all sends a cached pack item (old behaviour)");
// Limited: target.
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Target, 0, true, false, false, false) == V.Send, "target exempt from age and defer");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Target, 0, false, false, true, true) == V.SkipFresh, "target fresh skip");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Target, 0, false, false, false, true) == V.Send, "target cached but stale is sent");
// Limited: world never.
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.World, Old, false, false, false, false) == V.SkipMode, "creature / ground item skipped");
// Limited: container.
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, AutoIdPolicy.MinAgeMs - 1, false, true, false, false) == V.WaitAge, "container item waits for the minimum age");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, AutoIdPolicy.MinAgeMs, false, false, false, false) == V.Send, "container item at the minimum age is sent");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, Old, true, false, false, false) == V.WaitDefer, "container opened before the settle ended waits out the defer");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, Old, true, true, false, false) == V.Send, "container opened after the settle is not deferred");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, Old, false, false, true, true) == V.SkipFresh, "fresh container item skipped");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, Old, false, false, false, true) == V.Send, "stale cached container item re-appraised");
// Limited: inventory.
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Inventory, Old, false, false, false, true) == V.SkipFresh, "pack item with any cached appraisal skipped");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Inventory, AutoIdPolicy.MinAgeMs - 1, false, false, false, false) == V.WaitAge, "pack item waits for the minimum age");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Inventory, Old, true, true, false, false) == V.WaitDefer, "pack item deferred (the opened-container exemption does not apply)");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Inventory, Old, false, false, false, false) == V.Send, "uncached pack item sent");
// Limited: unknown place.
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Unknown, 100, false, false, false, false) == V.WaitAge, "unknown place waits while young");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Unknown, Old, false, false, false, false) == V.SkipMode, "still unknown when old: skipped");
Check(AutoIdPolicy.DefaultMode == AutoIdMode.Limited, "default mode is Limited");
}
// ---- the post-transition defer -----------------------------------------------------
private static void AutoIdDeferWindow()
{
_case = "autoid defer window";
const long D = AutoIdPolicy.DeferMs;
const long S = WorldTransitionState.SettleMs;
// No transition yet: nothing is deferred.
var w = new WorldTransitionState();
w.Sample(1000, dead: false, portaling: false, landblock: 0xA9B4);
Check(!AutoIdPolicy.InDefer(1000, w.SettleUntilMs, w.InTransition(1000)), "no transition, no defer");
// Walking into the next landblock never defers.
w.Sample(2000, false, false, 0xAAB4);
w.Sample(3000, false, false, 0xAAB5);
Check(w.SettleUntilMs == 0, "an adjacent walk sets no settle window");
Check(!AutoIdPolicy.InDefer(3000, w.SettleUntilMs, w.InTransition(3000)), "adjacent walk: no defer");
// A portal: deferred through portal space, the settle window, and DeferMs after it.
w.Sample(10_000, false, true, 0xAAB5);
Check(AutoIdPolicy.InDefer(10_000, w.SettleUntilMs, w.InTransition(10_000)), "in portal space: deferred");
w.Sample(12_000, false, false, 0x0007);
long settleEnd = w.SettleUntilMs;
Check(settleEnd == 12_000 + S, $"settle ends {S} ms after the portal exit, got {settleEnd}");
Check(AutoIdPolicy.InDefer(settleEnd + D - 1, settleEnd, w.InTransition(settleEnd + D - 1)), "deferred until DeferMs after the settle");
Check(!AutoIdPolicy.InDefer(settleEnd + D, settleEnd, w.InTransition(settleEnd + D)), "not deferred at DeferMs after the settle");
// A container opened after the settle ended is exempt; one opened before is not.
Check(AutoIdPolicy.OpenedAfterSettle(settleEnd + 1, settleEnd), "opened after the settle: exempt");
Check(!AutoIdPolicy.OpenedAfterSettle(settleEnd - 1, settleEnd), "opened during the settle: not exempt");
Check(!AutoIdPolicy.OpenedAfterSettle(0, settleEnd), "never opened: not exempt");
// Death defers too.
var d = new WorldTransitionState();
d.Sample(1000, false, false, 0x1234);
d.Sample(2000, true, false, 0x1234);
d.Sample(3000, false, false, 0x1234);
Check(AutoIdPolicy.InDefer(3000 + S + D - 1, d.SettleUntilMs, false), "death: deferred");
Check(!AutoIdPolicy.InDefer(3000 + S + D, d.SettleUntilMs, false), "death: defer ends");
// A landblock jump without portal space defers.
var j = new WorldTransitionState();
j.Sample(1000, false, false, 0x00AE);
j.Sample(1100, false, false, 0xA9B4);
Check(AutoIdPolicy.InDefer(1100 + S + D - 1, j.SettleUntilMs, false), "landblock jump: deferred");
// A PlayerTeleport message (a recall into the next landblock) defers.
var t = new WorldTransitionState();
t.Sample(1000, false, false, 0x1234);
t.OnTeleportMessage(5000);
Check(AutoIdPolicy.InDefer(5000 + S + D - 1, t.SettleUntilMs, false), "teleport message: deferred");
Check(!AutoIdPolicy.InDefer(5000 + S + D, t.SettleUntilMs, false), "teleport message: defer ends");
// In a transition right now: deferred whatever the settle time says.
Check(AutoIdPolicy.InDefer(1, 0, inTransition: true), "in a transition: deferred");
}
// ---- where an object is ------------------------------------------------------------
private static void AutoIdClassify()
{
_case = "autoid classify";
const uint Me = 0x50000001, Corpse = 0x80000100, Pack = 0x80000200, Monster = 0x80000300, Chest = 0x80000400;
Check(AutoIdPolicy.Classify(false, Me, Corpse, Corpse, 0, 0) == C.Unknown, "not in the snapshot: unknown");
Check(AutoIdPolicy.Classify(true, Me, 0, Me, 0, 0) == C.Inventory, "in the main pack");
Check(AutoIdPolicy.Classify(true, Me, 0, 0, Me, 0) == C.Inventory, "worn");
Check(AutoIdPolicy.Classify(true, Me, 0, Pack, 0, Me) == C.Inventory, "in a side pack");
Check(AutoIdPolicy.Classify(true, Me, Pack, Pack, 0, Me) == C.Inventory, "in an opened own side pack: inventory");
Check(AutoIdPolicy.Classify(true, Me, Corpse, Corpse, 0, 0) == C.Container, "in the open corpse");
Check(AutoIdPolicy.Classify(true, Me, Chest, Pack, 0, Chest) == C.Container, "in a pack inside the open chest");
Check(AutoIdPolicy.Classify(true, Me, Chest, Corpse, 0, 0) == C.World, "in a corpse that is not open");
Check(AutoIdPolicy.Classify(true, Me, 0, 0, 0, 0) == C.World, "on the ground, nothing open");
Check(AutoIdPolicy.Classify(true, Me, Corpse, 0, 0, 0) == C.World, "on the ground while a corpse is open (container 0 is not the open one)");
Check(AutoIdPolicy.Classify(true, Me, Corpse, 0, Monster, 0) == C.World, "wielded by a monster");
Check(AutoIdPolicy.Classify(true, 0, 0, 0, 0, 0) == C.World, "player unknown: nothing is inventory");
}
private static void AutoIdModeParse()
{
_case = "autoid mode parse";
Check(AutoIdPolicy.TryParseMode("ALL", out AutoIdMode m) && m == AutoIdMode.All, "all");
Check(AutoIdPolicy.TryParseMode(" limited ", out m) && m == AutoIdMode.Limited, "limited");
Check(AutoIdPolicy.TryParseMode("off", out m) && m == AutoIdMode.Off, "off");
Check(!AutoIdPolicy.TryParseMode("sometimes", out m) && m == AutoIdPolicy.DefaultMode, "unknown: false, default");
foreach (AutoIdMode mode in Enum.GetValues<AutoIdMode>())
Check(AutoIdPolicy.TryParseMode(AutoIdPolicy.Name(mode), out m) && m == mode, $"{mode} round-trips by name");
foreach (AutoIdMode mode in Enum.GetValues<AutoIdMode>())
Check(AutoIdPolicy.TryParseMode(mode.ToString(), out m) && m == mode, $"{mode} round-trips as engine.json writes it");
}
// ---- the engine-send marker --------------------------------------------------------
private static void IdMarkerScopes()
{
_case = "id marker";
Check(EngineSendMarker.Current == IdRequester.None, "no marker outside a scope");
using (EngineSendMarker.Enter(IdRequester.Plugin))
{
Check(EngineSendMarker.Current == IdRequester.Plugin, "marked inside");
using (EngineSendMarker.Enter(IdRequester.AutoIdContainer))
Check(EngineSendMarker.Current == IdRequester.AutoIdContainer, "nested scope");
Check(EngineSendMarker.Current == IdRequester.Plugin, "outer marker restored");
IdRequester seenElsewhere = IdRequester.Self;
var th = new Thread(() => seenElsewhere = EngineSendMarker.Current);
th.Start();
th.Join();
Check(seenElsewhere == IdRequester.None, "another thread is not marked (thread-local)");
}
Check(EngineSendMarker.Current == IdRequester.None, "cleared after the scope");
try
{
using (EngineSendMarker.Enter(IdRequester.Ui))
throw new InvalidOperationException();
}
catch (InvalidOperationException) { }
Check(EngineSendMarker.Current == IdRequester.None, "cleared after an exception");
}
private static void IdMarkerRidesTheQueue()
{
_case = "id marker queue";
var q = new PendingIdQueue(8);
q.Enqueue(1, 1000, 1, MergeMax, 0, (byte)IdRequester.AutoIdContainer);
q.Enqueue(2, 1000, 1, MergeMax, 0, (byte)IdRequester.Plugin);
Check(q.Enqueue(1, 1100, 1, MergeMax, 0, (byte)IdRequester.Plugin) == PendingIdQueue.Result.Merged, "merged");
Check(q.TryDequeue(out var a) && a.Source == (byte)IdRequester.AutoIdContainer, "the requester rides with the entry; a merge keeps the first");
Check(q.TryDequeue(out var b) && b.Source == (byte)IdRequester.Plugin, "second entry's requester");
q.Enqueue(3, 1200, 1, MergeMax);
Check(q.TryDequeue(out var c) && c.Source == 0, "unmarked stays None");
}
private static void IdHeartbeatNames()
{
_case = "id heartbeat names";
foreach (IdRequester who in Enum.GetValues<IdRequester>())
{
string s = IdRequesters.Short(who) + "=";
foreach (string bad in new[] { "fps=", "plug=", "login=", "qd=" })
Check(!s.Contains(bad) && !bad.Contains(s), $"{who}: \"{s}\" vs {bad}");
if (who != IdRequester.None)
Check(IdRequesters.Label((uint)who).Length > 0, $"{who} has a flight label");
}
Check(IdRequesters.Label(0) == "" && IdRequesters.Label(99) == "", "no label for none or an unknown code");
var regex = new System.Text.RegularExpressions.Regex(@"hb #\d+ .*?fps=(\d+) .*?plug=(\d+)/s .*?login=(\d)(?:.*?qd=(\d+))?");
string sample = "autoid 60s: mode=limited sent tgt=1 ctr=2 inv=0 wld=0 plg=5 slf=0 ui=0 cli=3 tot=11 skip mode=900 age=4 defer=0 fresh=1 pend=2";
Check(!regex.IsMatch(sample), "the minute line does not match the launcher's heartbeat regex");
}
}

View file

@ -16,6 +16,8 @@
DumpInProgressRule.cs the launcher holds its wedge kill while an OOM dump is written (capped)
CastSlot.cs the cast slot refuses during a world transition
CrashExitRule.cs which exit codes are crash exits (not ExitProcess(-1))
AutoIdPolicy.cs AutoIdMode All/Limited/Off: class, minimum age, post-transition defer
IdRequester.cs the engine-send marker that tags every engine 0xC8
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
@ -40,6 +42,8 @@
<Compile Include="..\..\src\Shared\DumpInProgressRule.cs" Link="Shared\DumpInProgressRule.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\CastSlot.cs" Link="Engine\CastSlot.cs" />
<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\Net\IdRequester.cs" Link="Engine\IdRequester.cs" />
</ItemGroup>
</Project>

View file

@ -42,6 +42,8 @@ internal static partial class Program
RunRingAndGateTests();
RunAutoIdLimitTests();
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
return _failed == 0 ? 0 : 1;
}

View file

@ -23,6 +23,7 @@
<Compile Include="..\..\src\RynthCore.Engine\Plugins\EngineSettings.cs" Link="Engine\EngineSettings.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Plugins\EngineSettingsFile.cs" Link="Engine\EngineSettingsFile.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ReloadCapNotice.cs" Link="Engine\ReloadCapNotice.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\AutoIdPolicy.cs" Link="Engine\AutoIdPolicy.cs" />
</ItemGroup>
</Project>

View file

@ -47,6 +47,7 @@ namespace EngineSettingsTests
Run(nameof(OwnedKeysMatchEngineSettings), OwnedKeysMatchEngineSettings);
Run(nameof(SaveKeepsLauncherKeys), SaveKeepsLauncherKeys);
Run(nameof(SaveRoundTripsOwnedKeys), SaveRoundTripsOwnedKeys);
Run(nameof(AutoIdModeRoundTrips), AutoIdModeRoundTrips);
Run(nameof(SaveWithoutFileWritesOwnedKeys), SaveWithoutFileWritesOwnedKeys);
Run(nameof(SaveLeavesMalformedFileAlone), SaveLeavesMalformedFileAlone);
Run(nameof(MaxHotReloadsReadAndKept), MaxHotReloadsReadAndKept);
@ -83,7 +84,12 @@ namespace EngineSettingsTests
case "imgui-off": EngineSettings.EnableImGuiBackend = false; break;
case "dcclose-off": EngineSettings.CloseOnServerDisconnect = false; break;
case "dcclose-on": EngineSettings.CloseOnServerDisconnect = true; break;
case "autoid":
if (!RynthCore.Engine.Compatibility.AutoIdPolicy.TryParseMode(args[1], out var aim)) throw new ArgumentException(args[1]);
EngineSettings.AutoIdMode = aim;
break;
case "dump":
Console.WriteLine("AutoIdMode=" + EngineSettings.AutoIdMode);
Console.WriteLine("PluginPaths=" + string.Join("|", EngineSettings.PluginPaths));
Console.WriteLine("StartTooltip=" + EngineSettings.IsUiHookEnabled("StartTooltip"));
Console.WriteLine("DecalBridge=" + EngineSettings.DecalBridgeMode);
@ -216,6 +222,33 @@ namespace EngineSettingsTests
Check(ReadJson(path).TryGetProperty("EnableDcompOverlay", out _), "launcher key still there");
}
private static void AutoIdModeRoundTrips()
{
string dir = NewDir("autoid");
string path = Path.Combine(dir, "engine.json");
File.WriteAllText(path, LauncherFile);
var (exit, output) = RunChild(path, "dump");
Eq(exit, 0, "dump");
Check(output.Contains("AutoIdMode=Limited"), "default is Limited: " + output);
Eq(RunChild(path, "autoid", "off").Exit, 0, "set off");
Eq(ReadJson(path).GetProperty("AutoIdMode").GetString(), "Off", "saved as \"Off\"");
(exit, output) = RunChild(path, "dump");
Check(output.Contains("AutoIdMode=Off"), "Off read back: " + output);
Eq(RunChild(path, "autoid", "all").Exit, 0, "set all");
(exit, output) = RunChild(path, "dump");
Check(output.Contains("AutoIdMode=All"), "All read back: " + output);
Eq(RunChild(path, "autoid", "limited").Exit, 0, "back to limited");
Check(!ReadJson(path).TryGetProperty("AutoIdMode", out _), "the default leaves the key out");
Check(ReadJson(path).TryGetProperty("EnableDcompOverlay", out _), "launcher key still there");
File.WriteAllText(path, LauncherFile.Replace("\"LoggingLevel\"", "\"AutoIdMode\": \"bogus\", \"LoggingLevel\""));
(exit, output) = RunChild(path, "dump");
Check(output.Contains("AutoIdMode=Limited"), "an unknown value reads as the default: " + output);
}
private static void SaveWithoutFileWritesOwnedKeys()
{
string dir = NewDir("nofile");

View file

@ -34,6 +34,7 @@
<Compile Include="..\..\src\RynthCore.Engine\Net\FlightRing.cs" Link="Engine\FlightRing.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Net\FlightCapture.cs" Link="Engine\FlightCapture.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Net\FlightFormat.cs" Link="Engine\FlightFormat.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Net\IdRequester.cs" Link="Engine\IdRequester.cs" />
<Compile Include="..\NetMessageTests\WireBuilder.cs" Link="WireBuilder.cs" />
</ItemGroup>

View file

@ -30,6 +30,7 @@ internal static unsafe class Program
RetransmitDedupe();
ResendRequestMarker();
EngineTagging();
IdentifyTagging();
EngineRepeatFolding();
DetectUseRefusal();
@ -378,6 +379,64 @@ internal static unsafe class Program
Has(engineLines, "engine UseObject(0x80068ACE, 0)", "engine call markers written");
}
private static byte[] Identify(uint obj) => Action(0x00C8, new Body().U32(obj));
private static void IdentifyTagging()
{
Case("capture: an IdentifyObject is [eng:<who>] after an engine send for that id, otherwise [cli]");
var c = NewCapture();
LoginAs(c);
int marks = Count(c, FlightDir.Mark);
c.EngineSend((byte)IdRequester.AutoIdContainer, Corpse);
Eq(Count(c, FlightDir.Mark), marks, "an engine send writes no marker line");
_t += 30;
Out(c, Identify(Corpse));
Has(Last(c), "[eng:autoid-container] IdentifyObject 0x80068ACE", "autoid container send");
Eq(c.IdentifyForeignTotal, 0L, "not counted as foreign");
Out(c, Identify(Corpse));
Has(Last(c), "[cli] IdentifyObject", "a second 0xC8 with no engine send is AC's or Decal's");
Eq(c.IdentifyForeignTotal, 1L, "counted as foreign");
c.EngineSend((byte)IdRequester.Plugin, Other);
Out(c, Identify(Corpse));
Has(Last(c), "[cli]", "an engine send for another id does not tag this one");
Out(c, Identify(Other));
Has(Last(c), "[eng:plugin] IdentifyObject 0x80012345", "plugin send matched by id");
c.EngineSend((byte)IdRequester.AutoIdTarget, Other);
_t += FlightCapture.EngineMatchMs + 1;
Out(c, Identify(Other));
Has(Last(c), "[cli]", "too late to match");
c.EngineSend((byte)IdRequester.AutoIdTarget, Other);
c.EngineSend((byte)IdRequester.AutoIdInventory, Other);
Out(c, Identify(Other));
Has(Last(c), "[eng:autoid-target]", "two sends for one id: the older first");
Out(c, Identify(Other));
Has(Last(c), "[eng:autoid-inventory]", "then the newer");
c.EngineSend(0, Corpse);
Out(c, Identify(Corpse));
Has(Last(c), "[cli]", "a send without a requester is not registered");
// 64 sends in a burst do not push out other engine calls (their own table).
c.EngineCall("UseObject", Corpse, 0);
for (uint i = 0; i < 64; i++) c.EngineSend((byte)IdRequester.AutoIdWorld, 0x80100000 + i);
Out(c, Use(Corpse));
Has(Last(c), "[eng] Use", "an identify burst leaves the pending use intact");
Out(c, Identify(0x80100000 + 63));
Has(Last(c), "[eng:autoid-world]", "the newest send of the burst still matches");
Out(c, Identify(0x80100000));
Has(Last(c), "[eng:autoid-world]", "and so does the oldest: 64 sends inside the match window all keep their slot");
foreach (IdRequester who in Enum.GetValues<IdRequester>())
{
if (who == IdRequester.None) continue;
Check(IdRequesters.Label((byte)who).Length > 0, $"{who} has a label");
}
}
private static void EngineRepeatFolding()
{
Case("capture: identical engine calls within 1 s fold into one line plus a 'repeated' line");

View file

@ -98,6 +98,7 @@ ENQUEUE = "AcMainThreadQueue.Enqueue"
# (file, method) pairs, each verified to do no off-thread AC mutation.
ENQUEUE_PRODUCER_ALLOW = {
("AutoIdService.cs", "DrainTick"), # appraisal: enqueues 0xC8, sent on main thread in DrainRequestIds
("AutoIdService.cs", "DrainPending"), # DrainTick's backlog half: only EnqueueRequestId; reads the PWD snapshot
("RynthCoreChatCommands.cs", "Reply"), # /rc and /rv plates replies: only EnqueueWriteToChat
("AcMouseOver.cs", "Say"), # /rc acmouse watch lines: only EnqueueWriteToChat (and the log)
}