Repository navigation
perf(sessions): reuse committed transcript context during chat turns - #169960
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR reuses bounded transcript context and recent reply anchors from the existing session actor replica. Example: A warm chat turn prepares and persists its next user message.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it provides a measured, maintainer-directed reduction in repeated transcript reads, with no concrete introduced defect found; current-head CI failures remain unattributed. Priority: P2 Before merge
FindingsNone. Agent review detailsHow this fits togetherThe session actor sits between chat orchestration and SQLite workers, publishing committed session facts that hydration and delivery readers consume under their existing authority checks. flowchart TD
A[Chat turn] --> B[Session actor replica]
B --> C[Retained bounded context]
B --> D[Committed reply anchors]
C --> E[Model preparation]
D --> F[Delivery authority checks]
B --> G[Canonical history worker]
G --> B
Technical reviewBest possible solution: Retain this optimization in the existing replica with canonical-reader fallback and resolve current-head CI attribution before landing. Do we have a high-confidence way to reproduce the issue? Current-main hydration still requests bounded history rather than reusing retained transcript payloads, and the supplied live baseline identifies repeated preparation and persistence reads; this read-only review ran no reproduction. Is this the best way to solve the issue? The approach fits the existing owner: committed receipts advance bounded payloads, unsupported cases retain canonical reads, and shared selection replaces the memory-only implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e3ed1945ba38. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +751, Tests +1240, Docs +16, Other +3. Total +2010 across 28 files. Added test files: 4. 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, 2:22 PM ET / 18:22 UTC (Revision 6). |
|
Hotguard coordination: this lane caches transcript hot/cold marker facts under existing session-ID write receipts and reuses autocommit participant rows inside an unchanged transaction. It does not change usage refresh scheduling, actor hydration, entry receipts, worker routing, or exported SDK contracts. Archive/restore and session deletion invalidate via their existing write scopes; unknown writes remain conservative misses. Shared-family counts will be reported with the live baseline/candidate pair. This composes with usage refresh coalescing and committed transcript context reuse; exact-entry receipt preservation is already included in the lane base. |
Preserve the actor-owned transcript across metadata and participant publications, and reuse committed reply anchors after actor release. Invalidate retained context for transcript changes and keep current sharing and delivery authorization with their existing owners. Exercise metadata, participant, rewrite, replacement, and released-delivery behavior; align transcript fixtures with exclusive database ownership.
|
Current-head CI attribution is now recorded in the PR body, including direct main runtime-config failures, exact predecessor/cross-PR assertion matches, and source-attributed media failures before hydration. The red-main repair owner has these failures and the remaining attribution limits. No concrete patch defect was found in the completed review. All current static/build/security gates pass. One extension runtime shard remains pending after more than 30 minutes; its outcome is unknown and is not labeled inherited. The identical source tree passed the earlier full CI run. Landing under the authorized relaxed slow-runtime-CI exception, with no static/security/review waiver and no re-review requested. |
…penclaw#169960) Retain bounded transcript context and committed reply facts in the existing session actor replica. Advance complete linear context from append receipts, preserve it across metadata-only lifecycle changes, and invalidate it for transcript-changing writers. Keep current sharing and delivery authority with their existing owners. Remove duplicate post-consumption checks and share bounded selection between memory and durable readers. The combined live pair saves 10 hydration statements and one request per warmed turn; anchors still fall back after unrelated trajectory publications. Includes the lifecycle follow-up reviewed in openclaw#170005. Preserve deprecated stable synchronous SessionManager APIs and native incognito custody for a separate owner cutover.
What Problem This Solves
Warm chat turns read the same bounded transcript during preparation and user-turn persistence, then read anchors and reply payloads again for delivery. Turn setup also discarded the actor's retained transcript after metadata and participant updates, preventing reuse on the next turn.
User Impact
Ordinary chat turns reuse committed transcript context. Resident replicas can also serve committed reply anchors; the measured workload still falls back for anchors after an unrelated trajectory publication (see follow-up below). Cold sessions and history-changing operations use the canonical bounded reader. Stored history, retention, schemas, delivery authorization, and update behavior are unchanged.
Why This Change Was Made
The existing actor replica remains the only owner. Cold hydration supplies exact stored byte sizes; append receipts advance complete linear context and a bounded recent suffix. Metadata-only lifecycle commits publish the actor entry they already own. Participant publications invalidate entry and sharing facts while retaining inert private transcript payloads until a fresh actor snapshot matches their session identity and transcript version. Delivery can consume committed anchor facts after releasing the actor handle; the caller still owns current authorization.
Truncated windows, unsupported controls, missing receipts, eviction, reset/replacement, rewrite, rewind, compaction, archive/restore, and deletion invalidate or return to the existing reader. Memory and durable backends share bounded selection. No parallel cache owner, worker operation, schema, or SDK contract is added. Activity-summary reads are unchanged.
Removed checks and accepted edge cases:
T1 remains 6 → 6 counted SQL primitives in the shared bounded-context kernel; this is not six measured Gateway calls per turn. Ordinary durable hydration and actor append-repair reads execute in workers. Native reachability remains through synchronous
SessionManagerAPIs that were present and deprecated in stablev2026.10.2, and through unbound process-owned incognito databases. Those deprecated APIs can be removed in a later release; unbound incognito database custody requires a separate owner cutover. This uses the task's explicit API/owner-redesign escape hatch and does not claim zero T1 for the shared kernel. Anchor and activity-summary adapters add no direct T1 primitive.Related owner work: #169727 (first-turn seeding), #169853 (row facts), #169858 (exact entry). The follow-up #170005 is incorporated at
8c3104276657, preserving its reviewable incremental diff without shipping the intermediate implementation alone.Evidence
One adjacent baseline/candidate live SQL harness pair under the campaign landing CPU semaphore; each run completed 13 turns, including 10 warmed turns. Baseline
ea0e2099e059; candidate6bf6f9f3b6cf. Native SQL execution instrumentation counts statements on every thread; requests count observed worker operation envelopes. No bindings, transcript payloads, or real user data were recorded.Warmed means: statements 269.2 → 259.7 (-9.5/turn), requests 65 → 63.9 (-1.1/turn), MAIN 0.1 → 0.1 (0/turn).
For the first four shared families, request counts are distinct envelopes containing that family’s SELECT call; families can overlap and must not be added together. All such SELECTs matched a census request envelope. Row facts count the entire
session-row-factsoperation, including its transaction envelope.Warmed execution time totaled 32.146s → 42.153s (ratio 1.311); build time is outside all SQL phase windows. Native SQL failures: 0 baseline, 0 candidate.
Median warmed duration [min–max]: 3.1210s [2.084–4.448] → 3.8055s [2.858–7.061], ratio 1.219.
The stable owner saving is 10 SQL statements and one request per warmed turn. Shared-family costs are disclosed rather than dismissed: exact-entry and actor hydration each add one distinct envelope over ten warmed turns; row backfill adds two. Charging all increased warmed operations to this change still leaves 83 fewer SQL statements and six fewer requests over ten turns before crediting unrelated decreases. The raw request median rises by 0.5 because unchanged-total maintenance batches move between turns (GitHub/secrets, placement recovery, and health); total warmed requests fall by 11. This is the campaign's disclosed, paid-for shared-family tradeoff.
Warm MAIN is unchanged: each run has one cron agent-deletion-journal read in a warmed turn. The full-workload MAIN increase is 124 existing Skill Workshop source-authority checks, 111 during compaction and 13 during shutdown. The unchanged scheduler waits 30 seconds of idle time: baseline has only 29.397 seconds between its final warmed turn and shutdown, while the candidate reaches review preparation at 156.709s and its first source check at 158.215s, before shutdown at 160.331s. Both runs end the review with a shutdown error; only the candidate progresses into context and agent/tool preparation. The Workshop model-context caller and synchronous source validator are directly identified in the trace; subsequent anchor, runtime-target, device-capability and placement requests are correlated background progression, although some outer caller stacks are truncated. The progression-related subtotal is +184 SQL/+21 requests, hydration saves 110 SQL/11 requests over the whole workload, and all remaining operations net -4 SQL/+3 requests, yielding the raw +70 SQL/+13 requests above. The remaining extra entry-read envelopes cannot be fully attributed from the truncated stacks and are not discounted. These authority checks remain at their existing effect boundary. Boot+connect+first-turn combined SQL decreases 3541 → 3530; deferred work shifts from connect into first-turn. Memory schema admission (135 SQL) and open (16 SQL) move from compaction to shutdown one-for-one.
The remaining anchor read has a concrete follow-up: in all ten warmed turns,
trajectory.events.appendcommits between the last actor append and delivery's anchor read. Its writer changes onlytrajectory_runtime_eventsbut emits an unscoped receipt, invalidating the replica's scoped token. Scope that existing writer without introducing a new cache owner; the current PR makes no claim of measured anchor savings. The target of 20 fewer statements was an aim; this combined change delivers a smaller measured saving.The intermediate implementation was measured twice and did not qualify for independent landing: pooled warmed SQL medians 379 → 396 and request medians 86 → 94. It repeatedly removed 8.8 hydration statements and 0.9 requests/turn, but still reread initial context and delivery anchors. The confirmation also had substantial duration skew (1.779×), and shared-family rises were not dismissed as noise. The combined implementation above addresses those remaining paths and is evaluated separately against its integrated main base.
The baseline request census attributes hydration to
prepareInitialPersistedUserTurnCohortandreadCurrentTurn→sessionManagerReloadTranscriptCohort; both consume bounded context, replay validation, and an entry anchor. Delivery'sreadSessionTranscriptAnchorsAsyncconsumes session facts, watermark, input anchor, later tail, and current-run messages.session-activity-summaries.ts:runconsumes the summary source and coverage facts.Real-owner regressions cover committed and duplicate actor appends, exact noncanonical UTF-8 byte lengths, bounded contexts/fences, detached payload ownership, native append, generation-preserving/content rewrite, replacement, suffix trim, rewind, compaction/reset, cold archive/restore, deletion, metadata changes, and participant insertion/count updates. Released-actor delivery reuses anchors and rejects stale answers after rewrite/replacement.
Changed-file formatting, oxlint, and diff checks pass. Two Codex review rounds per component are complete; no further review cycle is required. Accepted findings and CI fixture repairs are fixed. Extra speculative generation/anchor rechecks were declined because committed owner receipts already invalidate the replica; real authority checks remain at consumption/delivery boundaries.
The combined implementation passed CI run 38280392191 at
6bf6f9f3b6cf: 57 successful jobs and 24 skipped, including types, lint, source contracts, architecture/Madge, T1/dialect/worker ratchets, builds, security, and the CI gate. Initial wrapper-inventory and isolated-fixture ownership/path failures were repaired; the delivery rewrite/replacement regressions passed in 823ms/845ms and the wrapper-closure test in 5593ms. Final-head Knip passed with zero findings in all three sequential native scans: production 330.306s, full-tree 471.334s, scripts 341.548s; native timeout and thresholds were unchanged. The feature-branch squash preserves exactly the same source tree (ea9ba5d41c4ab857fc96cddeabece160ea2bb117). The combined main-targeted CI run 38289217596 at8c3104276657passes all static, security, CodeQL, and build gates, including final test types. Runtime disposition is recorded below.Runtime CI disposition
At landing: 55 CI jobs passed and 22 skipped; 11 completed runtime jobs failed in untouched tests.
checks-node-changed-extensions-bundle-1remains running after more than 30 minutes, so the aggregate CI gate is pending. Its unobserved outcome is not labeled inherited. All current static, build, and security checks are complete and green; the exact source tree already passed the full run at6bf6f9f3b6cf. Under the authorized relaxed slow-runtime-CI exception, this pending runtime shard does not hold the landing. Three changed residency regressions explicitly pass in the current run, and no changed test appears in any completed failure summary. The release-only preflight E2E is not established by this PR runtime matrix; the isolated live SQL harness supplies the turn-flow proof.The parent run also includes newer main changes. Its runtime failures are in files untouched by this PR. The main runtime-config preparation regression was introduced by
7e48efba1047(#169714): main run 38288818280, job 114943944832 directly reproduces the sameRuntime config is not preparederrors in session-manager rollback and model-context-prefix tests. Candidate failures in session accessor/finalization, native worker/process, heartbeat, memory, and provider transcript fixtures have this same directly logged error; secondary early-exit/timeouts are recorded rather than claimed fixed.Three additional assertions require more precise attribution:
dirtySettledassertion also fails in the final source of #169714, which landed before this run. This is exact predecessor-PR evidence, not a separately reproduced main test.assistantTranscriptOwnedand heartbeat's retained Exec event have exact cross-PR matches. Their unchanged fixtures omit prepared config, and unchanged callers read it before transcript storage. The finalizer catches that failure and returns undefined. This is source-supported attribution; those logs do not print the swallowed error, and no exact main reproduction is claimed.createMediaGenerationTaskRuncallsgetRuntimeConfigbefore its first session read and catches errors as null; the revocation tests wait for the reader spy that is never reached. Test, owner, reader, and fixture source are unchanged by this PR and identical on the inspected main comparator. This is source-attributed; the neighboring code-mode-source test directly logs the config error.These inherited/untouched runtime failures are assigned to the campaign's red-main repair owner, with exact run links and attribution limits. Landing uses the authorized relaxed runtime-CI exception; no static, security, review, or product-regression gate is waived. A focused main replacement-receipts probe was canceled after main CI supplied the direct matching error; it supplies no pass/fail evidence.
The update cell is not applicable: no update, Doctor, schema/migration, plugin loading, or service lifecycle code changes. No SDK surface changes.
LOC: 28 files; production +977/−226, tests +1247/−7, docs/inventory +19/−0. The shared selector replaces the memory-only copy; production growth retains bounded context and projects committed reply facts in the existing replica.