Files
reims-vgpu/scripts/app-sweep-probe/read_window.py
T
Anees IqbalandClaude 9dba0338ed ✨ Six stock applications and a tab-churning Safari, judged on the census that stops rather than the one that complains
Component: `scripts/app-sweep-probe/`, host-side probe harness. No Rust or QEMU
change; nothing in the device moves.

Every probe in this tree drives one motion of this repository's own choosing —
`window-drag-probe` repositions a window, `sustained-animation-probe` runs a rAF
loop, `spotlight-probe` opens one panel — and all three measure throughput. None
answers whether an ordinary user opening ordinary applications gets a freeze or
a panic, which is the question a rail sweep has to answer.

The six targets are not interchangeable stressors. Safari is layer-backed
compositing and tab churn; Maps is the only stock app holding a high-frequency
render loop open with no user input; App Store populates a collection view
asynchronously so its draws arrive in bursts separated by real idle; Contacts
is a vibrancy sidebar; Reminders is list animation and sheet presentation; and
Launchpad blurs the entire desktop, which is the largest single composite these
guests perform.

Three verdicts, and they fail differently:

- FREEZE is a gap in `drain_duty` wider than 8 s. Every census in this device is
  written at the *end* of a drain tranche, so a drain thread that never returns
  emits nothing while `display_vbl` and `host_window_loop` keep ticking from
  other threads — the boot then reads healthy. The gap is measured from each
  line's own `t=`, device milliseconds, never from the host clock.
- GUEST-GONE is the guest not answering ssh. The panic verdict itself stays with
  `vm/boot-x86.sh`, which owns the serial log and exits 126; this probe supplies
  the evidence, not the name.
- STALL is two different applications photographing byte-identical. A latched
  compositor is invisible to every counter this device has, and only the
  screenshots can see it — which is why they are hashed rather than left for a
  human to leaf through.

Driving is host-side over QMP's usb-tablet and usb-kbd, per AGENTS.md: a
guest-side probe does not degrade on macOS 26, it fails to build. Launching is
the one step that still needs ssh, and it is bounded by `timeout` so its failure
reports as a launch failure rather than as a device result.

`present_hz` is reported per app but is explicitly not a ranking instrument
here — AGENTS.md records that a bursty interaction probe measures the gaps
between its bursts, so these rates must not be quoted against a code change.

Verified: `bash -n` on the shell, and the reducer run against a captured driven
boot log from `journal/`, where it returns a 1.0 s worst gap over 76 drain
censuses and 65 cadence lines with 0 alarms — i.e. it reads a healthy boot as
healthy. Not yet verified: no rail has been swept with it, and no FREEZE or
STALL verdict has been observed firing against a known-bad boot.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-12 05:51:05 +03:00

83 lines
2.9 KiB
Python
Executable File

#!/usr/bin/env python3
"""Reduce one slice of the fail log to the six numbers app-sweep-probe judges on.
Prints, space-separated on one line, in this order:
gap_s cadence_lines present_hz_min present_hz_med drain_lines alarms
`gap_s` is the widest interval between consecutive `drain_duty` censuses, in
seconds, taken from each line's own `t=` (device milliseconds since start) and
never from this host's clock — AGENTS.md is explicit that the two are different
clocks. It is the freeze signal: every census here is written at the *end* of a
drain tranche, so a drain thread that never returns emits nothing at all while
`display_vbl` and `host_window_loop` keep ticking from other threads and the
boot reads healthy.
A slice holding fewer than two censuses cannot have a gap measured, so it
reports the slice's whole span instead — which is the honest answer for a window
in which the drain produced one line or none, and is what makes `drain_lines=0`
read as a freeze rather than as a clean zero.
`alarms` counts the two lines that come from *outside* the drain and so survive
a wedged one: `driver_call_outstanding` (a host driver call past its deadline)
and `driver_quarantine` (a call a previous process died inside). Ordinary
fail-channel records are not counted — AGENTS.md warns that a named reason on
the fail channel is not automatically lost work, and several report a repair
that succeeded.
"""
import re
import statistics
import sys
def main(path: str) -> int:
try:
text = open(path, errors="replace").read()
except OSError:
print("0 0 0 0 0 0")
return 0
drain_t: list[int] = []
span: list[int] = []
hz: list[float] = []
cadence = 0
alarms = 0
for line in text.splitlines():
m = re.search(r"\bt=(\d+)\b", line)
if m:
span.append(int(m.group(1)))
if " drain_duty " in f" {line} ":
if m:
drain_t.append(int(m.group(1)))
if " host_window_cadence " in f" {line} ":
cadence += 1
h = re.search(r"\bpresent_hz=([0-9.]+)", line)
if h:
hz.append(float(h.group(1)))
if "driver_call_outstanding" in line or "driver_quarantine" in line:
alarms += 1
if len(drain_t) >= 2:
drain_t.sort()
gap_ms = max(b - a for a, b in zip(drain_t, drain_t[1:]))
elif span:
# One census or none. The widest interval the slice can attest to is the
# slice itself, and reporting 0 here would turn a wedged drain into a
# clean reading.
gap_ms = max(span) - min(span)
else:
gap_ms = 0
print(
f"{gap_ms / 1000:.1f} {cadence} "
f"{min(hz) if hz else 0:.1f} {statistics.median(hz) if hz else 0:.1f} "
f"{len(drain_t)} {alarms}"
)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "/dev/null"))