Repository navigation
refactor(sessions): move child and metadata reads to workers - #169579
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 real behavior proof before merge. What this changesThis PR moves child-session discovery, Memory metadata reads, recap freshness reads, and raw transcript event appends into existing workers. Example: Load local history for agent:main:main with child agent:main:child.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open: current main still performs the targeted synchronous reads, the worker cutover has clear value, and the four earlier integration findings are fixed. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherGateway, embedded TUI, and Memory callers request session facts or transcript mutations; existing workers access the agent database and return metadata or committed results. flowchart TD
A[Gateway and embedded TUI] --> C[Session reader worker]
B[Memory ingestion] --> D[History worker]
C --> E[Agent SQLite database]
D --> E
F[Transcript event callers] --> G[Transcript writer]
G --> E
Technical reviewBest possible solution: Complete the worker cutover while preserving the existing Memory admission constraint until its awaited replacement safely covers supported writers. Do we have a high-confidence way to reproduce the issue? Current-main source directly establishes the synchronous SQLite paths; no runtime reproduction or tests were executed during this read-only review. Is this the best way to solve the issue? Reusing existing workers is appropriate, but returned metadata alone does not explain how the preceding implementation's admission constraint is preserved. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 866ff4d7f08e. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The Memory admission replacement has not established current exclusion authority through durable publication. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +299, Tests +298, Docs +9, Other +1. Total +607 across 67 files. Added test files: 2. View PR surface stats
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 (3 earlier review cycles)
Reviewed October 12, 2026, 2:03 AM ET / 06:03 UTC (Revision 4). |
|
The live SQL comparison and isolated workload proof are now in the PR body. All required static checks passed at the reviewed head. The Memory concern does not establish a new final-effect authorization regression: both the previous synchronous selection and this worker selection precede awaited transcript scanning ( The unchanged-owner CI failures and exact main matches are recorded in the body. Landing uses the campaign's relaxed route; no ClawSweeper re-review is requested. |
…primary-workspace Picks up main's session-backfill rework (openclaw#169579, openclaw#169405), which clears the failing changed-extensions lane. No conflicts; the fix is unchanged.
Repair the sessions-rewind failure from hourlies 38216343022 (c2fe11f, checks-node-compact-large-4) and 38220958692 (5a1f8c6, checks-node-compact-large-3, agentic-gateway-methods-hosted-5). Culprit: af0c38c (#169579), whose stated intent is: "Raw event appends use the existing event operation, including entry-less events and active-branch parent selection." The fixture's event appends now stay in workers instead of warming the host's shared-state reader. A cold fork therefore executes the existing transaction-admission and candidate-commit upstream SELECTs separately. These are authority reads, not duplicate cuts, history, or session rows. Assert both exact keyed SELECTs and exactly the source and returned fork keys after fork plus rewind. Keep the rewind one-read assertion and all editor/media/provenance/sandbox checks. No production behavior changes. Attribution: the culprit parent passes (92.77s); the culprit fails with the original 2-versus-1 assertion (98.02s). Both parents and merged commits for #169458 and #169513 pass. Baseline full file: 24 pass, 1 fail (90.61s). Reverting only this fix reproduces that same failure (86.66s). Proof: 10 full-file runs, 25/25 each: 100.71s, 82.57s, 110.16s, 72.92s, 55.99s, 58.74s, 93.46s, 55.29s, 58.21s, 57.20s. Owning gateway-methods config shard 98/128: 3 files, 53/53 (189.90s). Targeted gateway-methods tsgo passed (72.48s wrapper, 13.8s graph); type-aware oxlint (33.02s), boundary-guards (1.35s), oxfmt (0.33s), git diff --check and fresh independent P2 review passed. check-changed (422.73s) passed its selected guards/types but failed the production unused-export scan on renderPublicSessionCardSvg. The same scan fails identically on clean origin/main 044f8ea (150.38s); full-tree and script scans pass on both. No baseline or suppression changes. Peer recheck: no landed fix. Open #169566 removes these SQL counters in a broader cutover; this focused main repair preserves their exact contract.
…ers (#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 #169579.
…w#169579) Move child discovery, Memory metadata reads, recap freshness, and transcript event append through existing worker owners. Preserve deprecated public synchronous contracts through their documented migration window. Warmed median statements 344 to 327 and requests 106.5 to 102.5 over two alternating pairs. Types, lint, source contracts, architecture and database ratchets pass; unchanged-owner test failures and the baseline build verifier limitation are documented in the PR.
Repair the sessions-rewind failure from hourlies 38216343022 (9000810, checks-node-compact-large-4) and 38220958692 (8da3099, checks-node-compact-large-3, agentic-gateway-methods-hosted-5). Culprit: ae4267e (openclaw#169579), whose stated intent is: "Raw event appends use the existing event operation, including entry-less events and active-branch parent selection." The fixture's event appends now stay in workers instead of warming the host's shared-state reader. A cold fork therefore executes the existing transaction-admission and candidate-commit upstream SELECTs separately. These are authority reads, not duplicate cuts, history, or session rows. Assert both exact keyed SELECTs and exactly the source and returned fork keys after fork plus rewind. Keep the rewind one-read assertion and all editor/media/provenance/sandbox checks. No production behavior changes. Attribution: the culprit parent passes (92.77s); the culprit fails with the original 2-versus-1 assertion (98.02s). Both parents and merged commits for openclaw#169458 and openclaw#169513 pass. Baseline full file: 24 pass, 1 fail (90.61s). Reverting only this fix reproduces that same failure (86.66s). Proof: 10 full-file runs, 25/25 each: 100.71s, 82.57s, 110.16s, 72.92s, 55.99s, 58.74s, 93.46s, 55.29s, 58.21s, 57.20s. Owning gateway-methods config shard 98/128: 3 files, 53/53 (189.90s). Targeted gateway-methods tsgo passed (72.48s wrapper, 13.8s graph); type-aware oxlint (33.02s), boundary-guards (1.35s), oxfmt (0.33s), git diff --check and fresh independent P2 review passed. check-changed (422.73s) passed its selected guards/types but failed the production unused-export scan on renderPublicSessionCardSvg. The same scan fails identically on clean origin/main 85f4c3f (150.38s); full-tree and script scans pass on both. No baseline or suppression changes. Peer recheck: no landed fix. Open openclaw#169566 removes these SQL counters in a broader cutover; this focused main repair preserves their exact contract.
…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.
What Problem This Solves
Session child discovery, Memory ingestion metadata, activity recap freshness, and raw transcript event appends could still execute SQLite on the Gateway thread despite existing worker owners.
User Impact
No schema, retention, or transcript-format change. Bundled callers await worker-backed results. The Memory SDK adds
loadMemorySessionMetadataAsyncandloadMemorySessionMetadataBatchAsync; the synchronous methods remain deprecated until the next Plugin SDK major.Why This Change Was Made
Reuse the exact-entry/history workers and transcript writer. Child aliases share one indexed query; an ingestion batch shares one metadata read; the recap presenter consumes the prepared watermark. Raw event appends use the existing event operation, including entry-less events and active-branch parent selection. Delete the unused event-by-id reader and the package-local synchronous transcript corpus fallback.
Removed checks and accepted edge cases:
Native incognito ownership is deliberately left for its separate removal. Deprecated SDK metadata readers retain synchronous compatibility. This PR is the first of the lane's owner/API cutovers; it does not claim that every shared kernel is worker-only.
Evidence
Independent Codex review found no actionable P0/P1 issues. Local changed-file oxfmt, basic oxlint and
git diff --checkpass. Under RELAXED TESTING v6, PR CI owns tests and static proof: all production/test type shards, core/extension lint, source contracts and database baseline ratchets pass at215556e77dbc73ed336e336f2df9faa657911a96(CI run 38207983553). The worker recap freshness regression passed 2/2 before v6; no further local suites were run after the process change.Baseline
943da4fc9366e2acc1710542897b4e229064c6c1→ candidate215556e77dbc73ed336e336f2df9faa657911a96. Unchanged shared harness; alternating M1,C1,M2,C1b. The second pair is the RAW TURN INCREASE attribution check. Node 26.11.1 / SQLite 3.53.4; all four isolated workloads passed 13 top-level turns, child completion, list/history, cron, compaction and graceful shutdown.Warmed values pool the 20 turns from each revision. First-turn and whole-workload values summarize the 2 runs per revision.
Initial pair warmed SQL mean 343→354.5 (+11.5) and requests 108.7→109.2 (+0.5), with warmed duration ratio 1.02. Extra pair warmed SQL 319.4→317.6 (−1.8), requests 99.9→99.6 (−0.3), MAIN 0→0, duration ratio 0.99. The initial increase did not reproduce. Extra-pair whole-workload SQL 9456→9469 (+13,+0.14%) and requests 1895→1904 (+9,+0.47%); aggregate two-run whole-workload medians fell 16 statements and 12.5 requests.
session-exact-entriessession-activity-summary-sourcesession-corpus-inventorytranscript-statstranscript-hydrationsession.entry.patch.commitdatabase.domain.publishdatabase.prepareWriteAttribution: first-pair warmed publication/corpus/entry-commit SQL shifted from other phases; full-run totals stayed level or fell. One additional 32-statement cold writer admission ran during C1 warmed turns through
withSessionEntryWorker; it did not reproduce in C1b. The warmed MAIN difference is 2 secret-store SELECTs plus 2 delayed worker-placement startup session/participant reads (outside this lane); both repeat runs had zero warmed MAIN SQL. Baseline final read-only built-plugin verifier timed out twice after compilation; 43 emitted source-map contents matched pinned sources, and its live workloads used those complete artifacts without claiming a build pass or writing provenance. Candidate qaRuntime passed fully.CI has unrelated failures in unchanged owners: channel-inbound maintenance is identical to main run 38205326916/job 114667657722; the Bun fork test expects one upstream read and observes two; Workshop learning and cursor-reset E2E fail in unchanged observer/cursor paths. Built CLI and steer-fence tests also fail in untouched owners. These are retained as failures, not represented as passing behavior proof.
LOC versus the integrated base: production/docs +589/-257; tests/support +635/-360. No update cell is required (no update, Doctor, schema migration, plugin loading or service lifecycle change).
T1 inventory
The assigned 21 files contain 43 T1 primitives at the measured base and 42 after this cutover.
session-entry-children-read.tsfalls from 1 to 0. The original 46-call census predates a stats rewrite already on the base. These are inventory primitives, not warmed SQL totals: shared kernels remain reachable by deprecated synchronous SDK adapters, native incognito, offline maintenance, and the CLI's final execution-authority guard. The follow-up PR handles snapshot callbacks, worktree ownership, and remaining SDK replacements.The following checks passed before the final type-only/test-fixture fixes and main integration: Madge, worker and dialect ratchets, export collisions, SDK surface/API diff, and runtime API guardrails. Knip's 57 findings were reproduced on the same baseline files/rules with zero additions. The current PR CI supplies the final type/lint/source-contract/database-ratchet results above; unrelated test failures remain explicit. The extracted freshness test now uses the existing database-worker forks suite and passes prepared watermark facts through its list fixture; its assertions are unchanged.