Skip to content

studiobench: refuse the message that is still being written, and score the rest of the thread - #9575

Merged
danielhanchen merged 428 commits into
mainfrom
studiobench-streamed-parity
Aug 25, 2026
Merged

danielhanchen merged 428 commits into
mainfrom
studiobench-streamed-parity

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Stacked on #9542. Touches only tests/studio/studiobench.

The defect

The UI-parity digest is taken at the close of an action window, which is a wall-clock offset in the film. The two arms are two cells run back to back against one pacer: the bytes on the wire are identical by construction, but each has its own send click, its own t0 and its own paint clock. A slot that lands inside a live reply therefore digests two different points in the same stream, and the difference that comes back is wall clock wearing the shape of a UI change.

Same family as every entry in the instrument-defect list: measuring at a moment whose meaning is not stable across the things being compared.

Why you cannot recognise it by its size

Mid-stream, Studio does not show a prefix of the finished reply. parseIncompleteMarkdown runs remend over the tail and closes the half-arrived construct, KaTeX renders the repaired formula and, while it will not parse, writes its parse error and character offset into a title, Shiki re-tokenises the repaired fence, and the trailing code block carries data-incomplete. None of that is monotonic in how much text has arrived.

Measured on the frozen corpus's streamed unit (4,238 characters) driven through the real remend, the real KaTeX and the real Shiki into the shipped signature():

stepping result
by the pacer's own 24-character chunk 175 of 175 adjacent pairs differ, 0 of them at the same serialised length
one character at a time the signature gets SHORTER at 52 of 4,237 steps; 34 pairs of distinct stream positions serialise to exactly the same length with different digests; 398 steps move the digest not at all

So at the shipped cadence the drift is total, one chunk of skew fails a stable action outright, and the same-length variant is real but needs sub-chunk skew to reach. The fix is deliberately blind to length: what is refused is the message that was in flight, not a difference of a particular size.

The change

scene/dom.js gains streamingMessages(), read from the app's own published state: assistant-ui's data-status on the text part, aria-busy on the reasoning content. Nothing here reads a timer, a character count or "the last assistant message".

scene/parity.js carries in_flight, streaming, in_flight_unplaced and digest_scaffold: the thread with every message replaced by a marker carrying its tag, role and position. digest is the scaffold plus the per-message rows, so comparing them separately is the same reading taken apart, and taken apart it can withhold one message. signature() takes an optional element set to elide; it is a marker in place, never a silent hole, so a message that vanished still moves the digest.

Every message is elided from the scaffold rather than only the streaming ones, because whether a message is in flight is a property of ONE arm at the moment ITS digest was taken, and the ordinary case is that the arms disagree about it. Eliding all of them makes the walk identical on both sides by construction.

analysis/parity.compare then has three outcomes rather than two:

the settled document the in-flight message verdict
differs anything DIFFER, localised to the settled things only
agrees agrees MATCH, unchanged
agrees differs NOT COMPARABLE. Not a pass

The first is the case that used to be lost. An action landing inside a stream was silenced wholesale by UNSTABLE_ACTIONS, so a real regression anywhere else in the thread printed under "expected to vary" and the run exited 0.

in_flight_unplaced is the positive control on a scan that can return zero, and it is checked AFTER mount_count_mismatch on purpose: a build that drops a message while a reply is running is still a finding, because that reading does not depend on the stream split.

Scored both ways, not asserted

A normaliser that reports "identical" without ever having been shown a difference is worthless, so both directions are scored on every change.

On a live jsdom document built by the real renderers and digested by the shipped capture():

battery before after
NULL: one build, one document, six points in one stream, 15 pairs 15 of 15 reported as a UI change 0 of 15, all refused as not comparable, 0 passed
MUTANT: 11 real rendering differences injected while a reply is in flight 11 of 11 detected 10 of 11 still DIFFER, 11 of 11 never MATCH

The in-tree battery, which drives the shipped signature() through the node harness rather than a Python port, scores NULL 0 of 6 and MUTANT 13 of 13 with 0 of 13 reported as a match.

What it gives up, written down rather than discovered later

  1. A genuine regression INSIDE the streaming message lands as NOT COMPARABLE. It was not distinguishable before either, since every action that lands in a stream is on the declared unstable list, so nothing that used to be caught stops being caught; the outcome moves from "expected to vary, exit 0" to "not measured, not a pass".
  2. A reorder that moves the streamed message past another message of the same role is demoted from DIFFER to NOT COMPARABLE, because the per-message rows are keyed by mounted index. It is a demotion and not a hole, and the only shape that reaches it needs the streamed message not to be the last one, which the app does not do today.

Both are pinned as tests and stated in INTERFACES.md.

Checks

  • pytest tests/studio/studiobench -q: 1291 passed, against a 1272 baseline measured on this PR's own merge base.
  • ruff check tests/studio/studiobench: clean.
  • Old payloads are unaffected: a capture without the new fields carries no claim about a stream and falls back to the digest it does carry, which is the previous comparison exactly.

pre-commit-ci Bot and others added 30 commits August 22, 2026 11:15
The parent generalises the resume identity check that this branch introduced for
--stream-tail-chars and --corpus-dollars, so the narrower per-flag refusal here is superseded
rather than kept alongside it. Keeping both would be a third independent rule producing a second
refusal message for the same failure.

The two flags become two more entries in IDENTITY_AXES. They already sit in the run_meta row, so
there is no schema change and a payload written before either flag existed still declares neither
and therefore still resumes.

