The 9 October piece ended on a line of copy that's only true because of the order my screen runs its checks in. On 12 October that order went into my file twice, as a comment and as a test.
None of it is on a phone yet. The checks are real code in my file, and so is the test.
Two checks that don't know about each other
Before the needs-you screen draws anything, it checks the row it's been handed, top to bottom, and refuses the first thing it can't back. Two of those checks matter here.
Check 2 ends by asking the chip, the small line that says what Alpha is doing right now. If it doesn't say Stopped, the screen refuses:
word = (payload.get("alpha") or {}).get("word")
if word != "Stopped":
raise RenderRefusal(
"(2) chip says %r, not Stopped - a screen never renders a state "
"the dock isn't in" % (word,))
Check 3 compares two fields that both say how the last run ended. If they disagree, it refuses:
if last_end != token:
raise RenderRefusal(
"(3) last_end %r disagrees with last_run.end_token %r"
% (last_end, token))
Neither check mentions the other. Each one is right on its own. That line leans on both of them together. It's for the row where both fields say Alpha needs you, one saying it stopped and one saying we lost touch. Check 3 refuses that row, and the fallback drawn after it says "ALPHA: Stopped". That's only true because check 2 already ran and wouldn't let the row through with any other chip. Run 3 first and a row with a stale chip, one reading Out of touch, gets refused at 3 instead. The fallback would print Stopped on top of it.
Nobody writes down an order like that. It looks like formatting. Someone tidying the file a year from now could move check 3 up because it's shorter, and every test the file had before 12 October would still pass.
Check 2 trusts the chip's word, so the chip had better not lie. Anjali went and looked. The checks live in a function called check_row, and her read of it, in her words:
"check_row only asks what the chip says, so I opened the function that writes the word, to see whether 'Stopped' could ever be an old reading. It can't: it only says Stopped off a frame no more than two seconds old, and anything staler comes back as Out of touch."
The comment and the test
The comment sits at the top of check 3 and says what I just said, in more words: the chip check runs first, the fallback's chip line depends on it, and here's the test that pins it.
The test builds exactly the row that would slip through a swap. Two fields that disagree, and a stale chip:
env = _env(); env["payload"]["last_end"] = LOST
env["payload"]["alpha"] = {"word": "Out of touch", "fresh": False, "age_s": None}
with pytest.raises(RenderRefusal, match=r"^\(2\)"):
render_c(env)
It wants a refusal that starts with (2). In the right order the row never gets as far as 3.
Green, twice
I ran the file on the night of 12 October on my laptop, from the app's folder and again from the top of the repo, because the two places import things differently and that's bitten us before. Both printed the same last line:
12 passed
Eleven old tests and the new one. Green means check 2 ran before check 3 that night. It doesn't show the new test would notice if they swapped. I'd only ever watched it pass.
Breaking it on purpose
So on the night of 13 October, same laptop, I did the tidy-up myself in a script. It reads my file as text, lifts out check 3 (fifteen lines, the comment included) and puts it back above check 2's chip line. All of that happens in memory. The file on disk is never opened for writing. Then the script runs the same twelve tests twice, once against the file as it sits and once against the swapped copy.
The file as it sits:
............
The swapped copy:
......F.....
SWAPPED: exit 1; passed 11, failed 1 ['test_order_stale_chip_on_both_tokens_row_refused_at_2']
One red, and it's the one I wrote on 12 October. The script read the failure too: the test got its refusal from check 3. On the screen as drawn, that's the row where the fallback would have printed "ALPHA: Stopped" while the chip said Out of touch.
The other eleven tests passed on the swapped copy. Everything written before 12 October would have let the tidy-up through. Last, the script compared my file's bytes to what they were before it started. Same file.
Next
The line this test guards still lives on paper: the fallback box, and the picker that decides which screen a row gets, which I sketched on 13 October. Whoever builds them starts on a file that goes red the moment check 3 moves up.