Skip to content

#613 Workbench as a database companion — nine features, the cooperative lock handoff, and the QA sweep that followed - #810

Merged
nockawa merged 46 commits into
mainfrom
feature/613-workbench-db-companion
Aug 15, 2026
Merged

nockawa merged 46 commits into
mainfrom
feature/613-workbench-db-companion

Conversation

@nockawa

@nockawa nockawa commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #621. Completes epic #613 (F1–F9); the other eight sub-issues are already closed.

The Workbench stops being a viewer you open separately and becomes the companion to a database: it knows that database's captures, bridges what a capture recorded to what the database holds, and steps aside when you run your app.

Design: 10-database-and-profiles.md · 11-cooperative-lock-handoff.md. What shipped and every deviation is recorded in their §1.x / §9.x sections. Docs land in log2n-io/Typhon-Claude on the matching branch.

What ships

F1/F2 #614 #615 Captures name the database that recorded them; a rename is recorded rather than destroying the evidence
F3 #616 Captures live in {db}.typhon/profilings/ with a retention budget, enforced by whoever writes them — not by the Workbench, which is not always installed
F4 #617 Profiles as a session sub-resource; a capture attaches to the open database instead of being a separate session
F5 #618 Structural bridges: systems ↔ components, query → index, per-component drift in TSN
F6 #619 Physical lens — from a slow system to where that archetype's data actually lives
F7 #620 Entity lens — spawn/destroy cohorts, joined to live entities. Needed an engine change: SpawnBatch emitted nothing, so bulk-loaded worlds had no cohorts at all
F8 #621 Cooperative lock handoff — the Workbench yields its database to your app and resumes when it exits, staying useful (profiler, integrity) while released
F9 #622 Machine-local registry, so a database a server or sample app created is findable

Why it is safe to join a capture to a database: EntityId is monotonic and never recycled, TSN is durable across restarts, and SchemaHistoryR1 is an audit trail — so an old id names that entity or nothing, drift is measured rather than guessed, and it is itemisable per component. Where a guarantee cannot be met the UI falls to a weaker one, never to a plausible wrong one.

Engine-side

The QA sweep

Roughly half these commits come from walking the branch end-to-end as a user (the walkthrough), which found things no test did:

  • The second lock handoff never happened. Resume forgot its watch, so a live session advertised yieldable with nobody watching for claims — every handoff after the first timed out. All three existing yield tests pass with the bug in place; the failure table had a dozen rows for one handoff and none for two.
  • typhon ui <typo>.typhon created a 565 KB database instead of failing, and the Workbench did the same for a mistyped session path. A viewer never creates data.
  • "Schema incompatible" was the wrong word for a DLL that was merely not on the search path, and the button offering to fix it opened a panel that hung forever on two unauthenticated GETs.
  • Panels were laid out wider than their pane — dockview's .dv-content-container defaults to min-width: auto, so a 424 px panel sat inside a 260 px group and the difference was silently clipped. One cause behind both "content is right-aligned" and "no scrollbar ever appears".

Verification

bash scripts/pre-push.sh — all gate-equivalent checks passed:

Engine (Release) 5444 passed, 0 failed
Workbench (Release) 677 passed, 0 failed
Shell 34 passed, 0 failed
Client 1939 passed · tsc --noEmit · eslint clean
Policy rule-scopes, rule-coverage, doc-links all clean

Two findings worth flagging, both chased to ground rather than retried:

  1. Three engine failures turned out to be [Category("Quarantine")] — two of them fail identically on unmodified main, and the gate excludes the category by design.
  2. One Workbench failure was real and mine: my new handoff test ends mid-protocol (paused, claim standing), leaving the coordinator polling into the next test. Isolated by running the full Release suite with the production fix in and the new test filtered out — green — so the fix is innocent and the test now cleans up its own protocol state. Green twice since.

Notes for review

nockawa added 30 commits August 15, 2026 02:55
…om, and a rename destroyed the only evidence linking its old name to its new one

Two halves of making a capture self-describing (Epic #613). They land together because both edit DatabaseEngine.cs and cannot be split by file.

#614 — trace format v11 to v12. A capture now records the database it ran against (a new durable BK_DatabaseId, minted once at creation), the transaction window it spans, its duration, tick count and a schema fingerprint, so a list of thirty captures renders from headers alone instead of building thirty sidecar caches.

The landmine this closes: a trace carries archetype identity in two incompatible ushort spaces — the per-process catalog id in events, and the per-database routing id in the low 16 bits of every EntityId. Nothing distinguishes them, so a naive join is wrong for every archetype whose registration order differs from its routing order, and right in any freshly-created test database. It passes fixtures and fails on real data. ArchetypeRecord now carries the routing id, and TraceArchetypeIdentity is the only sanctioned reader of it. When more than one engine was live during a capture the ids are ambiguous, so they are stripped from the file at close and a header flag says so — the trace carries less rather than something plausible and wrong.

#615 — renames are journalled into SchemaHistoryR1 at the instant they are carried forward, which is the only moment both names are known: [Component(PreviousName=...)] is explicitly meant to be deleted once the row has been re-keyed, after which an old capture says Health, the database says Vitality, and nothing maps between them. Repeated renames leave a chain that resolves forward.

That needed a system component to change layout, and system components have no evolution path — LoadSystemSchemaR1 rebuilds their tables from the CLR types at a hardcoded revision, and the chunk stride is fixed at creation, so the change would have reinterpreted existing rows with no error at all. BK_SystemSchemaRevision becomes load-bearing for the first time: it is now 2, and a mismatch is refused in both directions. Existing databases must be recreated.

Also fixed along the way: a constructor that threw left a half-built engine which DI still disposed, and the final-persistence steps faulted on the incomplete state, burying the real exception under a NullReferenceException.
… be, with nothing tying them to a database and no bound on how much disk they took

Captures now live inside the database they profile, at {name}.typhon/profilings/{timestamp}.typhon-trace. Correlation becomes structural — given a capture, its database is two levels up — instead of being inferred from a fingerprint after the fact. Timestamp names sort chronologically as text, so a directory listing is already the order a profiles list wants.

profilings/ is bounded by a policy stored beside the captures in retention.json, and enforced by whoever writes a capture rather than by the Workbench: a game server, a CI box or a customer deployment records captures with no tooling installed, and a budget only the Workbench honoured would leave those disks filling exactly as before. Without a policy file the built-in default applies (20 GiB, keep 10) rather than no limit.

Pinned captures count toward the budget and are never evicted — exempting them would make the number a lie precisely when it matters, since pinning 200 GB would still read as 18 of 20 GB while the disk fills. The keep-latest floor wins over the budget. Derived -cache sidecars are reclaimed first and accounted separately, because they are regenerable and captures are not. A capture open in a session is never evicted, enforced not by consulting a session registry the writer cannot see but by the delete simply failing — which also protects a capture opened by any other tool.

Breaking change: an absent Typhon:Profiler:Trace used to mean "collect, export nothing" and now means "a capture in the database's profilings/". Trace=none is the new way to ask for no capture file, which is what the engine test suite uses — taking the old meaning away silently cost that suite 20 seconds a run and attached a file exporter to the process-global profiler that other fixtures did not expect.
…eparate session, so nothing could correlate them with the database they came from

F1-F3 made a capture self-describing, kept renames resolvable and put captures inside the bundle at {name}.typhon/profilings/. All three were plumbing with nothing on top: opening a database still told you nothing about what had been recorded against it, and opening a capture meant a peer session that had lost the database entirely.

A profile now attaches TO the open session rather than replacing it. The database is the persistent context, the profile a transient lens, which is what keeps one session id, one token and one customFetch — the client's single-session choke point is never touched.

Panels follow what a session can DO, not what it is. An open database with a capture attached is still kind Open and its profiler panels must nonetheless appear, which no session-kind enum can express. ISession gains Capabilities; the nine /profiler/* guards became one TryGetProfilerRuntime helper and the routes did not move.

The Profiles panel lists the database's captures from trace headers alone — about 200 bytes per file, no sidecar cache built — with the drift readout that turns "this profile is old" into "this profile is 124 transactions behind".

Three defects found by driving the feature in a browser, each sitting in a seam between layers that were individually correct and individually tested:

- Attaching a profile did not make the profiler panels appear, which was the entire point. The session is not backed by a TanStack query — every entry point pushes the DTO into Zustand imperatively — so invalidateQueries(['session']) matched no key and did nothing. The mutations now re-read the session and setSession the result.
- A rejected attach rendered nothing at all. The wrong-database guard is not an edge case, it is what fires on a copied or restored bundle, and clicking such a row looked identical to clicking dead space.
- The drift column showed "290 txns behind" for a capture belonging to another database — a subtraction across two unrelated TSN sequences, which is worse than a dash because it reads as an answer. ProfileDto now carries BelongsToDatabase and such a row reads "other database".

Also fixes a pre-existing wart that #617 is what made expressible: useQueryDefinitions gated only on having a session and the command palette that calls it is always mounted, so every plain database open fired /profiler/queries and logged the 409 the server correctly answers with. Opening a database is now console-clean.

DatabaseEngine.DatabaseId becomes public and gains CurrentTsn (the drift readout's right-hand side); TraceLocation moves to Profiler/public as F4 planned.
…oin that could give it one silently matched nothing

A database records components, archetypes and indexes; it records nothing about the systems that read and write them. That dimension exists only in a capture, so "which systems touch this component?" and "is this query's field actually indexed?" were unanswerable the moment you were looking at a file rather than a live engine.

Both bridges join a capture's declarations to the database's schema by component name, and the two sides do not spell that name the same way. A capture's access declarations carry the CLR full name; the database is keyed by the [Component("...")] schema name. Comparing them directly compiles, reads naturally, and matches nothing at all — which is exactly what the access chips were doing, presenting an empty result as "no system touches this component" rather than as a failed lookup. traceIdentityOf is the hop that makes the two comparable, and it lives in one place so the next consumer cannot reinvent the broken comparison.

The Context Bar now shows both coordinates at once — the database's HEAD and the attached capture's window, with the drift between them — because a reading taken from a capture and a reading taken from the database are not the same instant, and nothing on screen said so.

Attaching a capture flips an Open session's profiler capability, and for the seconds the sidecar cache takes to build, every not-ready answer came back as 409 Conflict — a permanent client error — instead of 202 Accepted, which is what it is. That window is hit on every single attach.
…othing could say where that archetype's data actually lives

The capture knows when and how much; the database knows where it sits on disk. Neither half is a diagnosis alone, and there was no route from one to the other — the Data Flow bar showed a bare per-process archetype id, which is meaningless to a reader and dangerous to anyone who tries to join on it.

The join key is the archetype's name, verified rather than assumed: the capture's archetype table, the database's segment owner and its archetype list all derive it from the same expression, so unlike the component case both sides genuinely write the same string. No id crosses the boundary.

Owned is not the same as stored-in, and conflating them multi-counts pages. An archetype owns its cluster rows, its entity map and its cluster index. A Versioned component's table is type-global, shared by every archetype carrying that component, so folding those pages into one archetype's footprint reports the same bytes again for the next archetype that lists it — and looks entirely plausible doing so. They are listed and explicitly not summed, which also states the true situation for a legacy archetype: its rows live in tables it shares.

The Archetype Inspector's existing "reveal in File Map" targeted the archetype's first component, and the map could only frame one segment, so an archetype's segments could not be expressed at all. Following the corrected reveal into the Detail pane exposed four more dead verbs: it assumed a segment's owner is always a component, so an archetype-owned segment offered a 404, an inspector for a type that does not exist, a reveal of the wrong segment and a resource node that is not there.

Residency and CRC are delegated to the File Map's own per-page encodings rather than rolled up: checksumming an archetype's page range reads every page, faulting the non-resident ones in and corrupting the residency figure printed beside it.
… that entity ids make safe had nothing to join

Entity ids are monotonic and never recycled, so an id lifted out of an old capture either finds the same entity or finds nothing — it can never resolve to a different one. That makes "1,240 entities spawned at this tick, 830 still alive, open those 830" the safest bridge in the epic. It was also unreachable: SpawnBatch and SpawnBatchAllocate emitted no telemetry whatsoever, so every bulk-loaded world produced an empty cohort set and looked merely quiet doing it.

A batch is a range, so it is recorded as one. SpawnBatch reserves all its keys with a single Interlocked.Add and stamps one routing id, so (baseKey, count, routingId) reconstructs every id exactly — this is not a summary. One 24-byte record replaces what would be ~11 MiB of per-entity spans for a 200K load, and the cache stores runs rather than rows for the same reason.

Everything emitted before the first TickStart is buffered and copied verbatim into a synthetic tick 0, bypassing the fold entirely — and a world populated at startup does all of its spawning there. The first end-to-end probe of a real capture returned zero lifecycle rows while every synthetic round-trip test passed. The fold now runs on the pre-tick path too, narrowly: only the lifecycle kinds, since the other rollups are keyed to a tick that has not begun.

The two archetype id spaces are not theoretical here. The capture used for verification records Character with catalog id 10 and routing id 1 — two ushorts, same archetype, different numbers, nothing distinguishing them. Every layer carries both and joins on neither implicitly: the cohort endpoint returns each separately, the panel labels them durable and this-capture, and the join is refused unless the database's routing id agrees with both the cohort's stated id and the id embedded in its own entity ids. A mis-joined cohort is reported as its own count, never folded into "missing" — folding it in would render a wrong join as a mass extinction.

The survival split is computed over the whole cohort, not a page of it. Computed per page it read "160 of 200" directly beneath "620 spawned"; the arithmetic was right and the obvious reading of it was not.
…ad opened it, so anything a server or a sample app created stayed invisible

The Workbench's recent-files list is localStorage, written when you open something in it. A shard a game server created under C:\srv\data\ therefore did not exist as far as the tool was concerned, and finding it meant remembering where you put it. The engine now records every database it opens into %LOCALAPPDATA%\Typhon\databases\, and the Workbench reads that — so a database shows up having never been opened there at all. Discoverability only: D-8 is explicit that an index of paths cannot say which capture belongs to which database, and nothing depends on it being complete or right.

One constructor covers every open. DI, DatabaseEngine.Open and the Workbench's EngineLifecycle all funnel through the same internal ctor, so the hook is one call rather than three, and putting it after the last line means an open that threw — the system-schema revision gate refuses one from inside that constructor — records nothing without a check saying so.

The key is normalised, and that is load-bearing rather than hygiene. PagedMMFOptions.BundleDirectory composes the raw DatabaseDirectory, which is frequently relative; only AbsoluteDatabaseDirectory normalises. Keying on it as given would have filed one database under two names the moment it was opened from a different working directory, and the user would simply have seen it twice — a recent-list nobody trusts, which is the failure this exists to avoid. Case is folded on Windows only: there the two spellings are one directory, on Linux they are two databases.

A directory of small files rather than one document, because several engines starting at once would otherwise contend on a read-modify-write. Each entry is written whole to a process-unique temp file and moved over its target, so a concurrent open cannot produce a half-written row; the two writers then race on content, which is benign since they describe the same database.

Four guards, and they cover different scopes rather than repeating each other. Anything under the OS temp directory is suppressed before any I/O, which covers nearly the whole test estate for free. A per-process opt-out is one line in a shared test base — but it does not reach a spawned process, and BenchmarkDotNet runs each benchmark in a child, so the benchmark entry points set the environment variable too, which is inherited. A "disabled" marker file in the registry directory is the machine-wide switch, documented alongside the entries in a README the registry writes itself: whoever goes looking at the index because it makes them uneasy finds the way to turn it off next to it.

The doc-guide example is deliberately NOT opted out, against the design's own list. That file is embedded verbatim as the `typhon new` scaffold template, so opting out there would ship the opt-out into every project a user scaffolds. It is also right on its own terms — the guide's next instruction is to open that shard in the Workbench.

Every write is absorbed and reported once. An unwritable or redirected %LOCALAPPDATA%, a service account with no profile, a read-only container: all degrade to "not in the index", never to a failed open. But absorbed is not invisible, so a failure logs one warning naming the directory and saying the open itself was fine. A guard declining is not a failure and says nothing — warning about a deliberately disabled registry on every open is how a warning stops being read.

Staleness is recomputed on every listing and never stored; the entry type makes storing it impossible. A vanished bundle is marked and demoted rather than dropped, because it is still the row the user is looking for and the only place they can act on it. Listing validates and offers to prune; it never deletes on its own.

Off, empty and broken are three different claims and must not render alike. A disabled registry says so and names the responsible switch, an empty one explains what would populate it, and a failed request says it failed — an empty list for a switched-off feature teaches the user it is useless and they stop looking.

Verified over HTTP against a live Workbench as well as by tests: 29 checks against ground truth produced by a separate process that does nothing but open databases, which is the only way to prove the rows served were created by an engine open rather than by a test calling the registry.
… throwing

CollectDirectoryMapExtensionPages read _pages[0] unconditionally, so a segment that is registered but never materialised (no root page yet) threw out of BuildOwnedPageBitmap and killed the whole crash-recovery occupancy re-derive. "None" is the correct answer for such a segment, not an exception. LogicalSegment.Length had the same unguarded read and could NPE out of AddSegment's own guard.

Surfaced as archetype_init_failed in the Workbench when opening a database holding an empty component, which is nearly every real schema.
PagedMMF's DatabaseLockedException handler called ReleaseLockFile() on the way out, but a rejected opener never wrote a lock of its own — it found the holder's. Deleting it meant the collision the lock exists to report destroyed the record of itself: the database still held, now advertising no owner, so the next opener could not say who had it.

Observed live: a Workbench session held a database and one rejected application open left the session running with no db.lock on disk.

ReleaseLockFile is now gated on _lockFileOwned, set only after this instance successfully writes the file. Stale-lock takeover and normal close are unaffected — both covered by the new fixture, which fails on the pre-fix code with the exact symptom.
The database is the reference; the schema assembly is checked against it. ClassifyAndRegister looped over every component type the DLL declared and called RegisterComponentByType — and registering a component the database has never held takes the engine's create path, allocating its segments and persisting a ComponentR1 row. Inspecting a database therefore rewrote its schema, permanently: measured at 20 invented components and a 2.2 MB to 8.4 MB data file on a database that declared six.

That also contradicted a stated product principle (00-product-vision.md: "Inspection never mutates"), and the cooperative-lock design still describes the Workbench as a read-only holder. Worse, those invented segments are exactly what the next application write destroys, because it does not know they exist — the CK-09 corruption, reached through the most common door.

Registration is now intersected with engine.PersistedComponents. ADR-055's migrate-on-open is preserved exactly: it concerns components that ARE present and behind, and those still register and migrate. A component absent from the file is reported as not_in_database and shown empty, never invented. The match honours [Component(PreviousName)] the way the engine's own reopen matching does, so a renamed component persisted under its old name is not misreported as absent — which would have silently defeated the #514 D4 rename hatch.

not_in_database is informational and never escalates the session state, so no new banner appears. Diagnostics are ordered errors-first because the MigrationRequired banner renders only the first three, and a database with one real breaking change plus a dozen absent components would otherwise bury the thing the user has to act on.

Verified end to end against the real Workbench: the data file no longer grows on open, and the mkcapture / Workbench / mkcapture sequence that used to corrupt now reports zero failures.
Every stop with a database open left it marked unclean and a stale db.lock behind, so the next open distrusted the persisted MVCC heads and redid work it did not need to. ApplicationStopping is wired to SessionManager.DisposeAll, but taskkill /F never runs it.

Asking the host to exit politely is not possible: the Kestrel child is a console process with no window, so taskkill without /F is refused outright ("This process can only be terminated forcefully"), and its console is not ours to send Ctrl+Break to. Measured, not assumed — a first attempt at graceful process shutdown reported success in the script while the lock file survived, which is exactly the kind of change that looks right and does nothing.

What actually matters is the DATABASE closing cleanly, not how the process dies. The running server already exposes DELETE /api/sessions/{id}, so stop now asks it to let go of its databases first, authenticating the way the Vite dev proxy does (bootstrap token from disk). Once nothing holds a database, the force-kill that follows is harmless. Best-effort throughout: a server already gone, wedged, or holding nothing falls straight through to the old behaviour.

Verified: with a database open, stop reports "closed 1 open database session(s) cleanly" and db.lock is gone.
… it does

Attach and detach are the same row gesture, so while a single click did it a double click ran the toggle twice and landed back where it started — the row read as dead to anyone who double-clicked, which is what most people try first on a list of files. Single click now selects, double click acts, Enter activates the focused row so the panel works without a pointer.

Opening a capture then having to go find the timeline yourself is a step nobody wants, so a successful attach reveals the Profiler. On success only: a rejected attach is the wrong-database guard firing, and that is exactly when the user needs to stay here and read why rather than stare at an empty profiler.

toggleViewProfiler could not do that as written. It only focused an existing panel, and an Open session's dock layout is built from the capabilities held at build time — database alone. The profiler capability is gained later, when a capture is attached, by which point the layout exists with no profiler panel, so the View menu grew a Profiler entry that led nowhere. It now creates the panel when absent, with no position, matching how buildDefaultLayout seeds it for trace sessions.
…he open marker

It is a navigator — you pick a capture from it and the result appears elsewhere — not a workspace you read, so it belongs beside Resources rather than in the centre. It anchors within the resource-tree panel rather than the left edge group's id, so it still lands correctly in a restored layout where the group was rebuilt under a different id, and it expands a collapsed left rail first. With no Resource Tree at all, dockview places it and Reset Layout restores the canonical spot — the same fallback the Systems & Queries navigator uses.

Which session is open is the one fact this list is scanned for, so that column leads; in the last column it sat off the right edge of a left-docked navigator and was never seen. Shrink-to-fit, so the columns carrying data lose nothing.

Only the labels change. The dockview component id and the view-registry id stay "Profiles" because both are serialised into saved dock layouts and the palette's viewId gating — renaming them would make every restored layout referencing one fail fromJSON. A test asserts the component id specifically, so nobody tidies it later.

The panel-side half of the rename rode along with the previous commit, which touched the same file.
Kind 36 declares Shape = Instant on its producer, so the generator emits a 12-byte header with no 25-byte span-header extension. TraceEventKindExtensions.IsSpan had no carve-out for it and returned true, so every span-aware reader consumed 25 bytes of payload as a span header: fabricated durationUs, fabricated spanId/parentSpanId. Records stayed aligned (pos += size), so nothing crashed and nothing else looked wrong — the only symptom was a phantom span named Kind[36] sitting on a thread lane in the profiler timeline.

Its numeric neighbours EcsSpawn (30) and EcsDestroy (31) are genuine spans, so it needs a point carve-out rather than a range.

Affects the two IsSpan consumers — TraceEventDecoder.HandGlue and the Workbench's TraceChunkScan. NOT the trace cache: IncrementalCacheBuilder reads the payload at an explicit CommonHeaderSize offset and never consults IsSpan, so v17 caches hold correct EntityLifecycle rows and CurrentChunkerVersion does not need bumping.

The real defect is that a producer's declared shape and the reader's ladder live in two assemblies with nothing tying them together, so this drifts silently. TraceEventShapeConsistencyTests now cross-checks every [TraceEvent(Shape = ...)] declaration against IsSpan by reflection, and asserts the hand-coded kinds that have no attribute to reflect over. It found exactly one mismatch across the whole engine — this one.
…rd it

isInstantKind in chunkDecoder.ts is a hand-transcribed copy of the C# IsSpan ladder with nothing in the build tying them together. Two divergences had accumulated:

  36 (EcsSpawnBatch, #620) — missing on BOTH sides; the engine half is fixed in the previous commit.
  247/248 (QueryDefinitionDescribe, QueryArgs, #342) — carved out in C# since #342, never mirrored here, so the client was decoding both as spans.

The client also had no TraceEventKind entry for 36 at all, which is why the display name fell through to the `Kind[${evt.kind}]` fallback. Adds the enum member and an ECS.SpawnBatch name.

The new test transcribes the ladder as data and checks both directions, sampling span kinds that sit immediately beside an instant — where an off-by-one in a range check would land. Pairs with the engine-side reflection sweep: that one catches a producer whose declared shape disagrees with the reader, this one catches the mirror drifting from the reader.
closeAllSessions destructured `{ sessions = [] }` from GET /api/sessions, which returns a BARE ARRAY. Destructuring a named property off an array yields undefined, so the default kicked in and the loop closed nothing — ever. Every spec's sessions accumulated across a run, each holding its database open, which is why later specs failed with "file in use" and why the paused-session suite took 60s instead of 9s. Tolerates both shapes so a future envelope cannot silently reintroduce the same no-op.

ensureDemoFile wrote a 0-byte FILE at demo.typhon. A Typhon database is a bundle DIRECTORY and the engine explicitly rejects a file sitting at that path ("this looks like a legacy or foreign artifact") — a leftover from the pre-bundle layout where the engine wrote demo.bin and the UI picked a separate marker. The seeding POST's failure is swallowed, so the symptom appeared much later as "the Connect dialog did not close", with nothing pointing at the cause. It now removes a stale file instead of creating one and lets the server create the bundle.

Neither is related to the feature work on this branch; both were found while trying to get a browser walk to run.
…ep aside

db.lock gains a `yieldable` boolean. A claimant that finds a live yieldable lock publishes db.lock.request and waits up to LockHandoffTimeout (5s, TimeSpan.Zero to opt out) instead of failing; the holder sees the request, releases, and the claimant acquires.

The trigger is the HOLDER's advertisement, never the claimant's configuration. That is what makes this safe to enable by default: two ordinary application instances contend exactly as they always did, because the incumbent wrote nothing. Absent means false, so every lock file written before this exists stays safe. TwoOrdinaryEngines_StillCollideImmediately gives the claimant a 30s budget and asserts it finishes in under 5 — if a non-yieldable holder were ever waited on, that test hangs.

The claimant — not the holder — deletes the request, and only after acquiring. Its presence is what stops a holder re-taking the database in the window between its own release and the claimant's acquisition.

DatabaseLockFile owns both files' formats. The engine enforces the lock and out-of-process observers read it, so left as literals joined at each call site the names and fields drift between assemblies with nothing to catch it — the same failure that silently broke `typhon ui --open-latest` when captures moved into the bundle, and that let an instant-shaped trace event be decoded as a span.

Two things found while building it:

  "Present but unreadable" is modelled as ClaimRequest? rather than a sentinel. An in-band marker (a zero pid) collides with a legitimately-recorded one, and the two lead to OPPOSITE decisions — an unreadable claim is honoured, a dead claimant's is retired. Caught by a test that wrote pid 0 and took the wrong branch.

  Process.GetProcessById(0) returns the System Idle Process and HasExited on it throws Win32Exception: access denied. That escaped the PagedMMF constructor and surfaced as "Virtual Disk Manager initialization error", describing neither cause nor fix. It is now caught and read as LIVE — evicting a process you cannot inspect is worse than waiting — but pid <= 0 is rejected before the probe, because it is never a real holder and routing it through "cannot inspect" would let one corrupt lock file wedge a database permanently.
It searched <cwd>/captures — the location captures were written to before #616 moved them inside the database bundle they belong to. That change landed on the WRITER; this is the READER, in another assembly, with no test spanning the two, so the flag silently found nothing from the day captures moved and reported "no captures found" pointing at a directory that no longer means anything.

It now scans each *.typhon bundle directly under the working directory for the newest capture in its profilings/, delegating every path question to TraceLocation so the two cannot drift apart again. One level deep only: bundles are where a project puts its databases, and a recursive walk of an arbitrary working directory would be both slow and surprising.

Sidecar caches share the stem and sit beside captures, so IsCapture is what keeps a derived file from being opened as a recording — the test writes a sidecar with a NEWER mtime so only that filter can exclude it.

This fixture is the test that was missing.
Two entry modes now, and a session that survives losing its database.

PAUSED SESSIONS. Pause is a dispose — there is no way to hold a mapped, write-open file "softly" — so releasing means unmapping and dropping db.lock, and resume is a fresh EngineLifecycle.OpenAsync. What survives the gap is the OpenSession: its id, its token, its attached captures and all client state, so the SPA never re-handshakes and a paused session keeps every file-backed capability. Reading a capture while your app runs against that database is the entire reason the Workbench belongs in a dev loop.

A database held by another process now opens PAUSED rather than failing. Without that, the cold-start order — application first, Workbench second, which is exactly when you reach for the profiler — produced no session at all, so there was nothing to pause and nothing to show. Both ways a database says "someone else has me" behave the same: DatabaseLockedException (which names its holder) and a raw OS sharing violation (which cannot). Failing hard on one while pausing on the other would make the same situation behave differently depending on which race the caller lost.

Three engine-derived caches are dropped on pause, not two. DataBrowserService's snapshots are keyed on the SESSION, which is precisely what outlives the engine, so leaving them serves a pre-pause entity list at a pre-pause Revision after the application has written — wrong data that looks right. The design named that one and StorageMapService; the latter is keyed on the DatabaseEngine and self-invalidates, while OpenSession._staticSchemaProvider memoises a LiveSchemaProvider over the engine and was missed.

The ALC is NOT kept alive across a pause. UnregisterEngineUse clears every registry entry whose Type came from a collectible ALC — exactly the per-session schema DLLs — and the [ModuleInitializer] barrier that repopulates them runs at most once per module per ALC, so a surviving ALC could never re-register what dispose removed. Full dispose and reopen is the only correct option, and PauseResumeCycles_WithSchemaLoaded_StayStable pins it drift-free.

TWO ENTRY MODES. TraceSession is deleted along with POST /api/sessions/trace and the Trace kind/state: a capture is reached through the database it was recorded against, which is what makes correlation structural rather than inferred. TraceSessionRuntime and TraceSchemaProvider stay — they are how a capture is read, which is unchanged. AttachSession gains profile hosting (shared with OpenSession via ProfileHost) so Capture & Analyse survives: a replay taken over TCP has no reachable database, so it attaches back to the live session it came from. save-replay performs that attach itself and returns the profileId, which also closes the "attach any file by path" hole — the only path ever attached is one the server just produced. The capture-magic guard moved to the attach path, where a wrong file now arrives.

Four surfaces still gated on `kind === 'trace'`, which #617 was meant to replace: the Query Analyzer refused outright ("available in Trace and Attach sessions only"), and call-tree scoping, the Inspector detail and Top Spans quietly disappeared. All four were false for an open database with a capture attached — the path F4 made primary — so a database-hosted capture was strictly LESS capable than a standalone one. Capability-gated now; this is a fix, not a migration.

One bug the browser walk caught that no unit test could: a session closed WHILE a resume was in flight left the freshly-opened engine attached to a disposed session, so nothing held a reference to it and nothing ever disposed it — its file handle and db.lock held until the Workbench exited, and the application this feature exists to unblock could never reopen its own database. Opening takes hundreds of milliseconds, so the window is wide. TryResume re-checks liveness after the open and disposes the engine if it lost the race.

The Data Browser shows a paused message instead of "Failed to load entities"; a 409 rendered as an error teaches the close-and-reopen habit pausing exists to remove. The remaining database-backed panels still show generic error text and need the same one-line useDatabasePaused gate.

Ten profiler test fixtures moved to CaptureSessionFactory, which sets a session up the way a user now does: make a database, put the capture in its profilings/, open it, attach.
…move left behind

SCHEMA-03, SCHEMA-04 and SCHEMA-05 were written beside the code they constrain, in the rule database's old home in the docs repository. #747 moved that database into this repository and brought the file's then-current contents with it, but these three had not reached main — they were sitting on this branch, so the move could not see them, and rebasing onto it deleted the file out from under them rather than relocating them.

They are the invariants the capture-identity work rests on. An archetype's per-process catalog id is never interchangeable with its per-database routing id, which is the join that silently matches the wrong archetype rather than failing. A rename is journalled at the instant it is carried forward, or the mapping between the old and new name is lost forever. And a system component's layout change is gated by BK_SystemSchemaRevision, so a database written by an incompatible build is refused in both directions instead of misread.
…ed server

The spec is generated but committed, which makes it the one file in the tree that a rebase cannot merge honestly: each side holds a complete document, so any resolution looks plausible and compiles, while silently dropping whichever half it did not pick. Taking this branch's copy dropped every path and DTO #729 added, and the client stopped building — fourteen TypeScript errors, all of them a missing Integrity* type that orval had no schema to emit.

Regenerated from the merged server rather than merged by hand. Both halves are present again and checkable: the document now carries the Integrity surface from main and the paused-session fields from this branch.
…iled

While the Workbench holds no database — it yielded to a running application and is waiting to take it back — every database-backed request answers 409. TanStack surfaces that as an error, and each panel rendered its own "Failed to load ...", which is untrue and points the wrong way: it teaches the reader to close and reopen the session, the exact dance pausing exists to remove. The banner cannot fix it, because the banner is not what someone is looking at when they wonder why the grid is empty.

Eight surfaces now branch on useDatabasePaused ahead of their error branch and render one shared DatabasePausedNotice that names what is coming back: the entity list, schema explorer, archetype and component inspectors, file map, storage health, resource tree, and the query console's result grid.

Two of them were not the one-line gate the design predicted. Storage Health guards on isLoading || !data and data stays undefined while paused, so a gate placed after the error branch would never be reached and the panel would sit on "Loading storage health..." forever. And the empty state lies as loudly as the error does: a pause returns a 409 AND empty lists, so the Schema Explorer rendered "Failed to load schema." directly above "No schema registered in this session." — two contradictory claims stacked. Emptiness now also requires !isError, which was already wrong before pausing existed, since a failed fetch never meant an empty database.

The query console's gate sits ahead of every state rather than only the error one, because "Press Run to execute the query" invites an action guaranteed to 409.

IntegrityStrip is deliberately left alone: it reads the bundle off disk rather than through an engine, so it keeps working while paused, for the same reason the profiles list does.
…ll databases 320 MiB of empty WAL

Nothing bounded a drain against the active segment's size. Rotation was evaluated only after the write (WriterLoop step 8, at 75% utilization), and no write site compared `segment.WriteOffset + bytesToWrite` against `SegmentSize`. A drain larger than the room left was therefore appended past the declared end of the file — the write succeeds because the segment is opened FILE_FLAG_NO_BUFFERING|WriteThrough with sector-aligned offsets and a positioned write past EOF simply extends the file. But WalSegmentReader computes its data region as `header.SegmentSize - SizeInBytes`, so those records are durable, acknowledged and invisible to recovery. Measured: a segment declaring 65,536 bytes grown to 114,688, with 49,152 bytes unreachable.

The safety margin was an accident. `(1 - RotationThreshold) * SegmentSize` has to exceed a commit-buffer half, and those two numbers live in different option classes that know nothing about each other — WalWriterOptions.SegmentSize and ResourceOptions.WalRingBufferSizeBytes. The shipped defaults already failed it: 16 MiB of worst-case headroom against a 32 MiB maximum drain. It stayed hidden because triggering it needs both a large drain and a nearly-full segment, and every fixture that configures a small SegmentSize also drives small transactions.

WriterLoop now rotates before writing when the batch does not fit, and RotateSegment sizes its target to hold the batch, so a batch larger than a whole configured segment still lands inside a declared region. The rotation has to precede the staging copy because PatchChunkCrcs continues the _lastFooterCrc chain and that chain resets per segment. It also needs an LSN to seal the outgoing segment with, and WalSegmentContext.LastLSN is only stamped at rotation time, so the writer tracks the previous batch's high LSN itself.

On top of that, a database that never rotates was carrying five 64 MiB files: one active segment plus four pre-allocated placeholders. Neither category is ever added to _sealedSegments, and MarkReclaimable iterates exactly that list, so checkpoint-driven reclamation was structurally unable to see any of them. A 1.8 MB bundle carried a 335.5 MB wal directory. The first segment now uses its own InitialSegmentSize (16 MiB), and the pre-allocation pool is built on the first rotation rather than at open — before a database has filled a segment there is no evidence it ever will. The first RotateSegment finds no spare and falls through to the CreateSegment branch that already existed for that case, and its trailing EnsurePreAllocated builds the full pool, so a database that does rotate is back to the previous steady state with no new state to track. Measured on a real engine with production defaults: 16.0 MiB in one file.

Segments are no longer uniformly sized, which retires two assumptions that were harmless only while they were. ActiveSegmentUtilization divided by the configured size rather than the active segment's own, so a 16 MiB segment would have reached the rotation threshold at 48 MiB of writes it could not hold. TotalWalBytes multiplied a count by the configured size, over-reporting to GetWalTotalBytes and the Workbench Storage Health panel. The segment header has always carried a per-file SegmentSize; both now read it, as does WriteSegmentHeader, which was stamping the configured constant instead of what it had actually allocated.

WR-03 records the invariant in rules/durability.md, verified by WalSegmentSizingTests.
…ed as healthy

Both found by walking the integrity feature as a user rather than as a test, and both are total failures rather than edge cases.

The plan fingerprint folded `string.GetHashCode`, which .NET randomises per process as hash-flood mitigation, so two scans of byte-identical data produced different fingerprints in different processes and the documented two-step workflow — `repair --plan`, review it, `repair --apply` — could never once succeed. It refused with "the database has changed since this plan was produced", which is the most misleading answer available: it accuses the database of drifting in order to explain a defect in the comparison. The fold was order-dependent too, chaining findings in list order, so a re-scan that merely enumerated the same findings in a different sequence changed the value as well. It now sorts and then runs FNV-1a over UTF-8 bytes with a separator, the same construction ProfilerSessionMetadataBuilder uses for schema fingerprints and for the same reason: sorting makes it order-independent, the byte-level hash makes it process-independent, and the separator stops adjacent fields colliding by concatenation.

The scanner also validated only two of the three things the engine checks about page 0. It read the signature and the format revision but never compared the recorded database name against the bundle directory's stem, which ManagedPagedMMF.OnFileLoading compares on every open. A copied or renamed bundle — `Copy-Item world.typhon broken.typhon` — therefore scanned as Divergent-but-repairable when no tool could open it at all, and the plan went on to propose a repair step that reopens the database. That is the one verdict a checker must never get wrong, and nothing downstream could have caught it because the scan is offline and never opens the engine. Reported Fatal and NotRepairable, since the remedy is a filesystem rename and this feature does not move the operator's files. A directory that is not named `*.typhon` at all is a different case and reports Advisory instead: that is what a backup looks like, including the pre-repair copies this feature creates itself, and condemning them would make every backup scan as a broken database.
PagedMMF wrapped every open failure in "Virtual Disk Manager initialization error, check inner exception", which names neither the cause nor the fix and refers the reader to an inner exception that every caller then drops: Spectre.Console prints `Error: {ex.Message}` and stops, the Workbench renders the message into a toast, and the shell's top-level handler only unwraps under `#if DEBUG`. The one actionable sentence — "Database name mismatch: expected 'broken', found 'world'" — reached nobody.

It has now misdirected twice, the other being a Win32Exception out of the liveness probe during the lock-handoff work, which is once more than a wrapper adding no information deserves. The message now names the bundle and carries the inner message; the inner exception stays attached for the stack trace.
… can fail

The behaviour shipped in the previous commit but three documents still described the world before it: the durability overview and the WAL feature-set page both listed uniformly-sized segments and a pool pre-allocated at open, which is now true only from the first rotation onward.

They also never mentioned InitialSegmentSize, so the knob that does the actual work was undocumented, and neither said that a header declares its own size rather than the configured one — the property that makes a mixed-size set readable at all.

The rule-coverage audit separately flagged WR-03 as having a verifier and no mutant. A predicate that cannot fail proves nothing, so the mutant grows a segment past its declared size and asserts the verifier's predicate rejects it. It doubles as the demonstration of why WR-03 is marked silent: the write does not fail, is not rejected, and leaves no error behind, so the only evidence is the disagreement between what the file measures and what its header permits recovery to read.
…res/

Captures moved into the database bundle's profilings/ directory, but everything that introduces a new user to profiling kept describing the old location: the scaffolded telemetry file pinned Typhon:Profiler:Trace to ./captures/, which opted every new project out of the default that makes captures findable, and the README, the post-scaffold hints and the getting-started guide all documented that opt-out as the norm.

Removing the key is the fix — an absent path is what means "a file in this database's profilings/". The guide now says where the capture landed and why it matters, and treats `typhon telemetry trace <path>` as the override it is, with `--clear` as the way back. The sample's own Program.cs resolves its capture through TraceLocation rather than guessing a directory, so the line it prints is the file that was actually written.
`typhon ui .\does-not-exist.typhon` printed "Workbench is running" and handed the path to the engine, which created a 565 KB empty database at it. A typo in a path silently produced a new database rather than an error, and the user then browsed an empty one wondering where their data went. Both --db and --trace now check that what they were given exists before the host starts, and say which path failed.

Spectre's default exception handler is the other half of the same complaint: it prints `Error: {ex.Message}` and stops, so any wrapped exception loses the sentence that says what actually happened. It now renders the whole chain, since the outermost message is the context and the innermost is almost always the cause and the fix. The stack stays behind DEBUG, which is the line the rest of the file already draws between an expected failure and an unexpected one.
…tibility, and a mistyped path fabricated a database

Two failures of the same kind: the Workbench answered a question the user did not ask, confidently.

Launched from anywhere other than the application's own output directory, it could not find the schema assembly and reported "Schema incompatible" — which is the wrong word for it. Nothing was incompatible; a DLL was not on the search path, and the advice that followed sent the user after binaries that were already correct. The lifecycle now probes bin/{Configuration}/{tfm}/ beside the database, newest first, as a last resort tier after the existing ones. Deliberately exactly bin/*/* and never a recursive walk: a deep sweep of whatever directory a database happens to live in is both slow and a way to load an assembly nobody meant to expose. It costs one failed Directory.Exists on any database that is not a development one.

The second is worse because it destroys nothing visibly. OpenAsync is create-if-missing by design — that is what makes an application's first run produce its database — so a stale or mistyped path did not fail: it fabricated an empty database and returned a healthy session onto it. The user then browsed an empty bundle wondering where their entities went, which reads as data loss rather than the typo it was. A viewer never creates data, so the session path now 404s on a missing directory, ahead of the lock handling since a path that is not there was never locked. The demo alias stays exempt because it is a create-on-demand fixture rather than a database anyone claims to already have.
nockawa added 14 commits August 15, 2026 02:57
The first handoff worked and every one after it failed. TryResume called Forget on the session it had just resumed, which removed the watch and disposed its FileSystemWatcher, leaving a live session holding a lock that still advertised yieldable with nobody watching for claims. The advertisement became a lie, and a lie that costs more than silence would: the next application to open the database published its request and waited out the whole LockHandoffTimeout before failing exactly as it would have anyway.

Found by running an application through its close-and-reopen chapter, which is the shape this feature exists to serve. The application released the database, the poll resumed into the gap within a second, and the reopen five seconds later reported that the Workbench had advertised it would yield and had not.

Resume is the one transition that moves a session from the paused half of PollOnce to the live half rather than out of the watched set, and it was the only one written as an exit. Two facts have to stay in sync across it — the lock file, which the engine re-stamps with yieldable on every acquisition, and the watch, which only the Workbench knows about. Stale watches need no cleanup at that point: the sweep already retires any whose session has been removed or replaced.

Every existing yield test drives a session tracked at creation and never resumed, so all three passed with this in place. The failure table in the design had a dozen rows for ways one handoff can go wrong and none for two. The new test drives the whole cycle and was verified by mutation.
…nt was clipped and no scrollbar ever appeared

Reported as two separate bugs — the Detail view's content looked right-aligned and cut off, and neither it nor Profile sessions ever showed a horizontal scrollbar — and they are one cause, a level above any panel.

`.dv-groupview` is a flex container and `.dv-content-container` is a `flex: 1 1 auto` child, so the CSS default `min-width: auto` applies and the container refuses to shrink below its content. Measured live: a 424 px content container inside a 260 px group, with the group's own `overflow: hidden` silently swallowing the difference. Content was not right-aligned, it was left-clipped; and no scrollbar appeared because each panel's `overflow-auto` had been handed 424 px, so from its point of view nothing overflowed. The overflow was one level up, where it is hidden rather than scrolled.

`min-width: 0` restores "you may shrink". Applied to every group rather than the edge ones, because the constraint is true of all of them and scoping it narrowly would leave the trap armed for whichever layout hits it next. Three rounds of fixes inside the panels changed nothing before this, all of them downstream of a container that was never constrained.

DetailPanel's grids get the same treatment in their own idiom, `minmax(0, 1fr)` instead of `1fr`, so a long path wraps instead of widening the panel.
…ing opened

A Typhon database is a directory, and the one action every user takes first was named after an implementation detail of it. Renamed to "Open Typhon Database" everywhere it appears — the Welcome screen, the File menu, the command palette and the Connect dialog's tab, which also stops offering to replay a trace now that a capture is reached through its database.

The Connect dialog opens on Known rather than Recent. Known lists every database this machine has seen, including the ones a server or a sample application created, so it is the tab that answers "open a database" for someone who has not opened one here before — which is exactly the person who needs the dialog.

The Playwright specs addressed the button by its old name, so they follow.
… button offered to fix it froze the app

Three complaints from one blocked state, all of them about being told the wrong thing.

A DLL that could not be found is not an incompatibility. The banner said "Schema incompatible" and advised reopening with binaries that match, which sends the user after a problem they do not have — their binaries are fine, they are simply not on the search path. A diagnostic set whose failures are all missing_assembly now says "Schema assembly not found", names the assemblies, and leads with the action that fixes it rather than the one that leaves. A mixed set still reports the incompatibility, because the stronger message is the honest one there.

"Open another file" was the only forward action on a screen about schemas, and it is not obvious that opening a different database is a way to resolve one. It is now "Open a different database…" and lands on the Known tab.

"Manage schema directories…" opened the Options panel on the wrong category and then hung on a spinner that never resolved, taking the whole app with it. Two causes: the panel ignored the requested category on first mount, and useOptionsStore.fetch issued its two GETs without the auth headers, so both 401ed and the promise never left the loading branch. The fetch now applies the same headers as every other call, records a load error instead of failing silently, and the panel renders that error with a Retry rather than an eternal spinner.
…nd a capture's provenance was unreachable

The Profile sessions list supported opening a capture and nothing else. Single-clicking a row did nothing, so the provenance F1 put in every capture header — which database recorded it, under which name, how far its schema has drifted — had no surface at all. A single click now selects the row and the Detail rail renders a provenance-first card for it, which is what the selection bus already does for every other object type; the capture leaf type is new.

Switching captures updated the top banner and left the profiler views showing the previous capture's data. The list invalidated its own queries but not the profiler's, and the panel kept the mounted view's state across the change. It now drops the profiler query tree on switch and remounts the panel on the active capture's id, so nothing survives that belongs to the capture that just left.

Double-clicking a second capture opened it without detaching the first, so each switch leaked a runtime holding its file. It now detaches the previous one after the new attach succeeds — after, so a failed attach leaves the working capture in place rather than none at all.
It rendered as bare muted text with no background, which is fine in the six panels that show it in empty flow and not in the Db Map, which overlays it on a painted canvas. The notice now carries its own semi-transparent background and a backdrop blur, since it cannot assume it has one — the other call sites gain content behind them as those panels grow.

Kept translucent and grey rather than opaque or coloured: a paused session is a normal handoff, and an alert-looking notice would misrepresent it.
…hat did nothing

Single-clicking a capture selects it and writes the selection to the bus, but if the right edge group is collapsed the only visible effect of that click lands somewhere nobody can see. Opening the Data Browser already expands the rail before focusing its list; this is the same move, factored out so the Profiles panel can use it too. A no-op when the rail is already open or absent, so it never steals focus from what the user is looking at.
…lently swallowed rude edits

Two dev-loop stalls with the same shape: the tooling looked healthy while nothing was actually being applied.

`reset` clears wedged processes, and there was no equivalent for the other way this loop gets stuck — stale StaticWebAssets caches in the Workbench obj directory, which fail a Kestrel build with "No file exists for the asset". Added `clean`, plus -Clean on start/restart and -Hard when the asset directory itself is suspect and a full Vite rebuild is warranted.

The detached watch is worse because it is silent. A rude edit — changed signature, a new type, generics — is one hot reload cannot apply, and dotnet watch then blocks on a stdin prompt asking whether to restart. `start` launches through cmd.exe with output redirected to log files and no console to type into, so nobody can ever answer: the edit never lands and the question sits unread in the log. Only the detached path now passes --non-interactive, which makes that case restart instead. watch-kestrel runs on the calling console where stdin exists, so it keeps the prompt — being asked is the right behaviour there.

A bind timeout also now reports whether the port is held by an untracked process, since that is the first thing worth knowing.
WR-03 gained a mutant and the rebase brought main's rows in; the matrix is generated and must not be hand-merged, so it is regenerated rather than reconciled by hand.
…next test paid for it

AResumedSession_YieldsAgain_WhenASecondClaimAppears deliberately ends where no other test in the fixture does: paused, with a claim still standing. That leaves the poll actively hunting for its turn back while TearDown removes the temp directory under it, and the next test's resume never completed — it failed only in a full-suite Release run, because in a fixture-scoped run nothing follows it.

Worth stating what this was NOT, since the first two hypotheses were both wrong: the production change is innocent, proven by a full Release suite that is green with the fix in and this test filtered out, and it is not the known quarantine band either. Retiring the claim and removing the session is the test cleaning up the protocol state it created — SessionRemoved is the same edge production uses to stop watching a session that has gone away.
…y platform except Windows

The guarantee is "never evict a capture currently open in a session", and the entire mechanism enforcing it was File.Delete failing. That is a Windows-only guarantee wearing a portable-looking API: a sharing violation stops the delete there, while POSIX unlink detaches the name from the inode no matter who holds the file open. On Linux the delete simply succeeded, the Workbench went on reading a capture that was no longer in the directory, and retention counted it as evicted. The guarantee did not degrade off Windows — it was absent, and nothing said so.

Caught by the first CI run this branch has ever had. Everything before it was validated on Windows, where the assumption is invisible because it happens to be true.

The fix probes with an exclusive open before deleting. FileShare.None is the portable spelling of "is anybody else holding this?", since .NET backs FileShare with flock on Unix, so it fails exactly when another .NET process has the capture open. Read access so a read-only mount cannot turn "in use" into "failed", and the handle is released immediately: it asks a question rather than holding the file.

A capture opened between the probe closing and the delete is a window this does not close, deliberately. On Windows the delete still refuses; on Unix nothing can close it, because nothing there makes unlink conditional. Closing it properly means an on-disk open-marker beside each capture, the shape db.lock already uses, which buys atomicity at the price of a second liveness protocol to keep honest — worth doing only if the window is ever observed.
…tes and names nothing

The Workbench suite wedged on the persistent runner and vstest printed nothing after "A total of 1 test files matched the specified pattern". The job then burned its entire ten-minute step budget, was killed by the action, and left orphan dotnet processes behind. No trx, no retry pass, no test name — a timeout kills the run before any of them are written, so a silent hang and a slow runner look identical from the log.

--blame-hang makes the hang name itself. Three minutes is roughly twice the whole suite's runtime, so it cannot fire on a merely loaded runner, and it lands inside the step's own ten-minute cap: a detector that only trips after the step has been killed would report nothing, which is the situation it exists to end. No dump — the test name is the finding, and a dump on a shared runner is a large artifact nobody reads.
…t one

It drives the protocol through three state changes — yield, resume, yield again — each gated on a one-second poll and one of them on a real engine open, so its wall-clock cost scales with how contended the machine is. It is the only test in the fixture that does three; the rest do one or two. On a loaded CI box the 10s/15s budgets were not always enough, and on the persistent runner the shortfall surfaced as a wedged test host rather than a clean failure.

Reproduced on Linux rather than guessed at: it passes alone and passes its own fixture, and failed one full-suite run in three under load.

Raising every deadline to 45 seconds weakens no assertion. Each one is a claim about what the protocol EVENTUALLY does, and the poll interval is an implementation detail the test must not encode — the same reason WaitUntilAsync exists here instead of a fixed sleep. A regression makes these fail by never happening, not by happening slowly.
…recedes it

Both waited for IsPaused and then read db.lock in the next statement, as if a yield were one event. It is two: Pause() sets the flag, and the lock file goes when the engine it disposes finishes releasing the file. Windows happened to finish the dispose first, so the tests passed there for the whole life of the branch; on Linux the dispose sometimes does not win, and the assertion fails with the session correctly paused and the file still present for a few more milliseconds.

The lock is now waited for on its own terms. Nothing is weakened — "yielding drops the lock" is still asserted, as the eventual condition it always was, and a regression makes it fail by never dropping rather than by dropping slowly.

Found by running the suite on Linux under WSL2 rather than by reading it: one failure in three full-suite runs, with the message naming the exact assertion. The previous commit's deadline increase was aimed at the wrong mechanism — a test that fails three seconds into a forty-five second budget is not timing out — and the raised budgets are kept only because encoding the poll interval in a deadline was independently wrong.
…g else

It hangs the Workbench test host on the c6id across three consecutive gate runs, and passes everywhere I can measure: alone, in its fixture, and 4/4 full-suite runs on Linux under WSL2 with the same Release build and the same gate filter. Nothing about the test has been shown to be wrong, so it is quarantined rather than changed — the difference is the runner, and inventing a fix for a mechanism I have not identified would only make the next failure harder to read.

What it is not, since three of these cost a CI cycle each: not a WaitUntilAsync deadline, which polls to a deadline and returns false rather than hanging, and whose waits here total sixty seconds against a hundred-and-eighty second hang; not the lock-file race fixed in the previous commit, which was real and did not stop it; not a slow machine, because a hang is not a slow pass. #811 records the two untested suspects — the engine suite running first in the same tree, and a persistent runner that has now accumulated orphaned dotnet processes from three aborted runs.

AC17 keeps its coverage: AResumedSession_YieldsAgain_WhenASecondClaimAppears drives the same yield, through a resume and a second claim, and asserts the same lock release. What this removes is the redundant single-yield case, not the guarantee.
… moved the hang

Excluding ALiveSession_YieldsTheDatabase_WhenAClaimAppears from the gate produced a run that wedged on AnAbandonedClaim_DoesNotPinTheSessionOutOfItsDatabase instead. That is the evidence that settles what this is: not one bad test, but something all fifteen share on one machine. They open and dispose real engines in a loop, each with a FileSystemWatcher over the bundle, and they pass alone, pass as a fixture, and pass four consecutive full-suite runs on Linux under WSL2 with the same Release build and the same gate filter.

Chasing it test by test would have taken as many CI cycles as there are tests and ended in the same place, with the fixture excluded and nothing learned.

The cost is stated rather than hidden: this removes all server-side F8 coverage from the merge gate until #811 is understood. The nightly still runs the fixture, which is where a quarantined test is supposed to be observed, and it passes on any developer machine either platform.
@nockawa
nockawa merged commit 5964195 into main Aug 15, 2026
12 checks passed
@nockawa
nockawa deleted the feature/613-workbench-db-companion branch August 15, 2026 03:05
nockawa added a commit that referenced this pull request Oct 19, 2026
…ites it; pack-check runs it on every PR (#1421)

The first 1.0.0-alpha.1 release run stopped in pack: the scaffolded app ran end to end and wrote its trace beside its database, under world-shard.typhon/profilings/, while the script still looked in captures/, where the template wrote it before #810 moved it two months ago. Only release.yml ran this test, so nothing noticed until a tag. The script now searches the app for a non-empty .typhon-trace, and pack-check packs the CLI and runs the CLI and onboarding smoke tests on every PR, as release.yml does. Nothing was published by the failed run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F8 — Cooperative lock handoff (pause / resume)

1 participant