Skip to content

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

Merged
danielhanchen merged 13 commits into
mainfrom
p130-parity-instrument
Aug 25, 2026
Merged

danielhanchen merged 13 commits into
mainfrom
p130-parity-instrument

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Both of these are gates that report a pass on input they cannot represent, which is the
one failure mode this whole instrument exists to refuse. Neither could report the other
answer.

The coverage floor never ran on a windowed run

main returns before the structural loop when no pair is fully mounted, and everything
cross-cutting kept being written below that line. During the review of #9439 three
consumers of that one early return were found and each was hoisted or duplicated in turn:
the null control's tier axis, then its corpus axis, then --audit-null. This is the
fourth. --min-compared is a parameter of report() and enforced at one site inside it,
and report() is only reachable below the return, so a run with no fully mounted pair
applied no coverage floor of any kind: --min-compared 20 exits 0 on one matched capture.

Two ways in, neither exotic. Every pair classifies windowed, or either of the forced
--mode visible / --mode behaviour invocations, both of which hard-set the structural
plan to an empty set for EVERY pattern, unconditionally. The workflow passes
--min-compared 16 on every run, and that floor is what replaces a slot-budget liveness
gate for a job that reads no timings. Two blank pages have identical digests, so a run
that drove nothing is the easiest possible pass, and this is the guard against it.

Fixed structurally rather than a fourth time by hand. The three reports return the pairs
they scored and main applies one floor over all of them. SUMMED across modes, not
checked per report: a combined run splits one film's coverage three ways and a per-report
floor fails a run that compared plenty. UNIONED rather than added: --mode auto scores
each windowed pair twice, once on the visible region and once on the invariants, so adding
two counts would double every windowed pair and let a floor of 16 pass on 8. report
keeps its own parameter and its own exit 3, because the selftests call it directly and it
is a complete report in its own right.

The return type is an int subclass. That is deliberate and it is commented at the
definition: the exit code is the primary value, main does worst = max(worst, ...) at
four call sites and the selftests assert == 0 / == 1 / == 2 / == 3 against these
three functions directly in several dozen places. A tuple or a dataclass would mean
rewriting all of those in bulk to say exactly what they say today, and an assertion
rewritten in bulk is an assertion nobody re-derived.

Two mounted rows sharing a thread position produced MATCH

parityVisible.capture() keys its per-message digests by thread position and the
assignment was unconditional, so a second mounted row publishing a position a row already
held silently REPLACED that row's digest. VIS.ever is a set of numbers, so it collapsed
the pair as well. Three rows on screen produced a capture indistinguishable from a capture
of two, and compare_visible then reached a verdict out of a set it did not know was
short.

Whether that was ever caught was DOM order and nothing else. Reproduced in Chromium: the
same ghost row 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. The pre-film readiness gate cannot help, because it checks the ordinals an arm
publishes before the film and this is introduced during an action.

Counted directly rather than derived. unmounted_at_capture looks like it should notice,
an extra row at one position and a vacancy at another, but in the renumber case the two
cancel and it reads a clean zero over a live collision. Consumed BEFORE ever_visible and
messages are compared, because those are the two quantities the collision made short.
Read defensively, so a payload recorded before the counter compares exactly as it did.

The residual is stated in the code: a collision that had resolved to one row by capture
time is not detectable here, and catching it needs the clash recorded when the position is
stamped, which is a change to the observer's state model rather than to this loop.

And the two build differences a capture comparison cannot see

compare_all_with built its whole result from a capture comparison plus the conjunction of
ran. So an action that RUNS on one build and cannot be performed on the other collapsed
into the same bucket as a missed slot, which every report here counts as lost coverage
rather than a finding, and an action that ran on both arms and failed its OWN assertion on
one of them left no trace at all.

compare_rows has always asked both questions; the visible and behavioural paths never
did. That is survivable on the structural path and not here, because on a windowed arm
THESE two reports are the entire UI verdict: the digest is not_applicable by construction
and stop_generation has no behavioural invariant of its own, so in --mode auto a
passing invariant on another action carried the run to exit 0.

