Repository navigation
perf(sessions): keep closed-turn transcript work in workers - #169052
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. |
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
|
Codex review: needs changes before merge. What this changesThis PR combines transcript suffix planning and replacement in one writer transaction, classifies closed-turn reads as worker-only, and rejects unbound incognito outbox operations. Example: Start a turn in agent:main:dashboard:incognito-demo with a durable context engine and no actor binding.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 2 items remain Keep this PR open: the suffix transaction simplification is useful, but the typed missing-owner rejection still prevents supported native incognito turns from starting. Priority: P1 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe session persistence and context-engine outbox owners consume transcript events and turn admissions, execute SQLite work, and return committed transcript facts or pending turn advancement. flowchart TD
A[Session turn] --> B[Outbox store]
B --> C[Agent or incognito worker]
C --> D[SQLite transaction]
E[Suffix replacement] --> D
D --> F[Committed transcript facts]
Technical reviewBest possible solution: Keep the suffix simplification and existing worker cutover, and defer typed unbound-incognito refusal until runtime acquisition installs the actor binding. Do we have a high-confidence way to reproduce the issue? The current source establishes the failure through native acquisition, missing binding, typed rejection, and admission rethrow; no target code was executed during this read-only review. Is this the best way to solve the issue? Combining suffix planning and mutation is coherent under the single synchronous writer owner, but rejecting every unbound incognito target is premature while native acquisition remains supported. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d1618ccd0b27. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -37, Tests -11, Docs +13, Other 0. Total -35 across 16 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
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 HistoryReview history (2 earlier review cycles)Reviewed October 11, 2026, 7:47 AM ET / 11:47 UTC (Revision 3). |
…#169052) Classify closed-turn range reads in the worker and keep incognito outbox operations on their actor. Prepare and apply transcript suffix mutations in one transaction, removing repeated internal checks while preserving the append/source integrity check. T1 calls decrease from 635 to 629 on the final integration base. Warmed-turn SQL is neutral; the measured +1.05% whole-workload admission overhead is accepted for this worker cutover. Focused tests and static gates pass; inherited lint and Knip failures match main.
First-parent upstream 75df19c..5ed6a30 (23 commits, including openclaw#169005 infrastructure SQLite work and runtime-write offload, openclaw#169062, openclaw#136677, openclaw#169070, openclaw#168857 plugin-sdk SQLite runtime writes into workers, openclaw#169038, openclaw#168916, openclaw#169053, openclaw#169052 closed-turn transcript work in workers, openclaw#168974, openclaw#168811, openclaw#169082, openclaw#169084, openclaw#166581 worker heap limits). Conflicts: - openclaw-state-worker-runtime.ts: upstream routes more update-run mutations to the worker; our continuation custody dispatch stays ahead of that branch. - worker-access inventory: regenerated (632 files, 2429 calls). server-restart-sentinel.ts auto-merged: upstream's awaited update-run writes; our continuation restart delivery is unaffected. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Closed-turn transcript persistence retained a main-thread incognito outbox fallback, and suffix replacement read the same source and projection facts repeatedly while preparing and applying a single mutation.
User Impact
Transcript suffix replacement preserves stale-input rejection and committed transcript bytes with fewer reads. Incognito outbox operations use their existing session actor; an unbound incognito session fails with the existing missing-session error instead of opening native state.
Why This Change Was Made
Prepare and apply suffix replacement in one synchronous writer transaction. Retain one exact source comparison and the caller-provided mutation timestamp check, plus writer authority and rollback. Remove the exported preparation path and its second source read, repeated mutation reads, duplicate projection-health check, and pre-transaction hot-state check. Mark the closed-turn range module as worker-only; retain the outbox worker cutover now also present on main.
Final-base T1 inventory: 635 → 629 (−6) against
2c1f8c167747805bee91c55970f1b5f5fd0665f5. All six calls are the range module now accurately classified as worker-only. The original measured base was 705 → 687 (−18); main independently absorbed the outbox cutover before this final integration. The twelve named transcript hot spots total 125 → 119 T1 calls; the six-call range module accounts for that scoped reduction. The remaining transcript/index/history/archive kernels still have released synchronous SDK or maintenance callers; they remain T1. Reclassifying those kernels would conceal reachable work. Their complete cutover needs an owner/API change outside this scoped patch. Remaining named counts are unchanged: transcript-state 14, suffix 12, projection-rebuild 12, index 9, transcript-write 6, parent 5, history-interval 8, active-events 5, active-context 6, archive-store-kernel 6, and node-artifacts 26. NativeSessionManager.persist()/append and unbound compaction still reach index/projection kernels; reconciliation's maintenance/deletion fallback reaches the archive/artifact kernels. These are the calls stopped under the owner-redesign escape hatch, not worker-only implementations.Removed checks and accepted edge cases:
No schema, migration, retention, update, Doctor, plugin loading, service lifecycle, or SDK surface changes.
Evidence
Shared harness, three alternating pairs on the same Blacksmith Testbox, baseline
4ea3e6bc0b9f781feea0ac744dd4428c63344367versus this patch. Values are median [min–max].The measured warmed transcript operations emit identical SQL and requests: anchors 12 statements/1 request, hydration 27/2, actor append 23/2, delivery settlement 7/2, patch commit 64/7, and patch prepare 6/3 per turn. The harness does not execute suffix replacement or incognito outbox operations; it therefore does not establish a warmed SQL saving for the modified paths.
The raw increase triggered the required extra alternating pair on a fresh Testbox after the original lease expired:
Extra SQL is repeated admission in unchanged readers: +19 each
user_version,schema_version, and schema-catalog reads; +13 primary schema metadata reads; +6 each canonical-table setup statements. The extra pair's unchanged reader families include exact entries (+32 statements), membership (+22), tombstones (+16), entry (+11), corpus inventory (+11), and transcript stats (+10); offsets in other families bring the total to +114. No changed suffix/outbox operation ran. Coordinator accepted this +114-statement (+1.05%) / +7-request cold admission overhead on 2026-10-11: moving Gateway SQLite off the main thread is the mission and warmed turns are neutral. This limitation is accepted for this PR; it is not reported as a warmed query-reduction win.Product source was pinned at
d992ea4bb0a8be8efe9ee4facb007c002e4bccc6; measurement carrier commits add only task-owned proof bootstraps. The canonical workload and observer were unchanged, with census hooks shared by the campaign. All workload runs passed and duration ratios stayed below 1.5.Blacksmith Testbox: all 179 focused tests passed on the integrated candidate (six files;
pnpm test <files> --maxWorkers=1via the repository runner, 145.54 seconds wall time / one remote job). Coverage includes stale full/incremental suffix input after an intervening append, bound actor outbox read-after-write, missing incognito actor rejection, closed-turn delivery, attempt handling, and canonical descendants.check:changed --base 4ea3e6bc0b9f781feea0ac744dd4428c63344367passed, including core/test typechecks, type-aware Oxlint, Knip exports, T1 and dialect ratchets, and source contracts. Separate Madge and export-collision checks passed. SDK API diff and published-driver update cell are not applicable to the touched surfaces.Production/test LOC: +54/−111 production (net −57), +55/−66 tests (net −11); +22/−1 inventory tooling and +39/−24 generated inventory/documentation. Generated inventory and documentation are reported separately. Reviewed with the Codex autoreview engine: no actionable P0/P1 findings.
Earlier integrated-head verification (
008e0df702461075febeeaafea851863a9f4c518): all 179 focused tests also passed after the first conflict-only integration (148.38s). All planned static commands completed on the final head: core and test typechecks, source contracts, T1/dialect ratchets, script lint and root-test lint passed. The max-lines suppression check fails on untouchedsrc/web-search/runtime.test.ts; the same rule/file was reproduced on baselineac8a432aafa73674f8e41ab2132860d8901c6dcb. Knip reports the same 28 production/full-tree export entries on candidate and that baseline (MCP UI components and one subagent registry export). Type-aware Oxlint reports the same 15 max-lines errors on the same untouched files on both revisions. No changed file has a static failure. Separate Madge and export-collision checks passed. The latest conflict integration adopts main’s outbox worker kernel and migrates its range import; it adds no SQL. On final headadfe6943727a9f2dfc5da279b0a0862e4c71cb66, the three affected outbox/attempt suites passed (96.81s), type-aware Oxlint for all three affected production modules passed, and export collisions, T1 and dialect ratchets passed. Knip’s 50 production/full-tree entries exactly match the same files and symbols on the integration base2c1f8c167747805bee91c55970f1b5f5fd0665f5; none is a changed module.Landing uses the RELAXED LANDING v4 head-pinned REST squash fallback after two native review allocation failures; the owned stale operation lock was recovered. Required CI/security status is checked on the exact head before dispatch. Final diff: 16 files, +128/−163.