Snapshot for release 2026.10.21.3 (internal 04b831a)

This commit is contained in:
Tom Bohar 2026-10-21 21:03:43 -04:00
commit c4efe5821d
46 changed files with 2657 additions and 213 deletions

View file

@ -5,7 +5,9 @@
icons per row = ceil(icons / rows) capped at the limit, the clamps (rows 1-6, limit 0 or
2-30), the grip menu's icons-per-row steps (no limit above 30), the Settings picker index
maps, and the barlayout= row of panel_state.txt (a missing or bad row gives 1 row, no limit).
No files, no ImGui. Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
The open highlight (src\RynthCore.Engine\UI\BarOpenState.cs, compiled in): the window each
button stands for (a script window by its panel key, not its title) and a menu button (ILT,
Scripts) lit while any window it lists is open. No files, no ImGui. Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
@ -18,6 +20,7 @@
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\UI\BarLayout.cs" Link="Engine\BarLayout.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\BarOpenState.cs" Link="Engine\BarOpenState.cs" />
</ItemGroup>
</Project>

View file

@ -22,6 +22,7 @@ internal static class Program
StepMaxPerRow();
PickerIndexes();
ParseAndFormat();
OpenState();
Console.WriteLine();
Console.WriteLine(_fails == 0 ? $"PASS ({_asserts} checks)" : $"FAIL ({_fails} of {_asserts} checks failed)");
return _fails == 0 ? 0 : 1;
@ -111,4 +112,43 @@ internal static class Program
Check(!BarLayout.TryParse("two,8", out r, out m) && r == 1 && m == 0, "not a number: defaults");
Check(!BarLayout.TryParse("2,8,1", out r, out m) && r == 1 && m == 0, "three values: defaults");
}
private static void OpenState()
{
Console.WriteLine("OpenState");
// What ImGuiPanelHost would say: these panels open (case-insensitive, like its set).
// A popped-out panel is in the set too (pop out never closes it).
var openSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Chat", "Mini Remote", "script:rynthsort", "Guardian" };
Func<string, bool> isOpen = openSet.Contains;
// Which window a one-window button stands for.
Eq(BarOpenState.KeyFor("Chat", null), "Chat", "an engine panel: its title");
Eq(BarOpenState.KeyFor("Mini Remote", ""), "Mini Remote", "an empty panel key reads as none");
Eq(BarOpenState.KeyFor("RynthSort", "script:rynthsort"), "script:rynthsort", "a script window: its panel key, not its title");
// One-window buttons.
Check(BarOpenState.IsOpen(BarOpenState.KeyFor("Chat", null), isOpen), "an open panel's button is lit");
Check(BarOpenState.IsOpen(BarOpenState.KeyFor("Mini Remote", null), isOpen), "the remote open: its button is lit");
Check(!BarOpenState.IsOpen(BarOpenState.KeyFor("Radar", null), isOpen), "a closed panel's button is not");
Check(BarOpenState.IsOpen(BarOpenState.KeyFor("RynthSort", "script:rynthsort"), isOpen), "an open script window's button is lit");
Check(!BarOpenState.IsOpen(BarOpenState.KeyFor("Oracle", "script:oracle"), isOpen), "a closed script window's button is not");
Check(!BarOpenState.IsOpen("", isOpen), "an empty key is never open");
Check(BarOpenState.IsOpen("chat", isOpen), "the open check's case rules apply (the host's set ignores case)");
// Menu buttons: lit while any window they list is open.
Check(BarOpenState.AnyOpen(new[] { "Bounties", "Guardian" }, isOpen), "ILT: Guardian open lights the ILT button");
Check(!BarOpenState.AnyOpen(new[] { "Bounties" }, isOpen), "ILT: only Bounties, closed");
Check(BarOpenState.AnyOpen(new[] { "script:lua/a", "script:rynthsort" }, isOpen), "Scripts: one window open is enough");
Check(!BarOpenState.AnyOpen(new[] { "script:lua/a", "script:lua/b" }, isOpen), "Scripts: none open");
Check(!BarOpenState.AnyOpen(Array.Empty<string>(), isOpen), "a menu with nothing listed is not lit");
// The open check is asked once a key, and the search stops at the first open one.
int asked = 0;
Func<string, bool> counting = k => { asked++; return openSet.Contains(k); };
BarOpenState.AnyOpen(new[] { "Guardian", "Bounties", "Radar" }, counting);
Eq(asked, 1, "stops at the first open window");
asked = 0;
BarOpenState.AnyOpen(new[] { "Radar", "", "Bounties" }, counting);
Eq(asked, 2, "every key asked once when none is open; an empty key not at all");
}
}

View file

@ -22,7 +22,9 @@
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
report names the plugin call the pump is inside; PluginShutdownGate:
plugins are shut down only once the pump stopped (plus source scans
of EngineLifecycle's step order and ShutdownAll's gate)
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>

View file

@ -50,6 +50,7 @@ internal static partial class Program
RunAutoIdDrainTests();
RunPumpGuardTests();
RunShutdownOrderTests();
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
return _failed == 0 ? 0 : 1;

View file

@ -0,0 +1,114 @@
using System.Text.RegularExpressions;
using RynthCore.Engine.Plugins;
namespace EngineRobustnessTests;
/// <summary>
/// Plugins are shut down only once the plugin pump has stopped (audit 2026-10-21, 01 #1):
/// PluginShutdownGate's verdicts (Plugins/PumpGuards.cs), and source scans that
/// EngineLifecycle.Shutdown stops the pump before any step that shuts a plugin down, and that
/// PluginManager.ShutdownAll asks the gate before it calls a plugin.
/// </summary>
internal static partial class Program
{
private static void RunShutdownOrderTests()
{
ShutdownGateVerdicts();
ShutdownGateRefusalLine();
LifecycleStopsPumpBeforePlugins();
ShutdownAllAsksTheGateFirst();
}
private static void ShutdownGateVerdicts()
{
_case = "shutdown gate";
Check(PluginShutdownGate.Decide(pumpStarted: false, pumpExited: false, onPumpThread: false) == PluginShutdownGate.Verdict.NoPump,
"no pump started: plugins may be shut down");
Check(PluginShutdownGate.Decide(true, true, false) == PluginShutdownGate.Verdict.PumpStopped, "pump left its loop: stopped");
Check(PluginShutdownGate.Decide(true, false, true) == PluginShutdownGate.Verdict.OnPumpThread, "on the pump thread itself");
Check(PluginShutdownGate.Decide(true, false, false) == PluginShutdownGate.Verdict.PumpStillRunning,
"pump still running on another thread");
Check(PluginShutdownGate.MayShutDownPlugins(PluginShutdownGate.Verdict.NoPump), "NoPump allows");
Check(PluginShutdownGate.MayShutDownPlugins(PluginShutdownGate.Verdict.PumpStopped), "PumpStopped allows");
Check(PluginShutdownGate.MayShutDownPlugins(PluginShutdownGate.Verdict.OnPumpThread), "OnPumpThread allows (no frame alongside)");
Check(!PluginShutdownGate.MayShutDownPlugins(PluginShutdownGate.Verdict.PumpStillRunning),
"a pump still in a frame refuses: no Shutdown alongside a Tick");
int wait = PluginShutdownGate.ShutdownWaitMs;
Check(wait >= 1000 && wait <= 10000, $"the extra wait is bounded (1-10 s), got {wait} ms");
}
private static void ShutdownGateRefusalLine()
{
_case = "shutdown gate line";
string line = PluginShutdownGate.DescribeRefusal(3, "inside RynthAi Tick for 4200 ms");
Check(line.Contains("inside RynthAi Tick for 4200 ms"), "names what the pump is inside");
Check(line.Contains("3 plugin(s) NOT shut down"), "says how many plugins were left alone");
Check(PluginShutdownGate.DescribeRefusal(1, null).Contains("no plugin call named"), "no dispatch: says so");
}
/// <summary>
/// The pump stops (TickPump.StopAndJoin) once, after the queues are disarmed and before
/// every step that can shut a plugin down or tear down what its tick reads.
/// </summary>
private static void LifecycleStopsPumpBeforePlugins()
{
_case = "shutdown order";
string? engine = FindRepoDir(Path.Combine("src", "RynthCore.Engine"));
Check(engine != null, "found src\\RynthCore.Engine by walking up");
if (engine == null) return;
string src = File.ReadAllText(Path.Combine(engine, "EngineLifecycle.cs"));
int start = src.IndexOf("public static void Shutdown()", StringComparison.Ordinal);
Check(start >= 0, "EngineLifecycle.Shutdown found");
if (start < 0) return;
var steps = new List<string>();
foreach (Match m in Regex.Matches(src[start..], "Step\\(\"([^\"]+)\""))
steps.Add(m.Groups[1].Value);
int pump = steps.IndexOf("TickPump.StopAndJoin");
Check(pump >= 0, "the pump is stopped");
Check(steps.FindAll(s => s == "TickPump.StopAndJoin").Count == 1, "exactly once");
foreach (string before in new[] { "AcMainThreadQueue.Disarm", "UiDataHub.Disarm" })
{
int at = steps.IndexOf(before);
Check(at >= 0 && at < pump, $"{before} still comes first");
}
foreach (string after in new[] { "AcUiPassHook.Uninstall", "VideoPatch.Uninstall", "EndSceneHook.Uninstall",
"DecalBridgeHost.Shutdown", "PluginManager.ShutdownAll (defensive)",
"EngineThreads.StopAndJoinAll", "ManagedPlugins.UnloadRetired" })
{
int at = steps.IndexOf(after);
Check(at > pump, $"the pump stops before {after} (pump at {pump}, {after} at {at})");
}
}
/// <summary>ShutdownAll asks PluginShutdownGate (through EntryPoint) before UnloadAllPlugins, and returns on a refusal.</summary>
private static void ShutdownAllAsksTheGateFirst()
{
_case = "ShutdownAll gate";
string? plugins = FindRepoDir(Path.Combine("src", "RynthCore.Engine", "Plugins"));
Check(plugins != null, "found src\\RynthCore.Engine\\Plugins by walking up");
if (plugins == null) return;
string src = File.ReadAllText(Path.Combine(plugins, "PluginManager.cs")).Replace("\r\n", "\n");
int start = src.IndexOf("public static void ShutdownAll()", StringComparison.Ordinal);
Check(start >= 0, "ShutdownAll found");
if (start < 0) return;
int end = src.IndexOf("\n }\n", start, StringComparison.Ordinal);
string body = end > start ? src[start..end] : src[start..];
int gate = body.IndexOf("EntryPoint.StopTickPumpForPluginShutdown(", StringComparison.Ordinal);
int refuse = body.IndexOf("PluginShutdownGate.MayShutDownPlugins(gate)", StringComparison.Ordinal);
int unload = body.IndexOf("UnloadAllPlugins();", StringComparison.Ordinal);
Check(gate >= 0 && refuse > gate, "asks the gate");
Check(unload > refuse, "before any plugin is called (UnloadAllPlugins)");
int ret = refuse < 0 ? -1 : body.IndexOf("return;", refuse, StringComparison.Ordinal);
Check(ret > refuse && ret < unload, "returns without calling the plugins on a refusal");
string? engine = Path.GetDirectoryName(plugins);
string entry = File.ReadAllText(Path.Combine(engine!, "EntryPoint.cs")).Replace("\r\n", "\n");
int stop = entry.IndexOf("internal static bool StopTickPumpAndJoin(", StringComparison.Ordinal);
Check(stop >= 0, "StopTickPumpAndJoin found");
if (stop < 0) return;
int flag = entry.IndexOf("Interlocked.Exchange(ref _tickPumpStopRequested, 1);", stop, StringComparison.Ordinal);
int nullCheck = entry.IndexOf("if (_tickPumpThread == null)", stop, StringComparison.Ordinal);
Check(flag > stop && flag < nullCheck, "the stop flag is set before the no-pump early return (a late pump exits at once)");
}
}

View file

@ -28,11 +28,13 @@
<Compile Include="..\..\src\RynthCore.App\InjectionMode.cs" Link="App\InjectionMode.cs" />
<Compile Include="..\..\src\RynthCore.App\LaunchAccountProfile.cs" Link="App\LaunchAccountProfile.cs" />
<Compile Include="..\..\src\RynthCore.App\AccountPasswordProtection.cs" Link="App\AccountPasswordProtection.cs" />
<Compile Include="..\..\src\RynthCore.App\SavedPasswordReveal.cs" Link="App\SavedPasswordReveal.cs" />
<Compile Include="..\..\src\RynthCore.App\LaunchServerProfile.cs" Link="App\LaunchServerProfile.cs" />
<Compile Include="..\..\src\RynthCore.App\KnownServerCatalog.cs" Link="App\KnownServerCatalog.cs" />
<Compile Include="..\..\src\RynthCore.App\AcLaunchArgumentBuilder.cs" Link="App\AcLaunchArgumentBuilder.cs" />
<Compile Include="..\..\src\RynthCore.App\AcClientCommandLine.cs" Link="App\AcClientCommandLine.cs" />
<Compile Include="..\..\src\RynthCore.App\FirstLoginRules.cs" Link="App\FirstLoginRules.cs" />
<Compile Include="..\..\src\RynthCore.App\AccountServerRules.cs" Link="App\AccountServerRules.cs" />
<Compile Include="..\..\src\RynthCore.App\UserPrefsSwapRecovery.cs" Link="App\UserPrefsSwapRecovery.cs" />
<Compile Include="..\..\src\RynthCore.App\CrashDumpWriterRule.cs" Link="App\CrashDumpWriterRule.cs" />
</ItemGroup>

View file