Both questions now come from analysis/parity.py's own functions, extracted out of
compare_rows so there is one copy rather than a second opinion written out elsewhere --
the drift INVALIDATING_CELL_GATES was centralised to prevent, arriving one level down.
Held to the same bar the structural path holds: 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.

One existing expectation changed, and it moved UPWARD

Calling this out rather than leaving it in the diff, because a changed expectation is the
right thing for a reviewer to be suspicious of.

test_a_timed_out_rebuild_leaves_the_behavioural_run_with_no_verdict asserted exit 2. Both
statements about that payload are true: the invariant could not be read, AND the action's
own assertion failed on the treatment arm alone. report already resolves that precedence
for the structural mode, in a comment at the site -- "a run can find a real regression
while deciding nothing, and 'it failed' is the more specific answer than 'it could not
tell'". Running report over that very payload returns 1, so the two modes were
disagreeing about one payload and the behavioural one was giving the vaguer answer.

The test now asserts 1, keeps every one of its original assertions (invariants held: 0,
one pair NOT COMPARABLE, NOTHING WAS COMPARED all still print), adds the new one, and pins
the agreement between the two modes so they cannot drift apart again. Nothing was
loosened: 1 is a failure and 2 is a refusal.

Tests

pytest tests/studio/studiobench -q: 1308 passed, up from 1298. ruff clean.

Mutation study, each mutant reverting one fix to its pre-fix behaviour, with the mutation
confirmed present in the tree before anything is run:

mutant tests red failure
floor goes back below the early return 3 assert 'TOO LITTLE COMPARED' in ..., mutant exits 0
reports blinded to the two build differences 3 assert 'ASSERTION FAILED ON ONE ARM' in ...
duplicate ordinal overwritten again 2 assert 0 == 1 on ordinal_collisions
compare_visible stops consuming the counter 1 assert 'differ' == 'not_comparable'

Both-direction controls are present and stay green: an assertion that failed on BOTH arms
is coverage lost rather than a build difference, a missed slot is a slow machine and not a
build difference, a legitimate renumber-in-place records zero collisions, and a floor set
beneath what the run actually compared still exits 0.

Follow-up to #9439, where the coverage floor was accepted as correct and deliberately not
fixed, and where the duplicate-ordinal and action-outcome reports arrived after the last
round and were merged over without an answer.

Both of these are gates that report a pass on input they cannot represent, which is the
one failure mode this whole instrument exists to refuse. Neither could report the other
answer.

## The coverage floor never ran on a windowed run

`main` returns before the structural loop when no pair is fully mounted, and everything
cross-cutting kept being written below that line. During the review of #9439 three
consumers of that one early return were found and each was hoisted or duplicated in turn:
the null control's tier axis, then its corpus axis, then `--audit-null`. This is the
fourth. `--min-compared` is a parameter of `report()` and enforced at one site inside it,
and `report()` is only reachable below the return, so a run with no fully mounted pair
applied no coverage floor of any kind: `--min-compared 20` exits 0 on one matched capture.

Two ways in, neither exotic. Every pair classifies windowed, or either of the forced
`--mode visible` / `--mode behaviour` invocations, both of which hard-set the structural
plan to an empty set for EVERY pattern, unconditionally. The workflow passes
`--min-compared 16` on every run, and that floor is what replaces a slot-budget liveness
gate for a job that reads no timings. Two blank pages have identical digests, so a run
that drove nothing is the easiest possible pass, and this is the guard against it.

Fixed structurally rather than a fourth time by hand. The three reports return the pairs
they scored and `main` applies one floor over all of them. SUMMED across modes, not
checked per report: a combined run splits one film's coverage three ways and a per-report
floor fails a run that compared plenty. UNIONED rather than added: `--mode auto` scores
each windowed pair twice, once on the visible region and once on the invariants, so adding
two counts would double every windowed pair and let a floor of 16 pass on 8. `report`
keeps its own parameter and its own exit 3, because the selftests call it directly and it
is a complete report in its own right.

The return type is an `int` subclass. That is deliberate and it is commented at the
definition: the exit code is the primary value, `main` does `worst = max(worst, ...)` at
four call sites and the selftests assert `== 0` / `== 1` / `== 2` / `== 3` against these
three functions directly in several dozen places. A tuple or a dataclass would mean
rewriting all of those in bulk to say exactly what they say today, and an assertion
rewritten in bulk is an assertion nobody re-derived.

