Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5 9fb71827f4 fix(persistence): the migration mutex is the ledger file's, so a hung process no longer fails every other ledger
MigrationRunner took Local\FrameLedger.Ledger.Migrate for every ledger. On #199's CI
run Infrastructure.Tests froze (the in-process minidump this PR removes) while
one of its tests held it, and seven App and Agent tests - each on its own
scratch ledger - failed after 30 s with "another process has been migrating
the ledger". The name is the file's now: Migrate.<SHA-256 of the full path>,
MigrationRunner.LockNameFor.

MigrationLockTests: names differ per file and ignore case; a thread holding
another ledger's lock does not delay opening this one (on main it waited 30 s
and threw). 06_DATA_MODEL §Migrations, CHANGELOG.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 14:28:28 +07:00
poli0981andClaude Opus 5 31676ede62 fix(diagnostics): a failed dump names dbghelp's error instead of 0
CsWin32 0.3.298 declares MiniDumpWriteDump without SetLastError, so
Marshal.GetLastPInvokeError() read whatever an earlier call left - 0 when
measured on CreateNamedPipeW the same day (#201). The code is read with
GetLastSystemError at once, as CsWin32's own wrappers do, and printed as the
HRESULT dbghelp reports. ParentDumpTests: dumping a process that has exited
fails, leaves no file, and the line carries a non-zero code.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 14:23:33 +07:00
poli0981andClaude Opus 5 7bb74d058a fix(diagnostics): a crash dump is written by a child process, so it can no longer hang the process it describes
FrameLedger.Infrastructure.Tests hung about one run in eight (it cancelled the
first tag's release run after 58 minutes). The verbose reporter of a hung run
showed thirteen tests started and none finished, one of them
CrashDumpWriterTests.WritesAMinidumpOfThisProcess — which, like the product's
crash path in the App and the Agent, called MiniDumpWriteDump on the calling
process. That suspends every other thread of it; one holding the heap or
loader lock deadlocks the dumper and the whole process freezes. Forty runs
without that test: no hang.

- CrashDumpWriter.TryWrite starts FrameLedger.Agent.exe --write-crash-dump
  <file> and waits up to 30 s; a missing, failed or slow helper is a null path
  and one line, as before.
- ParentDump (the helper) dumps its PARENT with the same flags. It takes no pid
  and refuses unless the parent is still running, started before it, and has
  its image in the helper's own directory — the App or the Agent, never a game
  (CLAUDE.md rule 4). The self-contained install ships no createdump.exe.
- The Agent answers --write-crash-dump before logging, rules and the ledger.
- build.ps1: --blame-hang did not stop the hung xUnit v3 executable, so dotnet
  test runs under a 25-minute wall-clock limit, kills the tree on expiry, and
  names the test projects that wrote no results.trx (exercised locally: success,
  timeout-kill with nothing left alive, failure exit).
- Tests: ParentDumpTests (a real minidump of another process; which parent is
  ours), CrashDumpWriterTests (failing and missing dumper), CrashDumpHelperTests
  (the shipped Agent dumps the test process from outside; refuses a System32
  parent; the flag's surface). 40 runs of the suite with them: no hang, no
  failure.
- Docs: 10_LOGGING §Crash handling, 12_BUILD Agent flags, 13_CI_CD tally,
  CHANGELOG.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 13:49:45 +07:00
17 changed files with 533 additions and 64 deletions

No files matched your search

+24
View File
@@ -27,6 +27,30 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
## [Unreleased]
### Fixed
- **A crash dump can no longer hang the process it describes, and the test suite no longer freezes (2026-09-17).**
`FrameLedger.Infrastructure.Tests` hung about one run in eight — it cancelled the first tag's release run after 58
minutes — and the verbose reporter of a hung run showed thirteen tests started and none finished, one of them
`CrashDumpWriterTests.WritesAMinidumpOfThisProcess…`. That test, and the product's crash path in the App and the Agent,
called `MiniDumpWriteDump` on the calling process, which suspends every other thread of it; one holding the heap or
loader lock deadlocks the dumper, and the whole process freezes with it. Forty runs without the test: no hang. The dump
is written by a child now: `CrashDumpWriter.TryWrite` starts `FrameLedger.Agent.exe --write-crash-dump <file>` and waits
up to 30 s, and the helper (`Infrastructure.Diagnostics.ParentDump`) dumps its parent with the same flags — it takes no
pid and refuses unless the parent is still running, started before it and sits in the helper's own directory, so it can
only ever read the App or the Agent (CLAUDE.md rule 4). Forty runs of the suite with the new tests: no hang.
`--blame-hang` (#196) did not stop the hung xUnit v3 executable, so `build.ps1` runs `dotnet test` under a 25-minute
wall-clock limit, kills the tree on expiry and names the test projects that wrote no `results.trx`. Tests:
`ParentDumpTests` (a real minidump of another process; which parent is ours), `CrashDumpWriterTests` (a failing and a
missing dumper), `CrashDumpHelperTests` (the shipped Agent dumps the test process from outside; it refuses a parent
from System32; the flag's surface). Docs: `10_LOGGING` §Crash handling, `12_BUILD` Agent flags, `13_CI_CD` tally.
**A hang in one test process no longer fails the others.** The migration mutex was one name for every ledger
(`Local\FrameLedger.Ledger.Migrate`), so a suite frozen mid-migration held every other process's scratch ledger: on
#199's run `Infrastructure.Tests` hung and seven App and Agent tests failed after 30 s with "another process has been
migrating the ledger". It is the file's now (`MigrationRunner.LockNameFor`; `MigrationLockTests`; `06_DATA_MODEL`
§Migrations). And a failed dump names dbghelp's error instead of 0: CsWin32 declares `MiniDumpWriteDump` without
`SetLastError`, so the code is read with `GetLastSystemError` (`ParentDumpTests`: an exited process).
### Added
- **A session whose frame-generation state changed publishes its steady state, with its share (2026-09-17, owner
+25 -9
View File
@@ -68,6 +68,25 @@ function Invoke-Checked([string]$What, [scriptblock]$Body) {
if ($LASTEXITCODE -ne 0) { throw "$What failed (exit $LASTEXITCODE)" }
}
<#
`dotnet test` under a wall-clock limit (2026-09-17). `--blame-hang` does not stop a deadlocked xUnit v3 test
executable — measured: the hung process was still alive four minutes after a 60 s hang timeout — so a hang spent the
CI job's whole 60-minute budget and named nothing (the first tag's release run, 2026-09-16). This kills the process
tree after $Minutes and names the test projects that wrote no results.trx: the ones that did not finish.
#>
function Invoke-TestsWithin([int]$Minutes, [string[]]$Arguments) {
$p = Start-Process -FilePath 'dotnet' -ArgumentList $Arguments -NoNewWindow -PassThru
$null = $p.Handle # Start-Process quirk: without a cached handle ExitCode reads empty after exit
if (-not $p.WaitForExit($Minutes * 60 * 1000)) {
& taskkill /T /F /PID $p.Id 2>&1 | Out-Null
$unfinished = @(Get-ChildItem (Join-Path $repo 'tests') -Directory -Filter '*.Tests' |
Where-Object { -not (Test-Path (Join-Path $_.FullName 'TestResults/results.trx')) } |
ForEach-Object { $_.Name })
throw "dotnet test did not finish within $Minutes minutes — a test hung, and the process tree was killed. No results.trx from: $($unfinished -join ', ')"
}
if ($p.ExitCode -ne 0) { throw "dotnet test failed (exit $($p.ExitCode))" }
}
<#
Clear an ambient Platform variable before any MSBuild invocation.
@@ -261,19 +280,16 @@ function Invoke-Managed([bool]$FixFormat) {
# until the 60-minute job limit cancelled it, and the log named nothing. The
# timeout is per test host, well above the slowest suite (Agent, ~1.5 min on
# the hosted runner); the mini dump goes to TestResults beside the trx.
$hang = @('--blame-hang', '--blame-hang-timeout', '15m', '--blame-hang-dump-type', 'mini')
# --blame-hang did NOT stop the deadlocked xUnit v3 executable it was added for (measured 2026-09-17); the
# wall-clock limit of Invoke-TestsWithin is what bounds a hang now. The suite takes 4-5 minutes on the runner.
$testArgs = @('test', "`"$solution`"", '-c', $Configuration, '--no-build', '--collect:"XPlat Code Coverage"',
'--logger', 'trx;LogFileName=results.trx')
if ($SkipIntegration) {
Skip-Gate 'integration tests' 'the guard refuses a .NET test host that loads a `protect`-matching module (20_OPEN_QUESTIONS §S19(b)) — run ./build.ps1 check with no switches to include them'
Invoke-Checked 'dotnet test' {
dotnet test $solution -c $Configuration --no-build --collect:"XPlat Code Coverage" `
--logger 'trx;LogFileName=results.trx' --filter 'Category!=Integration' @hang
}
Invoke-TestsWithin 25 ($testArgs + @('--filter', 'Category!=Integration'))
}
else {
Invoke-Checked 'dotnet test' {
dotnet test $solution -c $Configuration --no-build --collect:"XPlat Code Coverage" `
--logger 'trx;LogFileName=results.trx' @hang
}
Invoke-TestsWithin 25 $testArgs
}
# The cobertura reports above were produced and ignored from the day the
+3 -1
View File
@@ -468,7 +468,9 @@ Sequential embedded SQL (`Migrations/0001_init.sql`, `0002_*.sql`, …), applied
> the assembly (so the schema a build applies is the one it was tested against), one transaction per
> script, under `Local\FrameLedger.Ledger.Migrate` — session-local rather than `Global\`, because the
> Agent and the UI share a session and the global namespace asks for a privilege a standard user need
> not hold. **A ledger at a version newer than the build's scripts is refused, not read**
> not hold. *(One name per ledger FILE since 2026-09-17 — `Migrate.<hash of the path>`,
> `MigrationRunner.LockNameFor`: with one name for every ledger, a test process frozen mid-migration held
> every other process's scratch ledger, and seven App and Agent tests failed after 30 s on #199's run.)* **A ledger at a version newer than the build's scripts is refused, not read**
> (`LedgerSchemaException`): guessing at a schema we do not understand is the one option that could
> turn a newer file into wrong answers. `LedgerDatabase` opens with the four pragmas above, one
> connection per process behind a gate, and every write in an explicit transaction — a failing blob
+11
View File
@@ -15,6 +15,17 @@
- On fatal: Serilog `Fatal` with full exception → write minidump via `MiniDumpWriteDump` (CsWin32, `MiniDumpWithIndirectlyReferencedMemory | WithThreadInfo`) to `crashdumps/` (keep last 5) → UI shows crash dialog offering the bug-report flow → exit code 1.
- Agent crash mid-session → `.partial` recovery path (04_CAPTURE) on next start finalizes an `interrupted` session.
> **Written by a child process since 2026-09-17.** `MiniDumpWriteDump` on the calling process suspends every other
> thread of it, and a suspended thread holding the process heap or loader lock deadlocks the dumper — Microsoft's
> documentation says to dump "from a separate process if at all possible". The in-process writer below froze the
> Infrastructure test suite one run in eight, and a crashing App or Agent is the unstable process the warning is about.
> `CrashDumpWriter.TryWrite` now starts `FrameLedger.Agent.exe --write-crash-dump <file>` (the Agent beside the App;
> the Agent's own binary for the Agent) and waits up to 30 s; the helper (`ParentDump`) dumps **its parent** with the
> same two flags, and nothing else: it takes no pid, and refuses unless the parent is still running, started before it,
> and has its image in the helper's own directory — the App or the Agent, never a game (CLAUDE.md rule 4). A missing,
> failed or slow helper is a null path and one Warning line, as before. The runtime's `createdump.exe` would have done
> the job, but a self-contained install does not ship it (measured on 0.1.0-beta.1).
>
> **Built 2026-09-15 (P4 PR-9).** `Infrastructure/Diagnostics/CrashDumpWriter` writes
> `crashdumps\<ui|agent>-<yyyyMMdd-HHmmss, UTC>-<pid>.dmp` through CsWin32's `MiniDumpWriteDump` with exactly the two
> flags above, keeps the five newest `*.dmp` of either process after each write, and never throws: a failure is a null
+1 -1
View File
@@ -88,7 +88,7 @@ Launch profiles:
Native debugging notes: use **`hook-harness`, never a real game**, for step-through debugging — a breakpoint inside a present hook of a real game freezes it in ways anti-cheat and drivers both dislike. Enable the Vulkan validation layers when touching `FrameLedger.VkLayer`. Application Verifier + PageHeap on the harness catches ring-buffer bugs early.
Agent flags: `--serve`, `--console`, ~~`--diag`~~ (the App's — `FrameLedger.exe --diag`, `10_LOGGING`; the Agent answers exit 2 for it), `--install-task`, `--uninstall-task`, `--register-vklayer`, `--unregister-vklayer` (all four real since 2026-09-14, P3 PR-8b: the task is `\FrameLedger\FrameLedger.Agent` through the Task Scheduler COM API — `schtasks /Create /SC ONLOGON` is "Access is denied" unelevated on the dev box, measured — this user's logon trigger, interactive token, lowest run level; the layer registration is `17_HOOK_ENGINE` §Vulkan's HKCU value).
Agent flags: `--serve`, `--console`, `--write-crash-dump <file>` (2026-09-17: the crash-dump helper a crashing App or Agent starts; it dumps its parent and takes no pid — `10_LOGGING` §Crash handling), ~~`--diag`~~ (the App's — `FrameLedger.exe --diag`, `10_LOGGING`; the Agent answers exit 2 for it), `--install-task`, `--uninstall-task`, `--register-vklayer`, `--unregister-vklayer` (all four real since 2026-09-14, P3 PR-8b: the task is `\FrameLedger\FrameLedger.Agent` through the Task Scheduler COM API — `schtasks /Create /SC ONLOGON` is "Access is denied" unelevated on the dev box, measured — this user's logon trigger, interactive token, lowest run level; the layer registration is `17_HOOK_ENGINE` §Vulkan's HKCU value).
> **Built 2026-09-10 (P2 PR-F): `--serve` and `--console`; the other five answer "not implemented in P2"
> with exit 2** rather than being silently accepted (`--diag` is the App's anyway, `10_LOGGING`). The console
+12 -2
View File
@@ -29,9 +29,19 @@ FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, an
- **A hang, not a refusal — the first tag run (2026-09-16, run 35111939019).** Every suite green except
`Infrastructure.Tests`, which printed its "test run for …" line and nothing else for 58 minutes until the job's
60-minute limit cancelled the run; the same suite took 42 s in the rehearsal an hour earlier. The log named no
test. `build.ps1` now passes `--blame-hang --blame-hang-timeout 15m --blame-hang-dump-type mini` to `dotnet test`,
test. ~~`build.ps1` now passes `--blame-hang --blame-hang-timeout 15m --blame-hang-dump-type mini` to `dotnet test`,
so the next hang fails the run in 15 minutes with the test's name in `TestResults\…\Sequence.xml` and a mini
dump beside it — the diagnostic this run lacked. Which test hung is **unmeasured**; the re-run is the measurement.
dump beside it — the diagnostic this run lacked. Which test hung is **unmeasured**; the re-run is the measurement.~~
**Found and fixed 2026-09-17.** Reproduced locally one run in eight; the xUnit verbose reporter of a hung run showed
thirteen tests started and none finished, one of them `CrashDumpWriterTests.WritesAMinidumpOfThisProcess…` — which
called `MiniDumpWriteDump` on its OWN process. That call suspends every other thread of the caller, and one holding
the heap or loader lock deadlocks the dumper: the whole test process froze, including xUnit's long-running-test
timer, which is why nothing was ever named. 40 runs without that test: no hang. **The same call was the product's
crash path**, in the App and the Agent — a real crash could have hung instead of dumping. Dumps are written by a
child process now (`Infrastructure.Diagnostics.ParentDump`, `FrameLedger.Agent.exe --write-crash-dump`; `10_LOGGING`
§Crash handling). And **`--blame-hang` did not stop the hung xUnit v3 executable** — still alive four minutes after
a 60 s hang timeout — so `build.ps1` runs `dotnet test` under a 25-minute wall-clock limit instead, kills the tree on
expiry, and names the test projects that wrote no `results.trx`.
- **Two more shapes had one cause, found and fixed 2026-09-16** after four failures in one evening's merge train:
`AKilledHostLeavesAPartialThatRecoverTurnsIntoAnInterruptedSession` ("the process cannot access the file …
`.partial`") and `WithNoConsentRecordTheHostRefusesAndNothingIsEverInjected` (a leftover consent record). The
@@ -31,6 +31,7 @@ internal sealed record AgentCommandLine
private const string _usage =
"usage: FrameLedger.Agent --serve\n"
+ " FrameLedger.Agent --register-vklayer | --unregister-vklayer | --install-task | --uninstall-task\n"
+ " FrameLedger.Agent --write-crash-dump <file> (started by a crashing App or Agent; dumps that parent)\n"
+ " FrameLedger.Agent --console [--data-dir <dir>] consent list | consent grant --exe <path> | consent revoke --exe <path>\n"
+ " | capture --exe <path> [--seconds <n>] | launch --exe <path> [--args \"<string>\"] [--seconds <n>]\n"
+ " | recover | sessions [--last <n>] | db path | games add --exe <path>\n"
@@ -58,6 +59,9 @@ internal sealed record AgentCommandLine
public string? DataDirectory { get; init; }
/// <summary>The file <see cref="AgentVerb.WriteCrashDump"/> writes — a path, never a pid.</summary>
public string? CrashDumpFile { get; init; }
/// <summary>The flag behind <see cref="AgentVerb.NotImplemented"/>.</summary>
public string? Flag { get; init; }
@@ -84,6 +88,13 @@ internal sealed record AgentCommandLine
: new AgentCommandLine { Error = $"{args[0]} takes no options" };
}
if (string.Equals(args[0], "--write-crash-dump", StringComparison.Ordinal))
{
return args.Length == 2 && !string.IsNullOrWhiteSpace(args[1])
? new AgentCommandLine { Verb = AgentVerb.WriteCrashDump, CrashDumpFile = args[1] }
: new AgentCommandLine { Error = "--write-crash-dump takes exactly one argument, the dump's file" };
}
if (string.Equals(args[0], "--serve", StringComparison.Ordinal))
{
return args.Length == 1
+7
View File
@@ -35,4 +35,11 @@ internal enum AgentVerb
/// <summary><c>--uninstall-task</c>.</summary>
UninstallTask,
/// <summary>
/// <c>--write-crash-dump &lt;file&gt;</c> (2026-09-17): the crash-dump helper. Dumps this process's PARENT — the App or
/// Agent that crashed and started it — when that parent's image is in this binary's directory; takes no pid
/// (<c>Infrastructure.Diagnostics.ParentDump</c>).
/// </summary>
WriteCrashDump,
}
+8 -1
View File
@@ -96,6 +96,13 @@ internal static class Program
/// <summary>A usage error or a flag this binary does not implement is answered before any file is touched.</summary>
private static int? AnswerWithoutLogging(AgentCommandLine cmd)
{
if (cmd.Verb == AgentVerb.WriteCrashDump)
{
// Before logging, rules and the ledger: the crashed parent still holds the day's log file, and a helper that
// waited on anything the parent holds would be the deadlock it exists to avoid.
return ParentDump.Run(cmd.CrashDumpFile!, AgentConsole.Problem);
}
if (cmd.Error is not null)
{
AgentConsole.Problem(cmd.Error);
@@ -183,7 +190,7 @@ internal static class Program
}
Log.Fatal(exception, "agent: unhandled exception ({Source}); the Agent exits", source);
string? dump = CrashDumpWriter.TryWrite(paths.CrashDumps, "agent", DateTimeOffset.UtcNow, static line => Log.Warning("{Line}", line));
string? dump = CrashDumpWriter.TryWrite(paths.CrashDumps, "agent", DateTimeOffset.UtcNow, Environment.ProcessPath, static line => Log.Warning("{Line}", line));
Log.Information("agent: crash dump {Dump}", dump ?? "not written");
}
+5 -2
View File
@@ -38,7 +38,7 @@ public partial class App : System.Windows.Application
{
/// <summary><c>10_LOGGING</c> §Crash handling (P4 PR-9): Fatal, the minidump, the crash dialog offering the bug report.</summary>
private readonly CrashReporter _crashes = new(
static () => CrashDumpWriter.TryWrite(UiPaths.CrashDumps, "ui", DateTimeOffset.UtcNow, static line => Log.Warning("{Line}", line)),
static () => CrashDumpWriter.TryWrite(UiPaths.CrashDumps, "ui", DateTimeOffset.UtcNow, CrashDumper, static line => Log.Warning("{Line}", line)),
CrashDialog.AskToReport,
static () =>
{
@@ -47,6 +47,9 @@ public partial class App : System.Windows.Application
return Services.GetRequiredService<BugReportFlow>().RunAsync();
});
/// <summary>The crash-dump helper: the Agent binary beside the App dumps this process from outside (<c>10_LOGGING</c> §Crash handling).</summary>
private static string CrashDumper => Path.Combine(AppContext.BaseDirectory, "FrameLedger.Agent.exe");
private IHost? _host;
private LedgerDatabase? _db;
private Task? _run;
@@ -378,7 +381,7 @@ public partial class App : System.Windows.Application
AppDomain.CurrentDomain.UnhandledException += static (_, args) =>
{
Log.Fatal(args.ExceptionObject as Exception, "ui: unhandled exception (AppDomain, terminating {Terminating})", args.IsTerminating);
string? dump = CrashDumpWriter.TryWrite(UiPaths.CrashDumps, "ui", DateTimeOffset.UtcNow, static line => Log.Warning("{Line}", line));
string? dump = CrashDumpWriter.TryWrite(UiPaths.CrashDumps, "ui", DateTimeOffset.UtcNow, CrashDumper, static line => Log.Warning("{Line}", line));
Log.Information("ui: crash dump {Dump}", dump ?? "not written");
Log.CloseAndFlush();
};
@@ -1,32 +1,40 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.System.Diagnostics.Debug;
namespace FrameLedger.Infrastructure.Diagnostics;
/// <summary>
/// <c>10_LOGGING</c> §Crash handling: on a fatal exception, a minidump of this process through <c>MiniDumpWriteDump</c>
/// (<c>MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithThreadInfo</c>) into <c>crashdumps\</c>, the newest five kept
/// (P4 PR-9). Called from a crash path, so it never throws: every failure is a null path and a line for the caller's log.
/// The dump stays on this machine; a bug bundle carries it only when the user says so (<c>legal/PRIVACY_POLICY.md</c> §3).
/// <c>10_LOGGING</c> §Crash handling (P4 PR-9): a minidump of the crashing process under <c>crashdumps\</c>, named
/// <c>&lt;process&gt;-&lt;UTC time&gt;-&lt;pid&gt;.dmp</c>, the five newest kept. Never throws: a crash path that throws is a
/// second crash.
/// </summary>
/// <remarks>
/// <b>Written by a child process since 2026-09-17</b> (<see cref="ParentDump"/> carries why): <see cref="TryWrite"/> starts
/// its dumper — the Agent binary, <c>--write-crash-dump &lt;file&gt;</c> — and waits for it to dump this
/// process from outside. Calling <c>MiniDumpWriteDump</c> on the calling process could deadlock it, and did, in the test
/// suite, one run in eight.
/// </remarks>
public static class CrashDumpWriter
{
/// <summary>How many dumps the directory keeps; the oldest beyond this go after each write.</summary>
/// <summary>How many dumps a directory keeps.</summary>
public const int Kept = 5;
/// <summary>The dump file pattern; <see cref="Prune"/> and the bug bundle read nothing else from the directory.</summary>
public const string Pattern = "*.dmp";
/// <summary>
/// Writes <c>&lt;process&gt;-&lt;yyyyMMdd-HHmmss&gt;-&lt;pid&gt;.dmp</c> (UTC) under <paramref name="directory"/> and prunes to
/// <see cref="Kept"/>. Returns the path, or null when nothing usable was written (the partial file is removed).
/// </summary>
public static unsafe string? TryWrite(string directory, string process, DateTimeOffset now, Action<string>? log = null)
/// <summary>The Agent flag that runs <see cref="ParentDump"/>.</summary>
public const string DumperFlag = "--write-crash-dump";
/// <summary>How long a crashing process waits for its dump. A dump of a busy process takes a second or two.</summary>
public static readonly TimeSpan Timeout = TimeSpan.FromSeconds(30);
/// <summary>The dump's path, or null — with one line to <paramref name="log"/> — when none was written.</summary>
/// <param name="directory">Where dumps are kept.</param>
/// <param name="process"><c>ui</c> or <c>agent</c>: the file name's prefix.</param>
/// <param name="now">The crash's time; the name carries it in UTC.</param>
/// <param name="dumper">The executable that dumps its parent: <c>FrameLedger.Agent.exe</c> beside the App, or the Agent itself.</param>
/// <param name="log">One line per failure.</param>
public static string? TryWrite(string directory, string process, DateTimeOffset now, string? dumper, Action<string>? log = null)
{
string? path = null;
try
@@ -35,23 +43,27 @@ public static class CrashDumpWriter
ArgumentException.ThrowIfNullOrWhiteSpace(process);
Directory.CreateDirectory(directory);
path = Path.Combine(directory, string.Create(CultureInfo.InvariantCulture, $"{process}-{now.UtcDateTime:yyyyMMdd-HHmmss}-{Environment.ProcessId}.dmp"));
bool written;
using (var file = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
using (Process self = Process.GetCurrentProcess())
if (dumper is null || !File.Exists(dumper))
{
written = PInvoke.MiniDumpWriteDump(
new HANDLE(self.Handle),
(uint)self.Id,
new HANDLE(file.SafeFileHandle.DangerousGetHandle()),
MINIDUMP_TYPE.MiniDumpWithIndirectlyReferencedMemory | MINIDUMP_TYPE.MiniDumpWithThreadInfo,
null,
null,
null);
log?.Invoke($"crash dump: not written — no dumper at {dumper ?? "(none)"}");
return null;
}
if (!written)
var start = new ProcessStartInfo(dumper) { UseShellExecute = false, CreateNoWindow = true };
start.ArgumentList.Add(DumperFlag);
start.ArgumentList.Add(path);
using Process helper = Process.Start(start) ?? throw new InvalidOperationException($"{dumper} did not start");
if (!helper.WaitForExit(Timeout))
{
log?.Invoke($"crash dump: MiniDumpWriteDump failed (Win32 error {Marshal.GetLastPInvokeError()})");
helper.Kill(entireProcessTree: true);
log?.Invoke($"crash dump: not written — the dumper did not finish within {Timeout.TotalSeconds:0} s");
TryDelete(path);
return null;
}
if (helper.ExitCode != ParentDump.ExitWritten || !File.Exists(path) || new FileInfo(path).Length == 0)
{
log?.Invoke($"crash dump: not written — the dumper exited {helper.ExitCode}");
TryDelete(path);
return null;
}
@@ -71,7 +83,7 @@ public static class CrashDumpWriter
}
}
/// <summary>Keeps the <see cref="Kept"/> newest dumps in <paramref name="directory"/>; a file that cannot be removed stays.</summary>
/// <summary>Keeps the <see cref="Kept"/> newest <c>*.dmp</c> in <paramref name="directory"/>; touches nothing else.</summary>
public static void Prune(string directory, Action<string>? log = null)
{
if (!Directory.Exists(directory))
@@ -0,0 +1,119 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using FrameLedger.Application.Watch;
using FrameLedger.Infrastructure.Watch;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.System.Diagnostics.Debug;
namespace FrameLedger.Infrastructure.Diagnostics;
/// <summary>
/// The dumping half of <see cref="CrashDumpWriter"/>: runs in a CHILD process (<c>FrameLedger.Agent.exe --write-crash-dump
/// &lt;file&gt;</c>) and writes a minidump of its PARENT — the App or Agent that just crashed.
/// </summary>
/// <remarks>
/// <para>
/// <b>Why a child (2026-09-17).</b> <c>MiniDumpWriteDump</c> on the calling process suspends every other thread of it and
/// then allocates and walks modules; a suspended thread holding the process heap or loader lock deadlocks the dumper
/// forever. Microsoft's documentation says to call it from a separate process "if at all possible". The in-process
/// version hung <c>FrameLedger.Infrastructure.Tests</c> about one run in eight — the test that dumped its own process froze
/// the twelve tests running beside it, output stopped after "Starting:", and it cancelled the first tag's release run
/// after 58 minutes. A crashing App or Agent is exactly the unstable process the documentation warns about, so the same
/// deadlock was waiting for a real crash. The installed runtime does not ship <c>createdump.exe</c> beside a self-contained
/// app, so the child is our own Agent binary.
/// </para>
/// <para>
/// <b>It dumps its parent and nothing else.</b> No pid is accepted — CLAUDE.md rule 4 forbids reading a game's memory and
/// §S27's lesson is that a verb naming a pid is how a tool gets aimed somewhere it should not go. The parent must still be
/// running, must have started before this process (a recycled pid is not our parent), and its image must sit in THIS
/// binary's own directory: the App and the Agent, never a game, which is never installed there.
/// </para>
/// </remarks>
public static class ParentDump
{
/// <summary>Written.</summary>
public const int ExitWritten = 0;
/// <summary>The parent is gone, or is not a FrameLedger binary from this directory: nothing was read.</summary>
public const int ExitRefused = 8;
/// <summary>The dump could not be written.</summary>
public const int ExitFailed = 9;
/// <summary>The same content the in-process writer produced: the referenced memory and per-thread information.</summary>
private const MINIDUMP_TYPE _kind = MINIDUMP_TYPE.MiniDumpWithIndirectlyReferencedMemory | MINIDUMP_TYPE.MiniDumpWithThreadInfo;
/// <summary>Dumps this process's parent into <paramref name="file"/>; the exit code the helper returns.</summary>
public static int Run(string file, Action<string> problem)
{
ArgumentException.ThrowIfNullOrWhiteSpace(file);
ArgumentNullException.ThrowIfNull(problem);
using Process self = Process.GetCurrentProcess();
IReadOnlyList<ProcessSnapshot> snapshot = new ToolhelpProcessSnapshotSource().Take();
ProcessSnapshot? me = snapshot.FirstOrDefault(p => p.Pid == self.Id);
ProcessSnapshot? parent = me is { } m ? snapshot.FirstOrDefault(p => p.Pid == m.ParentPid) : null;
if (me is not { } child || parent is not { } candidate || !IsOurs(candidate, child, AppContext.BaseDirectory))
{
problem($"crash dump: refused — the parent is gone or is not a FrameLedger binary from {AppContext.BaseDirectory}");
return ExitRefused;
}
try
{
using Process target = Process.GetProcessById(candidate.Pid);
return WriteDump(target, file, problem) ? ExitWritten : ExitFailed;
}
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or System.ComponentModel.Win32Exception)
{
problem($"crash dump: the parent could not be opened ({ex.GetType().Name}: {ex.Message})");
return ExitRefused;
}
}
/// <summary>
/// The only process this helper will read: still running, started before the helper (not a recycled pid), and whose
/// image is in <paramref name="helperDirectory"/>.
/// </summary>
public static bool IsOurs(ProcessSnapshot parent, ProcessSnapshot helper, string helperDirectory)
{
ArgumentException.ThrowIfNullOrWhiteSpace(helperDirectory);
if (parent.ImagePath is not { Length: > 0 } image || parent.StartedAt is not { } parentStarted || helper.StartedAt is not { } helperStarted)
{
return false;
}
string imageDirectory = Path.GetFullPath(Path.GetDirectoryName(image) ?? string.Empty).TrimEnd(Path.DirectorySeparatorChar);
string ours = Path.GetFullPath(helperDirectory).TrimEnd(Path.DirectorySeparatorChar);
return parentStarted <= helperStarted && string.Equals(imageDirectory, ours, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Writes a minidump of <paramref name="target"/> — another process — into <paramref name="file"/>.</summary>
public static unsafe bool WriteDump(Process target, string file, Action<string> problem)
{
ArgumentNullException.ThrowIfNull(target);
ArgumentException.ThrowIfNullOrWhiteSpace(file);
ArgumentNullException.ThrowIfNull(problem);
bool written;
int error;
using (var stream = new FileStream(file, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
{
written = PInvoke.MiniDumpWriteDump(new HANDLE(target.Handle), (uint)target.Id, new HANDLE(stream.SafeFileHandle.DangerousGetHandle()), _kind, null, null, null);
// At once, and the SYSTEM error: CsWin32 0.3.298 declares MiniDumpWriteDump without SetLastError, so
// GetLastPInvokeError() is whatever an earlier call left (0 when measured on CreateNamedPipeW, 2026-09-17). The
// value is an HRESULT, which is how dbghelp reports this function's failures.
error = Marshal.GetLastSystemError();
}
if (!written)
{
problem($"crash dump: MiniDumpWriteDump failed (0x{error:X8})");
File.Delete(file);
}
return written;
}
}
@@ -1,5 +1,7 @@
using System.Globalization;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using Dapper;
using Microsoft.Data.Sqlite;
@@ -14,11 +16,22 @@ public static class MigrationRunner
{
private const string _resourcePrefix = "FrameLedger.Infrastructure.Persistence.Migrations.";
private const string _mutexPrefix = @"Local\FrameLedger.Ledger.Migrate.";
/// <summary>
/// One per session (<c>Local\</c>), because the Agent and the UI run in the same session and the
/// <c>Global\</c> namespace asks for a privilege a standard user need not hold.
/// The mutex that serialises migrations of the ledger at <paramref name="databasePath"/>: in this session's namespace
/// (<c>Local\</c>, because the Agent and the UI run in the same session and <c>Global\</c> asks for a privilege a
/// standard user need not hold), and one per FILE since 2026-09-17. One name for every ledger let a test process that
/// froze mid-migration hold every other process's scratch ledger: seven App and Agent tests failed after 30 s on #199's
/// run while <c>Infrastructure.Tests</c> hung.
/// </summary>
private const string _mutexName = @"Local\FrameLedger.Ledger.Migrate";
public static string LockNameFor(string? databasePath)
{
string key = databasePath is { Length: > 0 } path && !path.StartsWith(':')
? Path.GetFullPath(path).ToUpperInvariant()
: databasePath ?? string.Empty;
return _mutexPrefix + Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(key)), 0, 16);
}
/// <summary>The highest script version this build carries.</summary>
public static int LatestVersion => Scripts().Keys.Max();
@@ -54,7 +67,7 @@ public static class MigrationRunner
// The mutex serialises two processes opening the same file at once; the transaction below and
// schema_migrations' primary key serialise the rest. Taken synchronously: this runs once, at open.
using var mutex = new Mutex(initiallyOwned: false, _mutexName);
using var mutex = new Mutex(initiallyOwned: false, LockNameFor(connection.DataSource));
bool held = false;
try
{
@@ -0,0 +1,83 @@
using System.Diagnostics;
using FluentAssertions;
using FrameLedger.Agent.Cli;
using FrameLedger.Infrastructure.Diagnostics;
namespace FrameLedger.Agent.Tests;
/// <summary>
/// The product's crash-dump path end to end (2026-09-17): <see cref="CrashDumpWriter.TryWrite"/> starts the shipped
/// <c>FrameLedger.Agent.exe --write-crash-dump</c>, which dumps its parent — here, this test process, whose binary sits in
/// the same directory as the Agent's copy, as the App's does in an install. The dump is taken from OUTSIDE, so nothing in
/// this process is suspended by the process that is writing it; the in-process version froze a parallel test run one
/// time in eight.
/// </summary>
public sealed class CrashDumpHelperTests : IDisposable
{
private static string Agent => Path.Combine(AppContext.BaseDirectory, "FrameLedger.Agent.exe");
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-crashdump-" + Guid.NewGuid().ToString("N"));
public void Dispose()
{
try
{
Directory.Delete(_dir, recursive: true);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
}
}
[Fact]
public void TheWriterHasTheAgentDumpThisProcessFromOutside()
{
File.Exists(Agent).Should().BeTrue("the Agent must be built and copied beside this test");
var lines = new List<string>();
var now = new DateTimeOffset(2026, 9, 15, 1, 2, 3, TimeSpan.FromHours(7));
string? path = CrashDumpWriter.TryWrite(_dir, "test", now, Agent, lines.Add);
path.Should().NotBeNull("the Agent dumps its parent, this test process: {0}", string.Join(" | ", lines));
Path.GetFileName(path).Should().Be($"test-20260914-180203-{Environment.ProcessId}.dmp", "the name carries the UTC time and the crashing pid");
byte[] head = new byte[4];
using (var file = new FileStream(path!, FileMode.Open, FileAccess.Read, FileShare.Read))
{
file.ReadExactly(head);
}
head.Should().Equal("MDMP"u8.ToArray());
lines.Should().BeEmpty();
}
[Fact]
public void TheHelperRefusesAParentThatIsNotAFrameLedgerBinaryFromItsDirectory()
{
// cmd.exe from System32 is the parent here: the helper must read nothing and write nothing.
Directory.CreateDirectory(_dir);
string file = Path.Combine(_dir, "refused.dmp");
var start = new ProcessStartInfo(Path.Combine(Environment.SystemDirectory, "cmd.exe")) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardError = true };
start.ArgumentList.Add("/c");
start.ArgumentList.Add(Agent);
start.ArgumentList.Add(CrashDumpWriter.DumperFlag);
start.ArgumentList.Add(file);
using Process cmd = Process.Start(start)!;
string stderr = cmd.StandardError.ReadToEnd();
cmd.WaitForExit(30_000).Should().BeTrue();
cmd.ExitCode.Should().Be(ParentDump.ExitRefused, stderr);
stderr.Should().Contain("refused");
File.Exists(file).Should().BeFalse();
}
[Fact]
public void TheFlagTakesAFileAndNothingElse()
{
AgentCommandLine parsed = AgentCommandLine.Parse(["--write-crash-dump", @"C:\x\a.dmp"]);
parsed.Verb.Should().Be(AgentVerb.WriteCrashDump);
parsed.CrashDumpFile.Should().Be(@"C:\x\a.dmp");
AgentCommandLine.Parse(["--write-crash-dump"]).Error.Should().Contain("exactly one argument");
AgentCommandLine.Parse(["--write-crash-dump", "a.dmp", "--data-dir", "x"]).Error.Should().Contain("exactly one argument");
AgentCommandLine.Parse(["--console", "--write-crash-dump", "a.dmp"]).Error.Should().Contain("usage", "a flag, not a console verb");
}
}
@@ -22,25 +22,25 @@ public sealed class CrashDumpWriterTests : IDisposable
}
}
/// <summary>
/// 2026-09-17: this class used to dump ITS OWN process, and MiniDumpWriteDump on the calling process suspends every other
/// thread of it — one run in eight, a suspended test thread held a lock the dumper needed and the whole suite froze
/// (it cancelled the first tag's release run). The dump is written by a child process now; this is the writer's side of
/// that contract with a dumper that fails, and <see cref="ParentDumpTests"/> dumps a real child process.
/// </summary>
[Fact]
public void WritesAMinidumpOfThisProcessNamedByProcessUtcTimeAndPid()
public void ADumperThatFailsOrIsMissingLeavesNoFileAndOneLine()
{
var lines = new List<string>();
var now = new DateTimeOffset(2026, 9, 15, 1, 2, 3, TimeSpan.FromHours(7));
string where = Path.Combine(Environment.SystemDirectory, "where.exe");
string? path = CrashDumpWriter.TryWrite(_dir, "test", now, lines.Add);
CrashDumpWriter.TryWrite(_dir, "test", DateTimeOffset.UtcNow, where, lines.Add).Should().BeNull("where.exe does not know the flag and exits non-zero");
lines.Should().ContainSingle().Which.Should().StartWith("crash dump: not written — the dumper exited");
Directory.EnumerateFiles(_dir, "*.dmp").Should().BeEmpty();
path.Should().NotBeNull("MiniDumpWriteDump of our own process succeeds: {0}", string.Join(" | ", lines));
Path.GetFileName(path).Should().Be($"test-20260914-180203-{Environment.ProcessId}.dmp", "the name carries the UTC time");
Path.GetDirectoryName(path).Should().Be(_dir);
byte[] head = new byte[4];
using (var file = new FileStream(path!, FileMode.Open, FileAccess.Read, FileShare.Read))
{
file.ReadExactly(head);
}
head.Should().Equal("MDMP"u8.ToArray(), "a minidump starts with its signature");
lines.Should().BeEmpty();
lines.Clear();
CrashDumpWriter.TryWrite(_dir, "test", DateTimeOffset.UtcNow, Path.Combine(_dir, "absent.exe"), lines.Add).Should().BeNull();
lines.Should().ContainSingle().Which.Should().Contain("no dumper");
}
[Fact]
@@ -73,7 +73,7 @@ public sealed class CrashDumpWriterTests : IDisposable
File.WriteAllText(occupied, "a file where the directory should be");
var lines = new List<string>();
string? path = CrashDumpWriter.TryWrite(occupied, "ui", DateTimeOffset.UtcNow, lines.Add);
string? path = CrashDumpWriter.TryWrite(occupied, "ui", DateTimeOffset.UtcNow, dumper: null, lines.Add);
path.Should().BeNull();
lines.Should().ContainSingle().Which.Should().StartWith("crash dump: not written");
@@ -0,0 +1,93 @@
using System.Diagnostics;
using FluentAssertions;
using FrameLedger.Application.Watch;
using FrameLedger.Infrastructure.Diagnostics;
namespace FrameLedger.Infrastructure.Tests.Diagnostics;
/// <summary>
/// The dumping half of the crash-dump contract (2026-09-17): a minidump of ANOTHER process, and the rule for which process
/// the helper will read — its parent, still running, started before it, from the helper's own directory, never a pid.
/// </summary>
public sealed class ParentDumpTests : IDisposable
{
private static readonly DateTimeOffset _t0 = new(2026, 9, 17, 10, 0, 0, TimeSpan.Zero);
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-parentdump-" + Guid.NewGuid().ToString("N"));
public ParentDumpTests() => Directory.CreateDirectory(_dir);
public void Dispose()
{
try
{
Directory.Delete(_dir, recursive: true);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
}
}
[Fact]
public void AnotherProcessIsDumpedFromOutsideAndTheFileIsAMinidump()
{
// A child that just waits: dumping it cannot suspend THIS process, which is the whole point.
using Process child = Process.Start(new ProcessStartInfo(Path.Combine(Environment.SystemDirectory, "ping.exe"), "-n 30 127.0.0.1") { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true })!;
string file = Path.Combine(_dir, "child.dmp");
var problems = new List<string>();
try
{
ParentDump.WriteDump(child, file, problems.Add).Should().BeTrue(string.Join(" | ", problems));
}
finally
{
child.Kill();
child.WaitForExit(10_000);
}
byte[] head = new byte[4];
using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
{
stream.ReadExactly(head);
}
head.Should().Equal("MDMP"u8.ToArray(), "a minidump starts with its signature");
problems.Should().BeEmpty();
}
[Fact]
public void AFailedDumpLeavesNoFileAndNamesTheErrorDbghelpReturned()
{
// A process that has exited has nothing to read, so the dump fails. The line must carry dbghelp's code: CsWin32
// declares MiniDumpWriteDump without SetLastError, and GetLastPInvokeError read 0.
using Process child = Process.Start(new ProcessStartInfo(Path.Combine(Environment.SystemDirectory, "cmd.exe"), "/c exit 0") { UseShellExecute = false, CreateNoWindow = true })!;
child.WaitForExit(10_000).Should().BeTrue();
string file = Path.Combine(_dir, "exited.dmp");
var problems = new List<string>();
ParentDump.WriteDump(child, file, problems.Add).Should().BeFalse("an exited process cannot be dumped");
File.Exists(file).Should().BeFalse();
problems.Should().ContainSingle().Which.Should().StartWith("crash dump: MiniDumpWriteDump failed (0x").And.NotContain("0x00000000");
}
[Fact]
public void OnlyAParentFromTheHelpersOwnDirectoryThatStartedFirstIsOurs()
{
string ours = Path.Combine(_dir, "app");
var helper = new ProcessSnapshot(200, 100, "FrameLedger.Agent.exe", Path.Combine(ours, "FrameLedger.Agent.exe"), _t0.AddSeconds(5));
ParentDump.IsOurs(new ProcessSnapshot(100, 1, "FrameLedger.exe", Path.Combine(ours, "FrameLedger.exe"), _t0), helper, ours)
.Should().BeTrue("the App beside the helper, started before it");
ParentDump.IsOurs(new ProcessSnapshot(100, 1, "FrameLedger.exe", Path.Combine(ours, "FrameLedger.exe"), _t0), helper, ours + Path.DirectorySeparatorChar)
.Should().BeTrue("a trailing separator is the same directory");
ParentDump.IsOurs(new ProcessSnapshot(100, 1, "Game.exe", @"D:\Games\Game\Game.exe", _t0), helper, ours)
.Should().BeFalse("a game is never installed beside FrameLedger — CLAUDE.md rule 4");
ParentDump.IsOurs(new ProcessSnapshot(100, 1, "FrameLedger.exe", Path.Combine(ours, "FrameLedger.exe"), _t0.AddSeconds(10)), helper, ours)
.Should().BeFalse("a 'parent' that started after the helper is a recycled pid, not the parent");
ParentDump.IsOurs(new ProcessSnapshot(100, 1, "FrameLedger.exe", null, _t0), helper, ours)
.Should().BeFalse("an image nobody could read is not proven ours");
ParentDump.IsOurs(new ProcessSnapshot(100, 1, "FrameLedger.exe", Path.Combine(ours, "FrameLedger.exe"), null), helper, ours)
.Should().BeFalse();
}
}
@@ -0,0 +1,58 @@
using System.Diagnostics;
using FluentAssertions;
using FrameLedger.Infrastructure.Persistence;
namespace FrameLedger.Infrastructure.Tests.Persistence;
/// <summary>
/// The migration mutex is the ledger file's, not the session's (2026-09-17). With one name for every ledger, a test process
/// that froze mid-migration — <c>Infrastructure.Tests</c> on #199's run — held every other process's scratch ledger, and
/// seven App and Agent tests failed after 30 s with "another process has been migrating the ledger".
/// </summary>
public sealed class MigrationLockTests
{
private static CancellationToken Ct => TestContext.Current.CancellationToken;
[Fact]
public void EachLedgerFileHasItsOwnNameHoweverItIsSpelled()
{
string a = Path.Combine(Path.GetTempPath(), "fl-migrate-a", LedgerPaths.DatabaseFileName);
string b = Path.Combine(Path.GetTempPath(), "fl-migrate-b", LedgerPaths.DatabaseFileName);
MigrationRunner.LockNameFor(a).Should().StartWith(@"Local\FrameLedger.Ledger.Migrate.").And.NotBe(MigrationRunner.LockNameFor(b));
MigrationRunner.LockNameFor(a.ToUpperInvariant()).Should().Be(MigrationRunner.LockNameFor(a));
}
[Fact]
public async Task AMigrationHeldOnOneLedgerDoesNotHoldAnother()
{
// A thread that takes another ledger's lock and keeps it stands in for the frozen process.
string other = Path.Combine(Path.GetTempPath(), "fl-migrate-held-" + Guid.NewGuid().ToString("N"), LedgerPaths.DatabaseFileName);
using var taken = new ManualResetEventSlim();
using var release = new ManualResetEventSlim();
var holder = new Thread(() =>
{
using var mutex = new Mutex(initiallyOwned: false, MigrationRunner.LockNameFor(other));
mutex.WaitOne();
taken.Set();
release.Wait();
mutex.ReleaseMutex();
})
{ IsBackground = true };
holder.Start();
taken.Wait(Ct);
try
{
var clock = Stopwatch.StartNew();
await using LedgerFixture f = await LedgerFixture.OpenAsync().ConfigureAwait(true);
clock.Elapsed.Should().BeLessThan(TimeSpan.FromSeconds(15), "another ledger's migration is not this one's; one shared name waited 30 s and threw");
f.Db.SchemaVersion.Should().Be(MigrationRunner.LatestVersion);
}
finally
{
release.Set();
holder.Join();
}
}
}