Skip to content

perf(sessions): serve per-turn session projections and entry reads from workers - #164779

Merged
steipete merged 14 commits into
mainfrom
dbasync/sessproj
Oct 4, 2026
Merged

steipete merged 14 commits into
mainfrom
dbasync/sessproj

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Warmed chat turns repeatedly read session participant, owner, provenance, and entry data on the Gateway thread. The same SQLite kernels also serve native authority checks, writer operations, and public synchronous contracts, so moving their async runtime callers needs to preserve those boundaries.

Why This Change Was Made

Use the existing session readers for model selection, harness admission, skill refresh, dispatch, empty injection probes, local-turn placement preparation, completion metadata, diff-baseline selection, and Gateway finalization/publication preparation. Carry prepared sandbox facts through workspace preparation. Exact candidate reads validate only selected rows; default stores remain single-store and explicit agent templates retain configured/discovered selection.

Each new await retains physical-store custody and the applicable caller checks. Local placement rechecks authority before claiming a turn. Source callbacks that can read their own agent store stay outside worker grants. Model-read failures share existing run-context cleanup. Canonical-key migration errors retain their class identity through a leaf module and the existing worker codec; the compiled-wrapper inventory includes that leaf.

#164514 owns the writer-claim and live-model writer cutover; this delta keeps it and awaits admission reads. writeSessionEntry and its write sites remain excluded for #163592. The ensureSkillSnapshot row refresh here is distinct from #164648's approval/defaults preparation. #158903 adds a separate admission helper in the placement file; these hunks only change executeLocalTurn. #162433 remains the coordinated incidental overlap. No global worker-patch enablement or opaque callback contract change.

User Impact

On measured head 04818d014e0f358f6a218bd6e3d77992aad9bf0d versus pinned main 50b45abb1d479f98e2120423a328ee0390930f19, warmed turns average 505.7 → 458.0 main-thread statements (−9.4%). The six selected read sites fall 158 → 134 per turn (−15.2%); the full workload falls 12,660 → 11,940. This is an incremental read-side cutover: live guards, synchronous callbacks, and excluded writer work remain below. The owner-projection site is already zero on this main baseline, so this PR claims no additional reduction there.

Production scope: 33 files, +425 / −184 / net +241 (609 changed lines), excluding tests, documentation, and tooling. Static T1: 915 → 915; shared native kernels are not relabeled worker-only. All-tier static calls are 2,540 → 2,541, with the additional call in the existing worker.

No new worker service, cache, schema, retention, durability, permission, or environment-variable name. Process-held incognito keeps its existing reader. Prepared metadata does not grant authority; live delivery, sharing, publication, and claim guards retain their owners.

Landing integration

Landing candidate: 7eb1f0d6233df42e9ad5d4512dc46ef89622eba6. Initial fixture repair: f58c076f400661ea483c5d49ee7306f89b20787a; exact mock-baseline shrink: 920f2cfcb8b948; latest main merge: 7cfd2c302ca521eab39e12adafbe5405a2753dcd; dashboard publication fixture repair: 7eb1f0d6233df42e9ad5d4512dc46ef89622eba6.

Integrated main through 5f5125bcb6a975351b6e2369e56397265582cece, including the admitted-schema work and the upstream ACPX fixture repair. All integrations use merge commits. The overlap with #164753 was the shared error registry: its model-lock error and this PR's canonical-session-key error both remain registered, with both leaf modules in the wrapper inventory. The full PR patch was identical across the latest main integration before the three-line dashboard fixture repair.

Landing repairs give broker-dependent tests a single owner, keep plugin-contract discovery complete and disjoint, align synthetic session fixtures with the async readers, await database retirement before fixture reset/snapshots, and synchronize cancellation with actual provider entry and the terminal-failure callback. The dashboard durability probe now joins the saved row's publication before deliberately closing storage, preserving its observer and every existing assertion. These are test/tooling repairs, with no additional production behavior changes.

Released SDK audit: the five changed sync-to-async helpers are internal and absent from the released SDK barrels, runtime API, and documented subpaths at v2026.9.8. Public getSessionEntry remains synchronous; the extracted error class preserves its original re-export and identity. The completed SDK reports below remain applicable to the test-only landing repairs. No stored-format or schema change is introduced, and the preserved published-driver update cell supplies upgrade evidence.

Integrated proof: the 32 reader/authority cases passed again after the schema-admission integration (813.50 seconds command wall time), covering foreign commits on the next unpinned read, incognito exclusion, alias custody, cancellation, and Gateway authority. The earlier registry-conflict composition passed 78 runtime-process/wrapper/import/error tests (561.99 seconds). All 1,140 tests in the 15-file isolated repair campaign and focused script lint passed. The additional dashboard file passed all 34 cases (683.74 seconds). Fresh P2 reviews of the integrated delta and dashboard fixture change found no actionable findings. The original 130-run comparison is complete: all 65 original-head runs failed with the observed signatures, and all 65 baseline runs passed (five separate full-file runs per revision for each of 13 files). Valid prior runs were reused. Nine original-head results survive as validated streamed summaries/receipts rather than raw logs after a native staging disk incident; all 65 baseline raw logs are retained.

CI run 37186070579 tested 8fa787c0941b15bd21fa0ca8134963975d1e0f6c: 149 successful jobs, 14 skipped, three failed test jobs, and the downstream aggregate failure. The three roots are being handled explicitly:

  • ACPX's raw/canonical session-key expectation reproduced in all five head and five baseline runs. Its production inputs were unchanged; upstream d2a9f9a114c2e2570ed861a5ab0273291d56a793 repairs the fixture and is included in this integration. That commit records focused ACPX/ACP proof. The first Mac reproduction also had a cold timeout and a subsequent configuration-source failure, recorded separately; the eight Linux repetitions had only the canonical-key mismatch.
  • The dashboard-defaults reader revocation did not reproduce in five unchanged head runs or the bounded 113-test file-group replay. The observed native replay order differed from CI's unknown four-fork assignment. Source inspection identified the test's close/publication overlap; the existing publication drain now settles it before the durability close. All five unchanged baseline runs also passed. Passing replays are not claimed as a reproduction or explanation of the exact CI timing.
  • The hard-kill recovery timeout passed all five original-head and five original-baseline runs and the two-CPU head probe, but reproduced with the exact 120-second line-123 timeout on public main 5f5125bcb6a975351b6e2369e56397265582cece under two-CPU affinity. The failed state shows startup recovery finishing before deferred admission: the orphan remains running and the original inbound replay is skipped as duplicate. The independently inspected recovery/admission/test inputs are unchanged by this PR. This is inherited main behavior; passing older standalone revisions did not cover the newer main admission ordering used by CI. No CI rerun has been used.

Current-head CI run 37189194601, attempt 1, completed at 7eb1f0d6233df42e9ad5d4512dc46ef89622eba6: 148 successful jobs, 14 skipped, three failed Node jobs and their downstream aggregate. No CI reruns were used. The actual checkout was 501bd986ef98162cdb9b9adc0cdd1a2d814c51e7, with ordered parents main 9c66d4c9a39b16d70e7c55186fe7e8550468a663 and this head. It preserves newer main changes and contains only this PR's 69-path introduced delta.

The explicitly authorized native inherited-failure exception is qualified for these roots; this is not a claim that CI passed:

  • Memory origins and recovery and memory worker settlement: all 30 separate full-file comparison runs completed (three files × five runs × two revisions). Both this head and PR-free main 5f5125bcb6a975351b6e2369e56397265582cece reproduce the same 11 failing cases: origins 1 failed/10 passed, forget recovery 8 failed, and settlement 2 failed/2 passed. The worker reuses admitted schema facts after another connection drops optional tables, so schema restoration is skipped before the intended recovery/lost-result checks. All 21 causal source blobs/trees are identical across reproduction main, CI baseline, PR head and tested merge. This failure follows main's schema-facts change in c828f7ed1d560295f78166a98fb54687dc162b28; it is not repaired here.
  • Hard-kill recovery: independently reproduced on PR-free main as described above. All ten causal recovery/admission/test blobs match reproduction main, CI baseline and tested merge. The failed predicate stops before transcript metadata reads because no recovery-dispatch log exists; raw SQLite confirms an actual unmarked orphan, so this is not a stale projection assertion. The missing deferred-admission recovery handoff remains main-owned debt.

The downstream CI gate reports those three roots; no job was cancelled. security-fast succeeded, and the exact-head Security Review publisher completed successfully. ClawSweeper completed its latest trusted review at 2026-10-04T09:23:29.652Z with no actionable code/security findings. Its generic compatibility checkbox is satisfied by the unchanged stored-data contract, released SDK report, and successful published-driver update cell already recorded below. Native admission still revalidates current security, review and head authority.

The initial CI's independently inherited Windows import and two UI failures were fixed in incorporated main (3c0f7e4c5cdade, 65829ead96bb115b69782e6357e8b619b3add8bf, and 42b9aee33a7b03442f4c5ce3f088fd5e7dcefaf0). All performance figures below remain tied to their original measured commits; they are not measurements of this newer integration.

Landing repair proof and observed test cost

Isolated source: original head 04818d014e0f358f6a218bd6e3d77992aad9bf0d plus the reviewed 15-file repair patch 45b1f0cd540f25086564e6c13d7779c8d9400b907e987d5d9c1c2ca9f2f7d3b1. Each file ran singly through node scripts/run-vitest.mjs <file> --maxWorkers=1, the repository test runner. These are observed isolated runner seconds, not projected GitHub CI seconds.

File Tests passed Command wall time
src/agents/embedded-agent-runner/run-orchestrator.suspension.test.ts 33 113 s
src/gateway/server-methods/system-agent-nested-inference.integration.test.ts 2 34 s
src/agents/embedded-agent-runner/run.cli-dispatch-lane.test.ts 1 18 s
src/agents/embedded-agent-runner.run-embedded-agent.finalization-scope.test.ts 3 21 s
src/skills/runtime/session-snapshot.integration.test.ts 33 18 s
src/gateway/server-methods/sessions-diff.test.ts 47 22 s
src/auto-reply/reply/agent-runner-execution-provider-failures.test.ts 84 66 s
src/gateway/worker-environments/worker-github-binding.test.ts 16 17 s
src/gateway/github-publication-boundaries.test.ts 36 44 s
src/gateway/github-publication.test.ts 21 26 s
src/gateway/github-personal-publication.test.ts 50 87 s
src/gateway/github-publication-admission.test.ts 24 16 s
test/scripts/test-projects.test.ts 293 53 s
test/scripts/plugin-contract-test-plan.test.ts 5 3 s
test/vitest-projects-config.test.ts 492 60 s

The local personal-publication run had six fixture Git setup failures before application entry (five git init, one initial commit). The original helper discarded termination details, so the cause remains uncertain; a diagnostic replay passing is not evidence of a fix. The independent isolated full suite passed 50/50. Local script lint could not complete declaration preparation within its setup deadline; the independent isolated lint completed successfully.

Landed composition

Native admin squash landed as e95e11c679301368a2f30f09e13647597c65f730 on 2026-10-04T09:41:15Z, with direct parent bb9f63c75069bc2522f09b441d5ec93524ab6efe (#164648). Exec preparation landed during final admission; native reconciliation verified the exact prepared source and reconstructed landed tree against that main parent. Main's exec-defaults.ts is unchanged by this squash. ensureSkillSnapshot retains main's async exec-preparation flow, with only this PR's intended worker-backed final row refresh and imports differing.

Focused proof on that exact landed tree passed 16 cases: both complete session-update/exec-preparation files (9 passed, 185.667 seconds) and foreign-commit freshness plus the six incognito-owner cases (7 passed, 31 unrelated cases intentionally filtered, 68.207 seconds). Total wrapper wall time was 253.874 seconds. Source and dependency hashes stayed unchanged. This supplements the reviewed-head proof; it is not a new full-CI success claim.

Evidence

Main baseline pinned for the original integration/validation: 50b45abb1d479f98e2120423a328ee0390930f19. Measured candidate: 04818d014e0f358f6a218bd6e3d77992aad9bf0d. Same supplied synthetic local-provider harness and native statement observer, fresh isolated state, real Gateway/storage/workers, source maps, and Node v26.10.0. Statement counts exclude prepare calls and include maintenance settling during each phase. These instrumented runs are not latency benchmarks.

Phase Read sites before Read sites after Overall main before Overall main after
Boot 0 0 2,973 2,969
Connection / settling 0 0 46 47
First turn 167 143 1,767 1,721
Ten warmed turns 1,580 1,340 5,057 4,580
Second session + child 444 378 1,550 1,394
List / history / Inbox 0 0 0 0
Cron 89 75 592 552
Compaction 16 16 208 210
Shutdown 0 0 467 467
Warmed turn Read sites before Read sites after Overall main before Overall main after
1 158 134 506 550
2 158 134 596 437
3 158 134 496 441
4 158 134 495 437
5 158 134 493 437
6 158 134 493 446
7 158 134 495 517
8 158 134 497 439
9 158 134 493 437
10 158 134 493 439
Selected read site Statements / warmed turn before After
session-accessor.sqlite-participant-projection.ts:56 76.0 64.0
session-accessor.sqlite-owner-projection.ts:83 0.0 0.0
session-accessor.sqlite-provenance.ts:39 3.0 3.0
session-accessor.sqlite-entry-read.ts:320 26.0 16.0
session-accessor.sqlite-entry-read.ts:123 45.0 43.0
session-accessor.sqlite-entry-read.ts:357 8.0 8.0

Both runs passed all 13 top-level turns, child execution, cron, compaction, and clean shutdown ([0, null]). Counts retain all maintenance/settling samples; they are not latency measurements. Before: one busy host BEGIN during connection and three busy worker BEGINs at shutdown. After: two busy host BEGINs during connection and no worker SQL errors. Neither run had warmed-turn SQL errors, and all workload outcome assertions passed.

Check Result Wall time
Final local source-mapped measurement build Passed on final head 1,158.15 s
Full pnpm build Passed 545.03 s
Placement launcher suite 33 tests passed 113.94 s
Reader/authority/cleanup contract group 249 tests in 11 files passed 151.26 s
Remaining caller suites, including real server close order 322 tests in 12 files passed 322.39 s
Shared-registry/runtime-process/wrapper/import closures 22 tests in six files passed 43.30 s
Madge Zero cycles 30.92 s
Database worker ratchet against pinned main No T1 call-count growth 3.11 s
SDK comparisons, local with physical TMPDIR Main comparison: 131 reachable changes, no direct signatures or entrypoint changes; released comparison completed 2,849.14 s main; 2,343.25 s released
Published driver 2026.9.8 × candidate Passed; update finished, readiness HTTP 200, running version verified 443.67 s
Final memory-flush suite (c5a8b6a41322) 58 tests passed 128.88 s
Final identity + dispatch-metadata suites 16 tests passed 51.69 s
node scripts/check-changed.mjs Passed on final head; import-cycle guard zero 1,221.47 s

Focused commands use pnpm test <files> --maxWorkers=1; times are observed command wall times, not projected GitHub CI duration. The new placement regressions failed on the native read (host SQL and missed read-boundary revocation), then passed after the repair. Coverage includes foreign commits on the next unpinned read, pinned-reader behavior, incognito exclusion, candidate-store selection, unrelated-row isolation, error-class identity, cancellation, and accepted settlement before worker close. Final Codex review through P2 completed with no accepted findings; the subsequent fixture and lint repairs each received scoped-clean P2 follow-ups. One reported error-handling finding was rejected: both migrated exact-read callers already return no candidates for missing database/schema, while corruption and query errors throw. The new exact projection preserves that native contract (session-accessor.sqlite-exact-read.ts:363–364); existing list/full inventory readers retain their stricter handling.

Full build, the 626 focused/import tests, cycles, ratchet, package/update proof, and SDK comparisons used 5768b0871b86. Subsequent changes only rename an unexported binding, replace a two-field spread with explicit fields, and repair test fixtures. Public declarations, imports, and transport behavior are unchanged. The memory-flush suite covers the binding correction; final-head identity/dispatch tests, changed checks, and measurement cover the remaining edits. Earlier changed-check failures (one line of file growth, obsolete fixture fields, and two lint errors) were corrected and rerun. Final lint retains four existing max-lines warnings with zero errors.

SDK diff digests: main a097de53, released 9e9163f6. The released 2026.9.8 comparison includes all intervening main changes: one added/eight removed entrypoints, 60 added/1,007 removed exports, 73 signature changes and 1,175 reachable changes. The main comparison isolates this lane and has only reachable changes. Both use the fixed SDK diff tool locally with a physical TMPDIR; no renderer guard was bypassed.

The update cell applies because the shared worker error-identity codec changes. Heavy proof used the authorized AWS Crabbox fallback after Testbox source packaging stalled; SDK comparisons run locally as requested. The full build emitted its non-gating startup gzip advisory and exited successfully.

The measured 04818 every-phase trace reconciles 260 distinct selected-site stacks; 122 warmed caller chains total 134 selected statements per turn. Every phase matches the analyzer totals. The migrated executeLocalTurn read is absent from all selected-site stacks. Roots remaining in that measured revision are categorized below; these are explicit migration debts or excluded responsibilities, not a claim that all retained reads are authorization checks.

Native caller contracts and migration debt in the measured 04818 workload
Final statements/turn Owner / source reference Responsibility and remaining cutover boundary
66 src/gateway/session-sharing-policy.ts:101; src/gateway/server-methods/session-mutation-guards.ts:358 and line 366; src/gateway/server-methods/request-authorization.ts:161 Live authorization. Current sharing, requester policy and admitted-input custody are rechecked. Prepared descriptive entries cannot replace revocation checks. Some checks run in worker grants; exact debt is identified below.
9 src/auto-reply/reply/session.ts:310, line 546 and line 957 Initialization/writer coupling. Snapshot and commit reads belong to the existing session initialization lane and opaque hook/update contract. Migrate the compound owner rather than independently awaiting transaction callbacks.
7 src/config/sessions/session-accessor.sqlite-projection-state.ts:123 and line 143; src/config/sessions/session-accessor.sqlite-entry-mutation.ts:69; src/config/sessions/session-accessor.sqlite-provenance.ts:39 Writer coupling. Transaction-local expected-row comparison, lifecycle projection and writeSessionEntry provenance. Entry-store writes remain excluded from this lane; preserve the writer's atomic operation.
8 src/gateway/session-lifecycle-state.ts:361 and line 397 Lifecycle persistence. Initial entry selection and the native updater are coupled to terminal ownership, provider-review state and settlement. This is writer-owner migration debt, not a standalone descriptive lookup.
8 src/agents/embedded-agent-runner/run/pre-persisted-user-turn.ts:82 Live replay authority. Initial and final replay checks validate current session identity, lifecycle and writer fence alongside transcript context. A stale prepared row cannot authorize replay.
4 src/agents/exec-defaults.ts:151; src/auto-reply/reply/session-updates.ts:147; src/agents/tools/openclaw-delegate-tool.ts:63 Capability preparation. Skill eligibility and synchronous tool construction still request sandbox metadata. Related async preparation is owned by #164648. The public synchronous coding-tool factory is exported at src/plugin-sdk/agent-harness.ts:21; internal callers should carry prepared facts without changing that SDK contract.
6 src/auto-reply/reply/reply-tool-authority.ts:186, line 305 and line 417 Live capability authority. Steering and tool-route fingerprints reuse a synchronous authority interface. Moving these reads requires preserving route rebinding and revocation semantics, not caching one initial fingerprint.
4 src/gateway/server-chat.ts:348, called at line 1285 Synchronous event-processing debt. Restart-recovery suppression reads metadata while handling ordered lifecycle events. src/gateway/AGENTS.md:80 requires ingestion to capture content without awaiting row enrichment; the repair must supply prepared event facts or migrate the ordering owner.
4 src/gateway/session-observer-model.ts:303 and line 387; src/gateway/session-observer.ts:532 and line 180 Observer/lifecycle debt. Descriptive observer admission and terminal synthesis share a synchronous reader with lifecycle validation and final publication. This is not wholly authorization work; migrate the shared observer contract coherently.
2 src/gateway/server-methods/chat-send-session.ts:126 Descriptive admission-preparation debt. Initial chat preparation selects aliases and captures physical-source facts used by qualifyChatSendSession at line 253. Its synchronous API needs a coordinated asynchronous preparation cutover.
2 src/gateway/server-methods/chat-send-session.ts:276 Admission currentness. The later reread compares routing and captured physical identity before work proceeds; preserve those comparisons and the selected-store lifetime.
2 src/gateway/github-publication-availability.ts:102 and line 209 Live publication authority. Initial preparation already uses the worker at line 197. The retained synchronous closure rechecks session/repository/worktree ownership before publication effects.
2 src/trajectory/runtime-store-writer.ts:75 Recorder/writer identity debt. Synchronous sink construction validates the session-to-store mapping. The same constructor also serves worker live-event projection at src/gateway/worker-environments/live-event-projection.ts:47; migrate that ownership boundary together.
2 src/agents/session-maintenance/run.ts:191 Live admission. assertAllowed checks the generation and absence of pending final delivery inside session-work admission. This callback cannot simply become asynchronous.
6 src/gateway/server-methods/chat-send-reply-dispatch.ts:169 and line 233 Transcript custody. Synchronous start capture binds identity and watermark; later completion predicates recheck current transcript/session ownership after waits.
2 src/auto-reply/reply/dispatch-from-config.harness-defaults.ts:46 Descriptive synchronous-preference debt. The live verbosity predicate must observe preference changes on subsequent uses. dispatch-from-config.prepare-execution.ts:250 additionally captures the run's commentary classification once. Reusing the initial session entry for every predicate call would change that behavior.

Outside warmed turns, the trace also includes existing native parent-inheritance snapshots (src/gateway/agent-turn/agent-session-persist.ts:181, line 329 and src/gateway/server-methods/agent-session-patch.ts:164). Cron orphan cleanup reaches separate placement-recovery preparation at src/gateway/server-worker-placement-session-target.ts:241 and the live workspace/lifecycle binding closure at line 277. These remain with their existing writer/recovery owners; the initial qualified-target read is additional preparation debt.

Pre-existing worker-grant debt

The following chain is retained existing work; the moved-operation boundary tests do not claim zero host
SQL for all grant callbacks:

  • src/gateway/server-methods/chat-send-handler.ts:320 invokes admitted-input
    authority; line 334 forwards the same custody check during source staging.
  • src/gateway/server-methods/session-mutation-guards.ts:358 and line 366 call
    current session-sharing authorization, whose metadata reader is
    src/gateway/session-sharing-policy.ts:101.
  • Pending-input reads carry that assertion through
    src/config/sessions/session-pending-input-store.ts:194 into the admission
    callback at src/config/sessions/session-accessor.sqlite-replacement-worker.ts:138.
  • Pending-input mutation grants call their guard at
    src/config/sessions/session-pending-input-store.ts:256; commit dispatch is at
    line 301. Compound turn grants call custody currentness at
    src/config/sessions/session-turn.ts:140 and line 146, reached through
    src/config/sessions/session-entry-patch.ts:272 and line 253 respectively.

These sharing reads can concern the same agent store as the pending-input/turn
operation. They are not covered by the allowance for short indexed reads of
another owner's state. Future migration must carry typed transaction-local
session facts through the existing custody/authorization owner while keeping
the host's live authority checks. It must not add host SQL, use
maintenance-refusable same-owner reads, or relax authorization to a stale snapshot.
Boundary tests in this PR cover the operations actually moved, not these retained
callbacks.

Move model, sandbox, completion and Gateway metadata preparation off the calling thread while retaining live source authority and audited worker patch settlement. Preserve native incognito and opaque callback contracts; leave the entry-store write kernel unchanged.
Preserve exact-row validation and canonical-key error identity. Keep storage-backed source checks outside worker grants and retain acknowledged writer settlement.
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 7eb1f0d6233df42e9ad5d4512dc46ef89622eba6
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/workspace-sandbox.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 4, 2026
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 4, 2026, 5:23 AM ET / 09:23 UTC (Revision 6).

ClawSweeper review

What this changes

The branch moves per-turn session metadata reads into existing database workers and updates callers, error transport, documentation, and test routing.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful: current main retains the synchronous reads being migrated. No actionable introduced defect was found, and the recorded compatibility evidence resolves the previous upgrade checkbox.

Priority: P2
Reviewed head: 7eb1f0d6233df42e9ad5d4512dc46ef89622eba6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent worker cutover with strong production-path evidence and no remaining actionable patch findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured body’s real Gateway/storage/worker workload exercises the migrated per-turn readers and records successful turns with reduced caller-thread SQL; integrated boundary coverage checks revocation before claims and execution. The published 2026.9.8 update cell addresses the previous upgrade concern. No stored-data model changes, so migration compatibility is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured body’s real Gateway/storage/worker workload exercises the migrated per-turn readers and records successful turns with reduced caller-thread SQL; integrated boundary coverage checks revocation before claims and execution. The published 2026.9.8 update cell addresses the previous upgrade concern. No stored-data model changes, so migration compatibility is not applicable.
Evidence reviewed 11 items Pinned introduction boundary: Reviewed the introduced delta from 5f5125b to the exact checkout head. The supplied test merge has a different main parent and was not used to infer removal of current-main behavior.
Existing reader ownership retained: The new convenience reader delegates to the existing retained physical-reader operation, propagates read errors, and returns data after currentness checks. Incognito continues through its process-owned native reader.
Current main still needs this cutover: At fetched main, live model selection still calls loadSessionEntryReadOnly synchronously; local-turn admission and workspace sandbox preparation also retain the native reads changed here. Related merged writer and rewind PRs address distinct operations.
Findings None None.
Security None None.

How this fits together

Session storage supplies model choices, sandbox facts, dispatch metadata, and completion details to OpenClaw’s agent and Gateway workflows. Worker readers prepare those facts while existing execution and publication owners retain authorization.

flowchart TD
  A[Chat or agent turn] --> B[Session identity and store selection]
  B --> C[Existing database workers]
  C --> D[Prepared session metadata]
  D --> E[Current authority checks]
  E --> F[Agent execution and reply publication]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +241, Tests +640, Docs +15, Config 0, Other +1. Total +897 across 69 files.

View PR surface stats
Area Files Added Removed Net
Source 33 425 184 +241
Tests 31 826 186 +640
Docs 1 20 5 +15
Config 1 1 1 0
Generated 0 0 0 0
Other 3 5 4 +1
Total 69 1277 380 +897

Review metrics

Metric Value Why it matters
Production versus test growth production net +241 lines; tests and test support net +640 lines Production growth supports retained-reader preparation and caller cutover; test growth covers placement, currentness, and fixture integration.
Measured main-thread SQL 505.7 → 458.0 statements per warmed turn The pinned real-Gateway comparison demonstrates reduced main-thread database work without claiming latency improvement.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/state/openclaw-state-worker-error-identity.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Use the existing worker readers for descriptive preparation while preserving synchronous public contracts and live authorization at execution and publication.

Do we have a high-confidence way to reproduce the issue?

Not applicable to a functional bug report; the recorded paired Gateway workload establishes the synchronous SQL placement being improved. No repository code was executed during this review.

Is this the best way to solve the issue?

Yes. Reusing existing physical-reader and worker owners is a maintainable cutover, with public synchronous access and final-effect authority checks preserved.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d3af0db4027a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded runtime performance improvement with preserved product behavior and no demonstrated urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured body’s real Gateway/storage/worker workload exercises the migrated per-turn readers and records successful turns with reduced caller-thread SQL; integrated boundary coverage checks revocation before claims and execution. The published 2026.9.8 update cell addresses the previous upgrade concern. No stored-data model changes, so migration compatibility is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body’s real Gateway/storage/worker workload exercises the migrated per-turn readers and records successful turns with reduced caller-thread SQL; integrated boundary coverage checks revocation before claims and execution. The published 2026.9.8 update cell addresses the previous upgrade concern. No stored-data model changes, so migration compatibility is not applicable.

Evidence

What I checked:

  • Pinned introduction boundary: Reviewed the introduced delta from 5f5125b to the exact checkout head. The supplied test merge has a different main parent and was not used to infer removal of current-main behavior. (7eb1f0d6233d)
  • Existing reader ownership retained: The new convenience reader delegates to the existing retained physical-reader operation, propagates read errors, and returns data after currentness checks. Incognito continues through its process-owned native reader. (src/config/sessions/session-entry-read-runtime.ts:167, 7eb1f0d6233d)
  • Current main still needs this cutover: At fetched main, live model selection still calls loadSessionEntryReadOnly synchronously; local-turn admission and workspace sandbox preparation also retain the native reads changed here. Related merged writer and rewind PRs address distinct operations. (src/agents/live-model-switch.ts:160, d3af0db4027a)
  • Captured proof body fully recovered: Read the omitted body sections through GitHub and verified the exact captured identity: SHA-256 be6c5d974132ecce09e6406958f5732cad9116cb60e6aba628fff8ec3c0557a4, 26,879 UTF-16 units. Its real Gateway/storage/worker workload completed 13 top-level turns, child execution, cron, compaction, and clean shutdown. The measured candidate reduced warmed main-thread statements from 505.7 to 458.0; these are execution-placement measurements, not latency benchmarks. (04818d014e0f)
  • Upgrade evidence resolves prior checkbox: The captured body records a successful published 2026.9.8 driver-to-candidate update cell: update completion, HTTP 200 readiness, and verified running version in 443.67 seconds. It also records released SDK comparison digest 9e9163f6 and a lane-isolating main comparison with no direct signature or entrypoint changes. These receipts retain their original candidate identity; subsequent production edits were mechanical and later integrations received reader/authority proof. (5768b0871b86)
  • No introduced stored-data contract change: The introduced patch changes read placement and error-class transport, not session serialization, schemas, retention, or migrations. Public getSessionEntry still returns a synchronous SessionEntry projection; the SDK and plugin-runtime paths are unchanged by the delta. (src/plugin-sdk/session-store-runtime.ts:155, 7eb1f0d6233d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-04T05:16:23.879Z sha 04818d0 :: blocked before merge. :: [P2] Route the remaining worker-backed suites through the host broker | [P2] Synchronize cancellation tests with actual provider entry
  • reviewed 2026-10-04T07:16:48.850Z sha 3f6ab5c :: blocked before merge. :: none
  • reviewed 2026-10-04T07:37:09.687Z sha 8fa787c :: blocked before merge. :: none
  • reviewed 2026-10-04T07:56:21.757Z sha 8fa787c :: blocked before merge. :: none
  • reviewed 2026-10-04T08:38:11.193Z sha 7eb1f0d :: blocked before merge. :: none

Route worker-backed callers through the existing broker test lane, preserve contract command coverage, align synthetic entry readers, and await fixture shutdown. Synchronize provider cancellation on execution and terminal failure instead of a timer flush.
Integrate the mainline duration-formatter fix and preserve the session read cutover. Await database worker drainage before detached-compaction fixture snapshots, retaining row and byte-preservation assertions and surfacing run failures.
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit e95e11c into main Oct 4, 2026
243 of 248 checks passed
@steipete
steipete deleted the dbasync/sessproj branch October 4, 2026 09:41
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 4, 2026
Reply finalization moved to worker-backed session reads in #164779, while this fixture still mocked only the earlier reader. Route both readers through the existing synthetic session-selection owner, preserving current-activity checks and every transcript and media assertion.

Found during #164755 validation and independently reproduced on main. Validation: all 132 full-file cases, Gateway-method types, lint, formatting, and P2 review pass.
steipete added a commit that referenced this pull request Oct 4, 2026
The worker-backed session reader introduced in #164779 made the queue-only fixture enter durable writer admission from its threads lane. Declare its synthetic sessions detached, preserving session identities and all queue, placement, and lifecycle assertions.

Found during #164744 validation and independently reproduced on main with three capacity-wait timeouts and host-owner admission errors. Validation: queue liveness 20/20, durable writer claims 6/6, formatting, and P2 review pass. Production guards and test deadlines are unchanged.
steipete added a commit that referenced this pull request Oct 4, 2026
Route seven existing embedded-runner suites through the canonical infra
project after worker-backed admission began requiring its host owner.
Keep file isolation and every assertion; the registry also excludes these
paths from their former agent projects.

Reproduced the scheduled-main host-owner and warmup failures through the
real wrapper. The same seven files then passed all 42 cases in 86.79s.
Scoped lint, format, whitespace and independent review passed. Latest-main
changes leave these test and routing inputs unchanged.

Refs #164779 and main CI run 37200643847.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…om workers (openclaw#164779)

* perf(sessions): read per-turn metadata through existing workers

Move model, sandbox, completion and Gateway metadata preparation off the calling thread while retaining live source authority and audited worker patch settlement. Preserve native incognito and opaque callback contracts; leave the entry-store write kernel unchanged.

* fix(sessions): clear run context when model preparation fails

* perf(sessions): prepare dispatch and injection entries in workers

Preserve exact-row validation and canonical-key error identity. Keep storage-backed source checks outside worker grants and retain acknowledged writer settlement.

* refactor(sessions): keep prepared sandbox check within line budget

* test(sessions): use current agent entry config in injection fixtures

* refactor(sessions): make worker request and test await shapes explicit

* test(sessions): repair worker read fixture integration

Route worker-backed callers through the existing broker test lane, preserve contract command coverage, align synthetic entry readers, and await fixture shutdown. Synchronize provider cancellation on execution and terminal failure instead of a timer flush.

* test(sessions): prune repaired mock export baseline

* test(gateway): settle publication before durability probe
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
Reply finalization moved to worker-backed session reads in openclaw#164779, while this fixture still mocked only the earlier reader. Route both readers through the existing synthetic session-selection owner, preserving current-activity checks and every transcript and media assertion.

Found during openclaw#164755 validation and independently reproduced on main. Validation: all 132 full-file cases, Gateway-method types, lint, formatting, and P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
The worker-backed session reader introduced in openclaw#164779 made the queue-only fixture enter durable writer admission from its threads lane. Declare its synthetic sessions detached, preserving session identities and all queue, placement, and lifecycle assertions.

Found during openclaw#164744 validation and independently reproduced on main with three capacity-wait timeouts and host-owner admission errors. Validation: queue liveness 20/20, durable writer claims 6/6, formatting, and P2 review pass. Production guards and test deadlines are unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
Route seven existing embedded-runner suites through the canonical infra
project after worker-backed admission began requiring its host owner.
Keep file isolation and every assertion; the registry also excludes these
paths from their former agent projects.

Reproduced the scheduled-main host-owner and warmup failures through the
real wrapper. The same seven files then passed all 42 cases in 86.79s.
Scoped lint, format, whitespace and independent review passed. Latest-main
changes leave these test and routing inputs unchanged.

Refs openclaw#164779 and main CI run 37200643847.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant