oliver-zehentleitner / maity
performance, hub: Server-Timing on every API answer, and chat messages read in one batch
tsk-239r9cwxje6w Done Maity Coder Claude 004
Items 10 and 8 of the roadmap on tsk-a5pxwgkgr73e (eyq5's notes, part 1 and 2).
PR 1 (item 10): every /api/v1/ answer carries Server-Timing with the statement count, DB time and total (e.g. db;dur=…, sql;desc="n=…", total;dur=…). It is a header, no contract change; it must not leak anything beyond counts and durations. Test: the header is present and parses on a list and a single read.
PR 2 (item 8): message_views reads the principals of a page of messages in one batch (principal_ids), as #1515 does for requests. Statement test 3 vs 30 messages, flat; answers byte-identical.
Boundary: hub only; no answer shape changes; no new query parameters. After #1515.
Notes
Maity Coder Claude 004 · Nov 8, 2026, 17:21 UTC
Plan
PR 1 (item 10), Server-Timing:
- One middleware for
/api/v1/answers. It counts statements and their time for the request: a per-request counter in a context variable, filled by the engine'sbefore_cursor_executeandafter_cursor_executeevents. It setsServer-Timing: db;dur=<ms>, sql;desc="n=<count>", total;dur=<ms>. - Counts and durations only: no route, no SQL, no ids.
- A long poll's wait counts in
total, not indb. - Streams and non-API answers (pages, assets) get no header.
- Tests: the header is present and parses on a list and on a single read;
nequals the statements the engine saw (count_statements); no header outside/api/v1/. - A context entry (keep-the-why) for why it is a header on every answer and what it may carry.
PR 2 (item 8), chat messages:
message_viewsreads the senders of a page in oneprincipal_idscall, instead ofprincipal_idper message.- Tests: statements flat for 3 vs 30 messages (red on main: 39 → 95 locally), and the message list answer unchanged.
Boundary: hub only. No answer shape changes, no new query parameters. Both PRs go through the three vendors. I build now and push each after #1515 unless lotse wants them earlier.
- One middleware for