Skip to content

perf(cloud): batched roster entitlements + paged session listings#509

Merged
Harry19081 merged 4 commits into
developfrom
codex/batch-org-entitlement-hydration
Jul 24, 2026
Merged

perf(cloud): batched roster entitlements + paged session listings#509
Harry19081 merged 4 commits into
developfrom
codex/batch-org-entitlement-hydration

Conversation

@Neonforge98

@Neonforge98 Neonforge98 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Client side of ORGII-cloud-infra migration 0004_roster_and_listing_scalability.sql (one paste, all offline-validatable scalability fixes). Every path is fully backward compatible with pre-0004 backends.

Part 1 — batched org entitlements (audit B1). Eliminates the get_entitlement_state × N fan-out on every roster read (measured live: 7 extra RPCs per org activation and per coarse-signal refresh). Roster rows carrying an entitlement payload seed the coordinator directly (seedOrgEntitlement: floor mirror + TTL stamp); only unresolved rows fall back to the per-org RPC. Malformed payloads degrade via .catch without failing the roster parse.

Part 2 — keyset-paged full session listings (audit C2). Full cloud_list_org_sessions pulls walk p_limit=200 keyset pages until nextCursor disappears, so a large org can never push one unbounded aggregate through the managed statement timeout. Delta pulls stay single-shot. A pre-0004-signature backend answers the first paged call with PGRST202; the client falls back to the legacy call and remembers per endpoint. Runaway guard at 50 pages.

Part 3 — keyset-paged full collab-state listings (audit H3). Same treatment for cloud_list_org_collab_state: full listings walk the server's unified (updated_at, kind, id) cursor (one cursor pages projects and work items together), delta pulls stay single-shot, PGRST202 falls back with per-endpoint memory, 50-page guard. Ascending keyset order makes mid-walk writes safe — an update moves its row toward the unread tail, never behind the cursor.

Server-only parts of 0004 with no client change needed: work-item project-lock narrowing (M1 — steady-state edits stop locking the project row), comments p_since delta (M4 — client adoption deferred; threads are small), service-role GC for collab tombstones and bookkeeping tables (H3/L2).

Test plan

  • tsc clean; full suite green (6156 tests / 684 files); 15 new Org2Cloud tests across entitlement seeding, session paging, and collab paging (multi-page walk + cursor threading, PGRST202 fallback + endpoint memory, delta single-shot body, malformed-cursor degrade, page-cap guard, non-signature error propagation).
  • Server counterpart validated twice on disposable Postgres 16 (author agent + independent re-run): full 0001→0004 sequence, idempotent re-run, legacy calls byte-identical vs a 0003-only DB (collab state, comments, 6-step work-item upsert battery), paged unions equal unbounded listings, comments delta exact-set, GC horizon/live-item guards, pg_locks-level proof that steady-state work-item edits no longer wait on the project row.

🤖 Generated with Claude Code

Pre-commit hook ran. Total eslint: 1, total circular: 0
Pre-commit hook ran. Total eslint: 1, total circular: 0
@Neonforge98 Neonforge98 changed the title perf(cloud): hydrate org entitlements from the batched roster listing perf(cloud): batched roster entitlements + paged session listings Jul 24, 2026
Pre-commit hook ran. Total eslint: 1, total circular: 0
Pre-commit hook ran. Total eslint: 1, total circular: 0
@Harry19081
Harry19081 merged commit 7ae39f1 into develop Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants