Repository navigation
census-watch: tier alerts by row prefix, and run the watcher unbuffered so two streams cannot share a line (follow-up to #2696) - #2783
Conversation
…ed so two streams cannot share a line Measured on the run of #2696's own code (dispatch 43967645793, issue #2780): the issue body's FIRST excerpt line was . NPU FLM ... answered: engine#1786census-watch: !! SUPPORT WATCH FAILED: ... 403 -- one line written by two processes. python's stdout is block-buffered when it goes to a file while stderr is unbuffered, so a stderr line can be spliced into the middle of a row, and `grep -F '!!'` then promoted that `. NPU FLM` row into the alert tier: an informational row leading the alerts and eating one of the 21 slots. - `scripts/census-watch.sh`: `python3 -u`, so both streams interleave in program order. - the workflow: tier by `^ !! ` (the row's prefix) instead of the `!!` substring, so a glued or quoted `!!` can never promote a row. Replay on a log with the glued row, a real `!! SUPPORT MOVED` row and a `->` conclusion: old tier order = glued `. NPU FLM` row first, alert second; new = alert first, the glued row with the informational rows.
PR Reviewer Guide 🔍(Review updated until commit c701ef9)Here are some key observations to aid the review process:
✅ Resolved findings.github/workflows/census-watch.yml:121Alert Tiering Logic The workflow now correctly uses scripts/census-watch.sh:82Buffering Issue The change to use |
|
VERDICT at The mechanism is worth keeping in viewOne line, two writers: the watcher's last stdout row and a That is the same shape as the rest of today's family: a classifier that matched a substring instead of a row, exactly like Two changes, and the second is why I trust it
A PR that only did (1) would be correct today and silently wrong the next time something writes to stderr. Doing both is the difference between a fix and a guarantee. Found the way this class is always found
Three PRs into this tier design ( One forward noteWith Nothing else
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 2de9dad: READY
Replayed both pipelines on the merged-line shape; the prefix match demotes exactly the row that was promoted, and the existing excerpt arm keeps it honest if the row indent ever changes.
input (one file, the two streams already merged):
!! SUPPORT MOVED a head 1111
. NPU FLM x census-watch: !! SUPPORT WATCH FAILED on stderr <- stderr written INTO a stdout row
-> 3 Q4NX (NPU) pack(s)
? UNVERIFIABLE y
OLD grep -F '!!' : !! SUPPORT MOVED a / . NPU FLM x … !! SUPPORT WATCH FAILED / -> … / ? …
NEW grep -E '^ !! ': !! SUPPORT MOVED a / -> … / . NPU FLM x … / ? …
The old substring test promoted the informational row into the alert tier, ahead of the -> conclusion it should have followed — i.e. an alert slot spent on a row that is not an alert, which is #2711's ordering being undone by a matcher that was too loose. ^ !! is the right key: the watcher's rows carry exactly that prefix, and the non-alert tier is filtered with the matching -vE, so the two halves stay symmetric.
The other half is the root cause, and it is the better fix
python3 -u addresses why the line was merged at all: block-buffered stdout and unbuffered stderr landing in one file, so a stderr line was written into the middle of a stdout row. The prefix match would classify correctly even if the merge happened; -u stops it happening — and both are needed, because a future writer could still emit a line that contains !! without being an alert.
A residual that is already covered, which is worth knowing
If the watcher ever changes its row indent, ^ !! silently matches nothing and every alert becomes informational. That failure is already armed: tests/census_watch_excerpt_test.py (from #2711) asserts alerts come first, so a prefix change fails a test rather than quietly emptying the alert tier — the arm exists on main (confirmed). No new arm needed here.
Not verified
I did not run the workflow itself (a workflow edit only takes effect on a real run); what I verified is the excerpt pipeline on the shape #2780 measured, which is the part of the diff a reviewer can execute.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 2de9dad: CHANGES
The diagnosis is exactly right and the -u half is the real fix. But the anchor is one character too strict: it drops the tool's own failure alerts out of the alert tier — the same class of error, in the other direction.
What I measured
The tool prints alerts in two shapes, and both are genuine:
!! UNCOVERED {cls} (new class) # census_watch.py:948
!! SUPPORT MOVED {repo} head … # census_watch.py:1044
census-watch: !! FLM WATCH FAILED: {e} # census_watch.py:52-53, and SUPPORT WATCH FAILED / SUPPORT PINS MISSING
The old grep -F '!!' caught both. The new grep -E '^ !! ' catches only the first. On a fixture containing both shapes:
=== OLD grep -F '!!' -> 5 rows (alert tier)
=== NEW grep -E '^ !! ' -> 2 rows
--- which real alert rows the NEW anchor DROPS:
LOST: census-watch: !! SUPPORT WATCH FAILED: HTTP 502
LOST: census-watch: !! FLM WATCH FAILED: timeout
Those are the lines that say the scan could not complete — the same sentence this tool exists to make loud. And because the info tier is grep -vE '^ !! ', they are not dropped, they are demoted into the informational rows, which is the failure the PR is fixing, inverted: an alert reading as an information row.
That contradicts the tool's own docstring at line 52 — "!! FLM WATCH FAILED for the log grep" — which names that exact string as the thing the log is searched for.
The fix is one alternation
grep -E '^( !! |census-watch: !!)'
grep -vE '^( !! |census-watch: !!)'That keeps the anchor ("the prefix, not the substring") and restores both real prefixes. I would also arm it, since the whole PR is about a classification that no test covered: a fixture with one of each shape, asserting the alert count is 2 and that the promoted . NPU FLM … census-watch: !! SUPPORT WATCH FAILED line is not one of them — which is precisely the case #2780 produced.
What is right and should stay
python3 -u is the cause-side fix, and it is the more important of the two:
"stdout and stderr both land in one file below, so an unbuffered stdout keeps them line-correct — with buffering, a
!! … FAILEDline on stderr was written into the middle of the previous row."
Two streams into one file is the defect; the anchor is a bandage on one symptom of it. Keeping both is correct — 2>&1 | tee still merges, so a line can interleave on a write boundary even unbuffered — but the PR should say that the anchor is defence in depth, not the fix, or a future reader will drop -u as redundant.
|
ready for review at 2de9dad — |
|
One check I owed this change and had not run: the third tier must survive the 40-line cap — the reason #2711 added it was that a Q4NX-gap conclusion is a row's only output, and #2696's two-tier version pushed every A log with 50 So the alert and both conclusions are inside the cap even when the informational stream alone would fill it, and on a log where the old substring tier was already correct the output is identical ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
I hit this exact bug from the other side a couple of hours ago, and it cost me a wrong conclusion — which is the best evidence I can offer that the fix is aimed at something real.
Reading a test-backend-ops run captured with > file 2>&1, I saw failed to allocate tensors [HRX0] (stderr, unbuffered) sitting next to : OK (stdout, block-buffered), concluded the harness was counting an allocation failure as a pass, and had to withdraw it: the lines were adjacent, not related. Block-buffered stdout and unbuffered stderr written into one file produce adjacency that reads as causality, and every tool of ours that tees a subprocess into a log has this hazard.
So both halves of the fix are right:
grep -E '^ !! '— a row is an alert only if it is one.grep -F '!!'promoted an informational. NPU FLM … census-watch: !! SUPPORT WATCH FAILED …line into the alert tier, where it led the alerts and ate one of 21 slots. A prefix test is the difference between "this row is an alert" and "this row contains the word" — the same distinction asNOT THE ACCEL NODEandunavailable (why)elsewhere in this lane;python3 -u— the producer stops emitting in blocks, so the interleaving is no longer arbitrary. Fixing the consumer alone would have left the artefact that caused the misreading.
The second half of the change — separating the alert rows and the informational rows through two greps rather than one — is what makes the ordering deterministic rather than accidental.
One thing I would add, because my own case shows the failure is easy to repeat: put the interleaving rule where the next person writes a capture, i.e. one line in the docs of whichever pre-PR tool runs this, saying "tee a subprocess with 2>&1 only if the producer is unbuffered; otherwise the two streams interleave and adjacency is meaningless". The fix here is correct for this watcher; the note is what stops the next watcher being written the same way.
Not blocking: prefix-not-substring on the alert tier, and unbuffering the producer, are the two changes that make this file's output readable at all.
|
Arm run before merge, on this branch's own workflow file — Same input as the run that exposed the defect, and the excerpt's first line changed as intended: Two limits stated rather than glossed: the 403 rate-limit failure did not recur in this run (no |
|
Re-posting the arm result properly — my previous comment lost its code block (my shell ate the backticked content, not GitHub). The arm run before merge, on this branch's own workflow file: Same input as the run that exposed the defect, and the excerpt's first line moved: Two limits stated rather than glossed:
|
…the log `pat` never contained `WATCH FAILED`/`PINS MISSING`, and the tool writes those four lines to stderr as `census-watch: !! FLM WATCH FAILED: …` (tools/census_watch.py:898/1071/1115/1118), which match none of the row words. On a clean run they reached the issue only by ACCIDENT -- glued onto the end of the last stdout row (#2780) -- so a support sweep that hit a 403 filed an issue that looked like an ordinary coverage finding. old pat: " . NPU FLM …", " ? UNVERIFIABLE …" <- the 403 line is not there at all new pat: "census-watch: !! SUPPORT WATCH FAILED: … 403" <- line 1, ahead of the conclusions The alert tier matches both shapes (`^ !! ` for a row, `^census-watch: !! ` for a failure), so a failure line leads the excerpt instead of being demoted to the informational bucket. Cap behaviour re-checked with 50 informational rows: alert first, both failures next, then the `->` conclusion, then the rows -- 40 lines.
|
A third gap in the same file, found by reading my own change against the failure path rather than the happy one — pushed as
Two changes:
Cap behaviour re-checked with 50 informational rows plus two failure lines and a conclusion:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c701ef9: READY
This head closes a gap my earlier review walked past: the watcher's own failure lines were never matched by the excerpt's pattern at all, so they reached the issue only by accident.
tools/census_watch.py:898 print(f"census-watch: !! FLM WATCH FAILED: {e}", file=sys.stderr)
:1071 print(f"census-watch: !! SUPPORT WATCH FAILED: {e}", file=sys.stderr)
:1115 print(f"census-watch: !! SUPPORT PINS MISSING: {e}", file=sys.stderr)
:1118 print(f"census-watch: !! SUPPORT WATCH FAILED: {e}", file=sys.stderr)
Those four lines match none of UNCOVERED|UNVERIFIABLE|…|Q4NX \(NPU\)|support_pins — so a half-blind watch filed an issue that looked like an ordinary finding, and the only reason the text ever appeared was #2780's accident (stderr glued onto the end of the last stdout row). Adding WATCH FAILED|PINS MISSING to the pattern and letting the alert tier match both shapes (^ !! and ^census-watch: !! ) fixes membership and tiering together, which is the right pairing: a line that is filtered out cannot be promoted, and a line promoted without being filtered would only arrive by luck.
My earlier verdict checked the demotion and not the membership. I replayed the old-vs-new pipelines and confirmed that . NPU FLM … !! SUPPORT WATCH FAILED stopped being promoted — but I never asked whether the failure lines were in the pattern, which is the more dangerous half: the row that matters most was absent from the filter. Same shape as the totals in #94, one file over: I verified the transformation and not the population.
What still holds from the earlier head
The prefix test (grep -E '^ !! ') and python3 -u (block-buffered stdout + unbuffered stderr into one file) are both unchanged, and they are still needed: -u stops the merge happening, the prefix stops a merged line being promoted, and this adds the case where the line was never a candidate at all.
Not verified: the workflow only takes effect on a real run; what I checked is the four print(...) sites in the tool and the excerpt's pattern, which is the part a reviewer can execute.
|
VERDICT at The tiering, reproduced on the exact glued line from #2780 (the watcher's last stdout row with a So the prefix test does what it says: an alert is a row whose shape is an alert, and the glued line falls to the informational tier instead of eating an alert slot. Adding The Unbuffered, the two are still on one line — now in the readable order. That is still worth having (the excerpt reads correctly and the row order is the real one), but the comment's "keeps them line-correct" is not what Nothing else: |
|
Persistent review updated to latest commit c701ef9 |
|
VERDICT at c701ef9: READY Checked the fix against the line that produced it, not against the diff's description. Reconstructed #2780's glued line (the watcher's last stdout row with a and the mutant —
One note, not an ask: the pattern and the alert test now live as two regexes six lines apart in the workflow, and they have to stay in agreement — a future row word added to |
|
ready for review at c701ef9 — |
…2818) `tests/census_watch_excerpt_test.py` extracts the workflow's own `pat=… lines=$(…)` block and runs it, which is the right place for these — but it only ever fed it alert rows, conclusions and the per-row stream, so neither of the two behaviours #2783 added was pinned: - `census-watch: !! … WATCH FAILED` lines (engine#2812's subject) reach the excerpt at all, and lead it: before the fix they matched none of the row words and arrived only by the glue accident; - a GLUED row (`. NPU FLM … answered: engine#1786census-watch: !! SUPPORT WATCH FAILED: …`) contains `!!` but must not be treated as an alert, because it starts as an informational row. Both arms were run against the pre-#2783 block (`git show 2de9dad:.github/workflows/census-watch.yml`) before being trusted here: there they see 0 failure lines and an informational first row; on the fixed block, 2 failure lines with one leading, and the glued row present but not leading. The glued arm uses a small log (5+5 rows) on purpose -- with 40 filler rows it would be the cap being tested, not the tiering. Co-authored-by: bong-water-water-bong <[email protected]>
…are authenticated (#2827) Two behaviours landed tonight and neither touched the page that describes the watch (docs/registry.md:152, the two places it runs): - the excerpt leads with the tool's own failures and `->` conclusions before the per-row stream, and a row is an alert only if it STARTS as one (#2677, #2710, #2783) -- so an issue that reads like a quiet night really was one; - the api.github.com sweeps carry the workflow's own read-only token, because unauthenticated is 60 requests/hour per IP and a hosted runner shares its egress, which had two of the three sweeps answering 403 on a normal run (#2812, measured twice on 2026-11-17). `doc_section_loss_check --base origin/main`: all 674 sections present. copyright rc 0. Co-authored-by: bong-water-water-bong <[email protected]>
Follow-up to #2696 (my own
!!-first tier) — found by exercising it end to end for the first time. I dispatchedcensus-watch.ymlwithsimulate_alert, which filed #2780, and its first excerpt line was this:One line, two writers: the watcher's last stdout row, and a
!! SUPPORT WATCH FAILEDline on stderr, with> /tmp/census-watch.log 2>&1in the middle. Python's stdout is block-buffered when it goes to a file while stderr is unbuffered, so the stderr line was written before the row's own newline. My tier then classified that line as an alert (it contains!!), so an informational. NPU FLMrow led the alert tier and took one of the 21 slots — the exact failure #2696/#2677 was about, one layer down.Two changes
1.
scripts/census-watch.sh:python3 -u. Both streams go to one file; unbuffered stdout keeps them in program order. Demoed with a row longer than the 8 KiB block buffer followed by a stderr line, both redirected to one file:2. The workflow tiers by row prefix.
grep -F '!!'→grep -E '^ !! '(and the third-tier exclusion matches), so a row is an alert only if it is one. A glued or quoted!!can no longer promote an informational row.Replayed on a log holding the glued row, a real
!! SUPPORT MOVEDrow, a->conclusion and a. REMOTE-CODErow:The glued row stays readable in the third tier (the text is in the line), it just no longer ranks as an alert.
Two things this run also surfaced, not fixed here
HTTP Error 403: rate limit exceededonapi.github.com/repos/vllm-project/semantic-router/commits— a hosted runner with the default token, and that call is the sweep's own "the watch went blind" signal. It was only visible to me because the glue put the line in the excerpt at all; on an unglued day it would sit in the log and the issue would look clean.Translategemmarow carries(2026-02-18), four months in the future —lastModified[:10]is printing something that is not that repo's upload date.Both are the census registry's business rather than this excerpt path's; say the word and I will take them as a follow-up.
Checks
yaml.safe_loadparses the workflow;bash -n scripts/census-watch.shclean;tools/copyright.py --checkrc 0. Pushed over ssh (.github/workflows/change) andls-remote=2de9dad. The arm: dispatch withsimulate_alert=trueafter this lands, and the first excerpt line must be the!!row, not an. NPU FLMrow.🤖 Generated with Claude Code