Skip to content

perf(gateway): prepare sharing roles once per viewer - #174405

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-session-sharing-auth-cost-20260919
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-session-sharing-auth-cost-20260919

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 40 focused tests passed across session-sharing.test.ts, session-sharing.prepared.test.ts, and server-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.
  • 22 closure tests passed across test/scripts/eager-import-closure.test.ts and test/scripts/pr-wrapper-source-closure.test.ts (147.32 s wrapper wall time).
  • Changed-file formatting/lint and export collision guard passed. Broad validation is delegated to PR CI; no validation leases allocated.
  • Independent Codex review: scoped clean for P0–P2.

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 base 0dc31f5f64309d199f12aea643452bfde54f4888 with head be85c28594da4587d96eef843b25bd927903d32b using the production sessions.list handler 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.

Page size Mean main-thread CPU before → after Reduction p95 before → after
100 rows 5.252 → 4.329 ms 17.6% 7.738 → 5.999 ms
1,000 rows 63.063 → 50.481 ms 20.0% 69.306 → 58.914 ms

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:32 omits real exports while mocking ../process/supervisor/darwin-bun-process-census.js. The same signature appears in main run 38930096455, head bb642e181e130153894a45f141a5368123bcd487.
  • check-guards: duplicate-scan target coverage omits root cli-parent-lifetime.mjs. The filename-only pnpm dup:check:coverage check fails identically with the original base/head and with the exact CI main baseline bb642e181e130153894a45f141a5368123bcd487 / tested merge dc1a8f3c4cae1e3d8db26b52879e141e7e1e5cfd Git indexes. Tracked path inventories are identical, as are scripts/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 07667dcc8f4df3aa40be463415304623726b58c2 under the operator-authorized inherited-failure landing exception. No CI reruns or branch updates were requested to chase green.

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.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review October 16, 2026 16:14
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 16, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T16:16:58.874909Z be85c28 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 07667dc into main Oct 16, 2026
203 of 208 checks passed
@steipete
steipete deleted the steipete/perf-micro-session-sharing-auth-cost-20260919 branch October 16, 2026 16:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged reviewed head be85c28594da4587d96eef843b25bd927903d32b as 07667dcc8f4df3aa40be463415304623726b58c2 under the operator-authorized inherited-failure exception.

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 openclaw/ci-gate remained red:

  • checks-fast-baseline-ratchets: the mock-export failure at src/flows/doctor-plugin-source-captures.test.ts:32 matches main run 38930096455, head bb642e181e130153894a45f141a5368123bcd487.
  • check-guards: cli-parent-lifetime.mjs is missing from duplicate-scan target coverage. The filename-only coverage check exits 1 identically for the CI main parent bb642e181e130153894a45f141a5368123bcd487 and tested merge dc1a8f3c4cae1e3d8db26b52879e141e7e1e5cfd; path inventories and checker/module blobs are unchanged. The automated “new” labels compare against the older scheduled run 38924503696.

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 sessions.list CPU fell from 5.252 to 4.329 ms at 100 rows (17.6%) and 63.063 to 50.481 ms at 1,000 rows (20.0%). All six viewer/page access fingerprints match. This measures the warm production handler, excluding WebSocket transport and cold hydration. Full methodology is in the PR body.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant