nex_squid/scripts
mula.liu 5515bab2d9 A half-drawn frame can be seen twice, so being seen twice is not evidence
The Windows box came back with a ghost: the process card of the system panel
standing on top of the history panel, in a frame our own checker had certified as
a settled interface. No such layout exists in the code — the two panels are two
rectangles of one `Layout`, and one of them is cleared before the other is drawn —
so the honest reading was that `squid-tui` was painting something nobody had ever
seen on a screen. It took a round of measurement over the archived captures to
find out that the thing lying about the interface was not the interface. It was
the sentence in `tui-frame-check.py` that decides which frames are allowed to be
judged at all, and it had been lying quietly for every capture since the checker
was written.

The sentence was: a picture counts as settled once the same screen has been
sampled a second time. It reads well — crossterm patches a diff cell by cell, so
an unfinished paint keeps changing and cannot possibly be seen twice; the moment
it stops changing, the paint must be over. What it forgets is that the sampler
walks the stream every 64 bytes while one row of this interface costs about 190
bytes of it, so three samples land inside a single row; and that a paint which
has stopped is a paint whose next bytes belong to the next paint, not a verdict.
A frame cut in half is therefore guaranteed to be sampled two or three times in a
row — the same half picture, again, with nothing drawn in between. Being seen
twice was never evidence that the paint had finished. It was arithmetic, and it
cost a round spent chasing a rendering bug that cannot be written down.

Grouping the samples by how long each screen survives says it plainly. Switching
panels is one continuous write, offset 34688 to 37376, 2.7 KB without a pause;
inside that burst the screen passes through 33 states that carry both the process
card and the history card, and every one of them survives between 64 and 192
bytes of writes. The frames a human being stood in front of survive 1024 to 3840
bytes, because an idle interface repaints the same words every tick and nothing on
screen moves — which is exactly what "the user saw that" means. Lifetime is the
measurement, and it is the only one on offer: a captured stream carries no clock,
so "for a moment" has to be spelled out in bytes.

`analyze()` now cuts its samples into runs of consecutive identical screens, where
a run's length is how many bytes of stream passed while that screen sat there
unchanged, and only screens that survived `SETTLE`, 512 bytes, are judged. 512 is
not a magic number: it is comfortably above the 192 bytes that the longest-lived
half frame in that capture managed, and comfortably below the 1024 that the
shortest real one did, on the same stream, in the same second. The report says all
of it out loud — pictures painted, pictures that rested, pictures measured —
because the ratio between those numbers is the one piece of information that tells
the next reader whether the capture was worth anything at all. A stream where
nothing rests is now reported as unanswerable, with the three reasons a stream can
be unanswerable named next to it (a screen that animates forever, a capture cut
short, a screen with no borders at all) rather than being read as a clean pass.

Both new selftest cases were also run against the previous criterion, so that this
commit can be seen to bite rather than merely to look tidy. `半张画不许下判词`
paints a clean 140-column card, lets it rest, then begins a second paint mixing a
100-column card with a 70-column one and stops there, followed by 200 bytes of SGR
and cursor movement that change not one glyph. It is the same content as
`窄框和宽框叠着` above it — which is a fault, and still reported as one, because
that one rests — and under the old criterion the invisible padding is enough to
admit it and convict the capture of two frames stacked on each other. It lived 192
bytes, and under the new criterion it is not allowed to speak. `整条流没有一幅画
站得住` points the same machinery the other way: two clean pictures, neither of
them ever resting. The old criterion certified that stream as free of problems,
which is the more dangerous direction to be wrong in, since it files a measurement
that proved nothing as a pass; the new one refuses to answer. Under the old code
both cases are judged wrongly, under the new one all twelve are right.

On the archived real captures the filter is not cosmetic. The system-panel capture
went from 82 "settled" interfaces measured to 8, out of 327 screens painted; the
long kill capture from 291 to 36, out of 1198; the 140-column clean capture from
101 to 8, out of 376. All of them still come back with zero failures, which is the
point: not one verdict got worse, and every screen that no user ever saw is gone
from the docket. Sweeping every capture left in /tmp turned up one more fact worth
writing down — of the screens that the geometry rule has ever convicted, not one
survived more than 320 bytes. Every conviction this tool has ever handed down came
from a frame caught mid-sentence, which is why the overlap class of bug now has its
regression case in the selftest, where the picture is written twice on purpose and
therefore rests.

What the change gives up, named rather than glossed: a panel that animates for as
long as it is open — a scan progress line is the obvious one — never rests, so a
capture of it is now "cannot judge" instead of a verdict, and the handful of 10 KB
start-and-quit captures in /tmp moved to that verdict. That is a real narrowing.
The way through it is a marker inside the stream, since the interface knows when a
draw ended and the checker cannot infer it from bytes alone, and that belongs to a
round allowed to touch `squid-tui` and `win-tui-capture.sh`; this one only stops the
checker from inventing screens. No Rust changed: 190 tests, `cargo fmt --check`
clean.
2026-10-16 12:02:21 +08:00
..
ci-windows.ps1 Record what the Windows box proved, and keep the proof repeatable 2026-10-15 18:55:01 +08:00
install.sh squid 0.1.0: macOS 磁盘清理(CLI + TUI) 2026-10-13 17:00:50 +08:00
release.sh 修改了README.md 2026-10-15 10:05:34 +08:00
tui-frame-check.py A half-drawn frame can be seen twice, so being seen twice is not evidence 2026-10-16 12:02:21 +08:00
tui_smoke.py squid 0.1.0: macOS 磁盘清理(CLI + TUI) 2026-10-13 17:00:50 +08:00
win-check.ps1 Record what the Windows box proved, and keep the proof repeatable 2026-10-15 18:55:01 +08:00
win-hwcheck.ps1 Record what the Windows box proved, and keep the proof repeatable 2026-10-15 18:55:01 +08:00
win-sync.sh Ask NTFS for stored bytes, not for allocated clusters 2026-10-15 17:25:17 +08:00
win-tui-capture.sh The command line pays for its chrome at the same counter 2026-10-16 10:32:05 +08:00
win-tui-clean.ps1 The instruments that measured the two lies, on the box itself 2026-10-15 21:21:19 +08:00
win-tui-grow.ps1 The instruments that measured the two lies, on the box itself 2026-10-15 21:21:19 +08:00
win-tui-resize.py The instruments that measured the two lies, on the box itself 2026-10-15 21:21:19 +08:00
win-tui-run.ps1 Say which console a frame was judged on, and stop blaming the interface for the shell 2026-10-15 22:28:49 +08:00
win-tui-widths.ps1 The instruments that measured the two lies, on the box itself 2026-10-15 21:21:19 +08:00