Skip to content

feat(bench): price refusal rendering by strategy and explicit residency - #904

Draft
wenzowski wants to merge 4 commits into
mainfrom
claude/cloud-1606-refusal-render-perf-k7nr2y
Draft

feat(bench): price refusal rendering by strategy and explicit residency#904
wenzowski wants to merge 4 commits into
mainfrom
claude/cloud-1606-refusal-render-perf-k7nr2y

Conversation

@wenzowski

Copy link
Copy Markdown
Contributor

Closes CLOUD-1606.

What this measures

Six deterministic renderings — three strategies × two explicitly supplied residency inputs — over two committed classes, one per route kind, all through the shipped hook::deny_text path. Cold and Warm are benchmark inputs: nothing in this repository detects residency, and a successor that wants to act on it must name its own explicit authority.

bench/refusal-render/RESULTS.md is the record. The drift check is the tier's, not the task's: the six records are re-rendered in-process and diffed against the committed bytes, so the report cannot go stale without test:cargo reddening — which is what lets the task stay off the landing path.

The finding, and it corrects the row

CLOUD-1606's fourth expected relationship — a full warm delivery is longer than a compact repeat — is false over what this repository emits, and the tier records the correction rather than the expectation.

class emitted (cold = warm) unbounded first sighting
branch write unsafe (2 command routes) 31 chars / 7 tokens 156 chars / 40 tokens
tool run loose (1 document route) 35 chars / 8 tokens 35 chars / 8 tokens

No first sighting in this repository carries a route at all, and the two classes reach that by different mechanisms:

  • branch write unsafe declares two command routes and would render them, but the carried line is 40 estimated tokens against a committed [refusal] max_tokens of 24, so deny_text falls back to the compact form. A budget decision.
  • tool run loose declares a document route and no command route, and a first sighting appends command routes only — so it renders the identical line however much budget there is. A renderer gap, which is CLOUD-1637's.

Every arm therefore carries an unbounded column beside the emitted one, and those are two test cases rather than one: a single > over the emitted column would have reported the budget decision as a renderer defect.

Notes

  • The mutation //MUTANT current-warm-first-sighting lives on the projection in perf.rs; engine-perf joins MUTANT_GATES, since a module that declares a row without being in the set censuses as uncovered.
  • The report is emitted in prettier's own canonical shape. prettier owns every tracked Markdown file including this generated one, so a generator emitting unpadded tables would leave a tree the fixer rewrites and a drift check that then fails against the bytes the fixer just produced.
  • address-transport-bench joins acquisition_metric's BENCH_TASKS while that table is open: the task's own comment claims the assertion covers it and the table did not.
  • Untouched: hook.rs, refusal.rs, verdict.rs.

Generated by Claude Code

`hook::deny_text` has always taken a `first_sighting: bool` and rendered
differently on either side of it, and nothing had ever priced the difference.
CLOUD-1053 and CLOUD-417 both argue about refusal repetition without a number;
this supplies the number and nothing else.

`perf` gains the projection — `Strategy x Residency -> first_sighting` — the
record, and the report's bytes. The renderers are untouched: `deny_text`,
`Refusal::line` and `verdict::render_line` stay the authorities, and a bench
that re-implemented any of them would measure itself.

TWO CLASSES, ONE PER ROUTE KIND, and that is the half a single-class matrix
would have got wrong. A first sighting appends `command` routes only, so
`branch write unsafe` (two command routes) prices the renderer's best case
while `tool run loose` (one `document` route, no command route) renders the
identical bare line cold and warm.

THE ROW'S FOURTH EXPECTED RELATIONSHIP IS REFUTED AS STATED, and the tier
records the correction rather than the expectation. Over what this repository
EMITS, a full warm delivery is not longer than a compact repeat: the carried
line for `branch write unsafe` measures 156 characters and 40 estimated
tokens, the committed `[refusal] max_tokens` is 24, and `deny_text` drops the
routes rather than exceed the budget. So no first sighting in this repository
carries a route at all — for that class because the ceiling withholds it, and
for the document-only classes because the renderer filters them. The margin is
real in the renderer and withheld by the budget, which is why every arm also
carries an unbounded column and why those are two cases rather than one: a
single `>` over the emitted column would have reported a budget decision as a
renderer defect.

THE REPORT IS EMITTED IN THE FORMATTER'S OWN SHAPE, which is what keeps one
file under one authority. prettier owns every tracked Markdown file including
this generated one, so a generator emitting unpadded tables would leave a tree
the fixer rewrites and a drift check that then fails against the bytes the
fixer just produced. `markdown_table` emits what prettier would leave, so both
agree and neither has to yield.

The tier carries the drift check rather than the task: the six records are
re-rendered in-process and diffed against the committed report, so the file
cannot go stale without `test:cargo` reddening — which is what lets the
benchmark task stay off the landing path.

`engine-perf` joins `MUTANT_GATES` because the module now declares a row; a
module that declares one without being in the set censuses as `uncovered`.
`address-transport-bench` joins `acquisition_metric`'s table while it is open:
that task's own comment claims the assertion covers it and the table did not.

Refs: CLOUD-1606
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1fc32e7b-163a-4353-a1b3-e73ea019c85f

📥 Commits

Reviewing files that changed from the base of the PR and between c336eca and c9f7e9a.

📒 Files selected for processing (5)
  • batten.toml
  • crates/batten/src/mutate.rs
  • crates/batten/src/perf.rs
  • crates/batten/tests/it/mutate.rs
  • crates/batten/tests/it/refusal_render_bench.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6d17d319-ed4f-403f-acee-ca6334f3fa30

📥 Commits

Reviewing files that changed from the base of the PR and between 7fe35ef and c336eca.

📒 Files selected for processing (7)
  • bench/refusal-render/RESULTS.md
  • crates/batten/examples/refusal-render-bench.rs
  • crates/batten/src/perf.rs
  • crates/batten/tests/it/acquisition_metric.rs
  • crates/batten/tests/it/main.rs
  • crates/batten/tests/it/refusal_render_bench.rs
  • mise.toml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds a deterministic refusal-rendering benchmark for strategy and residency combinations. The benchmark measures emitted and unbounded character and token counts through the shipped refusal path. A new example writes a versioned Markdown report. mise registers the task and metric, and mutation gates include engine-perf. Integration tests validate matrix shape, rendering semantics, ceiling behavior, output constraints, and report drift.

Merge Risk: ⚪ Minimal · up to c336e

This change adds deterministic refusal-render measurements, a generated report, and task/test wiring without changing refusal behavior. The committed report is checked against current rendering, and no merge-blocking risk is evident.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 79.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 5 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: measuring refusal rendering by strategy and explicit residency.
Description check ✅ Passed The description is directly related to the benchmark, its measurements, report, drift checks, and integration changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 79.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 5 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/cloud-1606-refusal-render-perf-k7nr2y

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…roken harness

The staged tree persists between runs by design — that is what keeps an
unchanged source's timestamp and a compiled tier affordable — so `add -A`
stages nothing on every run after the first and a plain `git commit` exits 1
with "nothing to commit, working tree clean". `make_a_repository` bailed on
that, and the message it bailed with named the wrong thing entirely: it
reports a tree that cannot be made a repository, over a tree that already is
one, at exit 3.

Measured here, and it is why this is a fix rather than a row: the first sweep
in this checkout ran, and every sweep after it was could-not-look. That is the
shape a reader debugs for an hour before suspecting the harness rather than
their own gate — and it made CLOUD-1606's declared mutation unrunnable.
`--allow-empty` is the whole change; the case runs the toy sweep TWICE over
one root, because a fresh root per run is precisely what hides this.

AND THE MUTATION IT UNBLOCKED THEN SURVIVED, which is the finding that came
with it. `a_compact_warm_repeat_is_exactly_the_refusal_line` asserted over the
EMITTED line, and the emitted line is `Refusal::line()` on both sides of
`first_sighting` in this repository: the ceiling withholds the routes for
`branch write unsafe` and the renderer appends none for `tool run loose`. So a
projection defect is invisible in what this repository emits — a fact about
the repository, not a reason to assert less. The case now also asserts the
unbounded rendering, which is where `first_sighting` is observable at all, and
`mutate sweep` reports the row caught.

Refs: CLOUD-1606
…ment

The gate's own walk of `crates/batten/tests/**/*.rs` reads 231 against a
declared 220, eleven past a tolerance of 10. `main` carries ten of those and
this branch one, so this is the sixth entry of the shape the five above it
describe: the basis trailing the tree, caught.

Neither floor moves, for the 2026-09-06 entry's reason unchanged — a tracked
test file stopped being a proxy for a linked stem at the target consolidation,
so this basis is a trend counter over a quantity that no longer drives the
bytes the floors budget, and an exact floor needs a from-empty build this
container cannot hold.

Neither `measured` moves either, which is where this parts from the 2026-09-06
entry and follows the 2026-09-05 one. `measured` records when the FLOOR was
measured; bumping it to satisfy the refusal's own sentence performs the
staleness the field exists to record. A basis at 231 beside floors dated
2026-09-06 says what happened. A matching date would have claimed a
measurement nobody took.

Measured on this lap, and it is the sixth time the caller has misreported it:
`verify` rendered the refusal as "not enough disk to run the gate" with 19154
MB free against a 9472 MB warm floor. Twice the floor, and a stem count is
what refused.

Refs: CLOUD-1606
Admits: 2f89b34a8d87d2877f624a48fb26743613eab30d430a74515fe063ca5ec3083d
Admits-rule: protected-mutation
Admits-verdict: path write refused
Admits-subject: batten.toml
Admits-anchor: call:24c93bf070024ffba2eaeab063321a512188ce62
Admits-epoch: 981bf458ab45817a1c791dfae4d94fcfc212648592a708dc945e59431350169d
Admits-author: alec@wenzowski.com
Admits-prev: -
Admits-answer-lost: Every lap in this checkout stays refused. `target-prune` gates `verify`, so with the basis eleven past its tolerance no receipt can be written and nothing can be readied or landed — by a gate that is, on its own terms, correct: the basis really has trailed the tree, and only the committed config can say so.
Admits-answer-precondition: No surface writes this value. `batten target prune` READS `[prune.warm.basis] count` and refuses against it; there is no verb that moves it, and the refusal's own remedy is to move `count` and `measured` in the committed config by hand. The write is two integers, 220 -> 231, and it lands in the diff of the PR closing CLOUD-1606 where a reviewer sees it beside the entry explaining it.
Admits-answer-rejected-route: `config read first` points at `batten.toml` and is a READ route; it is how I found the declared 220 and the tolerance, and it cannot change either. `patch run first` is `git restore`, which would discard the basis move and restore the refusal it repairs. Neither reaches the value, which lives only in the committed config.
…s halves

Three workspace lints over the new code, and one of them is answered with an
`expect` rather than a rewrite because the rewrite would cost the thing the
code is for. `match_same_arms` sees `Current`/`Warm` and
`FirstFullThenCompact`/`Warm` agreeing today and offers to collapse them: each
is one declared row of the strategy table, the first is the anchor a declared
mutation rewrites, and a collapsed pair is beyond both the sweep's reach and a
reader's. The `expect` says so on the line it describes.

The other two are ordinary. `format_push_string` goes by building the pipe
line from pieces instead of formatting into a push, and `too_many_lines` by
splitting the report's prose preamble from its tables — two halves different
people read.

`bench/refusal-render/RESULTS.md` regenerates byte-identically across the
split, which is what says the refactor moved no measurement.

Refs: CLOUD-1606
@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

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