Repository navigation
perf(gateway): batch Web Push recipient preparation - #158595
Conversation
Share canonical profiles, preferences, and prepared session visibility across ordinary and approval notifications. Retain current authority through provider start and refresh batches across preference changes and profile merges.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 25, 2026, 10:59 PM ET / September 26, 2026, 02:59 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch moves Web Push preference and session-visibility preparation into shared worker-backed reads for browser attention and approval notifications. Merge readiness⛔ Blocked before merge - 4 items remain The Web Push performance problem remains on current main, and this branch addresses the right delivery path. Two findings from the prior review remain at the unchanged head: profile lookup still scans the full resident catalog for each subscriber, and the new worker read invokes a per-call schema check. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway turns attention events and approval changes into Web Push notifications for subscribed browsers. It selects recipients using subscription bindings, device pairing, profiles, preferences, and session visibility before sending to a push service. flowchart LR
A[Attention or approval event] --> B[Bound browser subscriptions]
B --> C[Profile and preference preparation]
C --> D[Pairing and session access checks]
D --> E[Eligible recipients]
E --> F[Web Push sender]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +235, Tests +272. Total +507 across 21 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Build or reuse a catalog-owned alias index and carry table availability from database admission into preference reads while preserving the existing binding, role, and session revocation checks. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main performs a synchronous preference read for each eligible Web Push target. The PR body reports an A/B component benchmark, but this read-only review did not execute it. Is this the best way to solve the issue? No, not yet. Shared recipient preparation is the right boundary, but its catalog projection still scales with subscribers times profiles and its new worker read repeats a schema check. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 37259b7cab6b. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Match the push snapshot action promise contract and omit default deferred type arguments. Fixes exact-head CI run 36213046146; targeted lint and 73 Web Push tests passed. Independent review found no actionable issues.
|
Merged via squash.
|
* perf(gateway): batch Web Push recipient preparation Share canonical profiles, preferences, and prepared session visibility across ordinary and approval notifications. Retain current authority through provider start and refresh batches across preference changes and profile merges. * test(state): control preference broker settlement * refactor(push): retire unscoped bound subscription listing * test(gateway): fix Web Push fixture lint contracts Match the push snapshot action promise contract and omit default deferred type arguments. Fixes exact-head CI run 36213046146; targeted lint and 73 Web Push tests passed. Independent review found no actionable issues.
What Problem This Solves
Web Push notifications perform synchronous per-subscriber database reads on the Gateway thread, delaying other work when many browsers subscribe.
User Impact
Ordinary attention notifications and approval requests/updates prepare account preferences and identity facts off-thread, while preserving current pairing, role, session visibility, and notification lifetime checks before dispatch. No protocol, configuration, schema, retention, or update migration changes are required.
Why This Change Was Made
The Web Push authority owner now shares batched preference reads and the resident profile catalog across both notification paths. Prepared session facts remove the remaining synchronous visibility reads. Preference changes and profile merges during preparation invalidate the batch; binding and pairing custody lasts through provider start, then releases before network completion. Both duplicate preference helpers are removed.
Evidence
Interleaved A/B component benchmark, 100 synthetic subscribers, 10 warmups and 60 measured samples per variant, with network/encryption excluded:
This is component proof, not an end-to-end latency claim.
134 focused tests passed on Blacksmith Testbox
tbx_01m3dkbgm9bywrtnwb3fnwyf3r(lease workflow). Each file ran withnode scripts/run-vitest.mjs <file> --maxWorkers=1:src/gateway/event-web-push.test.tssrc/gateway/approval-web-push.test.tssrc/gateway/event-web-push.storage-scope.test.tssrc/state/user-preferences.test.tssrc/state/user-profile-list.resident.test.tssrc/infra/push-web.test.tsThe real-session notification regression failed against the original delivery modules with 36
get, oneall, and threeiteratecalls, then passed with zero calls on the candidate. It covers eligible delivery, device/profile downgrades, missing role policy, and generic-event visibility. Deferred tests also cover preference changes/profile merges during pairing preparation and approval settlement during preference preparation.node scripts/check-changed.mjsran on the same Testbox. Production typechecking and all 25 selected test graphs passed, as did the preceding format, boundary, and contract guards. The initial dead-export scan found the retired subscription-list facade; it and its barrel export are now removed, and its persistence tests use the scoped reader. The follow-up changed gate passed the final state/infra test graphs, then the lease ended during its dead-export scan. The final aggregate lint/guard tail remains unverified; hosted CI is authoritative. The lease was retired withcrabbox stop.Local installation hit an unrelated noVNC patch failure, and local focused-test worker compilation was stopped under host saturation. Native Testbox sync timed out; the repository wrapper stalled during source packaging. Final remote proof used the same leased box, a clean verified base, task-scoped file transfer, and SHA-256 verification of every changed file. No full build or end-to-end swarm run was performed.
Deslop completed. Independent Codex branch review plus fresh reviews of the fixture correction and retired-facade cleanup: scoped-clean through P2; no accepted or actionable findings.
Production: +497/−262 lines (net +235). Tests: +352/−80 (net +272). The production growth retains preference mutation settlement, catalog lifetime, and current session authority across worker waits; deleting the duplicate preference helpers alone could not fund those necessary checks. The existing catalog module was split along its prepared-identity responsibility to stay below its line cap.
Related non-duplicate changes inspected: #158586 and #158380 change session preparation (this PR only exports its existing read type); #158445 and #158235 add other read-worker commands; #158123 changes approval error reporting; #158035 changes task-failure notification classification. Their overlapping work remains separate.
Landing validation: hosted CI run 36213046146 found seven lint errors in the two Web Push test fixtures (redundant default type arguments and a copied callback type that omitted the production promise return). Commit
54b1e7283778451feadd0aee008dc75fd0580bc4repairs those types without changing production behavior or completion ordering. Targeted lint passed; all 73 tests inevent-web-push.test.tsandapproval-web-push.test.tspassed in a combined single-worker run (127.93 s command wall, including cold compilation). Independent Codex review of the repair found no actionable issues. Hosted exact-head CI remains the landing gate; the cancelled jobs from the failed run are not passing evidence.Review follow-up: the table-existence finding does not apply to admitted connections:
tableExistsconsumesgetAdmittedSqliteSchemaFacts(db).tables, andselectUserPreferenceValuespredates this PR. The catalog alias projection still scans resident profiles per identity lookup; large-catalog scaling has not been measured and remains a follow-up limitation of the component benchmark. The coordinator approved this bounded recipient-preparation change; no claim of constant-time identity fan-out is made.