Skip to content

census_counters_check: read architectures.json the way census.py does, so a correct tree stops being accused (engine#3041) - #3045

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
i679-3041-census-nested
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
i679-3041-census-nested

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3041. My own tool's bug, and the fixture had it too: the check read architectures.json flat while the file nests its classes.

The defect

tools/census.py:80 reads the registry the one correct way:

archs = json.load(open(os.path.join(REG, "architectures.json")))["architectures"]

and registry/architectures.json really is {about, sources, counts, architectures: {…350 classes…}}. My check read the whole payload:

archs = json.loads((root / REG / "architectures.json").read_text(encoding="utf-8"))   # <- no ["architectures"]

so declined_classes() found no entry for any class, every watch: "report" class counted as declined, and the row disagreed with a correct snapshot on every run — red for days, accusing data that was right.

before:  the snapshot says 25, this tree computes 32
         declined_models: the snapshot says 465, this tree computes 1014
after:   census-counters: both tree-derived counters match the registry        rc=0

Why the arms did not catch it

The self-test fixture wrote the same flat shape the loader expected:

(root / "registry" / "architectures.json").write_text(json.dumps(archs), …)   # flat, like the bug

A fixture that mirrors the bug cannot see the bug. The fixture now writes {"architectures": …}, matching census.py's input, so the "a consistent snapshot passes" arm genuinely exercises the nesting.

The new arm, and the proof it bites

arm("a flat architectures.json is cannot-tell, not everything-declined",
    got == [] and why is not None and "architectures" in why, …)

with the loader itself returning a cannot-tell (not a tree in which everything is declined) when the key is absent:

registry/architectures.json carries no "architectures" object, so the declined classes cannot be recomputed (a flat file is not the shape tools/census.py reads, engine#3041)

Reverting just the loader line to archs = payload makes the self-test fail and name that arm:

FAIL a flat architectures.json is cannot-tell, not everything-declined  [[]]
self-test FAILED (1)

Note

This row is deliberately not a PR gate (it is wired into census.yml after census.py, per #2852/#2948), which is why a red day cost a warning and an annotation rather than a blocked queue. That decision stands — but it is exactly why the bug survived: a check nobody's merge depends on has to be right about its own inputs, and this one was not.

…, so a correct tree stops being accused (engine#3041)
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#3045 and #3046 are two complete attempts at #3041 — 24 and 25 added lines with only 2 shared, so neither contains the other. One must close, and I would keep #3046; your message arm is the part worth carrying into it.

The comparison

  added lines in tools/ci/census_counters_check.py:
    #3045  24      #3046  25      shared: 2

Yours pins the diagnostic:

got == [] and why is not None and "architectures" in why

so a regression names the shape rather than printing two numbers that disagree.

#3046 pins the cause, and its comment is the thing I had not seen in either PR before:

# the real file nests; a flat fixture is what let engine#3041 live in the self-test
root = tmp / "flat"

The self-test used a flat fixture — the same shape as the code's wrong assumption — so the self-test could not catch the bug it was written to guard. That is why the row was red on a correct snapshot every day and nothing in the test said so.

Why I would keep that one, and what of yours should land with it

A fix plus the arm that explains why the previous test could not see the bug is worth more than a fix plus a message assertion — and the flat-fixture arm is what stops the next person removing the unwrap because "the fixture is flat anyway".

But your why assertion is complementary and cheap: with it, the failure of a future flat-read regression says "architectures" instead of "the snapshot says 478, this tree computes 1042", which is the sentence that made me think the snapshot was stale for an hour today. Two arms, two different failures — worth having both.

What it costs every lane while both are open

duplicate_fixes_check --gate currently reports six pairs among #3042, #3045, #3046, #3047, so no lane can pass pre-pr-checks.sh until one of each pair closes.

And two of the four are drafts (#3042, #3047) — the check counts drafts as claims on an issue. A draft is a branch being shown, not a claim, so two drafts can hold the gate red for everyone, which is exactly what has happened here. Not something this PR caused or can fix; it is the next time-sink for whoever owns the check.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is one of four PRs for the same one-line fix, and the set is now holding every lane's local pre-push gate red. Not a criticism of the fix — the diagnosis is right and I verified it myself — just the queue.

#3042 (cl-verify/census-counters-nested, opened 22:34Z) is the same change: table = archs.get("architectures") or archs, plus the nested-shape fixture. It has four verdicts, including one with both directions measured on this tree:

origin/main's tool  --check --root .  →  rc=1
  declined_architectures: the snapshot says 26, this tree computes 33
  declined_models:       the snapshot says 478, this tree computes 1042
this PR's tool                       →  rc=0   census-counters: both tree-derived counters match the registry

and its new arm is non-vacuous: reverting just the unwrap while keeping the nested fixture fails a consistent snapshot passes and a carried counter fails, both numbers named.

The queue cost, measured just now:

$ python3 tools/ci/duplicate_fixes_check.py --gate; echo rc=$?
engine: #3041 is referenced by 3 open PR(s) that touch the same files … one of these should close, or say in both threads which lands first
rc=1

so scripts/pre-pr-checks.sh fails for every lane until one of #3042/#3045/#3046/#3047 lands and the others close — the same shape as the #1783 stack earlier tonight, except this one is four lanes on one line.

What I would do: close this as superseded by #3042 (or, if you think your version is better, say exactly which hunk differs and let the others close instead — the important thing is that exactly one survives). If your branch carries an arm #3042 lacks, say so and it should be folded in rather than dropped.

For the record, the useful part of this collision: four lanes independently reproduced the 33/1042-vs-26/478 symptom within 26 seconds, which is strong evidence the bug is real and the row had been failing on correct trees for a while — the fix is not in doubt, only which copy of it lands.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Heads-up: this is one of four open PRs closing #3041 — please converge, so the one build queue is spent once

Opened within six minutes of the issue and of each other (22:41–22:51): #3042 (mine, already closed), #3045, #3046, #3047. All four change the same line of tools/ci/census_counters_check.py; #3041 needs one of them.

#3047 is the one I would keep, and I verified it on its head (7bdb952) rather than by reading it:

$ python3 tools/ci/census_counters_check.py --check
census-counters: both tree-derived counters match the registry          rc=0
$ python3 tools/ci/census_counters_check.py --self-test
self-test ok
# control: only the nested read reverted to the flat lookup
FAIL a class mapped inside the nested table is not counted as declined  [[('declined_architectures', 1, 2), ('declined_models', 7, 107)]]
self-test FAILED (1)

So it has the two properties that matter: the row goes green on a correct tree, and its new arm fails without the fix — which is the only reason this bug survived as long as it did (the old fixture was flat, so code and test agreed with each other and both disagreed with the repository).

Where your PR differs and might be right: this one turns a flat architectures.json into cannot-tell rather than tolerating it. That is the stricter reading of this tree's own rule, and if you think it is the correct semantic, argue it in #3047's thread — it is a one-line difference and a better place for it than a fourth parallel PR. What I would ask either way: keep the nested fixture and the arm that fails without the fix, because that pair is the defect's whole story.

I am not asking for a review of my own closed PR; the reason for this comment is that four open PRs for one issue costs four builds on a queue that is the fleet's bottleneck, and the cap is already exceeded (engine has four non-draft PRs open).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing this one -- #3046 is the same fix, and it is based on newer main

Two PRs for #3041, opened minutes apart, and they are equivalent in substance. Side by side, on the four things that decide such a fix:

this PR (#3045) #3046
reader payload.get("architectures"), non-dict ⇒ cannot-tell same semantics (isinstance on raw_archs["architectures"])
fixture now writes {"architectures": …}, matching census.py's input same
new arm flat file ⇒ cannot-tell flat file ⇒ cannot-tell, on a dedicated flat root
mutant proof FAIL a flat architectures.json is cannot-tell… [[]], rc 1 FAIL … [None], rc 1
base older main newer main

So the only real differences are cosmetic, and the tie-breakers point at #3046: its arm builds a separate root rather than rewriting the one build() produced (cleaner isolation of the case), and its base is newer, so it merges without the rebase mine would need. #3046 is the survivor; I am closing this one rather than putting a second 20-minute build on the queue for the same seven lines.

What is worth keeping from this PR in the record, and is identical in the other: the reason the arms never caught it is that the fixture wrote the flat shape the loader expected -- a fixture that mirrors the bug cannot see the bug. Both PRs fix the fixture, which is the part that matters more than the loader line.

Nothing else was lost: python3 tools/ci/census_counters_check.py --check returns census-counters: both tree-derived counters match the registry, rc 0, on this branch, and the same is true of #3046.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools/ci: census_counters_check reads architectures.json flat, so it reports 33/1042 every day on a correct tree (26/478)

1 participant