@ -373,6 +373,48 @@ internal static class Program
Check(FirstLoginRules.Problem("", "pw", "pw", false, AcEmulatorKind.Ace) != null, "a name is required");
});
// Deleting a server profile re-pointed its accounts at the first remaining server, so the
// next launch sent one server's password to another (audit 2026-10-21 F2).
Scenario("server profiles: an account logs on only to its own server", root, () =>
{
var conquest = new LaunchServerProfile { Id = "conq", Name = "Conquest", Host = "conquest.example", Port = 9000 };
var ilt = new LaunchServerProfile { Id = "ilt", Name = "Infinite Leaftide", Host = "ilt.example", Port = 9000 };
var servers = new List<LaunchServerProfile> { conquest, ilt };
var onConquest = new LaunchAccountProfile { Id = "a", AccountName = "SK", ServerId = "conq" };
var onConquest2 = new LaunchAccountProfile { Id = "b", AccountName = "Buffi", Alias = "Buffer", ServerId = "CONQ" };
var onIlt = new LaunchAccountProfile { Id = "c", AccountName = "SK", ServerId = "ilt" };
var never = new LaunchAccountProfile { Id = "d", AccountName = "New" };
var dangling = new LaunchAccountProfile { Id = "e", AccountName = "Old", ServerId = "deleted-elsewhere" };
var accounts = new List<LaunchAccountProfile> { onConquest, onConquest2, onIlt, never, dangling };
Check(AccountServerRules.ServerFor(onConquest, servers) == conquest, "its own server");
Check(AccountServerRules.ServerFor(onConquest2, servers) == conquest, "the id is matched ignoring case");
Check(AccountServerRules.ServerFor(onIlt, servers) == ilt, "the same name on another server: that server");
Check(AccountServerRules.ServerFor(never, servers) == null, "no server set: none (not the first or the selected one)");
Check(AccountServerRules.ServerFor(dangling, servers) == null, "a server that is gone: none, never another server");
Check(AccountServerRules.ServerFor(dangling, new List<LaunchServerProfile> { ilt }) == null, "not even when only one server is left");
Check(AccountServerRules.ServerFor(onConquest, new List<LaunchServerProfile>()) == null, "no servers at all: none");
Check(AccountServerRules.AccountsOn(conquest, accounts).Select(a => a.Id).SequenceEqual(new[] { "a", "b" }), "Conquest's accounts: a and b");
string? blocker = AccountServerRules.DeleteBlocker(conquest, accounts);
Check(blocker != null && blocker.Contains("2 account(s)") && blocker.Contains("SK") && blocker.Contains("Buffer (Buffi)"),
"deleting a server with accounts is refused, naming them: " + blocker);
Check(blocker != null && !blocker.Contains("Old") && !blocker.Contains("New"), "only that server's accounts are named");
var unused = new LaunchServerProfile { Id = "spare", Name = "Spare", Host = "h", Port = 1 };
Check(AccountServerRules.DeleteBlocker(unused, accounts) == null, "a server no account uses can be deleted");
// The refusal leaves every account as it was (nothing re-pointed).
Check(accounts.Select(a => a.ServerId).SequenceEqual(new[] { "conq", "CONQ", "ilt", "", "deleted-elsewhere" }), "no account was changed");
var many = Enumerable.Range(1, 12).Select(i => new LaunchAccountProfile { AccountName = "Acc" + i, ServerId = "ilt" }).ToList();
string? manyBlocker = AccountServerRules.DeleteBlocker(ilt, many);
Check(manyBlocker != null && manyBlocker.Contains("12 account(s)") && manyBlocker.Contains("4 more") && !manyBlocker.Contains("Acc9"),
"a long list names 8 and counts the rest");
Check(AccountServerRules.NoServerMessage(dangling, anyServerProfiles: true).Contains("pick the server"), "no-server launch message says what to do");
Check(AccountServerRules.NoServerMessage(never, anyServerProfiles: false).Contains("Add a server profile"), "with no servers at all: add one");
});
// A saved UserPreferences.ini whose display mode the PC can't use made every launch
// fail with "Could not initialize Direct3D"; a quick exit must undo that swap.
Scenario("prefs swap: did the swap change the live file", root, () =>
@ -464,6 +506,8 @@ internal static class Program
}
ClientCommandLineChecks();
ExtraLaunchArgumentChecks();
PasswordEyeChecks();
Console.WriteLine(_failed == 0
? $"PASS: {_checks} checks"
@ -492,6 +536,10 @@ internal static class Program
// exactly as ThwargLauncher writes it.
string special = "Aa1!@#$%^&*()_+-=[]{}|\\:;'<>,.?/~`" + "Zz9\\\\end\\";
Check(AcClientCommandLine.Token(special) == special, "no space, no quote: the password as it is");
// The saved form (DPAPI over UTF-8, base64) gives every one of these characters back.
foreach (string pw in new[] { special, "Aa1!@#$%^&*(_+-=[]{}|\\:;'<>,.?/~`*Zz9" + new string('(', 3) + "**", "€£§°´¨ü x" })
Check(AccountPasswordProtection.TryUnprotect(AccountPasswordProtection.Protect(pw), out string back) && back == pw,
"saved and read back unchanged: " + pw.Length + " characters");
Check(ReadsBack(special, special), "and the client reads it back");
// Quote marks: the client drops them whatever the launcher does; with them left out the rest
@ -531,6 +579,117 @@ internal static class Program
Check(ours > 3500 && thwargSame > 100, $"random passwords: {ours} read back, {thwargSame} the same as ThwargLauncher's");
}
// ── Extra Launch Arguments ───────────────────────────────────────────────
// Labelled "appended", the box replaced the whole command line (account, password and host);
// it now appends to every launch, so it may not carry the login switches (audit 2026-10-21 F10).
private static void ExtraLaunchArgumentChecks()
{
Console.WriteLine("-- extra launch arguments");
var account = new LaunchAccountProfile { AccountName = "SK" };
account.SetPassword("pw x");
string built = new AcLaunchArgumentBuilder().BuildArguments(Server(AcEmulatorKind.Ace), account);
Check(AcLaunchArgumentBuilder.ExtraArgumentsProblem(null, out string none) == null && none == "", "none: fine, nothing added");
Check(AcLaunchArgumentBuilder.ExtraArgumentsProblem(" \r\n\t ", out string blank) == null && blank == "", "only blanks: fine, nothing added");
Check(AcLaunchArgumentBuilder.WithExtraArguments(built, "") == built, "nothing added: the account's line unchanged");
Check(AcLaunchArgumentBuilder.ExtraArgumentsProblem("-nointro\r\n-w \"My Window\"", out string extra) == null && extra == "-nointro -w \"My Window\"",
"line breaks become spaces: " + extra);
string line = AcLaunchArgumentBuilder.WithExtraArguments(built, extra);
List<string>? args = AcClientCommandLine.Split(line);
Check(line.StartsWith(built + " ", StringComparison.Ordinal), "appended after the account's own arguments, not instead of them");
Check(args != null && ArgAfter(args, "-a") == "SK" && ArgAfter(args, "-v") == "pw x" && ArgAfter(args, "-h") == "127.0.0.1:9000",
"the client still reads this account, its password and its server");
Check(args != null && args.Contains("-nointro") && ArgAfter(args, "-w") == "My Window", "and the extra arguments");
// An old whole-line override saved in the box: refused rather than appended to every account.
foreach (string sw in new[] { "-a", "-v", "-h", "-p", "-rodat", "-A", "-RODAT" })
{
string? problem = AcLaunchArgumentBuilder.ExtraArgumentsProblem($"-nointro {sw} other", out string n);
Check(problem != null && n == "" && problem.Contains(sw, StringComparison.OrdinalIgnoreCase), $"{sw} refused: {problem}");
}
Check(AcLaunchArgumentBuilder.ExtraArgumentsProblem("-a acct -v secret -h other.example:9000", out _) is string old && !old.Contains("secret"),
"a saved old override is refused, and the message doesn't repeat its password");
Check(AcLaunchArgumentBuilder.ExtraArgumentsProblem("-host -apple \"-a b\"", out string lookalike) == null && lookalike.Length > 0,
"switches that only start like a login switch, or a quoted value with one inside, are fine");
Check(AcLaunchArgumentBuilder.ExtraArgumentsProblem("-w \"open", out _)?.Contains("quote") == true,
"a quote left open is refused (the client would drop the whole line, login included)");
}
// ── The "show password" eye ──────────────────────────────────────────────
// Player request (2026-10-21): the account editor's box starts empty ("leave blank to keep the
// saved password") and the saved password was never shown. SavedPasswordReveal: the eye fills an
// empty box with the saved password and empties it again if unchanged; saving it unchanged keeps
// the saved one as it is.
private static void PasswordEyeChecks()
{
Console.WriteLine("-- the show-password eye");
const string Saved = "s3cret pw ü\\\"";
var account = new LaunchAccountProfile { AccountName = "A" };
account.SetPassword(Saved);
string blob = account.PasswordProtected;
var eye = SavedPasswordReveal.For(account);
Check(eye.EyeOn("") == Saved && eye.FilledFromSaved, "eye on, box empty: the saved password, decrypted now");
Check(eye.PasswordToSave(Saved) == null, "saved while shown and unchanged: the saved password is kept");
Check(eye.EyeOff(Saved) == "" && !eye.FilledFromSaved, "eye off, unchanged: the box is empty again (blank = keep)");
Check(eye.PasswordToSave("") == null && eye.PasswordToSave(null) == null, "blank box: kept");
ApplySave(account, eye, "");
Check(account.PasswordProtected == blob, "Save with a blank box: the blob is the same");
Check(eye.EyeOn("") == Saved, "fill, then Save while it's shown");
ApplySave(account, eye, Saved);
Check(account.PasswordProtected == blob, "Save with the shown password unchanged: nothing re-encrypted, the blob is the same");
Check(account.TryGetPasswordForLaunch(out string still, out _) && still == Saved, "and it still decrypts to the saved password");
Check(eye.EyeOn("") == Saved, "fill again");
Check(eye.EyeOff(Saved + "x") == Saved + "x" && eye.PasswordToSave(Saved + "x") == Saved + "x", "edited: stays in the box and is saved as the new password");
Check(eye.EyeOn("") == Saved && eye.EyeOff("") == "", "filled, then emptied by the player: stays empty");
Check(eye.EyeOn("") == Saved && eye.PasswordToSave("other") == "other", "filled, replaced while shown: the new one is saved");
eye.EyeOff("other");
Check(eye.EyeOn("typed") == "typed" && !eye.FilledFromSaved, "eye on with something typed: only reveals it");
Check(eye.EyeOff("typed") == "typed" && eye.PasswordToSave("typed") == "typed", "eye off: what was typed stays and is saved");
Check(eye.EyeOn(Saved) == Saved && eye.EyeOff(Saved) == Saved, "the saved password typed by hand is not taken for the eye's fill");
eye.EyeOn("");
eye.Reset();
Check(!eye.FilledFromSaved && eye.PasswordToSave(Saved) == Saved, "after Reset the fill is forgotten (at most re-encrypts the same text)");
ApplySave(account, eye, "new pw");
Check(account.TryGetPasswordForLaunch(out string got, out _) && got == "new pw", "a new password typed: saved");
var none = new LaunchAccountProfile { AccountName = "B" };
var noneEye = SavedPasswordReveal.For(none);
Check(noneEye.EyeOn("") == "" && !noneEye.FilledFromSaved, "no saved password: nothing to fill");
Check(noneEye.EyeOn("x") == "x", "no saved password: reveals what's typed");
// Settings copied from another Windows user or PC: the blob doesn't decrypt here.
var copied = new LaunchAccountProfile { AccountName = "C", PasswordProtected = Convert.ToBase64String(new byte[64]) };
var copiedEye = SavedPasswordReveal.For(copied);
Check(copiedEye.EyeOn("") == "" && !copiedEye.FilledFromSaved, "unreadable saved password: nothing filled in");
Check(copied.PasswordNeedsReentry, "and the profile says it needs re-entering");
Check(copiedEye.EyeOn("") == "" && copiedEye.EyeOn("retyped") == "retyped", "needs re-entering: the eye only reveals what's typed");
Check(copiedEye.PasswordToSave("retyped") == "retyped", "the retyped password is saved");
var legacy = new LaunchAccountProfile { AccountName = "D", LegacyPlainPassword = "legacy pw" };
Check(SavedPasswordReveal.For(legacy).EyeOn("") == "legacy pw", "a not-yet-migrated plain password is shown too");
// The eye keeps no copy of the password: no string field, only the "filled" flag.
Check(typeof(SavedPasswordReveal).GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)
.All(f => f.FieldType != typeof(string)), "SavedPasswordReveal holds no string");
Check(SavedPasswordReveal.ShowTip.Length < 20 && SavedPasswordReveal.HideTip.Length < 20, "short tooltips");
}
/// <summary>The account editor's Save for the password box (AccountProfileDialog.SaveAndClose).</summary>
private static void ApplySave(LaunchAccountProfile profile, SavedPasswordReveal eye, string? boxText)
{
if (eye.PasswordToSave(boxText) is string newPassword)
profile.SetPassword(newPassword);
eye.Reset();
}
/// <summary>The launcher's ACE line for <paramref name="password"/>, read back by acclient's rules.</summary>
private static bool ReadsBack(string password, string expected)
{

View file

@ -23,6 +23,7 @@
<Compile Include="..\..\src\RynthCore.App.Avalonia\RynthUpdater.MapPacks.cs" Link="Linked\RynthUpdater.MapPacks.cs" />
<Compile Include="..\..\src\RynthCore.App.Avalonia\RynthUpdater.NavData.cs" Link="Linked\RynthUpdater.NavData.cs" />
<Compile Include="..\..\src\RynthCore.App.Avalonia\RynthUpdater.Available.cs" Link="Linked\RynthUpdater.Available.cs" />
<Compile Include="..\..\src\RynthCore.App.Avalonia\RynthUpdater.Rollback.cs" Link="Linked\RynthUpdater.Rollback.cs" />
<Compile Include="..\..\src\RynthCore.App.Avalonia\PluginNames.cs" Link="Linked\PluginNames.cs" />
<Compile Include="..\..\src\RynthCore.App\KnownServerCatalog.cs" Link="Linked\KnownServerCatalog.cs" />
<Compile Include="..\..\src\RynthCore.App\LaunchServerProfile.cs" Link="Linked\LaunchServerProfile.cs" />

View file

@ -8,7 +8,7 @@ using RynthCore.App.Avalonia;
// Tests for the launcher's Available plugins list, plugin installs (verified, with progress and
// Cancel), Remove, old feeds without descriptions, the download meter, and the front page's
// update card. A throwaway signing key signs feeds served by a local HttpListener.
internal static class Program
internal static partial class Program
{
private static int _fails, _asserts;
private static void Check(bool cond, string msg)
@ -61,6 +61,7 @@ internal static class Program
await Run(nameof(TooNewUpdateIsHeldBack), TooNewUpdateIsHeldBack);
await Run(nameof(TooNewCompanionWaits), TooNewCompanionWaits);
await Run(nameof(MinEngineApiAtOrBelowInstalledIsFine), MinEngineApiAtOrBelowInstalledIsFine);
await RollbackTests();
}
finally
{
@ -275,7 +276,7 @@ internal static class Program
var f = Setup("olddesc", descriptions: false, extraPlugins: new[] { "RynthSomethingElse" });
var c = await f.Upd.CheckAsync(new[] { f.RynthAiPath });
Check(c.Manifest.Plugins.All(p => p.Description == ""), "an old feed parses with no descriptions");
Check(c.Available.Single(a => a.Entry.Name == "RynthOracle").Description == "Quests, character, titles and leaderboards.",
Check(c.Available.Single(a => a.Entry.Name == "RynthOracle").Description == "Quests, character and titles.",
"a missing description falls back to the launcher's table");
Check(c.Available.Single(a => a.Entry.Name == "RynthNav").Description.Contains("540 MB"), "RynthNav's says how big its map is");
Check(c.Available.Single(a => a.Entry.Name == "RynthSomethingElse").Description == "", "a plugin the table doesn't know: no description, still listed");

View file

@ -0,0 +1,255 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using RynthCore.App.Avalonia;
// Roll back (RynthUpdater.Rollback.cs): the earlier releases offered, their own signed manifests, what a
// rollback downloads and puts in place, and the hold afterwards.
internal static partial class Program
{
private const int RbInstalled = 2026100501; // the feed's release (WriteFeed), installed here
private static async Task RollbackTests()
{
await Run(nameof(RollbackReleaseNumbers), RollbackReleaseNumbers);
await Run(nameof(RollbackOffersVerifiedEarlierReleases), RollbackOffersVerifiedEarlierReleases);
await Run(nameof(RollbackRefusesForeignOrForwardManifests), RollbackRefusesForeignOrForwardManifests);
await Run(nameof(RollbackPreparesThenApplies), RollbackPreparesThenApplies);
await Run(nameof(RollbackFailedDownloadChangesNothing), RollbackFailedDownloadChangesNothing);
await Run(nameof(RollbackHoldsUntilANewerRelease), RollbackHoldsUntilANewerRelease);
await Run(nameof(RollbackHoldEndsWhenUpdatedByHand), RollbackHoldEndsWhenUpdatedByHand);
await Run(nameof(RollbackCardWhileHeld), RollbackCardWhileHeld);
}
private static Feed RollbackSetup(string tag)
{
Feed f = Setup(tag);
File.WriteAllText(Path.Combine(f.Dir, "app", "release.txt"), RbInstalled.ToString());
f.Upd.UpdatesDir = Path.Combine(f.Dir, "updates");
f.Upd.RollbackFloor = 2026100101;
return f;
}
private static string VersionOf(int release) =>
$"{release / 1000000}.{release / 10000 % 100}.{release / 100 % 100}.{release % 100}";
private static byte[] Envelope(Dictionary<string, object?> manifest, ECDsa? key = null)
{
key ??= Key;
byte[] payload = JsonSerializer.SerializeToUtf8Bytes(manifest);
byte[] sig = key.SignData(payload, HashAlgorithmName.SHA256, DSASignatureFormat.IeeeP1363FixedFieldConcatenation);
return Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new
{
payload = Convert.ToBase64String(payload),
signatures = new[] { new { key = RynthUpdater.KeyId(key.ExportSubjectPublicKeyInfo()), sig = Convert.ToBase64String(sig) } },
}));
}
/// <summary>
/// An earlier release's own signed manifest at releases/&lt;release&gt;/update.json, its installer and its
/// plugins (RynthAi, RynthChat, RynthNav as "v1"). <paramref name="claim"/>: the release written inside
/// (another one than its folder, for the test that refuses it).
/// </summary>
private static DateTime ServeRelease(string tag, int release, int? claim = null, ECDsa? key = null, string? tamper = null)
{
int inside = claim ?? release;
DateTime published = new(release / 1000000, release / 10000 % 100, release / 100 % 100, 12, 0, 0, DateTimeKind.Utc);
var plugins = new List<Dictionary<string, object>>();
foreach (string name in new[] { "RynthAi", "RynthChat", "RynthNav" })
{
byte[] body = Body(name, "v1-" + release);
string rel = $"{tag}/releases/{release}/plugins/{FileOf(name)}";
lock (Served) Served[rel] = name == tamper ? Encoding.UTF8.GetBytes("tampered " + name) : body;
plugins.Add(new Dictionary<string, object>
{
["name"] = name, ["file"] = FileOf(name), ["url"] = _base + rel, ["size"] = body.Length, ["sha256"] = Sha(body),
});
}
byte[] setup = Encoding.UTF8.GetBytes("installer " + release);
lock (Served) Served[$"{tag}/releases/{release}/RynthCore-Setup.exe"] = setup;
var manifest = new Dictionary<string, object?>
{
["schema"] = 1, ["release"] = inside, ["version"] = VersionOf(inside),
["published"] = published.ToString("yyyy-MM-ddTHH:mm:ssZ"), ["notes"] = "Notes " + inside,
["changes"] = new[] { $"Change one of {inside}.", "Change two.", "Change three.", "Change four." },
["core"] = new Dictionary<string, object>
{
["release"] = inside, ["version"] = VersionOf(inside),
["url"] = _base + $"{tag}/releases/{release}/RynthCore-Setup.exe", ["size"] = setup.Length, ["sha256"] = Sha(setup),
},
["plugins"] = plugins,
};
lock (Served) Served[$"{tag}/releases/{release}/update.json"] = Envelope(manifest, key);
return published;
}
private static void ServeReleasesList(string tag, params int[] releases)
{
var list = releases.Select(r => new { version = VersionOf(r), date = "x", changes = new[] { "c" } }).ToArray();
lock (Served) Served[$"{tag}/releases.json"] = JsonSerializer.SerializeToUtf8Bytes(new { releases = list });
}
/// <summary>The current feed, as a release of its own (WriteFeed's is fixed at <see cref="RbInstalled"/>).</summary>
private static void ServeFeed(string tag, int release)
{
var plugins = new List<Dictionary<string, object>>();
foreach (string name in FeedPlugins)
{
byte[] body = Body(name, "v3-" + release);
string rel = $"{tag}/releases/{release}/plugins/{FileOf(name)}";
lock (Served) Served[rel] = body;
plugins.Add(new Dictionary<string, object> { ["name"] = name, ["file"] = FileOf(name), ["url"] = _base + rel, ["size"] = body.Length, ["sha256"] = Sha(body) });
}
var manifest = new Dictionary<string, object?>
{
["schema"] = 1, ["release"] = release, ["version"] = VersionOf(release),
["published"] = Published.AddDays(1).ToString("yyyy-MM-ddTHH:mm:ssZ"), ["notes"] = "n",
["core"] = new Dictionary<string, object> { ["release"] = release, ["version"] = VersionOf(release), ["url"] = _base + $"{tag}/x.exe", ["size"] = 1, ["sha256"] = "00" },
["plugins"] = plugins,
};
lock (Served) Served[$"{tag}/update.json"] = Envelope(manifest);
}
private static Task RollbackReleaseNumbers()
{
Check(RynthUpdater.ReleaseOf("2026.10.21.2") == 2026102102, "2026.10.21.2 → 2026102102");
Check(RynthUpdater.ReleaseOf("2026.9.26.3") == 2026092603, "a one-digit month and day");
Check(RynthUpdater.ReleaseOf("2026.10.5.20") == 2026100520, "a two-digit release of the day");
Check(RynthUpdater.ReleaseOf("0.0.0") == 0 && RynthUpdater.ReleaseOf("2026.13.1.1") == 0 && RynthUpdater.ReleaseOf(null) == 0,
"not a release: 0");
Check(RynthUpdater.FirstRollbackRelease == 2026101901, "the launcher goes back to 2026.10.19.1 at the oldest");
return Task.CompletedTask;
}
private static async Task RollbackOffersVerifiedEarlierReleases()
{
Feed f = RollbackSetup("rb-list");
ServeRelease("rb-list", 2026100402);
ServeRelease("rb-list", 2026100301, claim: 2026100302); // holds another release's manifest
ServeRelease("rb-list", 2026100201);
ServeRelease("rb-list", 2026100105, key: ECDsa.Create(ECCurve.NamedCurves.nistP256)); // signed by a stranger
ServeRelease("rb-list", 2026093001); // below the floor
// 2026.10.4.1 is listed but has no manifest kept.
ServeReleasesList("rb-list", RbInstalled, 2026100402, 2026100401, 2026100301, 2026100201, 2026100105, 2026093001);
var targets = await f.Upd.ListRollbackTargetsAsync();
Check(string.Join(",", targets.Select(t => t.Version)) == "2026.10.4.2,2026.10.2.1",
"offered: older, verified, its own release, not below the floor: " + string.Join(",", targets.Select(t => t.Version)));
Check(targets[0].Manifest.Changes.Count == 4 && targets[0].Manifest.Changes[0] == "Change one of 2026100402.",
"the changes shown come from the signed manifest");
Check((await f.Upd.ListRollbackTargetsAsync(max: 1)).Count == 1, "at most max");
}
private static async Task RollbackRefusesForeignOrForwardManifests()
{
Feed f = RollbackSetup("rb-refuse");
ServeRelease("rb-refuse", 2026100301, claim: 2026100302);
ServeRelease("rb-refuse", 2026100601); // newer than installed
ServeRelease("rb-refuse", 2026100401, key: ECDsa.Create(ECCurve.NamedCurves.nistP256));
async Task<bool> Refused(int release)
{
try { await f.Upd.LoadReleaseManifestAsync(release); return false; }
catch (InvalidDataException) { return true; }
}
Check(await Refused(2026100301), "another release's manifest under its name: refused");
Check(await Refused(2026100601), "a release newer than the installed one: refused (that's an update, not a rollback)");
Check(await Refused(2026100401), "a manifest no trusted key signed: refused");
bool missing = false;
try { await f.Upd.LoadReleaseManifestAsync(2026100101); }
catch (HttpRequestException) { missing = true; }
Check(missing, "a release with nothing kept: the download fails (and ListRollbackTargets skips it)");
}
private static async Task RollbackPreparesThenApplies()
{
Feed f = RollbackSetup("rb-apply");
DateTime published = ServeRelease("rb-apply", 2026100402);
ServeReleasesList("rb-apply", RbInstalled, 2026100402);
string chat = Place(f, "RynthChat");
string mine = Path.Combine(f.Suite, "RynthMine", "RynthCore.Plugin.RynthMine.dll"); // not shipped by the release
Directory.CreateDirectory(Path.GetDirectoryName(mine)!);
File.WriteAllText(mine, "my own build");
var paths = new List<string> { f.RynthAiPath, chat, mine };
var target = (await f.Upd.ListRollbackTargetsAsync()).Single();
var plan = await f.Upd.PrepareRollbackAsync(target, paths);
Check(plan.LeavingRelease == RbInstalled && plan.Manifest.Release == 2026100402, "the plan: from the installed release to the chosen one");
Check(string.Join(",", plan.Plugins.Select(p => p.Entry.Name).OrderBy(n => n)) == "RynthAi,RynthChat",
"only the player's plugins the release ships (not RynthNav, not their own): " + string.Join(",", plan.Plugins.Select(p => p.Entry.Name)));
Check(File.Exists(plan.InstallerPath) && File.ReadAllText(plan.InstallerPath) == "installer 2026100402", "the release's installer, verified");
Check(File.ReadAllBytes(f.RynthAiPath).SequenceEqual(Body("RynthAi")), "prepared, nothing installed yet");
List<string> done = f.Upd.ApplyRollbackPlugins(plan);
Check(done.Count == 2 && done.All(d => d.EndsWith("→ 2026.10.4.2")), "two plugins put back: " + string.Join("; ", done));
Check(File.ReadAllBytes(f.RynthAiPath).SequenceEqual(Body("RynthAi", "v1-2026100402"))
&& File.ReadAllBytes(chat).SequenceEqual(Body("RynthChat", "v1-2026100402")), "RynthAi and RynthChat are the release's builds");
Check(File.ReadAllBytes(f.RynthAiPath + ".previous").SequenceEqual(Body("RynthAi")), "the replaced file kept as .previous");
Check(File.GetLastWriteTimeUtc(f.RynthAiPath) == published, "stamped with the release's time (not taken for a local build)");
Check(File.ReadAllText(mine) == "my own build", "a plugin the release doesn't ship is left alone");
}
private static async Task RollbackFailedDownloadChangesNothing()
{
Feed f = RollbackSetup("rb-fail");
ServeRelease("rb-fail", 2026100402, tamper: "RynthChat");
ServeReleasesList("rb-fail", RbInstalled, 2026100402);
string chat = Place(f, "RynthChat");
var target = (await f.Upd.ListRollbackTargetsAsync()).Single();
bool threw = false;
try { await f.Upd.PrepareRollbackAsync(target, new[] { f.RynthAiPath, chat }); }
catch (InvalidDataException) { threw = true; }
Check(threw, "a download that doesn't match the signed hash stops the rollback");
Check(File.ReadAllBytes(f.RynthAiPath).SequenceEqual(Body("RynthAi")) && File.ReadAllBytes(chat).SequenceEqual(Body("RynthChat")),
"and nothing installed is touched");
Check(f.Upd.HeldThroughRelease == 0, "and no hold started");
}
private static async Task RollbackHoldsUntilANewerRelease()
{
Feed f = RollbackSetup("rb-hold");
// Rolled back from 2026.10.5.1 to 2026.10.4.2: the installer wrote the older release.txt.
f.Upd.StartHold(RbInstalled, turnedOffAutoUpdate: true);
File.WriteAllText(Path.Combine(f.Dir, "app", "release.txt"), "2026100402");
var c = await f.Upd.CheckAsync(new[] { f.RynthAiPath });
Check(c.Held && !c.HoldEnded && c.HoldThrough == RbInstalled, "the feed still offers the release left behind: held");
Check(c.CoreUpdateAvailable, "going forward stays possible (by hand)");
Check(f.Upd.HeldThroughRelease == RbInstalled && f.Upd.HoldTurnedOffAutoUpdate, "the replay guard's write keeps the hold");
ServeFeed("rb-hold", 2026100601);
var c2 = await f.Upd.CheckAsync(new[] { f.RynthAiPath });
Check(!c2.Held && c2.HoldEnded, "a newer release than the one left behind: the hold is over");
f.Upd.EndHold();
Check(f.Upd.HeldThroughRelease == 0 && !f.Upd.HoldTurnedOffAutoUpdate, "EndHold clears both");
var c3 = await f.Upd.CheckAsync(new[] { f.RynthAiPath });
Check(!c3.Held && !c3.HoldEnded && c3.HoldThrough == 0, "no hold: nothing to say");
}
private static async Task RollbackHoldEndsWhenUpdatedByHand()
{
Feed f = RollbackSetup("rb-hand");
f.Upd.StartHold(RbInstalled, turnedOffAutoUpdate: false);
// release.txt still says 2026100501: the player went forward again by hand (or the rollback didn't install).
var c = await f.Upd.CheckAsync(new[] { f.RynthAiPath });
Check(!c.Held && c.HoldEnded, "installed release at or past the hold: it's over");
}
private static Task RollbackCardWhileHeld()
{
var card = UpdateCardModel.Build(new UpdateCardInput
{
HasCheck = true, InstalledVersion = "2026.10.4.2", CoreUpdateAvailable = true, AvailableVersion = "2026.10.5.1",
HeldFromVersion = "2026.10.5.1", PendingPluginUpdates = new[] { "RynthAi" },
});
Check(card.Kind == UpdateCardKind.Held && card.Title == "RynthCore 2026.10.4.2 - rolled back", "held: " + card.Title);
Check(card.Detail.Contains("went back from 2026.10.5.1") && card.Detail.Contains("on hold"), "says why: " + card.Detail);
Check(card.ActionButton == UpdateCardModel.UpdateCoreButton, "Update RynthCore still goes forward");
var normal = UpdateCardModel.Build(new UpdateCardInput
{
HasCheck = true, InstalledVersion = "2026.10.4.2", CoreUpdateAvailable = true, AvailableVersion = "2026.10.5.1",
});
Check(normal.Kind == UpdateCardKind.CoreUpdate, "without a hold: the usual update card");
return Task.CompletedTask;
}
}

View file

@ -576,6 +576,16 @@ internal static class Program
Match match = Regex.Match(File.ReadAllText(targets), @"<RynthCoreSdkApiVersion>(\d+)</RynthCoreSdkApiVersion>");
Check(match.Success, "targets declare RynthCoreSdkApiVersion");
Eq(match.Success ? uint.Parse(match.Groups[1].Value) : 0u, PluginContractVersion.Current, "RynthCoreSdkApiVersion in RynthCore.PluginSdk.targets");
// Release (shared-SDK) builds raise a minimum below the managed-plugin API to the SDK's API
// (Publish-Update.ps1 checks for this rule before building).
string targetsText = File.ReadAllText(targets);
Match managed = Regex.Match(targetsText, @"<RynthCoreManagedPluginApi>(\d+)</RynthCoreManagedPluginApi>");
Check(managed.Success && uint.Parse(managed.Groups[1].Value) == 88u, "targets: managed plugins need API 88 (RynthCoreManagedPluginApi)");
Check(targetsText.Contains("'$(RynthPluginSharedSdk)' == 'true'") &&
targetsText.Contains("MinEngineApi=\"$(_RynthPluginEffectiveMinEngineApi)\"") &&
targetsText.Contains("<_Parameter1>$(_RynthPluginEffectiveMinEngineApi)</_Parameter1>"),
"targets: the manifest and the runtime attribute both use the derived minimum");
}
// v79: the SDK's copies of the training structs must be the engine's, byte for byte.

View file

@ -1,4 +1,5 @@
using RynthCore.Engine.Compatibility;
using RynthCore.Engine.ImGuiBackend;
using RynthCore.Engine.UI.Sections;
namespace SectionsTests;
@ -30,6 +31,8 @@ internal static class Program
StateJson();
ManifestWindows();
WindowPlanChoices();
WindowTakeOver();
StackCheckAfterPluginDraw();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
@ -488,17 +491,130 @@ internal static class Program
var offIlt = new[] { new ServerState("ilt", "Infinite Leaftide", false, false, ServerForce.Auto, true, "") };
var onIlt = new[] { new ServerState("ilt", "Infinite Leaftide", true, true, ServerForce.Auto, true, "") };
var refused = new List<string>();
var plan = WindowPlan.Build(new[] { net, other }, offIlt, t => t == "Inventory", refused);
var takeOvers = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var plan = WindowPlan.Build(new[] { net, other }, offIlt, t => t == "Inventory" ? TitleUse.EnginePanel : TitleUse.Free, refused, takeOvers);
Check(plan.ContainsKey("Characters") && plan["Characters"].Plugin == "RynthNet", "the first plugin keeps a title");
Check(!plan.ContainsKey("Bank"), "a server's window waits for its server");
Check(!plan.ContainsKey("Inventory"), "an engine panel's title is refused");
Check(!plan.ContainsKey("Inventory"), "an engine panel's title is refused without takeOver");
Check(refused.Count == 2 && refused.Exists(r => r.Contains("Other") && r.Contains("RynthNet")) && refused.Exists(r => r.Contains("engine panel")),
"both refusals say why: " + string.Join(" | ", refused));
var on = WindowPlan.Build(new[] { net }, onIlt, _ => false, new List<string>());
Check(takeOvers.Count == 0, "nothing taken over");
var on = WindowPlan.Build(new[] { net }, onIlt, _ => TitleUse.Free, new List<string>(), new HashSet<string>());
Check(on.ContainsKey("Bank"), "and shows while its server is active");
Check(WindowPlan.Signature(net.Windows[0]) != WindowPlan.Signature(net.Windows[1]), "signatures differ per window");
}
// A plugin window that declares "takeOver" draws in an engine panel's place (same title, same key).
private const string TakeOverManifest = """
{ "windows": [
{ "id": "inv", "title": "Inventory", "surface": "window:inv", "bar": true, "takeOver": true },
{ "id": "chat", "title": "Chat", "surface": "window:chat", "takeOver": true },
{ "id": "lua", "title": "Lua", "surface": "window:lua", "takeOver": "yes" },
{ "id": "notes", "title": "Notes", "surface": "window:notes", "takeOver": true },
{ "id": "sort", "title": "RynthSort", "surface": "window:sort", "takeOver": true }
] }
""";
private static void WindowTakeOver()
{
Case("plugin windows: taking over an engine panel");
SectionManifest m = SectionManifestParser.Parse("RynthAi", TakeOverManifest, out string err);
Check(err.Length == 0 && m.Windows.Length == 5, "parses: " + err);
Check(m.Windows[0].TakeOver && m.Windows[1].TakeOver && m.Windows[3].TakeOver, "\"takeOver\": true read");
Check(!m.Windows[2].TakeOver, "not a boolean: off");
Check(!SectionManifestParser.Parse("RynthNet", WindowsManifest, out _).Windows[0].TakeOver, "absent: off (as before)");
Check(WindowPlan.Signature(m.Windows[0]) != WindowPlan.Signature(m.Windows[0] with { TakeOver = false }),
"takeOver is in the signature (a change re-registers)");
// Inventory, Chat and Lua are engine panels; RynthSort is a script window's key; Notes is free.
TitleUse Use(string t) => t switch
{
"Inventory" or "Chat" or "Lua" => TitleUse.EnginePanel,
"RynthSort" => TitleUse.Other,
_ => TitleUse.Free,
};
var refused = new List<string>();
var takeOvers = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var none = Array.Empty<ServerState>();
var plan = WindowPlan.Build(new[] { m }, none, Use, refused, takeOvers);
Check(plan.ContainsKey("Inventory") && plan.ContainsKey("Chat") && takeOvers.SetEquals(new[] { "Inventory", "Chat" }),
"declared takeovers of engine panels are hosted and marked: " + string.Join(", ", takeOvers));
Check(!plan.ContainsKey("Lua") && refused.Exists(r => r.Contains("'Lua'") && r.Contains("takeOver")),
"an engine panel's title without takeOver is still refused, and the line says how");
Check(plan.ContainsKey("Notes") && !takeOvers.Contains("Notes"), "takeOver on a free title: an ordinary window (the engine face is gone)");
Check(!plan.ContainsKey("RynthSort") && refused.Exists(r => r.Contains("RynthSort") && r.Contains("another panel")),
"never another panel's (a script window's) title, takeOver or not");
// Two plugins taking over the same panel: the first keeps it.
SectionManifest second = SectionManifestParser.Parse("RynthInventory",
"{\"windows\":[{\"id\":\"inv\",\"title\":\"inventory\",\"surface\":\"window:i\",\"takeOver\":true}]}", out _);
var refused2 = new List<string>();
var taken2 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var plan2 = WindowPlan.Build(new[] { m, second }, none, Use, refused2, taken2);
Check(plan2["Inventory"].Plugin == "RynthAi" && refused2.Exists(r => r.Contains("RynthInventory") && r.Contains("RynthAi")),
"the first plugin to take a panel over keeps it (titles match without case)");
// The plugin goes: its manifest is gone, so the panel isn't in the plan (the engine's face comes back).
var after = WindowPlan.Build(Array.Empty<SectionManifest>(), none, Use, new List<string>(), taken2 = new HashSet<string>());
Check(after.Count == 0 && taken2.Count == 0, "no manifest: nothing hosted, nothing taken over");
}
// ImGui 1.91.6's ImGuiErrorRecoveryState, in field order: windows, IDs, tree nodes, colours,
// style vars, fonts, focus scopes, groups, item flags, popups, disabled. The base values are
// the ones a 32-bit probe of our cimgui.dll read inside a panel's body child (2026-10-21).
private static short[] Rec(params short[] f) => f;
private static void StackCheckAfterPluginDraw()
{
Case("plugin windows: ImGui stacks after a plugin's draw");
short[] given = Rec(3, 2, 0, 0, 0, 1, 3, 0, 1, 0, 0);
Check(ImGuiStackState.Fields == 11 && ImGuiStackState.RecordBytes == 22 && ImGuiStackState.Names.Length == 11,
"11 shorts, 22 bytes, a name each");
Check(ImGuiStackState.Compare(given, (short[])given.Clone()) == StackCheck.Balanced, "as found: balanced");
Check(ImGuiStackState.IdsAtBase(Rec(3, 1, 0, 0, 0, 0, 3, 0, 1, 0, 0)), "the body's start (one ID) is a base to recover to");
Check(!ImGuiStackState.IdsAtBase(given), "inside the face's PushID it isn't (the recovery would pop the caller's IDs)");
// Probe frame 1: two colours, a style var, two IDs, a font, a group, a disabled block, a tree node.
short[] leaked = Rec(3, 4, 1, 2, 1, 2, 3, 1, 1, 0, 1);
Check(ImGuiStackState.Compare(given, leaked) == StackCheck.LeftOpen, "pushes left open: ImGui unwinds them");
string what = ImGuiStackState.Describe(given, leaked);
Check(what == "IDs +2, tree nodes +1, colours +2, style vars +1, fonts +1, groups +1, disabled +1",
"the log says what was left: " + what);
Check(ImGuiStackState.CanRecover(given, leaked), "same window depth: recoverable");
// A child window left open (with a table inside): deeper, still recoverable.
short[] child = Rec(4, 1, 0, 1, 0, 1, 5, 0, 1, 0, 0);
Check(ImGuiStackState.Compare(given, child) == StackCheck.LeftOpen,
"a child window left open (its own IDs aren't compared with the body's)");
Check(ImGuiStackState.Describe(given, child) == "windows +1, colours +1, focus scopes +2",
"the log leaves out the other window's IDs: " + ImGuiStackState.Describe(given, child));
Check(ImGuiStackState.CanRecover(given, child), "a deeper window stack is recoverable");
short[] childPopped = Rec(4, 1, 0, -1, 0, 1, 5, 0, 1, 0, 0);
Check(ImGuiStackState.Compare(given, childPopped) == StackCheck.ClosedTooMuch, "a context stack below, even in a deeper window");
// The plugin ended the host's body child (one End too many) and left a colour and a font.
short[] ended = Rec(2, 1, 0, 1, 0, 2, 2, 0, 1, 0, 0);
Check(ImGuiStackState.Compare(given, ended) == StackCheck.ClosedTooMuch, "ended a window it didn't begin");
Check(!ImGuiStackState.CanRecover(given, ended), "ImGui's recovery can't go back up to the host's window");
Check(ImGuiStackState.GlobalPops(given, ended) == (1, 0, 1), "only the context's colours and fonts are popped by hand");
Check(ImGuiStackState.Describe(given, ended) == "windows -1, colours +1, fonts +1, focus scopes -1",
"negative changes are shown with their sign: " + ImGuiStackState.Describe(given, ended));
// Popped the host's colours: below the record, nothing to pop.
short[] overPopped = Rec(3, 2, 0, -2, 0, 1, 3, 0, 1, 0, 0);
Check(ImGuiStackState.Compare(given, overPopped) == StackCheck.ClosedTooMuch, "popped what it didn't push");
Check(ImGuiStackState.GlobalPops(given, overPopped) == (0, 0, 0), "never pops below the record");
Check(ImGuiStackState.Describe(given, given) == "nothing", "no change: nothing");
// The first-use size check (the record filled with 0xCC, then written by ImGui).
byte[] rec = Enumerable.Repeat((byte)0xCC, 64).ToArray();
for (int i = 0; i < 22; i++) rec[i] = (byte)(i % 2 == 0 ? 1 : 0);
Check(ImGuiStackState.WroteExpectedSize(rec, 0xCC), "22 bytes written: the layout expected");
rec[30] = 0;
Check(!ImGuiStackState.WroteExpectedSize(rec, 0xCC), "more written: a different layout, the guard stays off");
Check(!ImGuiStackState.WroteExpectedSize(Enumerable.Repeat((byte)0xCC, 64).ToArray(), 0xCC), "nothing written: off");
}
// ── Harness ────────────────────────────────────────────────────────
private static void Case(string name)

View file

@ -3,7 +3,9 @@
<!--
Offline checks for the Mini Remote's sections (src\RynthCore.Engine\UI\Sections, the pure
files compiled in): the per-character server overrides file, the plugin manifest parser and
its limits, and the section catalog (core sections, server-scoped contributions, ordering).
its limits, and the section catalog (core sections, server-scoped contributions, ordering);
plugin windows: which are hosted, which take over an engine panel, and the stack check after
a plugin's draw (ImGui\ImGuiStackState.cs).
IltDetect.cs (with AelrynthWire.cs, which it shares a parser with) supplies the matching a
plugin-declared server is detected with. Nothing native: no AC, no engine state.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
@ -24,6 +26,8 @@
<Compile Include="..\..\src\RynthCore.Engine\UI\Sections\SectionManifest.cs" Link="Engine\SectionManifest.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\Sections\SectionCatalog.cs" Link="Engine\SectionCatalog.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\Sections\WindowPlan.cs" Link="Engine\WindowPlan.cs" />
<!-- What a plugin window's draw left on ImGui's stacks (the record ImGuiStackGuard takes). -->
<Compile Include="..\..\src\RynthCore.Engine\ImGui\ImGuiStackState.cs" Link="Engine\ImGuiStackState.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\IltDetect.cs" Link="Engine\IltDetect.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\AelrynthWire.cs" Link="Engine\AelrynthWire.cs" />
<!-- The Diagnostics server picker's plan and the plugin API v86 server-state JSON. -->