Skip to content

perf(sessions): reuse transcript admission and projection facts - #169523

Merged
steipete merged 12 commits into
mainfrom
dbasync/t1cut-s8
Oct 12, 2026
Merged

steipete merged 12 commits into
mainfrom
dbasync/t1cut-s8

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Transcript context, search, and rebuild paths repeat reads of facts already owned by the Gateway. The bundled memory visibility loader also enters the synchronous session-store path.

User Impact

No configuration or storage-format change. Bundled memory visibility loads the complete cross-session view through the existing worker. The public synchronous loader remains compatible, emits a bounded deprecation warning, and is scheduled for removal in the next SDK major; its replacement is loadCombinedSessionStoreForGatewayAsync.

Design

Use committed admission receipts for transcript bounds, return the completed search snapshot with projection readiness, and stop recounting/rechecking acknowledged rebuild work. Final publication retains source validation and bounded append catch-up. SQL projections that avoid materializing large payloads remain in SQL.

Removed checks and accepted edges:

  • Admission identity/role/generation reread: direct SQLite edits outside the Gateway owner are unsupported; the admission receipt supplies committed bounds. Store/session/user-role validation and effect-boundary authority remain.
  • Search connection revision reread: an append racing a completed search appears on the next search.
  • Rebuild claim source/clean-index rereads: stale prepared work can temporarily dirty a derived index before final publication rejects it.
  • Rebuild chunk recount/classification reread: acknowledged chunks are authoritative; final source validation remains.

Native-incognito paths remain for the separate incognito-removal migration. Deprecated public synchronous contracts and explicit offline maintenance remain honestly classified. Follow-up target/caller cutovers are being shipped separately; this PR does not claim the entire lane is at zero.

Evidence

  • Two Codex autoreview rounds completed without actionable findings.
  • Before the testing-policy change: 28 focused suites / 402 tests passed. These cover admitted context, append catch-up, complete async projection fields, incognito exclusion, and zero caller-thread SQL in the async SDK loader. The last changed/mock-consumer batch passed 75 tests in 646.8 seconds.
  • Local changed-file oxfmt, oxlint, and git diff --check pass.
  • Ordinary PR CI run 38213044338 passed at d23ecfbd6fe8691909e8c25445df2258de353106, including the repaired built lifecycle fixture. Static CI run 38214212751 passed production/full Knip export scans, all types/lint, source contracts and ratchets; SDK API diff passed (base 4de0aa670075, head d23ecfbd6fe8, acknowledgement 99e4d8f2). Its unused-file check found two unrelated script entrypoints; main removed both in 3a20164800a9, now incorporated conflict-free in 91338fabd80f7. Final static run 38217360424 passed types, lint, source contracts, database ratchets and SDK diff (digest 5ff6265e); it tests byte-identical PR1 source files as part of child head 3254d6171c275. Madge reports zero cycles. Knip fails identically on main run 38216343022 in untouched UI exports ComposerRunStatusContent and ChatPaneVersionsMenu; this is an inherited static failure. Final PR1 ordinary CI 38221257521 at 1dcc93a2641d5 fails only the untouched stale-version actor test, whose implementation came from main perf(sessions): skip snapshot reads for prepared appends #169651. These failures use the authorized inherited-failure landing route.
  • Owned lexical T1 sites: 27 → 23 (read fence 1 → 0, rebuild 12 → 10, search 4 → 3). These are source sites, not per-turn statements.
  • Two live alternating baseline/candidate pairs completed (the v6 pair plus the RAW TURN INCREASE follow-up). Source base 403e966fa7814238ad9fb67bc93641a59b04af1e, candidate 95d395c19a94e5781df0f3d2827f944aef462288; later changes are CI test-fixture repairs and conflict-free main integration. Shared workload is unchanged; temporary state is isolated on external storage.
Metric Base median [min–max] Candidate median [min–max]
Warmed all-thread statements/turn 350.45 [348.2–352.7] 340.15 [323.1–357.2]
Warmed requests/turn 107.4 [107.2–107.6] 104.9 [98.9–110.9]
Warmed MAIN statements/turn 0.3 [0.2–0.4] 0.1 [0–0.2]
Whole-workload statements 9,968.5 [9,941–9,996] 9,920.5 [9,633–10,208]
Whole-workload requests 2,070.5 [2,046–2,095] 2,052 [1,950–2,154]

