Repository navigation
perf(gateway): reuse live session lists for one second - #149387
Conversation
|
🦞👀 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 15, 2026, 11:09 PM ET / September 16, 2026, 03:09 UTC (Revision 9). ClawSweeper reviewWhat this changesThe PR lets Gateway session lists reuse live results for one second, strengthens caller isolation, and updates cache tests and protocol documentation. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain The optimization remains useful, but the previously reported idle-page invalidation defect is still present at the reviewed head. Current main does not contain this optimization, and the linked merged PRs address separate test failures. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway builds session rosters from stored session metadata and live activity for connected clients. Its list cache avoids repeated projection work while keeping results separated by caller and invalidating them when relevant state changes. flowchart TD
A[Client roster request] --> B[Caller identity and filters]
B --> C[Session list cache]
D[Access and state changes] --> C
C --> E{Reusable result?}
E -->|Yes| G[Session roster response]
E -->|No| F[Stored sessions and live activity]
F --> G
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +30, Tests +142, Docs +12. Total +184 across 5 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the existing cache owner, but track live-page reuse eligibility separately from status expiration so idle pages retain immediate soft invalidation. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a precise PR-head reproduction: cache an idle page with an unexpired status note, emit a transcript update, then repeat the same list request. The old page survives; no runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? The existing cache is the right owner, but the patch needs a narrower retention condition: status expiry alone must not authorize reuse across soft mutations. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c1c870a41755. LabelsLabel 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 (8 earlier review cycles)
|
4f245d0 to
62d5187
Compare
62d5187 to
44be1af
Compare
Use the sharing policy identity for internal operator callers so cached lists cannot return another operator’s draft rows. Preserve attribution, role caps, system actors, and GitHub sync state in the key.
Retain completed live pages across transcript and activity changes until their original deadline, capped by earlier agent-status expiry. Preserve immediate access, identity, profile, database, and configuration invalidation, along with in-flight generation semantics.
44be1af to
8295923
Compare
|
Merged via squash.
|
* fix(gateway): isolate cached session lists by sharing identity Use the sharing policy identity for internal operator callers so cached lists cannot return another operator’s draft rows. Preserve attribution, role caps, system actors, and GitHub sync state in the key. * perf(gateway): reuse live session lists for one second Retain completed live pages across transcript and activity changes until their original deadline, capped by earlier agent-status expiry. Preserve immediate access, identity, profile, database, and configuration invalidation, along with in-flight generation semantics.
What Problem This Solves
On team.openclaw.ai, active sessions prevent completed
sessions.listcache hits, so repeated roster requests rebuild the same rows while the Gateway main thread is already saturated. The September 15 observation recorded 12,852 calls from 71 connections in one hour, p50/p90 latency of 2,172/4,354 ms, and 9,384 slow-list warnings. Logged slow calls included 4,845 projection owners, 279 in-flight followers, and zero completed hits; list/describe projection accounted for roughly 35% of the main-thread CPU profile.User Impact
Matching requests can reuse a completed page containing live runs or child sessions for up to one second. Access, identity, profile, database membership, and configuration changes still invalidate immediately. Earlier agent-status deadlines take precedence. This reduces repeated projection work without changing the UI refresh cadence.
The first commit also fixes a prerequisite caller-isolation gap: internal operator callers now use the same sharing identity as row visibility, so one operator cannot receive another operator's cached draft rows.
Why This Change Was Made
The cache previously discarded every result containing live work, and transcript/activity version changes rotated its entire state. The cache owner now gives live pages a fixed one-second deadline matching the UI's maximum refresh wait, carries bounded completed entries across soft changes without extending their deadlines, and preserves the existing in-flight and model-catalog fences. Idle pages without an expiry retain immediate mutation invalidation.
The hard fence includes the existing Gateway access revision, whose owner also incorporates profile aliases. This was necessary because visibility/ownership changes need not change session identity. Its owner and producers are unchanged.
Caller audit: the key includes the sharing policy's identity, authenticated profile identity separately for owner-first/involving-me/membership decoration, admin/session-cap classification, system-actor state, GitHub-sync presence, and every sorted request parameter (filters, agent selection, ordering, paging). Those cover all caller-dependent visibility and projected sharing fields. The only relevant internal field is the operator role actor; its identity, system distinction, and effective cap are represented. Model-selection scope checks only the already-keyed admin scope plus fenced configuration and process-wide state. Connection IDs, other internal fields, and other scope bits do not select rows or change this projection.
Tradeoff: conservative keyed
sessions.changedmutations, including run-boundary and patch notifications, advance the hard access revision and immediately invalidate live pages. Mutation frequency can therefore shorten the one-second reuse window. The existing explicitaccessChanged: falsecertification skips that access bump; transcript updates—the dominant signal—do not bump it either. The coordinator will measure the rebuild rate after deployment; the planned projection redesign replaces this cache. This PR does not change per-rebuildsessions.describeor subagent-index work and includes no production deployment or post-deployment CPU measurement.Evidence
cacheRole=completed-hitthrough the existing diagnostics channel.git diff --checkpassed. Fresh Codex autoreview is clean at P2 with a retained, verified JSON result.Commands:
The protocol bootstrap documentation now describes the bounded reuse and immediate hard invalidation. Diagnostics hooks and subscription contracts are unchanged. Search, active-only, activity-window, and parent-filtered requests still share only in-flight work.
Final validation and landing
Reviewed head:
829592348ff5a18ec759ec53916a12091c9bf8ff. The conflict-free rebase included #149477 (476fa7a270e), fixing the earlier unrelated alias-fixture failures. Both reviewed patches remained unchanged.All 92 wrapper tests, all 62 cache/diagnostics/store-RPC tests across eight files, full
node scripts/check-changed.mjs, andgit diff --checkpassed. The earlier full requested selection passed 857 tests across 61 files. Retained P2 autoreview is scoped-clean with zero findings.Exact-head CI run 35046743154 completed successfully on attempt 1. The canonical watcher returned
GREEN, zero pending checks, and six superseded ancillary checks. No failed jobs were rerun or cancelled.Native review artifacts validated as
READY FOR /prepare-pr, and hosted preparation passed at the same head. Earlier merge attempts stopped at a shared GraphQL quota limit and a concurrent-main observation guard. The task-owned locks were recovered under coordinator authorization after process verification; no rebase or check bypass was used for those retries. Native merging then succeeded at 0d4a0154dd791445acc089c4dc370e02965078b5, with a complete receipt and cleanup. GitHub reportsMERGED, and the merge commit is reachable fromorigin/main.The wrapper warned about relevant mainline drift and explicitly proceeded under its default policy. It also emitted ordinary cleanup warnings for native branches retained by the receipt rather than the invoking checkout's HEAD. No completion step remains pending. Native completion comment.