Repository navigation
studiobench: refuse a streamed tail the corpus cannot deliver - #9659
Conversation
`--stream-tail-chars N` is the only way to vary reply length in this tool, and it silently under-delivered. The tail is one corpus unit and `clipped_to` returns the unit unchanged when the ask exceeds it, so delivery is capped at that unit's size. Asking for more tail lowers that cap rather than raising it: a bigger tail shrinks `seed_target`, which moves the streamed turn to a lower index, and the corpus escalates in size. Measured at 100K with a 400,000 character request: 15,405 characters streamed (3.9%) on a thread of 18,122 against the rung's 397,755 (4.6%), still carrying the `r100K` cell id that scoring and the report use as the rung key. `--assert-liveness` returned 0 scene problems, 0 missed slots, exit 0, byte-identical to the default run, because a saturated tail drains faster than the film it was meant to outlast. The guard keys on `clipped_to`'s own early return rather than on a percentage, because the two ways a tail lands under budget differ in kind: block-boundary clipping loses at most one block and keeps a prefix from ending inside a fence, while exceeding the unit is unbounded. The default ladder is untouched. The existing reply-axis test asserts the right property at the 100K rung with 24,000 and 96,000 only. Across the ladder, 10 of 15 pairs failed its own two assertions; it covered exactly the 2 that passed. The new test is the matrix.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c6decfe44
ℹ️ 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 DEFAULT path is exempt on purpose: `STREAM_TAIL_CHARS` is a ceiling the small rungs are | ||
| # legitimately under (the 1K rung is 4,000 characters in total, less than one tail), and that | ||
| # shortfall is the rung being small rather than the corpus failing to answer. | ||
| if stream_tail_chars is not None and tail_target >= source.chars: |
There was a problem hiding this comment.
Allow tails equal to the source unit
Using >= rejects requests that the corpus can deliver exactly. For example, plan_rung(corpus, "100K", stream_tail_chars=133_113) selects unit 8, whose size is exactly 133,113 characters; the resulting thread would be 399,282 characters against the 400,000 target, yet this branch raises and even reports that the reply would be 100.0% of the request. Since clipped_to returns the complete unit when the sizes are equal, only requests strictly larger than source.chars should be refused.
Useful? React with 👍 / 👎.
| f"the reply would be {deliverable / requested:.1%} of the one asked for. Asking for more " | ||
| f"tail makes this worse rather than better, because the seeded prefix shrinks to pay for " | ||
| f"it and the streamed turn moves to a smaller unit -- here the thread would collapse to " |
There was a problem hiding this comment.
Avoid claiming larger tail requests always reduce capacity
The frozen unit sizes are jittered rather than monotonic, so moving to a lower source index does not necessarily select a smaller unit. At the 100K rung, a 119,000-character request selects unit 9 (118,955 characters) and is refused, but increasing the request to 133,000 moves it to unit 8 (133,113 characters) and succeeds. The message therefore sends users in the wrong direction when it says increasing the request necessarily makes matters worse and advises only lowering it; describe the non-monotonic selection instead.
Useful? React with 👍 / 👎.
What this fixes
--stream-tail-chars Nis documented as the only way to vary reply length in this tool. It silently under-delivered, and in a way that corrupted the rung label at the same time.Two effects compound, and fixing only the one you notice leaves the other:
clipped_toreturns the unit unchanged when the ask exceeds it (fixture/corpus.py,if chars >= self.chars: return self). Delivery is capped at that unit's size.seed_target, which moves the streamed turn to a lower index, and the corpus escalates in size. At the extreme the seeded prefix is evacuated entirely and the rung's thread goes with it.Measured at 100K with a 400,000 character request, before this change:
The cell still carried the
r100Kid thatscoring/from_payload.pyandreport/build.pyuse as the rung key, so an 18,122 character thread was recorded, weighted and reported as the 100K rung.The check that should have caught it goes quieter as the input gets worse.
--assert-livenessreturned0 scene problems, 0 missed slots, exit 0, byte-identical to the default run, because a saturated tail drains faster than the film it was supposed to outlast. That is the shape of catalogued defect 13: a gate that cannot report the other answer is not a gate.Delivery across the ladder, before and after
ok= accepted, and every accepted pair now lands within 10% of the request with the thread within 5% of the default. Every refused pair is one that previously under-delivered silently.Before, those
refusedcells returned 15,405 / 11,374 / 133,113 / 306,669 / 290,984 characters with no warning of any kind.Why a mechanism predicate and not a tolerance
The guard keys on
clipped_to's own early return, not on a percentage. The two ways a tail lands under its budget are different in kind and only one is a defect:A percentage bound cannot separate those, and a bound nobody can derive is an unacknowledged bias rather than a tolerance.
The default ladder is untouched
The guard is scoped to an explicit request.
STREAM_TAIL_CHARS = 6_000is a ceiling the small rungs are legitimately under (the 1K rung is 4,000 characters in total, less than one tail), and that shortfall is the rung being small rather than the corpus failing to answer. Default numbers do not move by a character at any rung.Test coverage, and an honest note about it
test_studiobench_reply_axis.pyalready asserts the right property, reply within 10% and thread within 5%, but only at the 100K rung and only at 24,000 and 96,000. Re-running its own two assertions across the ladder, 10 of 15 (rung, tail) pairs failed them. The shipped test covered exactly the 2 that passed. A test can be right about the property and wrong about the coverage; the new file is the matrix.Teeth confirmed by mutation, each restored from a byte snapshot with md5:
STREAM_TAIL_CHARSabove the smallest unitOne mutant is NOT caught and the test file says so. Dropping the
stream_tail_chars is not Noneexemption leaves all selftests passing and the default ladder byte-identical, becauseSTREAM_TAIL_CHARS(6,000) is below the smallest corpus unit (11,374), so the guard's other half cannot fire on the default path. That clause is defensive, not load bearing. Rather than fake coverage of an unreachable branch,test_the_default_exemption_is_currently_unreachable_and_says_sopins the premise, so a re-freeze with smaller units or a raised constant fails loudly and someone re-checks.A wording bug this shipped with for one revision
The first draft of the refusal said "ask for at most 15,405 characters". That is confidently wrong: the ceiling rises as the request falls, because a smaller tail leaves a longer seeded prefix which draws the streamed turn from a larger unit. At 100K it would have told the reader to ask for at most 15,405 while 96,000 succeeds, a factor of six in the direction that makes someone abandon a measurement they could have taken. A refusal that names the wrong number is worse than a vaguer one.
test_the_refusal_does_not_name_a_maximum_it_has_not_computedpins it.No re-freeze is needed, and please do not do one by analogy
corpus_hashcovers eight generator parameters plus each unit'ssha256.STREAM_TAIL_CHARSis not among them,freeze()never reads it, andclipped_toproduces a read-time prefix that never touchesunits.jsonl. Verified across tails from 6k to 200k: the hash stays23cd2464.... Task #118's re-freeze was driven bymanifest_unit_count, a different lever. This change is hash-neutral, so everything measured before it remains comparable.A suspicion I checked and withdrew
While tracing this I suspected that nothing mechanically refuses to pool payloads taken at different tails, on the grounds that
scoring/ab.py'sCOMPARABILITY_FIELDSdoes not mentionstream_tail_chars. That was wrong and I am recording it rather than quietly dropping it.scoring/ab.pyis an intra-payload backstop whose only caller builds both identities from one dict. The real cross-payload key isscoring/payload_rules.py, which does carrystream_tail_chars, and three gates refuse on it:--compareexits 1,floor_table.renderraises, and--resumerefuses under a changed tail. There is also an existing producer-in-the-loop test that enumerates the field list rather than hard-coding it. No change was needed and none was made.Scope
This does not change what the rung ladder varies, and it is not a venue claim.
The ladder pins the streamed tail at 6,000 on every rung deliberately, and that pin should stay. It is a one-way fix: the tail originally grew with the rung, and it was pinned because at field cadence the stream drained in 811 s at 1M against a 135 s film, so every slot labelled "after the reply is complete" ran mid-generation. Scaling it back would also make
analysis/fit.py's published exponent unidentifiable, since a tail proportional to the rung reportsb = 1.00for a purely reply-driven cost that never touches the thread, andfit.pyreadsb ~ 1as "linear in thread length".What this change does is make the orthogonal axis trustworthy, so that a reply-length measurement at a large rung either happens or fails loudly.
Testing
tests/studio/studiobench: 1442 passed.ruff check tests/studio/studiobench: clean.ImportFromacross the package: 0.git status --porcelaindiffed before and after the full test run: no stray files.