Skip to content

improve: reduce repeated transcript reads per chat turn - #167238

Merged
steipete merged 21 commits into
mainfrom
dbasync/tb4b
Oct 9, 2026
Merged

steipete merged 21 commits into
mainfrom
dbasync/tb4b

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Chat turns repeat transcript hydration, anchor lookup, and scalar metadata reads across preparation, replay, completion, and delivery. This continues the transcript budget work stacked on #166804.

User Impact

The same chat flow uses fewer SQLite statements and worker requests while preserving transcript bytes, generations, cursors, required-byte accounting, limits, and live-authority checks. No schema, durability, retention, permissions, or configuration migration changes.

Why This Change Was Made

Initial bounded hydration, replay acceptance, and physical message presence share the existing transcript cohort. Replay refreshes at synchronous prompt admission after hooks or compaction. Actual agent construction now carries the selected execution owner's context into bounded model-context preparation, without holding the writer queue across setup. Unbounded SDK reads still prepare outside the writer queue and validate freshly before consumption.

Hydration and delivery pass their current projection into anchor selection. One readiness query serves that pinned snapshot; standalone reads retain their checks. Foreign commits overlapping a bounded operation are observed on the next unpinned read. Source replacement, local native mutation, and live authority remain checked at synchronous acceptance.

Terminal consumers use immutable append receipts and the live assertion captured from the producer's original target. Downstream owners still validate the historical anchors. Activity summaries use the patch transaction's acknowledged watermark. Cold metadata joins initialization and turn preparation; the existing restoration owner runs outside the writer queue and before message hooks. Delivery selects visible payloads, anchors, tail, session identity, and watermark in one history snapshot.

Display policy loads before the synchronous snapshot. Legacy native payload reads capture their original database handle before that load and reject replacement. The resident presentation view never becomes authority.

The 65-file change has 720 net production/tooling lines, 1,129 net test/support lines, and 18 documentation lines. The production growth carries typed cohort facts and commit receipts through the existing owners, including durable and incognito adapters; the tests cover the removed reads at their freshness, authority, and delivery boundaries. It does not add another cache or execution owner.

Evidence

Warmed all-thread work falls 1,394.9 → 1,279.1 statements/turn (−115.8 / −8.30%), with MAIN unchanged at 28. First-turn work falls 4,323 → 4,205. Effective transcript cost falls 197 SQL / 18 requests → 80 / 4; the request target is met, while the 42-SQL target remains 38 statements away. These are fresh measurements against the pinned, unmerged parent f11440d855ba1b79b80223a80b38cc4c78592e2d, not current main.

Three alternating base/candidate pairs ran on one AWS Linux host with Node 24.21.0 and the unchanged shared workload. Values are side medians [min–max]; warmed values summarize ten-turn run means. Every gated duration ratio is ≤1.011. The original settling windows, helper threads, background work, and unassigned SQL remain included.

Phase ALL base → candidate MAIN base → candidate ALL delta Duration ratio
01.boot 2758 [2757–2761] → 2761 [2758–2761] 1868 [1868–1868] → 1868 [1868–1868] +3 0.994
01.connect 413 [405–431] → 420 [412–420] 66 [66–70] → 66 [66–66] +7 1.000
02.first-turn 4323 [4271–4334] → 4205 [4187–4206] 126 [124–126] → 126 [126–126] -118 0.991
03.warmed-mean 1394.9 [1394.8–1395.6] → 1279.1 [1278.3–1280.3] 28 [28–28] → 28 [28–28] -115.8 0.984
04.second-session 4897 [4896–4903] → 4607 [4604–4610] 148 [147–148] → 148 [147–148] -290 0.992
05.control-plane 51 [51–52] → 47 [47–51] 0 [0–0] → 0 [0–0] -4 1.001
06.cron 1386 [1386–1410] → 1358 [1348–1361] 50 [50–50] → 50 [50–50] -28 0.997
07.compaction 852 [852–856] → 840 [836–843] 44 [44–44] → 44 [44–44] -12 1.010
08.shutdown 1084 [1084–1097] → 1085 [1085–1089] 403 [403–403] → 403 [403–403] +1 0.983

