Repository navigation
perf(gateway): prepare sharing roles once per viewer - #174405
Conversation
Prepare requester classification once within each synchronous sharing read and reuse the resolved row role for send and activity-summary authorization. Preserve current projection membership, role caps, creator aliases, and post-yield preparation.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merged reviewed head CI run 38930370094, attempt 1, completed with 34 passing jobs. Independent review was clean; 40 focused behavior tests and 22 closure tests passed. Security/dependency review passed. The two inherited failures and downstream
No CI reruns or branch updates were used to chase green. The SHA-pinned squash fallback was used because native preparation would provision outside this lane's permitted checkout. On the 13,000-session synthetic fixture, mean main-thread |
Prepare requester classification once within each synchronous sharing read and reuse the resolved row role for send and activity-summary authorization. Preserve current projection membership, role caps, creator aliases, and post-yield preparation.
What Problem This Solves
Session list presentation resolves the same caller's sharing identity and role repeatedly for each row, then resolves the row role again when calculating send availability.
User Impact
No access-policy or response change. Lists do less repeated authorization work while preserving creator, membership, role-cap, draft, and incognito behavior.
Why This Change Was Made
Prepare the caller class once inside the existing synchronous sharing boundary, and pass the resolved row role to send/activity-summary authorization. The one-shot role API delegates to the same policy owner. Existing resident projection owners retain session and membership facts; no new persistent cache or cross-user decision reuse is introduced. Preparation is renewed after yields.
Production delta: +51/-42 (net +9 lines). The small growth separates preparation from row evaluation while retaining a single policy implementation for individual callers and batches; no configuration, schema, or dependency changes.
Evidence
session-sharing.test.ts,session-sharing.prepared.test.ts, andserver-methods/sessions-read-cache.test.ts(165.30 s wrapper wall time). Coverage includes conditional-list revocation, identity/role changes, readiness yields, creator aliases, membership, draft and incognito restrictions.test/scripts/eager-import-closure.test.tsandtest/scripts/pr-wrapper-source-closure.test.ts(147.32 s wrapper wall time).Measurement
Isolated Linux, Node 26.8.1; 13,000 synthetic sessions, 24 profiles, mixed visibility, and 6,000 retained runs from
scripts/perf/team-shape-fixture.ts(seed 967). Compare base0dc31f5f64309d199f12aea643452bfde54f4888with headbe85c28594da4587d96eef843b25bd927903d32busing the productionsessions.listhandler and resident projection. Alternate two identified viewers (sessions.others: suggest) and one administrator; 18 warmups followed by 99 calls per page size.process.threadCpuUsage()measures only the calling thread; response fingerprints are calculated outside timing.All six viewer/page access fingerprints match, including returned session IDs/keys, visibility, sharing roles, send restrictions, and owner fields. These are warm handler measurements, excluding WebSocket transport and cold projection hydration; they do not measure direct-target mutation authorization or total Gateway CPU.
CI attribution
Exact-head run: 38930370094, attempt 1, completed with 34 passing jobs and two inherited failures plus the downstream aggregate gate. The automated table labels these failures “new” against the earlier scheduled main run
38924503696; the more recent main evidence and exact-checkout comparisons below establish their inherited origin:checks-fast-baseline-ratchets:src/flows/doctor-plugin-source-captures.test.ts:32omits real exports while mocking../process/supervisor/darwin-bun-process-census.js. The same signature appears in main run 38930096455, headbb642e181e130153894a45f141a5368123bcd487.check-guards: duplicate-scan target coverage omits rootcli-parent-lifetime.mjs. The filename-onlypnpm dup:check:coveragecheck fails identically with the original base/head and with the exact CI main baselinebb642e181e130153894a45f141a5368123bcd487/ tested mergedc1a8f3c4cae1e3d8db26b52879e141e7e1e5cfdGit indexes. Tracked path inventories are identical, as arescripts/check-duplicates.mts,scripts/check-duplicates.mjs, and the omitted module. No clone-token scan or full suite was rerun.Build, selected test shards, UI checks, production/test types, lint, source/architecture checks, and security checks passed. The aggregate gate remains red because of the two attributed inherited failures above. Merged as
07667dcc8f4df3aa40be463415304623726b58c2under the operator-authorized inherited-failure landing exception. No CI reruns or branch updates were requested to chase green.