Repository navigation
perf(sessions): reuse admitted transcript encoding - #169624
Conversation
Use committed admission bounds, remove duplicate projection and search revision reads, and migrate bundled memory search to the async combined-store SDK loader. Preserve final projection source validation, chunk ownership, and account authority checks.
…t1cut-s8-encoding
…t1cut-s8-encoding
…t1cut-s8-encoding
|
🦞👀 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 changesThis PR records SQLite text encoding during database admission and reuses it when preparing transcript payloads. Example: Save a 7 KiB transcript event to an admitted UTF-16le database.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this useful maintainer-authored optimization open. Prior fixture findings are resolved, and no introduced correctness or security defect remains; current-head CI is still running with an unrelated tooling inventory failure. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherPhysical-database admission publishes schema facts to handles and workers; transcript preparation consumes encoding to select identity text or compressed UTF-8 storage. flowchart TD
A[SQLite database] --> B[Schema admission]
B --> C[Published encoding facts]
C --> D[Handles and workers]
D --> E[Transcript preparation]
E --> F[Identity or compressed payload]
Technical reviewBest possible solution: Keep encoding with the existing physical-database admission owner while preserving encoding-specific transcript bytes. Do we have a high-confidence way to reproduce the issue? Current main directly shows first-use encoding SQL on each handle; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? The existing admission owner is the appropriate place for immutable encoding metadata, and the explicit migration argument preserves preparation before admission completes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2b4c2a10bb41. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +11, Tests +47, Docs +8. Total +66 across 20 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 (5 earlier review cycles)
Reviewed October 12, 2026, 4:31 AM ET / 08:31 UTC (Revision 6). |
…t1cut-s8-encoding
# Conflicts: # src/infra/sqlite-schema-facts.native.test.ts
…t1cut-s8-encoding # Conflicts: # src/gateway/managed-image-attachments.sqlite-visibility.test.ts
## What Problem This Solves Transcript payload preparation discovers database text encoding with synchronous SQL on the caller thread. SQLite encoding is immutable after schema creation and belongs with the database's admitted facts. ## Design Capture encoding with admitted schema facts and transfer it through the existing worker admission contract. Payload preparation consumes the admitted value. Pre-admission migration uses the shared native metadata helper. The old per-handle encoding cache and repeated SQL read are removed. UTF-8 and UTF-16 payload behavior is preserved. There is no stored-format, retention, or schema-version change. Boot admission and explicit pre-admission migration metadata reads remain permitted native work. Removed check and accepted edge: payload preparation trusts admission's encoding; replacing a database outside the Gateway owner's lifecycle is unsupported. ## Evidence - Two Codex review rounds completed with no actionable P0/P1 findings. - Changed-file oxfmt, oxlint and `git diff --check` pass. Broad checks run in PR CI under RELAXED TESTING v6. - First CI found raw test handles missing schema admission, the historical schema-read count missing the new encoding field, and a cold-writer fixture that incorrectly warmed its database before exercising discovery. These fixtures are corrected; their data, snapshot and lost-write assertions remain intact. The later full CI found the same missing admission on the competing media writer; that fixture now opens through the tracked native owner and admits before the snapshot exercise. - Owned lexical T1 sites: **23 → 22**; the removed payload encoding query is one source site. Boot admission/migration metadata reads are explicit exceptions. - One live baseline/candidate pair completed: base `d23ecfbd6fe8691909e8c25445df2258de353106`, candidate `5ec1a5d67afa2bb4f70ae56d8d1e369efaa6f224`. Later changes are test-only fixes and conflict-free integration. Both runs completed all 13 turns, child execution, every RPC, cron, compaction, and shutdown. | Metric | Base | Candidate | | --- | ---: | ---: | | Warmed all-thread statements/turn | 343.6 | 333.2 | | Warmed requests/turn | 105.4 | 101.7 | | Warmed MAIN statements/turn | 0.4 | 0 | | Whole-workload statements | 9,607 | 9,653 (+0.48%) | | Whole-workload requests | 1,942 | 1,943 (+0.05%) | | Whole-workload MAIN statements | 1,988 | 1,990 | The payload encoding SELECT ran 3 times on the base and 0 on the candidate. Shared admission added 16 encoding reads (4 boot, 7 connect, 5 first-turn startup); 2 were permitted MAIN boot reads and 14 ran in workers/helpers. Net: **+13 cold statements, no new requests, no new warmed reads**. The whole-workload increase is within the T1 MOVE exception with warmed counts lower. The remaining variation comes from unchanged background owners; no causal warmed saving or runtime speedup is claimed. Warmed duration ratio was 0.943. - Published-driver × candidate update cell passed in combined CI 38217360424, job 114712232724: published driver `2026.10.2` updated to candidate `3254d6171c275`, then readiness returned 200 and the running version matched. Later changes are test-only. [Update artifact](https://github.com/openclaw/openclaw/actions/runs/38217360424/artifacts/11734172334). It is required because this changes migration implementation, despite preserving storage format and version. - Final static CI 38217360424 passed types, lint, source contracts, database ratchets, SDK API diff (digest `5ff6265e`) and Madge. Knip reports the exact same untouched UI exports as main run 38216343022; it is inherited. SDK surface check and runtime API guardrail tests passed on the earlier measured head `95d395c19a94`; the lane inputs for both checks remain unchanged, so that proof is reused. - Integrated-head CI [38223201252](https://github.com/openclaw/openclaw/actions/runs/38223201252), at `4faaed07c01bb`, passed production/test types, lint, source contracts, Madge, and database/worker/dialect ratchets. Its one failed test root is the inherited type-suppression inventory assertion (18 expected, 19 actual): main added the annotation in `scripts/lib/managed-cleanup-handoff.mts` at `2efdcb956c136`; both the script and test are byte-identical on the integrated main and PR head. Security-sensitive review and dependency review are green. The authorized inherited-failure landing route applies. - Knip reuse: main scheduled run [38220958692](https://github.com/openclaw/openclaw/actions/runs/38220958692), job `114717131950`, reports the same `renderPublicSessionCardSvg` unused export. This PR changes neither that owner nor its consumers or Knip configuration; its only new production export, `readSqliteTextEncoding`, is used by the migrated payload and migration readers. The later combined child scan also reports the inherited `gateway-prewarm.mjs` unused file. These findings do not arise from the encoding-only diff. - Main integration at `4faaed07c01bb` preserves the exact encoding-only diff. The only conflict kept the two imports used by the admitted competing-writer fixture; local format/lint/diff checks pass. Earlier production, SDK and update proof remains applicable. - Current encoding-only diff against its parent: **20 files, +144 / −78 lines**. Parent openclaw#169523 is merged. This PR now targets main; the review diff contains only encoding changes and their fixture corrections.
What Problem This Solves
Transcript payload preparation discovers database text encoding with synchronous SQL on the caller thread. SQLite encoding is immutable after schema creation and belongs with the database's admitted facts.
Design
Capture encoding with admitted schema facts and transfer it through the existing worker admission contract. Payload preparation consumes the admitted value. Pre-admission migration uses the shared native metadata helper. The old per-handle encoding cache and repeated SQL read are removed.
UTF-8 and UTF-16 payload behavior is preserved. There is no stored-format, retention, or schema-version change. Boot admission and explicit pre-admission migration metadata reads remain permitted native work.
Removed check and accepted edge: payload preparation trusts admission's encoding; replacing a database outside the Gateway owner's lifecycle is unsupported.
Evidence
git diff --checkpass. Broad checks run in PR CI under RELAXED TESTING v6.d23ecfbd6fe8691909e8c25445df2258de353106, candidate5ec1a5d67afa2bb4f70ae56d8d1e369efaa6f224. Later changes are test-only fixes and conflict-free integration. Both runs completed all 13 turns, child execution, every RPC, cron, compaction, and shutdown.The payload encoding SELECT ran 3 times on the base and 0 on the candidate. Shared admission added 16 encoding reads (4 boot, 7 connect, 5 first-turn startup); 2 were permitted MAIN boot reads and 14 ran in workers/helpers. Net: +13 cold statements, no new requests, no new warmed reads. The whole-workload increase is within the T1 MOVE exception with warmed counts lower. The remaining variation comes from unchanged background owners; no causal warmed saving or runtime speedup is claimed. Warmed duration ratio was 0.943.
2026.10.2updated to candidate3254d6171c275, then readiness returned 200 and the running version matched. Later changes are test-only. Update artifact. It is required because this changes migration implementation, despite preserving storage format and version.5ff6265e) and Madge. Knip reports the exact same untouched UI exports as main run 38216343022; it is inherited. SDK surface check and runtime API guardrail tests passed on the earlier measured head95d395c19a94; the lane inputs for both checks remain unchanged, so that proof is reused.4faaed07c01bb, passed production/test types, lint, source contracts, Madge, and database/worker/dialect ratchets. Its one failed test root is the inherited type-suppression inventory assertion (18 expected, 19 actual): main added the annotation inscripts/lib/managed-cleanup-handoff.mtsat04cfcd8e25871; both the script and test are byte-identical on the integrated main and PR head. Security-sensitive review and dependency review are green. The authorized inherited-failure landing route applies.114717131950, reports the samerenderPublicSessionCardSvgunused export. This PR changes neither that owner nor its consumers or Knip configuration; its only new production export,readSqliteTextEncoding, is used by the migrated payload and migration readers. The later combined child scan also reports the inheritedgateway-prewarm.mjsunused file. These findings do not arise from the encoding-only diff.4faaed07c01bbpreserves the exact encoding-only diff. The only conflict kept the two imports used by the admitted competing-writer fixture; local format/lint/diff checks pass. Earlier production, SDK and update proof remains applicable.Parent #169523 is merged. This PR now targets main; the review diff contains only encoding changes and their fixture corrections.