Commit Graph
3195 Commits
Author SHA1 Message Date
Anees IqbalandClaude Opus 5 7f4e618d54 draw: the boot the clear-values array owed, and what the zero does not cover
macos-15/x86/Vulkan, three rounds of the committed workload then a clean
SIGTERM: zero `FAIL` across 25 213 lines, 146 cadence windows all `busy=0` with
119 at `direct_frac=1.00`, `walk_records_render` 285 753 over 146 windows,
123 510 draws, first guest frame presented via rail resident.

119 of the 121 windows past the firmware phase, the same shape as the 86-of-88
and 139-of-141 the two rows above read. A change on the render-pass begin path
owes a live boot even when it is mechanically equivalent, and this is it.
`slate_source_stale` absent this time.

The row also records what the new structural-zero gate does *not* cover, because
a gate whose scope is only in the test body reads as broader than it is: the
measured draw binds no descriptors, and `Vec::with_capacity(0)` allocates
nothing. A draw that binds anything still builds a `Vec<BindingSig>` and clones
it into the pipeline key. That is the next piece of the same gate, and it is
named here so the zero is not read as covering it.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:54:45 +03:00
Anees IqbalandClaude Opus 5 8aa30037c0 draw: the allocation zero says a draw happened inside the region
A zero trip count is only a reading if the measured region ran a draw. An early
return — a request rejected at validation, a batch already closed, a rail that
skipped — allocates nothing too, and would pass the structural-zero gate for the
wrong reason. That is the failure this file already names for its row parser and
it applies here.

The region now brackets a counter snapshot: exactly one `batch_joins` and zero
`batch_flushes`, so the measured work is one joining draw and not the flush that
ends a batch, which is not a steady-state draw either.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:48:51 +03:00
Anees IqbalandClaude Opus 5 3e4276c51a draw: the live warm draw meets the structural zero, and the gate that says so
"Heap allocations per steady-state draw" is a required value in the replacement
architecture's structural-zero table. `reims-vgpu-core` has met it for the
semantic model since `a_warm_path_stops_allocating`. Nothing measured the live
executor, and the allocation instrument's own doc says why that matters: a
helper returning a `Vec` on a per-draw path costs one `malloc` a draw and shows
up as a percent or two of drain duty spread evenly across a profile, so no
single line got slower and nobody bisects to it.

Measured, the live warm repeat draw took **1 trip, 16 bytes**, every run. All of
it was `exec::clear_values` returning a `Vec` whose first `push` allocated, on
the overwhelmingly common draw of one colour target with no secondaries and no
depth.

It is a `ClearValues` array now, and the answer is zero.

The capacity is not a guess: `1 + MAX_SECONDARY_ATTACH` is
`PASS_MAX_COLOR_ATTACHMENTS`, the wire's own attachment bound, and the `+ 1` is
depth — so it holds every attachment a pass this device can build, and one more
would be a pass Vulkan could not be given either. Overflow refuses rather than
truncating, because Vulkan indexes this array positionally against the pass's
attachments and a short one silently gives a later attachment an earlier one's
colour. The cap is already enforced where the pass key is built; refusing here
under the same `SecondaryAttachmentCap` reason makes the bound the array's own
instead of a call order it cannot see.

`a_warm_repeat_draw_does_not_enter_the_allocator` is the gate, on the live path
through a real device: opener, eight warm-up repeats of one reused
`DrawRequest`, then one measured repeat, staying below `batch_max_draws` so the
measured draw is not the one that flushes. It asserts 0 rather than a ceiling,
because a structural zero's question is not how many are acceptable but which
per-draw path started allocating.
`a_clear_array_past_the_attachment_bound_refuses_rather_than_truncating` covers
the full pass and the one past it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:47:59 +03:00
Anees IqbalandClaude Opus 5 fc1f944d7f residency: the two readings the next move needs, taken while they were cheap
`pools` follows `caches` onto the device once the whole present is a transaction
against the device that owns the registry, run by a thread that holds one. That
thread is the drain. The question anyone will ask first is what it costs, and
the boot behind `10696be7` already answered it — so the answer goes at
`window_present_frame` rather than being guessed at later.

**The schedule would not change.** `presents == offered` in all 112 cadence
windows of that boot, with `busy`, `busy_fence`, `busy_acquire` and
`busy_no_area` zero in every one — the same shape the seven rail boots
`PRESENT_IN_FLIGHT` was measured on read. The window presents exactly once per
publish and refuses nothing, so its cadence already *is* the publish's cadence;
the move relocates where the code runs, not when.

**The cost would be small.** Window-thread engine lock: median 4 acquisitions
per second, median 155 µs held per second, median longest single hold 68 µs,
against a present rate of median 9.7 Hz and p90 28.8 Hz. A drain absorbing all
of it takes on about 1 ms per second.

Neither reading says the move is easy — the acquire must precede the blit
recording and it is the window's surface that owns the swapchain. They say it is
not gated on throughput, which is the question that would otherwise be answered
by guessing.

Doc only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:38:07 +03:00
Anees IqbalandClaude Opus 5 de7b2a89b9 agents: the rule states the form its gate can read
`AGENTS.md` states the replacement-coverage rule and `039c8a5b` gave it a gate
that can enforce it, but only for names written ``fn `name` ``. A rule stated
without that form invites the shape the gate cannot see, which is the shape
seven of the nine existing rows were already in.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:35:57 +03:00
Anees IqbalandClaude Opus 5 039c8a5b07 dead: the coverage gate reads nine claims instead of two
`every_function_the_register_names_still_exists` is the gate the whole
disconnect amendment leans on: a group's legacy tests stop running the moment
they move, the register row is the only record that something replaced them, and
nothing in the build relates the two. Its own doc, `dead/README.md`'s rules and
`AGENTS.md` all say it checks every function a coverage column names.

It checked two of nine. Two reasons, both structural. It read only the register
proper, and seven of the nine coverage claims in the file are in the three-column
live-validation table below it. And it recognised a name only as a backticked
path with a `::` in it, while a coverage test is named the way a reader says it —
bare, `a_declined_publish_vouches_for_nothing` — which is indistinguishable from
the census routes, counters and slugs the rows are full of.

So a rename of any of those seven passed silently, in the record that exists to
stop exactly that. A gate reporting on what it did not inspect is worse than no
gate, because the rule it stands in for is then being trusted.

A coverage name is now written ``fn `name` ``. The `fn` is what separates a
promise about a function from the prose around it, so a row can go on naming
`pools/`, `winpub_*` or — as the newest row does — a slug that no longer exists,
in the same sentence, without either being read as a promise. Fourteen existing
names across nine rows are annotated; the parser reads both tables, keeps the
old `a::b::c` form, and asserts a floor on how many declarations it found, so a
parser that stops reading the form fails instead of passing empty.

Checked by rename: `a_declined_publish_vouches_for_nothing` renamed in the
register now fails the gate, and passed it before this commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:35:41 +03:00
Anees IqbalandClaude Opus 5 10696be701 residency: the boot the flush move owed, and what the window's lock hold now costs
macos-15/x86/Vulkan, three rounds of the committed workload then a clean
SIGTERM: zero `FAIL` across 22 868 lines, 112 cadence windows all `busy=0` with
86 at `direct_frac=1.00`, `walk_records_render` 291 960 over 111 windows,
127 344 draws, first guest frame presented via rail resident.

86 of the 88 windows past the firmware phase, against 139 of 141 on the boot
before it. Moving the guest batch's submission from the presenter to the publish
that vouches for the frame changes no frame, which is the claim.

The reading this change is about is the other one. **The window thread's engine
lock: median 4 acquisitions per second, median 155 µs held per second, median
longest single hold 68 µs.** One outlier window at 902 ms with a single 554 ms
hold is the swapchain creation at startup, named in the row so it is not taken
for steady state. What is left inside that hold is the blit recording and one
registry write, and `9b2470e0` says why that write cannot leave on its own.

One `slate_source_stale` episode again, same lawful case as the row above.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:31:23 +03:00
Anees IqbalandClaude Opus 5 9b2470e07f residency: why the window's last registry write stays, written down
`00a52e81` left the access write-back as an open question — "the access
write-back could be recorded by the publish instead, given the present's outcome
comes back to say whether the transition actually ran". The answer is no, by two
distinct routes, and the note is at the site so the next reader does not have to
re-derive it.

**Not the publish, eagerly.** It would promise a transition a `Busy` present, a
failed acquire or a detached window never makes. The lie is not the layout — a
primary target rests in `TRANSFER_SRC_OPTIMAL` and `transfer_read(false)` is the
same layout, which is exactly what makes this look safe — it is the access: the
next barrier would name `TRANSFER_READ` as its source scope and the colour write
that really happened last would never be made available.

**Not a restore after the blit,** transitioning back so the registry stays true
without a write. The layout comes back and the dependency does not: a guest
colour write barriering from the restored `ColorWrite` names
`COLOR_ATTACHMENT_OUTPUT` as its source stage, which does not wait for this
blit's `TRANSFER` read. That is a write-after-read on the pixels the screen is
reading, and making the next barrier say `TRANSFER` is the whole of what this
write-back is for.

Both fail the same way: the barrier and the record of it must be one action,
taken by whoever holds the registry, adjacent to the blit. So this write leaves
when the present becomes a transaction against the device that owns the
registry — not before, and not by moving the write alone.

Doc only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:27:30 +03:00
Anees IqbalandClaude Opus 5 e1a4af1886 residency: the guest batch is submitted by the publish that vouches for it
The window presenter's first act inside `begin_present` was
`pools.batch_flush(ctx, counters)` — submitting the guest's open command batch,
on the window thread, under the engine lock, on the display's latency path.

It had to be *somewhere*: `content_ready` is set when a draw records into a
resident, so a resolution can name pixels that exist only in a command buffer
nobody has ended, and the blit must not read that image first. The presenter was
the wrong somewhere in both directions.

The batch is the drain's, and `prepare_window_resident_present` *is* the drain,
holding the engine lock with a context and counters already in hand. So the
flush goes there, ahead of `resident_present_decision`, and the window thread
loses a submission it should never have been making.

It also moves what the frame is. A flush at present time submits every draw
recorded *after* the publish, so the frame that reached the screen was not the
frame the publish vouched for — a newer, possibly half-composited one. Flushing
at the publish draws that line where the caller already believes it is: the
resolution names a submitted image, and later recording stays unsubmitted until
its own tranche ends. Nothing here decides how long guest work may sit
unsubmitted; `flush_batched_draws` runs at every tranche end regardless.

A flush failure declines the publish by name (`winpub_batch_flush_failed`) and,
if it is a loss, latches `note_device_lost_seen` — this transaction holds the
engine guard and no `ObjectCaches`, and the order those two are taken in is
fixed, so it does what every other observer that cannot recover does and the
end-of-tranche flush acts on it within the second.

`begin_present` loses its `&EngineCounters` with the flush. It still takes
`&mut ResourcePools` for the access write-back, which is the window's last
contact with the registry.

`the_window_publish_flushes_the_open_batch_before_it_vouches` is the owner-level
test: a draw opens a batch, the publish flushes it, and the assertion is ahead
of the publish's own accept/decline so a future refactor that moved the flush
behind the decision cannot pass on the accepting arm alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:25:39 +03:00
Anees IqbalandClaude Opus 5 b02efcef0b blit: the driven boot the reason move owed, and its register row
macos-15/x86/Vulkan, three rounds of the committed workload then a clean
SIGTERM: zero `FAIL` across 27 263 lines, 167 cadence windows all `busy=0` with
139 at `direct_frac=1.00`, `walk_records_render` 301 624 over 166 windows,
129 678 draws, first guest frame presented via rail resident.

139 of 167 is the same shape the three boots before it read — 26 firmware
windows with no guest frame, two crossover windows at 0.83 and 0.90, and every
window after them at 1.00. Moving the blit reason out of a thread-local and into
the value changes no frame, which is the claim.

**No blit refusal fired in the whole boot.** That is the honest reading and it
is recorded as such: it says the change introduced none, not that the nineteen
newly-named sites were exercised. A driven desktop does not refuse blits; those
nineteen are covered at their owner.

One `slate_source_stale` episode, one frame, at `display_enable_mask 0xd -> 0xc`
— the lawful case the epoch exists for. Recorded because the three rows above it
say the class was absent, and this boot ran 167 windows against their 99.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:23:54 +03:00
Anees IqbalandClaude Opus 5 13f9aa4938 blit: the refusal carries its own reason, and the thread-local goes
Seam 6's disconnect list names `BLIT_FAIL_REASON` — "a thread-local carrying a
reason the observation channel should carry". This is that.

The rail is the crate's largest refusal surface: 177 distinct checks across 182
sites collapsing into a handful of coarse statuses, so the specific cause has
always had to travel *somewhere*. It travelled in a thread-local: `br` set it at
the failing site, every command entry cleared it, and `Refusal::refusal` read it
back on the assumption that the dispatch site runs on the same thread and gets
there before anything else writes. Three assumptions, none checkable, and each
one's failure mode is a line naming the wrong check — worse than no line,
because it is believed.

It also said nothing about a site that never called `br`. Nineteen of them:
`.ok_or(BlitStatus::Capacity)?` and `return Err(BlitStatus::GuestIo)` in the
buffer↔texture aspect helpers, every one of which reached the dispatch line as
`blit_unattributed`. Naming the gap beat hiding it; the gap was still there and
nothing stopped another appearing.

Both go away by putting the reason in the value. `BlitStatus` splits into
`BlitFailure` — the six classes a caller branches on — and
`BlitStatus::Failed { failure, reason }`, and `br` is the only constructor.
A refusal with no reason is now unspellable, so the nineteen did not compile
until each was given the check it had been silently discarding
(`bt_read_storage_row_over_buf`, `bt_dest_span_overflow`, `bt_insert_plane_row`,
…). `blit_unattributed` has no site left to come from.

`PartialEq<BlitFailure> for BlitStatus` keeps the class comparison the callers
and most tests want; a test about a specific check asserts on `reason()`. Eleven
tests that read the channel after the status now assert both in one
`BlitStatus::Failed { .. }` literal, which is a stronger statement than the pair
was — it says the class and the check came from the same refusal, which is
exactly what the thread-local could not promise.

`FenceStatus` made this same migration first, and `fence_exec`'s note that
separating the shared `Missing` meanings "belongs with `BlitStatus`'s own
migration" is updated to say where the reason is now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:17:05 +03:00
Anees IqbalandClaude Opus 5 8b5650b016 residency: the span the window hold really covers, drawn instead of assumed
`window_holds` documented itself as "do not reclaim the surface the user is
looking at" and left the reader to infer how long that lasts. It lasts less
long than that reads, and the inference is the kind a later change quietly
breaks.

The set the hold reads is cleared by `invalidate_window_sources`, and the
present's own `registry_note_access` write-back moves the access to
`TransferRead` — a change under a published identity, so it bumps. The hold
therefore spans [publish .. that write-back] and ends *before* the blit it was
taken for, often before submission.

That is a division of labour rather than a gap, and the doc now says which
half is whose: the graveyard bit covers "a blit is outstanding", a fact about
submitted GPU work owned by the thread that submitted it; this set covers "the
drain has promised this resident to the window", a fact about a publish owned
by the registry. The pin that used to try to answer the first from here
answered it badly.

`the_window_hold_ends_at_the_blits_own_access_write_back` draws the span at
the same argument `begin_present` passes, so the end is asserted rather than
described.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:09:13 +03:00
Anees IqbalandClaude Opus 5 3701cdc450 residency: the refusal that named a pin nobody takes
`WindowSourceDisappearedBeforePin` said one thing: the presenter asked to pin a
resident for its blit and the registry no longer had it. The presenter takes no
pin, so nothing can construct it, and a decline variant nothing constructs is
vocabulary that reads as a live failure mode to anyone grepping the reason
census for what the window can refuse.

The census assertion moves 4 -> 3 with it, and
`a_window_source_decline_names_the_whole_identity` goes too — it asserted the
identity fields reached the line for this variant alone.

Nothing replaces it. The condition it described is now handled by structure
rather than refused: `ResourcePools::window_holds` keeps a published resident
off both reclaim paths, so the source cannot be taken out from under a present
in the first place, and a removal that does happen moves `WINDOW_SOURCE_EPOCH`
and sends the next present to host memory instead of refusing it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:05:11 +03:00
Anees IqbalandClaude Opus 5 ffb31bc6be residency: the presenter's last write to the registry, and the set that replaced it
The window presenter pinned each resident it blitted from and unpinned it when
the fence retired. That pin was the last `&mut ResourcePools` the window thread
took, and it was wrong in both directions at once. Too narrow in time: it
existed only while a blit was in flight, so a resident the window was displaying
but not currently blitting was an ordinary reclaim victim. And too wide in
ownership: it was a registry write from the thread holding no device, on a
registry now on its way to the device the guest declared it against.

Both reclaim predicates ask `window_holds` instead, which reads
`window_published` — the set the drain already maintains and every removal path
already consults to move `WINDOW_SOURCE_EPOCH`. One set now answers both
questions, which residents a reclaim must not take and which residents' removal
invalidates the window's source, so the two cannot disagree.

The hold is policy, not safety. A reclaim that took a published resident would
move the epoch, so the next present falls to host memory rather than to a
destroyed handle, and a blit already in flight is held by the graveyard bit.
Its bound is the publish set's: at most WINDOW_PUBLISHED_MAX identities, and the
publish that would exceed it clears every one of them in the same call.

`destroy` and `release_pins_after_idle` lose their `&mut ResourcePools`; the
latter is now `release_claims_after_idle`, since the graveyard claim is all it
still gives back.

Two owner-level tests replace what the presenter's pin bookkeeping stood on:
`a_window_published_resident_is_taken_by_neither_reclaim_path` asserts the hold
on both predicates and its release through `invalidate_window_sources`, and
`overflowing_the_publish_set_returns_the_residents_it_was_holding` asserts the
bound the hold rests on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 18:03:45 +03:00
Anees IqbalandClaude Opus 5 00a52e815a residency: the window's first registry-free boot, and what is left of its contact
The boot `a9a7d515` owed, and its register row.

macos-15/x86/Vulkan, driven workload then a clean SIGTERM: zero `FAIL` across
21 806 lines, 99 cadence windows all `busy=0` with **73 at `direct_frac=1.00`**,
`slate_source_stale` absent, no `winpub_*` route firing at all, first guest frame
presented via rail resident, `walk_records_render=275577`, 176 642 draws.

73 of 99 is the same shape as the 97 of 123 and 97 of 122 the two boots before it
read: 25 firmware windows with no guest frame and one crossover window, and every
window after them at 1.00. The presenter selecting from a publish-time resolution
instead of from its own registry read changes no frame.

**What is left of the window's contact with `ResourcePools`** is two writes and
no reads: `pin_resident_target` around the blit, and `registry_note_access`
after it. The pin may already be redundant with `WINDOW_PRESENT_SLOT`, which does
the same job through `open_slot_mask` and the graveyard and was added for the
case the pin never covered; the access write-back could be recorded by the
publish instead, given the present's outcome comes back to say whether the
transition actually ran. Both are the next questions, and `pools` cannot follow
`caches` onto the device until they are answered.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 16:18:55 +03:00
Anees IqbalandClaude Opus 5 a9a7d515dd residency: the window reads no registry
The step three sessions have been building toward. `begin_present`'s two
`registry_get` calls are gone, and with them the presenter's whole judgement of a
resident.

**What replaced them is one atomic load.** `source.resolved` is what the publish
resolved this identity to under the engine lock — image, access, extent, storage
class — and `source.epoch` is `WINDOW_SOURCE_EPOCH` as it stood at that moment.
The epoch moves at every point that resolution can stop being true:
`unregister_resident` (the registry's sole `remove`), `destroy_all` (its sole
`drain`), `Drop for ResourcePools`, `set_registry_access` and
`set_registry_format` — the last two being the sole writers of the only two
fields production mutates on a live slot. Every other field is written once,
where the slot is built. So a stamp that still compares equal *is* the publish's
decision, still standing.

The window thread has no device to reach a registry through and cannot be given
one: the lock a `&DeviceState` comes behind is the one the drain holds for a
whole render tranche, measured at 935-979 ms per exec packet. That is why this
had to be answerable without a lookup rather than with a cheaper one.

**Six slate reasons become two.** `no_resident`, `content_not_ready`,
`not_bgra` and `geom_mismatch` were the presenter judging a resident it had
re-resolved. It judges nothing now: `resident_present_decision` decides
presentability a frame earlier, where the registry is, and reports each as
`winpub_no_resident` / `winpub_content_not_ready` / `winpub_scanout_order` /
`winpub_geometry` on the drain's route channel. A refused publish reaches this
thread as no source at all. `CandidateState` and `classify_slate` go with them;
`note_slate` names the *promised* resolution instead of a re-read, which on
`SourceStale` is the value a reader actually wants.

**Replacement coverage, named because four tests moved out from under.**
`unready_resident_reports_content_not_ready`,
`a_ready_resident_at_the_wrong_size_is_the_geometry_class`,
`non_bgra_resident_is_its_own_reason` and
`a_resident_that_clears_every_blocker_falls_to_the_residual_class` tested the
presenter's copy of a ladder that now exists only at the publish. They are
replaced by `the_publish_names_the_first_blocker_a_resident_carries` (the same
ladder, at its owner, plus the every-rung-failing case that says the coarsest
wins), `each_publish_blocker_has_its_own_route_name` (each rung's `winpub_*`
name, and that the accepting arm hands back exactly
`slot_window_resolution` of the slot it accepted, at the epoch it read) and
`a_declined_publish_vouches_for_nothing`. The seven divergence-census tests go
with the census, which had nothing left to compare.

Verified: lib suite 2209 pass / 0 fail with `-- --test-threads=1` (2218 before,
less the seven census tests and the four ladder tests, plus three publish-side
ones). clippy identical to HEAD's four known lints; the no-`host-window` warning
set at its baseline three; `cargo doc` at 312 warnings, which is what `9ebd77f6`
measures in a scratch worktree — the handoff's "311" was stale.
`--target aarch64-apple-darwin` clean on both Metal feature sets. A driven boot
follows: this is the first commit of the four that changes which code runs on a
presented frame.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 16:13:08 +03:00
Anees IqbalandClaude Opus 5 9c2ed9c10f residency: the promised interpretation, the fifth field and the quiet one
`slot_present_decline` refuses a resident on three conditions, and the publish
decides all three: content ready, scanout byte order, geometry. Two of them are
immutable on a live slot — `content_ready` is only ever set true in production,
and `width`/`height`/`memory`/`image` are written only where a slot is
constructed, a geometry or generation change going through `retire_resident` by
`reusable_for`'s own gate. The third is not.

`registry_ensure`'s framebuffer-only arm re-declares a surface's interpretation
while keeping its allocation — same image, second texture view, new
`slot.format` — and `ResidentTargetSlot::scanout_order` derives from exactly that
field. A published BGRA resident re-declared RGBA is still resident, still ready,
still the right size, and would be blitted by a window that was told at publish
it could take it, in the wrong channel order.

Quieter than the access failure and no less wrong: not an invalid barrier, a
wrong frame. So it gets the same treatment. `set_registry_format` is the sole
writer of a live slot's declared interpretation and moves the window epoch when
the value changes under a published identity — on a change and not on a write,
for the reason its sibling gives.

**This completes the resolution.** Every field `ResolvedResident` carries, and
every condition the publish decided presentability on, is now either immutable
for the slot's life or covered by the epoch:

| field | why a fresh stamp vouches for it |
|---|---|
| `image` | never assigned on a live slot; a replacement is remove + insert, and the sole `registry.remove` bumps |
| `access` | `set_registry_access`, the sole writer, bumps on a change |
| `width` / `height` | written only at construction; `reusable_for` sends a geometry change through `retire_resident` |
| `guest_imported` | `memory` written only at construction |
| `format` / `scanout_order` | `set_registry_format`, the sole writer, bumps on a change |
| `content_ready` | never set false in production |

`begin_present`'s two `registry_get` calls are now removable, and that is the next
commit rather than this one: the divergence census has run three clean boots
against the re-resolve, and the removal is the thing it was measuring for.

Two new owner-level tests: re-declaring the format a published resident already
carries moves nothing while re-declaring it to a genuinely different
interpretation moves the stamp, and the source-level count extended to `format` —
two writers in all of `pools/`, the setter and one test helper building a slot
before it is registered, which no window can be published against.

Verified: lib suite 2218 pass / 0 fail with `-- --test-threads=1`. clippy and the
no-`host-window` warning set identical to HEAD; `--target aarch64-apple-darwin`
clean on both Metal feature sets. No boot: this changes one arm of
`registry_ensure` that the previous three boots read `gen_mismatch=0` and
`evicts=0` through, so a fourth would measure the same nothing; the removal it
unblocks is what earns the next one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 16:03:39 +03:00
Anees IqbalandClaude Opus 5 8559ec43df residency: the access rule costs nothing, measured where it could only have cost frames
The boot `1fd17c08` owed, and its register row.

macos-15/x86/Vulkan, driven workload then a clean SIGTERM: **123 cadence windows
all `busy=0`, 95 at `direct_frac=1.00`**, against 97 and 89 on the two boots
before it. `slate_source_stale` absent, all five `window_source_*` classes absent,
zero `FAIL` across 23 822 lines, `walk_records_render=275915`, 171 675 draws.

That was the open question the commit itself named: the divergence census
compares publish-time against present-time and cannot see an access change that
reverts in between, and the window's own blit write-back is exactly such a change,
once per direct present. So the rule's cost was unbounded by anything measured.
It is now bounded: it fires and never reaches the window, because the publish that
follows a bump takes its stamp after it, and the only source that can go stale is
one being re-presented with no new frame — which `needs_present` makes rare.

**Where this leaves the window.** Both of its registry dependencies now have
registry-free answers, and a fresh stamp vouches for the whole `ResolvedResident`
— image, access, extent, storage class — rather than for the image alone. What is
left before `begin_present` can delete its `registry_get` calls is two smaller
claims that are argued but not verified: that `slot.width`/`height` and
`slot.memory` cannot move without passing `retire_resident`, and what can clear
`content_ready` under a resident the publish already vouched for.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 16:01:02 +03:00
Anees IqbalandClaude Opus 5 1fd17c08f8 residency: the promised access, because a barrier from an access the image has left is not a stale picture
The window's second registry dependency, closed the same way the first was.

`WINDOW_SOURCE_EPOCH` said the promised *image* still stood. Nothing said the
promised *access* did — and `ResidentAccess` is the `oldLayout`, `srcStageMask`
and `srcAccessMask` of the barrier the present blit builds. A resolution whose
image is right and whose access is stale is an invalid transition, not a torn
frame.

`ResourcePools::set_registry_access` is now the sole writer of a resident's
access — `registry_mark_ready_with_access`, the depth sibling and
`registry_note_access` all funnel through it — and it moves the window epoch when
the value **changes** under an identity the window is published against. A fresh
stamp therefore vouches for the whole resolution.

**On a change, not on a write.** Most writes here are no-ops for this purpose: a
colour target rendered again ends in the access it was already in. Bumping per
write would invalidate the window's source on every frame the drain redraws the
displayed surface — which is every frame — and send every present through host
memory.

**The window's own write-back is deliberately not exempt.** Its blit moves the
access to `TransferRead`, which genuinely makes the resolution it is holding
wrong. A re-present of that same source, reachable through `needs_present`'s
`redraw_required` on a resize or a suboptimal swapchain, must take host memory
rather than build a barrier from an access it has itself invalidated.

**What this costs is not yet measured, and the census does not bound it.**
`window_source_access_moved` counted zero across two driven boots, but that
compares publish-time against present-time and cannot see a change that reverts
in between — the window's own write-back is exactly such a change, and it happens
once per direct present. `direct_frac` on the next boot is the measurement, and
it is the reason the next commit is a boot.

Four new owner-level tests: a published resident's access moving invalidates the
stamp; re-writing the access it already holds moves nothing, eight times over,
which is the frame-cost rule; an unpublished resident's access is not the
window's business; and a source-level count that `pools/` writes an `access`
field in exactly two places — `set_registry_access`, and
`mark_resident_storage_image` on the compute-storage registry, which is a
different registry the host window is never published against. The needle takes
any receiver rather than a binding named `slot`, because a fourth door could
write through `get_mut(..).unwrap()`.

Verified: lib suite 2217 pass / 0 fail with `-- --test-threads=1`. clippy and the
no-`host-window` warning set identical to HEAD; `--target aarch64-apple-darwin`
clean on both Metal feature sets.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:55:36 +03:00
Anees IqbalandClaude Opus 5 1837cdba10 residency: the teardown the new bump lives in, driven and read
The boot `d6155cf1` owed, and its register row.

macos-15/x86/Vulkan, driven workload then a clean SIGTERM: zero `FAIL` lines
across 24 005, all five `window_source_*` classes still absent, 122 cadence
windows all `busy=0` with 97 at `direct_frac=1.00`, `walk_records_render=264964`,
155 742 draws. Indistinguishable from the previous commit's boot on the presenting
path, which is the claim — the change alters only what happens when a registry
goes away. QEMU exited on signal 15, the harness reverted its clone, and nothing
followed on the fail channel: the teardown that drives is the `destroy_all` the
bump was added to.

**What the two commits together change about the removal that is still owed.**
The previous handoff held the re-resolve's removal behind a boot with `evicts>0`,
on the argument that the epoch's cover of *removal* was unmeasured. It is now
covered by construction instead: one `registry.remove(` in all of `pools/` and it
bumps, one `registry.drain(` and it bumps above the loop that frees the images,
`Drop for ResourcePools` for the path that replaces a pools without destroying it,
and no `.image = ` assignment anywhere in `engine/` — so a slot's image is never
replaced in place and `Image`/`Vanished` cannot arise from a single removal. A
sixth boot reading `evicts=0` would confirm what the source already says.

What is still genuinely open is the other half, and the census is what will
answer it: whether the drain moves a live source's layout or source masks between
publish and present. `Access` is the last question in front of the re-resolve.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:52:02 +03:00
Anees IqbalandClaude Opus 5 d6155cf1ce residency: the window's licence ends where the registry does, because three call sites remembering is not a cover
The comment on `invalidate_all_resident_holders` said the arrangement "cannot be
tested into place — a *new* wholesale-invalidation site that bumps only one
counter is exactly the defect, and no test relates a future site to this
function." That is a description of a rule living in the wrong place, and this
moves it.

`pools::WINDOW_SOURCE_EPOCH` is now moved by the type that owns the registry, at
the points a published resident's promise can actually end:

- `unregister_resident` — one resident leaves. Already did.
- `ResourcePools::destroy_all` — the registry drains and every image it held is
  freed. The bump is the statement above the drain loop.
- `Drop for ResourcePools` — the registry goes away without being destroyed.
  `flush_device_derived` reaches `*pools = ResourcePools::new()` on a path with no
  `ctx`, the images having died with the `VkDevice`; nothing else moved the epoch
  there, and a stamp taken before it compared equal against the new registry's
  untouched counter. Guarded on the published set being non-empty, so the
  `ResourcePools::new()` every test in this crate builds moves nothing.

`invalidate_all_resident_holders` therefore drops its window half and keeps only
`RESIDENT_RESOURCE_EPOCH`, which has no such owner — a `ResidentResourceLease` is
a value a serialized resource holds and nothing in `ResourcePools` sees one. A
future wholesale site that forgets to call it can no longer strand a window stamp,
because it cannot invalidate the registry without passing one of the three above.

**Ordering.** Both production sites bumped earlier than they now do. Neither
window widens: `presenter.destroy` frees the swapchain and releases pins but no
resident image, and `queue_wait_idle` frees nothing, so in both the bump still
precedes every image destruction. The `destroy_all` bump is deliberately the line
*above* the drain loop for exactly that reason, and a test reads the source to
say so.

**And the count that makes the claim checkable.** `registry` is a private field of
`ResourcePools`, so `pools/` is the complete search space:
`the_resident_registry_has_exactly_one_removal_and_one_drain` asserts one
`registry.remove(`, one `registry.drain(`, and zero `clear`/`retain`/`extract_if`/
`Default::default()`. A third exit added by someone who did not know the window
existed is a use-after-free that nothing in the build would otherwise relate to
this rule. Needles are assembled from pieces so the test's own source is not a hit.

Four new owner-level tests: the two source-shape ones above, and Drop moving the
stamp when a pools carried a window source and not moving it when it carried none.

Verified: lib suite 2213 pass / 0 fail with `-- --test-threads=1`. clippy on
`backend-vulkan,host-window --all-targets` and the no-`host-window` warning set
both identical to HEAD. `--target aarch64-apple-darwin` clean on
`backend-metal,host-window` and `backend-metal,backend-vulkan,host-window`. The
paths this changes — device loss, guest reset, teardown — did not fire on the
previous commit's boot (`device_lost=0`, no reset), so the owner-level tests are
the coverage and a boot would not add to it; a live boot follows to confirm the
teardown path it does touch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:46:20 +03:00
Anees IqbalandClaude Opus 5 7d4a738f83 residency: the two resolutions agreed on every presented frame, and nothing left the registry to disagree
The boot `b37b6740` was written to be read, and its register row.

macos-15/x86/Vulkan, driven workload (three rounds of five apps): **all five
divergence classes absent**, zero `FAIL` lines outside `store_routes`, 136 cadence
windows all `busy=0` with 89 at `direct_frac=1.00`, `slate_source_stale` absent,
`walk_records_render=278859`, 169 515 draws.

The census runs on every present that takes a resident, and `direct_frac=1.00`
across 89 windows says that is nearly all of them — so the absence is a reading
and not a dead path. The publish-time resolution and the window's own re-resolve
agreed on every presented frame.

**What it does not say, and this is the half that matters.** `evicts=0` and
`gen_mismatch=0` on all 199 lines, for the fourth boot running. Nothing left the
registry, so `Vanished` and `Image` — the two classes that would say
`WINDOW_SOURCE_EPOCH` is not a complete cover of *removal* — were never given a
chance to fire. Reaching them needs a `sample_count` or `Texture`-format change at
an otherwise identical key, every identity namespace already carrying
width/height/generation. That is what is still owed before the re-resolve goes.

Also corrected while the boot ran: `caches::unified_color_layout()` is on by
default, so a colour target rests in `GENERAL` for its whole life and the *layout*
half of the stale-`access` hazard is already largely closed on the shipping
configuration. `ResidentAccess` is not only a layout, though — it also supplies
the barrier's `srcStageMask`/`srcAccessMask`, and a stale `TransferRead` over an
image last written as a colour attachment names TRANSFER_READ as the source and
fails to make that write available. Comparing the whole enum, which is what the
census does, is therefore the right comparison, and a same-layout different-masks
line is a genuine reading rather than noise.

No code change. Register row only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:41:34 +03:00
Anees IqbalandClaude Opus 5 b37b67409b residency: the window's registry access is two dependencies, and the stamp answers one
The plan for removing `begin_present`'s registry re-resolve was "publish carries
what the window reads off the slot". Reading the blit says that sizing is wrong,
and this commit is the census that will say by how much.

**The second dependency.** The window does not only *resolve* an identity. It
reads `slot.access` — the Vulkan layout its blit barrier names as `oldLayout` —
and on the way out it writes `registry_note_access(identity, TransferRead)`. The
read is a read-modify-write of registry state, not a field copy. `epoch` makes
"is the promise still good?" answerable with one atomic load; nothing yet makes
"what layout is the image in?" answerable, and a barrier from a layout the image
has left is not a stale picture but an invalid transition. Publishing the layout
as a value and removing the re-resolve would trade a torn frame for undefined
behaviour.

So the resolution is carried and *compared*, not used. `ResolvedResident` is what
the blit reads off a slot — image, access, extent, storage class — produced by one
function so the publish-time resolution and the present-time re-resolve cannot
read different fields and call the result agreement.
`prepare_window_resident_present` returns it beside the stamp;
`WindowPresentSource` carries it; `begin_present` compares it against its own
re-resolve and names the first difference on the always-on channel. The blit still
uses the re-resolve, so no frame changes.

**What the classes are for.** `Vanished` — a fresh stamp over an absent slot —
would say the epoch is not a complete cover of the ways a published resident can
leave, which is the claim the registry-free check rests on. `Image` is the
use-after-free case. `Access` is the finding this exists for: a boot where it
appears says the removal must move layout ownership rather than carry a value.
The line carries both resolutions because this window's own blit leaves a
resident in `TransferRead`, so `ColorWrite -> TransferRead` is this thread
re-presenting a source it already blitted — a redraw with no new frame — while
any other pair is the drain having touched the image in between. Those have
different fixes and the class alone cannot tell them apart.

Latched per class, no counter: reachability is the open question, and the same
argument `resident_retired_while_pinned` records.

`selected` becomes `(TargetIdentity, ResolvedResident)` instead of a six-tuple
destructured at three sites — the shape the removal wants, and the reason the
`host_accessible` element could be read as the geometry element at any of them.

Seven owner-level tests on the ladder as a pure function rather than through a
log line: one per class, one that the coarsest difference wins when every field
moved at once, one that no two classes share a slug, one that every rendered
field is a whitespace-free `k=v` pair (the sink is parsed by splitting on
spaces), and one that a vanished source names only what was promised rather than
echoing it back as if a slot were there.

Verified: lib suite 2209 pass / 0 fail with `-- --test-threads=1`. clippy on
`backend-vulkan,host-window --all-targets` identical to HEAD (the four known
pre-existing lints); the no-`host-window` warning set back to its baseline three
after the two new fields are marked as read only by the arm that compiled a
window. `--target aarch64-apple-darwin` clean on both `backend-metal,host-window`
and `backend-metal,backend-vulkan,host-window`. No live boot yet: the census is
the reason to run one and its reading is not in this commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:35:23 +03:00
Anees IqbalandClaude Opus 5 9ebd77f69b residency: a stamp the window can check without a registry, because the registry is leaving and the window cannot follow it
The window thread reads the resident registry on every present —
`registry_get` to resolve the identity it was published against, and again on the
failure path to name why. That read is what holds the registry in the
process-global engine, and Part 2 of this line of work settled that it cannot
simply be given a device to read one through: the lock a `&DeviceState` comes
behind is `BoundDevice::inner`, which the drain worker holds for a whole render
tranche — measured at 935-979 ms per exec packet in `sync_exec_lock_hold` — and
`device::window_publish` already uses its own small mutex precisely so it never
contends that. A present waiting on the render tranche is not a present.

So the read has to be replaced by something answerable without a registry.

**The stamp.** `ResourcePools::window_published` records every resident the window
has been published against; `pools::WINDOW_SOURCE_EPOCH` moves when one of them
leaves; `WindowPresentSource` carries the epoch as it stood at publish; and
`begin_present` compares them with one atomic load, ahead of the registry read,
falling to `SlateReason::SourceStale` on a mismatch. The check runs *before* the
re-resolve rather than as one more condition inside it, so it runs in the shape
it will run in once the re-resolve is gone instead of being exercised only as a
redundant agreement with an authority on its way out.

It does not replace the re-resolve yet. That is deliberate: a disagreement
between the two is a thing to find on a live boot while there is still an
authority to disagree with, and `note_slate` already reports it —
`reason=slate_source_stale`, run-deduped with a frame count, and a dent in
`direct_frac` because the present falls back to host memory.

**Two holes this had, both of which compiled, passed and booted clean.**

*The wholesale sites bumped only `RESIDENT_RESOURCE_EPOCH`.* `reset_guest_state`
does `*pools = ResourcePools::new()` after `destroy_all`, resetting the published
set but moving no window epoch — so a source stamped before a guest reset still
compared **equal**, and would have presented from an image `destroy_all` had
freed. The three wholesale sites now go through one
`invalidate_all_resident_holders`: two counters, different holders, one event.

*`window_published` was `Option<TargetIdentity>` — "the latest".* That is not the
set of residents a live source can name. The frame slot holds the newest source,
but the window thread may be holding an older one it has already read out, so
publishing B must not stop vouching for A; recording only the latest let a switch
of displayed surface hide A's removal. It is a set, cleared when the epoch moves,
bounded by `WINDOW_PUBLISHED_MAX`, and **overflow bumps rather than evicting** —
evicting the oldest reintroduces the same hole through the bound. A declined
publish is a no-op rather than a clear, because the window goes on presenting the
source it was already given.

Five owner-level tests, one per rule, every one driven through
`note_window_published` + `unregister_resident` rather than by moving the counter:
a test that moves it itself passes with the bump wired to nothing.

Verified: lib suite 2201 pass / 1 fail (`the_cursor_bound_matches_the_sprite_size_
qemu_will_allocate`, which reads `vendor/qemu/ui/cursor.c` in a worktree that has
none). clippy, `cargo doc`, and the no-`host-window` warning set all identical to
HEAD; checked `backend-vulkan`, `backend-vulkan,host-window`, and `--target
aarch64-apple-darwin` with `backend-metal,host-window` and
`backend-metal,backend-vulkan,host-window`. Driven macos-15/x86/Vulkan boot of the
*previous* shape (single-identity, no `invalidate_all_resident_holders`):
`slate_source_stale=0`, zero `FAIL`, 116 cadence windows all `busy=0`, 91 at
`direct_frac=1.00`. Boot of **this** shape: round 1 of 3 at commit time —
`slate_source_stale=0`, zero `FAIL`, 57 cadence windows all `busy=0`, 32 at
`direct_frac=1.00`. Rounds 2-3 not yet read.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:23:23 +03:00
Anees IqbalandClaude Opus 5 63d6d6b2e9 residency: the six submissions and what makes each visible, because the warning that caught one was abstract
`ce3e0062` closed the host-window present's invisibility to `open_slot_mask` on
the strength of that function's own warning about "a third state" the graveyard
does not cover. The warning was right and abstract, and one caller had already
walked into it — so this walks the rest and writes down what it found.

Six sites reach the queue, and each is covered by exactly one of three
mechanisms: `seal_entry` + `finish_entry_async` marking a slot pending (the draw
exec, the guest-write copy, the readback copy, and compute's transient storage);
the pin plus `compute_rekey_refusal` and the `!pinned` filter in
`recoverable_compute_storage_residents` (compute's *registered* residents, which
are deliberately popped out of the ring's live set at acquire and so need a
second mechanism); and `WINDOW_PRESENT_SLOT` (the present, which was the gap).

Nothing here changes behaviour. The table is beside `open_slot_mask` because that
is where a seventh submission's author will be standing, and it is labelled as a
reading of six call sites rather than a gate — nothing in the build relates a new
submission to it, which is exactly why the prose warning was not enough on its
own.

Verified: driven macos-15/x86/Vulkan boot on `ce3e0062` — **zero `FAIL`**, 133
`host_window_cadence` windows every one of them `busy=0` (no `busy_fence`, so the
graveyard change introduced no stall), 108 windows at `direct_frac=1.00`, and the
same decline profile as the `16aab32b` control. `evicts=0` again, so the recreate
arm still did not run and the park remains verified at the owner's boundary
rather than live. `cargo doc` warnings identical to HEAD (311); check green on
`backend-vulkan,host-window`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:09:20 +03:00
Anees IqbalandClaude Opus 5 ce3e00622d residency: the host window's blit is a slot the graveyard can see, because dispose was told to consult one that never named it
`16aab32b` named the precondition: a pin does not defer disposal, so a resident
retired by a `registry_ensure*` recreate arm while the host window was blitting
from it could be destroyed under the running blit. This closes it, and the shape
is not invented here — `open_slot_mask`'s own documentation prescribes it:

> A caller that wants to record several independent units of work into one
> submission ... must either do all of its bookkeeping after the submit, or make
> its recording slot visible here the way `open_batch` is. Do not assume the
> graveyard covers it: it covers the two states above, and this is a third.

The host window is that third state and now has a bit.
`WINDOW_PRESENTS_IN_FLIGHT` counts presents submitted and not yet retired;
`open_slot_mask` ORs `WINDOW_PRESENT_SLOT` while it is nonzero, so `dispose`
parks the image in the graveyard instead of taking its immediate-destroy arm.
The count is a count because the presenter runs a ring and several entries can
be outstanding.

**Why an atomic the presenter owns and `pools` only reads.** The alternative was
a field on `ResourcePools` that the presenter writes, and that is the coupling
the cutover exists to remove: the registry is guest-derived state on its way to
the device the guest declared it against, and the window thread holds no device
and cannot be given one. So the dependency runs one way. `pools` gives the bit
back from `advance_graveyard_maintenance`, which already runs per published
frame, at the cost of one load — rather than the presenter reaching into a
registry it must stop being able to reach.

A `static` and not a field on either side because it is a fact about the process:
one rail is latched, the engine owns one context, and `window_presenter` hangs
off that same owner as one host window — the same reason `owner` and `counters`
stay where they are.

**The clearing is one path.** `end_present_in_flight` takes a `&mut PresentFrame`
rather than being a method, because two of the four clearing sites iterate
`&mut self.frames` and could not call a `&mut self` method; a method plus two
hand-written copies is how the latch and the slot would come apart, and clearing
the latch alone opens the graveyard while the blit runs. `mem::replace` and not
an unconditional decrement, because `recreate_swapchain` and `destroy` both
clear latches that may already be clear.

Two sites needed nothing. `release_graveyard(!still_open)` recomputes
`open_slot_mask()`, so it preserves the window's bit for free. `destroy_all`
passes `SlotMask::MAX`, which does clear it against no fence of its own — sound
at all three callers, by two different routes, and now written down there as the
function's precondition rather than left as a property of today's callers.

Tests, owner-level and GPU-free: an idle ring with a present outstanding reports
`WINDOW_PRESENT_SLOT` rather than `0`, parks the handle, refuses to release it as
each engine slot retires, and releases it when the window's bit comes back; and
the window's bit aliases no slot index over the whole range `open_slot_mask`
derives bits from, with a `const` assertion beside the constant for depths a test
cannot enumerate.

`16aab32b`'s decline doc is corrected in the same commit — it claimed the hazard
was unfixed, which is no longer true. What the line reports now is the condition
underneath it, which still matters for the holder classes the window's bit does
not speak for, and it gains the reading a zero needs: a zero means nothing beside
`evicts=0`, because `evicts=0` says no recreate arm ran and the emitter was never
reached.

Verified: driven macos-15/x86/Vulkan boot on `16aab32b` (`drive-g2`, three rounds
of five apps opening and quitting) — `resident_retired_while_pinned=0` with
`evicts=0` and `gen_mismatch=0`, so **the path was not exercised and that boot is
not evidence either way**; `direct_frac` up to 1.00, zero `FAIL`. Lib suite 2196
pass / 1 fail (`the_cursor_bound_matches_the_sprite_size_qemu_will_allocate`,
which reads `vendor/qemu/ui/cursor.c` in a worktree that has none). clippy
identical to HEAD. Checked: `backend-vulkan`, `backend-vulkan,host-window`, and
`--target aarch64-apple-darwin` with `backend-metal,host-window` and
`backend-metal,backend-vulkan,host-window`. Not run: a boot on this commit, so
the graveyard park is verified at the owner's boundary and not yet live.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 15:03:33 +03:00
Anees IqbalandClaude Opus 5 16aab32b65 residency: the one removal path that does not wait for the holder it removes, named before it is sized
`pools` is the group the cutover has left, and the plan for it was to resolve the
window's present source on the drain — where a `&DeviceState` already is — so the
host-window thread stops reading the resident registry. Reading the pin
lifecycle to write that turned up a precondition that has to be settled first,
and it is not about the cutover at all.

**A pin does not defer disposal.** Two of the three removal reasons honour a pin
and the third cannot. `recoverable_residents` filters on `pin_count == 0`, so
`AllocationReclaimed` never selects a pinned slot. `ResourceReleased` leaves the
slot in the registry marked `resource_released` and lets maintenance retire it
once the last pin leaves — the deferral `ResidentTargetSlot::resource_released`
documents itself. The `registry_ensure*` recreate arms are the third, and they
have nowhere to defer to: the guest replaced the resource under this identity, so
the key must be free for its successor.

What actually has nowhere to wait is the *disposal*. `retire_resident` hands the
image to `dispose`, whose deferral is keyed on `open_slot_mask` — the engine's
own open command-buffer slots. The host window's present transaction is not one
of them. It carries `WindowPresenter`'s per-frame `in_flight` fence, submitted
inside `begin_present` and not waited on until some later present's `retire`, so
a recreate arriving between those two points can see `open_slot_mask() == 0`,
destroy the image on the spot, and leave the queued blit reading freed memory.

Today the window re-reads the registry and takes its pin inside the same engine
critical section that records the blit, which is what has kept the interleaving
narrow rather than what makes it safe — and publishing a resolved image to the
window thread, which is the cutover's plan, widens it from a critical section to
a frame interval. So the fix has to land first, and the fix changes what a pin
*is*: a retention that defers disposal, which needs the pin to carry the slot it
was taken against so an unpin can never be applied to a successor registered
under the same identity. That is a token at every pin site.

This commit does not do that. It makes the precondition say so on the always-on
stream, latched per removal reason, because the honest input to sizing a change
of that shape is whether it fires on a live boot and for which reason — and
`Recreated` is the only reason the reading above says can reach it. `pins` and
`resource_owners` both go on the line: their difference is which holder class is
outstanding, and the transient class is the one whose fence `dispose` never
consults.

Owner-level, both arms. `removing_a_pinned_resident_names_the_holder_...` pins
through the product path and asserts the rendered line's `why`, `pins` and
`resource_owners`; `removing_an_unpinned_resident_says_nothing` is the other
half, for the reason the readback-memory probe reports both of its outcomes — a
silence has to be readable as "no holder was outstanding" rather than as an
emitter nobody wired.

Verified: `-p reims-vgpu --lib --no-default-features --features
backend-vulkan,host-window`, 2194 pass, 1 fail — `the_cursor_bound_matches_the_
sprite_size_qemu_will_allocate`, which reads `vendor/qemu/ui/cursor.c` and was
run in a worktree that has no `vendor/qemu`. Not run: any live boot, so whether
this fires is exactly the open question and not something this commit answers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 14:52:01 +03:00
Anees IqbalandClaude Opus 5 50a3b9db15 cutover: the object caches are the device's, because every key in them is something the guest declared
The first handle-owning subsystem out of the process-global engine, and the
smallest one whose disjointness holds structurally rather than by an argument
about call sites.

**Why these and not the context.** A `VkInstance` and a `VkDevice` are facts
about the host: one physical GPU per process, chosen once, and the capabilities
derived from it are the same for every guest device that ever runs against it.
What is *cached* against them is not. Every entry in `ObjectCaches` is keyed by
something the guest declared — a shader's content digest, a pipeline's
descriptor, a render pass's attachment set, a sampler's state — so the
population is a function of the guest's own object set and ends when that
guest's device does. Keeping it beside the context made it outlive every device
on the process, which is what device epochs exist to stop.

So `EngineState` loses `caches`, and `VulkanDeviceState` — the rail slot
`DeviceState` already owns — gains them. `owner`, `pools`, `counters` and the
window presenter stay where they are, and this commit makes no claim about them:
the tally that picked this group says `caches` is touched by exactly six entry
points, that four of them are `execute_draw_request`, `execute_compute_request`,
`flush_batched_draws` and `object_cache_levels`, and that every caller of those
four already holds a `&DeviceState` or has one in scope. `window_present_*` and
`mark_drain_thread` — the entry points reached from the host-window loop and the
QEMU FFI, which hold no device and should not have to — touch `owner`,
`counters` and the presenter and none of them touch a cache. That is the
disjointness, and it is a property of the field tally rather than of who happens
to call what.

**The lock, and the one path that could have inverted it.** The caches get their
own `parking_lot::Mutex` rather than a field under the engine's, because the slot
they live in belongs to `DeviceState` and the engine may not own a device's
lifetime. Every entry point takes the engine guard first and this one second.
`DeviceObjectCaches::end_device` is the exception and is written to be one: it
empties the caches under its own lock, releases it, and only then asks the
engine for a context to destroy them through — so the one path that runs at
device teardown, from `Drop`, cannot take them in the other order.

**The unreachable arm is refused by name.** `rail_state` answers `None` when
another rail's type holds the slot, which `backend::select`'s one-rail-per-
process latch makes unreachable in any live build. It is refused as
`EngineFacadeDecline::DeviceCachesUnreachable` rather than fallen back on,
because the only available fallback is a second cache — and a second cache is a
second owner of the same `VkPipeline`.

`Backend::flush_deferred_submissions` and `Backend::emit_census` take the device.
The first because it is one of the three places a device loss is *acted on*, and
acting on one drops everything derived from the `VkDevice` that is going away —
an arm here that could not reach the caches would leave a dead device's handles
in the slot for the next draw to bind. The second because a census that could
not name the device would be reporting somebody else's levels. The Metal rail
reads neither; its caches are its own, and the trait carries the more demanding
of the two.

Verified. `cargo test -p reims-vgpu --no-default-features --features
backend-vulkan,host-window -- --test-threads=1`: 2193 lib + 60 parity + 16
compute + 15 batch + the rest, 0 failed — including
`warm_identical_draw_zero_creates_and_allocs`, which is the assertion that would
break first if the caches stopped being found.
`scripts/feature-matrix/feature-matrix.sh --no-counts`: all arms PASS. The Metal
cell caught the `emit_census` signature break that no Linux-target build can
see, which is the first time it has been in a position to.

New coverage: `a_second_devices_caches_are_its_own_and_ending_one_spares_the_other`
asserts what the process-global shape could not express — two `DeviceState`s on
the *same* `VkDevice`, the second drawing the identical request cold
(`creates > 0`, inheriting none of the first's warm pipelines), warm on its own
second draw, and its ending leaving the first device's levels unchanged and its
next draw still warm.

Live: driven macos-15 boot to the desktop, three rounds of five applications.
`FAIL` absent from 23 172 lines, `device_lost=0` on all 212 `engine_delta`
lines, `vk_engine_device_caches_unreachable` never fires, and
`object_cache_levels` — read through the device now — climbs and settles as
before. `dead/README.md` carries the row.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 14:35:54 +03:00
Anees IqbalandClaude Opus 5 871fe628c4 model: the device lifetime the rail slot never had, because everything left to move into it owns objects a drop cannot destroy
`RailDeviceState`'s own doc states the division the cutover runs on: the model
owns "the slot, the drop, and *when* a lifetime ends", and tells the rail about
a task teardown through `delete_task` because what dropping a task's references
costs is the rail's to know. A **device** lifetime ends the same way and was
never told. The slot was simply dropped — at `DeviceState::reset`'s wholesale
`*self = Self::new(..)`, and again when `device_destroy` drops the device out of
the registry.

That was survivable only because the slot holds nothing a host has to be told
about. `VulkanDeviceState` retains pipeline identities and `Arc`s, and every
native object behind them belongs to the process-global engine, which outlives
every device and destroys them through its own context. It is not survivable for
anything still to come: the plan's next tier — residency, variant families,
transfer and record state — owns `VkImage`, `VkPipeline` and command-buffer
lifetimes whose destruction goes through a device that `Drop` cannot reach and
cannot report. This is the ordering rule's "the model that owns those lifetimes"
and it did not exist.

So `RailDeviceState` gains `end_device`, and it is owned by `Drop for
DeviceState` rather than written at `reset`. A device ends two ways and `reset`
is only one of them; `Drop` is the single point both pass through, which is the
difference between an obligation that cannot be forgotten and one that a later
teardown path forgets. The slot is read through `OnceLock::get` and never
through `rail_state`, because the initializing accessor would *create* a rail
state for a device no rail ever claimed and then report an empty teardown for it.

`TaskReferenceStates::clear` is the table's half. It is not a loop over
`delete_task`: nothing here can enumerate the guest's task ids, and a guest is
under no obligation to delete its tasks before the device goes away — a reset
under a running guest is exactly the case where it does not, so the states left
behind are the normal population at this event rather than an error path. The
Vulkan rail reports them under `pipeline_state_device_ended`, its own name and
not `pipeline_state_task_deleted`, because an orderly per-task teardown and a
device vanishing with work still declared are different facts about a boot and
one counter carrying both cannot say which happened.

No guest-visible behaviour changes: the table was already emptied by its own
drop, and what is new is that the rail is told and that the count is on the
failure channel.

Owner-level tests, at both owners. Model side: the drop door tells once, the
reset door tells once and the lifetime after it ends on its own terms, and a
device no rail claimed ends without creating one. Rail side: an ending releases
every task no deletion named, while a state an encoder still holds outlives the
table exactly as it does across a reference delete. The counting tests serialize
on their own mutex rather than on `--test-threads=1`, because a gate that holds
only under a flag somebody has to remember is not a gate.

Verified: `cargo test -p reims-vgpu --lib --no-default-features --features
backend-vulkan,host-window -- --test-threads=1` 2193 passed, 0 failed;
`scripts/feature-matrix/feature-matrix.sh --no-counts` all arms PASS, including
both Apple cells; clippy clean on both touched files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 14:09:32 +03:00
Anees IqbalandClaude Opus 5 dd5e2a13dc dead: the reply destination asked of all six rails, and the four the plan listed as untried
The six-rail sweep `10764f8b` committed the script for, run end to end (13:26 to
14:02) with one binary shared by every rail, against `7ddd6f72` and `02bd23cd`
— the two commits that added the reply-frame geometry question and the second
stamp publisher. No code change; this row is the reading.

The term closes. `device_info_reply_frame_in_a_mapping` is **0 on all six** and
`device_info_reply_frame_in_no_mapping` fires on all six, so the frame a guest
is told to write its device-info reply into is never one of a live mapping's
pages on any rail this project can boot. The aliasing arm the question was asked
to find does not exist, which makes the term settled rather than untried — the
distinction the mint-count arm it replaced could never draw, since
`device_info_reply_after_an_identity = 1` everywhere.

Two more of the superseded section's numbers hold across the whole set:
`packet_class_unclassified = 0` on all six against the 2166 it recorded, and
`stamp_wait_model_ahead = 0`. `FAIL` appears in none of the six logs. Render
traffic spans two orders of magnitude across the rails (13 041 to 230 110
records), so those zeros are not one workload's accident.

`backing_id_heap_placed = 0` on all six, so the heap-extent term stays
unrecovered and refused by name — and the four rails the plan listed as untried
for it are now tried.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 14:02:55 +03:00
Anees IqbalandClaude Opus 5 0ce6188a85 exec: a wire constant carried a backend cfg, and it has had the Metal arm's test build red since the exec-walk landed
`runtime/exec/tests.rs` imported `reims_vgpu_wire::OP_HEADER_LEN` under
`#[cfg(feature = "backend-vulkan")]`, on a comment saying only the Vulkan-only
compute-preflight test named it. That was true when it was written. It is not
true now: the file names the constant 186 times, and 103 of those are outside
any `backend-vulkan` region — the exec-walk suites grew into it at `dc99ef8c`
and `b50d0633`.

So `cargo check --all-targets --target aarch64-apple-darwin --features
backend-metal,host-window` fails with 103 `cannot find value OP_HEADER_LEN`,
and has since that work landed. That is both Metal cells of
`scripts/feature-matrix/feature-matrix.sh` — the arm and the both-rails arm —
red, which is the exact failure mode that script's header was written about
after the arm last rotted unnoticed.

No `cfg` on a wire constant has a correct arm: `OP_HEADER_LEN` is the same
number on every rail, so the gate could only ever be wrong in one direction.
Removing it is the whole fix, and it leaves no unused import on either rail
because both name the constant.

Verified: `--all-targets` now clean on `backend-metal,host-window` and
`backend-metal,backend-vulkan,host-window` against `aarch64-apple-darwin`, and
on `backend-vulkan,host-window` natively; `cargo test -p reims-vgpu --lib
--no-default-features --features backend-vulkan,host-window --
--test-threads=1` 2188 passed, 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 14:02:44 +03:00
Anees IqbalandClaude Opus 5 0108dbbc36 feature-matrix: the note said Metal cannot be cross-checked off Apple, and the script it documents has been doing it all along
`feature-matrix.sh`'s own `--help` block says the Metal arm cross-checks from any
host, and explains why: `src/lib.rs` rejects `backend-metal` on
`not(target_os = "macos")`, which is a condition on the target rather than the
host, so `--target aarch64-apple-darwin` satisfies it and `cargo check` needs no
Apple SDK. The script has done exactly that since the arm rotted to 11 unnoticed
errors under the old theory.

The README kept the old theory. Measured here on Linux, `cargo check -p
reims-vgpu --target aarch64-apple-darwin` finishes clean in about ten seconds
warm for `backend-metal`, `backend-metal,host-window`, and
`backend-metal,backend-vulkan,host-window` — every Apple configuration the
pathway table ships, including the both-rails row.

That matters more than a documentation slip usually does. A session read this
note, concluded the Metal arm could not be verified from this host, and recorded
it in its handoff as a standing constraint on what could be changed — which
would have held the last cutover group back on a false premise, since it needs
`Backend` trait signatures to change and those are only checked on the arm this
note said was unreachable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 13:57:14 +03:00
Anees Iqbal 10764f8bad vm: the sweep and the workload it drives, because a rate is only comparable across boots if the workload is
Every validation row in `dead/README.md` names "host-driven workload (three
rounds of launching and quitting five applications over ssh)", and that
sentence has been a shell script in `/tmp` that each session re-derived from
the row it was reading. Two sessions re-derived it slightly differently. A
rate measured against a workload nobody can reproduce is not a reading, so
the workload is committed and named: `vm/drive-desktop.sh`.

`vm/rail-sweep.sh` is the sweep over it. A defect found on one guest OS line
is not a defect found on the pathway — macos-26 refused 914 exec packets on
`pipeline_absent` where macos-15 refused none — and `AGENTS.md` says not to
generalise between rails, so a regression sweep means all six provisioned
lines. The readings live in the script's KEYS and SUMS so that every later
sweep answers what this one answered.

Two things it refuses. It will not start while another boot or its QEMU is
live or host port 2222 is bound: QEMU's ssh hostfwd is a single host port, so
the first rail dies on it instantly and is then reported as a rail that never
presented a frame, and `boot-x86.sh` outlives its own QEMU so killing QEMU
alone does not free the port. **The preflight kills nothing** — it reports and
exits, because what is in the way may be somebody else's evidence run, and it
stops only the boot it started itself. It also does not rebuild between rails,
since `boot-x86.sh` does, and editing source mid-sweep gives the rails
different binaries.

`/vm/*` is ignored with an allowlist, so both scripts need their own line.
2026-09-03 13:35:44 +03:00
Anees Iqbal f9f96cedd3 dead: what is still live, read off the tree rather than off the plan
The plan's "final group" section names that group as `Namespace` +
`RefResolver` + the four `ingress::Gap` classes + the ingress switch. Three
of the four have since moved and the section has not been rewritten, so a
reader taking it as current goes looking for work that is done: the name
authority is `reims_vgpu_core::lifecycle::Lifecycle` and every lifetime door
routes through it, the ingress switch is cut at `admit_and_park`, and `Gap`
is down to two variants with the first refusing nothing a driven guest sends.

What blocks the wholesale delete is the third item on Seam 6's own disconnect
list and it is one thing: the process-global mutable engine, 62 000 lines
behind `static ENGINE` with nine more statics beside it. That is also what
holds the rest of `reims-vgpu-vulkan` out — the twelve wired modules are all
pure translations whose callers kept ownership, and the next tier owns
handles and retirement points, which the plan's own ordering rule places
after the model owning those lifetimes.

Recorded where the deletion rule is, because that is where the question
"is it time yet" gets asked.
2026-09-03 13:28:27 +03:00
Anees Iqbal 02bd23cd41 drain: the plane's other publisher is counted, because one nobody counts reads like one that never runs
The ordering plane's stamp timeline has two writers. The drain's read of the
guest's page is counted at three sites; `SessionModel::complete` publishing
its channel's released stamp is counted nowhere, because the model cannot
reach a failure channel or a route.

The asymmetry is not cosmetic. A whole driven boot reads
`stamp_publish_first = 1` and `stamp_publish_advanced = 1` against 1 700 804
page observations, which reads as a timeline that never moves — and is
instead a timeline that had always already moved by the time the page was
read. Every entry came from a completion, so the counted publisher only ever
found them there.

So the caller counts it: `stamp_published_by_channel` for a release carrying
a word, `stamp_released_without_a_word` for one that owes none, which is the
denominator that separates a channel publishing nothing from a channel
releasing nothing. The pair is what makes `stamp_publish_behind` readable —
it is the numerator the page's observations are behind.
2026-09-03 13:25:47 +03:00
Anees Iqbal 7ddd6f72f3 objects, drain: the reply page is asked about storage and not about numbers, because the count it was asked about closes on no real rail
`note_device_info_reply_destination` closes its term when nothing has been
minted, on the reading that a fresh number cannot equal a number nobody
holds. Both driven rails read `device_info_reply_scanned = 1` and
`device_info_reply_after_an_identity = 1`: the guest asks after this device
has minted, every time, so the closing arm never runs on a real guest and
the term would stay open on the counter alone.

The counter was also answering the wrong question. One monotone never-reused
counter feeds all three of `BackingWindowRefs`' key spaces, so a fresh number
cannot equal one already handed out — that half needs no boot. What the plan
names is aliasing rather than collision: the reply page being *storage* some
other identity already covers, so the reply write and every access to that
storage come out over two backings with no edge between them.

So it is asked of geometry, in the one key space a bare page frame can
collide with. A task-GVA window is the other instrument's half; what is left
is a mapping's surface, whose storage is a list of guest page frames.
`device_info_reply_frame_in_no_mapping` closes and
`device_info_reply_frame_in_a_mapping` opens, and both are reachable on a
rail that has already minted. An unmapped entry's stale page list is not
storage anything holds, and the test pins that alongside the hit and the
miss.

The same two boots retake the ordering group's classification denominator on
macos-15 — 25 694 classified, zero unclassified against the 2166 recorded,
`packet_unadmitted = 0` — and read the task-GVA half of the reply term at
twenty-eight replies, none inside an allocation this device identifies, on
both rails. `backing_id_heap_placed` is zero on both, so the heap-extent term
stays unrecovered with macos-26 now tried.
2026-09-03 13:23:09 +03:00
Anees Iqbal 1a83594130 drain, dead: the two counters a boot was needed to read, and what they turned out to be
`48f6252e` put the slot, the page's word and the plane's point on the
`stamp_publish_behind` line precisely because a bare count could not say
whether the counter's meaning had drifted or its invariant had broken —
`dead/README.md` records it at zero and every boot since `2099769c` reads
about fourteen thousand. A driven macos-26 desktop reads the line.

The meaning drifted. Three slots ever answer it, all inside the boot's
first 24 seconds and none after, by one to seven. The zero was taken when
the drain's page read was the ordering plane's only publisher; the model's
own completion publishes the channel's released stamp straight into the
scheduler now, counts no route where a store-route dump would show it, and
the word itself is queued on the GPU-ordered rail — 1 700 804 observations
against 25 stamps written inline. The page is behind because the write has
not landed, not because it went back: 2203 forward writes against one
backward. And nothing is decided inside that window — `stamp_wait_model_ahead`
and `stamp_wait_model_behind` are both zero against 767 waits decided, which
is the whole difference between this and the 12 824 the publication point
was moved to escape.

The same boot retakes the ordering group's classification denominator, whose
recorded reading names a ledger row that has since settled: `CmdDeleteObject`
was `Closure::Unresolved` and is `Closure::Implemented`, and this rail sends
none of the four commands `classify` still refuses. 2227 packets classified,
zero unclassified, no line on the failure channel. On this rail the group
refuses nothing for want of a class.

Both readings go beside the code that asks the question, and the boot's
row goes in `dead/README.md`. No behaviour changes.
2026-09-03 13:16:19 +03:00
Anees Iqbal 1795be1e7c compute: a refused dispatch says what the ordering plane thought of its pipeline, the same way a refused draw does
The render arm gained this field in `d1637062` and it is what made macos-26's
two remaining render losses legible: both read `model_pipeline=retired`, which
is a packet recorded before the guest's delete still binding the pipeline — the
loss `6587f618` chose to take — and not `ready`, which would be the ordering
plane releasing work against a shader still being translated. Opposite
conclusions from the same line.

The compute arm had no such field, so the same boot's three compute refusals
cannot be classified at all. They are the only losses left on that rail with no
reading.
2026-09-03 12:55:10 +03:00
Anees Iqbal 0ee2bb4c5b dead: the withdrawal on the rail that deletes pipelines, and what the residue turns out to be
macos-26 rewrites shaders five times as often as macos-15 (26
`m2v_pipe_content_changed` against 5) and retires 120 pipelines a boot against
4, which makes it the rail to try a scheduling change on. It does not hang and
strands nothing: 0 FAIL, table resting at `pending=0 … ready=108 retired=120
total=228`, `pipeline_lease_withdrawn = 14` with `pipeline_ready = 242` =
`declared 228` + those 14.

The row's value is the separation, not the confirmation. Five losses remain and
**none reads `model_pipeline=ready`** — the field `d1637062` added is what says
so. Both render ones read `retired`: a packet recorded before the guest's delete
still binds the pipeline, which is the loss `6587f618` chose to take. The three
compute ones carry no such field and are owed one before they can be classified.

`packet_unadmitted = 9` is recorded as unattributed rather than clean: no
macos-26 boot was taken at the pre-change commit, and an argument that the
change cannot reach admission's refusal path is not a measurement.
2026-09-03 12:54:14 +03:00
Anees Iqbal 48f6252e5b drain, model: a word behind the plane's timeline says which slot and by how much, because the count is two different facts
`stamp_publish_behind` measures about 14 000 a driven macos-15 boot, on every
tree back to this session's baseline. `dead/src/README.md`'s `9ab40542` /
`fb76145e` row records the same counter at **zero**, established when the
publication point moved to the drain's own read of the slot. One of those is
wrong and a bare count cannot say which — nor can it separate the two things
`Behind` is:

- one slot whose page rewound under a timeline that will not follow it, which
  is a slot to explain; and
- a timeline that has run ahead of every word the guest can read, which is the
  ordering defect the counter exists to catch.

`StampPublication::Behind` now carries what the plane holds, and the drain names
the slot, the site, the page's word and the plane's point once per slot. Nothing
reads it: the verdict below is unchanged and still the plane's.

Two model tests already covered the variant and now assert the carried value —
including the wrap case, where the point before the wrap is behind the one after
it and the numbers are the wrong way round, which is exactly the pair a reader
of the new line has to be able to tell from a rewind.
2026-09-03 12:50:41 +03:00
Anees Iqbal 0e0e10e3eb dead: the pipeline that stopped being ready, and the boot on which no draw is lost to a translation any more
Records `f696867d`, `77f5bd88` and `e2d11cb1` against the driven macos-15
desktop that validates them: every `m2v_translation_pending_at_sync_boundary`
and every `draw_prepare_{vertex,fragment}_translate` is absent from the log,
against one to four on each of the four boots before it, with 0 FAIL lines,
`packet_unadmitted = 0` and a table resting at `pending=0 … ready=139
retired=4 total=143` — nothing stranded by the new step.

The row also states the two things the boot cost or did not settle: the pump's
`parked_translations_already_ready` short-circuit no longer fires for a
position holding a withdrawn lease, which roughly doubles
`preflight_memo_absent` for about 1.9 ms/s; and `stamp_publish_behind` is
~14 000 here *and* on the pre-change baseline, which is pre-existing but
contradicts a zero an earlier row records.
2026-09-03 12:47:29 +03:00
Anees Iqbal e2d11cb1fd drain, exec: the pre-scan says which pipelines it could not serve, so the one the guest rewrote stops being ready
`77f5bd88` gave the table the step; this takes it, and the reason it needs the
refs rather than a bool is that the caller has two different things to do with
the two halves of the answer. A lease this rail cannot serve must stop being
ready; a lease it can serve must become ready. `preflight_translations` answered
"something is pending", which cannot tell those apart — so the pipelines that
were already ready stayed ready, and a transaction binding the one the guest had
just rewritten was released against a shader four milliseconds old.

`preflight_translations` now returns the deduplicated refs it could not serve.
Both halves still run whatever the first answers: every cold translation must be
*started*, so they proceed in parallel and the packet is retried once rather
than once per shader — which is why the render arm's two stages are `|` and not
`||`.

Admission and the pump each gained a withdrawal arm. The pump needs its own
because a position can be parked on one pipeline while another it binds is
`Ready` from an earlier packet, and the guest can rewrite that other one while
this position waits.

**The withdrawal is its own door, and an existing test is why.** `PipelineTable`
is walked `Translating → Compiling → Ready` by a rail that retains no pipeline
state and re-walks the build on **every draw**; if `advance` could take a ready
pipeline backwards, every draw would un-ready its own pipeline and every
transaction parked on it would wait again — a hot loop for a step that exists
for four events a desktop. `PipelineTable::withdraw` is the door, the same shape
`refuse` already has, and `advance` now declines the step explicitly.

`pipeline_lease_withdrawn` counts it and names the slot once. A count that
climbs with the frame rate is the cycle above rather than a guest recompiling a
shader, and that is the reading the next boot is for.
2026-09-03 12:41:27 +03:00
Anees Iqbal 77f5bd8847 core: a pipeline the executor stopped holding a translation for can wait again, because the guest rewrites a shader without renaming it
`Ready` was terminal except for `Retired`, so it meant "was translated once".
On a driven macos-15 desktop that is not the same as "the device can execute
this now", and the gap is a lost draw:

    linux_m2v_async queued pipe=5 stage=Fragment air=4332  t=34272
    pipeline_lease_ready site=…_pump slot=5 gen=1          t=34293
    m2v_pipe_content_changed pipe=5 stage=Fragment air=4328 was=… now=…
    linux_m2v_async queued pipe=5 stage=Fragment air=4328  t=54340
    draw_prepare_fragment_translate pipe=5 model_pipeline=ready t=54344

The guest rewrites the shader behind a live pipeline ref **in place**. No delete
arrives, so no generation is minted and the `ResourceId` is unchanged —
`pipeline_retired = 4` against 140 declared, and `pipe_memo_miss = 133` with no
re-miss. The executor's translation is keyed by the shader's *content*, so it
stops holding one and starts another; the table still said `Ready`, so
`waits_for` returned nothing and the ordering plane released the transaction
against a shader that was four milliseconds old.

Leaving it `Ready` and letting the record refuse is not the alternative it looks
like: that is a lost draw with the model still claiming the pipeline was usable,
which is a model that disagrees with the device about its own state.

So `Ready → Translating` becomes a legal step. It is not a reset — `Declared`
stays unreachable, because the pipeline is still declared and always was — and
only the executor may take it, being the layer that discovers it, since this
crate cannot read a shader. `Census::withdrawn` counts it: the step exists for
four events a desktop, and a count that climbs with the frame rate would mean a
cycle between the withdrawal and whatever re-readies rather than the guest
recompiling a shader.

Nothing takes the step yet — the rail that will is the next commit.
2026-09-03 12:37:30 +03:00
Anees Iqbal f696867d93 m2v: the moment one pipeline ref is translated under two identities says so, because that is where the pre-scan's memo stops being true
Two driven macos-15 boots put the remaining lost draws in one shape, and it is
the same shape on both rails of the pre-scan:

    linux_m2v_async queued pipe=5  stage=Fragment air=4332  t=34272
    linux_m2v_async done   pipe=5  stage=Fragment ok        t=34283
    pipeline_lease_ready site=…_pump slot=5                 t=34293
    linux_m2v_async queued pipe=5  stage=Fragment air=4328  t=54340
    draw_prepare_fragment_translate pipe=5 model_pipeline=ready t=54344
    linux_m2v_async done   pipe=5  stage=Fragment ok        t=54349

and the compute one is `pipe=14 stage=Kernel air=11764 → 11760`, refused one
millisecond into the second translation. The guest points a ref at different
AIR. This cache is keyed by AIR content, so it misses and starts a fresh
translation; `pipeline_resolve::translations_ready` is keyed by
`(task_id, pipeline_ref)`, so it still answers "translated" and the pre-scan
skips the pipeline. The ordering plane then releases a packet against a shader
that is microseconds old — two answers to "is this pipeline usable", derived
from two different questions, which is the thing the plan forbids rather than a
race.

`translations_ready` cannot be made honest from a name alone: only re-reading
the guest's AIR distinguishes the two, and skipping that read is the whole 8 %
the memo buys. So the fix needs the *invalidation* hook, and this commit is the
measurement that names it: the queue site is the one place both identities are
in one hand, so it records the last identity each `(ref, stage)` was translated
under and reports, once per ref, where they part company.

It decides nothing — `last_identity` is read by no product path. What it is for
is the population's size: a boot showing none of this is saying something
different from a boot showing it on eight refs, and which of those is true
decides whether the memo can be kept.
2026-09-03 12:29:47 +03:00
Anees Iqbal ab9bfe86b9 draw: a draw refused against a still-translating shader stops sharing a latch with the line that reports the same translation
`DrawPreparationDecline::{Vertex,Fragment}Translate` delegated to
`reason.slug()`, and the reason is `M2vCacheDecline`, which
`runtime::m2v_cache` also emits under its own name. `Emit::decline` claims a
slug on behalf of its concrete type, and a driven macos-15 boot said what that
cost:

    observe_slug reason=observe_slug_collision
      slug=m2v_translation_pending_at_sync_boundary
      holder=reims_vgpu::runtime::m2v_cache::M2vCacheDecline
      claimant=reims_vgpu::backend::vulkan::engine::draw_preparation::DrawPreparationDecline

`fail_once` latches on `(slug, discriminant)`, so the two shared a latch:
whichever side fired first for a discriminant silenced the other for the rest of
the boot. The silenced side was the draw refusal — which is the population a
lost-draw investigation is counting, and which this session's own diagnosis had
to work around by splitting on `stage=` instead.

This is the shape `SecondaryTargetUnbuildable` two arms below already declines to
take, for the same stated reason. The two arms take their own
`draw_prepare_`-prefixed slugs and carry the cache's slug as an `m2v_reason`
field, so one grep still finds the refusal and the cache line for the same
translation.

The AIR-extract arms keep delegating and are not the same case: `runtime::mtlb`
never emits `MtlbDecline` itself, so nothing else holds those slugs.

`the_draw_refusal_and_the_cache_line_do_not_share_a_slug` renders both sides in
one test, so the cross-type claim is checked deterministically rather than
depending on which other test in the suite rendered an `M2vCacheDecline` first.
2026-09-03 12:22:25 +03:00
Anees Iqbal 1fab7d6891 exec, preflight: the compute arm is asked about the dispatches the walk resolved, because the loss it was meant to catch is on its side of the line
`94838490` moved the render pre-scan's input from a second byte-scan to the
walk's lease list. Its driven boot is clean and it did not move
`m2v_translation_pending_at_sync_boundary`, which stood at 2 before and after —
and both of those lines read `compute_linux_m2v … stage=kernel`. They are
compute kernels, so the render arm could not have been the fix.

The compute arm still byte-scanned each stream while admission readied the
walk's class-blind `pipeline_leases` — which holds compute binds — on that
scan's verdict. A kernel the scan did not reach is a lease declared ready on an
answer that never examined it, and the scan had three ways not to reach one: a
selector carrying no threadgroup size, where the flat command offered a zeroed
field the scan then rejected as an out-of-range extent — the same word it uses
for "the guest asked for a grid of nothing"; a dispatch after an encoder
continuation, because the scan reset its bound ref at every framed segment while
a stream is one encoder however many segments carry it; and a framing refusal it
swallowed.

`ExecWork::compute_dispatch_translations` answers all three from records the
walk already resolved, and says the first structurally rather than by rejecting
a zero: `DispatchOp::ThreadsIndirect` has no such field. `preflight_translations`
now takes `(render_pipelines, compute_dispatches)` and reads no stream at all,
so the packet's bytes are read once.

`PreflightPart::Refs` goes with it. It measured the second decode at 8 % of the
largest non-draw cost in this device; the validation boot's every
`preflight_split` line reads `refs_n=0` against 47 a second on the baseline, so
the part is gone rather than smaller, and a column that is always zero reads as
"this part is free" when what happened is that the part no longer exists.

Driven macos-15: desktop reached, `packet_unadmitted` 0, `FAIL` 0,
`preflight_memo_ready` 47 577 → 54 142 on comparable `_absent` — the pre-scan
reaches more work, not less. The compute loss fell 2 → 1, which one boot cannot
separate from the variance the register row records; that row also names the
render-side occurrence this same boot found, which is owed a diagnosis.
2026-09-03 12:19:35 +03:00
Anees Iqbal c0b667b8ed core: the render arm of the lease list is asked about a packet that carries both classes, because that is the only shape that can tell a compute leak from a duplicate 2026-09-03 12:03:08 +03:00
Anees IqbalandClaude Opus 5 94838490a4 exec, drain: the pre-scan is asked about the leases it will be used to ready, because it was answering about a set it found itself
Admission readies the walk's `pipeline_leases` on the rail's whole-submission
verdict "nothing is still translating". The rail reached that verdict from a
*second* scan of the packet's bytes for `SetPipeline` records
(`render_pipeline_refs`), so the set it examined and the set its answer readied
were two answers to "which pipelines does this packet bind". A lease readied on
an answer that never examined it is a transaction released against a shader
that is still being translated — which is the
`m2v_translation_pending_at_sync_boundary` loss measured this session, with the
same pipeline drawn five milliseconds after its own fragment translation was
queued and four before it finished, while `model_pipeline=ready`.

So `preflight_render_translations` takes the list instead of finding one, and
`render_pipeline_refs` is deleted rather than left beside the walk. The two sets
are now the same set by construction.

That moves the question: the leases exist only after the walk, so the preflight
moves out of `arrival_work` and into `admit_and_park` beside the `declare`/
`ready_lease` loop it feeds. `Arrived::translating` is gone with it — the answer
is now computed where it is used and cannot be carried past the thing it is
about.

`ExecWork::render_pipeline_leases` is the render subset, derived from the
records rather than stored beside `pipeline_leases`. That list stays class-blind
because the ordering plane holds a compute pipeline for the same reasons it
holds a render one; a backend asking which *render* shaders it must have
translated is asking a different question, and a compute ref handed to the
render arm would load no MTLB pair and be counted as an unloadable one.

The compute half still walks the streams: a kernel's cache key carries its
threadgroup size, which is a dispatch record's field and not a lease's.

Verified: reims-vgpu all-targets serial, reims-vgpu-core, feature matrix, no new
clippy warnings. **Not yet validated on a live guest** — this changes when the
preflight runs and what it examines.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 12:00:55 +03:00
Anees IqbalandClaude Opus 5 2099769c4f exec: the two ways a pipeline leaves the pre-scan without being examined stop being one silence
`preflight_render_translations` answers one question — is any shader this
submission binds still translating — and the answer readies the packet's
pipeline leases at admission. Three of its arms say "not pending" and only one
of them means it: the memo hit is counted, but a pipeline whose MTLB pair will
not load and one whose AIR will not extract both `continue` silently, on the
reasoning that normal execution reports them precisely.

Normal execution does report them. What it cannot report is that the pre-scan
had already told the ordering plane there was nothing to wait for. A draw has
been measured reaching a shader that was still translating while the model
called its lease `ready` — five milliseconds after that same pipeline's
fragment translation was queued — and a pipeline the scan stopped examining is
one of the two ways that can happen.

`preflight_mtlb_unloadable` and `preflight_air_unextractable` are the two
counters. Beside the existing `preflight_memo_ready`/`_absent` they make the
scan's population close: every pipeline it walks now leaves through exactly one
named door.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 11:48:26 +03:00
Anees IqbalandClaude Opus 5 aedbc037b1 drain, draw: a lease that reached ready says which of the three answers put it there
A driven macos-15 desktop loses a draw to
`m2v_translation_pending_at_sync_boundary` while the ordering plane calls that
pipeline's lease `ready` — measured this session with `model_pipeline=ready` on
the refusal line, five milliseconds after the same pipeline's fragment
translation was queued and four before it finished.

Three sites can put a lease at `Ready`: admission, when the submission's
preflight said nothing was pending; the translation pump, when a later preflight
said the same; and the rail itself, when a draw resolves the pipeline. They are
one counter today, so which of them answered — and therefore which question was
wrong — is not recoverable from a boot.

Each now names itself once per slot on the observation channel, with the
generation, so the answer that arrived first can be read against the
`linux_m2v_async queued`/`done` pair for the same pipeline.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 11:41:05 +03:00