Repository navigation
fix(sessions): branches.list stalls the event loop for ~12s on long-lived sessions - #123541
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 11:47 AM ET / 15:47 UTC. ClawSweeper reviewWhat this changesThe PR memoizes shared transcript ancestry when producing SQLite session branch summaries and adds large-graph and duplicate-ID regression coverage. Merge readinessNo blocking correctness finding on the reviewed head: the prior duplicate-ID issue is addressed by canonicalizing each tip before traversal. Keep this PR open for normal exact-head validation; this checkout could not materialize the fetched current-main object for a final source comparison. Priority: P1 Review scores
Verification
How this fits togetherSQLite transcript events are converted into branch summaries for the Gateway branch-list endpoint and Control UI branch menu. This projection must retain canonical tree semantics while avoiding synchronous work that delays other Gateway activity. flowchart LR
A[SQLite transcript events] --> B[Transcript tree scan]
B --> C[Branch tip selection]
C --> D[Shared ancestry summaries]
D --> E[Branch-list response]
E --> F[Gateway and Control UI]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +27, Tests +92. Total +119 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the local memoized projection only after the current-main merge result retains the tested canonical, missing-parent, and cycle semantics. Do we have a high-confidence way to reproduce the issue? Yes. The pre-change implementation called the full path selector once per tip, and the supplied real-path benchmark plus large SQLite regression describe a high-confidence large-session reproduction; no target code was executed in this read-only review. Is this the best way to solve the issue? Yes. Memoizing at the SQLite branch-summary owner removes the repeated shared-prefix walks while retaining the canonical tree selector’s semantics; moving this into storage or a new global cache would broaden the state boundary unnecessarily. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6e6319440e7a. LabelsLabel changes:
Label justifications:
EvidenceWhat 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 (10 earlier review cycles; latest 8 shown)
|
b1aa620 to
084b3a0
Compare
|
Thanks for the detailed review! The P1 finding is addressed in Fix
if (node.parentId === null || !tree.byId.has(node.parentId)) {
stack.push({ node, count: 0, headline: undefined });
}
Regression testAdded CI statusAll checks pass on the updated head except Requesting a re-review of the P1 item. |
|
P2 addressed ( Verified:
Requesting a re-review of the P2 item. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
dabb8a1 to
18f2625
Compare
18f2625 to
25776ee
Compare
|
Thanks @njuboy11! Proof: The production
Example
|
Memoize ancestor branch summaries during each cold SQLite transcript scan so long-lived sessions do not repeat the same root-path work for every branch tip. Preserve active-first ordering, missing-parent and cycle behavior, and canonical duplicate-ID results from exact SQLite imports. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #123540
What Problem This Solves
Long-lived sessions can contain thousands of transcript events and more than one thousand branch tips. A cold
sessions.branches.listrequest walked the shared transcript prefix once for every tip. This blocked the Gateway event loop for seconds and delayed unrelated work.Why This Change Was Made
The SQLite session accessor owns branch-summary projection. It now memoizes the count and latest headline for each visited ancestor. Each shared prefix is summarized once, while the existing branch selector, active-first ordering, timestamps, missing-parent suffixes, and cycle behavior stay unchanged.
This repair was ported onto current main rather than rebasing the stale patch. It keeps newer session lifecycle, model-lock, incognito, commit-guard, and deferred-index behavior added since the original branch base.
User Impact
Evidence
The same production
sessions.branches.listhandler read a disposable SQLite session with 13,917 events and 1,362 tips on current main0a6c013be5f50981b12d021b387b4fd1ea7e491eand rebased repaired head25776eec814d88160251eff06658c2a444624281.32c1950f…66aded32c1950f…66adedThe 100x reduction removes the event-loop stall. The identical complete-result hash proves output equivalence. A warm-cache control remained 1 ms on both revisions.
Testing
pnpm check:changed: passed, including core and test type checks, type-aware lint, formatting, import cycles, schema guards, and repository ratchets.Change Shape