Repository navigation
refactor(sessions): cut over snapshot callbacks and SDK reads to workers - #169637
Merged
Merged
Conversation
# Conflicts: # src/plugins/compat/registry-records.ts
Contributor
|
🦞👀 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. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 13, 2026
…ers (openclaw#169637) Route snapshot callbacks, worktree ownership reads, prepared run starts, and bundled transcript statistics/export callers through existing session workers. Deprecate synchronous public SDK contracts while retaining released compatibility and final authority checks. Reuse Gateway-owned facts and write receipts, remove duplicate owner checks, and preserve large-value SQL projections. Live isolated comparison reduced warmed statements from 355.5 to 346.5 and requests from 110 to 107; MAIN remained zero by median. Shared native/offline/compatibility kernels remain documented exceptions. Completes the second session cutover slice after openclaw#169579.
This was referenced Oct 15, 2026
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Session snapshot callbacks, worktree cleanup, recovery, and run-start/statistics SDK contracts could still force durable session reads or writes onto the Gateway thread.
User Impact
Bundled callers now use worker-owned operations and prepared run-start facts. Plugins can migrate to
onPreparedAgentRunStart,readTranscriptStatsAsync, andreadTranscriptStatsBatchReadOnlyAsync; the synchronous SDK contracts warn and remain compatible until the next Plugin SDK major. No schema, retention, transcript-format, or operator migration changes.Why This Change Was Made
Reuse the existing entry patch, history, and metadata workers. Snapshot callbacks no longer select a durable native fallback; real authority callbacks run at the existing commit grant. Worktree cleanup consumes one worker owner view and invalidates it through committed session changes. ACP reset and recovery consume owner-prepared source facts. Batched statistics preserve order, duplicates, and missing-store results in one request per durable store. Memory ingestion awaits file statistics; transcript export observers and explicit parsing yields obtain their snapshot through the existing worker, then retain host callback behavior. Prepared statistics are reused without a new read; full messages are transferred only for observers that require them.
Removed checks and accepted edge cases:
Native incognito paths remain for their separate removal. Doctor/import canonical-validation writes remain synchronous exceptions. The CLI command-execution authority check stays because it guards a real external effect.
Evidence
Independent Codex review: no actionable P0/P1 findings in two rounds. Local changed-file formatting/basic lint and diff validation are followed by PR CI for tests, types, lint, Knip, Madge and database ratchets under RELAXED TESTING v6. The completed isolated live comparison is recorded below. The measured candidate contains the final authored changes; later commits integrate main and repair test fixtures. The prerequisite read cutover #169579 has landed; this PR targets main and preserves both changes through merge commits. The assigned-file inventory decreases from 42 to 39 T1 primitives in this slice (43 at the original base); retained compatibility/native/offline paths are documented in worker-access.md and are not claimed as worker-only.
The final bundled-caller audit found and removed two additional synchronous Memory paths: ingestion statistics and callback-based transcript exports. The existing SQLite export regression now checks callback contents, zero host SQL and fresh statistics after an append. The deprecated synchronous stat adapter warns only when it performs SQL.
LOC versus main after parent landing: 1,317 insertions and 1,018 deletions across 76 files after main integration and merge repair. No update cell is required.
Prior authored-head CI run 38214900818 passed all production/test types, lint, source contracts, architecture, database ratchets and SDK boundary checks. Follow-up fixes migrate native-only test fixtures and preserve their data/authorization assertions. Seven tests that only pinned the deleted duplicate transcript-owner predicate were removed. Main’s corrected rollback-journal regression remains and exercises the low-level writer directly. Named SDK surface accounting covers only the authorized
readTranscriptStatsAsync/readTranscriptStatsSyncand prepared-run-start migration pairs.Live SQL comparison
Baseline
215556e77dbc73ed336e336f2df9faa657911a96→ candidate4f14b0ef2c4a851f0c9b73f1c226f39d9f4fb9ca. The latter contains final authored changes before conflict-only integration. Unchanged shared harness; Node26.11.1 / SQLite3.53.4; both full QA runtime builds passed.The initial C1b→C2 comparison was invalid for gating: warmed duration ratio4.39 (baseline64.6s total, candidate333.2s) on sharply different host load. The replacement baseline C1c failed before turns with the existing15s connect handshake timeout (
auth_validatedprofile acquisition); no timeout changed. The completed replacement pair C1d→C2b is below. Both workloads passed13 turns, awaited child, control-plane list/history, cron, compaction and graceful shutdown.Whole-workload statements fall419 (4.1%) and requests fall149 (6.9%); warmed means fall11.7 statements and3.7 requests per turn. First-turn SQL rises22 while first-turn requests fall34; the full workload and touched operation totals below distinguish redistribution from added ordinary work. Boot and shutdown counts both fall despite slower phase timing; warmed/first-turn comparison ratios are0.70/0.50.
session.entry.readsession-entrysession.entry.patch.preparesession.entry.patch.commitsession-store-projectiontranscript-statshistory-pagesessionRows.sharedFactsdatabase.domain.publishdatabase.prepareWriteWarmed MAIN is the same2 secret-store list SELECTs in each run (outside this lane), shifting from turn7 to turn2. Exact native/request stacks are in
pr2-attribution.json. Full phase/operation results are inlocal-pair/live-summary.json; failed baseline startup and invalid initial comparison are retained as limitations, not counted as passing proof.Final integration repair: main independently introduced the same callback fields, so the automatic merge duplicated declarations and final callback invocation. The repair removes those duplicates, keeps the existing final transaction cancellation check, and restores the busy-timeout test helper import. No assertions were relaxed. That repaired head passed the static CI checks recorded below; that main integration is
87939000e48a31ffe0bb0f37d8e837410222ed45.Assigned-file T1 accounting: original base 43 → preceding read PR 42 → this PR 39. This slice retires the worktree-owner host primitive (worker-only classification), one canonical-key primitive (remaining validation is an offline exception), and the transcript write-guard host primitive. Shared transcript kernels retain deprecated synchronous SDK, native incognito, offline maintenance, or final real-effect callers; this PR does not claim their literal inventory is zero.
CI on the preceding repaired head
3b55950bdb88984a3788e5ebf734099d9f9450e4, run 38220964426: production types, all five core test-type stripes and aggregate types, core/extension lint, source contracts, Madge architecture, SDK boundaries/guardrails, and T1/dialect/worker ratchets pass. Security checks pass. All scheduled changed-test jobs pass except the documented unchanged-owner failures: incognito vanished-session error wording, Bun rewind SQL count, and the stale-version lazy-writer postimage test inherited from #169651.The build completed but its built-CLI flip smoke fails when the fixture deletes an in-flight session and
agent.waitreturnsAbortErrorwithout a stop reason. Recent main run38220958692, head5a1f8c692e9474323c8cbbf6c4d985ed2a1b6f0b, build job114717130399, fails with the exact same result. It is inherited; no passing smoke result is claimed. The separate live SQL workloads completed all flows.Local verification under RELAXED TESTING v6: changed-file oxfmt, basic oxlint, and
git diff --checkpass; broad suites were delegated to CI. The later focused failure-attribution runs and their wall times are recorded below. No update/Doctor/migration/plugin-loader/service-lifecycle change is included. The landing uses the explicitly authorized head-pinned REST squash route after native provisioning delay, with inherited CI failures named above.Final main integration
87939000e48a3preserves main’s retirement of the inactive standalone Memory backend (including its obsolete corpus test). Knip diagnosis: the reviewed head’s production scan reported only three untouched-owner exports (PreparedCronRunReceiptClaim,ComposerRunStatusContent,ChatPaneVersionsMenu); main commitf0a14bf986e60removed all three exports, and this integration includes that exact fix. Script export scans pass with zero entries on both revisions. Full-tree scans hit the same existing 600-second limit on the reviewed head and recent main5a1f8c692e94; no timeout or baseline was raised. Prior summaries calling Knip green should be read as this explicit inherited-failure disposition.Prior integration head:
155ca35fdf55c92d95f7f65c4a18b4aa8b8f82de, including main97775a426a352f307838e4095fa934b445d853b9. Main independently fixed the optional fixture read; the resolution keeps its stronger pre-commitinitiallabel assertion and this PR’s legacy callback coverage. The preceding head’s two test-type errors are corrected; production behavior did not change. Ordinary CI is recorded at 38229370938. The intermediate manual CI dispatch did not run proof: it refused a stale GitHub merge ref before this conflict resolution.The
sessions-read-cache.test.tspreview assertion failure is independently reproduced on main802f3415be1f0fb5c88d8063a61ea19f8f95daa4and candidate016106aeb7d2fa1d419e1a9a81b4ae30552c2208withpnpm test src/gateway/server-methods/sessions-read-cache.test.ts -t 'refreshes row previews after a committed transcript update' --maxWorkers=1. Both returnundefinedinstead ofFresh committed previewat line 430. Command wall times: main 1,083.65 seconds, candidate 1,051.70 seconds (Vitest 989.26/963.09 seconds), mostly worker transformation; these were focused failure attribution, not passing proof. This unchanged-owner failure joins the independently confirmed inherited rewind SQL-count failure. No timeout, assertion, or cache behavior was changed to hide them.Prior-head static evidence, run 38229370938: production types, all five core test-type stripes and aggregate types, all core/extension lint stripes, source contracts, Madge architecture, SDK boundaries/guardrails, and T1/dialect/worker ratchets pass. Security and dependency review pass. The corrected authority-test stripe passes. Knip retains the explicit inherited full-tree timeout disposition above; no baseline or timeout was raised.
Final CI failure attribution: recent main run 38226928416 independently reproduces the preview failure (job 114736776831), readonly-summary pending-row omission (job 114736776521), and incognito error-wording mismatch (job 114736776952). The background-tool capture-count fixture and two cron revoked-read/captured-alias fixtures belong to untouched owners; no exact main reproduction is claimed for those. Both cron fixtures request the unchanged
fullread path; this PR’s exact-read change removes only the obsolete worktree projection. Their theoretical in-flight close/alias expectations do not demonstrate a regression introduced here. They remain follow-ups; no compensating checks, assertion changes, or retries were added. Landing uses the authorized inherited-failure exception with the exact head pinned.Current integration head:
1b08b81a7a8614f101e6e7f47def1e635efdf96f, including mainb4063f202d3331d9825ba1a61cc446ecf17dca64. The sole conflict combines both documented SDK migration allowances: this PR’s async transcript statistics/prepared run start and main’s retained shippedcreateSessionHeaderLink. Public export/function/deprecation accounting is the exact composition of those named contracts. Session implementation merged automatically; local format, lint, and diff checks pass. Current-head static/security CI qualification passed in run 38232380143: all production/test type stripes, core/extension lint stripes, source contracts, Madge/architecture, SDK boundaries/guardrails, and T1/dialect/worker ratchets passed. Security-sensitive and dependency reviews passed. Knip retains the documented inherited full-tree timeout disposition. The prior exact-head REST merge returned HTTP 405 because the base moved; it did not merge the PR.Landed by an exact-head REST squash as
1ebb24d4fbd5f954c9cc5e07f5c009ab9abaea03. The head precondition was1b08b81a7a8614f101e6e7f47def1e635efdf96f; the final fresh check showed OPEN/MERGEABLE and all static/security checks passed. The authorized inherited-failure route did not wait for optional dynamic jobs.