console: TestWildcardEnableIsNotRateLimited must clear the instance budget, not just stay under the ceiling
Round 2's fix (domainsCeilingBurst/2 = 60) happened to equal cliInstanceBurst (60) exactly, so the test passed for a reason unrelated to its claim: the same 60 attaches would have passed even with the exemption removed and the instance budget still applied. attempts is now (cliInstanceBurst + domainsCeilingBurst) / 2 = 90, strictly above the workload budget the door must be exempt from and strictly below the convergence-rate ceiling that still applies, with a runtime assertion (cliInstanceBurst < attempts < domainsCeilingBurst) so a future change to either constant that collapses the gap fails the test loudly instead of letting it quietly stop proving anything. Verified the assertion actually fires by temporarily colliding the two constants locally and reverting.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016UimU7fAfeAoBMm6HKCPwQ
1 file changed,
+15
−6
internal/console/apidomains_test.go+15 −6
diff --git a/internal/console/apidomains_test.go b/internal/console/apidomains_test.go| index a7a4fa59b..602bb51d2 100644 |
| --- a/internal/console/apidomains_test.go |
| +++ b/internal/console/apidomains_test.go |
| @@ -1096,14 +1096,23 @@ func TestDelegationZoneInvalidAtConstruction(t *testing.T) { |
| // TestWildcardEnableIsNotRateLimited: a Pages hub with wildcard DNS makes no |
| // per-repo hostname call at all — one claim on the hub host with both flags, |
| // every repo's subdomain serves off the catchall. So the domains doors are |
| -// EXEMPT from the write/instance WORKLOAD budgets rather than uplifted — |
| -// this loop stays well under domainsCeilingBurst (the separate CONVERGENCE- |
| -// RATE ceiling that does still apply, see TestDomainsCeilingBoundsConvergence |
| -// below) precisely to isolate that claim: every one of these must succeed |
| -// for a reason that has nothing to do with hitting any door's cap. |
| +// EXEMPT from the write/instance WORKLOAD budgets rather than uplifted. |
| +// |
| +// attempts is deliberately ABOVE cliInstanceBurst (the workload budget this |
| +// door must be exempt from) and BELOW domainsCeilingBurst (the convergence- |
| +// rate ceiling that still applies, see TestDomainsCeilingBoundsConvergence |
| +// below): a pass here means the instance budget is genuinely gone, not that |
| +// the loop merely stayed under it. Derived from both constants, not a |
| +// literal, so the claim cannot quietly stop being true if either one moves |
| +// — the assertion just below catches that instead of the test silently |
| +// starting to prove nothing (Task 5 review, round 3). |
| func TestWildcardEnableIsNotRateLimited(t *testing.T) { |
| const zone = "acme.example" |
| - const attempts = domainsCeilingBurst / 2 |
| + const attempts = (cliInstanceBurst + domainsCeilingBurst) / 2 |
| + if !(cliInstanceBurst < attempts && attempts < domainsCeilingBurst) { |
| + t.Fatalf("attempts (%d) must sit strictly between cliInstanceBurst (%d) and domainsCeilingBurst (%d) — as written, this test would no longer prove the exemption it is named for", |
| + attempts, cliInstanceBurst, domainsCeilingBurst) |
| + } |
| fx, _ := instanceFixture(t, "code-wc-exempt") |
| svc := serviceToken(t, fx.st, OpsAccountID, "hub", "titogo", svcrole.Publish) |
| fx.srv.delegationZone = zone |