The six tests that pinned the removed _resume_set(paths, stream_tail_chars, corpus_dollars)
signature move to the parent's identity selftest and drive prepare_payload / requested_identity
instead, keeping every intent: both refusals, the two-fixtures-in-one-file refusal (now asserted
from both sides, which the old shape could not express), and the three controls -- an unchanged
fixture still resumes, a payload from before these axes still resumes, and a dead cell is still
re-run.
`skippable_cells` skips a (rung, rep) pair only when every arm of it completed and re-runs
both arms otherwise, so an interrupted run leaves the append-only payload holding a full
base/treatment pair under the dead session and another under the retry's. The scene writes
its action rows before `stream:drain`, so an arm that dies draining has already recorded
every digest it captured, and `collect` read both sessions: one logical repetition became
two comparable observations, the first of them measured off an arm that was on its way down.

That is the shape `derive_unstable` is least able to survive. One differing superseded pair
plus one matching replacement is exactly `min_observations`, so a stable action was marked
unstable at that rung on the strength of a reading the run itself threw away. A real DOM
regression at that rung then printed under "expected to vary" and the parity gate exited 0.

`readings_by_arm` already filters the same rows for the same reason on the timing side and
`floor_table.cell_metrics` gets it for free by keying completed cells on the cell id; this
was the one path left reading both attempts. Filtered per payload file, since a cell id is
reused across shards and superseding has to resolve inside the stream that appended it.

Two repetitions of one rung are still two observations, and an attempt that was never
re-run is still the latest attempt at itself and keeps its verdict.
…the stop slot's cleanup time

Two holes, both of which let a run report a mixture as one reading.

A RESUME AGAINST A PAYLOAD OLDER THAN THE FIXTURE AXES SKIPPED THE CHECK.
`identity_problems` skips an axis a payload never declared, on the principle
that an axis a row never declared cannot be a difference. That is right for the
axes `run_meta` has always carried, and wrong for `stream_tail_chars` and
`corpus_dollars`: those arrived with the flags that set them, so a payload
written before them could not have run under anything but `None` and `False`.
Absence proves the value there rather than withholding it. So
`--resume --stream-tail-chars 24000` against such a payload was accepted,
skipped every cell it had completed, and recorded the rest under a different
streamed fixture beneath the same cell ids -- one ladder built from two films,
which is what the refusal exists to prevent. Those two axes now normalise to
their historical defaults when absent and the refusal says why an axis the
payload never mentions is a difference; every other axis keeps the skip.

STOP SPENT THE NEXT SLOT'S WINDOW CLEANING UP AFTER ITSELF. `stop_generation`
waits for the cell's own reply to drain rather than truncating it, and the wait
was bounded by the whole of the slot's remaining budget. A reply that drained
at the last moment of the slot therefore left nothing for what follows: 1,280 ms
of fixed waits to fill the composer, let the throwaway turn get going, catch the
chunks in flight and settle the cleanup delete. Slots have absolute starts but
the runner is sequential, so that overrun comes out of the next action's
remaining budget: `stop_generation` closes 300 ms before `scroll_after` opens on
the fast film and 500 ms before it on the quick one, and on the fast film
`scroll_after` has 1,200 ms of budget behind that 300 ms gap. Measured against
the shipped action with a 3,000 ms budget and a drain at 2,900 ms: 4,180 ms
spent, 1,180 ms of it past the deadline. The row `scroll_after` then wrote
blamed the machine for reaching a slot late that this action had been sitting
in. The drain wait now reserves that fixed cost out of the budget it may spend,
and returns `not_run` when the reply has not drained by then, which is the
answer it already gives when the reply does not drain at all.

Both paths are reachable only through `--stream-tail-chars`, which is the
supported way to ask for a reply long enough to still be streaming when the stop
slot opens.

Regression tests drive the shipped functions: the legacy payload is refused
under a non-default fixture and still resumes under the defaults, and
`stop_generation` is run against each film's own stop slot with a clock the
page's waits advance.
… attached treatment by its URL, and report the ladder a resume promised

Three ways a run could come back with a number about something nobody measured.

A FAILED SETUP ABANDONED THE STUDIOS IT HAD ALREADY LAUNCHED. The sides are
acquired one after the other, so in a self-managed A/B the base is installed,
launched and serving before the treatment's clone begins; the cleanup that stops
them both is the `finally` under the cells, which a failure during setup never
reaches. A treatment whose `install.sh` exits non-zero therefore unwound past a
base nothing ever stopped, and the two setup steps that leave by RETURNING --
the health check and the development-build gate -- did the same with both
Studios up. That server is not idle afterwards: `launch_studio` detaches it with
`setsid -f`, so it keeps the port, and Studio's own launcher ABORTS rather than
binding when it finds one of its own servers there (`studio/backend/run.py`,
`_resolve_port` with `avoid_own_studio`). The retry's server exits,
`wait_for_healthz` takes its 200 from the stale process, and that run measures
the build the previous attempt installed while `run_meta` records the ref this
one asked for. Setup now runs under a `finally` that stops every side this run
launched unless it reached the cells; `--keep-studio` still asks for exactly
that leak and still gets it, and an attached Studio is still never touched.

AN ATTACHED TREATMENT WAS IDENTIFIED BY THE LABEL RATHER THAN BY THE SERVER.
`studio_ref` folds an attached base down to `attached:{url}` because the URL is
the only thing the harness can see about it, but the treatment carried nothing
but the name typed after `--ab`, and that name is free. So
`--attach A --attach-b B --ab fix --resume`, re-run later against `--attach-b C`,
passed `prepare_payload`, skipped every completed treatment cell and exited 0
with B's measurements standing as C's result. `ab_plan` now records the
normalised treatment URL, `requested_identity` asks for it, and the two are
compared on a `treatment_url` axis. Both treatment axes are still skipped when
only one side of the comparison is an A/B, decided from the ref, so an `A0`
payload and a `base`/`treatment` run do not collide and a payload recorded
before this axis existed still resumes.

A RUNG A RESUME ADDED WAS DROPPED FROM THE REPORT. `rungs` is deliberately not
a payload identity axis, so `--resume --rungs 1K,10K` over a finished 1K run is
a legitimate continuation that appends a second `run_meta` promising both.
`recorded_ladder` returned the FIRST header, so a continuation killed after that
header and before the 10K cell reported the 1K ladder it had already finished
and scored COMPLETE -- the crash-beats-limp failure `report/build.py` exists to
refuse, arriving through the front door. It now folds every `run_meta` in the
file: a rung any session promised is owed by the payload, and one it never
reached is scored INCOMPLETE rather than dropped.

Tests drive the shipped functions. `test_studiobench_run_acquisition.py` drives
`run()` itself with the seams that leave the process stubbed at the boundary
they cross -- the installer, the launcher, the health check, the login, the
browser and the cell runner -- so the acquisition loop, the gate, the identity
and the payload under assertion are the real ones. With the source change
reverted and the tests kept, 9 of them fail; with it restored the studiobench
suite is 437 passed. The controls that pass either way: `--keep-studio` still
leaves a failed setup running, an attached Studio is never stopped, a run that
reaches its cells still stops its Studios once and not before, an unchanged
attached A/B still resumes, and a resume that promised no new rung still reports
the same ladder.

Deliberately not changed. The pacer and the browser bundle are not released when
setup fails after they exist: both die with this process, unlike a Studio the
harness detached, and the guard is about the resource that outlives it.
`--report` still exits 0 on an incomplete ladder; the completeness verdict is in
the summary and `--assert-liveness` is the gate for it. Folding the headers of a
legacy payload that predates `archive_payload`, and so holds two runs' headers,
now declares the union of their rungs: more INCOMPLETE, never fewer.
Five conflicts in studiobench/__main__.py, all from the parent putting side acquisition under a
cleanup guard: the re-indent collides with everything this branch added inside run(). Resolved by
taking the parent's structure and re-applying this branch's three additions at the new indent, so
the stream-cost injection script, the two fixture keys in the run manifest and the FIXTURE CHANGED
banner now sit inside the guarded region and are covered by it.

The identity check needed both sides rather than either. The parent added treatment_url and moved
the not-an-A/B skip into a single both_ab decision over TREATMENT_AXES; this branch added the two
fixture axes and HISTORICAL_DEFAULTS, which reads an absent axis as the default it must have run
under. Those compose: the skip for a payload that never declared an axis still applies to every
axis outside HISTORICAL_DEFAULTS, and the treatment axes are still skipped when only one side is
an A/B.
One conflict in studiobench/__main__.py, and it is an artefact rather than a disagreement: the
parent's cleanup-guard re-indent shifted run() far enough that the diff aligned this branch's
CellRunner construction against the parent's two lines picking the first side out of the
acquisition loop. Both blocks exist on both sides. Resolved by dropping the copy that was dragged
up, keeping the parent's placement of both, and re-applying the click_probe argument this branch
passes to CellRunner, which the parent's copy of that call does not carry.
…and put the probe mode on the payload identity

Two review findings on this branch, both real, and both about a reading that
goes missing without anything saying so.

THE PROBE'S NUMBERS LEFT WITH THE CELL THAT DIED. `--click-probe` finishes
inside `_press_send`, and everything after it there -- the `page.fill`, the
send-button lookup and its click -- still runs under the 8s default action
timeout set in `runtime/browser.py`. That is the same default the composer
click needed a 90s bound of its own to survive at 500K, so the step right
after the probe is exactly the one a large rung fails on. The attribution was
assigned on the way out of `_run_inner`, so a cell that died there emitted its
failure row with no trace of the probe at all. Unlike `composer_click_ms` it
has no window row to survive in: it runs before `setup:composer_click` opens,
it is noted on no window, and the cell row was the only copy. It is now filed
from `run`'s `finally`, on both paths, and the field is cleared per cell so a
cell that dies before its own probe cannot inherit the previous one's.

--CLICK-PROBE IS AN IDENTITY AXIS. The flag's own help text says it "makes the
cell's timings incomparable with a cell that did not run it", and a `cell_id`
carries the rung, the arm and the repetition and none of that. So `--resume
--click-probe` against a finished plain payload skipped every completed cell,
appended the remaining rungs measured the other way, and reported the two
halves as one ladder -- the mixed ladder this check exists to refuse, arrived
at through an axis it could not see. `run_meta` now records the mode,
`IDENTITY_AXES` carries it, and its absence from an older payload reads as
false through `HISTORICAL_DEFAULTS`, exactly as `stream_tail_chars` and
`corpus_dollars` do.

Tests: the failure-path preservation is driven through `CellRunner.run` with
the browser stubbed at the boundary it crosses, asserted over the payload the
real recorder wrote, with controls for a cell that never asked for the probe
and for one that dies before its own probe runs. The axis is driven end to end
in `test_studiobench_run_acquisition` over a `run_meta` a real run wrote, with
controls for a resume that keeps the flag and for a plain run that never had
it.
…fail a cell whose reply never drained, keep the trace when its cross-check dies, and refuse a port somebody else already holds

Five places where this harness reported a number, a score or an exit code it
had not earned.