The first pair increased whole-workload statements/requests by 267/108; the follow-up decreased them by 363/145, satisfying the RAW TURN INCREASE lower-total condition. Warmed transcript publication remains exactly 27 statements / 7 requests per turn in all four runs. Whole-workload transcript publication was 478/103 → 478/103, then 477/102 → 478/103; Memory publication was 451/113 → 492/128, then 605/153 → 297/77; model context was 27/5 → 49/8, then 29/5 → 34/6. The trace shows existing context fallback after Memory writes but does not identify the failed fallback predicate.

Host load and background work varied substantially, so these results do not establish a causal SQL saving or runtime speedup. Warmed candidate/base duration ratios were 1.328 and 0.212. All four runs completed 13 turns, child execution, cron, compaction and shutdown. The first candidate's optional mentions.dismiss returned UNAVAILABLE before mention SQL; every RPC passed in both follow-up runs. That first sample is not claimed as entirely green.

  • Broad CI also exposed two stale fixtures, now corrected: the memory-flush test asserting the removed source reread is deleted, and the cursor fixture awaits the existing projection reconciliation before checking replacement identity.
  • Update cell is not applicable: no update, Doctor, schema/migration, plugin-loading, or service-lifecycle change.
  • Diff against integrated main: 32 files, +279 / −539 lines.

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.
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core agents Agent runtime and tooling extensions: memory-wiki size: L labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR reuses transcript admission and projection facts and moves bundled memory session-store reads onto database workers.

Example: A message containing 'needle' is appended while a completed search awaits projection readiness.

  • Before: The changed connection revision can make the search report indexing.
  • After: The completed snapshot is returned, and the appended message appears on the next search.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Reported runtime workloads provide limited confidence, but the confirmed admission regression prevents merge.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; its body reports alternating live Gateway workloads, while the inspected predecessor screenshots do not prove this change or a causal performance gain.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Transcript preparation and bundled memory visibility repeat database work that can occupy the Gateway thread.
Reason: The maintainer-authored direction reuses existing owners, retains public SDK compatibility, and explicitly records its search and rebuild tradeoffs.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this useful, maintainer-authored optimization still has an unfixed context-admission regression that blocks merge.

Priority: P2
Reviewed head: 91338fabd80f7a0970bfed836d8200c3785afa50

Before merge

  • Preserve admission freshness at final context acceptance (P1) - This prior finding remains unfixed. Start SessionManager.openModelContextAsync on the supported native-incognito path with the admission for user message 'current', remove that message through SessionManager, and append 'replacement' before acceptance. Returning the saved receipt makes validateSessionTranscriptContextInDatabase take its admission branch and skip validateContextVersion, accepting detached context despite removal of its input and a changed generation. captureNativeContextOwner checks only the database handle, and this PR removes the native-incognito rewrite regression parameter. Keep receipt bounds for preparation, validate current membership and generation at final acceptance, and continue allowing ordinary later appends.

Findings

  • [P1] Preserve admission freshness at final context acceptance — src/config/sessions/session-transcript-read-fence.ts:165-168

Tests

  • Missing end-to-end proof: The reported live workload does not exercise removed-admission rejection; restore the native-incognito rewrite case and preserve the worker-turn boundary regression.
Agent review details

How this fits together

Session context and memory consumers read per-agent SQLite stores through database workers, while projection maintenance owns derived history and search indexes.

flowchart TD
  A[Session and memory consumers] --> B[Transcript read owners]
  B --> C[Database workers]
  C --> D[Agent SQLite store]
  D --> E[Projection maintenance]
  E --> F[Context and search results]
Loading

Technical review

Best possible solution:

Reuse receipt bounds during preparation while validating current admitted-message membership and generation at final context acceptance.

Do we have a high-confidence way to reproduce the issue?

Source establishes the final-acceptance regression, corroborated by the prior-head removed-admission boundary failure; this read-only review executed no target code.

Is this the best way to solve the issue?

Reusing owner-published facts is appropriate, but preparation receipts cannot replace final validation after supported transcript rewrites.

Full review comments:

  • [P1] Preserve admission freshness at final context acceptance — src/config/sessions/session-transcript-read-fence.ts:165-168
    This prior finding remains unfixed. Start SessionManager.openModelContextAsync on the supported native-incognito path with the admission for user message 'current', remove that message through SessionManager, and append 'replacement' before acceptance. Returning the saved receipt makes validateSessionTranscriptContextInDatabase take its admission branch and skip validateContextVersion, accepting detached context despite removal of its input and a changed generation. captureNativeContextOwner checks only the database handle, and this PR removes the native-incognito rewrite regression parameter. Keep receipt bounds for preparation, validate current membership and generation at final acceptance, and continue allowing ordinary later appends.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9a1b712a9b80.

Provenance checked

  • Transcript admission validation changes intended behavior with a stated reason (5621979: The original admission fence preserves canonical admitted-turn identity; this PR explains trusting committed bounds, but supported owner rewrites still invalidate the admitted input.)
  • Search snapshot freshness changes intended behavior with a stated reason (6fdc930: fix: keep session search parallel with accurate indexing #167163 retained connection-local freshness while restoring parallel foreground searches; this PR expressly accepts append visibility on the next search.)
  • Projection claim and finalization changes intended behavior with a stated reason (3c9a40a: fix(sessions): converge projections during active writes #142018 introduced bounded append catch-up and unsafe-source rejection; final source validation and chunk ownership remain while acknowledged chunks replace recounting.)
  • Complete plugin session entries keeps the original intent (1e5ebed: fix(gateway): reduce memory growth during session lookups #140499 deliberately retained full entries for the published plugin helper; both loaders preserve that projection.)
  • Lifecycle proof cancellation keeps the original intent (8ba18cf: Earlier proof repairs recognized terminal deletion cancellation while requiring endedAt; the added canonical AbortError case retains that termination requirement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/sessions/session-manager-model-context.test.ts --maxWorkers=1
  • pnpm test src/config/sessions/session-transcript-context-read.worker.test.ts --maxWorkers=1
  • pnpm test src/gateway/worker-environments/worker-turn-detached-context.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7d71d7c adds src/config/sessions/session-transcript-projection-rebuild.ts:404 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7d71d7cf6b3c; files: src/config/sessions/session-transcript-projection-rebuild.ts)
  • Vito Cappello: Raw commit 5621979 adds src/config/sessions/session-transcript-read-fence.ts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5621979a469a; files: src/config/sessions/session-transcript-read-fence.ts)
  • Shakker: Raw commit 6fdc930 adds src/config/sessions/session-transcript.worker.ts:117 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6fdc93078732; files: src/config/sessions/session-transcript.worker.ts)
  • Dallin Romney: Raw commit 3c9a40a adds src/config/sessions/session-transcript-projection-rebuild.ts:651 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3c9a40aae8da; files: src/config/sessions/session-transcript-projection-rebuild.ts)

PR surface

Source -112, Tests -151, Docs +22. Total -241 across 30 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 78 190 -112
Tests 19 178 329 -151
Docs 2 22 0 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 30 278 519 -241

Review metrics

Metric Value Why it matters
SDK compatibility window One async loader added; synchronous loader retained and deprecated Installed plugins retain complete entries through the documented next-major window.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a performance improvement with an introduced blocker, without evidence of a current-main outage.
  • merge-risk: 🚨 compatibility: The public SDK gains an async companion and deprecates its synchronous loader under an explicitly preserved compatibility window.
  • merge-risk: 🚨 session-state: Detached context can be accepted after its admitted input is removed through the supported session owner.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-12T02:32:58.470Z sha 5f19cab :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T03:42:02.658Z sha be4afaf :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T04:14:48.519Z sha be4afaf :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T04:47:42.656Z sha 95d395c :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T05:55:58.817Z sha 215f0d1 :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T06:03:58.378Z sha 215f0d1 :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T07:00:57.336Z sha d23ecfb :: blocked before merge. :: [P1] Preserve admission freshness at final context acceptance
  • reviewed 2026-10-12T07:12:32.285Z sha d23ecfb :: needs changes before merge. :: [P1] Preserve admission freshness at final context acceptance

Reviewed October 12, 2026, 3:36 AM ET / 07:36 UTC (Revision 10).

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 12, 2026
@steipete
steipete merged commit 5aa61b5 into main Oct 12, 2026
135 of 138 checks passed
@steipete
steipete deleted the dbasync/t1cut-s8 branch October 12, 2026 08:16
steipete added a commit that referenced this pull request Oct 12, 2026
## 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 `04cfcd8e25871`; 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 #169523 is merged. This PR now targets main; the review diff contains only encoding changes and their fixture corrections.
steipete added a commit that referenced this pull request Oct 12, 2026
The cursor fixture starts a separate rebuild while transcript writes already schedule reconciliation, allowing a later rebuild to replace the expected stale-cursor error with a rebuilding error. Join the existing writer-owned reconciliation at both checkpoints. Preserve exact transcript, stale/foreign cursor and equal-length branch replacement assertions. Test-only: four lines added, four removed; no SDK API change.

The competing fixture rebuild predates the worker append migration. Reconcile changes in 5aa61b5 (#169523) exposed this ordering issue and added the second direct rebuild; automatic reconciliation already existed. This is source-supported attribution, not a bisected first-bad or sole culprit claim.

Validation: pnpm test src/plugin-sdk/session-transcript-runtime.test.ts --maxWorkers=1 passed 14/14 on composition b3c4dcb (450.21s runner, 752.61s wrapper), with a clean final checkout and no owned survivors. The exact changed file also passed 14/14 in CI run 38275924955. Codex scoped review found no actionable issue. V9 build, types, lint, dependencies, topology, contracts and baseline ratchets passed; the SDK API-report passed on V11 (run 38283393506, job 114926173322), with this test file unchanged. These results qualify the unchanged file in those compositions, not the whole current main head.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…claw#169523)

## What Problem This Solves

Transcript context, search, and rebuild paths repeat reads of facts already owned by the Gateway. The bundled memory visibility loader also enters the synchronous session-store path.

## User Impact

No configuration or storage-format change. Bundled memory visibility loads the complete cross-session view through the existing worker. The public synchronous loader remains compatible, emits a bounded deprecation warning, and is scheduled for removal in the next SDK major; its replacement is `loadCombinedSessionStoreForGatewayAsync`.

## Design

Use committed admission receipts for transcript bounds, return the completed search snapshot with projection readiness, and stop recounting/rechecking acknowledged rebuild work. Final publication retains source validation and bounded append catch-up. SQL projections that avoid materializing large payloads remain in SQL.

Removed checks and accepted edges:

- Admission identity/role/generation reread: direct SQLite edits outside the Gateway owner are unsupported; the admission receipt supplies committed bounds. Store/session/user-role validation and effect-boundary authority remain.
- Search connection revision reread: an append racing a completed search appears on the next search.
- Rebuild claim source/clean-index rereads: stale prepared work can temporarily dirty a derived index before final publication rejects it.
- Rebuild chunk recount/classification reread: acknowledged chunks are authoritative; final source validation remains.

Native-incognito paths remain for the separate incognito-removal migration. Deprecated public synchronous contracts and explicit offline maintenance remain honestly classified. Follow-up target/caller cutovers are being shipped separately; this PR does not claim the entire lane is at zero.

## Evidence

- Two Codex autoreview rounds completed without actionable findings.
- Before the testing-policy change: 28 focused suites / 402 tests passed. These cover admitted context, append catch-up, complete async projection fields, incognito exclusion, and zero caller-thread SQL in the async SDK loader. The last changed/mock-consumer batch passed 75 tests in 646.8 seconds.
- Local changed-file oxfmt, oxlint, and `git diff --check` pass.
- Ordinary PR CI run 38213044338 passed at `d23ecfbd6fe8691909e8c25445df2258de353106`, including the repaired built lifecycle fixture. Static CI run 38214212751 passed production/full Knip export scans, all types/lint, source contracts and ratchets; SDK API diff passed (base `10f79e8d1c24`, head `d23ecfbd6fe8`, acknowledgement `99e4d8f2`). Its unused-file check found two unrelated script entrypoints; main removed both in `07389389f157`, now incorporated conflict-free in `91338fabd80f7`. Final static run 38217360424 passed types, lint, source contracts, database ratchets and SDK diff (digest `5ff6265e`); it tests byte-identical PR1 source files as part of child head `3254d6171c275`. Madge reports zero cycles. Knip fails identically on main run 38216343022 in untouched UI exports `ComposerRunStatusContent` and `ChatPaneVersionsMenu`; this is an inherited static failure. Final PR1 ordinary CI 38221257521 at `1dcc93a2641d5` fails only the untouched stale-version actor test, whose implementation came from main openclaw#169651. These failures use the authorized inherited-failure landing route.
- Owned lexical T1 sites: **27 → 23** (read fence 1 → 0, rebuild 12 → 10, search 4 → 3). These are source sites, not per-turn statements.
- Two live alternating baseline/candidate pairs completed (the v6 pair plus the RAW TURN INCREASE follow-up). Source base `07df9bd4b780ddacbd23bcf76cd5fd19814c5819`, candidate `95d395c19a94e5781df0f3d2827f944aef462288`; later changes are CI test-fixture repairs and conflict-free main integration. Shared workload is unchanged; temporary state is isolated on external storage.

| Metric | Base median [min–max] | Candidate median [min–max] |
| --- | ---: | ---: |
| Warmed all-thread statements/turn | 350.45 [348.2–352.7] | 340.15 [323.1–357.2] |
| Warmed requests/turn | 107.4 [107.2–107.6] | 104.9 [98.9–110.9] |
| Warmed MAIN statements/turn | 0.3 [0.2–0.4] | 0.1 [0–0.2] |
| Whole-workload statements | 9,968.5 [9,941–9,996] | 9,920.5 [9,633–10,208] |
| Whole-workload requests | 2,070.5 [2,046–2,095] | 2,052 [1,950–2,154] |

The first pair increased whole-workload statements/requests by 267/108; the follow-up decreased them by 363/145, satisfying the RAW TURN INCREASE lower-total condition. Warmed transcript publication remains exactly 27 statements / 7 requests per turn in all four runs. Whole-workload transcript publication was 478/103 → 478/103, then 477/102 → 478/103; Memory publication was 451/113 → 492/128, then 605/153 → 297/77; model context was 27/5 → 49/8, then 29/5 → 34/6. The trace shows existing context fallback after Memory writes but does not identify the failed fallback predicate.

Host load and background work varied substantially, so these results do not establish a causal SQL saving or runtime speedup. Warmed candidate/base duration ratios were 1.328 and 0.212. All four runs completed 13 turns, child execution, cron, compaction and shutdown. The first candidate's optional `mentions.dismiss` returned UNAVAILABLE before mention SQL; every RPC passed in both follow-up runs. That first sample is not claimed as entirely green.

- Broad CI also exposed two stale fixtures, now corrected: the memory-flush test asserting the removed source reread is deleted, and the cursor fixture awaits the existing projection reconciliation before checking replacement identity.
- Update cell is not applicable: no update, Doctor, schema/migration, plugin-loading, or service-lifecycle change.
- Diff against integrated main: **32 files, +279 / −539 lines**.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
## 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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
The cursor fixture starts a separate rebuild while transcript writes already schedule reconciliation, allowing a later rebuild to replace the expected stale-cursor error with a rebuilding error. Join the existing writer-owned reconciliation at both checkpoints. Preserve exact transcript, stale/foreign cursor and equal-length branch replacement assertions. Test-only: four lines added, four removed; no SDK API change.

The competing fixture rebuild predates the worker append migration. Reconcile changes in de750b9 (openclaw#169523) exposed this ordering issue and added the second direct rebuild; automatic reconciliation already existed. This is source-supported attribution, not a bisected first-bad or sole culprit claim.

Validation: pnpm test src/plugin-sdk/session-transcript-runtime.test.ts --maxWorkers=1 passed 14/14 on composition b3c4dcb (450.21s runner, 752.61s wrapper), with a clean final checkout and no owned survivors. The exact changed file also passed 14/14 in CI run 38275924955. Codex scoped review found no actionable issue. V9 build, types, lint, dependencies, topology, contracts and baseline ratchets passed; the SDK API-report passed on V11 (run 38283393506, job 114926173322), with this test file unchanged. These results qualify the unchanged file in those compositions, not the whole current main head.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: memory-core Extension: memory-core extensions: memory-wiki gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant