Calibrate the killswitch perf guards to the claim, not to a machine#567
Merged
Conversation
`assert authz["median"] < 5.0` is red on main-merged PRs. It failed at 5.418 and 5.453 on PR #566, whose diff cannot touch authz at all, minutes after passing on main with the same test. Same code, different runner. The ceiling was never careless, and that is the interesting part: developer machine 0.253us what it was calibrated against old ceiling 5.0us ~20x the dev number; reads as generous shared CI runner ~5.44us ~21x SLOWER than dev for this in-memory call Written on a machine where it had 20x headroom, it lands a hair under the actual cost on a runner that is ~21x slower at a no-I/O `Policy.evaluate`. Nobody would guess that ratio, which is why the number survived review. Main cleared it by luck; the next PR did not. Assert the shape of the claim instead. Policy.evaluate is an in-memory decision, so it costs microseconds; a regression that matters means someone put a lookup on the decision path, and that costs milliseconds. Between runner noise and a real regression sit three orders of magnitude, so any ceiling in that gap catches everything this test exists to catch while ignoring which CPU GitHub assigned. 50us is ~200x the dev median, ~9x the CI median, and mirrors the headroom the replay floor already had (78k/s observed against a 10k/s floor) which is exactly why that assertion never flaked and this one did. The paper's numbers are unaffected: they come from a deliberate CORA_PERF_OUT run on the developer testcontainer, not from this guard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The symptom
assert float(authz["median"]) < 5.0is red on any PR merged against main. It failed at 5.418 and 5.453 on #566, whose diff cannot touch authz at all, minutes after passing on main with the identical test. Same code, different runner.Why it looked safe
This is the part worth knowing, because the ceiling was not careless:
Written on a machine where it had 20x headroom, it lands a hair under the real cost on a runner that is ~21x slower at a no-I/O
Policy.evaluate. No author would guess that ratio, which is why the number survived review. Main cleared it by luck; the next PR did not.Note the units:
authz_decision_usis microseconds (perf_counter_ns() / 1000.0 / batch). The old gate asserted that an in-memory decision completes in under five microseconds on shared infrastructure, and the overage was 0.4us. It was measuring which CPU GitHub assigned.The fix
Assert the shape of the claim, not a budget.
Policy.evaluateis an in-memory decision with no I/O, so it costs microseconds. A regression that matters means someone put a lookup on the decision path, and that costs milliseconds.Three orders of magnitude separate noise from a real regression, so any ceiling in that gap catches everything this test exists to catch while ignoring the runner. 50us mirrors the headroom the replay floor already had (78k/s observed against a 10k/s floor, ~8x), which is exactly why that assertion never flaked and this one did.
What is not affected
The paper's numbers. They come from a deliberate
CORA_PERF_OUTrun on the developer testcontainer, which writesdata/killswitch_perf.json. This guard only runs whenCORA_PERF_OUTis unset. Nothing the actor-symmetry paper reports changes.The correctness assertion.
runs_held == kacross the K sweep is untouched: that is the actual claim (onePolicyGrantRevokedholds all K runs) and it is timing-independent.Verification
Run against real Postgres locally (testcontainers,
pgvector/pgvector:pg18): passes, median 0.253us. Both assertions now carry a message naming what a real failure would mean, and the constants carry the measurements above so the next person tightening them knows what they are fighting.Unblocks #566.
🤖 Generated with Claude Code