Individual warmed turns retain their full range: base 1385–1417; candidate 1264–1305.

The separate diagnostic census reports 226 → 211.2 total worker requests per warmed turn. Its counts do not replace the three-pair statement medians. Every warmed request completed, zero SQL context rows are missing, and native counts reconcile exactly in every phase/thread. Both sides retain two unmatched boot-only protocol sends/receives.

Phase Requests base → candidate
01.boot 60 → 60
01.connect 56 → 56
02.first-turn 301 → 285
03.warmed-mean 226 → 211.2
04.second-session 714 → 679
05.control-plane 5 → 5
06.cron 193 → 188
07.compaction 93 → 89
08.shutdown 105 → 105

Requests are phase totals, except warmed is per turn. Second-session includes two top-level turns plus an awaited child: 357 → 339.5 requests per top-level turn.

Warmed read class Requests base → candidate SQL base → candidate
transcript-hydration 3 → 2 64 → 46
cold-metadata 4 → 0 8 → 0
current-turn-entry 1 → 0 13 → 0
model-context 1 → 1 13 → 13
transcript-anchors 4 → 1 46 → 18
transcript-maintenance 1 → 0 13 → 0
transcript-message-presence 1 → 0 9 → 0
history-page 1 → 0 12 → 0
transcript-watermark 1 → 0 5 → 0
session.entry.read 15 → 14 65.2 → 52.2

Direct combined transcript + actor reads fall 32 requests / 248.2 SQL → 18 / 129.2, removing 14 requests and 119 SQL. The removed 14-SQL actor validation had also cached canonical-key and participant facts. Those two required reads now occur in the next metadata append: the same two append requests cost 79 → 81 SQL/turn (first append 29 → 31, second 50 → 50). This induced write-side cost is charged to the change. The net attributed saving is 117 SQL and 14 requests per warmed turn.

The original exact actor allocation is 14 requests / 51.2 SQL (rounded to 51 in the parent PR). Full effective cost is 197 → 80 SQL and 18 → 4 requests: 77 transcript SQL + (52.2 − 51.2) actor SQL + (81 − 79) metadata-append SQL. The 4-request target is met; the 42-SQL target remains 38 statements away. The whole census falls 118 SQL and 14.8 requests/turn; the additional net 1 SQL / 0.8 request reduction is outside the directly attributed lane saving.

The same census conserves the affected read families and their induced metadata-append costs in every phase. This diagnostic table is separate from the ordinary-run median gate; other changes are reported but not claimed as this lane's savings. Boot, connect, control, and shutdown have zero change in the affected union.

Census phase Read SQL delta Induced metadata SQL Net affected SQL Net affected requests Other SQL / requests
02.first-turn -125 +2 -123 -15 -4 / -1
03.warmed-mean -119 +2 -117 -14 -1 / -0.8
04.second-session -282 +4 -278 -35 -8 / +0
06.cron -38 +0 -38 -5 +0 / +0
07.compaction -8 +0 -8 -4 +14 / +0

Shutdown has an additional unclaimed −3 SQL in the census; boot/connect/control are unchanged. Warmed values are per turn, other values are phase totals.

The relative statement gate passes. The three positive non-turn medians are each ≤10 statements and all their recorded owner source files are byte-identical to the base. Boot/connect have unchanged census request totals and no transcript-group requests. Per-group medians are not added together; the complete per-pair SQL/stack vectors reconcile to each phase delta.

