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.
Three ways this pipeline produced a verdict that was not about the TUI.
The frame judge required every right border on a screen to land in the same
column. That was written when the widest window anyone captured was 100 columns
and the interface drew one card. At 140 columns the menu column and the panel
are two frames side by side — the menu ends at column 31, the panel at 140 — and
the rows where the panel has already finished genuinely do end at 31. A tidy
140-column screen was therefore garbled on every single capture, which is a
mistake the judge makes rather than the console, and mistakes the judge makes
should not have to be re-litigated on real hardware. The rule is now the one that
survives both layouts: the border columns of the widest rows are the picture, and
a row with a border column that appears nowhere in that picture means two
pictures of different sizes are stacked on one screen. `side_by_side` and the
narrow-card-under-wide-card case are both in `--selftest`, so whoever tightens
that rule again finds out there, in a millisecond, rather than on the box.
`win-tui-run.ps1` always ran `chcp 65001`, because UTF-8 comes back through the
capture with no decoding guess involved. It also means the probe always measured
a UTF-8 console, while the window being complained about sits on cp936 — and
which code page a console is on is exactly what decides what an unasked-for
character costs. `$SQUID_TUI_CP` picks the code page now, the runner reports it
as `MARK_CODEPAGE`, and the judge prints it on the first line of every report,
because a frame is only evidence for the console it was taken from. Both routes
are green on the box with the price list as it now stands: 140x35 on 65001, 101
settled frames, none of them overflowing, box-drawing intact; 100x32 on 936, 54
frames, same. The comments that claimed the ConPTY measures one cell because
UTF-8 is forgiving have been corrected too — it measures one cell on 936 as
well, which is a fact about a console with no font, not about a code page.
And when the runner itself fails to parse, the stream still contains a console:
a PowerShell error block, and then nothing. The judge said "no settled frame with
a border was ever drawn", which is true and useless, and it read like a rendering
regression badly enough that drawing code got changed because of it. A
`CategoryInfo` in the stream is now reported as what it is — the capture script
never started the interface — and it is a selftest case, so the excuse is on
record as belonging to the harness.
`tui-frame-check.py` is the part of `win-tui-capture.sh` that decides whether a
run passed, taken out of the shell script so that fixing the judgement does not
require the real machine to run again — `TUI_REUSE=1` re-reads a saved byte
stream, which is how both bugs in this branch were confirmed fixed against
captures taken before the fix existed. `--selftest` feeds it six screens it made
up — two good ones and four broken ones, including a screen where every Chinese
character makes `len()` measure the frame too narrow — and fails if the judge
goes quiet on a bug or shouts at a good screen.
The four rules it encodes were each paid for with a false verdict:
* the right border is only trusted on rows whose *first* character is a border
character, because the box-drawing bar also appears in prose and in ASCII mode
as `|`, and reading the last one on a row found the wrong column;
* columns are counted by accumulated display width, not by `len()`, because a
terminal emulator keeps one character for a glyph that occupies two cells;
* only a screen that was painted at least eight rows and seen twice is judged,
so a half-drawn frame cannot be mistaken for a torn one;
* a row that ends in a border but starts with prose is a row sitting *on* a
border — the shape the toast produced — which is how the judge caught a bug
nobody had thought to look for.
`win-tui-run.ps1` was missing from the repository while `win-tui-capture.sh`
depended on it, so the proof the last commit described was not in fact
repeatable. It exists here, and it is the reason the captures are trustworthy:
`mode con cols=100 lines=30` fails silently on the ConPTY that Windows OpenSSH
allocates, so every earlier "capture at 100 columns" was a 120-column frame
reflowed by the emulator. It sets the size through `[Console]::WindowWidth` and
reports the size it ended up with, and the emulator replays that rather than the
one we asked for.