A RESUME IS JUDGED ON THE BUILD, NOT ON THE NAME OF THE BUILD. `checkout_ref`
resolves a ref afresh on every install and returns the commit it landed on, and
that return value was discarded, so no payload ever recorded which build
produced its cells. `--branch main --resume` into a payload recorded before
`main` moved therefore passed every identity axis, skipped the completed cells,
measured the rungs still owed on a different build, and `report.assemble_rows`
printed the mixture under one header naming one ref. `main` moves several times
a day and a topic branch under review moves on every push, so this is the
ordinary shape of an interrupted run resumed the next morning, not an unusual
one. `StudioInstall` now carries the resolved commit, `run_meta` and `ab_plan`
record it, and `commit_problems` refuses a resume whose build changed.
Deliberately NOT in `prepare_payload`: that refusal is made before anything is
installed and a commit cannot be known before the fetch that resolves it, so
this check runs once the sides are up and still before the browser, the pacer
and the first cell. An empty commit on either side is not a difference, so a
payload written before this existed and an attached Studio, whose build is not
visible from here, both still resume.

`--resume` READS THE LATEST ATTEMPT, WHICH IS WHAT EVERYTHING ELSE READS.
`_resume_set` read the payload raw and was the last reader in which a superseded
row still counted, and it counted in the direction that skips work. An A/B pair
is re-run whole, so a resume re-runs an arm that had already succeeded; when
that retry failed while its partner succeeded, the payload held a completed row
and a LATER failed row under one deterministic `cell_id`. The next `--resume`
found the old success, skipped the pair and exited 0, while `--report` scored
the failed retry INCOMPLETE and `--assert-liveness` failed on it permanently. It
now reduces through `latest_attempt_rows`, the same helper `score_payload`,
`readings_by_arm`, the parity sweep and `--assert-liveness` already use.

A REPLY THAT NEVER FINISHED IS A FAILED CELL. `_drain_stream` reports rather
than raises, and what it reported was written to `row["stream"]` and read by
nothing: no gate, no report column, no liveness check and no exit code. So the
app still generating three times past its own cadence and 120 s beyond that,
with the whole film already run, came back as `completed: true`, `ok` in the
summary and exit 0, with its actions and its frame windows scored and paired
into the A/B ratio against an arm that did finish. `_run_inner` now raises,
after the drain reading and the pacer's own counters are on the row, so the rung
scores INCOMPLETE with the evidence for why attached. A reply that ends LATE but
ends is untouched: a slow finish is a finding the cell has to keep, and only a
reply that never ends at all is a failure.

A PORT SOMEBODY ELSE HOLDS IS REFUSED BEFORE THE SPAWN. The cleanup added for a
failed setup cannot reach `--keep-studio`, because retention is exactly what it
asks for. The next run's `unsloth studio -p <port>` then finds one of our own
servers there and aborts rather than binding (`studio/backend/run.py`,
`_resolve_port` with `avoid_own_studio`), or falls back to the next port when
the pid record is not readable. Either way nothing this run launched is on that
port, and everything downstream agrees the launch worked: `_discover_pid` pgreps
`unsloth studio.*-p <port>` and finds the OLD process, `wait_for_healthz` takes
its 200 from it, and `authenticate` reaches it with the bench password a
previous studiobench run rotated it to. The run measures the previous
invocation's build while `run_meta` records the ref this one asked for, and
`stop_studio` then kills the server the caller asked to keep. `launch_studio`
now refuses an occupied port outright.

LOSING THE METRICS PROBE COSTS THE CROSS-CHECK AND NOTHING ELSE, which is what
`start_cell` already says it costs. `Tracing.start` had succeeded by the time
`MetricsWindow.open()` ran, so clearing `self.capture` in that handler abandoned
a live per-browser tracing session: `close()` returned early and never sent
`Tracing.end`, `detach()` had nothing to stop, and every later window's
`Tracing.start` failed with "Tracing has already been started". One failed
`Performance.getMetrics` therefore cost the tracing instrument for the rest of
the run and left a `recordAsMuchAsPossible` capture recording underneath every
number taken after it. The capture is now retained and only `self.metrics` is
dropped; `close()` and `_analyse` already guard every use of it.

Left as they are: the two lines over 100 columns in `__main__.py`, which predate
this change.
… and a stop reserve that was measured

Four things the injection validation and the stop slot were getting wrong.

TWO ARMS ON ONE ORIGIN BOTH BURNED THE INJECTED COST. The injection is a
context init script gated on window.location.origin, and both arms are driven
by one browser context and one page, so the origin is the only discriminator
there is. `--attach U --attach-b U` is a null control `is_null_control`
detects on purpose, and it is the cheapest place to check that the metric can
see a known cost: one Studio, no installs. With the injection on, both arms
burned it, `evaluate_stream_cost_recovery_gate` read
`(injected_rate - base_rate)` as zero, and the gate failed with "the
accumulator is under-attributing" against a metric that was working. Refused
now, before anything is cloned or launched, with the two origins named.

THE INJECTION AMOUNT WAS NOT IN THE RESUME IDENTITY. A cell id carries the
rung, the arm and the repetition, so a treatment cell burning 3 ms per chunk
and one burning nothing are the same id. `--resume` against a FINISHED
uninjected payload therefore skipped every pair, exited 0 having measured
nothing, and left the recovery gate to be answered out of cells that were
never injected; a resume of a half-finished injected run without the flag left
the ladder part injected and part not. Recorded in run_meta and added to
IDENTITY_AXES beside `--stream-tail-chars` and `--corpus-dollars`, with
HISTORICAL_DEFAULTS reading absence as off so older payloads still resume.

A BURST STILL IN FLIGHT AT A WINDOW CLOSE WAS DROPPED. `read()` snapshotted
deltaTaskMs and reset it while the chain the last chunk started was still
open, so the MessageChannel callback charged that burst to a fresh accumulator
that nobody reads: `StreamCostInstrument.close` keeps only overhead_ms from
its tail read, and `open()` resets before the next window in any case. The
burst kept its characters in the denominator and lost its cost from the
numerator. Driving the shipped file in chromium against a real SSE response
read through a fetch reader at field cadence, a driver-side read found a chain
open 10 to 21 times in 2,600 to 5,500 reads, so this is small: a cell opens
about eight windows over its stream. It is still the file's own contract that
a burst is charged once, and a burst charged to nothing breaks it downward.

THE STOP SLOT'S RESERVE WAS SIZED FROM A SHIM WHOSE POLLS WERE FREE.
OWN_TURN_FIXED_MS counted the four sleeps the throwaway turn makes and nothing
else, because the page it was measured against answered in-process and its
clock only moved when wait_for_timeout was called. Driving the same shipped
stop_generation against real chromium and a real clock, the stretch after the
drain costs 1,394 to 1,451 ms on a page that answers instantly and 1,723 to
1,938 ms on one that takes 120 ms to start a turn, 90 ms to stop it and 60 ms
to delete it. Against 1,280 ms reserved, a fast-film sweep of every moment the
reply could drain overran the slot by up to 500 ms with 300 ms before
scroll_after opens, which scroll_after records as a missed slot and blames on
the machine.

Sized from that measurement (OWN_TURN_POLL_MS), and not only sized: the drain
loop tests its deadline at the top, so the iteration that finds the reply
drained has already spent a wait and a round trip past it, and no constant can
pay for time already gone. The action now re-reads the clock before it commits
to a turn it cannot abandon, and bounds the wait for that turn to start by the
slot rather than by a flat 8 s that is 2.7x the whole fast-film budget. The
stop-settle poll and STOP_CLEANUP_JS are deliberately left unbounded: once
Enter is pressed the turn has to be stopped and removed or every later action
measures the scaffolding, and a settle poll cut short would report a stop that
worked as still_running. The same sweep after the change stays 435 ms inside
the slot at its worst.

The stop-slot selftest now charges its shim for every page call and holds it
to a start, stop and delete latency, which puts the post-drain stretch at
1,688 ms against the measured 1,723 to 1,938 and reproduces the old 1,280 ms
exactly when the latency is switched off.
One conflict, and both sides are kept: the parent added COMMIT_AXES and this branch extended
HISTORICAL_DEFAULTS with inject_stream_cost_ms, and the two land at the same point below
TREATMENT_AXES without touching each other. They answer different questions. HISTORICAL_DEFAULTS
reads an axis a payload never declared as the default it must have run under, and COMMIT_AXES is
checked after the sides are up rather than in prepare_payload, because a commit cannot be known
before the fetch that resolves it.
Four conflicts and every one of them is the same shape: both branches added an identity axis in the
same four places, this one click_probe and the parent inject_stream_cost_ms. Both are kept
everywhere. The only hunk needing more than that was the HISTORICAL_DEFAULTS docstring, where each
side had extended one shared sentence with its own axis; the sentence now names both.
The loop in CONTRIBUTING-perf.md ran `--assert-liveness` after `floor_table` and
`ui_parity`, under a comment saying it comes before any timing is read. Following
the loop as written, the first thing a contributor sees is a verdict table built
from a payload nothing has checked for missed slots.

That table is not only early, it can be wrong. `paired` matches on the metrics
BOTH arms recorded, so a repetition whose action never reached its slot leaves the
table with no trace except a smaller `n`. A treatment build 10% faster on the three
repetitions it managed, and so slow on the fourth that `message_menu` missed its
slot, prints as

  message_menu.open_close_ms   3   1000.0   900.0   -10.0   0.0   0.3   faster
  1 metric(s) cleared all three gates.

With the fourth repetition's timing present the same run reads +30.0% and VOID
(pairs disagree on sign). `--assert-liveness` exits 1 on that payload either way,
so the only thing deciding whether the contributor sees a clean win or a void is
which command they were told to run first.

The selftest reads the documented loop and fails if any of `floor_table`,
`ui_parity` or `--report` is ordered ahead of the liveness gate, plus the pair of
runs above driven through the real `floor_table.main` and the real
`--assert-liveness`.
…throwaway turn the slot gave up on

Three follow-ups to the stream-cost injection guard and the stop slot's own-turn
reserve.

ONE ORIGIN SPELLED TWO WAYS GOT PAST THE INJECTION REFUSAL. `arm_origins`
compared the `--attach` URLs with a trailing slash stripped, and
`window.location.origin` -- which is the only thing `origin_scoped` can
discriminate on -- is the URL standard's canonical origin. Measured in chromium
against real documents, `http://studio:80`, `http://STUDIO`, `HTTP://studio` and
`http://studio/app` all report an origin of `http://studio`, and the shipped
predicate built from any of those four ran on NONE of them. So
`--attach http://studio --attach-b http://studio:80` is one server under two
names: the treatment's injection is gated on an origin no document has and burns
on neither arm, or, spelled the other way round, the base's predicate is the
dead one, the treatment's matches every document and both arms burn. Either way
the difference between the arms is zero and
`evaluate_stream_cost_recovery_gate` reports a working metric as
under-attributing, which is the exact verdict the refusal was added to prevent.
Both halves now read `browser_origin`, so the refusal and the predicate it
protects compare the same thing. `localhost` and `127.0.0.1` stay two origins,
because a browser treats them as two.

A TURN THE SLOT GAVE UP ON WAS LEFT GENERATING. Enter is pressed BEFORE the
turn-start wait, so bounding that wait by the slot does not return from a
decision, it returns from a turn the app has already accepted. Driving the
shipped action against real chromium on a page taking 1,800 ms to start, against
the fast film's 3,000 ms stop slot, it returned `not_run` after 1,759 ms and
handed on a thread with two extra messages in it and a live stream running
through `scroll_after`'s window. That is the scaffolding `STOP_CLEANUP_JS`
exists to remove, reached by giving up instead of by finishing, and every later
action, the final census and the seeded-versus-streamed comparison then measure
it. The wait is split rather than shortened: the slot bounds how long the turn
is worth MEASURING, `TURN_START_TIMEOUT_MS` bounds how long it is worth waiting
for so it can be taken back, and `_reclaim_pending_turn` stops it and deletes
it. It deletes only what it added, because `STOP_CLEANUP_JS` removes the LAST
assistant message and a send the app refused would have it take a seeded reply
instead, so the message count is read before Enter. A refused send still returns
at the slot bound, since nothing was committed there.

THE TURN-START BOUND RESERVED THE SLEEPS AND NOT THE POLLS. A turn starting on
the last millisecond the bound allowed still had the stop-settle poll, the
delete and the driver calls between them ahead of it, and the bound subtracted
`OWN_TURN_FIXED_MS`, which also counts the 80 ms already spent settling the
fill. Measured in chromium with the turn starting at the bound and a 3,000 ms
slot, the stretch after it cost 60 ms past the fixed sleeps on a page that
answers instantly, 227 ms at 90/60 and 424 ms at 200/150; the last of those put
the action 344 ms past its slot against the 300 ms the fast film leaves before
`scroll_after` opens, and it was recorded there as a missed slot.
`OWN_TURN_POLL_MS` is now split at the moment the turn starts and the bound
reserves the part that is still ahead. The same sweep after the fix peaks at
2,912 ms of a 3,000 ms slot.
One conflict, additive on both sides: both branches appended tests to the end of the sweep selftest,
this one the composer-click frame-floor test and the parent three tests for the documented loop
asserting liveness before it reads a timing. All four kept, and the names do not collide, which
tests/studio/test_no_test_shadows_another.py confirms.
Base automatically changed from studiobench-instrument-settled to main August 24, 2026 07:45
danielhanchen and others added 2 commits August 24, 2026 07:56
9542 landed as 02206f3; this resolves against that squash. Twelve hunks
across six files.

analysis/parity.py and scene/parity.js are this branch's own streamed-parity
feature and main holds only the pre-feature baseline, so every hunk there is
a strict superset. They were read as ONE pair rather than two files, because
parity.py consumes what parity.js captures: in_flight is emitted twice in
the JS and read twice in the Python, streamingMessages is defined in dom.js
and called from parity.js, and settled and uncomparable are both bound in
compare_visible.

The check worth naming is the elide parameter. parity.js gained a third
signature() argument, and a definition whose only caller had auto-merged
from main would have left the feature wired up and never invoked, with
nothing failing. Verified the call exists and is coherent: scaffold =
signature(root, undefined, new Set(nodes)) beside whole = signature(root).

localise is the same shape at the Python end: main has the two-argument
form, this branch widened it to three with the third defaulted, and the one
call site passes three. Not a loss, a widening.

scene/actions.py took MAIN's side, which is the combined comment written
while resolving 9542 and now arriving back through the squash. Same field
set either way. INTERFACES.md took this branch's two documentation
additions, no duplicate headings. Two whitespace-only hunks took main.

Nothing main has was removed: 36 main-side lines, all of them the
pre-widening localise body, and symbol parity holds on all eight axes.

tests/studio/studiobench: 1474 passed. ImportFrom and duplicate-def/const
AST sweeps both clean. All three negative controls re-run and all three
still fail without their fix.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Aug 24, 2026
Found by rehearsing the merge with unslothai#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 unslothai#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'`.
The blind-probe branch withheld the scaffold whenever generation_disagrees
said the arms were at different points in the turn. That predicate reads
composer_control, the token naming which control the composer rendered, so it
was excusing a composer difference with the composer.

A treatment that drops the Stop control, renames it, or selects the wrong one
makes the tokens differ for exactly that reason, and the scaffold carrying the
regression went out with the refusal while streaming and queued_idle were
saying the arms had been in the same run state all along. Since report files a
refusal under blind and takes its exit code from stable_bad or one_sided, the
run went green on it.

This is the same circle the settled-pair composer suppression was already
fixed for, and it is now the same guard: the disagreement has to be visible in
streaming or queued_idle, which are read off the thread's run state and are
not derivable from which button was drawn.

Both directions pinned. An uncorroborated composer difference is reported, and
a genuinely cross-run-state pair is still withheld, since quoting that would
manufacture the wall-clock false alarm this file exists to remove.
A refusal that names one cause reads as having ruled out the others.
digest_scaffold is a single digest over the viewport, the composer dock and
the empty state together. The suppression is justified by the composer swap
alone, but the reading it acts on cannot tell that swap apart from a change to
another scaffold surface captured at the same time, so such a change rides
along inside the refusal.

Unqualified, the sentence reads as "only the composer differed", which is a
stronger claim than the reading supports and the one a reader would act on. It
now states the aggregate and states what it could not separate, which is also
part of why the honest verdict there is a refusal rather than a pass.

Separating the two for real needs a composer-scoped digest the payload does
not carry today. That is worth doing and is not done here: the elision has to
be validated against Studio's own composer markup, since if the dock differs
across run states in any way beyond the control itself, a stable digest that
disagrees would put back exactly the wall-clock false alarm this branch exists
to remove.

@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: 771ba41c04