Increasing phase Median delta Unchanged-owner attribution Per-pair phase deltas
Boot +3 State/config schema and content-version freshness; config-health/delivery startup timing. +4, +3, −3
Connect +7 Cron load/upsert/maintenance, deletion registry readiness, and their transaction/ownership envelopes. −11, +7, +7
Shutdown +1 WAL checkpoints, busy-timeout restoration, and read-owner retirement/freshness. +1, −12, +5
Combined window (reported for context) Pair 1 ALL Pair 2 ALL Pair 3 ALL Median ALL
boot+connect 3188 → 3181 3171 → 3181 3166 → 3170 3171 → 3181
boot+connect+first-turn 7459 → 7386 7494 → 7368 7500 → 7376 7494 → 7376
control+cron 1462 → 1399 1437 → 1408 1437 → 1405 1437 → 1405
compaction+shutdown 1940 → 1925 1949 → 1928 1936 → 1925 1940 → 1925

Remaining Transcript Budget

Remaining transcript cost is explicit:

Remaining history request Requests SQL Fact/payload reads Envelope/control statements
Initial hydration, replay, and physical message presence 1 26 17 9
Fresh hydration at prompt admission 1 20 13 7
Bounded model-context payload projection 1 13 6 7
Delivery payloads, current anchors, and watermark 1 18 11 7
History subtotal 4 77 47 30

The 30 envelope/control statements are 12 existing schema/role/version checks, eight data-version probes, eight BEGIN/COMMIT statements, and two quarantine-decision reads. They remain in the existing admission owners; step 5 owns the connection/schema envelope work. The two hydration calls are distinct fresh phases separated by preparation/hooks; model context retains different payload filters and byte limits, and delivery reads after the assistant commit. The resident presentation view supplies no authority.

The 42-statement allocation is not achieved. Even removing every envelope/control statement hypothetically would leave 47 history facts plus one incremental actor read and two induced write-side reads. Further work needs to compose the remaining history kernels as well as admission envelopes, preserving exact payload/size/branch semantics; these measurements do not establish that every remaining fact query is irreducible. The overall warmed turn also remains above the campaign's 500-statement goal.

Validation

Final commit: c7c5692d19a5c828a98ce89e972de528e5c81964.

SDK API comparison was inspected (digest 20408311): zero added/removed entrypoints, 137 changed export records (136 reachable-type changes and one direct signature change). The direct change adds the optional internal [completedTurnMessageAnchor] property to finalizeHarnessContextEngineTurn's turn candidate; existing arguments and return values remain compatible, and callers without receipts keep their fresh-read fallback. Reachable changes cover internal cohort/receipt types, moved patch types, SessionManager symbols, and declaration ordering. Neither new receipt symbol is promoted through an SDK barrel. The final render also compares against the measured candidate: all 130 affected direct declarations are identical; the only reachable declaration delta removes the unused internal SessionEntryPatchContext forwarder. The canonical type declaration and existing session-accessor export are unchanged.

Three baseline negative controls fail at the intended budget assertions: delivery uses three transcript requests instead of one; admitted model context records two queued requests instead of one; initial replay hydrates twice instead of once. The original private classifier qualified delivery but returned exit 1 for the other two because their captured source coordinates were redacted. Independent inspection verified the pinned baseline, all six test/support overlay hashes, the sole failing test in each JSON report, and the unique matching assertions. The redacted reports and failed classifier result are preserved; no sanitizer was bypassed and no test was rerun to obtain different output. All corresponding positive candidate suites passed.

Runtime proof passed 658 tests in 37 files: 267 cases across all 13 changed test files and 391 cases in 24 sibling files. Coverage includes foreign rewrites at acceptance, next-unpinned-read freshness, revoked/replaced owners, FIFO settlement, physical message presence on empty active branches, exact cold-restored bytes, bounded context limits, branch/reset generations, delivery visibility, and transaction receipt invalidation. All 16 native calibration streams produced 8 calls / 2 prepares / 7 statements / 0 failures. Every ordinary/census workload had zero native SQL failures and zero remaining fixture children.

The canonical package build passed in 419.6 seconds. Published [email protected] drove the candidate update cell successfully in 467.6 seconds (update operation 377.7 seconds): recorded completion, readiness 200, candidate build identity/version, durable history retained, incognito history cleared, and service cleanup all passed. The candidate retains package version 2026.9.8; the build identity and source manifest distinguish its bytes from the published driver.

