Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 a99cdb7826 feat(app): Change executable... opens in the game's own folder (beta.19 PR-2)
The owner's request of 2026-10-12: the file dialog of Change executable...
opened wherever the last file dialog was, and the pick is almost always
another file of the same install.

GameFolder.StartFolder derives the folder from the row's path - the only
place one is stored: the install folder a store boundary names (InstallRoot:
steamapps\common\X, GOG Galaxy\Games\X, Epic Games\X, GamesInstalled\X), above
an Unreal package's <Project>\Binaries\Win64 where no boundary is recognised,
else the executable's folder; the nearest folder still there when that one is
gone (a Not installed entry); null for a drive that is not connected, where
Windows opens its last folder. It asks the file system, so the page runs it off
the UI thread. IGamePicker.PickExecutable takes the folder; Add game passes
none and keeps Windows' own choice.

Tests: GameFolderTests (each layout, a gone folder, an absent drive),
GameDetailViewModelTests.ChangingTheExecutableOpensThePickInTheGamesOwnFolder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:10:56 +07:00
poli0981andClaude Opus 5.5 38fdb6bd32 fix(import): a helper a store names is never the game, and an NW.js runtime outranks its launcher (beta.19 PR-1) (#292)
The owner's A Doll's Locket - Remake (itch 5085165, RPG Maker MZ) was imported as
Dolls Locket\notification_helper.exe. The pick was butler's verdict, taken as is:
butler stores a filtered verdict - the shallowest candidates, minus those whose
manifest asks for elevation - and does not rank what is left, so with the 213 MB
DollsLocket.exe launcher asking for administrator and the NW.js runtime a level
deeper in css\, the helper was the whole verdict (read from the owner's butler.db,
read-only).

- ItchLibrarySource skips a verdict candidate whose whole name is a runtime helper
  (ExecutableLocator.RuntimeHelperNames) or that sits in a Unity plugin folder; with
  nothing left the locator guesses and the review marks the row guessed. Whole
  names, not the locator's fragments: "node" is inside Nodebuster.
- ExecutableLocator ranks an executable beside nw.dll + package.json as an NW.js
  runtime (owner decision D56): below the Unity and Unreal layouts, above a name
  match. On the owner's disk it now picks css\Game.exe for Doll's Locket and
  swiftshader\Game.exe for HELLO, HELLO WORLD! (what D28 chose by hand); every other
  install it was run over picks what it picked before. notification_helper, nwjc
  and chromedriver join the helper fragments.
- LibraryImporter matches a store title to an entry by platform + store id as well
  as by path, so a corrected guess does not offer the same game a second time; the
  existing entry is re-pointed with Change executable... (nothing rewrites it).

HANDOFF owner-only item 14 (beta.18 on real hardware) is struck: passed 2026-10-08.

* fix(import): a store title is its entry by store id also when the entry's executable is inside the title's folder (beta.19 PR-1)

Found in a self-review after the stack's gate: the platform an import writes
is badged "detected", and the detection sweep refreshes it with what its own
rules find - an itch build that ships steam_api64.dll reads as Steam. Matching
the store id under the same platform only would then offer the same itch
title again beside its entry. The id now matches under the same platform, or
with the entry's executable inside the title's install folder; the same number
under another platform elsewhere is another store's numbering and stays a new
candidate (LibraryImporterTests.TheSameStoreIdInsideTheTitlesFolderIsTheSameTitleWhateverThePlatformReadsAs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:10:47 +07:00
poli0981andClaude Opus 5.5 6ed7851d90 test(capturehost): the Vulkan launch case asks the harness before the host runs; the target-exit case holds 15 s (beta.18 PR-5) (#290)
The two CaptureHost end-to-end races that failed beta.18's CI (both re-run green), taken at the owner's request
(2026-10-07) before the tag.

LaunchModeOnAVulkanTargetAttachesToTheLayersRingAndInjectsNothing failed #288 (run 37627351438) with
"session: RefusedByGuard / verdict: ModuleScanFailed  a module list came back incomplete". A hosted runner has the
Vulkan loader and no device, so the harness exits 77 with a "[SKIP]" line; the test read that line, or the session's
LaunchTargetExited, off the HOST's output. The runner is elevated, so the host starts the harness through
CreateProcessWithTokenW (UnelevatedProcess), which hands the child no stdout: the line never reached the host's output,
and when the guard's scan hit the dying harness the test failed instead of skipping. It now runs the plain harness
itself first (`--vulkan --hold-presenting 1`, bounded at 60 s), skips on 77 with the harness's own line, and otherwise
runs in full with no skip after the host - once the harness has presented here, every failure is real.
Measured: on this machine (a device) both cases pass, the Vulkan one in full; with the probe's ICDs hidden
(VK_DRIVER_FILES / VK_ICD_FILENAMES at a missing file, a throwaway edit) it skips in 0.66 s:
"[SKIP] vkCreateInstance failed (no ICD, or no surface extensions)".

WhenTheTargetExitsTheHostStopsAndSaysWhy failed #286 (run 37619719203) with TargetNotRunning: the host resolves its
target once, as it starts, and a host slower than the harness's 6 s hold found it gone (recorded since 2026-09-21).
The host prints nothing until its session ends, so there is no "attached" to wait for; the hold is 15 s, a margin.

The class's remark said CI does not run it; CI has, since 2026-09-06 - corrected in place. Docs: 13_CI_CD (the flake
tally), HANDOFF (beta.18's trap, struck to fixed), CHANGELOG [0.1.0-beta.18] (this ships in that tag).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 23:39:14 +07:00
22 changed files with 603 additions and 51 deletions

No files matched your search

+23
View File
@@ -28,6 +28,24 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Changed
- **Change executable… opens in the game's own folder** — the install folder a store made (`steamapps\common\<game>`
and the like), or above an Unreal game's `Binaries\Win64`, else the folder the executable is in — instead of wherever
the last file dialog was. For a game whose folder is gone it opens at the nearest folder still there
(`docs/08_UI.md` §Games).
### Fixed
- **An imported game is no longer one of its helpers, and an RPG Maker MV/MZ game behind a launcher is its runtime.**
A Doll's Locket - Remake (itch) was added as `notification_helper.exe`, NW.js's notification helper, because the itch
app's own record named only that file (it leaves out a launcher that asks for administrator and anything a folder
deeper) and the import took it as the game. A helper named by the store is skipped now and the executable is guessed —
the import list says so — and the guess takes the executable beside NW.js's `nw.dll` and `package.json`, the process
that draws (`css\Game.exe` there; its launcher asks for administrator, so it is measured with *Run the agent as
administrator* on). The import also no longer offers a store's game again when the library has it at another
executable: an entry already there is re-pointed with *Change executable…* (`docs/05_DETECTION.md` §Library import).
## [0.1.0-beta.18] - 2026-10-07
**The eighteenth pre-release: every page readable in the dark theme, notices that say what happened in words, and a
@@ -68,6 +86,11 @@ the database changes and nothing is shown again for you to accept; sessions alre
the build, and the build id was read from the tree after that. It is read from the clean checkout first and handed to
the build, and `tools/buildid-check.ps1` reads it back out of the published binaries (`docs/12_BUILD.md` §Release-time
token substitution). Nothing changes for a game: both sides of the ring's handshake always carried the same id.
- **Two end-to-end tests no longer fail CI by a race** (developers only). The Vulkan launch test asks the test harness
whether this machine can present through Vulkan before it starts the capture host: on GitHub's runners the harness's
own "skip" line never reached the host's output, and a scan of the exiting harness failed the test instead of skipping
it. The target-exit test holds its harness 15 seconds instead of 6, the margin a slow runner's host needed
(`docs/13_CI_CD.md`).
## [0.1.0-beta.17] - 2026-10-07
+23
View File
@@ -293,6 +293,29 @@ wrote, where detection wrote it.
> is fetched (CLAUDE.md rule 8's "opt-in store metadata" is the online lookup, which does not exist). First-run
> step 4 now points at File ▸ Import library… rather than saying "later build".
> **beta.19 (owner report 2026-10-12): a store's own pick can be a helper, and a launcher is not the game.** The owner's
> A Doll's Locket - Remake (itch 5085165, RPG Maker MZ) was imported as `Dolls Locket\notification_helper.exe` — NW.js's
> toast helper. The pick was **butler's verdict**, taken as is: butler stores a *filtered* verdict (the shallowest
> candidates, minus those whose manifest asks for elevation) and does not rank what is left, and on that install the
> 213 MB `DollsLocket.exe` launcher asks for administrator while the NW.js runtime sits a level deeper in `css\`, so the
> helper was the whole verdict (read from the owner's `butler.db`, read-only). Three changes:
> **(1)** a verdict candidate whose whole name is a runtime helper (`ExecutableLocator.RuntimeHelperNames`:
> `notification_helper`, `crashpad_handler`, `UnityCrashHandler64/32`, `CrashReportClient`, NW.js's `nwjc` and
> `chromedriver`) or that sits in a Unity plugin folder is skipped, and with nothing left the locator guesses and the
> review marks the row *guessed* — whole names, because the locator's fragments are inside real games' names (`node` in
> *Nodebuster*) and a store's pick is overruled only when it cannot be the game; the locator's `HelperFragments` gain the
> same three NW.js names. **(2)** The locator ranks **an executable beside `nw.dll` + `package.json`** — the `rpgmaker_mv`
> rule's own signal — as an NW.js runtime (owner decision D56), below the Unity and Unreal layouts (an NW.js folder can
> be a tool shipped beside such a game) and above a name match (the launcher in front of the runtime is named after the
> install): the install's guess is `css\Game.exe`, the process that draws, as D28 pointed HELLO, HELLO WORLD!'s entry at
> its runtime by hand. That runtime starts elevated (its launcher asks for administrator), so it is measured with the
> admin mode on (D34). **(3)** Discovery matches a store title to an entry by **platform + store id** as well as by
> path: the entry an earlier import made at another executable is "already in the library" (the log names its path),
> so a corrected guess never adds the same game a second time — that entry is re-pointed with Change executable…, and
> nothing rewrites it by itself (D25/D27). Tests: `ExecutableLocatorTests.AnNwjsRuntimeBeatsTheLauncherNamedAfterTheInstallAndItsHelpersAreDropped`,
> `StoreLibrarySourcesTests.ItchSkipsAVerdictCandidateThatIsARuntimeHelper` (the verdict as stored),
> `LibraryImporterTests.AStoreTitleAlreadyInTheLibraryAtAnotherExecutableIsNotOfferedAgain`.
**Publisher/version order:** store manifest → PE `CompanyName`/`ProductVersion` → *(opt-in)* Steam `appdetails` lookup, cached 7 days. *(Since beta.8 the PE versions are stored beside the store's rather than instead of it — §What the files say about themselves; the page labels a store's value with its store, "Steam build 20374416".)*
## Capability hints (explicitly labelled as such)
+4 -1
View File
@@ -299,7 +299,10 @@ All screens are `Page`s registered with the navigation page provider and navigat
> fields), **the row's executable path under the subtitle and Change executable… since 2026-09-21** (a store import
> guesses the executable and everything downstream is keyed on it; the pick re-points the row, which comes back
> hooking-off and unconsented like a new game, consent revoked over the pipe first, a block never cleared —
> `05_DETECTION` §Library import), **one App per data folder since 2026-09-21** (`Services.SingleInstance`: a named mutex and a named event keyed on a hash of the data directory, claimed in `Program.Main` after Velopack's hooks and before any window; a later start sets the event and exits 0, and the first instance brings its window forward through `ShellHost.Reveal` — from the tray too. Nothing stopped a second App before: the owner's log shows two started 360 ms apart, two tray icons, a second log file. `--diag` never claims), ~~**the guard-bypass switch since 2026-09-21**~~ **withdrawn 2026-09-22** (the card, its dialog, the session mark and the export line are gone; a blocked row's toggle is disabled and `Safety_Blocked_Toggle_Format` is the whole story; a refusal or unhook notice that turned hooking off ends with `Safety_HookingTurnedOff` — `19_SAFETY` §What a finding does to the game), **Supports** (from `capability_flags`; ~~empty until P4's scan writes it, and the card says so~~ **written by the Agent's detection sweep since P4 PR-1, 2026-09-14** — the rule ids as product names via `CapabilityNames`, "not scanned yet" only until the Agent's next tick) beside
> `05_DETECTION` §Library import; **since beta.19 the file dialog opens in the game's own folder** — `GameFolder.StartFolder`:
> the store boundary's install folder (`InstallRoot`), an Unreal package's root above `<Project>\Binaries\Win64`, else
> the executable's folder, and the nearest folder still there when that one is gone; nothing for a drive that is not
> connected, where Windows opens its last folder; owner request 2026-10-12, `GameFolderTests`), **one App per data folder since 2026-09-21** (`Services.SingleInstance`: a named mutex and a named event keyed on a hash of the data directory, claimed in `Program.Main` after Velopack's hooks and before any window; a later start sets the event and exits 0, and the first instance brings its window forward through `ShellHost.Reveal` — from the tray too. Nothing stopped a second App before: the owner's log shows two started 360 ms apart, two tray icons, a second log file. `--diag` never claims), ~~**the guard-bypass switch since 2026-09-21**~~ **withdrawn 2026-09-22** (the card, its dialog, the session mark and the export line are gone; a blocked row's toggle is disabled and `Safety_Blocked_Toggle_Format` is the whole story; a refusal or unhook notice that turned hooking off ends with `Safety_HookingTurnedOff` — `19_SAFETY` §What a finding does to the game), **Supports** (from `capability_flags`; ~~empty until P4's scan writes it, and the card says so~~ **written by the Agent's detection sweep since P4 PR-1, 2026-09-14** — the rule ids as product names via `CapabilityNames`, "not scanned yet" only until the Agent's next tick) beside
> **Last session measured** (upscaler · resolution, frame generation, the non-N/A chips — accent pills, from the
> hooks). Hooking: the toggle is `OneWay` from the row and its command runs `HookingConsent`; a refusal, a
> mismatch or a failure is a persistent `InfoBar` on the page (never a toast); a blocked row disables the
+11
View File
@@ -52,6 +52,17 @@ FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, an
case. `Kill` now waits for exit (bounded, asserted) and the delete retries. Not §S19(b) either — a test-harness
race, and the third flake shape of the day (the registry-subtree race between `VkLayerRegistrationTests` and the
GOG reader's test, fixed in #188) was the same kind.
- **Two more on 2026-10-07 (beta.18), both re-run green and then fixed the same day.**
`WhenTheTargetExitsTheHostStopsAndSaysWhy` ended **`TargetNotRunning`** (#286, run 37619719203): the host resolves its
target once, as it starts, and a host slower than the harness's 6 s hold found it gone — the shape recorded since
2026-09-21. The hold is 15 s: a margin, not a signal, because the host prints nothing until its session ends.
`LaunchModeOnAVulkanTargetAttachesToTheLayersRingAndInjectsNothing` ended **`RefusedByGuard` / `ModuleScanFailed`**
(#288, run 37627351438): the hosted runner has the Vulkan loader and no device, so the harness exits 77 with a
`[SKIP]` line — but the runner is elevated, the host starts the harness through `CreateProcessWithTokenW`
(`UnelevatedProcess`), the child gets no stdout, and the line never reached the host's output; the test then
depended on the session reading `LaunchTargetExited`, and a scan that hit the dying harness failed it instead. The
test now asks the harness directly, before the host runs (exit 77 = skip, with the harness's own line); hiding the
Vulkan ICDs from that probe makes it skip in under a second, and on a machine with a device it runs in full.
- **A re-run ERASES the evidence, which is why the count above had to be kept by hand.**
`gh run rerun --failed` updates the original run's conclusion, so `gh run list` showed **18 success, 1
cancelled, 0 failed** across the twenty runs that contained all three failures above. Anyone measuring
+4 -2
View File
@@ -2118,7 +2118,8 @@ blends into the background in dark mode").
device, so the harness exits 77 with a `[SKIP]` line — but the runner is elevated, the launch goes through
`CreateProcessWithTokenW` (`UnelevatedProcess`), the child inherits no stdout, and the line never reaches the host's
output; when the guard's scan hits the exiting harness (`ModuleScanFailed`) the test fails instead of skipping. Re-run;
the deterministic fix is a task of its own.
~~the deterministic fix is a task of its own~~ fixed the same day by beta.18 PR-5 (the test asks the harness itself,
before the host runs), which also gave the `TargetNotRunning` case a 15 s hold (`13_CI_CD` §ci.yml).
**Owner-only, added to the list below:** item 14.
@@ -2217,7 +2218,8 @@ blends into the background in dark mode").
halves and a footer naming `v0.1.0-beta.17` — then tick *Restrict editing to collaborators only* (Settings ▸ General
▸ Features ▸ Wikis), or anyone can change a page until the next release overwrites it. (e) The `ja` strings marked
`review`.
14. **beta.18 on real hardware.** (a) **The dark theme:** every page's title and section headings — Dashboard, Games, a
14. ~~**beta.18 on real hardware.**~~ **Passed 2026-10-08** — the owner ran it on real hardware and reported it OK ("Đã
test và ok"). *(The item as written:)* (a) **The dark theme:** every page's title and section headings — Dashboard, Games, a
game's page, Compare, Settings, Logs — read light on the dark window, after starting in Dark, after Light → Dark, and
after moving between pages. (b) **The overlay build** on the Dashboard's *Capture agent* card reads `v0.1.0-beta.18`,
without `-dirty`. (c) **Disable all hooking:** turning it on says a game being measured stops within 30 seconds; with
+2 -2
View File
@@ -69,8 +69,8 @@ stopped, hooking turned off — each with one button that only says you have rea
- **At the top:** the name, publisher, version, store and engine, the `.exe` path, the last session, the last measured
session's frame rate and its ray-tracing chips. **Edit…** changes the name, publisher, version and notes. **Change
executable…** points the entry at another `.exe` and turns hooking back off. **Remove…** asks whether to keep the
game's sessions.
executable…** points the entry at another `.exe` and turns hooking back off; its file dialog opens in the game's own
folder. **Remove…** asks whether to keep the game's sessions.
- **Recording** — off, FrameLedger ignores the program completely: for a launcher or a tool that is not a game.
- **Hooking** — on, the game is measured. A warning comes first, and you type `I ACCEPT THE INJECTION RISK` to go on.
Read [Anti-cheat and safety](04-anti-cheat-and-safety.md) before you do.
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using FrameLedger.Infrastructure.Detection;
namespace FrameLedger.App.Services;
/// <summary>
/// The folder Change executable… opens in (beta.19, owner request 2026-10-12): the game's own root folder rather than
/// wherever Windows' dialog was last — the pick is almost always another file of the same install.
/// </summary>
/// <remarks>
/// <para>
/// The root is <see cref="InstallRoot.Resolve"/>'s — the folder a store boundary names (<c>steamapps\common\X</c>,
/// <c>GOG Galaxy\Games\X</c>, <c>Epic Games\X</c>, <c>GamesInstalled\X</c>) — and, where no boundary is recognised, out of
/// an Unreal package's <c>&lt;root&gt;\&lt;Project&gt;\Binaries\Win64</c> to <c>&lt;root&gt;</c>, else the executable's own
/// folder. Only the row's path is stored (no install folder), so this is derived, never remembered.
/// </para>
/// <para>
/// An entry whose folder is gone (*Not installed*) opens at the nearest folder above it that is still there; an entry on a
/// drive that is not connected gets null, and the dialog opens where Windows last was. It asks the file system, so its
/// caller runs it off the UI thread: a share that went away can take seconds to answer.
/// </para>
/// </remarks>
public static class GameFolder
{
/// <summary>The folder to open the pick in for an entry at <paramref name="exePath"/>, or null when there is none.</summary>
public static string? StartFolder(string exePath)
{
ArgumentException.ThrowIfNullOrWhiteSpace(exePath);
string full;
try
{
full = Path.GetFullPath(exePath);
}
catch (Exception ex) when (ex is ArgumentException or NotSupportedException or PathTooLongException)
{
return null;
}
string? drive = Path.GetPathRoot(full);
if (string.IsNullOrEmpty(drive) || !Directory.Exists(drive))
{
return null;
}
string exeDirectory = Path.GetDirectoryName(full) ?? drive;
string root = InstallRoot.Resolve(full);
if (string.Equals(root, exeDirectory, StringComparison.OrdinalIgnoreCase) && UnrealRoot(exeDirectory) is { } unreal)
{
root = unreal;
}
for (string? folder = root; !string.IsNullOrEmpty(folder); folder = Path.GetDirectoryName(folder))
{
if (Directory.Exists(folder))
{
return folder;
}
}
return drive;
}
/// <summary><c>&lt;root&gt;\&lt;Project&gt;\Binaries\Win64</c> (or <c>WinGDK</c>) → <c>&lt;root&gt;</c>; null for any other folder.</summary>
private static string? UnrealRoot(string exeDirectory)
{
string platform = Path.GetFileName(exeDirectory);
string? binaries = Path.GetDirectoryName(exeDirectory);
bool unreal = (string.Equals(platform, "Win64", StringComparison.OrdinalIgnoreCase) || string.Equals(platform, "WinGDK", StringComparison.OrdinalIgnoreCase))
&& binaries is not null && string.Equals(Path.GetFileName(binaries), "Binaries", StringComparison.OrdinalIgnoreCase);
string? project = unreal ? Path.GetDirectoryName(binaries) : null;
return project is null ? null : Path.GetDirectoryName(project);
}
}
+9 -1
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using Microsoft.Win32;
namespace FrameLedger.App.Services;
@@ -8,7 +9,7 @@ namespace FrameLedger.App.Services;
/// <summary>The WPF <see cref="OpenFileDialog"/> for FR-1.1.</summary>
public sealed class GamePicker : IGamePicker
{
public string? PickExecutable()
public string? PickExecutable(string? initialDirectory = null)
{
var dialog = new OpenFileDialog
{
@@ -17,6 +18,13 @@ public sealed class GamePicker : IGamePicker
CheckFileExists = true,
Multiselect = false,
};
// InitialDirectory opens the dialog there whatever folder it remembers (DefaultDirectory would only be a fallback).
if (!string.IsNullOrEmpty(initialDirectory) && Directory.Exists(initialDirectory))
{
dialog.InitialDirectory = initialDirectory;
}
return dialog.ShowDialog() == true ? dialog.FileName : null;
}
}
+5 -1
View File
@@ -7,5 +7,9 @@ namespace FrameLedger.App.Services;
public interface IGamePicker
{
/// <summary>The chosen executable's full path, or null when the user cancelled.</summary>
string? PickExecutable();
/// <param name="initialDirectory">
/// The folder the dialog opens in (beta.19: Change executable… opens in the game's own folder, <see cref="GameFolder"/>);
/// null leaves it to Windows, which opens where the last pick was.
/// </param>
string? PickExecutable(string? initialDirectory = null);
}
@@ -801,7 +801,8 @@ public sealed partial class GameDetailViewModel : ObservableObject
/// <summary>
/// A store import guesses the executable (Steam names none), and everything downstream is keyed on it: a wrong guess
/// is a game that can never be matched. The pick is the user's own; the row comes back hooking-off and unconsented,
/// exactly as a new game would, and consent is revoked over the pipe first, as removal does.
/// exactly as a new game would, and consent is revoked over the pipe first, as removal does. The dialog opens in the
/// game's own folder (beta.19, <see cref="GameFolder"/>), asked off the UI thread.
/// </summary>
private async Task ChangeExecutableCoreAsync()
{
@@ -810,7 +811,9 @@ public sealed partial class GameDetailViewModel : ObservableObject
return;
}
string? path = _picker.PickExecutable();
string current = Game.Fingerprint.ExePath;
string? folder = await Task.Run(() => GameFolder.StartFolder(current)).ConfigureAwait(true);
string? path = _picker.PickExecutable(folder);
if (path is null || string.Equals(ExecutableIdentity.Normalise(path), Game.Fingerprint.ExePath, StringComparison.OrdinalIgnoreCase))
{
return;
@@ -72,6 +72,12 @@ public sealed class LibraryImporter
bool missing = exe is not null && _identity.Read(exe) is null;
bool already = exe is not null && await _games.FindAsync(exe, ct).ConfigureAwait(false) is { InLibrary: true };
string? movedFrom = exe is null || already ? null : StaleTwinOf(exe, library)?.Fingerprint.ExePath;
if (exe is not null && !already && movedFrom is null && SameStoreTitleOf(game, library) is { } entry)
{
already = true;
_log($"import: {game.Name} ({game.Platform} {game.StoreId}) is already in the library as {entry.Fingerprint.ExePath} — not offered again at {exe}");
}
candidates.Add(new ImportCandidate(game, exe, already, guessed, missing, movedFrom));
}
@@ -130,4 +136,23 @@ public sealed class LibraryImporter
/// </summary>
private GameRow? StaleTwinOf(string exe, IReadOnlyList<GameRow> library) =>
library.FirstOrDefault(r => ExecutableRelocator.IsDriveLetterTwin(r.Fingerprint.ExePath, exe) && _identity.Read(r.Fingerprint.ExePath) is null);
/// <summary>
/// The library entry an earlier import made for this very store title, at another executable (beta.19): the store's id,
/// under the same platform or with the entry's executable inside the title's install folder. The import used to compare
/// paths only, so a guess that changed between builds — A Doll's Locket - Remake's helper became its NW.js runtime —
/// would have offered the same game again beside the entry the user already has; that entry is what Change executable…
/// re-points. The folder half is there because the platform is the detection sweep's to refresh: an itch build that
/// ships Steam's API reads as Steam. A title with no store id is never matched.
/// </summary>
private static GameRow? SameStoreTitleOf(StoreGame game, IReadOnlyList<GameRow> library) =>
string.IsNullOrEmpty(game.StoreId)
? null
: library.FirstOrDefault(r => string.Equals(r.StoreId, game.StoreId, StringComparison.Ordinal)
&& (string.Equals(r.Platform, game.Platform, StringComparison.OrdinalIgnoreCase)
|| IsInside(r.Fingerprint.ExePath, game.InstallDirectory)));
private static bool IsInside(string path, string directory) =>
!string.IsNullOrEmpty(directory)
&& path.StartsWith(Path.TrimEndingDirectorySeparator(directory) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase);
}
@@ -24,9 +24,14 @@ namespace FrameLedger.Infrastructure.Import;
/// bootstrapper and as <c>Game-Win64-Shipping.exe</c>.
/// </para>
/// <para>
/// The two layout rules are the engines' own conventions, not guesses about names: a Unity player is <c>X.exe</c>
/// beside a directory <c>X_Data</c>, and an Unreal packaged build's game process is <c>*-Win64-Shipping.exe</c> (the
/// root executable of the same name is a bootstrapper that starts it and exits).
/// The layout rules are the engines' own conventions, not guesses about names: a Unity player is <c>X.exe</c> beside a
/// directory <c>X_Data</c>, an Unreal packaged build's game process is <c>*-Win64-Shipping.exe</c> (the root executable
/// of the same name is a bootstrapper that starts it and exits), and — since beta.19 (owner decision D56) — an NW.js
/// runtime is the executable beside its <c>nw.dll</c> and <c>package.json</c>, which is how an RPG Maker MV/MZ game
/// ships. The last one ranks below the first two and above a name: an NW.js folder can be a tool shipped beside a Unity
/// or Unreal game, and a launcher named after the install is exactly what fronts the runtime on A Doll's Locket - Remake
/// (itch), whose 213 MB <c>DollsLocket.exe</c> starts <c>css\Game.exe</c> — the process that draws, the one D28 pointed
/// HELLO, HELLO WORLD!'s entry at by hand.
/// </para>
/// </remarks>
public sealed class ExecutableLocator : IExecutableLocator
@@ -37,7 +42,8 @@ public sealed class ExecutableLocator : IExecutableLocator
/// </summary>
public const int MaxDepth = 4;
private const int _rankEngineLayout = 2;
private const int _rankEngineLayout = 3;
private const int _rankNwjsRuntime = 2;
private const int _rankNamedAfterTheInstall = 1;
private const int _minimumNameLength = 4;
@@ -50,8 +56,30 @@ public sealed class ExecutableLocator : IExecutableLocator
// beta.14: BugSplat's sender (BsSndRpt64.exe, Kingdom Come: Deliverance II) matches none of the above — its name says
// "report" without the letters; KCD2 picked its game by rank alone.
"bssndrpt", "bugsplat",
// beta.19: what an NW.js runtime keeps beside itself — Chromium's toast helper (NW.js 0.48.4 on A Doll's Locket - Remake,
// 0.82.0 on Flower in Us), and the SDK flavour's compiler and driver, which the NW.js rank would otherwise weigh as the game.
"notification_helper", "nwjc", "chromedriver",
];
/// <summary>
/// Whole names (no extension) of helpers a runtime ships beside a game, which no store's choice makes the game (beta.19).
/// itch's butler keeps the shallowest candidates and drops those that ask for elevation, so its verdict for A Doll's
/// Locket - Remake named <c>notification_helper.exe</c> and nothing else. Whole names rather than
/// <see cref="HelperFragments"/>: a store names its own pick, and a fragment such as <c>node</c> is inside a real game's
/// name (<c>Nodebuster</c>) — the locator's guess can afford that, overruling a store's verdict cannot.
/// </summary>
public static readonly IReadOnlySet<string> RuntimeHelperNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"notification_helper", "crashpad_handler", "UnityCrashHandler64", "UnityCrashHandler32", "CrashReportClient", "nwjc", "chromedriver",
};
/// <summary>True for a name in <see cref="RuntimeHelperNames"/>.</summary>
public static bool IsRuntimeHelper(string fileNameWithoutExtension)
{
ArgumentNullException.ThrowIfNull(fileNameWithoutExtension);
return RuntimeHelperNames.Contains(fileNameWithoutExtension);
}
/// <summary>
/// Folder-name fragments of what a store install carries beside the game: a folder whose name holds one is not walked.
/// Red Dead Redemption 2's <c>Redistributables\Rockstar-Games-Launcher.exe</c> is 140 MB to <c>RDR2.exe</c>'s 90.
@@ -164,6 +192,11 @@ public sealed class ExecutableLocator : IExecutableLocator
return _rankEngineLayout; // Unreal: the packaged game process, not the root bootstrapper
}
if (dir is not null && File.Exists(Path.Combine(dir, "nw.dll")) && File.Exists(Path.Combine(dir, "package.json")))
{
return _rankNwjsRuntime; // NW.js (RPG Maker MV/MZ): the runtime, not the launcher in front of it (D56)
}
string squashed = Squash(name);
bool named = squashed.Length >= _minimumNameLength && installName.Length >= _minimumNameLength
&& (installName.Contains(squashed, StringComparison.Ordinal) || squashed.Contains(installName, StringComparison.Ordinal));
@@ -99,16 +99,7 @@ public sealed class ItchLibrarySource(string? itchDirectory = null, Action<strin
""", cancellationToken: ct)).ConfigureAwait(false)).Select(static r => new CaveRow(r.GameId, r.LocationPath, r.FolderName, r.CustomFolder, r.Verdict, r.Title))];
}
int added = 0;
foreach (CaveRow cave in caves)
{
if (ToGame(cave) is { } game && byInstall.TryAdd(game.InstallDirectory, game))
{
added++;
}
}
return $"butler.db read: {locations} location(s), {caves.Count} cave(s), {added} title(s)";
return AddCaves(locations, caves, byInstall);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or SqliteException or InvalidOperationException)
{
@@ -126,7 +117,26 @@ public sealed class ItchLibrarySource(string? itchDirectory = null, Action<strin
}
}
private static StoreGame? ToGame(CaveRow cave)
/// <summary>One row per cave the database lists; returns the log fragment — with the titles whose verdict named only a helper.</summary>
private static string AddCaves(int locations, List<CaveRow> caves, Dictionary<string, StoreGame> byInstall)
{
int added = 0;
List<string> helperVerdicts = [];
foreach (CaveRow cave in caves)
{
if (ToGame(cave, helperVerdicts) is { } game && byInstall.TryAdd(game.InstallDirectory, game))
{
added++;
}
}
string note = $"butler.db read: {locations} location(s), {caves.Count} cave(s), {added} title(s)";
return helperVerdicts.Count == 0
? note
: note + $"; butler's verdict named only a helper for {string.Join(", ", helperVerdicts)} — the executable is guessed instead";
}
private static StoreGame? ToGame(CaveRow cave, List<string> helperVerdicts)
{
string? install = !string.IsNullOrWhiteSpace(cave.CustomFolder) ? cave.CustomFolder
: cave.LocationPath is { Length: > 0 } && cave.FolderName is { Length: > 0 } ? Path.Combine(cave.LocationPath, cave.FolderName)
@@ -138,7 +148,13 @@ public sealed class ItchLibrarySource(string? itchDirectory = null, Action<strin
install = Path.GetFullPath(install);
string name = cave.Title is { Length: > 0 } ? cave.Title : ReadReceipt(Path.Combine(install, ".itch", "receipt.json.gz"))?.Title ?? Path.GetFileName(install);
return new StoreGame(_platform, cave.GameId.ToString(System.Globalization.CultureInfo.InvariantCulture), name, install, VerdictExecutable(cave.Verdict, install), Version: null);
string? exe = VerdictExecutable(cave.Verdict, install, out bool onlyHelpers);
if (onlyHelpers)
{
helperVerdicts.Add(name);
}
return new StoreGame(_platform, cave.GameId.ToString(System.Globalization.CultureInfo.InvariantCulture), name, install, exe, Version: null);
}
/// <summary>
@@ -146,8 +162,17 @@ public sealed class ItchLibrarySource(string? itchDirectory = null, Action<strin
/// Windows candidate is the executable butler itself launches; anything else (an HTML5 or Love2D game, a
/// verdict that will not parse) leaves the guess to the locator.
/// </summary>
private static string? VerdictExecutable(string? verdict, string install)
/// <remarks>
/// <b>Not a candidate a runtime ships as a helper (beta.19).</b> butler saves a FILTERED verdict — the shallowest
/// candidates, minus those whose manifest asks for elevation — and does not rank what is left, so on A Doll's Locket -
/// Remake (game 5085165) the one candidate was <c>Dolls Locket/notification_helper.exe</c>: the 213 MB launcher asks for
/// administrator and the NW.js runtime sits a level deeper. The import took it as the game, unmarked as a guess. A
/// candidate <see cref="ExecutableLocator.IsRuntimeHelper"/> names, or one inside a Unity plugin folder, is skipped;
/// when nothing else is left, <paramref name="onlyHelpers"/> is true and the locator guesses — the review says so.
/// </remarks>
private static string? VerdictExecutable(string? verdict, string install, out bool onlyHelpers)
{
onlyHelpers = false;
if (string.IsNullOrWhiteSpace(verdict))
{
return null;
@@ -167,7 +192,15 @@ public sealed class ItchLibrarySource(string? itchDirectory = null, Action<strin
&& string.Equals(flavor.GetString(), "windows", StringComparison.Ordinal);
if (windows && candidate.TryGetProperty("path", out JsonElement path) && path.ValueKind == JsonValueKind.String && path.GetString() is { Length: > 0 } relative)
{
return Path.GetFullPath(Path.Combine(install, relative.Replace('/', Path.DirectorySeparatorChar)));
string full = Path.GetFullPath(Path.Combine(install, relative.Replace('/', Path.DirectorySeparatorChar)));
if (ExecutableLocator.IsRuntimeHelper(Path.GetFileNameWithoutExtension(full)) || ExecutableLocator.IsUnderPluginFolder(install, full))
{
onlyHelpers = true;
continue;
}
onlyHelpers = false;
return full;
}
}
@@ -175,6 +208,7 @@ public sealed class ItchLibrarySource(string? itchDirectory = null, Action<strin
}
catch (JsonException)
{
onlyHelpers = false;
return null;
}
}
@@ -107,12 +107,19 @@ public sealed class GameDetailViewModelTests
private sealed class FakePicker(string? path) : IGamePicker
{
public string? PickExecutable() => path;
/// <summary>The folder each pick was asked to open in.</summary>
public List<string?> Folders { get; } = [];
public string? PickExecutable(string? initialDirectory = null)
{
Folders.Add(initialDirectory);
return path;
}
}
private static async Task<(GameDetailViewModel Vm, FakeAgent Agent, FakePrompt Prompt, FakeNavigator Nav, FakeStrip Strip)> BuildAsync(
ScratchLedger s, long gameId, RemoveGameChoice remove = RemoveGameChoice.Cancel, GameMetadata? edit = null, string? pick = null,
FakeAgent? withAgent = null, RegisteredSettings? settings = null, UiMode? mode = null)
FakeAgent? withAgent = null, RegisteredSettings? settings = null, UiMode? mode = null, FakePicker? picker = null)
{
FakeAgent agent = withAgent ?? new FakeAgent();
var prompt = new FakePrompt();
@@ -121,7 +128,7 @@ public sealed class GameDetailViewModelTests
var vm = new GameDetailViewModel(s.Library, new GameSelection { GameId = gameId }, new HookingConsent(agent, prompt), nav,
new FakeConfirmations(remove), new FakeEdit(edit), strip, new NoSummaries(),
new Charts.SessionSeriesLoader(s.Sessions), new Infrastructure.Persistence.SqliteHardwareSnapshotRepository(s.Db), new SessionSelection(),
new FakePicker(pick), settings, mode: mode);
picker ?? new FakePicker(pick), settings, mode: mode);
Task pending = vm.Pending;
await pending.ConfigureAwait(false);
return (vm, agent, prompt, nav, strip);
@@ -815,6 +822,36 @@ public sealed class GameDetailViewModelTests
}
}
/// <summary>
/// beta.19 (owner request 2026-10-12): the pick opens in the game's own root folder — a Steam install's folder under
/// <c>steamapps\common</c>, not the <c>bin\x64</c> the executable sits in, and not wherever the dialog was last.
/// </summary>
[Fact]
public async Task ChangingTheExecutableOpensThePickInTheGamesOwnFolder()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
string library = Path.Combine(Path.GetTempPath(), "fl-pick-" + Guid.NewGuid().ToString("N"));
string install = Path.Combine(library, "steamapps", "common", "Title");
Directory.CreateDirectory(Path.Combine(install, "bin", "x64"));
try
{
GameRow game = await s.GameAsync("Title", Infrastructure.Io.ExecutableIdentity.Normalise(Path.Combine(install, "bin", "x64", "Title.exe")));
var picker = new FakePicker(null);
(GameDetailViewModel vm, _, _, _, FakeStrip strip) = await BuildAsync(s, game.Id, picker: picker);
vm.ChangeExecutableCommand.Execute(null);
Task pending = vm.Pending;
await pending;
picker.Folders.Should().Equal([install], "the install root under steamapps\\common, not bin\\x64");
strip.Lines.Should().BeEmpty("a cancelled pick changes nothing");
}
finally
{
Directory.Delete(library, recursive: true);
}
}
[Fact]
public async Task ChangingTheExecutableToAnUnreadableFileOrCancellingChangesNothing()
{
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using FluentAssertions;
using FrameLedger.App.Services;
namespace FrameLedger.App.Tests;
/// <summary>
/// Where Change executable… opens (beta.19, owner request 2026-10-12): the game's root folder for each layout the library
/// holds — a store's install folder, an Unreal package outside a store, a loose folder — the nearest folder still there for
/// an entry whose folder is gone, and nothing for a drive that is not connected.
/// </summary>
public sealed class GameFolderTests : IDisposable
{
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-gamefolder-" + Guid.NewGuid().ToString("N"));
public GameFolderTests() => Directory.CreateDirectory(_dir);
public void Dispose() => Directory.Delete(_dir, recursive: true);
private string Sub(params string[] parts)
{
string p = Path.Combine([_dir, .. parts]);
Directory.CreateDirectory(p);
return p;
}
[Fact]
public void AStoreInstallOpensAtItsFolderUnderTheStoresBoundary()
{
string install = Sub("SteamLibrary", "steamapps", "common", "Lies of P");
string bin = Sub("SteamLibrary", "steamapps", "common", "Lies of P", "LiesofP", "Binaries", "Win64");
GameFolder.StartFolder(Path.Combine(bin, "LiesofP-Win64-Shipping.exe")).Should().Be(install);
}
[Fact]
public void AnUnrealPackageOutsideAStoreOpensAboveItsProjectFolder()
{
string root = Sub("Games", "Hell Is Us");
string bin = Sub("Games", "Hell Is Us", "HellIsUs", "Binaries", "Win64");
GameFolder.StartFolder(Path.Combine(bin, "HellIsUs-Win64-Shipping.exe")).Should().Be(root, "<root>\\<Project>\\Binaries\\Win64 is Unreal's own layout");
}
[Fact]
public void ALooseFolderOpensWhereTheExecutableIs()
{
string game = Sub("it", "a-dolls-locket-remake", "Dolls Locket");
GameFolder.StartFolder(Path.Combine(game, "notification_helper.exe")).Should().Be(game);
}
[Fact]
public void AFolderThatIsGoneOpensAtTheNearestOneStillThere()
{
string library = Sub("it");
GameFolder.StartFolder(Path.Combine(library, "uninstalled", "Sub", "Game.exe")).Should().Be(library, "the entry reads Not installed; its library folder is still there");
}
[Fact]
public void ADriveThatIsNotConnectedOpensNowhereInParticular()
{
char? absent = null;
for (char letter = 'Z'; letter >= 'D'; letter--)
{
if (!Directory.Exists(letter + @":\"))
{
absent = letter;
break;
}
}
Assert.SkipWhen(absent is null, "every drive letter from D to Z is in use on this machine");
GameFolder.StartFolder(absent + @":\Games\Title\Title.exe").Should().BeNull("Windows then opens where the last pick was");
}
}
@@ -37,7 +37,7 @@ public sealed class GamesViewModelTests
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
public string? PickExecutable(string? initialDirectory = null) => null;
}
private sealed class NoStrip : IMessageStrip
@@ -129,7 +129,7 @@ public sealed partial class PagesLoadTests
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
public string? PickExecutable(string? initialDirectory = null) => null;
}
private sealed class NoTheme : IThemeApplier
@@ -92,7 +92,7 @@ public sealed class SessionDeletionAndOverviewTests
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
public string? PickExecutable(string? initialDirectory = null) => null;
}
/// <summary>The summary windows, counting how often they were asked to close the deleted sessions' ones.</summary>
@@ -129,6 +129,72 @@ public sealed class LibraryImporterTests
log.Should().Contain(static l => l.Contains("added Cyberpunk 2077", StringComparison.Ordinal) && l.Contains("hooking off", StringComparison.Ordinal));
}
/// <summary>
/// beta.19: the owner's library holds A Doll's Locket - Remake at the helper an earlier import took from butler's
/// verdict. This build guesses the NW.js runtime instead — and without matching the store's own id it would offer the
/// same game a second time beside the entry the owner already has (and re-points with Change executable…).
/// </summary>
[Fact]
public async Task AStoreTitleAlreadyInTheLibraryAtAnotherExecutableIsNotOfferedAgain()
{
var games = new FakeGameRepository();
var identity = new FakeIdentity();
var locator = new FakeLocator();
List<string> log = [];
const string install = @"D:\another\it\a-dolls-locket-remake";
const string helper = @"D:\ANOTHER\IT\A-DOLLS-LOCKET-REMAKE\DOLLS LOCKET\NOTIFICATION_HELPER.EXE";
GameRow old = await games.EnsureAsync(new ExecutableFingerprint { ExePath = helper, SizeBytes = 7, MtimeUnixMs = 7 }, "A Doll's Locket - Remake", Ct);
await games.ApplyStoreMetadataAsync(old.Id, new StoreMetadata { Platform = "itch", StoreId = "5085165" }, Ct);
identity.Existing.Add(helper);
identity.Existing.Add(@"D:\ANOTHER\IT\A-DOLLS-LOCKET-REMAKE\DOLLS LOCKET\CSS\GAME.EXE");
locator.Guesses[install] = install + @"\Dolls Locket\css\Game.exe";
var itch = new ScriptedStore("itch",
new StoreGame("itch", "5085165", "A Doll's Locket - Remake", install, null, null),
new StoreGame("itch", "1659887", "Plethora of Bullets 2", @"D:\another\it\plethora-of-bullets-2", @"D:\another\it\plethora-of-bullets-2\POB2.exe", null));
identity.Existing.Add(@"D:\ANOTHER\IT\PLETHORA-OF-BULLETS-2\POB2.EXE");
var importer = new LibraryImporter([itch], games, identity, locator, log.Add);
IReadOnlyList<ImportCandidate> found = await importer.DiscoverAsync(Ct);
ImportCandidate dolls = found.Single(static c => string.Equals(c.Game.StoreId, "5085165", StringComparison.Ordinal));
dolls.AlreadyInLibrary.Should().BeTrue("the same itch title is an entry already, at the executable an earlier import chose");
dolls.CanImport.Should().BeFalse();
found.Single(static c => string.Equals(c.Game.StoreId, "1659887", StringComparison.Ordinal)).CanImport.Should().BeTrue("another title of the same store is not matched");
log.Should().Contain(l => l.Contains("already in the library as " + helper, StringComparison.Ordinal));
(await importer.ImportAsync([.. found.Where(static c => c.CanImport)], Ct)).Added.Should().Be(1);
games.Rows.Should().HaveCount(2, "Plethora was added and A Doll's Locket stayed one entry");
}
/// <summary>
/// The entry's platform is the detection sweep's to refresh — an itch build that ships Steam's API reads as Steam — so the
/// same store id with the entry's executable inside the title's install folder is the same title too; outside it, an id
/// under another platform is another store's numbering, not this game.
/// </summary>
[Fact]
public async Task TheSameStoreIdInsideTheTitlesFolderIsTheSameTitleWhateverThePlatformReadsAs()
{
var games = new FakeGameRepository();
var identity = new FakeIdentity();
var locator = new FakeLocator();
const string install = @"D:\another\it\some-game";
const string old = @"D:\ANOTHER\IT\SOME-GAME\NOTIFICATION_HELPER.EXE";
GameRow entry = await games.EnsureAsync(new ExecutableFingerprint { ExePath = old, SizeBytes = 7, MtimeUnixMs = 7 }, "Some Game", Ct);
await games.ApplyStoreMetadataAsync(entry.Id, new StoreMetadata { Platform = "steam", StoreId = "42" }, Ct);
identity.Existing.Add(@"D:\ANOTHER\IT\SOME-GAME\GAME.EXE");
locator.Guesses[install] = install + @"\Game.exe";
identity.Existing.Add(@"D:\ANOTHER\IT\OTHER\OTHER.EXE");
locator.Guesses[@"D:\another\it\other"] = @"D:\another\it\other\Other.exe";
var itch = new ScriptedStore("itch",
new StoreGame("itch", "42", "Some Game", install, null, null),
new StoreGame("itch", "42", "Another store's 42", @"D:\another\it\other", null, null));
IReadOnlyList<ImportCandidate> found = await new LibraryImporter([itch], games, identity, locator, static _ => { }).DiscoverAsync(Ct);
found.Single(static c => string.Equals(c.Game.Name, "Some Game", StringComparison.Ordinal)).AlreadyInLibrary.Should().BeTrue("its entry's executable is inside the title's folder");
found.Single(static c => string.Equals(c.Game.Name, "Another store's 42", StringComparison.Ordinal)).CanImport.Should().BeTrue("the same number under another platform, elsewhere, is not this title");
}
[Fact]
public async Task AStoreThatThrowsCostsItsOwnTitlesAndTheSameExecutableUnderTwoStoresIsOneRow()
{
@@ -39,11 +39,10 @@ namespace FrameLedger.CaptureHost.Tests;
/// machine, so the record's path is pinned too.
/// </para>
/// <para>
/// <b>Category=Integration, and CI will not run it.</b> §S19(b): the guard refuses a
/// .NET test host that has loaded a <c>protect</c>-matching module, measured on CI.
/// On this dev box the guard allows it, so these are dev-box-reproducible and
/// merge-gate-absent — the same split <c>ShmDrainIntegrationTests</c> lives with, and
/// stated rather than implied.
/// <b>Category=Integration — and CI runs it.</b> This paragraph said CI would not (corrected 2026-10-07): §S19(b), the
/// guard refusing a .NET test host that had loaded a <c>protect</c>-matching module, was answered on 2026-09-06 by the
/// signer check, and <c>./build.ps1 check</c> runs the Integration category on CI since (<c>13_CI_CD</c> §ci.yml). A green
/// CI is evidence for this suite, and a race in it fails a merge: two did on 2026-10-07 (the two cases below that say so).
/// </para>
/// </remarks>
[Trait("Category", "Integration")]
@@ -454,13 +453,26 @@ public sealed class CaptureHostEndToEndTests : IDisposable
// P1 item 3, from OUTSIDE the process: the host launches the harness in its Vulkan mode with the
// layer's environment, the guard passes and injects nothing (TargetIsVulkanLayered), and the
// records come from the layer's ring. Skipped honestly where there is no Vulkan loader or no
// presentable device -- the harness says so with exit 77, which the session reports as
// LaunchTargetExited before any ring existed.
// presentable device -- the harness says so itself, with exit 77 and a "[SKIP]" line.
if (!File.Exists(Path.Combine(Environment.SystemDirectory, "vulkan-1.dll")))
{
Assert.Skip("no Vulkan loader on this machine");
}
// ASKED BEFORE THE HOST RUNS, of the harness itself (beta.18). This used to be read off the host's run: its output
// for the harness's "[SKIP]" line, or the session's LaunchTargetExited. Neither holds on a hosted runner, which has
// the loader and no device. The runner is elevated, so the host starts the harness through CreateProcessWithTokenW
// (UnelevatedProcess), which hands the child no stdout -- the line never reached the host's output -- and the
// harness's exit races the guard's poll: #288's CI run scanned it while it died and ended RefusedByGuard
// (ModuleScanFailed, "a module list came back incomplete"), failing where it should have skipped. Run directly, the
// harness's own output and exit code are this test's; and once it HAS presented here, every failure below is real.
(int probeExit, string probeOutput) = await ProbeVulkanAsync();
if (probeExit == 77)
{
Assert.Skip("the harness found no presentable Vulkan device on this machine: " + probeOutput);
}
probeExit.Should().Be(0, "the harness presents through Vulkan on this machine, or says why it cannot: " + probeOutput);
(await GrantConsentAsync()).Should().Be(ConsentWriteOutcome.Written);
using Process host = StartHost("launch", "--exe", ConsentedExecutable, "--args", "--vulkan --hold-presenting 8",
@@ -470,16 +482,6 @@ public sealed class CaptureHostEndToEndTests : IDisposable
await host.WaitForExitAsync(TestContext.Current.CancellationToken);
stdout += "\n---- stderr ----\n" + await stderrTask + $"\n---- exit {host.ExitCode} ----\n";
// The harness says so itself (exit 77, a "[SKIP]" line on the shared console) when this
// machine has a loader but no device -- a hosted runner's shape. Its exit races the guard's
// poll, so the session may read LaunchTargetExited or, if it died under the scan, whatever
// the scan could not read; the harness's own line is the signal that does not race.
if (stdout.Contains("[SKIP]", StringComparison.Ordinal)
|| stdout.Contains(nameof(SessionEndReason.LaunchTargetExited), StringComparison.Ordinal))
{
Assert.Skip("the harness found no presentable Vulkan device on this machine: " + stdout);
}
stdout.Should().Contain("vulkan layer: ", "the launch names the manifest it wrote and the enable-list entry");
stdout.Should().Contain("capture side: the Vulkan implicit layer", stdout);
stdout.Should().Contain("apiMask=0x8", "FL_API_VULKAN is bit 3; the ring is the layer's, not an Overlay's");
@@ -487,6 +489,34 @@ public sealed class CaptureHostEndToEndTests : IDisposable
host.ExitCode.Should().Be(0, stdout);
}
/// <summary>
/// The plain harness asked to present through Vulkan for a second, under its own name — never the consented copy, whose
/// name the host resolves its target by — with its output and exit code read here: 77 and a "[SKIP]" line where this
/// machine cannot, 0 where it can. Bounded: a driver that hangs is a failure to report, not a test that never ends.
/// </summary>
private static async Task<(int ExitCode, string Output)> ProbeVulkanAsync()
{
using var probe = Process.Start(new ProcessStartInfo(Harness, "--vulkan --hold-presenting 1")
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
})!;
using var bound = CancellationTokenSource.CreateLinkedTokenSource(TestContext.Current.CancellationToken);
bound.CancelAfter(TimeSpan.FromSeconds(60));
try
{
string output = await probe.StandardOutput.ReadToEndAsync(bound.Token).ConfigureAwait(false);
await probe.WaitForExitAsync(bound.Token).ConfigureAwait(false);
return (probe.ExitCode, output);
}
catch (OperationCanceledException e) when (!TestContext.Current.CancellationToken.IsCancellationRequested)
{
probe.Kill(entireProcessTree: true);
throw new TimeoutException("hook-harness --vulkan --hold-presenting 1 did not end within 60 s", e);
}
}
[Fact]
public async Task WhenTheTargetExitsTheHostStopsAndSaysWhy()
{
@@ -494,7 +524,11 @@ public sealed class CaptureHostEndToEndTests : IDisposable
// DLL_PROCESS_DETACH teardown — so this can only come from the held process handle.
(await GrantConsentAsync()).Should().Be(ConsentWriteOutcome.Written);
Process harness = StartHarness("--real --hold-presenting 6");
// 15 s, not 6 (beta.18): the host resolves its target once, as it starts, and on a loaded runner a host that took
// longer than the hold found the harness gone and ended TargetNotRunning — #286's first CI run, as on 2026-09-21
// and before. The host prints nothing until its session ends, so there is no "attached" to wait for; the hold is
// the margin, and the case's run time with it.
Process harness = StartHarness("--real --hold-presenting 15");
Process? host = null;
try
{
@@ -106,6 +106,51 @@ public sealed class ExecutableLocatorTests : IDisposable
new ExecutableLocator().PickPrimary(game).Should().Be(Path.Combine(game, "b.exe"));
}
/// <summary>
/// A Doll's Locket - Remake (itch, 2026-10-12), with its real names: a .NET launcher named after the install at the top
/// (213,745,664 bytes on disk — scaled down here, it only has to be the largest), NW.js's toast helper beside it, and the
/// RPG Maker MZ runtime one folder down beside its <c>nw.dll</c> and <c>package.json</c>. The runtime is the process
/// that draws (D56); the launcher only starts it.
/// </summary>
[Fact]
public async Task AnNwjsRuntimeBeatsTheLauncherNamedAfterTheInstallAndItsHelpersAreDropped()
{
string cave = Sub("a-dolls-locket-remake");
string game = Sub("a-dolls-locket-remake", "Dolls Locket");
string css = Sub("a-dolls-locket-remake", "Dolls Locket", "css");
await File.WriteAllBytesAsync(Path.Combine(game, "DollsLocket.exe"), new byte[3_000_000], Ct);
await File.WriteAllBytesAsync(Path.Combine(game, "notification_helper.exe"), new byte[919_552], Ct);
await File.WriteAllBytesAsync(Path.Combine(css, "Game.exe"), new byte[2_139_648], Ct);
await File.WriteAllBytesAsync(Path.Combine(css, "notification_helper.exe"), new byte[919_552], Ct);
await File.WriteAllBytesAsync(Path.Combine(css, "nw.dll"), new byte[10], Ct);
await File.WriteAllTextAsync(Path.Combine(css, "package.json"), "{\"name\":\"rmmz-game\",\"main\":\"index.html\"}", Ct);
new ExecutableLocator().PickPrimary(cave).Should().Be(Path.Combine(css, "Game.exe"),
"an executable beside nw.dll and package.json is the NW.js runtime; the larger launcher named after the install only starts it");
}
[Fact]
public async Task AnNwjsRuntimeAtTheRootIsTheGameAndAUnityPlayerOutranksAnNwjsToolBesideIt()
{
// Flower in Us (Steam): the runtime at the root, NW.js 0.82.0's helper beside it.
string flower = Sub("Flower in Us");
await File.WriteAllBytesAsync(Path.Combine(flower, "Game.exe"), new byte[2_191_360], Ct);
await File.WriteAllBytesAsync(Path.Combine(flower, "notification_helper.exe"), new byte[1_157_632], Ct);
await File.WriteAllBytesAsync(Path.Combine(flower, "nw.dll"), new byte[10], Ct);
await File.WriteAllTextAsync(Path.Combine(flower, "package.json"), "{}", Ct);
new ExecutableLocator().PickPrimary(flower).Should().Be(Path.Combine(flower, "Game.exe"));
// A Unity game shipping an NW.js tool: the NW.js rank sits below the engines' own layouts.
string unity = Sub("Some Unity Title");
string tool = Sub("Some Unity Title", "tools", "config");
Sub("Some Unity Title", "Title_Data");
await File.WriteAllBytesAsync(Path.Combine(unity, "Title.exe"), new byte[650_000], Ct);
await File.WriteAllBytesAsync(Path.Combine(tool, "Config.exe"), new byte[2_000_000], Ct);
await File.WriteAllBytesAsync(Path.Combine(tool, "nw.dll"), new byte[10], Ct);
await File.WriteAllTextAsync(Path.Combine(tool, "package.json"), "{}", Ct);
new ExecutableLocator().PickPrimary(unity).Should().Be(Path.Combine(unity, "Title.exe"), "X.exe beside X_Data outranks an NW.js folder");
}
[Theory]
[InlineData("ZFGameBrowser")]
[InlineData("KernelDumpAnalyzer")]
@@ -116,6 +161,22 @@ public sealed class ExecutableLocatorTests : IDisposable
[InlineData("CrashReportClient")]
[InlineData("UnityCrashHandler64")]
[InlineData("crashpad_handler")]
[InlineData("notification_helper")]
public void TheHelpersThisWasMeasuredOnAreHelpers(string name) =>
ExecutableLocator.IsHelper(name).Should().BeTrue();
/// <summary>
/// What may overrule a store's own pick is a whole name, never a fragment: <c>node</c> is a helper fragment and inside
/// a real game's name.
/// </summary>
[Theory]
[InlineData("notification_helper", true)]
[InlineData("NOTIFICATION_HELPER", true)]
[InlineData("crashpad_handler", true)]
[InlineData("UnityCrashHandler64", true)]
[InlineData("Nodebuster", false)]
[InlineData("Game", false)]
[InlineData("DollsLocket", false)]
public void OnlyWholeRuntimeHelperNamesOverruleAStore(string name, bool helper) =>
ExecutableLocator.IsRuntimeHelper(name).Should().Be(helper);
}
@@ -190,6 +190,35 @@ public sealed class StoreLibrarySourcesTests : IDisposable
log.Should().ContainSingle().Which.Should().Contain("butler.db read: 1 location(s), 4 cave(s), 4 title(s)").And.Contain("1 receipt(s), 1 new", "only the apps folder is scanned for receipts; the one beside a cave elsewhere is read for its title, not counted here");
}
/// <summary>
/// beta.19: butler's verdict for A Doll's Locket - Remake (game 5085165), as it is stored on the owner's machine — one
/// candidate, NW.js's toast helper, because butler keeps the shallowest candidates and drops the launcher that asks
/// for elevation. A helper is no game whoever names it: the row leaves the guess to the locator, and a verdict with a
/// real candidate after a helper still names that one.
/// </summary>
[Fact]
public async Task ItchSkipsAVerdictCandidateThatIsARuntimeHelper()
{
string itch = Sub("itch");
string location = Sub("it");
string dolls = Sub("it", "a-dolls-locket-remake", "Dolls Locket");
await File.WriteAllBytesAsync(Path.Combine(dolls, "notification_helper.exe"), new byte[10], Ct);
string other = Sub("it", "other-game");
await WriteButlerAsync(Path.Combine(itch, "db", "butler.db"), location, [
(5085165, "a-dolls-locket-remake", "", "A Doll's Locket - Remake",
"{\"basePath\":\"x\",\"candidates\":[{\"path\":\"Dolls Locket/notification_helper.exe\",\"depth\":2,\"flavor\":\"windows\",\"arch\":\"amd64\",\"size\":919552,\"windowsInfo\":{\"gui\":true}}]}"),
(42, "other-game", "", "Other Game",
"{\"candidates\":[{\"path\":\"crashpad_handler.exe\",\"flavor\":\"windows\"},{\"path\":\"Other.exe\",\"flavor\":\"windows\"}]}"),
]);
List<string> log = [];
IReadOnlyList<StoreGame> games = await new ItchLibrarySource(itch, log.Add).ListAsync(Ct);
games.Single(g => string.Equals(g.StoreId, "5085165", StringComparison.Ordinal)).ExePath.Should().BeNull("the only candidate is a helper, so the locator guesses");
games.Single(g => string.Equals(g.StoreId, "42", StringComparison.Ordinal)).ExePath.Should().Be(Path.Combine(other, "Other.exe"), "the first candidate that is not a helper");
log.Should().ContainSingle().Which.Should().Contain("named only a helper for A Doll's Locket - Remake").And.NotContain("Other Game");
}
[Fact]
public async Task ItchWithoutADatabaseOrWithAnUnreadableOneStillReadsReceipts()
{