## Two mounted rows sharing a thread position produced MATCH

`parityVisible.capture()` keys its per-message digests by thread position and the
assignment was unconditional, so a second mounted row publishing a position a row already
held silently REPLACED that row's digest. `VIS.ever` is a set of numbers, so it collapsed
the pair as well. Three rows on screen produced a capture indistinguishable from a capture
of two, and `compare_visible` then reached a verdict out of a set it did not know was
short.

Whether that was ever caught was DOM order and nothing else. Reproduced in Chromium: the
same ghost row 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. The pre-film readiness gate cannot help, because it checks the ordinals an arm
publishes before the film and this is introduced during an action.

Counted directly rather than derived. `unmounted_at_capture` looks like it should notice,
an extra row at one position and a vacancy at another, but in the renumber case the two
cancel and it reads a clean zero over a live collision. Consumed BEFORE `ever_visible` and
`messages` are compared, because those are the two quantities the collision made short.
Read defensively, so a payload recorded before the counter compares exactly as it did.

The residual is stated in the code: a collision that had resolved to one row by capture
time is not detectable here, and catching it needs the clash recorded when the position is
stamped, which is a change to the observer's state model rather than to this loop.

## And the two build differences a capture comparison cannot see

`compare_all_with` built its whole result from a capture comparison plus the conjunction of
`ran`. So an action that RUNS on one build and cannot be performed on the other collapsed
into the same bucket as a missed slot, which every report here counts as lost coverage
rather than a finding, and an action that ran on both arms and failed its OWN assertion on
one of them left no trace at all.

`compare_rows` has always asked both questions; the visible and behavioural paths never
did. That is survivable on the structural path and not here, because on a windowed arm
THESE two reports are the entire UI verdict: the digest is `not_applicable` by construction
and `stop_generation` has no behavioural invariant of its own, so in `--mode auto` a
passing invariant on another action carried the run to exit 0.

Both questions now come from `analysis/parity.py`'s own functions, extracted out of
`compare_rows` so there is one copy rather than a second opinion written out elsewhere --
the drift `INVALIDATING_CELL_GATES` was centralised to prevent, arriving one level down.
Held to the same bar the structural path holds: `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.

## One existing expectation changed, and it moved UPWARD

Calling this out rather than leaving it in the diff, because a changed expectation is the
right thing for a reviewer to be suspicious of.

`test_a_timed_out_rebuild_leaves_the_behavioural_run_with_no_verdict` asserted exit 2. Both
statements about that payload are true: the invariant could not be read, AND the action's
own assertion failed on the treatment arm alone. `report` already resolves that precedence
for the structural mode, in a comment at the site -- "a run can find a real regression
while deciding nothing, and 'it failed' is the more specific answer than 'it could not
tell'". Running `report` over that very payload returns 1, so the two modes were
disagreeing about one payload and the behavioural one was giving the vaguer answer.

The test now asserts 1, keeps every one of its original assertions (`invariants held: 0`,
one pair NOT COMPARABLE, NOTHING WAS COMPARED all still print), adds the new one, and pins
the agreement between the two modes so they cannot drift apart again. Nothing was
loosened: 1 is a failure and 2 is a refusal.

## Tests

`pytest tests/studio/studiobench -q`: 1308 passed, up from 1298. `ruff` clean.

Mutation study, each mutant reverting one fix to its pre-fix behaviour, with the mutation
confirmed present in the tree before anything is run:

| mutant | tests red | failure |
| --- | --- | --- |
| floor goes back below the early return | 3 | `assert 'TOO LITTLE COMPARED' in ...`, mutant exits 0 |
| reports blinded to the two build differences | 3 | `assert 'ASSERTION FAILED ON ONE ARM' in ...` |
| duplicate ordinal overwritten again | 2 | `assert 0 == 1` on `ordinal_collisions` |
| `compare_visible` stops consuming the counter | 1 | `assert 'differ' == 'not_comparable'` |

Both-direction controls are present and stay green: an assertion that failed on BOTH arms
is coverage lost rather than a build difference, a missed slot is a slow machine and not a
build difference, a legitimate renumber-in-place records zero collisions, and a floor set
beneath what the run actually compared still exits 0.

Follow-up to #9439, where the coverage floor was accepted as correct and deliberately not
fixed, and where the duplicate-ordinal and action-outcome reports arrived after the last
round and were merged over without an answer.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 4 commits August 24, 2026 08:34
Found by rehearsing the merge with #9575 and then auditing the auto-merged result rather
than trusting it, which is how this class of thing is supposed to be caught.

The collision refusal added in this PR returns NOT_COMPARABLE before anything else in
`compare_visible`, and one of the things it was returning ahead of is the "one arm's
viewport ended EMPTY and the other's did not" finding, which is raised with `severe: True`
and documented at that site as NOT SUPPRESSIBLE. Losing the conversation is a different
kind of statement from a capture that could not be read, and the blanket refusal was
downgrading it.

A collision provably cannot have manufactured that finding: a collision needs TWO mounted
rows sharing one position, so the map it corrupts still holds at least one entry. It can
merge two entries and it can never empty a map. So the one comparison a collision cannot
have caused is still reported.

Only that one, and the asymmetry is the point. 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. Those stay behind the refusal.

This also puts the refusal on the same footing #9575 gives its own blindness probe --
placed so that losing the thread stays a finding whether or not the capture could be read
in full -- so the two land consistently rather than establishing two different orderings
for the same kind of refusal.

Two tests, both live: the severe finding survives a collision on the other arm, and the
control that a collision with both viewports alive is still refused. Mutation: drop the
`and not lost_the_thread` guard and the first fails with
`assert 'not_comparable' == 'differ'`.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 2e8e9e2ee0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The declared policy named two exemptions and there are three. The missing one is
UI-PERF-POLICY.md section 1(c): select-all need not select all, PROVIDED copy stays
complete. Copy may serialise the thread from the message store as markdown or plain
text rather than reproducing a DOM selection. Completeness of the copied content is
REQUIRED, silent truncation being data loss; visual selection fidelity is NOT. That
is what makes deferral and virtualization cheap, because the copy path stops
depending on what is mounted.

Updated everywhere the policy is stated, not only the two places that counted it:
the POLICY constant and its comment in analysis/parity.py, which is what the three
report modes print into the CI job output; the header comment in scene/parity.js;
CONTRIBUTING-perf.md; and INTERFACES.md.

The exemption is stated with its condition attached everywhere it appears. Naming it
without the condition would read as permission to lose conversation.

No mode grants it off a digest, and the text says so rather than implying otherwise.
--mode behaviour is the only one that speaks to it, through
clipboard_carries_the_whole_thread, which already 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. This is the same shape as the caveat the off-screen exemption already
carries, and neither is weakened here.

Nothing in the verdict logic enumerated the exemptions, so the gate was never
narrower than its docstring: the off-screen exemption is expressed as NOT_APPLICABLE
in compare() and granted in compare_visible(), the performance one is a human
decision with no code path, and there is no exemption list or count anywhere. The
only code carrying the two-exemption shape was prose in strings. One assertion did
encode it -- "cannot grant either exemption" for the behavioural mode, where "either"
means one of two -- and it now asserts the accurate three-way split. Every mode's
policy line is held to naming the exemption together with its condition, which fails
if the POLICY constant is reverted to two.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The behaviour-mode policy line claimed the copy stays "complete", which reads
as a comparison of the copied characters. It is not one. Each arm's clipboard
length is divided by the thread's own visible text and the ratio has to land
inside MIN_CLIPBOARD_COVERAGE-MAX_CLIPBOARD_COVERAGE.

A content comparison is not available here and is not the missing half: the
base arm's clipboard is the DOM's rendered text while a store-based copy is
markdown source, so two correct serialisations of one conversation differ
character by character. The band is what carries the claim, 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 at 2.16.

So the printed line now names the measure, disclaims the comparison it does
not perform, and interpolates the live band through behaviour_policy() rather
than repeating numbers that would drift away from the ones enforced.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 2 commits August 24, 2026 23:05
The coverage floor unioned the compared sets of the two windowed modes. That
is right for the structural set, which is a disjoint set of pairs whose
coverage really does add up. It is wrong for these two: under --mode auto they
are not two slices of one film, they are two verdicts on the same pairs.

Unioned, one stood in for the other. Behavioural mode reaching all 16 pairs
while the visible capture could be read on only 1 still put 16 keys in the set,
cleared --min-compared 16, and exited 0 with essentially the whole appearance
surface unmeasured. That is the false green the floor exists to refuse,
arriving through the floor itself.

It is not an intersection either, and that is worth stating because it looks
like the obvious repair. The two modes are asymmetric in what they 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 not a pass and equally not a
shortfall, so requiring both verdicts on every pair fails a run for pairs
behavioural mode never had an opinion about. Measured at 1 of 4 on the existing
coverage fixture, where visible mode read all four.

So in auto the numerator is the visible verdict, the one owed on every pair,
and --mode behaviour on its own still counts its own. seen stays a union: it is
the denominator, the pairs the reports were offered, and shrinking it alongside
the numerator would hide the shortfall it exists to express.

Both directions are pinned. Four behaviourally checked pairs with one visible
capture now report 1 of 4 and exit 3; four visible pairs with three UNCHECKED
behavioural ones still exit 0.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17e858cbac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +524 to +525
if not (len(failed) == 1 and passed):
return "", ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude mutually failed assertions from coverage

When an asserted action runs on both arms with expect_ok == False—for example, stop_generation cannot stop either stream—this branch returns no signal, so the structural, visible, and behavioural reports retain any matching capture/invariant verdict and add the pair to their compared set. Consequently, such actions can satisfy --min-compared even though the intended post-action state was never reached, contradicting this helper's own classification of the case as lost coverage; keep it from being a build-difference failure, but mark the pair not comparable or otherwise exclude it from the coverage numerator.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mechanism is accurate, I reproduced it: a stop_generation pair with ran=True and expect_ok=False on both arms and identical digests reaches MATCH, increments matched, and enters compared, so it does count toward --min-compared. But I am not making the change, for three reasons.

It cannot hide a regression. The parity job runs base = merge_base against treatment = head (studiobench-ui-parity.yml:497), so a head-side change cannot break the assertion on the base arm. Both arms failing is environmental or fixture by construction, never the PR. The shape that IS a build difference, one arm passing and one failing, is exactly what expect_regression returns and it already fails the run.

The intended-state-never-reached case is already unconditionally red elsewhere. main.py:2649 makes ran with expect_ok False a problem with no allowance, and studiobench-ci.yml:300 runs --assert-liveness on every PR over a trigger path superset of the parity job's. A selector regression that fails every cell's assertion reds the PR either way.

And the measured cost is a false red. Simulating the workflow's real shape (16 actions x 2 reps, 5 slots lost, floor 16), with k fragile actions failing on both arms: k=0 gives 22/32 exit 0 today and after the change; k=3 gives 16/32, exactly at the floor; k=4 gives 14/32 and TOO LITTLE COMPARED; k=5 gives 12/32 and red. The floor was sized for 6 to 10 pairs of headroom and every one of the 17 registered actions declares an assertion, so this eats it two pairs at a time on a PR with no UI change. That is the same false red I declined the coverage-floor intersection for last round. Suite is 1438 passed either way, so the cost shows up in the workflow's numbers rather than a selftest.

matched and broken are filled from disjoint branches of one loop, so an
all-BROKEN payload reaches matched == 0 as well. The run listed its broken
invariants, then said not one invariant was evaluated and that it carried
neither a pass nor a failure, then returned 1, sending the reader off to find
out why actions that had run did not run.

Gate the banner on broken, which is the precondition its own paragraph argues
from, matching report and visible_report. Not gated on build_failed: those
shapes come from pairs whose invariants were unreadable, so the banner stays
true there and the existing timed-out-rebuild test pins that pairing.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 412b583905

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 25, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 25, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 25, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 25, 2026
@danielhanchen
danielhanchen merged commit b3d86b2 into main Aug 25, 2026
29 checks passed
@danielhanchen
danielhanchen deleted the p130-parity-instrument branch August 25, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant