Repository navigation
refactor(sessions): move transcript reads to retained history owner - #166293
Conversation
|
Codex review: blocked before merge. Reviewed October 8, 2026, 4:37 AM ET / 08:37 UTC (Revision 13). ClawSweeper reviewWhat this changesMoves transcript pages, pre-reset memory capture, and context validation through retained database workers while preserving existing storage and synchronous plugin contracts. Warning SQLite table change This PR modifies persisted SQLite tables in Review scores
ProductKind: Performance · Worth it: Yes Merge readiness⛔ Blocked before merge - 3 items remain This PR remains useful: current main still performs the targeted transcript reads synchronously. The freshness-observer finding is fixed, and no new actionable code defect was found in the inspected paths, but the declared integrated SQL qualification remains incomplete. Priority: P2 Before merge
FindingsNone. Provenance
Tests
Agent review detailsHow this fits togetherOpenClaw stores conversation transcripts in per-agent SQLite databases. These readers supply conversation pages, memory excerpts, and validated model context to the Gateway and bundled plugins. flowchart TD
A[Conversation and plugin requests] --> B[Capture physical database]
B --> C{Prepared worker available?}
C -->|Yes| D[Retained execution worker]
C -->|No| E[Existing history reader]
D --> F[Check freshness and current authority]
E --> F
F --> G[Transcript pages and validated context]
Technical reviewBest possible solution: Complete the existing worker cutover with source-bound SQL qualification while retaining the documented synchronous SDK compatibility and final authority fences. Do we have a high-confidence way to reproduce the issue? Not applicable as a behavior-preserving worker refactor; current-main source confirms the synchronous reads, and the body records focused failing-before regressions for the repaired integration defects. Is this the best way to solve the issue? Yes: reusing the existing physical database and history owners is a maintainable direction, with final acceptance fences and released synchronous contracts preserved; the declared measurement remains necessary to qualify the integrated result. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4dc47557f10d. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. Added test files: 30. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: LabelsLabel changes: No label 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 HistoryReview history (12 earlier review cycles; latest 8 shown)
|
Record the synchronous Codex validator deprecation boundary and prove the released three-argument generic reader and validator signatures remain compatible. Runtime behavior, stored data, and update semantics are unchanged.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep Gateway read and turn suites in their existing forked project. Join projection reconciliation before settled cursor assertions, while retaining separate unavailable coverage. Count evaluated table-valued PRAGMA branches without losing cached direct-PRAGMA counts; positive controls preserve the zero-schema and freshness budgets.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Integrate main 5be0e77. Preserve the Board, transcript-delta, and Memory operations in the shared history reader. Keep foreign-DDL admission revocation and exact freshness-probe bounds.
|
Merged via squash.
|
The two cancellation branches added in #166293 rejected raw abort reasons, requiring new lint suppressions. Preserve existing Error identity and wrap other reasons with the canonical AbortError factory, retaining string messages and the exact original cause. Keep listener cleanup, FIFO ordering, and accepted-work draining unchanged. Cover both already-aborted and queued operations with Error, string, and object reasons. The four non-Error regressions fail before this change. Remove the now-obsolete exact inventory entry added by #167185. No persistence format, migration, or public SDK signature changes. Validation: the six-case regression fails on the original non-Error paths and passes with this change. Linux runtime-config passed 5,492 tests; all 40 SDK lock/read cases passed. Full infra completed with 27,124 passes and two stale fixtures already fixed on the landing base. Full tooling's runner prerequisite and Git-shape failures were reconciled by unchanged 17-file replays (1,407 passing tests, no skips). Production/all-exports Knip, source contracts, architecture, formatting, typed/boundary lint, core/root test types, and changed-file lanes passed. The suppression guard passes on the rebased tree. P2 review is scoped-clean.
…penclaw#166293) * refactor(sessions): move transcript reads to retained history owner * test(codex): capture callable history worker spy * test(sdk): guard released transcript reader compatibility Record the synchronous Codex validator deprecation boundary and prove the released three-argument generic reader and validator signatures remain compatible. Runtime behavior, stored data, and update semantics are unchanged. * test(sessions): stabilize transcript worker CI contracts Keep Gateway read and turn suites in their existing forked project. Join projection reconciliation before settled cursor assertions, while retaining separate unavailable coverage. Count evaluated table-valued PRAGMA branches without losing cached direct-PRAGMA counts; positive controls preserve the zero-schema and freshness budgets. * fix(gateway): rejoin sharing readiness after history reads * test(gateway): await child settlement before stable public reads * fix(sessions): preserve transactional context prefix validation * perf(sessions): reuse prepared executors for transcript reads * perf(sessions): reuse prepared watermark readers * test(sessions): fix worker reader integration fixtures Wait for the existing projection owner before asserting the committed mirror page. Recognize combined SQLite version probes in the pairing and conversation counters while preserving exact freshness counts and foreign-change checks. Remove an unused cold-worker type re-export; the canonical type and emitted JavaScript remain unchanged. * fix(ci): remove duplicate transcript test routing * fix(ci): align transcript lint and freshness counter checks * refactor(sqlite): keep atomic version probes with snapshots * test(sessions): count combined runtime-target freshness probes
The two cancellation branches added in openclaw#166293 rejected raw abort reasons, requiring new lint suppressions. Preserve existing Error identity and wrap other reasons with the canonical AbortError factory, retaining string messages and the exact original cause. Keep listener cleanup, FIFO ordering, and accepted-work draining unchanged. Cover both already-aborted and queued operations with Error, string, and object reasons. The four non-Error regressions fail before this change. Remove the now-obsolete exact inventory entry added by openclaw#167185. No persistence format, migration, or public SDK signature changes. Validation: the six-case regression fails on the original non-Error paths and passes with this change. Linux runtime-config passed 5,492 tests; all 40 SDK lock/read cases passed. Full infra completed with 27,124 passes and two stale fixtures already fixed on the landing base. Full tooling's runner prerequisite and Git-shape failures were reconciled by unchanged 17-file replays (1,407 passing tests, no skips). Production/all-exports Knip, source contracts, architecture, formatting, typed/boundary lint, core/root test types, and changed-file lanes passed. The suppression guard passes on the rebased tree. P2 review is scoped-clean.
What Problem This Solves
Transcript deltas, pre-reset Memory capture, and final context validation still execute SQLite work on the Gateway thread. This moves those reads to the existing database workers while preserving physical store identity, foreign-commit freshness, reset ordering, and live authority after asynchronous work.
User Impact
Transcript and file reads retain one physical source across pages. Memory captures the pre-reset excerpt before its continuation proceeds. Public session reads consume current membership facts after awaited history, and captured context prefixes remain valid across later appends. Schema, retention, durability, configuration, transcript format, and released synchronous SDK contracts remain unchanged.
Why This Change Was Made
Raw/visible deltas, bounded Memory capture, and context validation reuse admitted revision facts and existing read kernels. When the exact physical database already has a prepared executor, reads borrow its captured generation and join its admission queue. Otherwise, the existing read-only owner remains responsible. A captured generation cannot fall back to a replacement after revocation. Incognito storage retains its existing process-local owner unless explicitly bound to an executor.
Memory hooks reserve continuation and settlement before capture yields. Manual reset waits for the excerpt; automatic reset joins the complete save. The cold-worker extraction changes types only. Manual compaction and
sessions.compact/maxLinesretain main's implementation.Related and overlapping work includes #166054, #166074, #166102, #165921, #162433, #166387, #166503, #166539, #166689, #166698, #166617, #166704, #166778, and #166867. The resolved integration preserves main's worker-owned locked writes, compressed transcript payloads, current public-session readiness, and both sides of the host-owned test routing. Manual compaction and
sessions.compact/maxLinesretain main's implementation.Nested delta, watermark, and context reads reuse the transcript lock's retained worker and FIFO. Append preparation uses a child read queue that settles before commit. Final context validation keeps its native mutation witness and synchronous acceptance in the same lock turn. Cancelled waiting reads do not dispatch; escaped callbacks reject after their scope closes. The carrier is shared across native and bundled SDK module copies.
The execution owner also distinguishes coordinated native generation closure from unexpected worker loss. A maintenance operation completing during an intentional close previously retired the entire owner. The fix joins that close while retaining existing revocation, native-loss, and failed-cleanup behavior.
Remaining synchronous reads
src/skills/workshop/experience-review.ts:198/:212andsrc/agents/cli-runner/history-boundary.ts:159/:161.src/gateway/server-methods/sessions-files.ts:240.extensions/codex/src/app-server/session-history.ts:135and:34.Compatibility
The released-signature audit compares
v2026.10.1-beta.1andv2026.9.8. Raw/visible delta APIs were already asynchronous. The generic three-argument Codex context reader and both validators remain synchronous; the physical-source argument is optional. Thecodex-transcript-sync-validationcompatibility record and type test cover that retained boundary. The removedSessionColdTurnGuardre-export was internal-only; its canonical type remains, and emitted JavaScript is identical.The final local SDK comparison for
2f1f73ccb222→bab073ed48a9completed in 852.05 seconds with native cleanup (digest0ac1cc24926dd88a4934f6057007fb5bf57117f5927e33e3a081d06c507f787a): zero entrypoint additions/removals and zero direct public declaration changes. The independent audit confirms 165 reachable exports and 16 named declaration records (15 distinct text pairs). The successor8d6bd1327651changes only a test observer; production and SDK inputs are identical. The measured/report SHAs are retained rather than relabeled. No newOPENCLAW_*names are introduced.Evidence
Final candidate:
8d6bd132765108f2e7f40c70cc2a28320e4a4f7e. Runtime/SDK proof is pinned tobab073ed48a9954e4b3bbeaa250db013125560a0; the only successor change recognizes the combined freshness probe insession-entry-readonly.worker.test.ts, preserving all assertions. Independent P2 reviews of the integration, atomic-probe extraction, and final observer repair are clean. Exact-head CI: 37749479845.Post-integration core production, all 27 core test graphs, extension production/test, UI, scripts and root types passed. Subsequent reader and owner repairs passed affected core/config/SDK/state type lanes and Madge (zero cycles). The resolved integration initially passed 92 focused cases. Final focused local proof passed 18 context/delta cases, plus the six native-close recovery cases; native and worker transcript-lock suites also passed. Prior-head Linux proof at
981cd975605epassed 431 focused cases across 26 files in 362.63 seconds, the X E2E in 392.52 seconds, 31 selected import/build/wrapper cases, and all ten tail gates. The wrapper selection intentionally excluded 16 unrelated cases. These are prior-head results; final-head CI owns the integrated broad test gate.SQL measurements
The integrated sanity comparison completed one alternating M,C pair for each of five scenarios (ten fresh samples), on the same Darwin arm64 host with Node 24.21.0, SQLite 3.53.4 and pnpm 12.5.1. Main is
2f1f73ccb2224bbe7d961b4c0d3b29cfdd51e7f8; measured candidate isbab073ed48a9954e4b3bbeaa250db013125560a0. The final test-only successor has identical runtime and SDK inputs. All-thread successful SQL executions are counted, including transaction envelopes and background owners; no statements are dropped.Independent raw audit verified all 638 archive files, all 41 harness files, both actual packages, exact source trees/diff, ten alternating samples and native process settlement. There were zero SQL failures and zero raw/CSV, per-SQL or summary mismatches. Of 43 phase medians, 30 decreased, seven were equal and six increased as attributed below. The unchanged legacy strict auditor reports
REVIEW REQUIREDbecause it rejects any positive phase; the current landing policy applies the documented tolerances explicitly.The positive phase deltas are attributed, not erased. Boot's +6 is unchanged-owner work; boot+connect falls 3075→2954. Cron's changed-owner net is −54 and unchanged-owner net +77; control+cron rises 1990→2011 (+1.055%). RPC catalog/auth/entry-patch work shifts from seed into history, while their combined window falls. Across the three file blocks, foreground SQL falls 235→234 and background SQL rises 78→83 (+1.278% total). File get/assets retain seven foreground executions per read; the added work is scheduled WAL, shared-state, OAuth, secret-expiry and pairing maintenance. Some unchanged-owner background query shapes occur only in the candidate sample; this is not claimed as an exact trace match. The documented non-turn tolerances and adjacent windows apply.
The run retains duration flags: shared boot 5.20× and first turn 3.26×, RPC boot 2.40× and compaction 1.55×, facade warmed phases 2.17–3.54×, memory capture first 33.73×/warmed 2.34×, and Codex marker first 1.75×/warmed 2.08×. The complete duration audit retains all 16 flags, including RPC post-work completion 143.39×. Shared warmed-turn duration falls 2572→2284.4 ms. This is the explicitly requested one-pair landing sanity check, not a latency pass or a replacement multi-pair performance benchmark. No PR-attributable first/warmed SQL increase triggers expansion under the landing instruction.
Pinned workload and commands
The identical 41-file workload on both sides is
rpc-catalog-settled-v1; harness manifest SHA-2567f833b9f28b49c963c1c0962e1fc29ed86e75d5d0bfb5aa4dc4ad18d2f923635, archive SHA-256af92bfc0678b9815585fa7d2f78b8ffa3eab4706b0bc2ea1c8a6f603951cc205. The independently audited numerical archive is22eb972474863669257f129c9fefe203c048a54a479726130c668ed8e4a7b142. Main package SHA-256 isbc99fdd016a48ddf1634089f2ab2333f712eee664e56aa6e7ff2ce5176001b5c; candidate package SHA-256 is01be755b6f1051e13328742206d8eb1d9bcbbeeefda71623c9234708d510a9e3. The source/command binding manifest is8a05bf85c322249bdbd8bf78fd581651d6066b713749f838b2c417545010289d; orchestration SHA-256a4507c74dec75329e5509b73d5e6a1929f57bcb7aa76bd5ccb1f8a23d1e0f713. The harness is task-local, not a checked-in product file or a publicly downloadable artifact; these are immutable content identities and the actual command recipe, not a claim of a public harness URL.Both source builds precede sampling. Execute each scenario once on main, then once on candidate, in the table's scenario order;
REPO,SHA,OUT,HARNESSandINSTALLbelow name the pinned source/output paths. Both actual Codex packages are built and installed before their M,C sample pair.Failures diagnosed and repaired
The public-reader 404 was a real readiness bug: membership publication during awaited history was mistaken for a missing share.
9005380f57carejoins the existing readiness owner before and after history, retaining identity and revoke/reset checks; the corresponding main implementation is now preserved.The subsequent X HTTP 503 was a fixture settlement race. The cache correctly refused a response invalidated by actual child publication and returned
Retry-Afterwithout stale content. The stable GET must follow the child's admission release. Main now contains that wait plus explicit membership preparation and an active-share assertion; this PR preserves the complete fixture. It makes one GET with no retry or weakened assertion.699a0a02dbcaremoved an incorrect exact-validation shortcut for captured context. Four affected cases each passed 5/5 on main and failed 5/5 on the pre-fix PR withSessionTranscriptReadFenceError; all three repaired suites then passed 83 cases.03545d95ae64andbb4abcada046fixed measured cold-read admission regressions by reusing the prepared physical executor for transcript and watermark reads. Both queued-writer regressions failed before the corresponding owner fix and passed afterward.CI run 37672190145 on e514 exposed two fixture defects, not inherited-main failures. The mirror case assumed projection repair could not finish before an awaited public read; the test now joins the existing projection owner and asserts the exact committed two-entry page. The dedicated visible-delta test still asserts refusal while projection is dirty. The pairing counter recognized only
PRAGMA data_version, missing the combinedSELECT ... FROM main.pragma_data_version()probe. The same issue was found in the conversation counter.f821bdac8872recognizes both forms while retaining exact 1/3/4 and 3 freshness counts and foreign-change assertions.Matched Node 24.21.0/SQLite 3.53.4 reproductions ran each complete file five times on main
7e16a229and unpatched PR2d14ae01, singly with--maxWorkers=1, with identical test bytes. Main passes all 15 invocations. All 15 PR invocations reproduce exactly the diagnosed failure; every other case passes. The repaired four-file selection passes all 24 cases in 101.59 seconds. The earlier Linux candidate passed these files; the final integrated broad test gate is the exact-head CI linked above. A separate PR-context failure was corrected by using the requiredEvidenceheading; no test was rerun merely to obtain green.Historical CI run 37565579194 had 38 admission/replay cases independently attributed to main: 34 through matched remote main reproductions and four through exact scheduled-main failures (main run 37559068121). Main fixes
b7987881046c,a6092b141bc2, anda74c84be818eare integrated, and those failures were absent from inspected later main run 37583759368. That evidence is retained as historical attribution, not an exception for the newer fixture defects.Historical head
981cd975605epassed CI 37693825224 and ClawSweeper 37693922653 with no actionable findings. These are prior-head evidence. Final head8d6bd1327651now has green exact-head CI (37749479845) and a completed ClawSweeper review at 2026-10-08 08:37 UTC with no actionable code findings. Its remaining measurement request is answered above. The generic schema/config warnings are rejected based on the same review’s explicit technical finding of no DDL, migration, serialized-state or default change.The worker-lock integration exposed two additional self-waits. A delta read reacquired its enclosing writer reservation; final context validation did the same before reaching the prepared reader. Both were reproduced before repair. The context diagnostic specifically reached final-validation admission after projection returned; its queued callback never entered before the 60-second deadline. The repaired boundary tests cover raw/visible/watermark reads, final context acceptance, asynchronous preparation, cancellation and closed contexts.
An existing generation-replacement regression then exposed a separate owner race. The trace showed an intentional native close starting without native failure, followed by concurrent maintenance preparation treating the closing native store as failed and closing the entire execution owner. The assertion remains unchanged. The owner fix passes it and the existing contention, deadline, shutdown, genuine native-loss and cleanup-recovery cases. Temporary diagnostics are removed. The queue fixture now identifies its exact reader by target and signal, so unrelated background admission cannot satisfy its gate.
CI on
60f6951f1f58stopped in preflight because the main integration registeredsession-transcript-runtime.configured-store.test.tstwice in the host-owned test list (failed job).470cebf4ea5fremoves only the later duplicate, preserving the original routing and all assertions. The real CI manifest command passes locally in 45.94 seconds after the repair. This was PR-caused, not an inherited failure.The next CI run exposed three lint diagnostics in the lock integration and one stale version-probe counter (lint job, test job).
34ba3f89e354renames the nested queue parameter, preserves caller-owned abort reasons using the retry owner’s narrow lint exception, and teaches the validation-cache observer to recognize the combined pragma-function SELECT. Cancellation logic and every exact-count, foreign-change, transaction and revocation assertion remain unchanged. Focused lint passes; all 32 validation-cache cases pass (648.77 seconds including compiled-worker preparation), with native process settlement verified. Fresh P2 review is clean. These failures are repaired, not claimed as inherited.GitHub reported another real conflict after
34ba3f89e354. Merge commitd2ecdabf676fintegrates main2f1f73ccb222: it preserves main’s Workshop rewrite and carries committed schema markers from the combined version probe into the existing schema-invalidation owner. No second snapshot read is added. All 27 core test type graphs, core and extension production/test type lanes, 93 focused cases, and the import-cycle check passed.bab073ed48a9then moves that unchanged atomic probe into the already-imported snapshot module to satisfy main’s 700-line lint limit. Focused lint/core types, 42 schema cases, 11 import/build-graph cases, and fresh P2 review pass. The additional overlaps are #166587 and #161057. Final one-pair measurement and SDK comparison use this integrated head.The final observer repair
8d6bd1327651fixes the same combined-probe recognition in the readonly-worker suite. Its focused case passed in 75.74 seconds including worker preparation (one selected case, 18 deliberately filtered); all exact-count and foreign-schema refusal assertions remain. CI on the preceding head exposed this PR-caused observer defect; it is not classified as inherited.The two agent stop-command cases observed on
bab073edalso fail in scheduled main run 37740077201, head2f1f73ccb222, with the sameError: Expected recordstack atagent.test-harness.ts:98andagent.abort-integration.test-utils.ts:250/:495. The cases are “preserves stop-command reason when /stop lands during the accepted ack yield” and “does not dispatch when a stop command lands during pre-accept setup.” The test and both harness files are byte-identical and untouched by this PR. These qualified the inherited exception on the prior head, but final-head CI passed: no inherited-failure bypass or rerun was needed.