Repository navigation
perf(sessions): reduce cold history child lookup overhead - #148775
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 17, 2026, 10:11 AM ET / 14:11 UTC (Revision 6). ClawSweeper reviewWhat this changesCold session-history lookups use existing SQLite lineage indexes and load compact child metadata while preserving complete selected-session data. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful, focused optimization absent from current main. No introduced correctness or security defect was found, and the previous conflict blocker is resolved in the verified test merge. Priority: P2 Review scores
Verification
How this fits togetherThe session store supplies saved session data and child relationships to Gateway and embedded terminal history readers. Child metadata supports navigation and presentation without requiring saved child prompts. flowchart TD
A[History request] --> B[Resolve selected session]
B --> C[Complete selected entry]
B --> D[Discover child sessions]
E[SQLite lineage indexes] --> D
F[Retained run registry] --> D
D --> G[Compact child metadata]
C --> H[History and session presentation]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +169. Total +170 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep child discovery within the existing SQLite and metadata owners while preserving complete selected entries and resident list/describe behavior. Do we have a high-confidence way to reproduce the issue? Yes for unnecessary payload decoding: current main's embedded-history caller requests full entries and propagates that projection to children. The current SQLite planner outcome was not executed during this review. Is this the best way to solve the issue? Yes. The patch reuses existing indexes and metadata projection without adding storage, configuration, or a competing reader. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9bea925e27aa. LabelsLabel 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 (5 earlier review cycles)
|
b918ab1 to
fa202e5
Compare
Use the existing parent and spawn indexes for direct child discovery, and load child metadata without unused skill snapshots or prompt reports. Preserve complete selected entries and current ownership, lineage, and deletion behavior for persisted and retained-run children. Keep resident list and describe ownership intact. Exercise the cold loader used by embedded history while retaining current resident lifecycle tests. Related: #130741; the broader Gateway latency target remains open. Source review is scoped-clean through P2. Runtime proof and exact-head CI for this integration remain pending; earlier proof belongs to fa202e5c.
fa202e5 to
4e7a66e
Compare
|
Merged via squash.
|
Use the existing parent and spawn indexes for direct child discovery, and load compact child metadata without unused skill snapshots or prompt reports. Preserve complete selected entries, current ownership and lineage, and fresh deletion results. Keep ordinary list/describe reads with the resident owner; cover the real cold loader used by embedded history. Related: openclaw#130741. On Linux/Node 24.19.0, the full 35-case baseline/candidate comparison produced exactly four intended failures on baseline and 35 passes on candidate. Nine current consumer selections added 159 passes. All 194 selected candidate cases passed; the TUI history filter intentionally left 128 other cases unselected. All 13 native reports and assertion identities were independently verified. Exact-head CI run 35231150085 succeeded with 142 successful jobs and 16 skipped. The full selected gate passed, including production/core-test types, export scans, lint, formatting and contract guards. The Linux command exited 0; a subsequent portal-sync request timed out. Reports and source bindings were verified before owned cleanup. Fresh source review and the trusted exact-head ClawSweeper review found no introduced correctness/security defect. Prior SQL medians of 4.119 ms and 0.091 ms belong to b918ab/3d08e342 and were not repeated. The original live campaign's 17 of 1,316 observations above 500 ms and historical recursive-failure attribution gap remain documented; the broader Gateway target remains open.
Related: #130741
What Problem This Solves
Cold session lookup still decodes unused child skill snapshots and prompt reports, and direct child discovery can scan retained session history. Embedded TUI history requests a complete selected entry together with child metadata, so retained Swarm children can add unnecessary preparation work.
User Impact
Reduces work in cold child lookup while preserving the selected session's complete data, child links, visibility, ownership, and fresh deletion results. Ordinary session lists and descriptions keep the current resident-row owner. No configuration, schema, retention, or queue policy changes are required. The overall 500 ms responsiveness target remains open.
Why This Change Was Made
Child discovery uses the existing list metadata projection and the existing parent/spawn indexes in one ordered, deduplicated query. Guards keep child metadata from replacing selected full entries. This port preserves #150625's prepared store discovery and selection and #150196's resident list/describe behavior. Payload regressions now exercise the actual cold loader while retaining the current real registry and resident lifecycle checks.
Evidence
Candidate
4e7a66ec3a09a3b0fb423f59693544a5f8709c70is based on mainbfb531c055e27cff373116fa715174b7d3b85222, with tree5fbc526cca2d833e9a602ff31c6aa6ce442a1cb5. The four-file source change passed fresh independent P0–P2 review, formatting, and diff sanity. Fresh Linux proof passed all 194 selected candidate cases. Exact-head CI completed successfully with 142 successful jobs and 16 skipped. The full selected gate passed, including production and core-test typechecking, all three unused-export scans, lint, formatting, and the state and contract guards. The Linux command returned exit 0 after 35m16.841s; a subsequent external runner portal-sync request timed out. The downloaded native reports and complete command result were verified before normal owned-lease cleanup.The two complete regression files produced matching 35-case inventories: the baseline passed 31 and failed exactly the four intended assertions; the candidate passed all 35. The failures reproduced a full-table scan and unnecessary persisted/main/worker child payload retention through the cold loader. Nine current consumer selections added 159 passes covering prepared lookup ownership, retained children, resident descriptions and sharing, diagnostics, clean-read SQLite behavior, incognito generation fences, registered chat history/startup, and embedded history. The history filter selected 9 TUI cases and deliberately excluded 128 others; no selected case skipped or failed. All 13 native reports and the reconciliation summary were downloaded and independently verified. Embedded history's mock boundary checks are not live TUI proof. Retired list-worker suites remain deleted.
The provider fell back from targeted sync to full sync within this single invocation, then verified the exact source and tree before execution. The trusted review of this head, completed at 14:11 UTC, found no introduced correctness or security finding and confirmed merge composition. Its request for completed current-head integration evidence is answered by these retained results; this text does not claim that the public review marker changed.
No timing benchmark was repeated. Earlier SQL measurements and the original 17 of 1,316 foreground observations above 500 ms remain attributed below; none establish latency for this new integrated head. This PR does not close #130741.
Retained evidence from earlier source revisions
The previously qualified candidate was
fa202e5c1d6323ce6decac288b5bfb3549bfc359, based on main62507cc516f706f40a1985086f06d066917f2d92, with source treecc0c136e5443f8bd2c1c0abcd02ce6bf6248f3c9. Range-diff confirms the same five-file patch as the previously verified candidate. Main now includes #149971’s conversation-read workers and shared-cache changes, plus the canonical CI fixture repairs in #150655. Fresh Linux proof verified this exact source and passed all 116 candidate cases on Node 24.19.0. The matching 59-case current-baseline comparison produced 55 passes and exactly four intended failures; all 59 cases passed on the candidate, with matching test identities and assertion locations. Seven current sibling suites contributed 57 additional passes covering worker/cache independence, concurrent inventory ordering, capacity and native-close lifetime, current async page-access decisions, diagnostics, and recursive spawning. All 13 native reports were downloaded and verified locally, with no skipped cases, retries, or reporting gaps. The full selected gate passed, including production typechecking, all 20 core test-type graphs, lint, formatting, export scans, and contract guards. Exact-head CI completed successfully with 141 successful jobs and 16 skipped jobs. No timing benchmark was repeated. The Linux command completed with exit 0; a subsequent external runner portal-sync request timed out. The retained reports and source bindings were verified, and the owned Testbox was stopped and its local capsule removed.The prior Blacksmith proof belongs to head
b918ab166fb1c2b757065683cda1045656e463baon base7a3160e582776548a9ec73c0b5a9139fa714c61d, using Linux and Node 24.19.0. All 59 candidate session/Gateway cases and 15 session-list diagnostics cases passed. Its matching 59 baseline cases produced 55 passes and four exact regressions:sessions.describedecoded two child skill snapshots and two prompt reports; registry-only child reads decoded unused payloads for both main and worker agents; and the child-query test observed a full session-table scan. Every failing baseline case passed on that candidate. The full selected gate passed, including all 20 core test-type graphs, production typechecking, lint, formatting, export scans, and contract guards.That proof’s initial driver stopped after the expected Gateway failures before starting the baseline exact-read shard, leaving its aggregate report incomplete. A continuation ran only that unstarted shard and found the fourth baseline regression; its overly strict expected count also returned nonzero. Both driver exits are retained. Native reports were reconciled by exact test identities and assertion locations. All candidate phases and the full selected gate exited zero.
On the same prior head/base comparison, both revisions passed the 16-case recursive-spawn production-boundary suite, including all three descendant-model inheritance cases. Actual owner queries returned identical five-child results on the same 4,622-row synthetic retained state, with schema, data-version, row-count, and total-change counters unchanged. The baseline query scanned the session table; the candidate used both existing covering lineage indexes plus keyed row lookup. Forty alternating pairs measured median SQL time of 4.119 ms before and 0.091 ms after. These measurements belong to
b918ab/7a3160e5; they have not been repeated for the refreshed runtime and are not Gateway latency measurements.The prior hosted CI run tested merge
7d449a56361d475c4c250412bcee516989d56585, containing main34f548cb280836ea60ec99276116d63ec23eeeecandb918ab. It had 139 successful jobs, 16 skipped jobs, and one independent Doctor fixture failure plus the aggregate gate. The fixture expected onlybusctlbut the existing unavailable-service diagnostic legitimately calledsystemctl. Its source came from newer main; all five candidate files were unchanged in the tested merge. The canonical fix is included in the refreshed base. The trusted ClawSweeper review offa202e5c, updated September 17 at 13:02 UTC, accepted the refreshed integration evidence and historical timing scope with no introduced correctness or security findings. Newer main changes caused a merge conflict, requiring the current cold-history port. That review does not qualify the new head.Historical evidence from the original September 15 candidate
These results belong to original head
be4cdc61d59a0ef0d1f19b50a7dcf28e1511c7c8. Focused coverage passed 147 tests across five files, 31 selected history/TUI cases, and 11 single-row cases. Prompt-decoding regressions failed on the original lookup; changed checks, review, and the normal build passed.On retained synthetic state, the two SQL queries returned identical rows. Forty alternating measurements averaged 1.95 ms before and 0.08 ms after. The original query-plan test verified indexed execution but did not reproduce the old planner choice in that earlier run. These are SQL measurements, not Gateway latency measurements.
The real-provider natural20, Stop9, recovery2, and held20 campaigns passed functional, settlement, and durable-deletion checks. All 1,316 foreground RPC observations succeeded, but 17 exceeded the unchanged 500 ms target: 14 of 958 UI foreground observations and 3 of 358 held foreground observations. Held reads reached 3,862.680 ms. Stop took 669 ms at the Gateway, 906.800 ms in the native browser request, and 2,010.947 ms through relay acknowledgement; these clocks remain separate. Public deletion took 7,188.631 ms and is separate from foreground reads. No original failure or slow sample was removed.
The original CI run failed its older recursive-spawn case waiting for model execution; nine siblings passed. Later main included #149199’s measured cold-entry fixture repair, #149179’s model-catalog isolation, and #149036’s model-inheritance coverage. The failure did not recur in the subsequent
b918ab/7a3160e5comparison; the cause of the historical failure remains unestablished.