DeepTutor icon indicating copy to clipboard operation
DeepTutor copied to clipboard

Route budgets have ~1 KB of headroom left on /chat; rebaseline them deliberately

Open ZQR1101 opened this issue 3 days ago • 0 comments

Problem

web/scripts/route_budgets.mjs runs as the last step of npm run check (the Web Node Tests job) and fails a PR when Math.round(bytes / 1024) > budgetKb. The comment at the top of that file asks for roughly 2-4% headroom, and the numbers measured on dev no longer leave any.

From dev @ c9017be1 (Tests run 46851829644, Web Node Tests job 143358353400, 2026-12-02):

route size budget slack
/chat 1099 KB 1100 KB 1 KB
/chat/[sessionId] 1099 KB 1100 KB 1 KB
/co-writer 468 KB 470 KB 2 KB
/co-writer/[docId] 512 KB 515 KB 3 KB
/learning/reading/.../sessions/[sessionId] 1367 KB 1370 KB 3 KB
/knowledge-bases 488 KB 550 KB 62 KB
/learning/mastery/.../sessions/[sessionId] 912 KB 1090 KB 178 KB
/settings 127 KB 840 KB 713 KB

The chat route is the product's main surface and it has 1 KB of slack, against a policy comment that assumes percent-level headroom.

Consequence

  • Any PR that touches the chat shell fails the gate for reasons unrelated to its own change. #2965 measured 1103 KB against a 1100 KB budget and got back under it by relocating FeatureCrumb from components/layout/LocationCrumbs to components/sidebar/PageBar. That was a genuine de-duplication, but it should not be the toll for a bug fix, and the result is now zero headroom instead of some.
  • Nothing in the check distinguishes removing weight from moving it across a chunk boundary, so the gate can be satisfied by relocating code into a route nobody measures. That is easy to game and hard to review.
  • A contributor sees a red Web Node Tests reading FAIL /chat ... KB / budget 1100KB, which looks like a rejected change when what it really is a budget decision we have not made.

What I would like to settle here

  1. Rebaseline the pinned routes with the reason recorded next to each entry in ROUTE_TARGETS (what the route carries today, and why that number), instead of nudging ceilings by single kilobytes per PR.
  2. Decide whether the script should derive ceilings from a measured baseline plus a fixed slack band (say 2%), regenerated in a dedicated maintainer PR, so no PR can edit its own limit implicitly.
  3. Look at measuring the shared shell once rather than charging its providers to every route in the group. app/(shell)/layout.tsx mounts the chat runtime, the reading provider and the sidebar for all routes below it, which is where most of the /chat pressure comes from.

The gate should stay. It caught real duplication in #2965, and first-load JS on the main surface is exactly what it is meant to protect. This is about making the numbers honest and the failure actionable, not about loosening them.

References

  • web/scripts/route_budgets.mjs header comment: baseline dated 2026-10-26 records chat at 1072 KB against the 1100 KB budget.
  • PR #2965 review thread: 1103 KB to 1100 KB via the FeatureCrumb relocation.

ZQR1101 avatar Dec 02 '26 10:12 ZQR1101