ℹ️ 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 +535 to +536
if b.get("role") == "user" and b.get("digest") != t.get("digest"):
out.append(f"msg{i}(user):{b.get('chars')}->{t.get('chars')}c")

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 Score earlier assistant rows during blind streams

Fresh evidence beyond the prior user-row fix: on a full-mounted thread, an earlier assistant message is necessarily settled while generation is writing the tail, but this predicate preserves digest differences only for user rows. If the treatment blinds the status probe and also changes an earlier assistant response, settled_messages_moved() returns nothing, the Stop/Send scaffold is suppressed as run-state drift, and compare() returns NOT_COMPARABLE; structural_report then places the pair in blind and the regression can leave the run green. Preserve assistant rows that can be proven to precede the active tail; the duplicated visible-mode predicate has the same gap.

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.

I tried this and it does not work, so I am recording the reason in the code rather than leaving it to be proposed again. See 757ce3d.

Your premise is right twice over. An earlier assistant row on a fully mounted thread is settled while the tail is written, and it can even be made provable WITHOUT knowing which row is in flight: a thread writes one reply at a time, so two differing assistant rows cannot both be it, and the excess is a rendering difference. I implemented that counting version, since it needs no assumption about the stream being in the last message.

What breaks it is the thing that blinds the probe in the first place. The reachable blind pair is a build that renamed the data-status hook. That attribute is on the assistant text part and the digest walks attributes, so the rename that blinds the probe ALSO moves the digest of every assistant row by itself. Reporting those rows therefore turns every genuinely blind pair into a difference, which is the wall-clock false alarm this file exists to remove wearing the other hat. Measured, not reasoned: the counting rule flipped the blind control in test_a_settled_queued_idle_pair_is_scored_rather_than_refused from NOT COMPARABLE to DIFFER.

A user row is not exposed to that, and that is precisely why it is the one shape that qualifies -- the hook is not on it. Separating "the hook attribute moved" from "the content moved" needs a digest that excludes the attribute, which this capture does not carry.

Once a queued entry is dispatched, ComposerRightControls renders Stop queued
message under isQueueRunning and not thread.isRunning, so the thread reports
itself not running and neither control isRunning() matches is present. Both
streaming and queued_idle therefore came back false, which is exactly how a
settled Send arm reads.

That matters now that the scaffold suppression requires independent run-state
evidence. An arm caught in that interval against a settled one had a differing
composer and a differing scaffold with no run-state difference to account for
it, which is the shape the comparison layer is entitled to call a rendering
regression. It is queue timing, and calling it a regression is a false red the
corroboration guard would otherwise have introduced.

Recognised from its own control rather than from the queue surface, because
getPromptQueueUIItemsForRun drops dispatched items, so the stack can be absent
in exactly this state. Pinned live against the real markup: the pair now
refuses in both directions, and without the fix queued_idle reads false on the
dispatched arm.
The bounded computed-style probe is an independent reading: it is computed
styles, not the DOM digest. So a pair refused for landing at two points in one
live reply can still carry a real CSS regression on a settled surface, and it
is the only mechanism here that sees display, visibility or pointer-events at
all.

The NOT_COMPARABLE bucket sat above the style check and continued, so that
verdict was computed, attached to the row, and then dropped -- for exactly the
pairs a streamed-parity refusal creates most of. The refusal is right and
stays; losing the other reading with it is not.

Read through .get, since the rows built for a refusal elsewhere in this file
carry no style verdict at all. style_bad is advisory and feeds no exit code, so
this surfaces a reading that was being discarded rather than changing what
fails.

@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: a616c3eb7f

