Repository navigation
refactor(transcripts): stream meeting exports through the read worker - #167532
Conversation
Keep one snapshot across bounded export chunks and join asynchronous consumers before releasing reader custody. Replace repeated artifact batch queries with a fixed-head cursor and retain live lease checks at guarded file publication.
Keep subagent restore and meeting transcript streaming inside the existing native section while moving their reply adapters out of the main dispatcher. Correct Promise executor and synchronous-read test lint violations.
Reuse the output writer’s compatible temporary-file owner while retaining guarded publication. Keep exports working beneath group-writable ancestors and exercise that contract in the existing artifact test.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesStream meeting downloads and artifact exports through the shared database read worker while retaining snapshot consistency, cancellation cleanup, and guarded file publication. Example: Export a meeting while its saved utterances are reset
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR retains useful work absent from current main. The earlier integration blocker is resolved, and the reviewed patch has no actionable code findings. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherMeeting transcripts live in the shared SQLite state database. Download requests and capture-stop operations read those records to produce JSONL, Markdown, and explicit artifact files. flowchart TD
A[Meeting download or capture stop] --> B[Transcript export owner]
B --> C[Shared database read worker]
C --> D[One read snapshot]
D --> E[Bounded chunks with backpressure]
E --> F[Download response]
E --> G[Artifact staging]
G --> H[Live lease check and file publication]
Technical reviewBest possible solution: Keep export snapshots in the shared read worker and retain current durable lease checks at final artifact publication. Do we have a high-confidence way to reproduce the issue? Yes, source establishes caller-thread export queries and separate artifact batch reads; the supplied campaign also reports baseline failures for reset truncation and stale publication. This review did not execute them. Is this the best way to solve the issue? Yes, the patch extends the existing read owner, removes the obsolete native export route, and preserves the filesystem and writer owners rather than introducing competing persistence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d5becdb65bbc. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +279, Tests +256, Docs +22, Other +4. Total +561 across 28 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 (1 earlier review cycle)
Reviewed October 8, 2026, 8:32 PM ET / October 9, 2026, 00:32 UTC (Revision 2). |
Preserve current transcript-owner cleanup and shared-reader additions while resolving the worker export conflicts. Adapt consolidated library tests and restore the retained-operation test import.
|
Merged via squash auto-merge.
|
…openclaw#167532) * perf(transcripts): stream meeting exports through the read worker Keep one snapshot across bounded export chunks and join asynchronous consumers before releasing reader custody. Replace repeated artifact batch queries with a fixed-head cursor and retain live lease checks at guarded file publication. * refactor(state): share bounded stream read dispatch Keep subagent restore and meeting transcript streaming inside the existing native section while moving their reply adapters out of the main dispatcher. Correct Promise executor and synchronous-read test lint violations. * fix(transcripts): preserve shared export path permissions Reuse the output writer’s compatible temporary-file owner while retaining guarded publication. Keep exports working beneath group-writable ancestors and exercise that contract in the existing artifact test.
What Problem This Solves
Meeting transcript downloads and stop-time artifact exports execute SQLite on the Gateway main thread. Artifact export also rereads every 64 rows, so a concurrent reset can truncate the exported snapshot.
User Impact
JSONL and Markdown keep their existing formats and limits. Exports retain one database snapshot, and a revoked export lease cannot replace an already published artifact. Custom export roots retain their existing permission support.
There are no schema, stored-format, retention, permission, configuration, or Plugin SDK API changes. Guarded publication keeps the previous best-effort file/directory sync policy, including the Windows fallback contract, at the cost of one additional artifact-sized temporary copy. Linux runtime proof is below; other platforms were not separately exercised.
Why This Change Was Made
The existing shared-state read worker owns the export snapshot and ordered cursor. Bounded chunks wait for consumption; cancellation joins accepted asynchronous consumers and native cleanup. Worker failures never fall back to caller-thread SQLite. Artifact selection replaces a sequence-head query plus repeated 64-row queries with one head query and one cursor; empty artifacts skip the cursor. The obsolete native export iterator is removed.
Pending markers and manifest writes retain their existing writer, FIFO, transaction guards, and settlement behavior. Files publish through the filesystem owner's live mutation callback. The synchronous durable lease/database-ownership checks remain final-authority guards because native and foreign writers can revoke ownership without complete process publication. These checks add rare-operation cost; the measurements report that cost rather than treating relocation as a call saving.
The diff is 1,244 lines: production +439/−160, tests +433/−178, docs +24/−2, inventory tooling +6/−2. Production growth covers bounded consumer custody, the snapshot adapter, and guarded file publication. The retired native route and its exclusive tests are deleted.
Evidence
Pinned baseline
bc162d9e05d5e8c776c37fb832c493e6d7bb927eand candidate845baa7234ac8688929342b2d7db3163e1802ff1; one isolated AWS Linux x64 host, Node 24.21.0, SQLite 3.53.4. Ordinary Gateway runs alternated M1,C1,M2,C2,M3,C3. The export supplement then added M4,C4,M5,C5,M6,C6 on that same host after high duration ratios appeared. Every JSONL/Markdown/artifact output matched byte-for-byte. All final samples had zero failed SQL executions.The shared SQL workload/native counter is unchanged; a task-owned copy adds the campaign request-census observer. It counts all successful native statement executions across MAIN, workers, and helpers. Product task sends, admission messages, reverse stream messages, and source-compiler requests are kept separate. SQL/census conservation matched every phase/thread/SQL group. Origin classification remains partial, so no foreground-only subtotal is used to pass the gate.
Ordinary Gateway budget
Cells are median [min–max], baseline → candidate. Warmed values are each run's ten-turn mean, then the side median. All ordinary-phase candidate/baseline median duration ratios are ≤1.006; there is no duration-skew rejection in this series. No ordinary-turn saving is attributed to this rare export change.
Comparing the samples at the side medians, the first-turn +3 is unchanged deferred cron work (+4 statements), minus one ACP poll; three admission probes move between existing read request owners without changing their total. The connect +21 decomposes into existing cron +24, device identity +3, and catalog −6 statements. The combined startup window passes the deferred-startup rule:
Boot+connect alone is 3,135 → 3,157 (+0.70%, within combined non-turn tolerance). Second-session +7 is within the +10 non-turn allowance and belongs to unchanged session readers/maintenance. Compaction +1 is an unchanged WAL checkpoint. Other differences are unchanged admission/maintenance timing; no meeting-export command occurs in the ordinary-turn series.
Ordinary phase timing and admission messages
Reverse messages are unchanged: first turn 2, second session 1, compaction 2, and zero elsewhere. Each side has two unresolved-target boot sends; all are counted. Source-compiler requests and failed SQL executions are zero in the ordinary series. The final
donephase has zero SQL and requests on both sides. Including admission requests, the warmed request median is 481.6 → 481.4; no request saving is claimed for ordinary turns.Rare export operations
Six alternating pairs produced identical SQL/request counts in every sample; ranges are retained below. This is an in-process Gateway request dispatcher and actual stop handler using source workers, not a production latency benchmark. High duration ratios persisted after the extra pairs: cold JSONL ≈21.26×, warm JSONL ≈9.22×, cold stop ≈1.79×, close ≈2.50×, cleanup ≈1.67×. They are explicit foreground worker/bootstrap/authority costs under the requested rare-operation off-MAIN allowance, not a claimed latency win or a duration-valid ordinary-turn comparison.
Admission messages are unchanged: seed 520, cold stop 10, warm stop 8, and zero elsewhere. Source-compiler requests, excluded only through their actual esbuild sender stacks, are seed 4,294 → 4,293, cold JSONL 16 → 1,141, cold stop 1,582 → 2,695, and zero elsewhere. The two cold candidate exports each have one unresolved target-ID send; both remain counted and are not used for request-origin attribution.
Across the entire export sequence excluding fixture seeding, observed totals are 1,580 → 1,559 SQL, 824 → 740 MAIN, 27 → 34 product requests, and 0 → 25 reverse stream messages, invariant in all six pairs. Cold library initialization shifts into the first retained native publication guard, so the large cold-endpoint delta is not a standalone saving.
The warmed stop path rises 146 → 196 total SQL, 54 → 92 MAIN, and 12 → 13 task requests. Its exact +50 breakdown is −4 payload queries, −4 old writable-read preparation checks, +10 worker read/snapshot admission statements, and +48 final-authority/supporting ownership/freshness checks. These guards are retained deliberately; caching an earlier lease result would permit stale publication.
Whole-sequence attribution (all threads, excluding seeding):
Each of the five exports adds one product read request and five bounded reverse chunk requests. Two additional product requests close the reader resources. The actual row-query saving for one 257-row artifact is 6 → 2; moving those queries off MAIN is reported separately.
Correctness and structural checks
check:changedpassed in 2,168.8 s. One client connection was interrupted while the sequential typecheck continued; its terminal exit-zero receipt was recovered, and remaining checks continued on the same unchanged head/lease without repeating completed proof.src/transcripts/store-export-jsonl.ts:26:24,src/transcripts/store-export-jsonl.ts:42:24,src/transcripts/store-read.ts:487:15,src/transcripts/store-read.ts:634:15. Supplementalstore-read.ts:722:1now executes in the worker;openclaw-state-db-read-connection.ts:316:1is deleted.Focused test cost
Command:
pnpm test <the 13 files below> --maxWorkers=1 --reporter=default --reporter=json. File times are from native reports within the shared 162.182 s invocation. The physical SQLite snapshot, real worker, publication, and settlement contracts require these boundary tests. CI seconds are pending until the PR run exists.src/state/openclaw-state-read-worker.test.tssrc/state/openclaw-state-db-readonly.test.tssrc/state/openclaw-state-read-worker.settlement.test.tssrc/state/openclaw-state-read-worker.ownership.test.tssrc/transcripts/store.test.tssrc/transcripts/library.test.tssrc/infra/sqlite-worker-transcripts.test.tssrc/transcripts/library.query-budget.test.tssrc/infra/sqlite-worker-transcript-export.test.tssrc/state/openclaw-state-read.existing-schema.test.tssrc/transcripts/library.async.test.tssrc/infra/sqlite-worker-transcripts.export-settlement.test.tssrc/agents/subagents/registry/subagent-registry-worker.test.tsGaps and follow-up
The rare source-worker fixture is slower end to end, particularly on first worker/compiler acquisition; this PR makes no export latency claim. Final native authority guards remain until complete revocation publication and removal of raw synchronous writers at the next Plugin SDK major. The separate admission owner can remove inherited schema-preparation overhead without introducing a second cache here.
An initial unpaired baseline context probe saw one shutdown audit-pruning
BEGIN IMMEDIATElock refusal. No fix is claimed for that unrelated path; the final paired series had zero SQL failures. Runtime proof uses synthetic isolated Linux state, not a live production Gateway. PR CI timing is pending.Landing integration
Integrated main
c881d464aafee4b07a80d34ae7c357a94b161690with merge commit7071c869be9c986239521d6682a1067695a7bde6. Conflicts were limited to additive documentation/imports and transcript-store cleanup. Main's inlined materialization and test consolidation are preserved. The moved library fixtures now consumestreamExport, and the retained-operation import used by cancellation cases is restored. No SQL-path behavior changed during resolution; the alternating-pair proof above is reused under the approved landing policy.The released SDK check compared
v2026.10.1-beta.1and stablev2026.9.9: changed/removed store, artifact, and read-transport functions are not exposed throughsrc/plugin-sdk,api.runtime, or documented SDK subpaths. The existing SDK-diff report found no API changes. No compatibility shim is needed. The wrapper import inventory has no missing or stale entries, and indirect transcript consumers already use host-owned fork projects. Incidental overlap with the landed cleanup in #167073 is preserved.ClawSweeper completed its review of
845baa7234ac8688929342b2d7db3163e1802ff1with no code findings; its requested follow-up was integration and focused export/cancellation proof. The integrated production diff received a clean Codex P2 review.Integrated proof: 114 passing tests across seven files, reusing successful shards while rerunning repaired fixtures. The import-boundary shard passed 11 tests in 12.96 s; shared-reader tests passed 33 in 9.73 s; the export/artifact shard passed its 58 non-library tests (the complete initial shard took 216.31 s with two stale library fixture failures); repaired library tests passed 12 in 59.33 s. Commands used
node scripts/run-vitest.mjs <files> --maxWorkers=1. No sleeps, retries, or weakened assertions were added. Production types, all core/test typecheck shards, and Madge (zero cycles) passed. An initial terminalonCopytype error came from this worktree's old Ghostty patch; frozen-lockfile installation resolved it. CI completed successfully on this exact head: run 37864736145. The final Node shard took 661 seconds (00:30:11–00:41:12 UTC); the required aggregate and security gates passed. No inherited-failure exception or CI rerun was needed.