Repository navigation
refactor(sessions): move status and typed creation reads into workers - #169608
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs changes before merge. What this changesThis PR moves status reads and typed session-creation work into existing workers and removes redundant mutation reads. Example: Status is requested after transcript usage increases from 1,000 to 2,000 tokens.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it advances the approved session-worker migration without a verified introduced defect, but GitHub reports a conflict and several CI failures remain unattributed. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherSession operations send reads to the history worker and mutations to the agent executor, which return prepared facts and committed publications for status rendering and native participant settlement. flowchart TD
A[Session operations] --> B[History worker]
A --> C[Agent executor]
B --> D[Agent SQLite]
C --> D
C --> E[Native binding settlement]
E --> F[Shared SQLite]
B --> G[Status presentation]
C --> G
Technical reviewBest possible solution: Complete the existing worker cutover while preserving status output, final transaction checks, and native settlement ordering. Do we have a high-confidence way to reproduce the issue? Fetched-main source confirms synchronous status reads and the native-participant creation exclusion; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? Reusing the existing readers, executor, and settlement owner is appropriate, and the removed reads retain transaction-local validation or committed receipts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ccb7b5f7e5de. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +85, Tests +429, Docs +8, Other +16. Total +538 across 46 files. Added test files: 3. View PR surface stats
Review metrics
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 (7 earlier review cycles)
Reviewed October 12, 2026, 4:24 AM ET / 08:24 UTC (Revision 8). |
…openclaw#169608) Prepare status and model facts through the history worker and route typed creation participants through the existing writer transaction. Remove redundant rewrite and compaction reads, fold ACP provenance retention into upsert, and use DELETE RETURNING for conversation demotion. Retain named SDK/native, incognito, offline repair, and effect-boundary contracts. SQL measurement and inherited CI evidence are recorded in the PR.
What Problem This Solves
Status/model-directive presentation and typed session creation still reached synchronous transcript/native paths. Session mutations also repeated reads already covered by their loaded state or successful write receipts.
User Impact
No intended visible behavior change. Status retains fresh usage/model facts, and typed native deletion participants retain transaction and post-commit settlement. No schema, permission, retention, plugin-loading, service-lifecycle, or update contract changes.
Why This Change Was Made
Prepare status facts through the existing history worker and render them without database access. Reuse the existing native-binding worker transaction for typed creation participants. Remove duplicate rewrite/compaction reads, fold ACP provenance retention into the node upsert, and use DELETE RETURNING for stale primary-conversation demotion.
This is the first focused PR in the owner/API cutover. Conservative T1 callsites in the 17 assigned files fall 46 → 43 against original inventory metadata (44 → 43 when applying today's ACP Doctor-only classification to both revisions). Mixed native/worker kernels are still reported honestly; remaining ordinary currentness, leaf/completion and Memory-corpus callers are being cut over separately. Deprecated SDK/native, incognito, offline repair and actual effect guards are not relabeled worker-only here.
Removed checks and accepted edges
Statements and requests
Shared harness on one Hetzner host, alternating M,C,M,C,M,C. Immutable base
c0e0bbaf21e7e4fd559cae660a4be92bfcbdbfee; measured implementation6ccf82c4af4cfc680807d8d7b732b4df34166543. Later changes split tests, remove a test for a deliberately deleted intermediate check, and extract unchanged provenance preparation. The shared harness is unchanged; a task-local census observer counts logical sends, excluding continuation/reply frames.Warmed duration ratio 1.012. Warm delta is +0.12% statements/+0.10% requests. Added warm executions are existing session-row/transcript-watermark and background Memory admission/index work; no new ordinary-turn command was introduced. The first-turn median shifted +56 statements as background work moved from connection into the turn. Per RAW TURN INCREASE, an extra M,C pair measured 9,636 → 9,605 statements and 1,910 → 1,906 requests over startup→shutdown, establishing redistribution rather than a workload increase. That pair's first turn was 1,114 → 1,136 statements and 225 → 214 requests.
Per-operation deltas: fully loaded ACP identity changes remove one provenance SELECT and UPDATE; partial legacy snapshots retain one SELECT. Conversation demotion removes one SELECT. Rewrite removes its preliminary version read and per-source event rereads; its host preparation drops one maintenance request. Compaction removes the next-sequence read, appended-row scan and final version read. Harness request medians remain 6→6
session.entries.replace, 15→15 each rewrite prepare/commit, and 4→4 maintenance reads; the particular rewrite/compaction helpers are not all exercised by this workload, so no warmed saving is claimed for them. Status moves reads to the worker and adds one coldsession-entry-readrequest across the workload (18→19).Evidence
Earlier CI exposed fixture/type/lint issues that are fixed. The isolated CLI
sessions --jsoncompleted successfully with an empty session list. Workshop learning has the identical missing-announcement failure on main run 38205338506/job 114669571918. Incognito and label-lookup fixtures now persist their configuration through the owner, retaining their behavior assertions.Final PR delta against integrated main: production +363/−262 across 26 files, tests +1085/−662 across 17 files, docs +31/−24 across 2 files. No warmed-query reduction is claimed; this moves cold reads off MAIN and removes redundant mutation reads.
Final integration and CI attribution
The latest integration includes main
a27b46c127eb4. Its only conflict was the deletion-proof helper: main independently landed the equivalent terminal-abort handling, and main's version is retained. No production SQL changed in this resolution. CI on1ecfd72f89120passed production/test types, all lint stripes, source contracts, architecture and database ratchets, plus the built-artifact lifecycle proof.The actor stale-version failure traced to main
670306081a73d(#169651): prepared appends intentionally stopped reading/retrying snapshots, while an old fixture still injected a stale expectation and expected replay. The integrated main already corrects the fixture to expect one refusal. A focused base/head diagnostic stalled before test cases and was canceled; it is not reported as passing or reproduced-inherited evidence. The separate Bun rewind diagnostic also stalled in worker compilation before assertions; no result is claimed. The data-version suite passed its behavior assertions and failed during native retirement cleanup. Those cleanup files are unchanged by this PR. The type-suppression inventory failure identifies an unchanged main-tooling Bun annotation. Workshop's missing learning announcement is independently reproduced in main CI as recorded above. Final integration includes main2fc20b367b69d; exact-head PR CI is run38226567508at72514211565e1. The inventory resolution preserves both ACP Doctor-only metadata and main’s config-health worker classification. It regenerates the inventory without changing runtime SQL. Final static results are recorded below as they complete.Source attribution for the Bun rewind count assertion:
9c54108→1ecfd72leaves the fork handler, message-cut operation, upstream reader, and its connection/revision cache unchanged. Durable fork omits native deletion capture and sends nonativeBindings, so the new typed replacement participant does not run there. Its two pre-existing upstream callbacks can each execute a SELECT when connection/read-revision reuse is unavailable. No PR-added callback or invalidation was found; this is source attribution, not a claim of reproduced inherited failure.Fresh main-tier CI at
2e631903584bd(run38223693899) passed types, lint, source contracts, architecture/Madge, and ratchets. Knip found the unused exportretainLegacyAcpMigrationSourcesJson;992add916eb8bmakes that same-module helper private. Three other UI/cron findings are removed by mainf0a14bf986e60, included in the subsequent main integration. The remaining manual jobs were canceled after the required static evidence was collected; their tests are not claimed as passing. A current-main Knip baseline (run38224696307) records unrelated unusedgateway-prewarm.mjsandrenderPublicSessionCardSvg.Final stack live check (v6)
One additional baseline/candidate live pair exercises the complete three-PR stack: baseline
9c54108f9f20a, candidate22bf8aa966027. This supplements, rather than replaces, the valid PR-local alternating proof above. Per warmed turn (total divided by ten): statements 306.7 → 381.9, requests 84.0 → 106.7, MAIN 0 → 0.2. Whole workload: statements 9,283 → 10,211, requests 1,668 → 2,016, MAIN 1,984 → 1,982. Candidate warmed elapsed time was 114.3s versus 18.8s baseline, so the raw pair is severely duration-skewed.The transcript hydration, anchor, row-facts, patch preparation/commit, activity-summary and actor operations retain their statement/request counts; row backfill falls 100/20 → 95/19. Twelve additional periodic Memory refresh cycles account for twelve each of entry, corpus, tombstone and transcript requests. The two warmed MAIN statements are untouched scheduled GitHub OAuth maintenance, not this lane. Lifecycle has one extra 13-statement generation-tracker setup batch with unchanged request count. Five ordered-cache misses, one entry-admission read and exact-entry request differences remain incompletely attributed; this pair is not claimed as a clean no-increase proof.
All 13 turns, cron, compaction, child terminal and shutdown completed.
mentions.dismissreturned retryableUNAVAILABLE, so the outer all-RPC assertion failed (40/41 RPCs passed); no SQL execution failed in that phase and the generic owner catch hides the underlying exception. The run is qualified live evidence, not a fully passing end-to-end run.Exact-head Knip (
72514211565e1, run38226745674, job114736339119) reports only unusedgateway-prewarm.mjsandrenderPublicSessionCardSvginsrc/gateway/control-ui-public-session-card-render.ts. The same rules/files fail on current main run38224696307; both are untouched by this PR. This is an inherited static exception, not a waived new finding.The main-tier core-test-types-4 failure is also exactly inherited:
session-entry-patch.authority.test.ts:41:22,56:12reports TS2532 on both candidate job114736339016and main run38224696307/job114729780171atb82b033920ee7. The fixture’s optional return and affected contracts are unchanged. The incognito “vanished non-default agent” mismatch is the same failure as main run38209130771, job114679390704: expected the not-found error, receivedUnknown agent id "work".Landing evidence at
72514211565e1Exact PR run
38226567508: every production/test type lane and all basic/type-aware lint stripes passed; source contracts passed; architecture reports zero runtime and Madge cycles; fast database-worker/T1 and dialect ratchets passed. Main-tier run38226745674collected the broader static scans: the only static failures are the exact main-matching Knip and TS2532 findings above. Its remaining broad jobs were canceled after static evidence was complete, so their tests are not claimed as passing.Remaining test failures are disposed under the authorized inherited-failure route. Besides the exact main incognito failure, the detached-context variants pin an admission reread intentionally removed on main by
5aa61b5216632(#169523); their older passing main run predates that change. The fork upstream-read count has an unchanged two-callback call chain and no new lane guard/invalidation. Raw-edited listing/projection fixtures and their complete read paths match integrated main; maina9b40cf325e8d(#169340) removed repeat canonical validation for admitted stores. The asynchronous resident preview failure is outside this lane's active path: resident materialization setsskipTranscriptUsageFallback: true, already supplies prepared terminal facts, and the title/preview worker, projector, test and transcript-only append path are unchanged. No standalone current-main execution is claimed for these source-attributed cases. Owner follow-ups should retire the two obsolete detached-check variants and investigate the remaining cache/count/fixture assertions; no retry, guard, timeout, baseline increase or weakened assertion was added here.Landing uses the coordinator-authorized head-pinned REST squash because native provisioning requires the off-limits canonical checkout. No schema/update/Doctor/plugin-loading/service-lifecycle change is made, so the published-driver update cell is not applicable.
Final CI run
38226567508is terminal. Its last completed failure is the same raw-cursorgeneration_mismatchassertion as main run38205338506/job114669571918; the test is unchanged by this PR. No new failure class appeared after merge. The verified squash commit isf61bbd1668c5a67cabc38aedd1f920d6e439f99d, authored by Peter Steinberger.