Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

studiobench: two ui parity gates that could only ever say yes (#9608)

Daniel Hanb3d86b2d0dee
diff --git a/tests/studio/studiobench/CONTRIBUTING-perf.md b/tests/studio/studiobench/CONTRIBUTING-perf.md
index f0d9f9222cf..1c9a51d91a7 100644
--- a/tests/studio/studiobench/CONTRIBUTING-perf.md
+++ b/tests/studio/studiobench/CONTRIBUTING-perf.md
@@ -174,19 +174,28 @@ were junk.
## 4. Parity: prove you did not change what is rendered
-### The policy, and the two exemptions
+### The policy, and the three exemptions
-**UI and UX idempotency is required for every change, with exactly two exemptions:**
+**UI and UX idempotency is required for every change, with exactly three exemptions:**
1. **A deliberate difference accepted for a dramatic performance improvement.** This is a decision
somebody makes on the record with the number attached, not a default. If you are relying on it,
say so in the pull request and say what the difference is.
2. **A difference that exists only OFF SCREEN.** This one is a definition rather than a judgement:
rendering only what is visible is an accepted technique, not a parity violation.
+3. **Select-all need not select all, PROVIDED copy stays complete.** Copy may be implemented as
+ "emit the whole thread as markdown, or as plain text, read from the source" rather than as a
+ faithful reproduction of a DOM selection.
+ - **Completeness of the copied content is REQUIRED.** Silent truncation is data loss.
+ - **Visual selection fidelity is NOT required.**
-Neither exemption removes the need for a floor. An exemption changes what counts as a pass; it does
+ This is what makes deferral and virtualization cheap: the copy path stops depending on what is
+ mounted. Do not reject a design on the grounds that it breaks DOM-based select-all.
+
+No exemption removes the need for a floor. An exemption changes what counts as a pass; it does
not make an unmeasured claim into a measured one, so the null control still has to run on the same
-scale.
+scale. The third carries a condition on top of that, and the condition is the required half: an
+exemption you are relying on for the selection does not excuse the copy.
**A bare "PARITY OK" reads far stronger than any of the three modes can support**, which is why
each mode prints the CLAIM it is making and the POLICY it is judging against, and why you should
@@ -198,6 +207,23 @@ read both before quoting a pass:
| `--mode visible` | every message the viewport showed is present and identical, and every difference lies off screen | **yes** -- this is the mode that can say so |
| `--mode behaviour` | scroll extent matches and the invariants a windowed mount breaks first still hold | no, and it says nothing about appearance |
+No mode grants exemption 3 off a digest. `--mode behaviour` is the only one that speaks to it,
+through `clipboard_carries_the_whole_thread`, which scores the copy against the THREAD rather than
+against the other arm -- that is the required half. Where a payload carries no readable
+`select_all_copy`, the gate records that the exemption exists and does not grant it.
+
+**And it scores it by LENGTH, not by content.** Each arm's `clipboard_chars` is divided by the
+thread's own visible text and has to land inside `MIN_CLIPBOARD_COVERAGE`-`MAX_CLIPBOARD_COVERAGE`;
+the copied characters are never compared. That is not an oversight to be fixed by comparing them.
+The base arm's clipboard is the DOM's RENDERED TEXT and a store-based copy is markdown SOURCE, so
+the two are different serialisations of one conversation and a character comparison fails on a
+CORRECT build -- the only way to make it pass would be to normalise until it stopped testing
+anything. The band is where the strength is, and it is two-sided for that reason: the lower bound
+refused truncation measured at 0.61 of the thread, the upper bound refused the substitution its
+first fix turned into, measured at 2.16. A copy that rewrote content while landing inside the band
+would not be caught, so `--mode behaviour` prints the band it is enforcing next to its claim and
+does not use the bare word "complete".
+
The digest is **sidebar-blind and layout-blind**: run against a real sidebar-drag change it reported
0 of 34 differing pairs, and so did its own null control. So a digest pass is not a statement that
the UI is unchanged.
diff --git a/tests/studio/studiobench/INTERFACES.md b/tests/studio/studiobench/INTERFACES.md
index 8e5e819ffea..9471bce5ba8 100644
--- a/tests/studio/studiobench/INTERFACES.md
+++ b/tests/studio/studiobench/INTERFACES.md
@@ -372,7 +372,8 @@ and `thread_total` on every parity capture, `mounted_before` / `mounted_after` o
`reopen_readiness` on `thread_reopen`, `visible` on every action row, `observation_ms` on every
action row, `stream_samples` / `attached_fraction_of_stream` / `reattachments` on the cell's
`follow`, `reply_chars_scoreable` / `wire_parse_failures_in_window` /
-`wire_pending_chars_at_close` on every `stream_cost` window, and the gate rows
+`wire_pending_chars_at_close` on every `stream_cost` window, `ordinal_collisions` /
+`collided_ordinals` on every visible-region capture, and the gate rows
`thread_ready:{mode}`, `thread_complete`, `follows_the_stream` and `windowed_readiness:{arm}`.
**What `thread_reopen` measures.** `reopen_ms` runs from the click on the thread's sidebar row
@@ -444,11 +445,16 @@ limitation next to the passing verdict rather than leaving it in a source commen
### The policy, and the three claims
-All changes must preserve UI and UX idempotency, with two exemptions:
+All changes must preserve UI and UX idempotency, with three exemptions:
1. a UI difference may be accepted DELIBERATELY when performance improves dramatically;
2. a difference that exists only OFF SCREEN is fine by definition, because rendering only what is
- visible is an accepted technique rather than a parity violation.
+ visible is an accepted technique rather than a parity violation;
+3. a select-all need not select all, PROVIDED the copy it produces stays complete. Copy may
+ serialise the thread from the message store as markdown or plain text instead of reproducing a
+ DOM selection. Completeness of the copied content is REQUIRED, silent truncation being data
+ loss; visual selection fidelity is NOT. This is what makes deferral and virtualization cheap,
+ because the copy path stops depending on what is mounted.
The whole-document digest cannot express exemption 2. It compares everything in the DOM, so every
deferred-off-screen technique fails it by construction: virtualization, deferred fence
@@ -458,11 +464,13 @@ rather than giving one, so there is now a mode that gives one.
`sweep/ui_parity.py --mode auto|digest|visible|behaviour`. Every report prints the CLAIM it is
making AND the POLICY it is being judged against, because "PARITY OK" has meant three different
things in this file's history and none of them is "the UI is unchanged". The claim says what was
-compared; the policy says what a pass is worth, and the two exemptions are what decide that. Only
+compared; the policy says what a pass is worth, and the three exemptions are what decide that. Only
the `visible` mode can GRANT the off-screen exemption, and its policy line says so, together with
-the reminder that the exemption does not remove the floor. `analysis/parity.py` holds both as
-`POLICY` and `POLICY_BY_MODE`, and a test fails if any mode prints a claim without a policy beside
-it -- a constant nothing prints is a constant nobody reads.
+the reminder that the exemption does not remove the floor. No mode grants exemption 3 off a digest:
+`behaviour` is the only one that speaks to it, through `clipboard_carries_the_whole_thread`, and
+where there is no readable `select_all_copy` it records the exemption rather than granting it.
+`analysis/parity.py` holds both as `POLICY` and `POLICY_BY_MODE`, and a test fails if any mode
+prints a claim without a policy beside it -- a constant nothing prints is a constant nobody reads.
| mode | claim | fails on |
| --- | --- | --- |
@@ -532,6 +540,19 @@ only by a batch that mounted a message element, so a stream (text churn inside m
none. A row that can be placed by neither route is stamped with no ordinal and counted in
`unplaced_rows` rather than given a guess.
+**Two mounted rows publishing ONE position make the capture unreadable, and it says so.** The
+per-message digests are keyed by that position and `ever_visible` is a set of them, so a second row
+carrying a position a row already holds replaces the first one's digest and adds nothing to the
+set: three rows on screen produce a capture indistinguishable from a capture of two. Which of the
+two survives is DOM order, so the pair reaches MATCH exactly when the survivor happens to agree with
+the other arm. It is counted as `ordinal_collisions` with the positions named in
+`collided_ordinals`, and any nonzero count makes the pair NOT COMPARABLE before `ever_visible` and
+`messages` are read, because both of them are short by a row. The count is taken directly and NOT
+derived from `unmounted_at_capture`: in the renumber case the extra row at one position and the
+vacancy at another cancel, and that reads a clean zero over a live collision. The limit, stated: a
+collision that had resolved to one row by capture time is not visible here, and seeing it would need
+the clash recorded when the position is stamped.
+
**The visible-region noise floor is keyed by (rung, action), and needs more than one observation.**
`visible_unstable_set` derives it from a base-vs-base null control. It returned ACTION NAMES, so a
single differing null pair silenced that action for every rep and every rung -- and a payload
diff --git a/tests/studio/studiobench/analysis/parity.py b/tests/studio/studiobench/analysis/parity.py
index f53cb09743c..507a593729d 100644
--- a/tests/studio/studiobench/analysis/parity.py
+++ b/tests/studio/studiobench/analysis/parity.py
@@ -423,6 +423,116 @@ def compare(base: Optional[dict], treat: Optional[dict]) -> dict:
}
+def execution_verdict(base_row: Optional[dict], treat_row: Optional[dict]) -> Optional[dict]:
+ """The verdict that the DIGEST never gets to answer, or `None` when both arms ran.
+
+ EXTRACTED SO THERE IS ONE COPY, not for tidiness. Only `compare_rows` ever consulted this; the
+ visible-region and behavioural paths reduced execution to a boolean conjunction of `ran`, which
+ cannot express WHICH arm went idle. An action that RUNS on one build and cannot be performed on
+ the other leaves no digest to differ, and on a windowed arm those two reports are the whole UI
+ verdict, so that class had nowhere left to be seen. A predicate copied into them would drift the
+ way the gate-admission lists did before `INVALIDATING_CELL_GATES` was centralised.
+
+ The returned dict is the caller's to merge or return whole: `compare_rows` returns it, the other
+ two keep their own capture comparison and take `one_sided` and `idle_reason` off it.
+ """
+ ran: dict[str, bool] = {}
+ for label, row in (("base", base_row), ("treatment", treat_row)):
+ if not isinstance(row, dict):
+ return {
+ "verdict": NOT_COMPARABLE,
+ "reason": f"the {label} arm has no row for this action",
+ "moved": [],
+ "one_sided": "",
+ "idle_reason": "",
+ "style_verdict": NOT_COMPARABLE,
+ "style_reason": "",
+ }
+ ran[label] = bool(row.get("ran"))
+ if all(ran.values()):
+ return None
+ # Named after the arm that DID run, so an empty string is the symmetric case.
+ live = [label for label in ("base", "treatment") if ran[label]]
+ label = "base" if not ran["base"] else "treatment"
+ row = base_row if label == "base" else treat_row
+ assert isinstance(row, dict)
+ reason = row.get("reason") or "no reason recorded"
+ # A MISSED SLOT IS NOT A BUILD DIFFERENCE, even when only one arm missed it, and this
+ # distinction is the whole load-bearing part of `one_sided`. `ran=false` has two causes
+ # that look identical in the count and mean opposite things. The runner arriving after
+ # the slot closed says nothing about the build: the schedule is fixed, the budgets are
+ # small, and a machine slow enough to miss a slot at 45700ms is slow enough to miss it
+ # on the next repetition too, so corroboration does not separate them -- the misses are
+ # correlated through the runner, not independent draws. Treating that as asymmetric
+ # execution reds the job on machine speed and breaks the invariant the mutation study
+ # established, that a missed slot cannot move this verdict. A precondition failure is
+ # the opposite: `image_upload` records `slot_missed=false` with "no visible attachments
+ # button", and a control that stops opening records exactly that. So the signal is
+ # `slot_missed`, which the driver already writes, and not merely which arm went idle.
+ missed_slot = bool(row.get("slot_missed"))
+ detail = (
+ f"the action did not run on the {label} arm ({reason}), so any "
+ "agreement here is about a surface nothing touched"
+ )
+ if live and not missed_slot:
+ detail = (
+ f"the action RAN on the {live[0]} arm and could not be performed on the "
+ f"{label} arm ({reason}), so the two builds did not behave the same way"
+ )
+ if missed_slot:
+ live = []
+ return {
+ "verdict": NOT_EXERCISED,
+ "moved": [],
+ "one_sided": live[0] if live else "",
+ # The idle arm's OWN not_run string, unwrapped. `reason` above is prose built for a
+ # reader; the exemption has to match on what the action actually recorded.
+ "idle_reason": reason,
+ "reason": detail,
+ "style_verdict": NOT_EXERCISED,
+ "style_reason": "",
+ }
+
+
+def expect_regression(base_row: Optional[dict], treat_row: Optional[dict]) -> tuple[str, str]:
+ """(the arm whose own assertion failed while the other's passed, why) or `("", "")`.
+
+ AN ACTION THAT RAN AND FAILED ITS OWN ASSERTION IS NOT A COMPARISON OF WHAT IT NAMES, and
+ `ran` alone cannot see it. `stop_generation` returns `ran = True, expect_ok = stopped_ms is not
+ None`, so a head on which Stop no longer ends the stream records a row this layer read as a
+ perfectly good observation. `scoring.from_payload`, `report.payload` and `--assert-liveness`
+ already know better; the parity layer was the one left reading only `ran`.
+
+ CARRIED SEPARATELY FROM THE DIGEST, not folded into the verdict. `stop_generation` is on the
+ declared unstable list, so its DOM difference is excused -- but that exemption measures one
+ quantity (does this digest race) and the assertion is another (did the button do its job). They
+ share an action name and nothing else, so the caller gets its own signal and decides.
+
+ ONLY AN ASYMMETRY. `expect_ok is None` means the action asserts nothing, and both arms failing
+ means the fixture cannot reach the state on either build -- coverage lost, not a build
+ difference. One arm asserting successfully while the other does not is the question asked here.
+
+ SHARED WITH THE VISIBLE AND BEHAVIOURAL PATHS for the reason on `execution_verdict`: those two
+ ARE the UI verdict on a windowed arm, and `stop_generation` has no behavioural invariant, so an
+ assertion failing on one arm alone left no trace in either.
+ """
+ rows_ = (("base", base_row), ("treatment", treat_row))
+ if not all(isinstance(row, dict) for _label, row in rows_):
+ return "", ""
+ failed = [label for label, row in rows_ if row.get("expect_ok") is False] # type: ignore[union-attr]
+ passed = [label for label, row in rows_ if row.get("expect_ok") is True] # type: ignore[union-attr]
+ if not (len(failed) == 1 and passed):
+ return "", ""
+ who = failed[0]
+ row = base_row if who == "base" else treat_row
+ assert isinstance(row, dict)
+ return who, (
+ f"the action ran on both arms and its own assertion failed on the {who} arm "
+ f"({row.get('reason') or 'no reason recorded'}), so the two builds did not behave "
+ "the same way"
+ )
+
+
def compare_rows(base_row: Optional[dict], treat_row: Optional[dict]) -> dict:
"""`compare()`, gated on whether the action actually RAN on both arms.
@@ -445,101 +555,16 @@ def compare_rows(base_row: Optional[dict], treat_row: Optional[dict]) -> dict:
one regression class that produces no digest to differ. An arm that merely arrived after its
slot closed is a slow machine and cannot move a verdict, whether one arm missed it or both.
Only the first sets `one_sided`; the caller decides what to do with it.
+
+ Both halves live in `execution_verdict` and `expect_regression` so the visible-region and
+ behavioural paths can ask the same two questions of the same code; see those docstrings.
"""
- ran: dict[str, bool] = {}
- for label, row in (("base", base_row), ("treatment", treat_row)):
- if not isinstance(row, dict):
- return {
- "verdict": NOT_COMPARABLE,
- "reason": f"the {label} arm has no row for this action",
- "moved": [],
- "one_sided": "",
- "style_verdict": NOT_COMPARABLE,
- "style_reason": "",
- }
- ran[label] = bool(row.get("ran"))
- if not all(ran.values()):
- # Named after the arm that DID run, so an empty string is the symmetric case.
- live = [label for label in ("base", "treatment") if ran[label]]
- label = "base" if not ran["base"] else "treatment"
- row = base_row if label == "base" else treat_row
- assert isinstance(row, dict)
- reason = row.get("reason") or "no reason recorded"
- # A MISSED SLOT IS NOT A BUILD DIFFERENCE, even when only one arm missed it, and this
- # distinction is the whole load-bearing part of `one_sided`. `ran=false` has two causes
- # that look identical in the count and mean opposite things. The runner arriving after
- # the slot closed says nothing about the build: the schedule is fixed, the budgets are
- # small, and a machine slow enough to miss a slot at 45700ms is slow enough to miss it
- # on the next repetition too, so corroboration does not separate them -- the misses are
- # correlated through the runner, not independent draws. Treating that as asymmetric
- # execution reds the job on machine speed and breaks the invariant the mutation study
- # established, that a missed slot cannot move this verdict. A precondition failure is
- # the opposite: `image_upload` records `slot_missed=false` with "no visible attachments
- # button", and a control that stops opening records exactly that. So the signal is
- # `slot_missed`, which the driver already writes, and not merely which arm went idle.
- missed_slot = bool(row.get("slot_missed"))
- detail = (
- f"the action did not run on the {label} arm ({reason}), so any "
- "agreement here is about a surface nothing touched"
- )
- if live and not missed_slot:
- detail = (
- f"the action RAN on the {live[0]} arm and could not be performed on the "
- f"{label} arm ({reason}), so the two builds did not behave the same way"
- )
- if missed_slot:
- live = []
- return {
- "verdict": NOT_EXERCISED,
- "moved": [],
- "one_sided": live[0] if live else "",
- # The idle arm's OWN not_run string, unwrapped. `reason` below is prose built for a
- # reader; the exemption has to match on what the action actually recorded.
- "idle_reason": reason,
- "reason": detail,
- "style_verdict": NOT_EXERCISED,
- "style_reason": "",
- }
+ idle = execution_verdict(base_row, treat_row)
+ if idle is not None:
+ return idle
assert base_row is not None and treat_row is not None
out = compare(base_row.get("parity"), treat_row.get("parity"))
- # AN ACTION THAT RAN AND FAILED ITS OWN ASSERTION IS NOT A COMPARISON OF WHAT IT NAMES, and
- # `ran` alone cannot see it. `stop_generation` returns `ran = True, expect_ok = stopped_ms is
- # not None`, so a head on which Stop no longer ends the stream records a row this layer reads
- # as a perfectly good observation. Every other reader already knows better --
- # `scoring.from_payload` drops such a row's timing and `report.payload` and `--assert-
- # liveness` both single it out -- and the parity layer was the one left reading only `ran`.
- #
- # CARRIED SEPARATELY FROM THE DIGEST, not folded into the verdict, and that is the whole point
- # of it. `stop_generation` is on the declared unstable list, so its DOM difference is excused;
- # applying that exemption to the assertion as well is applying a measurement of one quantity
- # (does this digest race) to a different one (did the button do its job). The two happen to
- # share an action name and nothing else. So the caller gets its own signal and decides.
- #
- # ONLY AN ASYMMETRY. `expect_ok is None` means the action asserts nothing, and both arms
- # failing means the fixture cannot reach the state on either build -- coverage lost, not a
- # difference between the builds. One arm asserting successfully while the other does not is
- # the two builds behaving differently, which is the question this instrument asks.
- failed = [
- label
- for label, row in (("base", base_row), ("treatment", treat_row))
- if row.get("expect_ok") is False
- ]
- passed = [
- label
- for label, row in (("base", base_row), ("treatment", treat_row))
- if row.get("expect_ok") is True
- ]
- out["expect_regressed"] = failed[0] if len(failed) == 1 and passed else ""
- if out["expect_regressed"]:
- _who = out["expect_regressed"]
- _row = base_row if _who == "base" else treat_row
- out["expect_reason"] = (
- f"the action ran on both arms and its own assertion failed on the {_who} arm "
- f"({_row.get('reason') or 'no reason recorded'}), so the two builds did not behave "
- "the same way"
- )
- else:
- out["expect_reason"] = ""
+ out["expect_regressed"], out["expect_reason"] = expect_regression(base_row, treat_row)
return out
@@ -629,10 +654,16 @@ def summarise(results: Iterable[dict[str, Any]]) -> dict[str, int]:
# ── visible-region parity ───────────────────────────────────────────
#
-# THE POLICY. All changes must preserve UI and UX idempotency, with two exemptions: a difference
-# may be accepted deliberately when performance improves dramatically, and a difference that exists
+# THE POLICY. All changes must preserve UI and UX idempotency, with three exemptions: a difference
+# may be accepted deliberately when performance improves dramatically; a difference that exists
# only OFF SCREEN is fine by definition, because rendering only what is visible is an accepted
-# technique rather than a parity violation.
+# technique rather than a parity violation; and a select-all need not select all, PROVIDED the copy
+# it produces stays complete.
+#
+# The third is what makes deferral and virtualization cheap: the copy path stops depending on what
+# is mounted, so it may serialise the thread from the message store as markdown or plain text
+# instead of reproducing a DOM selection. Completeness of the copied content is REQUIRED -- silent
+# truncation is data loss -- and visual selection fidelity is NOT.
#
# `compare()` above cannot express the second exemption. It digests the thread whether or not any
# of it is on screen, so deferred off-screen work fails it by construction: virtualization,
@@ -664,7 +695,9 @@ CLAIM_VISIBLE = (
)
CLAIM_BEHAVIOURAL = (
"behavioural parity: the scroll extent matches and the invariants a windowed mount breaks "
- "first still hold. Says NOTHING about how anything looks"
+ "first still hold, including that each arm's clipboard covers the thread's own visible text "
+ "BY LENGTH. Says NOTHING about how anything looks, and nothing about WHICH characters were "
+ "copied"
)
#: THE POLICY EVERY VERDICT IS JUDGED AGAINST, printed beside the claim.
@@ -675,12 +708,29 @@ CLAIM_BEHAVIOURAL = (
#:
#: The exemptions are not loopholes. The first is a decision someone makes on the record with a
#: number attached; the second is a definition, because rendering only what is visible is an
-#: accepted technique rather than a parity violation. Neither removes the need for a floor: a
-#: difference that is exempt still has to be shown to be the difference you think it is, which is
-#: what the null control is for.
+#: accepted technique rather than a parity violation; the third is CONDITIONAL, and the condition
+#: is the part that is required -- the copy must be complete, and only the visual fidelity of the
+#: selection is given up. None of the three removes the need for a floor: a difference that is
+#: exempt still has to be shown to be the difference you think it is, which is what the null
+#: control is for.
+#:
+#: NO MODE GRANTS THE THIRD ON A DIGEST. `--mode behaviour` is the only one that speaks to it at
+#: all, through `clipboard_carries_the_whole_thread`, which scores the copy against the THREAD
+#: rather than against the other arm. Where a payload carries no readable `select_all_copy` the
+#: gate records that the exemption exists and does not grant it.
+#:
+#: And it scores it BY LENGTH. That is a proxy for completeness, not completeness itself, so the
+#: printed line says so rather than leaving "complete" to be read as a content comparison. A
+#: content comparison is not available here: the base arm's clipboard is the DOM's rendered text
+#: while a store-based copy is markdown SOURCE, so the two are different serialisations of one
+#: conversation and comparing their characters fails on a CORRECT build. The coverage band is what
+#: carries the weight, and it is the band that refused both defects this was written for --
+#: truncation at 0.61 of the thread and substitution at 2.16 -- so it is interpolated from the
+#: live constants by `behaviour_policy()` rather than written out here, where it could drift.
POLICY = (
- "UI and UX idempotency is required, with two exemptions: a deliberate difference accepted "
- "for a dramatic performance improvement, and a difference that exists only OFF SCREEN"
+ "UI and UX idempotency is required, with three exemptions: a deliberate difference accepted "
+ "for a dramatic performance improvement, a difference that exists only OFF SCREEN, and a "
+ "select-all that does not select all PROVIDED the copy it produces stays complete"
)
#: What each mode can and cannot decide under that policy. The point of the second half of each
@@ -702,11 +752,29 @@ POLICY_BY_MODE = {
f"{POLICY}. This mode judges neither requirement directly. It checks invariants a "
"windowed mount breaks first -- scroll extent, what the clipboard carries, whether the "
"thread survives being reopened -- so a pass here is evidence about BEHAVIOUR and says "
- "nothing about appearance. It cannot grant either exemption"
+ "nothing about appearance. It cannot grant the performance or off-screen exemptions, and "
+ "it is the only mode that speaks to the select-all one, on the half of that exemption "
+ "that is REQUIRED: whether the copy stays complete. It measures that BY LENGTH, scoring "
+ "each arm's clipboard against the thread's own visible text and requiring coverage in "
+ "{min}-{max}. It does not compare the copied characters and cannot: the base arm's "
+ "clipboard is the DOM's rendered text and a store-based copy is markdown source, so a "
+ "character comparison of two correct serialisations fails. Without a readable "
+ "select_all_copy it records the exemption rather than granting it"
),
}
+def behaviour_policy(min_coverage: float, max_coverage: float) -> str:
+ """The behaviour-mode policy line with the coverage band it actually enforces filled in.
+
+ The band lives in `analysis.behaviour`, which imports THIS module, so the caller passes it in
+ rather than this module importing back and closing a cycle. Interpolating it is the point: a
+ band written out by hand here drifts away from the one enforced, and the sentence a reader
+ trusts is then describing a gate that no longer exists.
+ """
+ return POLICY_BY_MODE["behaviour"].format(min = min_coverage, max = max_coverage)
+
+
def compare_visible(base: Optional[dict], treat: Optional[dict]) -> dict:
"""One base/treatment pair, scored on the VISIBLE REGION only.
@@ -740,6 +808,52 @@ def compare_visible(base: Optional[dict], treat: Optional[dict]) -> dict:
"claim": CLAIM_VISIBLE,
}
+ # BEFORE THE TWO SETS ARE COMPARED, because a collision is what makes them untrustworthy.
+ # `scene/parity.js` keys its per-message digests by ordinal, so two mounted rows sharing an
+ # `aria-posinset` -- a virtualizer renumbering a recycled row wrongly -- leave one digest where
+ # two rows were on screen, and `ever_visible` collapses them too. Both quantities below are then
+ # short by a row, and whether the verdict came out MATCH or DIFFER would turn only on which of
+ # the two survived, which is DOM order and nothing else.
+ #
+ # Read defensively so a payload recorded before the counter existed compares exactly as it did.
+ collisions = {
+ label: int(side.get("ordinal_collisions") or 0)
+ for label, side in (("base", base), ("treatment", treat))
+ }
+ # A SEVERE FINDING OUTRANKS THIS REFUSAL, and exactly one finding qualifies. "One arm's
+ # viewport ended EMPTY and the other's did not" is marked NOT SUPPRESSIBLE where it is raised,
+ # because losing the thread is a different kind of statement from a capture that could not be
+ # read -- and a collision provably cannot manufacture it. A collision needs TWO mounted rows
+ # at one position, so the map it corrupts still has at least one entry in it; it can merge two
+ # entries and never empty a map. So the one thing a collision cannot have caused is still
+ # reported rather than swallowed by a blanket refusal.
+ #
+ # Only that one. Every other comparison below IS corrupted by a collision: `ever_visible` loses
+ # an ordinal on one arm alone, so "the two arms put different messages on screen" can be
+ # entirely an artefact of the collision, and the per-ordinal digests are short by a row.
+ lost_the_thread = (len(base.get("messages") or {}) == 0) != (
+ len(treat.get("messages") or {}) == 0
+ )
+ if any(collisions.values()) and not lost_the_thread:
+ which = ", ".join(
+ f"{label} {n} at ordinal(s) "
+ f"{sorted((base if label == 'base' else treat).get('collided_ordinals') or [])[:8]}"
+ for label, n in collisions.items()
+ if n
+ )
+ return {
+ "verdict": NOT_COMPARABLE,
+ "reason": (
+ "two or more mounted rows published the SAME thread position during this action, "
+ f"so one of them is missing from everything compared below ({which}). The digest "
+ "map is keyed by that position and the visible set is a set of them, so neither "
+ "carries the extra row"
+ ),
+ "moved": [],
+ "claim": CLAIM_VISIBLE,
+ "not_digested": [],
+ }
+
bev, tev = set(base.get("ever_visible") or []), set(treat.get("ever_visible") or [])
if bev != tev:
only_b, only_t = sorted(bev - tev), sorted(tev - bev)
diff --git a/tests/studio/studiobench/analysis/selftest/test_studiobench_visible_parity.py b/tests/studio/studiobench/analysis/selftest/test_studiobench_visible_parity.py
index be7740de278..3e0b7469c50 100644
--- a/tests/studio/studiobench/analysis/selftest/test_studiobench_visible_parity.py
+++ b/tests/studio/studiobench/analysis/selftest/test_studiobench_visible_parity.py
@@ -3,9 +3,11 @@
"""VISIBLE-REGION PARITY, held to the policy it exists to serve.
-The policy: all changes preserve UI and UX idempotency, with two exemptions. A difference may be
-accepted deliberately when performance improves dramatically, and a difference that exists only OFF
-SCREEN is fine by definition, because rendering only what is visible is an accepted technique.
+The policy: all changes preserve UI and UX idempotency, with three exemptions. A difference may be
+accepted deliberately when performance improves dramatically; a difference that exists only OFF
+SCREEN is fine by definition, because rendering only what is visible is an accepted technique; and
+a select-all need not select all, PROVIDED the copy stays complete. Only the second is a question
+this file can answer -- the third is scored behaviourally, on the clipboard.
The structural digest cannot express the second exemption -- it digests the thread on screen and
off, so every deferred-off-screen technique fails it by construction -- and answering NOT_APPLICABLE
@@ -245,9 +247,14 @@ def test_every_mode_names_the_policy_it_is_judging_against():
"""A BARE "PARITY OK" READS FAR STRONGER THAN ANY MODE CAN SUPPORT.
Each mode already prints the CLAIM it is making. The claim says what was compared; it does not
- say what a pass is worth, and the two exemptions are exactly what decide that. So the policy is
- printed beside the claim, per mode, and this holds that every mode has one, that all three name
- both exemptions, and that only the visible mode says it can grant the off-screen one.
+ say what a pass is worth, and the three exemptions are exactly what decide that. So the policy
+ is printed beside the claim, per mode, and this holds that every mode has one, that all three
+ name all three exemptions, and that each says which of them it can grant.
+
+ THE THIRD IS THE ONE A READER IS LIKELIEST TO BE MISSING, and it is the one with a condition
+ attached: the copy must stay complete, only the visual fidelity of the selection is given up.
+ A policy line that named the exemption without its condition would read as permission to lose
+ conversation, so the condition is asserted alongside it.
"""
from studiobench.analysis import parity as P
@@ -256,25 +263,50 @@ def test_every_mode_names_the_policy_it_is_judging_against():
assert "idempotency" in text, mode
assert "performance improvement" in text, mode
assert "OFF SCREEN" in text or "off-screen" in text, mode
+ assert "select-all that does not select all" in text, mode
+ assert "PROVIDED the copy it produces stays complete" in text, mode
assert "can GRANT the off-screen exemption" in P.POLICY_BY_MODE["visible"]
assert "cannot grant" in P.POLICY_BY_MODE["structural"]
- assert "cannot grant either exemption" in P.POLICY_BY_MODE["behaviour"]
+ # The behavioural mode grants neither of the first two and is the only one that speaks to the
+ # third, so "either" would be the wrong word for it now.
+ assert "cannot grant the performance or off-screen exemptions" in P.POLICY_BY_MODE["behaviour"]
+ # AND IT SAYS HOW IT MEASURES THE CONDITION. "Complete" on its own reads as a comparison of
+ # the copied content; what the gate does is divide each arm's clipboard length by the thread's
+ # visible text and require the ratio to land in a band. Saying which of those it is decides
+ # whether a reader is entitled to conclude the copy was intact, so the weaker wording is not
+ # allowed back: the line has to name the measure AND disclaim the one it does not perform.
+ assert "BY LENGTH" in P.POLICY_BY_MODE["behaviour"]
+ assert "does not compare the copied characters" in P.POLICY_BY_MODE["behaviour"]
+ assert "records the exemption rather than granting it" in P.POLICY_BY_MODE["behaviour"]
# The floor survives the exemption. An exemption changes what counts as a pass; a measurement
# with no floor under it is not a pass in the first place.
assert "does not remove the floor" in P.POLICY_BY_MODE["visible"]
def test_the_policy_line_is_printed_next_to_every_claim_line():
- """A constant nothing prints is a constant nobody reads."""
+ """A constant nothing prints is a constant nobody reads.
+
+ Every needle below is DERIVED from the module under test rather than written out here: the
+ claim names come from `vars(P)` and the mode names from `POLICY_BY_MODE` itself. Counting two
+ hand-typed substrings instead could only ever report a total, so it said "3 claim lines but 2
+ policy lines" without naming the mode that had gone quiet, and it broke the moment a policy
+ line started being built by a function so that it could interpolate the band it enforces.
+ """
from pathlib import Path
source = (Path(__file__).resolve().parents[2] / "sweep" / "ui_parity.py").read_text(
encoding = "utf-8"
)
- claims = source.count("CLAIM: {P.CLAIM_")
- policies = source.count("POLICY: {P.POLICY_BY_MODE[")
- assert claims == 3, f"expected one claim line per mode, found {claims}"
- assert policies == claims, f"{claims} claim lines but {policies} policy lines"
+ claims = sorted(name for name in vars(P) if name.startswith("CLAIM_"))
+ assert len(claims) == 3, claims
+ for name in claims:
+ assert f"P.{name}" in source, f"{name} is never printed"
+ for mode in P.POLICY_BY_MODE:
+ # Either printed straight from the table, or through the per-mode helper that fills in
+ # the numbers that mode is actually enforcing.
+ assert (
+ f"POLICY_BY_MODE['{mode}']" in source or f"{mode}_policy(" in source
+ ), f"the {mode} policy line is never printed"
def test_the_mode_names_the_pull_request_template_uses_are_accepted():
diff --git a/tests/studio/studiobench/scene/parity.js b/tests/studio/studiobench/scene/parity.js
index bc497fbad19..cdc467511d0 100644
--- a/tests/studio/studiobench/scene/parity.js
+++ b/tests/studio/studiobench/scene/parity.js
@@ -286,10 +286,13 @@
// ── VISIBLE-REGION PARITY ────────────────────────────────────────────────────────────────────
//
- // THE POLICY THIS SERVES. All changes must preserve UI and UX idempotency, with two exemptions:
- // a difference may be accepted deliberately when performance improves dramatically, and a
- // difference that exists only OFF SCREEN is fine by definition, because rendering only what is
- // visible is an accepted technique rather than a parity violation.
+ // THE POLICY THIS SERVES. All changes must preserve UI and UX idempotency, with three
+ // exemptions: a difference may be accepted deliberately when performance improves dramatically;
+ // a difference that exists only OFF SCREEN is fine by definition, because rendering only what is
+ // visible is an accepted technique rather than a parity violation; and a select-all need not
+ // select all, PROVIDED the copy stays complete. Nothing in this file can see the third -- the
+ // clipboard is scored behaviourally, in analysis/behaviour.py -- so a selection that shrank is
+ // not a finding here.
//
// The whole-document digest above cannot express the second exemption. It compares everything
// that is in the DOM, so ANY deferred off-screen work fails it by construction -- virtualization,
@@ -604,6 +607,20 @@
const nodes = (D().messages && D().messages()) || [];
const byOrdinal = {};
let mounted_ever_visible = 0;
+ // TWO MOUNTED ROWS CANNOT BE ONE MESSAGE, and until this counter existed nothing said so.
+ // The assignment below is keyed by ordinal, so a second row reusing one SILENTLY REPLACED
+ // the first row's digest, and `VIS.ever` is a Set of numbers so it collapsed them too.
+ // Whether the ghost row was caught was pure DOM order: reproduced in a browser, the same
+ // ghost inserted BEFORE the real row returns MATCH and AFTER it returns DIFFER.
+ //
+ // COUNTED DIRECTLY, NOT DERIVED. `unmounted_at_capture` looks like it should notice, but
+ // the extra row and the vacancy cancel in exactly the renumber case, so it reads a clean 0
+ // over a live collision.
+ //
+ // The residual: a collision that had resolved to one row by the time `capture()` ran is
+ // not detectable here. Seeing it needs the clash recorded where the ordinal is stamped.
+ let ordinal_collisions = 0;
+ const collided = [];
for (let i = 0; i < nodes.length; i++) {
const el = nodes[i];
const ord = typeof el.__sbOrdinal === "number" ? el.__sbOrdinal : ordinalOf(el, i + 1);
@@ -635,6 +652,10 @@
// holes -- and those are the checks that can say what a right ordinal would be, which a
// digest comparison against an arm that publishes none never could.
const sig = signature(el, VIRTUALIZATION_ATTRS);
+ if (Object.prototype.hasOwnProperty.call(byOrdinal, String(ord))) {
+ ordinal_collisions += 1;
+ if (collided.indexOf(ord) === -1) collided.push(ord);
+ }
byOrdinal[String(ord)] = {
role: el.getAttribute("data-role") || "?",
digest: hash(sig),
@@ -656,6 +677,11 @@
// ordinal and so appear nowhere above, which is a hole in the compared set rather than
// agreement, and it is counted here so a reader can see it is zero.
unplaced_rows: VIS.unplaced,
+ // Mounted, ever-visible rows whose ordinal a row already written had. See the note in
+ // the loop: the digest map and `ever_visible` both lose one of the two, so a nonzero
+ // count here means neither of them can be compared.
+ ordinal_collisions,
+ collided_ordinals: collided.sort((a, b) => a - b),
messages: byOrdinal,
};
} catch (e) {
diff --git a/tests/studio/studiobench/scene/selftest/test_studiobench_visible_capture_live.py b/tests/studio/studiobench/scene/selftest/test_studiobench_visible_capture_live.py
index 42677022dc2..f238343509d 100644
--- a/tests/studio/studiobench/scene/selftest/test_studiobench_visible_capture_live.py
+++ b/tests/studio/studiobench/scene/selftest/test_studiobench_visible_capture_live.py
@@ -727,3 +727,134 @@ def test_a_row_renumbered_in_place_is_restamped_and_reported(browser):
# And its content is filed under the position it actually holds.
assert "42" in got["messages"], got["messages"]
assert got["unplaced_rows"] == 0, got
+ # A LEGITIMATE RENUMBER IS NOT A COLLISION. One node holds one position at a time here, so the
+ # collision counter added for the two-rows-one-ordinal case must not fire on this, or a correct
+ # recycling virtualizer would be refused on every action it recycles a row in.
+ assert got["ordinal_collisions"] == 0, got
+
+
+#: TWO MOUNTED ROWS PUBLISHING ONE POSITION. A virtualizer that renumbers a recycled row wrongly
+#: leaves an extra message on screen wearing a position another row already holds.
+COLLISION_FIXTURE = """
+<!doctype html><meta charset="utf-8">
+<style>
+ body { margin: 0; }
+ .aui-thread-viewport { height: 400px; overflow-y: auto; }
+ [data-role] { height: 100px; }
+</style>
+<div class="aui-thread-root">
+ <div class="aui-thread-viewport" id="vp">
+ <div aria-posinset="1"><div data-role="user">message 1</div></div>
+ <div aria-posinset="2"><div data-role="assistant">message 2</div></div>
+ </div>
+</div>
+<script>
+ window.__ghost = (before) => {
+ const vp = document.getElementById("vp");
+ const holder = document.createElement("div");
+ holder.setAttribute("aria-posinset", "1");
+ const row = document.createElement("div");
+ row.setAttribute("data-role", "user");
+ row.textContent = "a ghost the user can see";
+ holder.appendChild(row);
+ if (before) vp.insertBefore(holder, vp.firstChild);
+ else vp.appendChild(holder);
+ };
+</script>
+"""
+
+
+def _capture_with_ghost(browser, *, before: bool) -> dict:
+ pg = browser.new_page(viewport = {"width": 800, "height": 600})
+ try:
+ pg.set_content(COLLISION_FIXTURE)
+ pg.add_script_tag(content = _DOM_JS.read_text(encoding = "utf-8"))
+ pg.add_script_tag(content = _PARITY_JS.read_text(encoding = "utf-8"))
+ _watch(pg)
+ pg.evaluate("(b) => window.__ghost(b)", before)
+ pg.wait_for_timeout(150)
+ return _capture(pg)
+ finally:
+ pg.close()
+
+
+def test_two_rows_sharing_a_thread_position_are_counted_rather_than_overwritten(browser):
+ """THE DEFECT. The digest map is keyed by ordinal and the assignment was unconditional, so the
+ second row in DOM order silently REPLACED the first one's entry; `VIS.ever` is a Set of
+ numbers, so it collapsed the pair as well. Three rows on screen came out of the capture looking
+ exactly like a capture of two.
+
+ Whether that was ever caught was DOM order and nothing else. Reproduced in this browser, the
+ same ghost inserted BEFORE the row it shadows leaves the surviving digest agreeing with the
+ other arm and the pair returns MATCH; inserted after, it returns DIFFER. Last writer wins, so
+ the collision passes exactly when the survivor happens to be the one that agrees.
+ """
+ for before in (True, False):
+ got = _capture_with_ghost(browser, before = before)
+ assert got["ordinal_collisions"] == 1, (before, got)
+ assert got["collided_ordinals"] == [1], (before, got)
+ # The counter is not derived from the arithmetic, and this is why: two of the three rows
+ # on screen are filed under one key, so the map still holds two entries.
+ assert set(got["messages"]) == {"1", "2"}, got["messages"]
+
+
+def test_a_collision_refuses_the_pair_instead_of_reporting_agreement(browser):
+ """THE CONSEQUENCE, through the comparison. Three rows are on screen on one arm and two on the
+ other, and the capture cannot say so: the digest map holds two entries either way and
+ `ever_visible` holds two ordinals either way. So `compare_visible` reached a verdict out of a
+ set it did not know was short, and WHICH verdict depended only on which of the two rows sharing
+ the position happened to be written last -- MATCH when the survivor agrees with the other arm,
+ DIFFER when it does not, neither of them a statement about the row that was dropped.
+
+ Refused rather than answered. A pair whose inputs are known to be incomplete carries no verdict
+ in either direction, which is the rule this file applies to every other unreadable capture."""
+ from studiobench.analysis import parity as P
+
+ clean = _capture_with_ghost(browser, before = False)
+ clean["ordinal_collisions"] = 0
+ clean["collided_ordinals"] = []
+ ghosted = _capture_with_ghost(browser, before = True)
+ verdict = P.compare_visible(clean, ghosted)
+ assert verdict["verdict"] == P.NOT_COMPARABLE, verdict
+ assert "SAME thread position" in verdict["reason"], verdict
+
+
+def test_losing_the_thread_outranks_the_collision_refusal(browser):
+ """THE ONE FINDING A COLLISION CANNOT HAVE MANUFACTURED, so the refusal must not swallow it.
+
+ "One arm's viewport ended EMPTY and the other's did not" is raised with `severe: True` and is
+ documented at that site as not suppressible, because losing the conversation is a different kind
+ of statement from a capture that could not be read. A blanket collision refusal placed ahead of
+ it downgraded it to NOT COMPARABLE.
+
+ A collision provably cannot cause it: a collision needs TWO mounted rows sharing one position,
+ so the map it corrupts still holds an entry. It can merge two entries and never empty a map.
+ """
+ from studiobench.analysis import parity as P
+
+ ghosted = _capture_with_ghost(browser, before = True)
+ assert ghosted["ordinal_collisions"] == 1, ghosted
+ # The other arm ended with nothing on screen at all, which is the 100K `model_change` shape:
+ # 12 mounted messages to 0, never recovered.
+ empty = dict(ghosted)
+ empty["messages"] = {}
+ empty["ordinal_collisions"] = 0
+ empty["collided_ordinals"] = []
+
+ verdict = P.compare_visible(empty, ghosted)
+ assert verdict["verdict"] == P.DIFFER, verdict
+ assert verdict.get("severe") is True, verdict
+ assert "lost the thread" in verdict["reason"], verdict
+
+
+def test_a_collision_with_both_viewports_alive_is_still_refused(browser):
+ """THE CONTROL for the one above. The severe finding is the only thing that outranks the
+ refusal, so a collision on an arm whose viewport is perfectly healthy must still refuse."""
+ from studiobench.analysis import parity as P
+
+ clean = _capture_with_ghost(browser, before = False)
+ clean["ordinal_collisions"] = 0
+ clean["collided_ordinals"] = []
+ ghosted = _capture_with_ghost(browser, before = True)
+ assert clean["messages"] and ghosted["messages"], (clean, ghosted)
+ assert P.compare_visible(clean, ghosted)["verdict"] == P.NOT_COMPARABLE
diff --git a/tests/studio/studiobench/sweep/selftest/test_studiobench_windowed_parity.py b/tests/studio/studiobench/sweep/selftest/test_studiobench_windowed_parity.py
index d0650d15eb7..a6e7abb537d 100644
--- a/tests/studio/studiobench/sweep/selftest/test_studiobench_windowed_parity.py
+++ b/tests/studio/studiobench/sweep/selftest/test_studiobench_windowed_parity.py
@@ -350,7 +350,19 @@ def test_an_old_payload_that_records_no_rebuild_evidence_is_not_a_pass():
def test_a_timed_out_rebuild_leaves_the_behavioural_run_with_no_verdict(tmp_path, capsys):
"""THE CONSEQUENCE, through the command that reports it. This pair was the run's only one, so
counting it as a held invariant produced `invariants held: 1` and exit 0 over a rebuild that
- never finished. It is now the third outcome, and a run that compared nothing exits 2."""
+ never finished. It is now the third outcome: nothing was compared, and that is not a pass.
+
+ EXIT 1 RATHER THAN 2, and the difference is which of two true statements is the more specific.
+ The invariant genuinely could not be read -- `invariants held: 0`, one pair NOT COMPARABLE,
+ NOTHING WAS COMPARED, all still asserted below. But the pair also carries a DIRECTIONAL
+ assertion failure: the action ran on both arms and its own `expect_ok` failed on the treatment
+ alone, which is the two builds behaving differently rather than the tool being unable to tell.
+ `report` already resolves this precedence for the structural mode and says so where it does it
+ -- 'a run can find a real regression while deciding nothing, and "it failed" is the more
+ specific answer than "it could not tell"' -- and running `report` over this very payload
+ returns 1. The behavioural mode was reading only its invariants, so the same payload came out
+ of the two modes with two different verdicts. It no longer does.
+ """
import json
from studiobench.sweep import ui_parity as U
@@ -367,7 +379,11 @@ def test_a_timed_out_rebuild_leaves_the_behavioural_run_with_no_verdict(tmp_path
assert "invariants held: 0" in out, out
assert "NOT COMPARABLE: 1" in out, out
assert "NOTHING WAS COMPARED" in out, out
- assert code == 2, out
+ assert "ASSERTION FAILED ON ONE ARM" in out, out
+ assert code == 1, out
+ # THE TWO MODES AGREE ON THIS PAYLOAD, checked rather than asserted in prose. The structural
+ # report is the one that already had this precedence rule written down, so it is the reference.
+ assert U.report([shard], "structural on the same payload", frozenset()) == 1
def test_an_action_with_no_declared_invariant_is_unchecked_and_not_a_pass():
@@ -477,6 +493,79 @@ def test_behavioural_scoring_that_validated_nothing_is_not_a_pass(tmp_path, caps
assert "NOTHING WAS COMPARED" in out
+def _scroll_extent_broken_pair(cell_suffix = "rep0"):
+ """A `select_text` pair whose declared invariant is BROKEN: the windowed arm's scrollbar says
+ the thread is a third of its real length. `compare_behaviour` returns BROKEN, so this pair
+ lands in `broken` and NOT in `matched`."""
+ rows = []
+ for side, mounted, scroll in (("base", 18, 10_000), ("treatment", 6, 3_300)):
+ row = _row(
+ "select_text",
+ _capture(mounted, 18),
+ selected_chars = 100,
+ visible_chars = 100,
+ )
+ row["census"]["viewport_scroll_height"] = scroll
+ row["cell_id"] = f"r100K.{side}.{cell_suffix}"
+ rows.append(row)
+ return rows
+
+
+def test_a_run_whose_every_invariant_BROKE_does_not_also_claim_it_compared_nothing(
+ tmp_path, capsys
+):
+ """THE SELF-CONTRADICTING ARTIFACT. `matched` and `broken` are independent counters, so a
+ payload whose only pair BROKE its invariant satisfies `matched == 0` as well.
+
+ The no-verdict banner was gated on `matched == 0` alone, so this run printed its broken
+ invariant, then printed that not one behavioural invariant was evaluated and that it carried
+ "neither a pass nor a failure" -- and then returned 1. Every clause of that banner is false
+ here, and its instruction ("find out why the actions did not run") points away from the
+ regression listed three lines above it.
+
+ The exit code was right and stays right; asserted below, because a banner fix that quietened
+ the failure would be far worse than the banner.
+ """
+ from studiobench.sweep import ui_parity as U
+
+ shard = _write(tmp_path, "all_broken", _scroll_extent_broken_pair())
+ code = U.behaviour_report([shard], "UI PARITY: all broken")
+ out = capsys.readouterr().out
+
+ assert code == 1, out
+ assert "invariants held: 0" in out, out
+ assert "INVARIANTS BROKEN: 1" in out, out
+ assert "scroll_extent" in out, out
+ assert "NOTHING WAS COMPARED" not in out, out
+ assert "neither a pass nor a failure" not in out, out
+
+
+def test_the_no_verdict_banner_still_fires_when_a_build_DIFFERENCE_is_the_only_failure(
+ tmp_path, capsys
+):
+ """THE OTHER HALF OF THE GATE, pinned so the fix above cannot be widened into a regression.
+
+ `build_differences` collects two shapes -- one-arm execution and a directional assertion
+ failure -- from pairs whose INVARIANTS were unreadable. When one of those is the only reason a
+ run fails, "not one behavioural invariant was evaluated" is literally true, and the banner
+ belongs there alongside exit 1. Gating it on `build_failed` as well as on `broken` would
+ silence a true statement.
+ """
+ from studiobench.sweep import ui_parity as U
+
+ rows = []
+ for side, row in (("base", _reopen_row(18)), ("treatment", _reopen_row(3, ready = False))):
+ row["cell_id"] = f"r100K.{side}.rep0"
+ rows.append(row)
+ shard = _write(tmp_path, "build_diff_only", rows)
+
+ code = U.behaviour_report([shard], "UI PARITY: build difference only")
+ out = capsys.readouterr().out
+ assert code == 1, out
+ assert "INVARIANTS BROKEN: 0" in out, out
+ assert "NOTHING WAS COMPARED" in out, out
+
+
def test_the_observation_cost_is_not_charged_to_the_action_budget():
"""`over_ms` used to be sampled AFTER the census and the multi-megabyte digest that this
change had just moved outside the measured window, so an action that finished inside its
@@ -1777,3 +1866,398 @@ def test_a_resume_that_failed_again_is_still_refused(tmp_path):
bad = U.incomplete_cells([shard / "payload.jsonl"])
assert set(bad) == {"r100K.base.rep0", "r100K.treatment.rep0"}, bad
assert "still short" in bad["r100K.base.rep0"], bad
+
+
+# ── the coverage floor applies to every mode, not only the structural one ─────
+
+
+def _windowed_only_shard(
+ tmp_path,
+ name,
+ *,
+ pairs = 1,
+ differ = False,
+):
+ """A payload whose every pair is a WINDOWED mount, so `main` takes the structural early return.
+
+ One clean, matching windowed pair per action. `--mode auto` classifies these on the capture's
+ own `mounted_messages` / `thread_total`, so nothing here has to be declared.
+ """
+ rows = []
+ for i in range(pairs):
+ action = f"select_text{i}" if i else "select_text"
+ for side in ("base", "treatment"):
+ windowed = side == "treatment"
+ digest = "regressed" if (differ and windowed) else "shipped"
+ rows.append(
+ _action(
+ action,
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = 9 if windowed else 18, total = 18),
+ visible = _visible([1], [1], digest = digest),
+ expect = {"selected_chars": 100, "visible_chars": 100},
+ )
+ )
+ return _write(tmp_path, name, rows)
+
+
+def _windowed_shard_visible_only_on_one(
+ tmp_path,
+ name,
+ *,
+ pairs = 4,
+):
+ """Every pair carries a behavioural invariant; only the FIRST carries a visible capture.
+
+ One action at four cells, so all four are pairs behavioural mode declares an invariant for --
+ what varies is whether the visible-region capture is there to be read at all.
+ """
+ rows = []
+ for i in range(pairs):
+ for side in ("base", "treatment"):
+ windowed = side == "treatment"
+ rows.append(
+ _action(
+ "select_text",
+ f"r100K.{side}.rep{i}",
+ parity = _capture(mounted = 9 if windowed else 18, total = 18),
+ visible = _visible([1], [1], digest = "shipped") if i == 0 else None,
+ expect = {"selected_chars": 100, "visible_chars": 100},
+ )
+ )
+ return _write(tmp_path, name, rows)
+
+
+def test_behavioural_coverage_does_not_stand_in_for_visible_coverage(tmp_path, capsys):
+ """THE SUBSTITUTION. The floor unioned the two windowed modes' compared sets.
+
+ They are not two slices of one film. Under `--mode auto` they are two verdicts on the SAME
+ pairs, so the union let one stand in for the other: behavioural mode reaching every pair while
+ the visible capture could be read on only ONE still filled the set, cleared the floor, and
+ exited 0 with essentially the whole appearance surface unmeasured. That is the same false green
+ the floor exists to refuse, arriving through the floor itself.
+
+ Four pairs here, all of them behaviourally checked, one of them visible. A floor of 4 has to
+ fire, and the count has to be the visible one.
+ """
+ from studiobench.sweep import ui_parity as U
+
+ _windowed_shard_visible_only_on_one(tmp_path, "winsub", pairs = 4)
+ code = U.main([str(tmp_path / "winsub"), "--min-compared", "4"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" in out, out
+ assert "1 of 4 pair(s) carry a verdict" in out, out
+ assert code == 3, out
+
+
+def test_a_pair_behavioural_mode_declares_no_invariant_for_is_not_a_shortfall(tmp_path, capsys):
+ """THE OTHER DIRECTION, and the reason this is not an intersection.
+
+ A behavioural invariant only exists for the handful of actions that declare one; every other
+ pair is reported UNCHECKED, which is not a pass and equally not a coverage shortfall. Requiring
+ both verdicts on every pair therefore fails a run for pairs behavioural mode never had an
+ opinion about -- measured at 1 of 4 on this very fixture, where visible mode read all four.
+ """
+ from studiobench.sweep import ui_parity as U
+
+ _windowed_only_shard(tmp_path, "winunchecked", pairs = 4)
+ code = U.main([str(tmp_path / "winunchecked"), "--min-compared", "4"])
+ out = capsys.readouterr().out
+ assert "UNCHECKED: 3" in out, out
+ assert "TOO LITTLE COMPARED" not in out, out
+ assert code == 0, out
+
+
+def test_the_coverage_floor_applies_to_a_run_with_no_fully_mounted_pair(tmp_path, capsys):
+ """THE HOLE. `--min-compared` was a parameter of `report()` and enforced at one site inside it,
+ and `report()` is reached only from the structural loop BELOW `main`'s early return. A payload
+ whose every pair is a windowed mount returns before that loop, so the floor was never applied
+ to anything: `--min-compared 20` exited 0 having compared one pair.
+
+ That floor is what replaces a slot-budget liveness gate for a job that reads no timings, and
+ two blank pages have identical digests, so it is the guard against the easiest false green
+ there is. The workflow passes `--min-compared 16` on every run.
+ """
+ from studiobench.sweep import ui_parity as U
+
+ _windowed_only_shard(tmp_path, "winonly", pairs = 1)
+ code = U.main([str(tmp_path / "winonly"), "--min-compared", "20"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" in out, out
+ assert "below the floor of 20" in out, out
+ assert code == 3, out
+
+
+def test_the_coverage_floor_passes_a_windowed_run_that_compared_enough(tmp_path, capsys):
+ """THE POSITIVE CONTROL, and it is the half that matters most here: a floor that fires on
+ everything is not a floor. The same shape as above with the floor set beneath what the run
+ actually compared has to come out 0, or the test above would pass against a `return 3`."""
+ from studiobench.sweep import ui_parity as U
+
+ _windowed_only_shard(tmp_path, "winenough", pairs = 4)
+ code = U.main([str(tmp_path / "winenough"), "--min-compared", "4"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" not in out, out
+ assert code == 0, out
+
+
+def test_the_behaviour_policy_prints_the_coverage_band_it_actually_enforces(tmp_path, capsys):
+ """The printed policy said the copy must be "complete", which reads as a content comparison.
+
+ It is a LENGTH: each arm's clipboard over the thread's own visible text, inside a band. That
+ band is the whole strength of the claim -- it is what refused truncation at 0.61 and
+ substitution at 2.16 -- so the sentence has to carry the live numbers rather than a pair
+ somebody typed once. The needle here is DERIVED from the constants, so widening the band
+ without touching the wording is caught, and so is a sentence that stopped interpolating.
+ """
+ from studiobench.sweep import ui_parity as U
+
+ band = P.behaviour_policy(B.MIN_CLIPBOARD_COVERAGE, B.MAX_CLIPBOARD_COVERAGE)
+ assert f"{B.MIN_CLIPBOARD_COVERAGE}-{B.MAX_CLIPBOARD_COVERAGE}" in band, band
+
+ # A different band has to travel through as well: a hard-coded sentence would pass the
+ # assertion above by coincidence and fail this one.
+ other = P.behaviour_policy(0.5, 2.0)
+ assert "0.5-2.0" in other, other
+ assert f"{B.MIN_CLIPBOARD_COVERAGE}-{B.MAX_CLIPBOARD_COVERAGE}" not in other, other
+
+ # And the report has to be wired to it, not merely able to produce it.
+ _mixed_rung_shard(tmp_path, "banner")
+ U.main([str(tmp_path / "banner"), "--mode", "behaviour", "--min-compared", "0"])
+ out = capsys.readouterr().out
+ assert f"{B.MIN_CLIPBOARD_COVERAGE}-{B.MAX_CLIPBOARD_COVERAGE}" in out, out
+
+
+def test_the_coverage_floor_is_applied_under_forced_visible_and_behaviour_modes(tmp_path, capsys):
+ """The other route to an empty structural plan, and it does not need a windowed payload at all.
+ `--mode visible` and `--mode behaviour` hard-set `structural` to an empty set for EVERY
+ pattern, unconditionally, so under either of them the floor could never be applied to any
+ payload whatsoever."""
+ from studiobench.sweep import ui_parity as U
+
+ _mixed_rung_shard(tmp_path, "forced")
+ for mode in ("visible", "behaviour"):
+ code = U.main([str(tmp_path / "forced"), "--mode", mode, "--min-compared", "50"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" in out, (mode, out)
+ assert code == 3, (mode, out)
+
+
+def test_the_coverage_floor_sums_the_windowed_and_structural_halves(tmp_path, capsys):
+ """SUMMED, NOT CHECKED SEPARATELY. A combined run splits one film's coverage across three
+ reports, and a floor applied inside each of them separately fails a run that compared plenty:
+ the structural half here compares 1 pair and the windowed half 1, and a floor of 2 is cleared
+ by the run and by neither half alone.
+
+ The `--mode auto` pair is scored TWICE, once on the visible region and once on the invariants,
+ and it still counts once: summing the two reports' counts would double every windowed pair and
+ let a floor of 2 pass on 1."""
+ from studiobench.sweep import ui_parity as U
+
+ _mixed_rung_shard(tmp_path, "sums")
+ code = U.main([str(tmp_path / "sums"), "--min-compared", "2"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" not in out, out
+ # 1 is the digest regression the fixture carries at the 1K rung, so the floor did not mask it.
+ assert code == 1, out
+ # And one more than the run can reach refuses it, which is what proves the count above is 2
+ # rather than the 3 a sum of the three reports would have produced.
+ code = U.main([str(tmp_path / "sums"), "--min-compared", "3"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED: 2 of 2" in out, out
+ assert code == 3, out
+
+
+def test_the_coverage_floor_is_checked_per_payload_pattern(tmp_path, capsys):
+ """PER FILM, not per invocation. The three modes are one film's coverage split three ways, so
+ they are unioned; two positional payloads are two films, and pooling those lets each satisfy
+ the other's floor. `ui_parity normal_run windowed_run` is a supported invocation -- the mode
+ decision above already says why per-invocation was too coarse for it -- so a nearly empty or
+ failed film could be carried over the floor by an unrelated one on the same command line.
+
+ Two films of 2 pairs each against a floor of 4: pooled they clear it, and neither one did."""
+ from studiobench.sweep import ui_parity as U
+
+ _windowed_only_shard(tmp_path, "filmA", pairs = 2)
+ _windowed_only_shard(tmp_path, "filmB", pairs = 2)
+ code = U.main([str(tmp_path / "filmA"), str(tmp_path / "filmB"), "--min-compared", "4"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" in out, out
+ assert out.count("TOO LITTLE COMPARED") == 2, out
+ assert "filmA" in out and "filmB" in out, out
+ assert code == 3, out
+
+
+def test_a_floor_each_film_clears_on_its_own_still_passes(tmp_path, capsys):
+ """THE POSITIVE CONTROL for the one above: per-pattern must not mean every multi-payload run
+ fails. Two films of 2 pairs each against a floor of 2 is 0, or the test above would pass
+ against an unconditional `return 3`."""
+ from studiobench.sweep import ui_parity as U
+
+ _windowed_only_shard(tmp_path, "filmA", pairs = 2)
+ _windowed_only_shard(tmp_path, "filmB", pairs = 2)
+ code = U.main([str(tmp_path / "filmA"), str(tmp_path / "filmB"), "--min-compared", "2"])
+ out = capsys.readouterr().out
+ assert "TOO LITTLE COMPARED" not in out, out
+ assert code == 0, out
+
+
+# ── a build difference the capture comparison cannot see ─────
+
+
+def test_an_assertion_that_failed_on_one_arm_fails_the_windowed_verdict(tmp_path, capsys):
+ """`stop_generation` returns `ran = True, expect_ok = stopped_ms is not None`, so a head on
+ which Stop no longer ends the stream records a perfectly ordinary row with two viewports that
+ look the same. The visible and behavioural paths built their whole result from a capture
+ comparison plus one boolean -- the conjunction of `ran` -- so that shape left no trace at all,
+ and on a windowed arm those two reports ARE the UI verdict: the digest is not applicable by
+ construction and `stop_generation` has no behavioural invariant of its own, so a passing
+ invariant on some other action carried the run to exit 0."""
+ from studiobench.sweep import ui_parity as U
+
+ rows = []
+ for side in ("base", "treatment"):
+ windowed = side == "treatment"
+ mounted = 9 if windowed else 18
+ # A held invariant on another action, which is what used to carry the run to a pass.
+ rows.append(
+ _action(
+ "select_text",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = mounted, total = 18),
+ visible = _visible([1], [1]),
+ expect = {"selected_chars": 100, "visible_chars": 100},
+ )
+ )
+ stop = _action(
+ "stop_generation",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = mounted, total = 18),
+ visible = _visible([1], [1]),
+ )
+ if windowed:
+ stop["expect_ok"] = False
+ stop["reason"] = "the stream did not stop"
+ rows.append(stop)
+ _write(tmp_path, "assertion", rows)
+
+ code = U.main([str(tmp_path / "assertion")])
+ out = capsys.readouterr().out
+ assert "ASSERTION FAILED ON ONE ARM" in out, out
+ assert "stop_generation" in out.split("ASSERTION FAILED ON ONE ARM")[1], out
+ assert code == 1, out
+
+
+def test_an_assertion_that_failed_on_BOTH_arms_is_not_a_build_difference(tmp_path, capsys):
+ """THE CONTROL, and it is the reason the signal is an ASYMMETRY rather than a failure count.
+ Both arms failing means the fixture cannot reach the state on either build -- coverage lost,
+ not a difference between the builds -- and refusing on it would red every run whose scene
+ cannot reach `stop_generation` at all."""
+ from studiobench.sweep import ui_parity as U
+
+ rows = []
+ for side in ("base", "treatment"):
+ windowed = side == "treatment"
+ rows.append(
+ _action(
+ "select_text",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = 9 if windowed else 18, total = 18),
+ visible = _visible([1], [1]),
+ expect = {"selected_chars": 100, "visible_chars": 100},
+ )
+ )
+ stop = _action(
+ "stop_generation",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = 9 if windowed else 18, total = 18),
+ visible = _visible([1], [1]),
+ )
+ stop["expect_ok"] = False
+ stop["reason"] = "the stop button is not present"
+ rows.append(stop)
+ _write(tmp_path, "sym", rows)
+
+ code = U.main([str(tmp_path / "sym")])
+ out = capsys.readouterr().out
+ assert "ASSERTION FAILED ON ONE ARM" not in out, out
+ assert code == 0, out
+
+
+def test_an_action_that_could_not_be_performed_on_one_arm_fails_the_windowed_verdict(
+ tmp_path, capsys
+):
+ """The other shape a capture comparison erases. An action that RUNS on one build and cannot be
+ performed on the other is the one regression class that leaves no digest to differ -- a control
+ that stopped opening records exactly this -- and both windowed reports filed it under NOT
+ EXERCISED, which each of them counts as lost coverage rather than as a finding."""
+ from studiobench.sweep import ui_parity as U
+
+ rows = []
+ for side in ("base", "treatment"):
+ windowed = side == "treatment"
+ mounted = 9 if windowed else 18
+ rows.append(
+ _action(
+ "select_text",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = mounted, total = 18),
+ visible = _visible([1], [1]),
+ expect = {"selected_chars": 100, "visible_chars": 100},
+ )
+ )
+ rows.append(
+ _action(
+ "message_menu",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = mounted, total = 18),
+ visible = _visible([1], [1]),
+ ran = not windowed,
+ reason = "no message menu control on the page" if windowed else None,
+ )
+ )
+ _write(tmp_path, "onesided", rows)
+
+ code = U.main([str(tmp_path / "onesided")])
+ out = capsys.readouterr().out
+ assert "RAN ON ONE ARM ONLY" in out, out
+ assert code == 1, out
+
+
+def test_a_slot_the_runner_arrived_too_late_for_is_still_not_a_build_difference(tmp_path, capsys):
+ """THE CONTROL FOR THE ONE ABOVE, and it is the load-bearing half of `one_sided`. A missed slot
+ is a slow machine and cannot move this verdict: the misses are correlated through the runner
+ rather than being independent draws, so corroboration cannot separate them and reding on them
+ would fail the job on machine speed."""
+ from studiobench.sweep import ui_parity as U
+
+ rows = []
+ for side in ("base", "treatment"):
+ windowed = side == "treatment"
+ mounted = 9 if windowed else 18
+ rows.append(
+ _action(
+ "select_text",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = mounted, total = 18),
+ visible = _visible([1], [1]),
+ expect = {"selected_chars": 100, "visible_chars": 100},
+ )
+ )
+ row = _action(
+ "message_menu",
+ f"r100K.{side}.rep0",
+ parity = _capture(mounted = mounted, total = 18),
+ visible = _visible([1], [1]),
+ ran = not windowed,
+ reason = "the slot closed before the runner reached it" if windowed else None,
+ )
+ if windowed:
+ row["slot_missed"] = True
+ rows.append(row)
+ _write(tmp_path, "missed", rows)
+
+ code = U.main([str(tmp_path / "missed")])
+ out = capsys.readouterr().out
+ assert "RAN ON ONE ARM ONLY" not in out, out
+ assert code == 0, out
diff --git a/tests/studio/studiobench/sweep/ui_parity.py b/tests/studio/studiobench/sweep/ui_parity.py
index c2475978b14..fa2788179ca 100644
--- a/tests/studio/studiobench/sweep/ui_parity.py
+++ b/tests/studio/studiobench/sweep/ui_parity.py
@@ -138,6 +138,104 @@ STRUCTURAL = "structural"
ARMS = ("base", "treatment")
+class Outcome(int):
+ """An exit code that carries WHICH PAIRS it was reached over.
+
+ `--min-compared` used to be a parameter of `report()` alone, and `report()` sits below `main`'s
+ structural early return. A run with no fully mounted pair -- every pair windowed, or a forced
+ `--mode visible` / `--mode behaviour` -- therefore applied no coverage floor at all, and the
+ workflow's `--min-compared 16` passed on one matched capture. Two blank pages have identical
+ digests, so that floor is the guard against the easiest possible false green.
+
+ AN `int` SUBCLASS, DELIBERATELY. PLEASE DO NOT SIMPLIFY THIS BACK TO A PLAIN RETURN. `main` does
+ `worst = max(worst, ...)` and the selftests assert `== 0`/`== 1`/`== 2`/`== 3` directly against
+ `report`, `visible_report` and `behaviour_report` in several dozen places. A tuple or dataclass
+ would mean rewriting all of those in bulk to say what they already say, and this change is
+ precisely about a gate nobody re-derived.
+
+ PAIR KEYS RATHER THAN A COUNT: `--mode auto` scores the same windowed pairs on the visible
+ region AND on the invariants, so summing would double them and let a floor of 16 pass on 8.
+
+ The key is `(action, shard, cell)`. `latest_attempt_rows` has already reduced a cell to one
+ attempt by the time `collect` builds these, so the session term dropped from `cell` cannot merge
+ two live observations; if it ever did, the union would UNDER-count, which is a loud false red
+ rather than a quiet false green.
+ """
+
+ compared: frozenset[tuple[str, str, str]]
+ seen: frozenset[tuple[str, str, str]]
+
+ def __new__(
+ cls,
+ rc: int,
+ compared: frozenset[tuple[str, str, str]] = frozenset(),
+ seen: frozenset[tuple[str, str, str]] = frozenset(),
+ ) -> "Outcome":
+ self = super().__new__(cls, rc)
+ self.compared = compared
+ self.seen = seen
+ return self
+
+ @property
+ def total(self) -> int:
+ """Pairs this report was offered, compared or not: the floor message's denominator."""
+ return len(self.seen)
+
+
+def _floored(
+ worst: int, compared: dict[str, set[tuple]], seen: dict[str, set[tuple]], min_compared: int
+) -> int:
+ """`main`'s application of the coverage floor, once per payload pattern it scored.
+
+ UNIONED ACROSS MODES, not checked per mode. One film's coverage is split three ways -- visible
+ region, invariants, structural digest -- and a floor applied inside each report separately fails
+ a run that compared plenty. `Outcome` says why the pairs are unioned rather than added.
+
+ PER PATTERN, not per invocation, and that is the other half of the same rule. The three modes
+ are one film seen three ways; two positional payloads are two films. Pooling those lets each
+ satisfy the other's floor, so two payloads comparing 8 pairs apiece cleared `--min-compared 16`
+ and a nearly empty film was hidden by coverage from an unrelated one on the same command line.
+ `ui_parity normal_run windowed_run` is a supported invocation -- see the mode decision, which
+ already rejected per-invocation as too coarse for exactly this shape.
+
+ RAISED, NEVER LOWERED. A shortfall can only make the verdict worse: a run that already found a
+ difference keeps that finding and gains the reason its coverage is too thin to trust either way.
+ """
+ for pattern in sorted(compared):
+ shortfall = coverage_shortfall(
+ len(compared[pattern]), len(seen.get(pattern) or ()), min_compared
+ )
+ if not shortfall:
+ continue
+ print(f"\n {pattern}: {shortfall}")
+ worst = max(worst, 3)
+ return worst
+
+
+def _keys(results: list[tuple]) -> frozenset[tuple[str, str, str]]:
+ """The `(action, shard, cell)` key of every pair a report was offered. See `Outcome`."""
+ return frozenset((action, shard, cell) for action, shard, cell, _r in results)
+
+
+def coverage_shortfall(scored: int, of_pairs: int, min_compared: int) -> str:
+ """The TOO LITTLE COMPARED message, or `""`. One rule, one wording, three call sites.
+
+ NOT a detection threshold. This is the "did the film actually run" floor, and it is the
+ thing that replaces a slot-budget liveness gate for a job that reads no timings: a
+ missed slot costs COVERAGE, and coverage is what has to be defended, not punctuality.
+ Healthy runs measured here compared 22, 25 and 26 of 32 scheduled pairs; a payload
+ mutated until 24 slots were missed compared 9 and still produced a correct verdict, so
+ the floor sits between "lost some to a slow machine" and "did not run the film".
+ """
+ if not min_compared or scored >= min_compared:
+ return ""
+ return (
+ f"TOO LITTLE COMPARED: {scored} of {of_pairs} pair(s) carry a verdict, "
+ f"below the floor of {min_compared}. A run that compared almost nothing passes"
+ f"\n trivially, and this is that run. Nothing below is a pass."
+ )
+
+
def rows(path: Path) -> list[dict]:
return [
json.loads(line) for line in path.read_text(encoding = "utf-8").splitlines() if line.strip()
@@ -546,12 +644,91 @@ def any_windowed(paths: list[Path]) -> Optional[str]:
return None
+def build_differences(results: list[tuple], min_reps: int) -> dict[str, list[tuple]]:
+ """The two shapes that are a difference between the BUILDS and leave no capture to differ.
+
+ Shared by `visible_report` and `behaviour_report` so the windowed verdict cannot come to a
+ different opinion in its two halves, and held to exactly the bar `report` holds the structural
+ path to: `racy_execution` exempts the not-run reasons that are a lost race rather than a missing
+ control, and `corroborated` demands the same repetition count, keyed on the arm the finding
+ names so two repetitions blaming opposite arms cannot corroborate each other.
+
+ Not folded into the visible or behavioural verdict itself. A digest or an invariant that agrees
+ is a true statement about what was on screen; that it was reached on a build where the button no
+ longer works is a second, separate statement, and merging them would let the noise floor
+ measured for one silence the other.
+ """
+ one_sided: list[tuple] = []
+ racy: list[tuple] = []
+ expect_bad: list[tuple] = []
+ for action, shard, cell, r in results:
+ if r.get("one_sided"):
+ entry = (action, shard, cell, [r.get("idle_detail") or ""], r["one_sided"])
+ # ON THE RECORDED REASON, not the action name; see the same call in `report`.
+ if P.racy_execution(action, r.get("idle_reason") or ""):
+ racy.append(entry)
+ else:
+ one_sided.append(entry)
+ if r.get("expect_regressed"):
+ expect_bad.append(
+ (action, shard, cell, [r.get("expect_reason") or ""], r["expect_regressed"])
+ )
+ firm_one, weak_one = corroborated(one_sided, min_reps)
+ firm_expect, weak_expect = corroborated(expect_bad, min_reps)
+ return {
+ "one_sided": firm_one,
+ "one_sided_weak": weak_one,
+ "one_sided_racy": racy,
+ "expect": firm_expect,
+ "expect_weak": weak_expect,
+ }
+
+
+def print_build_differences(found: dict[str, list[tuple]], min_reps: int) -> bool:
+ """Print what `build_differences` found; True when something in it fails the run."""
+ if found["one_sided"]:
+ print(
+ "\n RAN ON ONE ARM ONLY -- the action could be performed on one build and not the"
+ "\n other, which is the two builds behaving differently and leaves no capture to"
+ "\n differ:"
+ )
+ for action, shard, cell, why, *_dir in found["one_sided"]:
+ print(f" {action:<26} {shard} {cell}: {why[0]}")
+ if found["expect"]:
+ print(
+ "\n THE ACTION'S OWN ASSERTION FAILED ON ONE ARM -- it ran on both and did its job"
+ "\n on only one, in every repetition. The captures can agree and still be a reading"
+ "\n of a control that stopped working:"
+ )
+ for action, shard, cell, why, *_dir in found["expect"]:
+ print(f" {action:<26} {shard} {cell}: {why[0]}")
+ for key, what in (
+ ("one_sided_weak", "one-arm execution"),
+ ("expect_weak", "assertion failure"),
+ ):
+ if found[key]:
+ print(
+ f"\n UNCORROBORATED {what} -- in fewer than {min_reps} repetitions, or on "
+ f"opposite arms;\n reported, not counted:"
+ )
+ for action, shard, cell, why, *_dir in found[key]:
+ print(f" {action:<26} {shard} {cell}: {why[0]}")
+ if found["one_sided_racy"]:
+ names = sorted({a for a, _s, _c, _w, *_d in found["one_sided_racy"]})
+ print(
+ f"\n (reported, not counted) {len(found['one_sided_racy'])} one-arm execution(s) whose "
+ f"recorded reason is a lost race rather than a missing control: {', '.join(names)}"
+ )
+ return bool(found["one_sided"] or found["expect"])
+
+
def behaviour_report(
paths: list[Path],
label: str,
windowed: bool = True,
select: Optional[set] = None,
-) -> int:
+ min_reps: int = 1,
+) -> Outcome:
"""The windowed arm's report: behavioural invariants instead of a structural digest.
Printed with the reason it is being printed, every time. The one way this could mislead is by
@@ -585,13 +762,26 @@ def behaviour_report(
(action, shard, cell, {"verdict": P.NOT_COMPARABLE, "reason": why, "checks": []})
)
continue
- results.append(
- (action, shard, cell, B.compare_behaviour(sides["base"], sides["treatment"]))
+ out = B.compare_behaviour(sides["base"], sides["treatment"])
+ # THE SAME TWO QUESTIONS THE STRUCTURAL PATH ASKS, off the same functions; see
+ # `compare_all_with`. `compare_behaviour` cannot see either shape: an action not performed
+ # on one arm records no quantities to disagree about, and one that ran and failed its own
+ # assertion records perfectly ordinary ones.
+ idle_ = P.execution_verdict(sides["base"], sides["treatment"])
+ out["one_sided"] = (idle_ or {}).get("one_sided") or ""
+ out["idle_reason"] = (idle_ or {}).get("idle_reason") or ""
+ out["idle_detail"] = (idle_ or {}).get("reason") or ""
+ out["expect_regressed"], out["expect_reason"] = P.expect_regression(
+ sides["base"], sides["treatment"]
)
+ results.append((action, shard, cell, out))
print(f"\n{label} (BEHAVIOURAL MODE)")
print(f" CLAIM: {P.CLAIM_BEHAVIOURAL}.")
- print(f" POLICY: {P.POLICY_BY_MODE['behaviour']}.")
+ # Through the helper, not straight off the table: this mode's line names the coverage band it
+ # enforces, and the band lives in `behaviour`. Printing the raw template would emit the
+ # placeholders themselves and quietly stop reporting the numbers being applied.
+ print(f" POLICY: {P.behaviour_policy(B.MIN_CLIPBOARD_COVERAGE, B.MAX_CLIPBOARD_COVERAGE)}.")
# WHICH REASON, and only if it is true. Forced behavioural mode on a payload that mounts its
# whole thread -- which is exactly how a NULL CONTROL is scored on the same scale as the
# windowed arm it is the control for -- used to print "one arm of this payload mounts a window
@@ -616,22 +806,26 @@ def behaviour_report(
)
if not results:
print(" NO ACTION DATA in this payload.")
- return 2
+ return Outcome(2)
broken, unchecked, idle, blind = [], [], [], []
+ compared: set[tuple[str, str, str]] = set()
matched = 0
for action, shard, cell, r in results:
verdict = r["verdict"]
if verdict == B.BROKEN:
broken.append((action, shard, cell, r))
+ compared.add((action, shard, cell))
elif verdict == P.MATCH:
matched += 1
+ compared.add((action, shard, cell))
elif verdict == P.NOT_EXERCISED:
idle.append((action, shard, cell, r))
elif verdict == P.NOT_COMPARABLE:
blind.append((action, shard, cell, r))
else:
unchecked.append((action, shard, cell, r))
+ found = build_differences(results, min_reps)
print(f"\n {len(results)} action pairs across {len(paths)} shard(s)")
print(f" invariants held: {matched}")
@@ -646,6 +840,7 @@ def behaviour_report(
print(f" {action:<26} {shard} {cell}: {r['reason']}")
else:
print("\n Every declared behavioural invariant held on both arms.")
+ build_failed = print_build_differences(found, min_reps)
if unchecked:
names = sorted({a for a, _s, _c, _v in unchecked})
@@ -663,9 +858,21 @@ def behaviour_report(
names = sorted({a for a, _s, _c, _v in idle})
print(f"\n NOT EXERCISED: {', '.join(names)}")
- if broken:
- return 1
- if matched == 0:
+ # `not broken` IS THE PRECONDITION THE PARAGRAPH BELOW ARGUES FROM, and it used to be assumed
+ # rather than checked. An all-BROKEN payload reaches `matched == 0` too -- the two counters are
+ # independent -- so a run that had just listed its broken invariants went on to say that not
+ # one invariant was evaluated and that it carried no failure, immediately before returning 1.
+ # The artifact contradicted its own results and sent the reader off to find out why actions
+ # that had run did not run. `report` (`elif decided == 0`) and `visible_report` (`and not
+ # differing`) both already gate this banner on their own failure bucket; this is that gate.
+ #
+ # NOT GATED ON `build_failed`, which is the other half of the return condition and is NOT the
+ # same case: those two shapes are collected from pairs whose invariants were unreadable, so
+ # "not one behavioural invariant was evaluated" stays literally true when one fires, and the
+ # run is a failure for a directional reason rather than an invariant one. See
+ # `test_a_timed_out_rebuild_leaves_the_behavioural_run_with_no_verdict`, which asserts exactly
+ # that pairing -- NOTHING WAS COMPARED together with exit 1 -- on purpose.
+ if matched == 0 and not broken:
# NOTHING WAS VALIDATED, which is not the same as nothing being wrong. With every pair
# unchecked, not comparable or never exercised, `broken` is empty and the block above has
# just printed "Every declared behavioural invariant held on both arms" -- a sentence that
@@ -678,8 +885,14 @@ def behaviour_report(
"so this run carries no UI verdict -- neither a pass nor a failure. Treat it as an "
"absent result and find out why the actions did not run."
)
- return 2
- return 0
+ # AFTER the diagnosis prints and BEFORE the "could not tell" code, the ordering `report` states:
+ # a run can find a real regression while deciding nothing (the two shapes `build_differences`
+ # collects survive a pair whose invariants were unreadable), and "it failed" is more specific.
+ if broken or build_failed:
+ return Outcome(1, frozenset(compared), _keys(results))
+ if matched == 0:
+ return Outcome(2, frozenset(compared), _keys(results))
+ return Outcome(0, frozenset(compared), _keys(results))
def visible_unstable_set(null_paths: list[Path] | None) -> frozenset[tuple[str, str]]:
@@ -751,7 +964,8 @@ def visible_report(
label: str,
unstable: frozenset[tuple[str, str]] = frozenset(),
select: Optional[set] = None,
-) -> int:
+ min_reps: int = 1,
+) -> Outcome:
"""VISIBLE-REGION PARITY. The verdict the off-screen exemption asks for.
Policy: all changes preserve UI and UX idempotency, except that a difference may be accepted
@@ -775,8 +989,10 @@ def visible_report(
)
if not results:
print(" NO ACTION DATA in this payload.")
- return 2
+ return Outcome(2)
+ found = build_differences(results, min_reps)
+ compared: set[tuple[str, str, str]] = set()
differing, unstable_bad, blind, idle, matched = [], [], [], [], 0
# THE RESIDUE, PRINTED. A message that was on screen during the action and had been unmounted
# again by the time the capture ran cannot be digested, and `compare_visible` refuses the pair
@@ -802,8 +1018,10 @@ def visible_report(
# and the film's slots land somewhere else entirely.
noise = (rung_of_cell(cell), action) in unstable and not r.get("severe")
(unstable_bad if noise else differing).append((action, shard, cell, r))
+ compared.add((action, shard, cell))
else:
matched += 1
+ compared.add((action, shard, cell))
print(f"\n {len(results)} action pairs across {len(paths)} shard(s)")
print(f" visible region matched: {matched}")
@@ -871,17 +1089,22 @@ def visible_report(
+ (f", and {len(keys) - 12} more" if len(keys) > 12 else "")
)
- if differing:
- return 1
- if matched == 0:
+ build_failed = print_build_differences(found, min_reps)
+
+ if matched == 0 and not differing:
# The same false green every other mode here has already been fixed for: nothing compared
# is not the same as nothing wrong, and it must not exit 0.
print(
"\n NOTHING WAS COMPARED. Not one action pair yielded a visible-region verdict, so\n"
" this run carries no UI verdict at all -- neither a pass nor a failure."
)
- return 2
- return 0
+ # See the same three lines in `behaviour_report` and in `report`: the diagnosis prints, then a
+ # failure outranks a refusal.
+ if differing or build_failed:
+ return Outcome(1, frozenset(compared), _keys(results))
+ if matched == 0:
+ return Outcome(2, frozenset(compared), _keys(results))
+ return Outcome(0, frozenset(compared), _keys(results))
def compare_all_with(
@@ -895,6 +1118,20 @@ def compare_all_with(
`require_complete` drops the action rows of a cell that never wrote its terminal `cell` row;
see `collect`, which states why that is right on a null control and wrong on a result.
+
+ THE ACTION'S OUTCOME TRAVELS WITH ITS CAPTURE, and it did not use to: this path built its result
+ from `compare()` plus one boolean, `_ran`, so the two shapes that are a difference between the
+ BUILDS rather than between two DOMs were erased before any report saw them. An action performed
+ on one arm only collapsed into the same "did not run" bucket as a missed slot, which counts as
+ lost coverage and not as a finding; an action that ran on both and failed its OWN assertion on
+ one -- `stop_generation` on a head where Stop no longer ends the stream -- left no trace, the two
+ viewports looking the same.
+
+ Survivable on the structural path, where `compare_rows` has always asked both questions. Not
+ here: on a windowed arm THESE reports are the entire UI verdict, the digest being
+ `not_applicable` by construction and `stop_generation` having no behavioural invariant, so in
+ `--mode auto` a passing invariant on some other action carried the run to exit 0. Both questions
+ now go to `analysis/parity.py`'s own functions, the ones `compare_rows` calls.
"""
got = collect(paths, select, require_complete = require_complete)
results = []
@@ -929,6 +1166,15 @@ def compare_all_with(
ran = bool(sides["base"].get("ran")) and bool(sides["treatment"].get("ran"))
out = compare(sides["base"].get(key), sides["treatment"].get(key))
out["_ran"] = ran
+ idle = P.execution_verdict(sides["base"], sides["treatment"])
+ # WHICH ARM, not merely that one of them was idle. `execution_verdict` returns `one_sided`
+ # empty for a missed slot and for the symmetric case, and the arm that DID run otherwise.
+ out["one_sided"] = (idle or {}).get("one_sided") or ""
+ out["idle_reason"] = (idle or {}).get("idle_reason") or ""
+ out["idle_detail"] = (idle or {}).get("reason") or ""
+ out["expect_regressed"], out["expect_reason"] = P.expect_regression(
+ sides["base"], sides["treatment"]
+ )
results.append((action, shard, cell, out))
return results, got
@@ -1445,7 +1691,7 @@ def report(
select: Optional[set] = None,
min_reps: int = 1,
min_compared: int = 0,
-) -> int:
+) -> Outcome:
"""THREAD-STRUCTURE PARITY. `select` scores only those pair keys; see `decide_modes`.
`unstable` holds both kinds of entry `is_unstable` reads: a bare action name, which is a
@@ -1464,12 +1710,13 @@ def report(
f"{got['missing']} action rows carried no digest. "
f"Was this run recorded before the parity instrument existed?"
)
- return 2
+ return Outcome(2)
stable_bad, unstable_bad, blind, style_bad, idle = [], [], [], [], []
inapplicable: list[tuple] = []
one_sided, one_sided_unstable = [], []
expect_bad = []
+ compared: set[tuple[str, str, str]] = set()
matched = 0
for action, shard, cell, r in results:
# COLLECTED BEFORE THE VERDICT BRANCHES AND OUTSIDE THE EXEMPTION, because it is not a
@@ -1536,8 +1783,10 @@ def report(
style_bad.append((action, shard, cell, [r.get("style_reason", "")]))
if r["verdict"] == P.MATCH:
matched += 1
+ compared.add((action, shard, cell))
continue
entry = (action, shard, cell, r["moved"])
+ compared.add((action, shard, cell))
(unstable_bad if is_unstable(unstable, action, cell) else stable_bad).append(entry)
# SPLIT BEFORE THE COUNTS ARE PRINTED. Printing "stable actions differing: 1" above a verdict
@@ -1599,20 +1848,16 @@ def report(
f"pointer-events)"
)
+ # THE SAME SET, COUNTED TWICE, checked rather than assumed: `compared` is what the coverage
+ # floor is applied to, `scored` is the count this report has always printed, and `stable_bad`
+ # splits into itself plus `uncorroborated` above. The assert is here so a later edit to either
+ # branch cannot make the floor answer about a different set than the summary does.
scored = matched + len(stable_bad) + len(uncorroborated) + len(unstable_bad)
- if min_compared and scored < min_compared:
- # NOT a detection threshold. This is the "did the film actually run" floor, and it is the
- # thing that replaces a slot-budget liveness gate for a job that reads no timings: a
- # missed slot costs COVERAGE, and coverage is what has to be defended, not punctuality.
- # Healthy runs measured here compared 22, 25 and 26 of 32 scheduled pairs; a payload
- # mutated until 24 slots were missed compared 9 and still produced a correct verdict, so
- # the floor sits between "lost some to a slow machine" and "did not run the film".
- print(
- f"\n TOO LITTLE COMPARED: {scored} of {len(results)} pair(s) carry a verdict, "
- f"below the floor of {min_compared}. A run that compared almost nothing passes"
- f"\n trivially, and this is that run. Nothing below is a pass."
- )
- return 3
+ assert len(compared) == scored, (len(compared), scored)
+ shortfall = coverage_shortfall(scored, len(results), min_compared)
+ if shortfall:
+ print(f"\n {shortfall}")
+ return Outcome(3, frozenset(compared), _keys(results))
if expect_bad:
print(
@@ -1737,7 +1982,7 @@ def report(
# joins them for the reason given where it is collected: an assertion that failed on one arm
# only is the two builds behaving differently, and it is the one shape a digest cannot show.
if stable_bad or one_sided or expect_bad:
- return 1
+ return Outcome(1, frozenset(compared), _keys(results))
# 2, the same code the empty-payload path uses, and for the same reason: the tool was asked a
# question it could not answer. Exiting 0 here would let CI go green on a run where the parity
# check was structurally incapable of firing -- whether because every pair was a windowed mount
@@ -1747,8 +1992,8 @@ def report(
# nothing -- `expect_bad` is collected ahead of the verdict branches and survives a pair that
# `continue`s -- and "it failed" is the more specific answer than "it could not tell".
if decided == 0:
- return 2
- return 0
+ return Outcome(2, frozenset(compared), _keys(results))
+ return Outcome(0, frozenset(compared), _keys(results))
def tier_of(paths: list[Path]) -> set[str]:
@@ -2018,6 +2263,17 @@ def main(argv: list[str] | None = None) -> int:
worst = 0
scored_windowed = 0
+ # THE COVERAGE FLOOR'S OWN BOOKKEEPING, kept per payload pattern and across every mode that
+ # pattern was scored in. A SET rather than a running total because `--mode auto` scores each
+ # windowed pair twice, once on the visible region and once on the invariants; see `Outcome`.
+ # Keyed by pattern because the floor is a question about one film; see `_floored`.
+ compared_pairs: dict[str, set[tuple]] = {}
+ seen_pairs: dict[str, set[tuple]] = {}
+
+ def note(pattern: str, out: "Outcome") -> None:
+ compared_pairs.setdefault(pattern, set()).update(out.compared)
+ seen_pairs.setdefault(pattern, set()).update(out.seen)
+
vis_unstable: Optional[frozenset[tuple[str, str]]] = None
vis_null_tiers: set[str] = set()
vis_null_corpora: set[str] = set()
@@ -2045,6 +2301,10 @@ def main(argv: list[str] | None = None) -> int:
if len(win) > 8:
print(f" ... and {len(win) - 8} more windowed pair(s)")
scored_windowed += len(win)
+ # Per pattern, and reset here rather than outside the loop: two payload patterns are two
+ # films and must not pool their coverage, which is the rule `_floored` already states.
+ windowed_compared: Optional[frozenset[tuple]] = None
+ windowed_seen: set[tuple] = set()
# BOTH, and in this order. Visible-region parity is the verdict the off-screen exemption
# asks for and it is the one that can FAIL a windowed arm for something a user would see.
# The behavioural invariants are the complement: they catch what a viewport comparison
@@ -2091,20 +2351,53 @@ def main(argv: list[str] | None = None) -> int:
f"reading them as findings."
)
floor = frozenset()
- worst = max(
- worst,
- visible_report(paths, f"UI PARITY: {pattern}", floor, select = win),
+ vis = visible_report(
+ paths, f"UI PARITY: {pattern}", floor, select = win, min_reps = args.min_reps
)
+ worst = max(worst, int(vis))
+ windowed_compared = frozenset(vis.compared)
+ windowed_seen |= set(vis.seen)
if args.mode in ("auto", "behaviour"):
- worst = max(
- worst,
- behaviour_report(
- paths,
- f"UI PARITY: {pattern}",
- windowed = args.mode == "auto" or any_windowed(paths) is not None,
- select = win,
- ),
+ beh = behaviour_report(
+ paths,
+ f"UI PARITY: {pattern}",
+ windowed = args.mode == "auto" or any_windowed(paths) is not None,
+ select = win,
+ min_reps = args.min_reps,
)
+ worst = max(worst, int(beh))
+ # Only where behavioural mode is the ONLY mode, i.e. `--mode behaviour`. Under
+ # `--mode auto` it adds nothing to the numerator; see below.
+ if windowed_compared is None:
+ windowed_compared = frozenset(beh.compared)
+ windowed_seen |= set(beh.seen)
+ # NOT UNIONED ACROSS THE TWO WINDOWED MODES. The union is right for the structural set
+ # below, which is a DISJOINT set of pairs -- coverage there really does add up. It is wrong
+ # here: under `--mode auto` these two are not two slices of the film, they are two verdicts
+ # on the SAME pairs, which is what the comment above says when it says neither subsumes the
+ # other. Unioned, one stood in for the other: behavioural mode reaching all 16 pairs while
+ # visible capture succeeded on 1 and returned NOT COMPARABLE for the other 15 still put 16
+ # keys in the set, cleared `--min-compared 16`, and exited 0 with essentially the whole
+ # appearance surface unmeasured.
+ #
+ # AND THE TWO ARE NOT INTERCHANGEABLE, so this is not an intersection either. The modes are
+ # asymmetric in what they even claim to reach: visible-region parity applies to EVERY
+ # windowed pair, while a behavioural invariant only exists for the handful of actions that
+ # declare one -- every other pair is reported UNCHECKED, which is explicitly not a pass and
+ # equally not a shortfall. Intersecting would therefore fail a run for pairs behavioural
+ # mode never had an opinion about, which is a false red measured at 1 of 4 on the coverage
+ # fixture here.
+ #
+ # So in `auto` the numerator is the visible verdict, the one that is owed on every pair.
+ # Behavioural coverage cannot vouch for the appearance of a pair the viewport comparison
+ # could not read, which is exactly the substitution above.
+ #
+ # `seen` stays a union: it is the denominator, the pairs the reports were OFFERED, and a
+ # pair offered to either was offered. Shrinking it alongside the numerator would hide the
+ # shortfall it exists to express.
+ if windowed_compared is not None:
+ compared_pairs.setdefault(pattern, set()).update(windowed_compared)
+ seen_pairs.setdefault(pattern, set()).update(windowed_seen)
# AHEAD OF THE STRUCTURAL EARLY RETURN, because this mode does not read the plan at all.
#
@@ -2153,9 +2446,18 @@ def main(argv: list[str] | None = None) -> int:
worst = max(worst, rc)
return worst
+ # THE STRUCTURAL EARLY RETURN, and the reason there is now a floor check on both sides of it.
+ # Everything below is the structural half, and a payload with no fully mounted pair has none, so
+ # returning here is right for all of it. `--min-compared` was not one of those things: it is a
+ # COVERAGE floor asking whether the film ran, and a windowed run's film runs exactly as much.
+ #
+ # This return is the FOURTH cross-cutting enforcement found sitting below it -- the null
+ # control's tier axis, then its corpus axis, then `--audit-null`, then this. The first three
+ # were hoisted one at a time; so the floor goes through `coverage_shortfall` on BOTH exits, over
+ # the pairs every mode compared, with the reports handing those pairs back.
remaining = [e for e in plan if e["structural"] is None or e["structural"]]
if not remaining:
- return worst
+ return _floored(worst, compared_pairs, seen_pairs, args.min_compared)
if scored_windowed:
# The rest still get the digest they were owed, in the same run.
print(
@@ -2238,10 +2540,14 @@ def main(argv: list[str] | None = None) -> int:
# written it would have bound `args.min_reps` to `select` and `args.min_compared` to
# `min_reps`, leaving the coverage floor at its default of 0 -- a silently disabled guard
# and a structural pass scoring against an integer, with nothing failing to say so.
- worst = max(
- worst,
- report(paths, label, effective, select, args.min_reps, args.min_compared),
- )
+ # `min_compared` IS NOT PASSED DOWN ANY MORE: that is the change, not an omission. A floor
+ # applied inside each report is checked separately per report, so a run that compared nine
+ # windowed pairs and nine structural ones would fail a floor of sixteen twice over having
+ # compared eighteen. `report` keeps the parameter (the selftests call it directly and it is
+ # a complete report on its own); `main` collects the pairs and applies the floor below.
+ struct = report(paths, label, effective, select, args.min_reps)
+ worst = max(worst, int(struct))
+ note(pattern, struct)
# COMBINED, and the worst outcome wins. A behavioural failure on one payload is not cancelled
# by a structural pass on another, and a structural failure at the fully mounted rungs is not
# cancelled by the windowed rungs passing their own two modes.
@@ -2251,7 +2557,7 @@ def main(argv: list[str] | None = None) -> int:
f"region and behavioural invariants, {scored_structural} scored structurally. Any "
"mode's failure fails the run."
)
- return worst
+ return _floored(worst, compared_pairs, seen_pairs, args.min_compared)
if __name__ == "__main__":