Repository navigation
perf(tts): carry prepared TTS preferences through dispatch - #164694
Conversation
Refresh freshness at read admission and after BEGIN while reusing handle-owned facts for runtime schema checks. Validate canonical triggers before exposing agent readers and classify shared-state failures only after failed admission. Focused runtime checks execute zero SQL statements, versus 30 with the baseline owner. Preserve foreign-commit and snapshot semantics. Full workload measurement and remote integration checks remain merge preconditions after remote runner and fleet-capacity admission failed.
Route audited writer claims, live-model-switch bookkeeping, and pending-final preparation, settlement, and cleanup through the existing agent executor. Preserve native opaque SDK callbacks and the excluded lifecycle and cron paths. The paired isolated Gateway workload reduces native patch transactions from 8 to 2 per warmed turn and target-site SQL from 48 to 12. Overall main-thread SQL averages 648.5 to 493.4 statements per warmed turn. Lifecycle persistence remains follow-up work after #142236; cron preparation remains with #161105. Local caller, settlement, error identity, import-boundary, cycle, and database ratchet proof passes. Full build, changed checks, and released SDK diff remain explicit merge preconditions under the maintainer's validation instruction.
Integrate the pinned measurement baseline and retain main-key facts through the existing connection and reader-admission owners. Preserve raw writes, foreign commits, transaction snapshots, authorizers, and continuation authority.
Create and read producer-recovery sessions under the same explicit shared-state root as their delivery queue. Worker-backed pending-final settlement correctly rejects the previous fixture ownership mismatch. Preserve durable payloads and all existing assertions.
Use the existing worker generation claim for maintenance metadata instead of retaining a host read handle. Keep both live ownership checks around the required transaction-entry freshness probe. Consolidate shared-state cache initialization, refresh, and terminal failures in its admission sibling and update the compiled-wrapper inventory. This keeps the cache within the existing module-size limit without changing stored schema or quarantine semantics. Focused maintenance, ownership, schema, worker, wrapper, and quarantine proof passed. Independent Codex review is clean through P2. Full landing validation remains required before merge.
Keep the accounting persistence suite within its line cap by moving fixture construction into a dedicated test-support module. Preserve suite-owned state, immediate operation registration, and every test case and assertion.
Refresh canonical readiness when it consumes schema facts. Retention only holds native lifetime, so cold restore and other worker handoffs no longer execute host SQLite before dispatch. Protect foreign schema invalidation at the warm readiness fast path. Tighten retained-reader budgets to the optimized counts, and require early missing-table diagnosis before callbacks while preserving handle-cleanup assertions. Validation: 93 focused tests, production types, state/config test types, and independent review clean through P2.
Integrate the released-SDK diff tooling fix and the inherited child-coordination fixture correction. The merge preserves every authored source, test, and documentation blob; the wrapper inventory combines both branches.
…in/dbasync/agenttx' into dbasync/ttsprepare
Read the machine-owned preference path through the shared-state worker once per turn and carry the result through delivery and prompt assembly. Preserve scoped path precedence, fresh preference-file reads, and synchronous SDK compatibility. Move existing machine-state, ACP prompt, and CLI error helpers to their owning modules to keep capped orchestration files from growing. No schema, retention, durability, or configuration changes.
|
🦞👀 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: blocked before merge. Reviewed October 4, 2026, 4:41 AM ET / 08:41 UTC (Revision 8). ClawSweeper reviewWhat this changesThe PR reads text-to-speech preferences through the existing database worker and carries the prepared path through reply delivery and agent prompts while preserving released plugin calls. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: current main still performs the synchronous TTS preference reads this PR removes. No actionable introduced defect was found, and the prior migration checklist is inapplicable because the compatibility record is static metadata and no stored-data contract changes. Priority: P2 Review scores
Verification
How this fits togetherText-to-speech settings determine whether replies become speech and what voice guidance enters agent prompts. Reply dispatch combines machine preferences with configuration and fresh preference-file contents before prompt construction and audio delivery. flowchart TD
A[Machine preference row] --> B[Shared database read worker]
B --> C[Prepared preference path]
D[Configuration and environment] --> E[TTS settings resolution]
C --> E
F[Fresh preference file] --> E
E --> G[Agent prompt guidance]
E --> H[Reply speech delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +197, Tests +139, Docs +26, Other +1. Total +363 across 52 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing worker to prepare one turn-scoped machine path while retaining configuration precedence, fresh file reads, and the released synchronous SDK contract. Do we have a high-confidence way to reproduce the issue? Yes, source inspection identifies the current-main synchronous preference read, and the recorded Gateway workload measures its SQL cost; this reviewer did not execute the workload. Is this the best way to solve the issue? Yes, the patch reuses the existing read worker and carries explicit presence or absence through consumers without adding a competing cache or changing released call requirements. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 403b0ced4f6b. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Record and type-check the retained synchronous Plugin SDK calls while host turns carry worker-prepared preferences. Include the compatibility metadata in the PR wrapper dependency inventory. Update TTS and cron fixtures to supply and expect prepared preference facts. Bind pending-final recovery fixtures to the queue shared-state environment, matching the worker admission ownership boundary without changing assertions. Validation: 192 focused tests, wrapper inventory, released SDK type graph, lint, documentation links, and clean P2 review.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…164694) * perf(state): carry admitted schema facts with database handles Refresh freshness at read admission and after BEGIN while reusing handle-owned facts for runtime schema checks. Validate canonical triggers before exposing agent readers and classify shared-state failures only after failed admission. Focused runtime checks execute zero SQL statements, versus 30 with the baseline owner. Preserve foreign-commit and snapshot semantics. Full workload measurement and remote integration checks remain merge preconditions after remote runner and fleet-capacity admission failed. * perf(agents): run per-turn session-entry patches through the worker Route audited writer claims, live-model-switch bookkeeping, and pending-final preparation, settlement, and cleanup through the existing agent executor. Preserve native opaque SDK callbacks and the excluded lifecycle and cron paths. The paired isolated Gateway workload reduces native patch transactions from 8 to 2 per warmed turn and target-site SQL from 48 to 12. Overall main-thread SQL averages 648.5 to 493.4 statements per warmed turn. Lifecycle persistence remains follow-up work after openclaw#142236; cron preparation remains with openclaw#161105. Local caller, settlement, error identity, import-boundary, cycle, and database ratchet proof passes. Full build, changed checks, and released SDK diff remain explicit merge preconditions under the maintainer's validation instruction. * test(outbound): align recovery fixtures with queue state Create and read producer-recovery sessions under the same explicit shared-state root as their delivery queue. Worker-backed pending-final settlement correctly rejects the previous fixture ownership mismatch. Preserve durable payloads and all existing assertions. * fix(state): preserve worker handoffs during schema admission Use the existing worker generation claim for maintenance metadata instead of retaining a host read handle. Keep both live ownership checks around the required transaction-entry freshness probe. Consolidate shared-state cache initialization, refresh, and terminal failures in its admission sibling and update the compiled-wrapper inventory. This keeps the cache within the existing module-size limit without changing stored schema or quarantine semantics. Focused maintenance, ownership, schema, worker, wrapper, and quarantine proof passed. Independent Codex review is clean through P2. Full landing validation remains required before merge. * test(agents): extract accounting persistence fixture Keep the accounting persistence suite within its line cap by moving fixture construction into a dedicated test-support module. Preserve suite-owned state, immediate operation registration, and every test case and assertion. * fix(state): keep retained handles free of schema probes Refresh canonical readiness when it consumes schema facts. Retention only holds native lifetime, so cold restore and other worker handoffs no longer execute host SQLite before dispatch. Protect foreign schema invalidation at the warm readiness fast path. Tighten retained-reader budgets to the optimized counts, and require early missing-table diagnosis before callbacks while preserving handle-cleanup assertions. Validation: 93 focused tests, production types, state/config test types, and independent review clean through P2. * perf(tts): carry prepared TTS preferences through dispatch Read the machine-owned preference path through the shared-state worker once per turn and carry the result through delivery and prompt assembly. Preserve scoped path precedence, fresh preference-file reads, and synchronous SDK compatibility. Move existing machine-state, ACP prompt, and CLI error helpers to their owning modules to keep capped orchestration files from growing. No schema, retention, durability, or configuration changes. * fix(tts): finish prepared preference compatibility Record and type-check the retained synchronous Plugin SDK calls while host turns carry worker-prepared preferences. Include the compatibility metadata in the PR wrapper dependency inventory. Update TTS and cron fixtures to supply and expect prepared preference facts. Bind pending-final recovery fixtures to the queue shared-state environment, matching the worker admission ownership boundary without changing assertions. Validation: 192 focused tests, wrapper inventory, released SDK type graph, lint, documentation links, and clean P2 review. * test(tts): document dispatch preference mock isolation
What Problem This Solves
Ordinary reply dispatch and prompt preparation repeatedly read the machine-owned
tts.prefsPathon the Gateway thread. The local ten-turn fixture attributed 100 successful main-thread SQL statements to these TTS call chains: 40 row reads and 60 admission statements.Why This Change Was Made
Read that fixed key through the existing shared-state read worker, then carry explicit present/absent facts through internal reply options, embedded/CLI prompt preparation, and delayed delivery callbacks. Each consumer retains its existing config/agent/channel/account/environment precedence and fresh preference-file reads. Standalone prompt, ACP, cron, and message-action preparation use the same reader.
The machine-state command branch now lives with its domain kernel. Two unchanged ACP prompt / CLI error helpers were extracted to satisfy the line-cap ratchet. No new worker service, policy cache, or
OPENCLAW_*name was added.User Impact
The measured TTS paths execute 10 → 0 main-thread statements per warmed turn, with one worker preference-row read per turn. This is a scoped reduction: the overall observed mean is 344.5 → 345.4 (median 338 → 330), not an aggregate reduction. Non-TTS paths executed 109 more warmed statements at unchanged session-entry, participant, and read-admission sites; the per-site accounting is below.
No schema, stored-data, retention, durability, config option, or update migration changes. Released synchronous TTS SDK calls remain supported with optional prepared facts, an explicit compatibility record, a next-major removal gate, and a compile-time contract test. No existing caller argument becomes required.
Evidence
Final integration
Candidate
4ebfcd375fe80amerges main06d4475d6079aaa875a9b477ac0935d1459b1023, including the final schemafacts prerequisite (#164490,c828f7ed1d560295f78166a98fb54687dc162b28). The PR remains based onmain; its diff against that captured main is 52 TTS-lane files, +426 / −63, with no prerequisite residue.Conflict resolution preserves main's canonical
buildConfiguredAgentSystemPrompt, tool normalization and inferred agent ID, while carrying prepared TTS facts through ordinary and compaction prompts. Compaction uses that canonical builder, and both storage-documentation paragraphs are retained.The integrated candidate passed 130 tests across 11 files / six Vitest projects with
--maxWorkers=1on Node 24.21.0 (972.61 s wall). Coverage includes the real TTS read-worker/zero-caller-SQL boundary, worker settlement, TTS fallback behavior, canonical/embedded/CLI prompt builders, SDK compatibility, registry, shared-worker and reply import closures, and runtime process build graph. The dedicated wrapper-inventory case passed in 122.85 s wall. SDK type checking passed in 20.84 s; core production type checking passed in 139.51 s, including artifact-owner wait. Conflict-file lint, formatting, andgit diff --checkpassed. Fresh P2 review against the captured main is scoped-clean.The released SDK comparison against
v2026.9.8completed locally for correction0f4e8b8(2,091.91 s wall). The relevant public TTS owner/facade/signature files remain byte-identical after integration, so that report still covers this lane's signature changes. The full SDK compiler graph also passed in 36.6 s in earlier CI; that is whole-graph cost, not an isolated per-case timing. Per-file CI timings were unavailable in the retained artifacts. The type-only case takes 0 ms at runtime locally.Exact-head CI run 37188231800 passed for
4ebfcd375fe80a341f644655fbfbac6fd6ad6d1d. ClawSweeper completed this head at 08:19 UTC on October 4 with no actionable introduced defect and confirmed the integration blocker is resolved. Its generic migration checklist item points to the static SDK compatibility-registry record; that record introduces no stored state, schema, or migration. Earlier heads’ results remain historical evidence.Failure attribution and repairs
The original TTS truncation and cron exact-call fixtures were stale after prepared facts were introduced. Correction
0f4e8b8c31110668f7937fc3e929feda1978ffcfupdates those inputs/expectations without weakening assertions, and adds the released-SDK record, type contract, docs, and wrapper inventory entry. Correction6d94e4279faaf9433945f07e1ecaf92812993920documents why the shared dispatch fixture isolates the real database worker; its exact mock ratchet failed before and passed afterward.Inherited failures are now integrated from their owners: recovery fixture and retired Doctor-test inventory corrections in
1836ae2146443e(#164675), native formatter import repair in3c0f7e4c5cdade, MCP cursor fixture correction in42b9aee33a7b(#164795), and spinner-test repair in65829ead96bb(#164465). The prerequisite also carries private-completion receipt settlement correction395e837b023866. The latest pre-integration CI (37181377968, headb70ed5e) failed only the inherited spinner assertion and aggregate gate; every other executed job succeeded.Attribution used 45 complete Linux file runs across the original PR, merge base, and pinned main. The later spinner failure reproduced in five complete E2E file runs on GitHub's actual tested merge and five on its exact main parent, each with only that assertion failing and two sibling cases passing; scheduled main CI independently matched. The cursor type error reproduced five times before its upstream correction superseded further repetitions. No sleeps, retries, timeouts, assertions, or baselines were weakened.
Loaded-Mac full declaration-fixture repetitions also hit unrelated compiler timeouts and are not counted as passing proof. The native-import defect has a real Node regression from main, and subsequent Windows CI passed. Original WebSocket 1006 fixture interruptions remain disclosed below; no transport fix is claimed.
Local SQL measurement
Before:
cd69bcb581dfe35192d3f83b036844c88e3ce100(main plus both prerequisite heads). After:bd25d971b8a0141c556fddb2c6fe8f956d704371. Node 24.21.0 / SQLite 3.53.4, source-map builds, fresh synthetic state, local streaming Responses fixture, real Gateway/WebSocket/storage paths. No external model service was called. Both completed workloads include 13 top-level turns, a successful child, cron completion, committed compaction, and clean[0, null]shutdown; all resolved disk database paths stayed within their fixtures.The original native SQL observer and analyzer were reused unchanged. Counts include successful top-level SQL executions, including admission and transaction statements, and exclude prepares and failed attempts. The successful after run adds harness-only timestamps and passive ping/pong listeners after two interrupted attempts; workload, model, auth, RPC sequence, waits, deadlines, and SQL interception are unchanged. The inherited harness's hardcoded
headfield is not the source identity; use the pinned refs above.The preserved per-site analysis accounts for the aggregate +9 entirely: −100 TTS statements +109 at unchanged non-TTS sites. The original raw fixtures were removed after measurement; this audit reuses the recorded analyzer output and independently traces the current reader implementation.
session-accessor.sqlite-entry-read.ts:123session-accessor.sqlite-participant-projection.ts:56openclaw-agent-db-readonly.ts:118openclaw-state-db-cache.admission.ts:53session-accessor.sqlite-entry-read.ts:348agent-deletion-journal.ts:123All nonzero non-TTS site changes are accounted for. The five unchanged files above have an empty before/after diff. Stack attribution places all 33 additional canonical session reads in existing chat/session authorization and pending-input paths, without TTS frames. Eight of ten overall turn counts decrease; the increases concentrate in turns 2 and 10, consistent with timing-dependent work within phase windows.
The integrated TTS reader does not replace its removed SQL with host admission SQL:
openclaw-state-read-operation.tsretains the handle throughretainOpenClawStateDatabaseForIndependentRead;openclaw-state-db-borrow.tsreads the cached-handle map directly withoutcacheAdmission.refresh. Host admission uses in-memory generations and filesystem identity; schema admission and the preference-row query run inside the worker. Explicit prepared absence ({}) prevents the synchronous SDK fallback. The evidence supports ten fewer main-thread statements in this path per turn, while no aggregate or latency improvement is claimed.These are phase windows, including concurrent admission and maintenance, not causal RPC counts or latency measurements. Before had one failed main-thread and two failed off-main native attempts; after had two and three, respectively, excluded from the successful-statement totals.
Two initial after attempts ended with WebSocket 1006 / EPIPE after long gaps, before the next TTS preparation. They are excluded from the tables. The diagnostic run completed without a code change; it does not establish a fix for those transport interruptions. Those transport interruptions remain an unresolved fixture risk.
Original lane checks
All selected tests used
--maxWorkers=1.node scripts/check-changed.mjs -- <changed paths>89c984736562959b3e6160dc118d4b84e18aabe6v2026.9.8→ lane commit, local realpathTMPDIRThe new worker boundary file took 1.63 s of test execution initially and 6.86 s on the loaded final run; it uses the real native reader to prove zero caller SQL, fresh next-turn facts, and prepared absence. Wall times above include substantial compilation/import/ownership waits on the loaded host. The historical CI failures and their corrections are recorded above; final integration checks are separate from these original receipts. The first changed-gate attempts exposed real line-cap growth; the helper extractions resolved it without exceptions.
Overlap discovery used the local archive and bounded live searches for PRs updated since October 1. Related independent work includes #162433 (standing inactive umbrella), #134617 (command history), #127091 (other-goal prompt forwarding), #127653 (import cleanup), and CLI cleanup/tests #164320 / #164520. Minimal propagation hunks preserve those areas' ownership. No production Gateway was changed or restarted.