ℹ️ 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 +934 to +936
queued_idle: Boolean(
(running || (dom.stopQueuedButton ? Boolean(dom.stopQueuedButton()) : false)) &&
!generating

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 Distinguish dispatched from undispatched queue waits

When the two arms straddle the queue entry becoming dispatched, the undispatched arm renders Queue message while the dispatched arm renders Stop queued message, but this expression records queued_idle=true for both. Their composer tokens and scaffold digests therefore differ while _run_state_disagrees() returns false, so compare() reports DIFFER even though this is ordinary queue timing; the new self-test covers dispatched-versus-settled but not this adjacent queued-idle transition. Record the dispatched substate separately or otherwise refuse this control swap.

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.

This one does not hold: _run_state_disagrees() returns True for that pair, so compare() already returns NOT_COMPARABLE rather than DIFFER.

It is an or over two fields (analysis/parity.py:465), and queued_idle is only the second. The first is streaming, which is dom.isRunning() (scene/parity.js:900, dom.js:100), and isRunning() is stopButton() || queueButton(). The undispatched arm renders aria-label="Queue message" so streaming is true; the dispatched arm renders aria-label="Stop queued message", which matches neither selector, so streaming is false. dom.js:91-98 documents exactly that. queued_idle being true on both is real, it is just not the only evidence available.

Measured on both arms through the PR's own scene JS: streaming True against False, queued_idle True on both, _run_state_disagrees True, compare() not_comparable. The two controls are also mutually exclusive, a ternary on queueEntry.dispatched in ComposerRightControls (thread.tsx:6500-6529), and PromptQueueStack renders no Queue button, so no arm can carry both. The remaining suggestion is a self-test for a case that already behaves correctly.

It looks like the obvious next rule to add, and it does not work. Writing down
which reading was tried and what it cost, so it is not tried again.

An earlier assistant row on a fully mounted thread really is settled while the
tail is written, and a counting argument makes it provable without knowing
which row is in flight: a thread writes one reply at a time, so two differing
assistant rows cannot both be it. Both readings are sound.

Both are unusable, because of what blinds the probe in the first place. The
reachable blind pair is a build that renamed the data-status hook. That
attribute sits on the assistant text part and the digest walks attributes, so
the rename that blinds the probe also moves every assistant row's digest by
itself. Reporting those rows turns every genuinely blind pair into a
difference, which is the wall-clock false alarm this file exists to remove
wearing the other hat. Implementing the counting rule flipped the blind control
in test_a_settled_queued_idle_pair_is_scored_rather_than_refused from NOT
COMPARABLE to DIFFER.

A user row is not exposed to that, which is exactly why it is the one shape
that qualifies: the hook is not on it.
styleProbe puts the matched selector name into its signature and the composer
run-state buttons are in STYLE_SELECTORS, so two arms straddling a run-state
boundary move the digest on the button name alone, over identical display,
visibility and pointer-events. Neither queue control is in the list at all, so
those pairs move the element count instead and take the differ branch. Since
the refusal now collects the style verdict before bucketing, that printed a
style regression advisory for the ordinary timing this change withholds.

Gate it on the same corroboration the scaffold suppression uses, so a
treatment that drops or renames the control is still reported. Withheld as
not comparable rather than a match: the digest is one aggregate, so a real CSS
difference elsewhere cannot be separated out here.
@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
@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 added a commit that referenced this pull request Aug 25, 2026
* studiobench: two ui parity gates that could only ever say yes

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.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten the comments added by the ui parity gate change

* Check the ui parity coverage floor once per payload pattern

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* studiobench: losing the thread outranks the collision refusal

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'`.

* Record the third UI parity exemption in the policy the gate prints

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.

* Say that clipboard completeness is scored by length, not by content

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.

* Stop behavioural coverage standing in for visible coverage

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.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Withhold the no-verdict banner when invariants broke

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.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
One conflict, in INTERFACES.md, where both sides documented a different
finding at the same point in the parity section. Kept both paragraphs
rather than choosing: they describe unrelated mechanisms.

main's paragraph covers two mounted rows publishing one position, which
makes the capture short by a row and is counted as ordinal_collisions.
This branch's paragraph covers the streaming probe's positive control
travelling with the visible payload, since compare_visible never sees the
structural one.

Verified after resolving, rather than trusting the clean merge: both
paragraphs present, no conflict markers anywhere in the tree, and a
scoped AST sweep for duplicate definitions across studiobench came back
clean. The sweep matters here because parity.py, ui_parity.py, parity.js
and test_studiobench_windowed_parity.py all auto-merged outside the
markers, which is where an unfaithful merge usually lands.

pytest tests/studio/studiobench: 1508 passed.

@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: b6507dae52

ℹ️ 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".

and _run_state_disagrees(base, treat)
and scaffold_moved(base, treat)
and not overlays_moved(base, treat)
and not _messages_moved(base, treat, streaming)

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 Preserve in-flight role changes when suppressing the composer

When one arm is still generating and the other has settled, a treatment that changes the live row from data-role="assistant" to user reaches this branch: streaming contains that index, so _messages_moved(..., streaming) skips the entire row—including its separately captured role—while scaffold_moved is true from both the role marker and the expected Stop/Send swap. The result is incorrectly NOT_COMPARABLE with the claim that every message agreed, and report() can leave the run green, even though a role change is independent of stream position and compare_visible() already reports the same case explicitly. Check in-flight roles separately before applying this composer-only suppression.

Useful? React with 👍 / 👎.

: false;
const anyPublishes = dom.statusHookPresent ? Boolean(dom.statusHookPresent()) : true;
const windowedArm = dom.isWindowed ? Boolean(dom.isWindowed()) : false;
const probeBlind = lastPublishes ? !windowedArm : !anyPublishes;

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 Detect status hooks removed only from the running part

When a treatment omits data-status only while a text part is running but leaves it on older completed assistant parts, streamingMessages() returns no live row, lastPublishes is false, and anyPublishes remains true. This expression therefore classifies the capture as the ordinary pre-first-part gap instead of a blind probe, so both structural and visible comparison paths digest two wall-clock stream positions as settled content and can report a false DIFFER. The gap case needs to be distinguished from a last assistant row that already contains rendered part content but no longer publishes the hook.

Useful? React with 👍 / 👎.

Comment on lines +811 to +812
generation_disagrees(base, treat)
and _run_state_disagrees(base, treat)

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 Withhold queue timing when both states render Queue

When one arm is actively streaming with queueable composer text and the other is in the undispatched queued-idle interval, both arms render Queue message, so generation_disagrees() is false even though _run_state_disagrees() correctly sees queued_idle change. The queued-idle arm additionally renders PromptQueueStack and uses a different button wrapper, so the scaffold moves and this condition is bypassed; compare() then reports a structural DIFFER for ordinary queue timing rather than withholding it. The run-state disagreement must also cover this same-control transition instead of requiring the composer token itself to differ.

Useful? React with 👍 / 👎.

# list that refuses the verdict below rather than the list that fails it. Same
# rule as `compare` applies to the structural digest; the two modes must not
# disagree about which readings have a defined moment.
uncomparable.append(ordinal)

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 Report streaming residue separately from unmounted rows

This newly appends a still-mounted in-flight ordinal to not_digested, but visible_report() interprets every value in that field as a row that was unmounted before capture and prints exactly that diagnosis in both its count and detail section. Consequently any visible pair refused because its live message was still being written is reported as a virtualization/unmounting failure, sending readers toward the wrong cause. Carry a residue reason or separate fields for in-flight and unmounted ordinals before exposing them to the existing reporter.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen merged commit 5cdeb9a into main Aug 25, 2026
27 checks passed
@danielhanchen
danielhanchen deleted the studiobench-streamed-parity branch August 25, 2026 02:06
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