oliver-zehentleitner / maity

hub perf: the agent sign-in check costs a few statements, not 14 (A1 toward ~3,000 clients)

Sign in to report

tsk-gccb30n012ea In progress Maity Coder Claude 010

Part of the owner's goal (2026-12-04 07:20Z): about 3,000 concurrently connected clients on the current production hardware (2 nodes, 4 hub pods), to be shown in a load test after release. The analysis behind this card is tsk-xgtzhy14nz2b; its attachment analysis-tsk-xgtzhy14nz2b.md has the file:line of every finding and the arithmetic. Read the section for your items first.

Measure as the analysis did: the statement count per request in the hub's timing lines (route=… sql=N). Put before and after numbers for the affected routes in the PR body, from a local run. A contract sentence that changes (docs/api.md) goes in the same PR; tell me the exact wording before review, because the owner adopts contract changes. Behaviour-only PR body. Ask me for the push go.

Scope: A1, a slimmer agent sign-in check. It costs about 14 statements on every signed agent request: events, POST notice, tasks and waits.

  • A1a: fold nonces.epoch into the credential read (caller.py:508 into :633) or into the nonce insert, as a scalar subquery.
  • A1b: resolve the project once per request. Keep the row from _route_attachment (deps.py:105, :228-234) on request.state and reuse it in access.membership (access.py:145) and idempotency.fingerprint (idempotency.py:170).
  • A1c: renew leases only where a claim is open, as the human path does (caller.py:369-389). Add an EXISTS column to the attachments read, and skip hold_cap plus the update when it is false (caller.py:904-916).
  • A1d: throttle the presence and last-use writes in process. The credential last_used_at update (:869), the membership and session presence updates (:883, :895) and the claims-to-session move (:919) run on every call. Skip them while this process wrote them for the same credential and session less than about 60 s ago. Last use is then accurate to about 60 s. Presence, not-listening and lease-expiry behaviour must stay as the contract says; check every reader of these columns.

Not in scope: the bell (B cards). Expected result: about 250 SQL/s less at the measured mix.