Repository navigation
perf(sessions): batch transcript index reconciliation - #173620
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR batches transcript-index traversal, readiness classification, and pending-queue updates. Example: Background maintenance encounters 96 dirty sessions named session-000 through session-095.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed optimization preserves the existing reconciliation owner and bounds, adds distinct work absent from current main, and has no identified correctness defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe agent database's writer-owned maintenance worker consumes transcript changes and pending receipts, classifies projection readiness, removes bounded orphan rows, and returns sessions needing rebuild. flowchart TD
A[Transcript and projection writes] --> B[Transactional pending receipts]
B --> C[Projection maintenance worker]
D[Bounded session traversal] --> C
C --> E[Shared readiness predicate]
E --> F[Pending rebuild sessions]
C --> G[Bounded orphan cleanup]
Technical reviewBest possible solution: Retain batching within the existing projection owner while preserving readiness, traversal progress, and bounded cleanup. Do we have a high-confidence way to reproduce the issue? Current main visibly performs traversal, readiness, and pending-queue commands per session; source establishes the repeated work, but no performance benchmark was run during this read-only review. Is this the best way to solve the issue? Batching at the existing writer owner addresses repeated command overhead directly and reuses the canonical readiness predicate without adding persistent state or another maintenance path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5ae65452e5a0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +56, Tests +40, Docs +3. Total +99 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 15, 2026, 9:30 PM ET / October 16, 2026, 01:30 UTC. |
* commit '56c315156f4542f197a2b7f727681ba3f41c21b5': (23 commits) fix(ui): remove stale Lit cleanup from model catalog tests refactor(tests): consolidate iMessage discovery checks (#173624) fix(auto-reply): retire older collect cancellation after admission fix(memory): avoid rebuilding initially empty indexes after restart (#173622) fix(test): preserve subprocess runtime identity (#173446) perf(sessions): batch transcript index reconciliation (#173620) fix(gateway): share GitHub options preparation during reconnects (#173589) perf(control-ui): open the composer model picker without list-wide work (#173275) fix: finish compile-cache cleanup after short CLI commands exit (#173603) refactor(ui): finish native shell rendering (#171554) fix: preserve standalone CLI profiles and settle Doctor shutdown (#173154) refactor: centralize agent memory host typing (#173619) fix: camera fallback picker opens away from the attachment button (#173618) refactor: deduplicate existing CI runner routing with YAML anchors (#172670) fix(ai): preserve multiline Google replies and report malformed streams (#173612) refactor(tests): remove duplicate speech policy test (#173606) refactor(ui): simplify page rendering and derivations (#173608) fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615) fix(update): wait for native Gateway ownership before restarting (#173588) test(sessions): admit schema probe fixture writes behind maintenance ...
Batch transcript-index traversal, readiness classification and receipt updates inside the existing writer owner. Preserve 128-session and 512-orphan bounds, immediate search freshness and incremental receipt invalidation. Remove the redundant clean-status sibling-revision reread; a later sibling write is handled by its receipt and the next maintenance pass. A 4.76-million-event synthetic fixture reduces cold reconciliation from 38,074 to 938 SQL statements with zero MAIN SQL and unchanged append WAL costs. Exact-head CI and two Codex review rounds pass. Knip findings match scheduled main run 38832586414. The shared synchronous SDK index sites remain under their existing compatibility contract.
* fix(ci): share the iOS screenshot build * fix(ci): preserve the screenshot artifact container on download * merge: integrate main for iOS screenshot workflow conflicts * style(ci): format the combined screenshot evidence changes * docs(ci): name the combined screenshot capture * fix(ios): expose screenshot simulator creation errors * Merge main at 56c3151 to include the UI test cleanup fix * commit '56c315156f4542f197a2b7f727681ba3f41c21b5': (23 commits) fix(ui): remove stale Lit cleanup from model catalog tests refactor(tests): consolidate iMessage discovery checks (#173624) fix(auto-reply): retire older collect cancellation after admission fix(memory): avoid rebuilding initially empty indexes after restart (#173622) fix(test): preserve subprocess runtime identity (#173446) perf(sessions): batch transcript index reconciliation (#173620) fix(gateway): share GitHub options preparation during reconnects (#173589) perf(control-ui): open the composer model picker without list-wide work (#173275) fix: finish compile-cache cleanup after short CLI commands exit (#173603) refactor(ui): finish native shell rendering (#171554) fix: preserve standalone CLI profiles and settle Doctor shutdown (#173154) refactor: centralize agent memory host typing (#173619) fix: camera fallback picker opens away from the attachment button (#173618) refactor: deduplicate existing CI runner routing with YAML anchors (#172670) fix(ai): preserve multiline Google replies and report malformed streams (#173612) refactor(tests): remove duplicate speech policy test (#173606) refactor(ui): simplify page rendering and derivations (#173608) fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615) fix(update): wait for native Gateway ownership before restarting (#173588) test(sessions): admit schema probe fixture writes behind maintenance ... Co-authored-by: Vincent Koc <[email protected]>
* fix(ci): share the iOS screenshot build * fix(ci): preserve the screenshot artifact container on download * merge: integrate main for iOS screenshot workflow conflicts * style(ci): format the combined screenshot evidence changes * docs(ci): name the combined screenshot capture * fix(ios): expose screenshot simulator creation errors * Merge main at a11e38b to include the UI test cleanup fix * commit 'a11e38b8bb1eb58aaf392a0eab458dbb47aad30f': (23 commits) fix(ui): remove stale Lit cleanup from model catalog tests refactor(tests): consolidate iMessage discovery checks (openclaw#173624) fix(auto-reply): retire older collect cancellation after admission fix(memory): avoid rebuilding initially empty indexes after restart (openclaw#173622) fix(test): preserve subprocess runtime identity (openclaw#173446) perf(sessions): batch transcript index reconciliation (openclaw#173620) fix(gateway): share GitHub options preparation during reconnects (openclaw#173589) perf(control-ui): open the composer model picker without list-wide work (openclaw#173275) fix: finish compile-cache cleanup after short CLI commands exit (openclaw#173603) refactor(ui): finish native shell rendering (openclaw#171554) fix: preserve standalone CLI profiles and settle Doctor shutdown (openclaw#173154) refactor: centralize agent memory host typing (openclaw#173619) fix: camera fallback picker opens away from the attachment button (openclaw#173618) refactor: deduplicate existing CI runner routing with YAML anchors (openclaw#172670) fix(ai): preserve multiline Google replies and report malformed streams (openclaw#173612) refactor(tests): remove duplicate speech policy test (openclaw#173606) refactor(ui): simplify page rendering and derivations (openclaw#173608) fix(release): Linux channel promotion fails after a withdrawn Windows companion (openclaw#173615) fix(update): wait for native Gateway ownership before restarting (openclaw#173588) test(sessions): admit schema probe fixture writes behind maintenance ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Transcript-index reconciliation spends hundreds of SQLite statements per maintenance chunk when an agent has thousands of session generations.
Related: #172985 and #172681.
User Impact
Background transcript-index maintenance uses fewer database commands while preserving immediate transcript-search freshness, bounded cleanup, and writer fairness. No schema migration, configuration change, or user action is required.
Why This Change Was Made
The existing writer-owned pending-session receipts already identify local changes. This change batches their classification and queue updates, and replaces per-session traversal commands with one bounded recursive index-seek query. It reuses the projection owner's readiness predicate, keeps the 128-session and 512-orphan-row budgets, and deletes the superseded per-session query loop.
A clean-status read no longer rereads the sibling-write revision afterward. Accepted edge case: a sibling write immediately after the read is observed through its receipt and the next maintenance pass. This is internal bookkeeping; search readiness and external-effect authority checks are unchanged.
The initial traversal and a sibling receipt still reconcile the owner state; subsequent local writes use the existing pending-session receipt path. No new generations, admission protocol, engine-specific search implementation, or durable bookkeeping store is added.
Evidence
git diff --checkpass. Exact-head CI passes, including production/test types, lint, Madge, source contracts, architecture guards, T1/dialect ratchets and changed Node tests. The required CI, dependency and security gates are green.cedc5aeb4cc5; none is in the changed files. These are inherited under the campaign landing rule. All six alternating harness cells have completed.The six shared-module sites remain for the supported synchronous SessionManager/SDK contract through December 31, 2026; their async API cutover is separate from this caller-only reconciliation change.
Cold production reconciliation removes 97.54% of statements. The extra candidate production statement is a passive checkpoint outside the direct owner. Physical visits come from a separate read-only-main
sqlite3_stmt_scanstatusreplay; intermediate work is disclosed separately and is not a physical-table scan.The synthetic fixture contains 4,763,052 transcript events, 9,329 nonempty generations, 8,564 logical sessions, 155,249 FTS rows and 84 aggregate planner-statistics rows. Database plus compressed reset is 7.80 GB. It models aggregate cardinalities and planner statistics, not the complete production payload-size distribution. No private rows or messages were copied. The fixture was deleted after measurement.
No append-WAL saving is claimed: small byte differences are consistent with UUID-related page splits. Actor statement counts remain 8 / 11 / 9 for metadata / assistant / tool appends. The standalone first-write driver has 8 lazy admission/watch MAIN statements on both versions; that is outside reconciliation and is not a warmed Gateway measurement.
Values are median [min–max]. The order was M,C,M,C,M,C at baseline
ffcb0a8cfa75f189abbbf425180907c797522767and candidate969ddfd51d3e96e112784d4a3c60b148b882fa38. Warm distributions pool 30 turns per version; other distributions contain three phase totals per version. Six complete runs passed, including foreground turns, RPCs, cron, child execution, compaction, restart and both shutdowns per run. Independent totals and request-ID joins agree with the shared analyzer; no failed SQL executions or prepares occurred.Causal warm MAIN is zero throughout. Raw warm MAIN has occasional background lease-maintenance reads from
openclaw-state-lease-store.ts; none belongs to the index owner. Index/memory request counts mean requests containing that family’s SQL, joined through the request ID and origin stack. A request may contain multiple families, so these counts are not additive.The remaining three index-related statements per warm turn are the latest active-boundary metadata read, visible-transcript statistics read, and transcript accounting snapshot read: one each on both versions.
appendToIndexretains ten statements in three containing requests per warm turn on both versions.Shared read families use explicitly recorded SQL signatures and source attribution for these v3 runs; their scope is not asserted identical to older census taxonomies.
Raw first-turn increases are startup redistribution, not added turn work. The agent-database schema owner emits exactly 142 statements across boot + connect + first turn in every run; 128 of those statements fall before the first-turn window in two baselines but inside it in every candidate. The agent-database owner and metadata totals are also unchanged across the combined window (14 and 8 statements respectively). Combined memory SQL is 409 in all six runs; combined index SQL is 51/52/52 on base and 51/52/51 on candidate. First-turn causal requests remain 68 at the median; the raw request difference is background submission timing.
Whole-workload medians differ by +3 SQL (+0.065%) and +1 request (+0.086%); index and memory medians are unchanged at 354 and 499 statements. Idle medians differ by +1 SQL and +1 request from unchanged checkpoint/housekeeping timing. One candidate idle window includes one extra background
loadMemorySourceFileStateread, leaving its three-run median unchanged. All warm shared-read medians are unchanged; workload entry-cache snapshots fall from 64 to 63. No touched-owner regression is observed.The six runs contain 84 successful foreground turns, 250 successful RPC records, six successful child runs and six successful cron runs. RPC record totals vary with successful
cron.runspolling. The reported first-turn, warm-turn, boot and restart duration ratios stay below 1.5 (largest 1.362); observed pre-run host load ranges from 46.98 to 69.22 on 32 CPUs. These are count comparisons, not latency claims.The host is heavily loaded. Fixture wall times and writer holds are descriptive; no latency improvement is claimed.
Scope follow-ups: the three per-turn index-state updates should be folded into the actor's existing append or turn-settlement transaction. FTS write amplification needs a separate measured change, beginning with engine-owned merge tuning or insert batching. Deferring FTS requires a durable backlog and a pending-search overlay to retain immediate freshness, so it is outside this no-schema change.
Change size: four files, +152/-53 lines, including regression coverage and storage documentation.