Repository navigation
perf(sessions): reuse prepared transcript rewrite queries - #139770
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: needs maintainer review before merge. Reviewed September 6, 2026, 4:58 AM ET / 08:58 UTC. ClawSweeper reviewWhat this changesReuse compiled SQLite update queries during transcript repairs and add coverage for distinct row bindings, caller ordering, and preserved session state. Merge readiness✅ Ready for maintainer review Keep open: the optimization remains absent from current main and the latest release, and no introduced correctness or security defect was found. The linked issue establishes accepted scope. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s transcript store receives session edits and maintenance repairs and writes canonical conversation records to SQLite. It also maintains generation markers, activity timestamps, and searchable transcript projections. flowchart TD
A[Session edits and maintenance repairs] --> B[Existing write transaction]
B --> C[Compile update once]
C --> D[Bind each row in caller order]
D --> E{Exact rewrite conflict?}
E -->|Yes| F[Roll back transaction]
E -->|No| G[Update generation and projections]
G --> H[Commit transcript changes]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +12, Tests +53. Total +65 across 2 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. Technical reviewBest possible solution: Use operation-local compiled queries with fresh row bindings while preserving the existing exact-write, rollback, and projection contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: source confirms repeated query compilation on main, and the PR supplies batch timing comparisons. Is this the best way to solve the issue? Yes. Reusing the established binding helper at the existing operation boundary removes repeated construction without adding a competing cache or changing stored-data semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f5d4d6bf53a8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
Related: #139768
What Problem This Solves
Transcript maintenance rebuilds and compiles an identical Kysely UPDATE for every rewritten row. Native SQLite statements are already cached, so repeated query construction adds avoidable work to large repairs and migrations.
Why This Change Was Made
Prepare each exact-rewrite and maintenance-repair UPDATE once per existing operation, then bind rows through the shared executor in caller order. Exact JSON predicates and affected-row checks, synchronous transaction boundaries, generation/recency updates, and text-search reconciliation are unchanged. This uses the existing helper and native cache; it adds no schema, configuration, dependency, or retained connection cache.
User Impact
Large transcript repairs and migrations spend less time constructing queries while preserving conflict rollback and all stored/projection state. Single-row operations are not the optimization target.
Evidence
4e330557ae33e0f003c8b6e17524acd859b1d0de.Warm native UPDATE preparations remained zero on both sides: these gains come from Kysely construction/compilation reuse. A separate 500-sample single-row probe found small differences, including about 7 μs overhead for Node 24 metadata rewrites. Measurements used synthetic state on a shared host; they are not universal latency guarantees.