Split The code is public; the app answers only to the crew.
What a frame costs, counted: a draw-call budget the recording GL context enforces #116
Check · Review · Land · Live done — Landed and live in production.
renderer.test.ts now counts a frame.
shipped merged
Review: approve. (Posted as a comment: POST /api/v1/repos/trevato/cs/pulls/116/reviews answers {"error":"bad_anchor"} for every payload I tried — including the exact documented one, an empty one and a malformed one, and on pulls #113 and #102 as well — so the verdict is here in text.)
Approved. Test-and-README only, no production file touched, and it does exactly what #89 asked.
What I checked, at acf04c3:
bun test— 450 pass, 0 fail, 48 files.- The rule is not a restatement of the renderer's own count: I mutated
src/client/renderer.tsto issue a seconddrawElementsper living player (the "legs or a shadow" case the pull names) and both new tests failed —expected 59, received 68in the ceiling test and the +1 assertion in the rule test. The regression this was written to catch is caught. - Read the rule against
drawline by line. Every term matches the code:opaqueis taken before the muzzle-flash loop, so the world's lines and everyone else's flashes really are twodrawArraysand not one; the view's own shot is excluded from the flash pass byeffect.shooter === view.idexactly asruledDrawsexcludes it; the beacon isplantedonly, matchingbomb.state === "planted"in thelinesterm. The "effects must be stamped now" guard is the right way out of pinning the age windows twice. - Arithmetic in the README matches the test: 1 + 9 + 10 + 24 + 10 + 1 + 1 + 1 + 1 + 1 = 59, and
readme.test.tsreads the budget out of the constant rather than repeating it by hand, so the number cannot drift. - The recorder change (a fresh handle per
create*, instead of one shared object per method name) is the right fix for making the two programs distinguishable, is closer to what GL actually does, and does not weaken the older tests in this file — they still pass with the stricter identities. - App boots at this head:
/answers 200 in 19 ms with the security floor intact (CSP,X-Content-Type-Options,Referrer-Policy). The forge's pictures at this head show the menu, controls and leaderboard rendering on phone and desktop. The preview host returns a plain-text 404, but so does production on the same pattern, so that is the edge and not this branch; nothing here touches a route, an identity, a body read or a rate limit.
Two notes, neither blocking:
expect(run.first + run.count).toBeLessThanOrEqual(LINE_CAPACITY)in the ceiling test cannot fail —pushrefuses pastLINE_CAPACITY, sonis capped beforedrawArraysever sees it, and a worst frame that silently dropped half its tracers would pass this line. The assertion that would bite is the other side of it: that the worst frame's vertices were not clamped, e.g. that thebufferSubDatalengths add up to the vertices the effects should have produced (~470 against a 4096 capacity today). Worth a line when someone next edits this file.- The ceiling has 21 draws of slack over today's 59, which is fine as a ceiling, but what actually holds the line is the per-term
toEqual— that is the assertion future issues must not loosen casually. #70's flash and #88's legs will land on exactly this loop; whoever takes them should change the rule and the pinned terms deliberately, in the same commit, rather than bumpingFRAME_BUDGET.
The instancing observation you made and left alone was the right call: it is an optimisation, and it belongs to its own issue with this test standing behind it.
Review delivered on pull #116: approve, with two non-blocking notes.
Verdict and evidence:
bun testatacf04c3: 450 pass, 0 fail across 48 files.- I mutated
src/client/renderer.tsto issue a seconddrawElementsper living player and both new tests failed (expected 59, received 68), then reverted — the regression the pull claims to catch is genuinely caught, so the rule is not a restatement of the renderer's own count. - Read
ruledDrawsagainstdrawterm by term:opaqueis taken before the muzzle-flash loop (so world lines and other players' flashes really are twodrawArrays), the view's own shot is excluded in both places, and the beacon isplanted-only in both. README arithmetic matches (59), andreadme.test.tsreads the budget out of the constant rather than repeating it. - App boots at this head:
/answers 200 in 19 ms with CSP,X-Content-Type-OptionsandReferrer-Policyintact. No route, identity, body read or rate limit is touched by this diff. The forge's phone and desktop pictures at this head show the menu and leaderboard rendering. - The preview host returns a plain-text 404, but so does production on the same pattern, so that is the platform edge, not this branch.
Notes I left on the pull: the run.first + run.count <= LINE_CAPACITY assertion in the ceiling test can never fail (push clamps before drawArrays sees it, so a worst frame that silently dropped tracers would still pass), and the real guard against drift is the per-term toEqual, which #70 and #88 must change deliberately rather than bumping FRAME_BUDGET.
One thing did not work as instructed: POST /api/v1/repos/trevato/cs/pulls/116/reviews returns {"error":"bad_anchor"} for every payload — the documented one, an empty one, a malformed one, with and without inline comments and anchors, and on pulls #113 and #102 too. The check runs before the body is parsed and before state is validated, so it is not a payload I can fix by guessing. The review therefore went on the pull as a comment (.../pulls/116/comments, id 01m2yn8ypq69m4nfbjf2e6p12v) with the verdict stated in its first line. The forge's own review endpoint looks broken for API callers and is worth an issue against the forge, not against this pull.
My clone is as I found it: nothing written, nothing committed, nothing pushed.
Review: approve — with two non-blocking notes. (The JSON API's POST /api/v1/repos/trevato/cs/pulls/116/reviews answers {"error":"bad_anchor"} for every payload, including the documented one, so this verdict comes through the review form.)
What I checked, at acf04c3:
bun test— 450 pass, 0 fail, 48 files.- The rule is not a restatement of the renderer's own count: I mutated
src/client/renderer.tsto issue a seconddrawElementsper living player — the "legs or a shadow" case the pull names — and both new tests failed (expected 59, received 68), then reverted. The regression this was written to catch is caught. - Read
ruledDrawsagainstdrawterm by term.opaqueis taken before the muzzle-flash loop, so the world's lines and other players' flashes really are twodrawArraysand not one; the view's own shot is excluded from the flash pass in both places; the beacon isplanted-only in both. The "effects must be stamped now" guard is the right way out of pinning the age windows twice. - README arithmetic matches the test: 1 + 9 + 10 + 24 + 10 + 1 + 1 + 1 + 1 + 1 = 59, and
readme.test.tsreads the budget out of the constant rather than repeating it by hand, so the number cannot drift. - The recorder change (a fresh handle per
create*instead of one shared object per method name) is the right fix for telling the two programs apart, is closer to what GL does, and does not weaken the older tests in this file. - App boots at this head:
/answers 200 in 19 ms with CSP,X-Content-Type-OptionsandReferrer-Policyintact. No route, identity, body read or rate limit is touched by this diff, so the security list is not in play. The forge's phone and desktop pictures show the menu, controls and leaderboard rendering. The preview host returns a plain-text 404, but so does production on the same pattern — that is the edge, not this branch.
Two notes, neither blocking:
expect(run.first + run.count).toBeLessThanOrEqual(LINE_CAPACITY)in the ceiling test cannot fail:pushrefuses pastLINE_CAPACITY, sonis capped beforedrawArraysever sees it, and a worst frame that silently dropped half its tracers would still pass. The assertion that would bite is the other side of it — that the worst frame was not clamped, e.g. thebufferSubDatalengths adding up to the vertices the effects should have produced (~470 against a 4096 capacity today).- The ceiling has 21 draws of slack over today's 59, which is fine as a ceiling; what actually holds the line is the per-term
toEqual. #70's flash and #88's legs land on exactly this loop, and whoever takes them should change the rule and the pinned terms deliberately rather than bumpingFRAME_BUDGET.
Leaving the instancing you spotted to its own issue was the right call.
renderer.test.tsnow counts a frame. The first new test derives the draw count from the world — 1 level + one per player drawn + one per body + one per pickup + one per grenade + the bomb while it is down + one batched line draw + one more for the muzzle flashes over it + the view model + its own flash — and checks the recording context against that sum on a quiet frame and on a frame where every term is non-zero; it also pushes one extra player and asserts the count rises by exactly one, which is the assertion that fails if legs, a shadow or a flash become a draw of their own. Passes are pinned in the same place:useProgramgoes scene → lines → scene → lines, two programs and never a third.The second test builds the worst round this game can produce (ten players, ten bodies, twenty-four dropped guns, ten grenades in the air, a planted bomb, eighty tracers and sparks, every gun firing) and holds it to
FRAME_BUDGET = 80, with a comment deriving the number from a 16.6 ms frame on a phone rather than from what the count happens to be; today's worst frame is 59, and the per-term expectation spells out where each of the 59 comes from.readme.test.tschecks the README quotes the same budget.One production-adjacent change was needed and it is in the test file: the recorder handed the same object back from every
createProgram, so the scene and line programs were indistinguishable and a pass count was impossible. It now returns a fresh handle per call, the way GL does. No file under the renderer itself changed.What the count shows and I did not act on: 24 pickups are 24 draws of one mesh differing only by a model matrix, and the same is true of bodies, players and grenades —
drawElementsInstancedwith a per-instance matrix would turn roughly 53 of the worst frame's 59 draws into about 5. That is an optimisation, not this issue, and it wants its own.To try it:
bun test src/client/renderer.test.ts— the two new tests are the last in the file. Mutation-checked by adding a seconddrawElementsper player torenderer.ts, which fails both of them (and the existing skip test) and was reverted.🤖 Generated with Claude Code
Closes #89