The package build logged a nonfatal Control UI startup-JS gzip violation: 373,567 bytes versus the 373,454-byte limit (+113 bytes). Startup CSS was 50,749 bytes, above its 46,080-byte advisory target and below the 51,200-byte hard ceiling. UI source is unchanged; no baseline UI package build was run to attribute these notices.

For each changed file, the command was CI=1 pnpm test <file> --maxWorkers=1. These are measured AWS Linux CI-mode seconds, including preparation, not hosted GitHub Actions timings. The 13 commands total 777.94 seconds; the 24-file sibling group adds 295.60 seconds.

Changed test execution costs
File Passing cases pnpm wall seconds Vitest elapsed seconds
attempt-session-replay-cohort.test.ts 19 94.574 75.95
attempt-session-replay.test.ts 62 191.270 172.75
attempt-session-runtime-prepare.test.ts 12 26.789 24.25
agent-end-side-effects.test.ts 6 32.201 29.73
context-engine-turn-outbox.test.ts 15 42.777 40.35
session-manager-async-message.test.ts 17 26.560 24.10
session-manager-model-context-snapshot.test.ts 16 41.421 38.96
session-accessor.sqlite-entry-revalidation.test.ts 33 67.822 65.43
session-cold-storage.transcript-turn.test.ts 4 46.566 44.16
session-entry-cohort.worker.test.ts 1 22.780 4.01
session-transcript-anchor-read.worker.test.ts 11 33.535 31.15
chat-send-reply-dispatch.test.ts 45 67.687 49.02
session-activity-summaries.retry.test.ts 26 83.954 81.56

Final source validation: fresh independent Codex P2 review is scoped clean with no actionable findings. The complete pnpm check:changed passed on final source in 2,823.1 seconds, including core/script types, all 27 core-test type graphs, dead exports, all five core lint stripes, script lint, and database/runtime/account guards. Madge reports zero cycles; Knip, the database-worker no-T1-growth ratchet, wrapper inventory, formatting, and diff checks pass. Three max-lines warnings remain in byte-identical base files: src/agents/worktrees/service-preparation.ts, src/agents/tools/message-tool-execution.ts, and ui/src/components/session-organizer-operations.runtime.ts. No baseline or ignore exception was added.

The first changed-check found a test-only access to .id on an unknown persisted entry; it now uses the existing record helper, and all 15 outbox cases passed again (44.6 seconds). The next scan found an obsolete internal type forwarding export after its sole caller moved; that export is removed, and the canonical type and session-accessor export remain. The final complete check passes after both corrections.

Runtime, measurement, SDK, and packaged-update evidence binds the full source digest 0f5c2b1144cf4006cdba99615810318d3395d725edc1550ba37dbbc111b7c9bf. Final source digest 5f0f576934b421b4725fa6debb90b244f3ba1f56dd665f224286e64f2d0d5b38 differs only in that test narrowing and removal of the unused internal type-only forwarding export. Two verified single-file transitions reconstruct the exact original full digest; every other product file is byte-identical. Node TypeScript stripping confirms the changed type module has zero executable tokens before and after. The transitions and erasure are independently verified on the retained proof host; the final SDK comparison checks the declaration change. Measurements retain their original source pin.

Remote proof: runtime, measurements, and published-driver cell; final complete check and SDK comparison. Earlier aggregate failures retain the corrected test/type diagnostics and the negative-control classifier issue described above; the final follow-up exits 0. Both evidence archives and source transitions were hash-verified. The sole AWS lease was released and independently reports hasHost=false.

Scheduling included an approximately 48-minute proof-slot wait, a 15-minute Testbox admission timeout, and two AWS capacity refusals with 10/15-minute backoffs. All heavy work ran through the campaign proof-slot wrapper; the final runtime proof and static follow-ups reused one AWS lease. Historical candidate iterations are excluded from the tables above.

The parent has merged. Landing integrated main with a merge commit. The existing alternating-pair SQL proof is reused under the authorized landing policy; no new main-relative SQL measurement is claimed.

Landing integration

Integrated main 811d442afa2c1103ed10f33f3b64fb1afa7675f8 without rebasing in 3015123aab37d2d3192c3b1a96eadc9968ec9fb9. The landed parent's source was used to distinguish tb4b's own delta from squashed parent history. Resolution preserves main's runtime target mapping, live source checks, retention publication, and fused append metadata reads.

8185e1307d392a286e353ffc596d42a942f03eb8 repairs integration fixtures and guards: one anchor query execution site retains both SQL shapes; the unchanged incognito projection selector moves to a leaf module to keep the worker within its line limit. Source-loss tests now interrupt target preparation, Talk owns the first cold hydration, and delivery races occur before the combined authoritative snapshot. No assertion was weakened to obtain a pass. A transient incomplete test-variable rename was caught by local types/review and corrected before this push.

Fresh independent Codex P2 reviews are clean on the integrated source and final repairs. The released signatures were checked against v2026.10.1-beta.1 and stable v2026.9.9: existing calls remain compatible, the finalizer receipt remains optional, and the canonical session-accessor type export remains. The existing SDK diff report (digest 20408311) was inspected and retained as historical evidence; no new SDK surface is introduced by conflict resolution. Worker test routing and wrapper/import inventories were checked.

Landing validation: production types and all 27 core-test type graphs pass; the eight-file replay/cohort/entry/cold-storage/model-context batch passes 123 tests in 821.62 seconds. Original replay, delivery, activity-summary, runtime-process graph and eager-wrapper/import checks passed in the earlier integration batch. SQLite worker and line-cap ratchets pass. The final three-file preview/delivery/anchor batch passes 20 tests in 890.69 seconds on the loaded local host. The final local lint wrapper timed out while rebuilding SDK declarations on the loaded host, before lint ran; required CI lint remains the landing gate.

The earlier CI run 37868811397 exposed the fixed fixture/lint/SQL-site issues. Its Madge failure is independently present on main run 37868734021, job 113621794431: prepared-model-catalog-fingerprints.ts ↔ prepared-model-catalog-worker.ts; both files are untouched by tb4b. The registry failure in subagent-registry.persistence.test.ts occurs at completion-authority revalidation before terminal session effects and is unrelated to this delta; the entire registry tree is identical to the integrated baseline. Its exact race winner is not established. These remain inherited failures, not passing checks.

The integrated delta is 67 files: production/tooling +1,481/-747 (net +734), test/support +1,491/-337 (net +1,154), and docs +18. No new OPENCLAW_* variable names. Existing public SDK, storage, durability, and live-authority contracts are retained.

Final CI attempt 37871955941 is complete on 8185e1307d392a286e353ffc596d42a942f03eb8: 102 successful jobs, 23 skipped jobs, two inherited root failures and their aggregate failure; no cancellations. CI lint, production/test types, security-fast and repaired suites passed. In addition to the confirmed main Madge cycle, native-cancellation-authz.e2e.test.ts passes its assertions and then reports an unhandled OpenClaw state database read admission is closed rejection in detached subagent completion recovery. Its test, registry waiter/queue, state admission, and shutdown inputs are unchanged from the tested main parent; the rejection happens before any transcript work. The native admin evidence retains both failures, the complete job census, matching baseline proof and exact tested merge 211725224d42b58d50d62c7979c3058a00fda970. This is an explicitly authorized inherited-failure landing, not a claim of green CI.

Merge main at cbfbdc8 while retaining the selected session execution owner. Preserve transcriptOwner alongside the consolidated sessionPreparation input.

Seed the queued-reader freshness fixture through the existing synchronous writer so unrelated automatic maintenance cannot occupy its controlled race window. Preserve the original snapshot, queued-write, and event-order assertions.

The original head reproduced the fixture failure in all five runs; the merge base passed all five. A diagnostic proved that consumption preceded the queued write, and the corrected fixture passed all seven tests. Production and core test types, Madge, and independent P2 review passed on the integrated tree.
Merge main at e1dbb59 after #166698 landed. Keep the selected session execution and foreground fact implementation, and its freshness-fixture correction, unchanged while incorporating the canonical TEMP generation admission fix.

The integration required no conflict resolution or additional product changes. Fresh P2 review is clean; affected checks and alternating statement measurements remain required before landing.
Carry the admitted physical session owner into transcript preparation and
combine fresh bounded hydration with replay metadata under the existing
history reader. Combine delivery anchors and watermarks while preserving
source identity, synchronous consumption, and mutable SessionManager semantics.

Measured effective transcript work falls from 228 to 197 SQLite statements
and 25 to 18 logical requests per warmed turn, including incremental actor
work. Keep the remaining transcript composition budget for step 4b.
Merge main at 0abba2b while preserving both required-worker selection and the retained session reader.

Keep main's reply-input and classification helpers alongside the cohort fingerprint path. Reuse main's sessionTarget object while carrying the reader, lifecycle facts, abort check, and acknowledged initialization handoff through their existing owners.

Fresh independent P2 review found no actionable defects in the integrated tree. Exact-head runtime, SDK, CI, and statement proof remain landing gates.
Merge current main into the turn-budget step-one branch without rebasing.
Preserve main's native writer claim and empty-maintenance completion alongside
retained session-reader authority and the extracted preparation regressions.
Route the two model-selection consumers to the existing host-owned test
project after main moved placement reads to the shared-state worker.

The three missing-broker cases reproduce before the routing repair and pass
through the normal test router afterward. Post-integration production and
core test types pass; Madge reports no cycles. Fresh independent P2 review
found no actionable correctness findings.
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 8, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR combines conversation-history reads across chat preparation, replay, completion, and delivery, reuses committed message receipts, and incorporates separately landed export, catalog, and Tlon fixes.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The useful optimization has strong runtime evidence and focused invariant coverage, with no concrete patch finding identified.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Recorded AWS Gateway chat workloads exercise the changed history owners and show lower statement and request counts; packaged update evidence preserves durable history. Historical measurement pins and subsequent integration checks are distinguished, and source inspection confirms no stored-format migration. The prepared UI screenshots do not support the optimization claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Each chat turn performs repeated conversation-history database work.
Reason: Measured savings justify composing reads within the existing owners. Merged area history establishes the author's ownership and the accepted optimization direction.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this owner-authored PR provides a measured optimization that current main does not yet contain. No discrete actionable patch defect was identified in the inspected paths.

Priority: P2
Reviewed head: 8185e1307d392a286e353ffc596d42a942f03eb8

Before merge

  • Complete next step - Validate a merge with current main, preserving its session-reset and shared-state-reader changes.

Findings

None.

Provenance

  • Terminal context-engine and Skill Workshop consumers: original intent not found (unknown: Path history and the Skill Workshop introducing PR were inspected, but unavailable older blobs prevented establishing the exact introduction of the replaced terminal pre-read.)
  • Integrated meeting-export, catalog, and Tlon paths: original intent not found (unknown: The integrated changes match separately landed fixes on current main; available path history did not establish every original baseline implementation's rationale.)

Tests

  • Missing end-to-end proof: Validate the changed transcript paths on a merge with fetched current main; the supplied test merge uses an older main parent.
Agent review details

How this fits together

The Gateway loads saved conversation history before running an agent and checks committed messages before declaring reply delivery complete. These changes carry compatible history facts through the existing database workers while retaining session-owner checks.

flowchart TD
  A[Chat turn] --> B[Session preparation]
  B --> C[History worker snapshot]
  C --> D[Live owner and source checks]
  D --> E[Agent context and replay]
  E --> F[Committed message receipts]
  F --> G[Reply delivery and completion]
Loading

Technical review

Best possible solution:

Keep compatible reads composed within the existing history owners, with fresh prompt admission and live assertions at consumption and commit boundaries.

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

Not applicable as a bug reproduction: the PR optimizes existing behavior, and recorded paired Gateway workloads demonstrate the repeated-read cost and its reduction.

Is this the best way to solve the issue?

Yes: composing compatible reads and carrying immutable commit facts through existing owners avoids adding a competing cache or execution owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 608134ea54c3.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced source: The pinned merge-base-to-head delta adds combined hydration, synchronous bounded-context acceptance, terminal append receipts, and combined delivery inspection. (src/config/sessions/session-transcript-context-read.ts:224, 8185e1307d39)
  • Current-main necessity: Current main still lacks the synchronous bounded-context path and combined delivery snapshot. The merged prerequisite perf(sessions): coalesce transcript metadata reads (step 4a) #166804 explicitly leaves further transcript composition for this work. (src/gateway/server-methods/chat-send-reply-dispatch.ts:195, 8185e1307d39)
  • Feature history and routing: Main history repeatedly connects Peter Steinberger to transcript worker ownership, turn preparation, and anchor reads. The compound-turn commit records preservation of physical identity, current authority, publication, and FIFO ordering. (src/config/sessions/session-turn.ts, ca77256127e6)
  • Runtime and upgrade evidence: The complete REST-read PR body reports three alternating AWS Gateway workload pairs: warmed SQL falls from 1,394.9 to 1,279.1 statements per turn, with zero native SQL failures. It also records a published [email protected] update into the candidate with readiness, durable-history preservation, and incognito cleanup. Measurements retain their historical candidate pin; subsequent integration checks are separately identified. The supplied opening-body identity was SHA-256 f8eb17ff329d6162ccc2a726081b857a551178a31569e10af5f39b48efd264ee. (c7c5692d19a5)
  • Freshness and receipt semantics: Bounded context checks cancellation, live ownership, physical source, and native mutation before synchronous consumption. Terminal receipts retain the producer's assertion; callers without a receipt keep the fresh-read fallback. (src/agents/harness/context-engine-lifecycle.ts:391, 8185e1307d39)
  • Accepted consistency and SDK tradeoffs: The area owner's PR and documentation expressly define bounded snapshot acceptance with overlapping foreign commits observed on the next unpinned read. The body records stable and beta signature comparisons, an optional finalizer receipt, unchanged existing arguments and returns, and no added or removed SDK entrypoints. Public docs: docs/reference/database-schemas/worker-access.md. (docs/reference/database-schemas/worker-access.md:408, 8185e1307d39)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Warmed chat SQL 1,394.9 → 1,279.1 statements per turn; −8.30% Three alternating workload pairs demonstrate the optimization against its pinned parent, without claiming a current-main comparison.
Effective transcript requests 18 → 4 requests per warmed turn The recorded census includes induced write-side costs and reaches the stated request budget.

Labels

Label changes:

  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a measured internal performance improvement with bounded user impact.
  • merge-risk: 🚨 compatibility: Reader-consistency and SDK-reachable contracts are compatibility-sensitive; the area owner explicitly documents snapshot semantics and preservation of existing released calls.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-08T13:02:55.126Z sha c7c5692 :: blocked before merge. :: none
  • reviewed 2026-10-09T00:50:06.780Z sha c7c5692 :: blocked before merge. :: none
  • reviewed 2026-10-09T01:23:52.587Z sha 3015123 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T02:06:28.702Z sha 8185e13 :: needs maintainer review before merge. :: none

Reviewed October 8, 2026, 10:33 PM ET / October 9, 2026, 02:33 UTC (Revision 5).

Base automatically changed from dbasync/tb4transcript to main October 9, 2026 00:42
…#167532)

* perf(transcripts): stream meeting exports through the read worker

Keep one snapshot across bounded export chunks and join asynchronous consumers before releasing reader custody. Replace repeated artifact batch queries with a fixed-head cursor and retain live lease checks at guarded file publication.

* refactor(state): share bounded stream read dispatch

Keep subagent restore and meeting transcript streaming inside the existing native section while moving their reply adapters out of the main dispatcher. Correct Promise executor and synchronous-read test lint violations.

* fix(transcripts): preserve shared export path permissions

Reuse the output writer’s compatible temporary-file owner while retaining guarded publication. Keep exports working beneath group-writable ancestors and exercise that contract in the existing artifact test.
ly85206559 and others added 3 commits October 8, 2026 17:47
Keep the full destination for Tlon Markdown links and images whose URL contains balanced parentheses (for example Wikipedia `Function_(mathematics)`), instead of cutting the href at the first `)`. Ordinary links, bare URLs and parenthesized text are unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
Await startup catalog publication before measuring explicit refresh requests. Assert the exact startup count and subsequent provider order independently, without polling, retries, or relaxed assertions. Fixes the fixture's double count exposed by b05104a; reproduced on pristine latest-main and repaired remotely.

(cherry picked from commit dae5077c64dae94e370098636755272f0b50d33b)
Carry the committed shared-store location with prepared catalog input and include it in generation identity, so reused workers read credentials from the authoritative store after first login. Preserve configured and unconfigured provider login coverage, including passive publication and worker reuse.

(cherry picked from commit d7a7b238bac29d147a9fa328b46d26f95d5bfda0)
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
Merge main without rebasing the reviewed transcript-read work. Preserve landed target selection, retention publication, cold restoration contracts, and prepared-reader test fixtures. Keep the measured child optimization separate from its squashed parent history.
@openclaw-barnacle openclaw-barnacle Bot added the channel: tlon Channel integration: tlon label Oct 9, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
Keep anchor query execution at one existing owner site, retain incognito selection in a leaf module, and exercise current preparation and combined delivery snapshots in the source-loss regressions.
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@steipete
steipete merged commit ab5fd51 into main Oct 9, 2026
201 of 205 checks passed
@steipete
steipete deleted the dbasync/tb4b branch October 9, 2026 02:50
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
)

Chat turns repeatedly hydrate transcripts and read anchors and metadata across preparation, replay, completion, and delivery. Compose compatible reads in the existing transcript owners, reuse historical append receipts, and select delivery payloads, anchors, identity, and watermark in one snapshot.

Preserve exact transcript bytes, limits, cold restoration outside writer admission, fresh replay phases, synchronous live-authority checks, and released SDK fallbacks. Integrate main without rebasing, preserve its target mapping and retention publication, and align source-loss fixtures with the new snapshot boundaries. No schema, durability, retention, permission, or configuration migration changes.

Validation includes focused replay, context, cold-storage, entry, delivery and activity-summary suites; all 27 core-test type graphs; wrapper/import closure checks; no-T1-growth and line-cap ratchets; released SDK comparison; and clean independent P2 review. Reuse the PR's original paired SQL proof with its original baseline pin.

Land under the explicitly approved inherited-CI exception. Run 37871955941 at 8185e13 has 102 successful jobs, 23 skipped jobs, two inherited root failures and their aggregate failure. The model-catalog Madge cycle also fails on main run 37868734021. The cancellation test passes before an unhandled rejection in unchanged detached subagent shutdown recovery. Security, CI lint, types, and repaired suites passed; the exception does not claim green CI.
steipete added a commit that referenced this pull request Oct 9, 2026
Repair eager reader backedges introduced by 34cb8f7 (#167520) and ab5fd51 (#167238). Move physical-source validation and transcript presence queries to existing narrow owners, migrate every caller, and remove the broad exports. Preserve identity checks, query semantics, and snapshot ownership.

The unchanged import regression passes with the fix and fails with both original edges when only the production diff is reversed. Core types and the import-cycle gate pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
Repair eager reader backedges introduced by e414045 (openclaw#167520) and 23c7173 (openclaw#167238). Move physical-source validation and transcript presence queries to existing narrow owners, migrate every caller, and remove the broad exports. Preserve identity checks, query semantics, and snapshot ownership.

The unchanged import regression passes with the fix and fails with both original edges when only the production diff is reversed. Core types and the import-cycle gate pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: tlon Channel integration: tlon docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed size: XL 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.

2 participants