Files
reims-vgpu/scripts/visual-gate/README.md
T
Anees Iqbal 839b8ae9ca ✨ The gate was blind to the two classes that lose guest work most quietly
`scripts/visual-gate` is this repo's stated sign-off harness — three probes plus
a budget over the silent-loss counters — and it watched six classes. Two that
belong were not among them, and both read zero on every boot in the tree, which
is exactly the state in which a gate is worth adding rather than argued about.

Component: `scripts/visual-gate`. Harness only; no device code touched.

- **`render_unimplemented`** — the class a green run hides best. AGENTS.md
  already says it in so many words: an `Ok` from `render::decode` is not a
  decode, because `Kind::OtherAccepted` is the catch-all for "no arm claimed
  this". The draw completes, the guest is stamped, and the only trace is this
  one line. It is deduped per opcode, so the count is a count of *kinds* lost.
- **`device_info truncated`** — the device-info reply could not carry every
  capability key the guest's own key-table length admits. The guest asks once
  per boot, frees the buffer and answers every later reader from what it
  parsed, so a firing is a capability gone for that boot's life.

Both enter `baseline.tsv` at **0** with their measurement written beside them,
which is the file's own rule: zero is the default and needs no argument, a
non-zero budget is an admission about the device. `render_unimplemented` is zero
across all seventeen archived boots, driven and idle; `device_info truncated` is
zero by construction on the guests measured here — a whole page of pair slots
against a table of a few dozen keys.

The parser is proved to see them rather than assumed to. `self-test.sh` gains
three cases: one per class firing on text quoted from the emitter, and one
asserting an `OFF `-prefixed lookalike is *not* counted — the channel inversion
AGENTS.md warns about when ranking `reason=` slugs. Its class-count guard goes
6 → 8, which is what caught the headers this commit also fixes; that guard
exists so a class can never quietly stop being parsed.

Verified: `self-test.sh` PASS, 17/17 cases. `counter-budget.sh` against the
archived driven boot at this branch's head
(`journal/2026-08-06-driven-boot-at-head.log`) prints all eight classes at 0 and
exits 0. Synthetic firings of both new classes take it to exit 1. A full
`visual-gate.sh --quick` on a live x86/PCI boot of this head passed earlier this
session — 3/3 probes green, counters all zero over 1.27 MB of fail log — but
that run predates these two classes; what covers them is the archived-log check
above, not that run.

Not verified: no live gate run since the classes were added, and neither class
has ever been observed firing on real hardware — that is the point of the zero,
not a gap in it.
2026-08-06 15:10:55 +03:00

127 lines
6.8 KiB
Markdown

# visual-gate
**A performance commit does not land until this passes on a live boot of the
pathway it touches, and the commit body says which pathway and quotes the
verdict line.**
```sh
scripts/visual-gate/visual-gate.sh # full, for phase sign-off
scripts/visual-gate/visual-gate.sh --quick # fewer trials, for iteration
scripts/visual-gate/visual-gate.sh --keep /tmp/vg # keep every probe's frames
scripts/visual-gate/self-test.sh # the parser's own tests, no boot
```
Exits `0` when every probe passed and every silent-loss counter read zero, `1`
on any regression, `2` on a setup failure — a guest that never settled, a probe
that could not run, or a QEMU that died under it.
## Why it exists
A branch of 59 commits was once reset off wholesale because it had introduced
graphical glitches. Every one of the 21 code-changing commits on it had been
verified — against clippy, unit tests, the feature matrix, and device-side
performance counters. The work was performance work, so the instruments it was
checked with were performance instruments, and a rendering regression was
invisible **by construction**. Nothing lied; the right question was never asked.
Three probes existed the whole time that ask exactly that question. None of them
gated anything. This is the entry point that makes them gate.
## What it runs
Each probe is a two-observation instrument: the guest declares what it believes
it drew and where, and the host measures its own capture at exactly those
places. That is what separates *the guest declined to draw it* from *this device
lost it* — the distinction a screenshot cannot make, and the reason staring at
images never resolved it.
| probe | what the guest declares | trials, full | trials, `--quick` |
|---|---|---|---|
| `web-content-probe` | a palette and the screen rects that carry it | 20 captures | 5 |
| `wallpaper-probe` | a 64-bar aperiodic barcode wallpaper the probe itself supplied | 10 trials | 3 |
| `modal-button-probe` | the accessibility hierarchy's buttons and their rects | 10 trials | 3 |
All three run even when an earlier one fails. Which probe fails is the
diagnostic, and a gate that stops at the first one throws that away.
Read each probe's own README before quoting its result. In particular
`modal-button-probe` summons the **log-out** modal, not the Control-Power one a
bug report may name, and `web-content-probe` has twice produced a worthless
result — once from a stressor clipped away by `contain: strict`, once from a
macOS sheet dimming every region to exactly half.
## The counter budget
Probes see what they drive. The other half of a silent loss is the device saying
so in the fail log and nobody reading it, so the gate marks the log by byte
offset before the first probe and applies eight classes over its own window only —
never the accumulated log, which spans builds.
| counter | meaning |
|---|---|
| `deferred_flush_lost` | a guest render this device dropped. Always a real loss |
| `gw_audit_unsound` | the gather witness refuted itself; a stale image is being served |
| `render_flush_over_guest_write` | documented as expected-never; if it fires the writeback ordering repair has broken |
| `mapping_page_drift` | the page list changed under an armed window |
| `THRASH present_action_starvation` | zero across the whole accumulated log to date; a first occurrence is a real change |
| `tdc_overflow` | census target map overflowed and re-seeded — only meaningful when the census probe is on |
Each class is held to the budget `baseline.tsv` records for it, and every class
that fired is named in the verdict line whether or not it was inside budget — so
a `PASS` reading `deferred_flush_lost=2/4` is never mistaken for nothing lost.
Two of these are standing alarms that read zero across the whole accumulated
log; a zero is the working state, so do not delete them for being constant.
**Zero is the default, and six of the eight keep it. Two do not, and the first
full run on unmodified HEAD is what said so.** The plan that specified this gate
asserted all six read zero. `deferred_flush_lost` and `mapping_page_drift` read
1 and then 2 over two consecutive full windows of one x86/PCI boot, five over
the boot as a whole. Every event is the same pair — the guest re-points a
24-pixel-tall strip (1877x24 at 1920 wide: the menu bar) with no packet saying
so, the cached page list disagrees with a fresh walk, and the render is dropped
rather than landed at stale GPAs. Refusing that write is correct; not re-landing
it at the new translation is an open defect, and it predates this gate.
A non-zero budget is an admission about the device, not a setting. It does not
belong in that file without a measurement and a reason beside it, and it is
never raised to make a run pass — only when a boot of the *unmodified* tree
exceeds it, saying in the commit which boot. A class with no row at all is
budgeted zero, so a forgotten row fails strict rather than leaving the class
unwatched.
`counter-budget.sh` does the parsing and `self-test.sh` tests it against
synthetic log text with no guest, no QEMU and no GPU. That split is deliberate:
a parser that matches nothing prints the same eight zeros a clean run does, so
without those cases a green gate would mean nothing and there would be no way to
tell from its output. The cases are mutation-checked — dropping the `^` anchor
on the line families, or matching route fields by prefix instead of exactly,
each fails exactly one case.
## What it refuses to do
**It will not start on an unsettled guest.** sshd answers well before the
desktop composites, and a probe started in that window measures the guest's own
startup work. One such run read 12.2 fps with the device idle at `duty=0.001`.
The gate polls `ssh macos-vm uptime` for a 1-minute load average under
`SETTLE_LOAD` (1.0) for up to `SETTLE_TIMEOUT` (420 s) and exits 2 rather than
guess. It also aborts if QEMU stops matching, so a boot that died early is never
mistaken for a clean run.
## Two things this is not
**Not a frame-rate check.** Frame rate is bimodal here — ~59 and ~118 with
nothing between, both on one unchanged binary within one boot — so a rAF figure
cannot support a claim in either direction. This gate answers *correct or not*.
The device-side counters answer *fast or not*.
**Not proof of absence.** The probes bound the classes they drive. A green gate
means "no regression this instrument can see", and a green `--quick` is not a
phase sign-off. For a change whose failure mode needs a second frame to appear —
a stale tile the next frame declines to rewrite, say — run the full gate twice
on one boot.
If a change cannot be gated because it only manifests under a workload no probe
drives, say so explicitly in the commit body under "Not verified". An honest
admission is what the reset branch's suspect commit already did; the failure was
that nobody treated the admission as blocking.