Repository navigation
perf(sessions): reuse revision-bound transcript projection status - #165377
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 real behavior proof before merge. Reviewed October 5, 2026, 5:29 PM ET / 21:29 UTC (Revision 12). ClawSweeper reviewWhat this changesThe PR makes transcript search and reconciliation reuse connection-local SQLite readiness facts, bounds projection maintenance, and preserves caller context during deferred worker opening. Merge readiness⛔ Blocked before merge - 6 items remain Keep open: current main still performs store-wide status scans, so the optimization remains useful, but this head is not merge-ready. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw derives searchable transcript projections from canonical session events. The projection maintenance owner repairs those derived rows, while search consumes readiness information to indicate whether results may still be indexing. flowchart TD
A[Session events and mutations] --> B[Projection maintenance owner]
B --> C[Revision-bound readiness facts]
C --> D{Clean revision?}
D -->|Yes| E[Transcript search results]
D -->|Unknown or dirty| F[Bounded reconciliation]
F --> B
F --> E
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +667, Tests +1016, Docs +32. Total +1715 across 43 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the bounded maintenance design, preserve the legacy SDK adapter type, and establish production-owner rejection at the native opening boundary. Do we have a high-confidence way to reproduce the issue? Yes, the SDK regression is source-reproducible: a run-and-close adapter accepted by v2026.9.8 cannot satisfy the branch's newly required methods. No code or tests were executed during this read-only review. Is this the best way to solve the issue? The maintained-facts approach fits the existing projection owner, but the public adapter type should remain compatible while the opener exposes richer methods separately. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0e54386a4634. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
cf97282 to
d58a1f0
Compare
Pull request was converted to draft
d58a1f0 to
dd09685
Compare
dd09685 to
fd6e5f8
Compare
Inject the synthetic deletion failure on the real SQLite worker connection with a TEMP trigger, preserving storage admission and planner schema cookies. Rename the private error constructor to avoid shadowing its exported binding. On base a9f4080, Testbox passed 277 focused tests and four regression negative controls on the exact tree.
Keep the legacy incognito handle fence at write execution so readiness can observe disposal and scheduled successors remain joined to old settlement. Narrow the memory publication consumer to the run/close contract it uses. Capture queued worker-opening assertions in their caller context, preserving live revocation before dispatch and native open grants. This fixes the lost startup preparation authority exposed by the projection queue changes. Validation: independent review is clean. The memory lifecycle and scheduling suites pass (33 tests), as does extension typechecking. The original Gateway shard failure and a diagnostic stack establish the queued-open defect; the unmodified base passes. Broker regression and fixed Gateway proof are pending Testbox sync recovery, with full validation tracked in the PR.
…equests Clean native orphan-only projections before reporting readiness. Coalesce requests only when they share caller authority, and separate native settlement from the public handoff promise so a canceled successor cannot drop prior work or create a promise cycle. Extend the existing memory and scheduling regressions for orphan-only stores, both cancellation arrival orders, and a canceled distinct memory successor. Independent P0-P2 review is clean; remote runtime proof is pending source-sync recovery and remains tracked in the draft PR.
Use the shared maintained facts to schedule store repair for dirty siblings while keeping search hits scoped. Carry bounded preflight and sweep work through actor reconciliation, and keep admission traversal in its existing maintenance owner. Preserve the reconciliation result type through cancellation settlement.
5502d95 to
9a52ae8
Compare
359eb9c (#165377) validates the search reader revision after checking index status. Releasing the status writer can close and checkpoint it before that validation, invalidating the search's own snapshot even when all transcript projections are complete. Real command-palette searches then show "Indexing older messages" for an already indexed corpus. Retain the canonical lazy execution across the hit read, status read, and revision validation. Release it after the history read settles. Preserve authorized read-only hits if maintenance admission fails, and keep the existing stale-snapshot and incognito handling. Remove the scoped-search fixture's artificial execution hold while keeping all assertions. Extend the worker availability check to cover early writer admission failure. The real-Gateway e2e file remains unchanged. Database work stays in its existing workers; no schema or stored-data change. Validation: unchanged real-Gateway file before fails, after passes with all 15 searches complete; seven scoped RPC cases and the worker safety case pass. Type-aware/boundary lint, core types, both changed-test type graphs, and independent P2 review pass. Testbox-congestion exception: the lease timed out after 15 minutes queued, before sync or execution. The authorized ready-PR fallback leaves Linux 3x e2e, owning configurations, whole architecture, and full check-changed unrun. This real-Gateway suite is hourly-only under current CI policy.
Transcript projection preflight now uses the canonical agent executor even for clean stores. The divergent secondary-agent scenarios reached real startup maintenance from Vitest threads, where the host-owner guard correctly refused admission. Route the unchanged suite through the existing isolated infrastructure forks. Keep all 13 cases and every assertion. Production startup already runs this path on the host; no runtime, schema, permission or timeout behavior changes. Validation: Linux admission 13/13; targeted routing 484 assertions; isolated tooling 367 assertions; lint, boundary lint, script types, check-changed, four real preflight manifest shapes, and P2 review passed. Broader Linux coverage: 40/49 normal CI groups and all 17 release-only tooling files passed. Nine groups remain unfinished after Testbox transport termination; AWS was refused by the shared fleet cap (21/20). Use the authorized ready-PR fallback. Refs #165377 and hourly 37382954831.
…enclaw#165377) * perf(sessions): reuse revision-bound transcript projection status Let the projection publication owner maintain transactional clean and pending facts, invalidate them on local and foreign mutations, and advance bounded orphan cleanup. Remove the recurring global status scans and pass the owner's worklist to reconciliation. Preserve search snapshot consistency, missing-store behavior, and committed results across continuation retirement. Clean reads avoid write grants. * test(sessions): isolate projection cleanup failure injection Inject the synthetic deletion failure on the real SQLite worker connection with a TEMP trigger, preserving storage admission and planner schema cookies. Rename the private error constructor to avoid shadowing its exported binding. On base 7a63692, Testbox passed 277 focused tests and four regression negative controls on the exact tree. * fix(sessions): preserve projection and worker admission custody Keep the legacy incognito handle fence at write execution so readiness can observe disposal and scheduled successors remain joined to old settlement. Narrow the memory publication consumer to the run/close contract it uses. Capture queued worker-opening assertions in their caller context, preserving live revocation before dispatch and native open grants. This fixes the lost startup preparation authority exposed by the projection queue changes. Validation: independent review is clean. The memory lifecycle and scheduling suites pass (33 tests), as does extension typechecking. The original Gateway shard failure and a diagnostic stack establish the queued-open defect; the unmodified base passes. Broker regression and fixed Gateway proof are pending Testbox sync recovery, with full validation tracked in the PR. * fix(sessions): retain orphan cleanup and independent reconciliation requests Clean native orphan-only projections before reporting readiness. Coalesce requests only when they share caller authority, and separate native settlement from the public handoff promise so a canceled successor cannot drop prior work or create a promise cycle. Extend the existing memory and scheduling regressions for orphan-only stores, both cancellation arrival orders, and a canceled distinct memory successor. Independent P0-P2 review is clean; remote runtime proof is pending source-sync recovery and remains tracked in the draft PR. * fix(sessions): retain actor projection maintenance status Use the shared maintained facts to schedule store repair for dirty siblings while keeping search hits scoped. Carry bounded preflight and sweep work through actor reconciliation, and keep admission traversal in its existing maintenance owner. Preserve the reconciliation result type through cancellation settlement. * test(gateway): retain settled writers in search scope fixture
…65879) 2eb7cdf (openclaw#165377) validates the search reader revision after checking index status. Releasing the status writer can close and checkpoint it before that validation, invalidating the search's own snapshot even when all transcript projections are complete. Real command-palette searches then show "Indexing older messages" for an already indexed corpus. Retain the canonical lazy execution across the hit read, status read, and revision validation. Release it after the history read settles. Preserve authorized read-only hits if maintenance admission fails, and keep the existing stale-snapshot and incognito handling. Remove the scoped-search fixture's artificial execution hold while keeping all assertions. Extend the worker availability check to cover early writer admission failure. The real-Gateway e2e file remains unchanged. Database work stays in its existing workers; no schema or stored-data change. Validation: unchanged real-Gateway file before fails, after passes with all 15 searches complete; seven scoped RPC cases and the worker safety case pass. Type-aware/boundary lint, core types, both changed-test type graphs, and independent P2 review pass. Testbox-congestion exception: the lease timed out after 15 minutes queued, before sync or execution. The authorized ready-PR fallback leaves Linux 3x e2e, owning configurations, whole architecture, and full check-changed unrun. This real-Gateway suite is hourly-only under current CI policy.
) Transcript projection preflight now uses the canonical agent executor even for clean stores. The divergent secondary-agent scenarios reached real startup maintenance from Vitest threads, where the host-owner guard correctly refused admission. Route the unchanged suite through the existing isolated infrastructure forks. Keep all 13 cases and every assertion. Production startup already runs this path on the host; no runtime, schema, permission or timeout behavior changes. Validation: Linux admission 13/13; targeted routing 484 assertions; isolated tooling 367 assertions; lint, boundary lint, script types, check-changed, four real preflight manifest shapes, and P2 review passed. Broader Linux coverage: 40/49 normal CI groups and all 17 release-only tooling files passed. Nine groups remain unfinished after Testbox transport termination; AWS was refused by the shared fleet cap (21/20). Use the authorized ready-PR fallback. Refs openclaw#165377 and hourly 37382954831.
Warm disk and actor projection status no longer walk the store to prove there is no work. The existing projection maintenance owner publishes connection-owned, revision-bound facts; status and search consume those facts and schedule bounded maintenance when the revision is unknown or dirty.
What Problem This Solves
A production census found three slow projection-status holds (4.787-second median, 4.916-second maximum) on a 36.88 GiB agent database. The census did not distinguish global from targeted requests. Global status scanned session windows and latest events, then performed negative orphan checks across active events, FTS identities and index state.
LIMIT 1did not bound a clean answer.The writer now classifies at most 128 candidate sessions and removes at most 512 orphan rows per projection table per transaction. Transactional TEMP facts retain pending sessions, admission progress and completed traversals. Clean reads need no writer transaction or commit grant. The recurring global read-worker scan and duplicate planner scan are removed; actor search uses the same owner so a dirty sibling still schedules store-wide repair while hits remain scoped.
PRAGMA data_versionobservation invalidates clean certification; bounded traversal retains progress under continued writes.Rollback restores source and tracking together. Reconciliation preserves cancellation, live actor authority, native settlement, and committed publication receipts. Moving these paths through queued worker admission exposed a lost async opening context; binding the captured assertion fixes startup without weakening live revocation. Independent requests retain their own cancellation custody.
Production LOC: +667 (1,039 added, 372 deleted), excluding tests/test-support/docs. This exceeds the shrink target: raw-write/savepoint correctness requires transactional tracking (347 lines), bounded foreign admission requires resumable traversal, and search must retain a reader-revision witness. The coordinator also preserves independent caller cancellation and the public read contract when maintenance is refused or its owner retires. The existing synchronous
appendSessionYieldContextSDK contract and native operator maintenance retain their native adapter; removing it requires a separate asynchronous SDK cutover. No config, persistent schema, retention, or upgrade behavior changes.Measurement
Linux rig, Node 26.8.1: 4,000 sessions; 2,000,000 rows each in transcript, active projection and FTS identity tables; 601 MiB. Baseline
989bd3f055fa343632957da15372886c65ee4be6includes ordered owner-set cleanup. The measured warm clean-status function is unchanged in the final candidate. The final rebase did not change the SQLite, schema-fact, or query-cache modules used by the harness.Seven baseline/100 candidate status samples; 500 append samples per side. The synthetic append transaction inserts transcript/active rows and updates index state; it omits FTS-content insertion. Its measured bookkeeping increase is about 52 µs. Complete production append latency remains unmeasured. Warm clean status is constant-time. The fixture omits full FTS content; transport/admission and production latency on the 37 GiB store remain unmeasured.
The admission cursor uses five ordered, covering-index seeks, each
LIMIT 1; its merge sorts at most five candidates:Per-session orphan cleanup uses indexed transcript existence checks and bounded deletes. Earlier bounded-admission measurements were 14.633 ms median/36.752 ms maximum; a late orphan was cleaned in 32 calls/660 ms despite foreign commits. Regression coverage additionally exercises local/foreign churn, rollback/savepoints, schema invalidation and continued work after traversal completion.
Evidence
Production validation head
9a52ae80a00c93ed5dd5b822101e12d90e061286, basedd09da279cbdad3b6bf34a23220de3307079b80d, tree78527b9100b8e193ce5ec9c6f34b1e943973408f. The branch contains only lane commits. A conflict-free rebase incorporated the upstream export-guard fixesd5fbbe86and8ccf43d1(#165631); their files are outside this PR's diff.Production proof uses the authorized Hetzner fallback after Testbox queueing: lease
cbx_9cb8b61346f0, runrun_ffe39c124884b587d31335a19f7d8972, Node 24.21.0, pnpm 12.5.1, SQLite 3.53.4. The fresh PR checkout verifies the full tree, all 42 changed-file hashes, and absence of other tracked edits. No local suites, builds or typechecks ran.node --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mtsnode scripts/run-vitest.mjs <30 focused files> --maxWorkers=1(exact selection below)node scripts/run-vitest.mjs src/infra/sqlite-worker-broker-lifecycle.test.ts --maxWorkers=1node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts --maxWorkers=2 …node scripts/check-changed.mjs --staged --base dd09da279cbdad3b6bf34a23220de3307079b80dThe production suites total 397 tests in 38 files. Prior negative controls failed for their intended defects: lost opening context, orphan-only native state, and a live request dropped when its predecessor later cancels. Those repaired behaviors passed again on this head. Coverage includes rollback/savepoints, schema changes, foreign/local mutation progress, bounded orphan cleanup, actor dirty siblings and multi-batch admission, snapshot freshness, cancellation/native settlement, and clean reads without write grants.
The Gateway timeout reproduced in its original shard while the unmodified base passed. Diagnostic evidence identified the lost async opening context. The repaired original shard passes without increased timeouts or weaker assertions. Staged checks also caught the reconciliation line cap, an unbound result generic, and a fixture collector signature; the final code keeps backlog reads with the publication owner and uses the correctly typed result and collector. The shared-traversal regression remains unchanged.
Measured case time in the one-worker focused run: status facts 0.511 s; actor history 3.425 s; actor compute 17.155 s; native memory 5.289 s; continuation 14.506 s; scheduling 5.300 s; readiness 11.976 s; search 29.434 s; query plans 0.860 s. Worker publication, cancellation and snapshot guarantees need their real reader/writer boundary; fixtures are reused. Standalone broker wall time is recorded above; the aggregate wall time includes the selected owners' compilation and setup. All Node test shards, UI shards, build artifacts, and core test-type checks passed on the final head. Main CI is blocked by hosted-runner admission, as detailed below.
Final head
2b43ee3b745d62fc8cf6c815cc9897d10352c436adds only the five-store search fixture repair; production bytes are unchanged from the validated head above. SQLiteTRUNCATEcheckpoints can increment a reader'sdata_versionwithout changing rows. The native executor retains one idle writer; releasing other fixture writers caused those checkpoints during search, correctly invalidating its snapshot witness. The test now holds all five real writer owners through clean-status preparation and the unchanged response assertions, then releases them infinally. The production freshness fence is unchanged.Final fixture proof on Hetzner
cbx_ddaf3003ccb6, runrun_6cfdc203b03f321dd3c9861ac582bce0:node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-methods.config.ts src/gateway/server-methods/sessions-search-scope.test.ts --maxWorkers=1--maxWorkers=4node scripts/run-vitest.mjs src/config/sessions/session-transcript-search.worker.test.ts --maxWorkers=1node scripts/check-changed.mjs --stagedCI runner-admission blocker
Final-head CI run
37366923726passed its Node tests, UI tests, build, core test types and lint. Attempt 1 lost six jobs before execution; each had no runner and zero steps. GitHub reported: “The job was not acquired by Runner of type hosted even after multiple attempts.” The failed jobs were retried once without changing source or rerunning passing tests. Docs and extension lint passed on retry; attempt 2 again cancelledsecurity-fast,check-source-contracts,check-additional-boundaries, andcheck-prod-typesafter about 15 minutes, with no runner and zero executed steps.The required
openclaw/ci-gateis therefore blocked. CodeQL, workflow sanity, and PR automation also encountered hosted-runner admission failures. No further identical retry was submitted. The PR remains ready at2b43ee3b745d62fc8cf6c815cc9897d10352c436; these nonexecuted jobs need a retry when hosted-runner admission recovers. The remote full production gate and final staged fixture gate above both passed. All owned leases are released.Search-fixture diagnostic runs on Hetzner cbx_ddaf3003ccb6
run_282cfb284081b32c650ab9eb6674f5b4run_d23d2da898175dfcb141a13e77ffdac2run_f28d9027f26077a6725ea50b77d26946data_version.run_254e065a92bd5c33010db2b0e2983cd3run_e796065a2746f04c20d817310872486cTemporary diagnostic changes were restored. The final retained-owner candidate passed the complete focused validation above. The lease is released.
The original fixture failed both in CI run
37358853001and standalone with the sameindexingassertion. An unretained warmup attempt also failed. Diagnostic runs traced the revision change; one later diagnostic stopped before tests because its source hash no longer matched the edited fixture. All proof runs use normal sync and exact source checks. Earlier production validation remains applicable because the final repair is test-only.Validation attempts on Hetzner lease cbx_83e62537ed93
run_dacd1b2889e6e9226e0b6fb7f1aba24frun_631700a4bf164b1f9a8a1c43f3540cd6run_044932ba323a52a2939c306f994e7ec3curl 65); no validation ran. One fresh-checkout retry succeeded.run_5120afe7014695b4a126415f99e6b71arun_be53fbceceac2da519c33ee361537b60run_1a3cbcb07a21e59131304cb0f4744af8run_de31611d1eccf09277041e5bb074ae4drun_c94479b7e66d6538bc01cded7d642f9eAll runs used normal fresh-PR checkout; uncommitted candidates applied the intended local patch. No run bypassed sync. Final proof verifies full-tree identity, not just the published parent SHA.
Exact focused-suite selection
The Gateway selection is the original seven-file shard: