Repository navigation
perf(talk): index open voice session lookups - #165546
Conversation
|
🦞👀 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. Reviewed October 5, 2026, 10:19 AM ET / 14:19 UTC (Revision 5). ClawSweeper reviewWhat this changesTalk voice-call lookups use indexed background reads and revision-bound compact facts, with safeguards for concurrent legacy consults and stale-call recovery. Merge readiness✅ Ready for maintainer review Keep open: current main still performs broad voice-record scans, and this PR provides a useful, validated optimization. No actionable correctness or security findings remain; the previous readiness action is resolved. Priority: P2 Review scores
Verification
How this fits togetherTalk connects realtime voice clients to OpenClaw agent consults. Its per-agent voice records track call ownership, transcripts, confirmation capability, and closure. flowchart TD
A[Realtime voice client] --> B[Talk request handler]
B --> C[Current session authorization]
C --> D[Background open-call lookup]
D --> E[Indexed agent database]
E --> F[Validated call candidates]
F --> G[Consult or stale-call close]
E --> H[Revision-bound tool facts]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +185, Tests +344, Docs +25. Total +554 across 16 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Retain one canonical voice-record store, use indexed worker reads for candidate selection, and preserve synchronous fresh ownership checks and transaction-bound closure. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: current-main source establishes the broad scan, and the captured benchmark quantifies its cost without claiming production throughput. Is this the best way to solve the issue? Yes. Filtering through derived indexes in the existing reader and retaining revision-bound facts avoids record conversion, a second persistence owner, and configuration growth. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e698b96e7480. 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 (4 earlier review cycles)
|
3baecb8 to
86c5cc0
Compare
Filter and validate legacy and stale candidates in the agent reader, retain revision-bound tool facts, and preserve close and legacy-binding ordering across reader waits. Keep voice JSON bodies and schema version unchanged with additive partial indexes.
86c5cc0 to
bec2340
Compare
Filter and validate legacy and stale candidates in the agent reader, retain revision-bound tool facts, and preserve close and legacy-binding ordering across reader waits. Keep voice JSON bodies and schema version unchanged with additive partial indexes.
What Problem This Solves
Talk legacy-client inference and stale-call recovery decoded every retained voice record, including closed history, before checking status. Repeated tool checks also decoded the record's growing effect and consult arrays.
User Impact
Closed history no longer contributes payload decoding to open-call lookups. Ownership, confirmation, transcript, and persisted JSON contracts stay unchanged. Concurrent legacy consults reuse their connection binding, and an explicit close still completes when stale recovery skips a resumed call.
Why This Change Was Made
Two partial expression indexes select open records by agent/session/origin or update time. The existing agent history worker selects and validates candidates; the all-row scanner is deleted. Synchronous tool policy retains at most 128 compact facts per native connection, invalidated by admitted schema, foreign-commit data version, and local mutation revision. Exact-record transaction helpers keep their native preparation/error ordering.
The index-only design is recorded in storage changes. It preserves table shape, schema version, and JSON bytes; no Doctor data conversion is required. Generated columns were avoided because they require a version bump under the storage policy. Writable admission builds the indexes once, and older same-version readers tolerate the additional non-unique indexes.
Production LOC is +273 / −88, net +185 (
git diff --stat origin/main...HEAD -- ':!*.test.ts' ':!*test-support*' ':!docs/*'). Growth preserves the synchronous tool-policy contract with revision-safe facts and the legacy protocol's validated uniqueness and worker-custody contracts. No scan fallback, second persistence owner, or configuration option is added.Evidence
A 50,000-record synthetic fixture, 95% closed, contains 171,561,674 JSON bytes. On Blacksmith Testbox
tbx_01m45rd64c95hwqn912tjfw512(openclaw-check, Linux/Node 24.19):Matching results are identical. Both queries use their partial indexes. The first isolated worker request took 1.75 s to initialize; warm end-to-end inference was 0.96 ms median, with a 50.98 ms maximum over 10 samples. These are synthetic measurements, not production throughput claims. The <=0.5 ms open-check target passed across 1,000 samples.
pnpm test src/talk src/gateway/talk/handlers/index.test.ts src/gateway/talk/handlers/client-native-control.test.ts src/state/sqlite-query-index-repair.test.ts --maxWorkers=1passed 486 tests in 43 files, including the new concurrent-legacy and close-race regressions. Wrapper wall time was 162.15 s on current head; the new public-handler regression took 0.978 s on prior-head validation. Original-base tests fail on the old host-payload reads; both asynchronous race regressions were observed failing before their fixes.Prior-head Testbox
tbx_01m464c2q8s0vt5s8abh7mzh9qpassed 49 tests across all five changed test files. Each ran aspnpm test <file> --maxWorkers=1; serial wall time totaled 133.86 s including startup/compilation:src/talk/client-voice-session.test.tssrc/talk/client-voice-session-store.test.tssrc/talk/client-voice-session.recovery.test.tssrc/state/sqlite-query-index-repair.test.tssrc/gateway/talk/handlers/client-native-control.test.tsIndependent review returned no actionable P0–P2 findings. Revisions obtained upstream fixes through rebase only; the stable patch ID is unchanged and this PR contains one lane commit across 16 intended files.
Static gate on
86c5cc0c: completed with exit 1 on the isolated Linux rig, usingnode scripts/check-changed.mjs --stagedagainst an index verified byte-for-byte equal to head86c5cc0cd38bfcc4833e4015496209d5ba96aed4. All 25 preceding checks passed, including production types and all 27 test typecheck groups; the only failure is the inherited export scan described below. This fallback started after the Testbox lease remained queued for over 20 minutes. Prior-head Testbox lint, max-lines, schema, database-first, media/sidecar, import-cycle, webhook and pairing guards passed.Historical inherited failure on
86c5cc0c: the global dead-export scan reportedBranchSummaryResult,renderRootHelpText,stripEnvelopeFromMessage, and seven media-understanding default exports. The same command reproduces the identical findings in a clean worktree at untouched base223f6e441ecb9bb80bbd80d885997a8ecc7270db. None of those files is changed here; no suppression or unrelated fix was added. Earlier base failures were obtained as upstream fixes by rebase rather than copied into this branch.CI recovery: run 37322965820 failed the Madge guard on an inherited 17-file startup/database import cycle. Every cycle file and the detector were byte-identical between CI merge
612ef6e8and its based94b8d8a. Main fixed the cycle in21901766c534and removed some inherited unused exports ine698b96e7480. This branch was rebased onto0d9e310d9fe79bd205fd0e83a19b60cb95e11131, yielding headbec2340dab57d2d53706a16f46fed1ce2b5bdec4with unchanged stable patch IDfa61639ec885c7956702dc720e8ef9844c982267. No upstream fix was copied into the lane. CI run 37324528419 is green on this head, including the requiredopenclaw/ci-gate.Current-head Testbox proof:
blacksmith-testbox/openclaw-check, leasetbx_01m4678767xqnn70w90bxxxhmx, Linux:node --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts: passed, zero cycles.pnpm tsgo:core: passed.pnpm test src/talk src/gateway/talk/handlers/index.test.ts src/gateway/talk/handlers/client-native-control.test.ts src/state/sqlite-query-index-repair.test.ts --maxWorkers=1: 486 tests / 43 files passed, 162.15 s.node --import tsx scripts/check-deadcode-exports.mts: fails onrenderRootHelpText,resolvePolicyPluginActivationState, and seven media-understanding default exports. An isolated untouched-base worktree at0d9e310d9fe79bd205fd0e83a19b60cb95e11131reproduces the identical findings. This standalone inherited failure remains documented; no guard or export baseline was weakened.The combined command took 424.28 s and returned 1 solely for that export scan. The untouched-base reproduction took 115.94 s. All Testbox leases are stopped, and the completed Linux rig worktree has been removed.
Remote validation and recovery
Runtime tests and benchmarks used the installed Crabbox CLI, provider
blacksmith-testbox, profileopenclaw-check. Final static validation uses the authorized Linux rig fallback.tbx_01m45n99vd3w5ghe55qpnht17j: Talk suites passed; index-plan fixture sorting was corrected. The initial 50k benchmark passed. Original-base payload-read regressions failed as expected after installing the temporary worktree's dependencies. Gateway handlers passed 117 tests. The close-race regression failed before repair. The first changed-file attempt identified a type-file size limit; declarations moved to the existing sibling. Two subsequent sync attempts timed out before validation. Lease stopped.tbx_01m45rd64c95hwqn912tjfw512: focused tests passed after the close fix. Recovery cases moved into a focused sibling to meet the test-file size cap. Full typechecks and preceding changed-file guards passed; the dead-export failure was reproduced on the untouched base. The legacy race was then reproduced and repaired; final runtime suites passed 486 tests. The benchmark above passed. Post-repair core/Gateway typechecks passed. Remaining lint found mechanical issues, now corrected, before the connection dropped. Lease is completed.tbx_01m45wyff3j2vrjwx14wrmnebe: all typechecks passed. The global dead-export check found two further inherited exports. Changed-file lint, architectural guards, and all 486 tests passed independently. A generated one-line stale-baseline prune was reviewed, then discarded when the same fix arrived on main. The lease was stopped and the branch rebased; its stable patch ID remains unchanged.tbx_01m460eqenqkk9rpamg4temkg6: lease disappeared while queued after more than an hour; no validation command ran. Cleanup completed.tbx_01m464c2q8s0vt5s8abh7mzh9q: final-head changed-file runtime checks passed 49 tests; max-lines, changed-file lint and architectural guards passed. Lease stopped. The dead-export guard failed with the same findings reproduced in a clean worktree at untouched base223f6e441ecb9bb80bbd80d885997a8ecc7270db.node scripts/check-changed.mjs --stagedon an index verified byte-for-byte against head86c5cc0cd38bfcc4833e4015496209d5ba96aed4; 25 checks passed, inherited export scan failed (exit 1). No guard was skipped.No production database was copied or mutated, and no live Gateway deployment is included.
Linux rig static-gate summary for prior head 86c5cc0