Repository navigation
refactor(sessions): route transcript appends through the session actor - #168539
Merged
Merged
Conversation
…odules Merge current main while preserving shared physical admission, cancellation, reader validation birthtime, and live deletion authority. Split worker usage, pool construction, failure settlement, and schema owner types to keep the existing line caps.
Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress.
Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions.
Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity.
Merge current main and preserve its optional settlement-only receipt delivery through the extracted owner. Keep the worker refusal error with the leaf contract to stay within the existing admission line cap. End the marker-free read-only fixture transaction normally; dedicated rollback and explicit revocation coverage remains unchanged.
Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress.
Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence.
Carry actor receipts through SessionManager and direct-note append adapters while preserving the unbound SDK path. Retain lifecycle owners until accepted descendants drain. Actor acquisition remains inactive pending the B1 runtime backend; remote proof and runtime cutover follow in this lane.
Contributor
Author
|
ClawSweeper follow-up: retain the suggested turnover-after-submission proof as follow-up work. This review did not demonstrate user-data loss, a security hole, or money risk; the accepted-write lifecycle remains the owner, without adding speculative fencing. The native-incognito persistence issue is addressed in a552cdb: native-incognito keeps its existing transcript owner, while durable sessions use actor-backed appends. |
Detached helper attempts retain caller-owned transcript state. Skip durable actor acquisition for them so preparation does not create a database or route later reads through an unintended owner. Extend the existing runtime-facts test to verify that the attempt creates no durable database.
This was referenced Oct 11, 2026
This was referenced Oct 11, 2026
obviyus
added a commit
that referenced
this pull request
Oct 12, 2026
…mpaction V2) (#168401) Closes #168088. Related: #168164. ## What Problem This Solves With ChatGPT sign-in, every automatic compaction in OpenClaw ran a client-side summary: separate summarization requests with 0 cached tokens, and a lossy text summary in place of the conversation. Codex compacts the same route server-side ("remote compaction V2"): the next normal model request carries a trailing `{"type":"compaction_trigger"}` item, and the provider returns one opaque `compaction` item that stands in for the history. ## Fix - **Request:** automatic compaction on the ChatGPT route (preflight before a turn, and mid-turn between tool rounds) sends V2 as the next normal request, through the same attempt pipeline and native ChatGPT stream, with `compaction_trigger` appended last. Tools, instructions, parameters, cache key and the full input prefix are the turn's own, so the compaction request reads the warm prompt cache. - **Result:** exactly one non-empty `compaction` item is accepted, only after a successful terminal response and never after an abort. Collection resets for each provider attempt. - **Checkpoint:** real user messages are retained newest-first within 64k tokens, plus the item, matching Codex `compact_remote_v2.rs`. Users retained from an earlier window stay eligible, so repeated compactions keep them. - **Fallback:** every fallback to client compaction logs a WARN with its reason. Overflow recovery, `/compact <focus>` and manual `/compact` stay client-side; manual V2 needs session-writer ownership work and is a follow-up. - **Fixed during live testing** (each with a regression that fails on the defect): 1. V2 never ran: the compact request was checked before the async provider adapter dispatched it. 2. V2 ran only in the managed client; real ChatGPT turns use the native stream. V2 now runs there. 3. Replay normalization dropped the checkpoint turn as an empty failed turn, so the next request grew back to full history. It now keeps successful compaction checkpoints; error turns and suppression markers are still dropped. ## User Impact ChatGPT sign-in sessions compact server-side with no extra summarization requests. Compaction reads 87–100% of its input from cache, and later turns stay at about 14–22k input tokens instead of about 91k. `params.responsesCompactEndpoint: false` turns it off. ## Evidence Live, real ChatGPT OAuth login, `openai/gpt-6-astra`, isolated Gateway, synthetic corpus, three facts seeded before compaction. The host was loaded, so wall times are upper bounds. | Compaction | Compaction input / cached / output | Wall | Input before → after | Next user turn input / cached | Recall | |---|---:|---:|---:|---:|---:| | Preflight | 90,999 / 73,856 / 885 | 20.2 s | 90,999 → 22,308 | 22,439 / 22,144 | 3/3 | | Mid-turn, first | 91,075 / 82,560 / 575 | 12.3 s | 91,075 → 13,904 | 14,121 / 12,928 | 3/3 | | Mid-turn, second | 76,486 / 58,880 / 716 | 17.4 s | 76,486 → 14,476 | 14,709 / 14,336 | 3/3 | Request parity, compaction request vs the preceding normal turn: | Compaction | Tools | Instruction chars | Input prefix | Cached vs previous input | |---|---|---|---|---:| | Preflight | 6 → 6 | 35,857 → 35,857 | 26/26 items identical | 89.3% | | Mid-turn, first | 6 → 6 | 35,855 → 35,855 | 26/26 items identical | 99.8% | | Mid-turn, second | 6 → 6 | 35,855 → 35,855 | 39/39 items identical | 86.7% | The tool schemas, instructions, parameters and cache-key hashes were identical in all three. The final head sent exactly 3 `compaction_trigger` requests, all HTTP 200, and no client-summary requests. **Client comparison (same route, before this change):** one client compaction of a 117.9k-token session took two summary calls (9,777 input, 0 cached, 961 output, 24.4 s). The next turn read 33,967 input with 12,800 cached. Trigger points were not matched to the V2 runs, so this is a reference, not a head-to-head benchmark. **Tests:** fetch-boundary regressions across the managed and native ChatGPT streams cover: - request parity; - failed, cancelled and incomplete terminal responses; - aborts; - duplicate or empty items; - multilingual retention; - two consecutive persisted compactions; - the async-dispatch case and replay normalization through the real `SessionManager`. Negative controls fail on each defect. tsgo core/src/packages pass; `check-changed` passes. ## Release-landing follow-ups (2026.10.2) - **ClawSweeper P2 fix (budget anchor), commit e902124:** V2 used to price the outgoing request with the conservative preflight estimator. That estimator counts unchanged instructions twice, because measured usage already includes them. The V2 boundary now uses the same accounting as the mid-turn precheck it replaces: - The shared code is `resolveProjectedRequestPressure`, split out of `checkMidTurnPrecheck`. - The stream guard's request observation now returns the matching measured predecessor. The foreground request is observed before V2 decides, so both price the same anchor. A checkpoint request is then observed again as its own request. - Requests with no anchor keep the conservative estimate. - Regression test: `chatgpt-v2-compaction.test.ts` "prices a matching measured prefix once before deciding to compact". It uses the 15,000-token / 12,000-char / 24,576 numbers from `attempt-midturn-precheck.test.ts`. It fails on the previous head (the boundary throws `MidTurnPrecheckSignal`) and passes now. - Production LOC: +45/-27. Most of that is the function split plus contract comments. - **Test-only fixture fix, commit 018c9bc:** three Gateway e2e fixtures counted the labeled `OpenClaw runtime context:` carrier as a user turn: `gateway-rpc-chat`, `gateway-provider-review-product-proof` and `gateway-completion-replay`. These fail the same way on `main` (#168843; same fix as #168961). - **Rollback to v2026.10.1:** that release's replay normalization drops the empty, zero-usage V2 checkpoint carrier. The raw transcript is never rewritten, so v2026.10.1 replays the full raw history, and its own client compaction applies if that history is too large. Rollback loses no data; it just loses the provider checkpoint. The stored checkpoint format already shipped in v2026.10.1, and its reader ignores the added optional `outputTokens` (details in the compatibility comment). ### Unrelated failures that also happen on `main` (proof scoped to the tests involved) Both failures reproduce on a clean `origin/main` checkout at `ce5b795128e` with no PR code. Checking out commits around one change shows that both start at 5843d60 (#168539, "route transcript appends through the session actor"): | Test | `5843d60c^` | `5843d60c` | `origin/main` `ce5b795128e` | |---|---|---|---| | `src/agents/embedded-agent-runner.prompt-cache.test.ts` | 4/4 pass | 2 fail (`SqliteTranscriptMutationConflictError` from `appendSessionManagerActor`) | 2 fail | | `test/gateway-steer-fifo.e2e.test.ts` | 7/7 pass | 3 fail (1 model request where 2 are expected) | 3 fail | - #168981 independently reports the prompt-cache failure on clean main. - #169006 (steering diagnostics) landed and did not fix the steer-fifo failures. - CI selects these tests for this PR only through the shared embedded-runner files. Neither failing path is touched here. ### Local proof on the current head All runs below were local and focused on the touched files: - `chatgpt-v2-compaction`: 13/13. - The other affected `src/agents/embedded-agent-runner/run/` unit files: 208/208. These are `attempt-midturn-precheck`, `attempt-prompt-submit.*`, `attempt-stream-*`, `preemptive-compaction*`, `attempt-execution-phase`, `attempt-prompt-preflight` and `attempt-context-guards`. - `agent-runner.runreplyagent.e2e`: 231/231. - The 3 repaired Gateway e2e files: all passed. - `node scripts/check-changed.mjs -- <touched files>` exited 0. That run includes `tsgo` for core and core tests. - Codex protocol check (read directly in `../codex`): `codex-rs/core/src/compact_remote_v2_attempt.rs:70-84` and `compact_remote_v2.rs:65,398-450`. ### Unrelated failures on the current head (b3a7405, which merges `origin/main` at `ff6f58a8c32`) The two failures above (prompt-cache and steer-fifo) no longer fail on this head; main has since landed actor-append fixes. Two other unrelated failures remain: 1. **`src/agents/embedded-agent-runner/run.harness-auth-failover.test.ts`** (5 tests, `checks-node-changed-compact-large-4`): - Fails the same way on a clean `origin/main` checkout at `ff6f58a8c32`, and passes at `bdcbb2d8870` (10/10). - `git bisect` names `e63b5a01cf26` as the first bad commit: #168992, "perf(agents): reduce repeated SQLite work during agent preparation". - This PR does not touch native harness auth. 2. **`extensions/codex/src/app-server/run-attempt.steering-settlement.test.ts`** (`checks-node-changed-extensions-bundle-3`, 180s hook timeout): - Also fails on the unrelated PR #169026 (CI run 38137511377). - Passes locally (2/2) on this head, on clean `origin/main` `ff6f58a8c32`, and on this branch merged with that main. - This PR touches no `extensions/codex` files. Two other failures were flaky: `build-artifacts` (`sqlite-sessions-transcripts-flip-proof.built-cli`) and `gateway-completion-replay`. Each passed on rerun, and each passes locally after `pnpm build` on this head. Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 12, 2026
openclaw#168539) * perf(sqlite): checkpoint shared admission across workers (WIP) * test(sqlite): align worker fixtures with shared admission * perf(sqlite): avoid repeated quarantine reads in retained scopes * docs(sqlite): define single-owner database freshness * perf(sqlite): replace runtime probes with writer publications Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress. * test(sqlite): align first-admission coverage and deletion fixtures Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions. * build(sqlite): include shared admission in compiled wrappers Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity. * test(sqlite): use the canonical settlement owner in publication proof * fix(sqlite): complete writer custody and snapshot cache lifetimes Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress. * fix(sqlite): retain integrity and worker admission through cleanup * test(sqlite): preserve reader coverage in existing fixture owners * fix(sqlite): preserve cache receipts across sibling writers and temp DDL * fix(workboard): type the replacement card-list promise * fix(sessions): integrate receipt-based list revision reads * perf(sessions): reuse committed entry facts across ordered reads * refactor(sessions): identify fused query as worker-only * fix(sessions): preserve receipt facts across read phases * docs(sessions): clarify retained listing and alias guards * refactor(sessions): define shared session actor contract Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence. * refactor(sessions): update actor cutover contract * refactor(sessions): prepare actor-backed transcript appends Carry actor receipts through SessionManager and direct-note append adapters while preserving the unbound SDK path. Retain lifecycle owners until accepted descendants drain. Actor acquisition remains inactive pending the B1 runtime backend; remote proof and runtime cutover follow in this lane. * refactor(sessions): add inactive phase actor backend * refactor(sessions): preserve actor append outcomes through callers * fix(sessions): preserve actor projection readiness and held facts * perf(sessions): reuse retained transcript initialization facts * refactor(sessions): bind attempt appends to the session actor * test(sessions): service actor fixture admission synchronously * feat(sessions): contract update 2 for existing incognito owners * fix(agents): retain native incognito actor for transcript appends * perf(agents): defer native actor adapter loading * fix(sessions): reacquire incognito projection claims after actor commits * test(sessions): distinguish model metadata from context messages * refactor(sessions): separate actor contracts and share mutation executors * docs(sessions): explain actor assertion invariants * fix(sessions): borrow active native actor admission * fix(sessions): publish committed actor initialization identity * refactor(sessions): share native transcript presence query * test(sessions): assert atomic metadata cancellation receipts * docs(sessions): describe actor append cutover * test(sessions): explain actor eviction mock isolation * test(sessions): observe actor context fallback boundary * refactor(sessions): separate native persistence compatibility * refactor(sessions): retain private writer claim storage * fix(sessions): preserve typed actor append failure and scope * refactor(sessions): keep writer lease types below actor contracts * fix(sessions): retain optional actor writer fence fields * test(sessions): align actor fixtures with typed owner contracts * fix(sessions): preserve actor callback bindings and audit inactive APIs * fix(sessions): preserve actor callback bindings and lint contracts * fix(sessions): keep host config out of worker transport bundles * feat(sessions): contract update 3 for scoped receipts and command preimages * fix(sessions): reject mutations during actor authority admission * perf(sessions): append with actor command-local preimages * fix(sessions): retain actor state across unrelated pending writes * fix(sessions): preserve incognito transaction settlement contract * test(sessions): keep scoped receipt fixtures within storage contracts * refactor(sessions): separate receipt and transcript helper responsibilities * test(sessions): pass the logical scope to sibling writes * fix: retain native incognito transcript ownership * fix(sessions): keep detached attempts out of durable actors Detached helper attempts retain caller-owned transcript state. Skip durable actor acquisition for them so preparation does not create a database or route later reads through an unintended owner. Extend the existing runtime-facts test to verify that the attempt creates no durable database.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 12, 2026
…mpaction V2) (openclaw#168401) Closes openclaw#168088. Related: openclaw#168164. ## What Problem This Solves With ChatGPT sign-in, every automatic compaction in OpenClaw ran a client-side summary: separate summarization requests with 0 cached tokens, and a lossy text summary in place of the conversation. Codex compacts the same route server-side ("remote compaction V2"): the next normal model request carries a trailing `{"type":"compaction_trigger"}` item, and the provider returns one opaque `compaction` item that stands in for the history. ## Fix - **Request:** automatic compaction on the ChatGPT route (preflight before a turn, and mid-turn between tool rounds) sends V2 as the next normal request, through the same attempt pipeline and native ChatGPT stream, with `compaction_trigger` appended last. Tools, instructions, parameters, cache key and the full input prefix are the turn's own, so the compaction request reads the warm prompt cache. - **Result:** exactly one non-empty `compaction` item is accepted, only after a successful terminal response and never after an abort. Collection resets for each provider attempt. - **Checkpoint:** real user messages are retained newest-first within 64k tokens, plus the item, matching Codex `compact_remote_v2.rs`. Users retained from an earlier window stay eligible, so repeated compactions keep them. - **Fallback:** every fallback to client compaction logs a WARN with its reason. Overflow recovery, `/compact <focus>` and manual `/compact` stay client-side; manual V2 needs session-writer ownership work and is a follow-up. - **Fixed during live testing** (each with a regression that fails on the defect): 1. V2 never ran: the compact request was checked before the async provider adapter dispatched it. 2. V2 ran only in the managed client; real ChatGPT turns use the native stream. V2 now runs there. 3. Replay normalization dropped the checkpoint turn as an empty failed turn, so the next request grew back to full history. It now keeps successful compaction checkpoints; error turns and suppression markers are still dropped. ## User Impact ChatGPT sign-in sessions compact server-side with no extra summarization requests. Compaction reads 87–100% of its input from cache, and later turns stay at about 14–22k input tokens instead of about 91k. `params.responsesCompactEndpoint: false` turns it off. ## Evidence Live, real ChatGPT OAuth login, `openai/gpt-6-astra`, isolated Gateway, synthetic corpus, three facts seeded before compaction. The host was loaded, so wall times are upper bounds. | Compaction | Compaction input / cached / output | Wall | Input before → after | Next user turn input / cached | Recall | |---|---:|---:|---:|---:|---:| | Preflight | 90,999 / 73,856 / 885 | 20.2 s | 90,999 → 22,308 | 22,439 / 22,144 | 3/3 | | Mid-turn, first | 91,075 / 82,560 / 575 | 12.3 s | 91,075 → 13,904 | 14,121 / 12,928 | 3/3 | | Mid-turn, second | 76,486 / 58,880 / 716 | 17.4 s | 76,486 → 14,476 | 14,709 / 14,336 | 3/3 | Request parity, compaction request vs the preceding normal turn: | Compaction | Tools | Instruction chars | Input prefix | Cached vs previous input | |---|---|---|---|---:| | Preflight | 6 → 6 | 35,857 → 35,857 | 26/26 items identical | 89.3% | | Mid-turn, first | 6 → 6 | 35,855 → 35,855 | 26/26 items identical | 99.8% | | Mid-turn, second | 6 → 6 | 35,855 → 35,855 | 39/39 items identical | 86.7% | The tool schemas, instructions, parameters and cache-key hashes were identical in all three. The final head sent exactly 3 `compaction_trigger` requests, all HTTP 200, and no client-summary requests. **Client comparison (same route, before this change):** one client compaction of a 117.9k-token session took two summary calls (9,777 input, 0 cached, 961 output, 24.4 s). The next turn read 33,967 input with 12,800 cached. Trigger points were not matched to the V2 runs, so this is a reference, not a head-to-head benchmark. **Tests:** fetch-boundary regressions across the managed and native ChatGPT streams cover: - request parity; - failed, cancelled and incomplete terminal responses; - aborts; - duplicate or empty items; - multilingual retention; - two consecutive persisted compactions; - the async-dispatch case and replay normalization through the real `SessionManager`. Negative controls fail on each defect. tsgo core/src/packages pass; `check-changed` passes. ## Release-landing follow-ups (2026.10.2) - **ClawSweeper P2 fix (budget anchor), commit e902124:** V2 used to price the outgoing request with the conservative preflight estimator. That estimator counts unchanged instructions twice, because measured usage already includes them. The V2 boundary now uses the same accounting as the mid-turn precheck it replaces: - The shared code is `resolveProjectedRequestPressure`, split out of `checkMidTurnPrecheck`. - The stream guard's request observation now returns the matching measured predecessor. The foreground request is observed before V2 decides, so both price the same anchor. A checkpoint request is then observed again as its own request. - Requests with no anchor keep the conservative estimate. - Regression test: `chatgpt-v2-compaction.test.ts` "prices a matching measured prefix once before deciding to compact". It uses the 15,000-token / 12,000-char / 24,576 numbers from `attempt-midturn-precheck.test.ts`. It fails on the previous head (the boundary throws `MidTurnPrecheckSignal`) and passes now. - Production LOC: +45/-27. Most of that is the function split plus contract comments. - **Test-only fixture fix, commit 018c9bc:** three Gateway e2e fixtures counted the labeled `OpenClaw runtime context:` carrier as a user turn: `gateway-rpc-chat`, `gateway-provider-review-product-proof` and `gateway-completion-replay`. These fail the same way on `main` (openclaw#168843; same fix as openclaw#168961). - **Rollback to v2026.10.1:** that release's replay normalization drops the empty, zero-usage V2 checkpoint carrier. The raw transcript is never rewritten, so v2026.10.1 replays the full raw history, and its own client compaction applies if that history is too large. Rollback loses no data; it just loses the provider checkpoint. The stored checkpoint format already shipped in v2026.10.1, and its reader ignores the added optional `outputTokens` (details in the compatibility comment). ### Unrelated failures that also happen on `main` (proof scoped to the tests involved) Both failures reproduce on a clean `origin/main` checkout at `02040ecbc92` with no PR code. Checking out commits around one change shows that both start at 9657a374 (openclaw#168539, "route transcript appends through the session actor"): | Test | `9657a374^` | `9657a374` | `origin/main` `02040ecbc92` | |---|---|---|---| | `src/agents/embedded-agent-runner.prompt-cache.test.ts` | 4/4 pass | 2 fail (`SqliteTranscriptMutationConflictError` from `appendSessionManagerActor`) | 2 fail | | `test/gateway-steer-fifo.e2e.test.ts` | 7/7 pass | 3 fail (1 model request where 2 are expected) | 3 fail | - openclaw#168981 independently reports the prompt-cache failure on clean main. - openclaw#169006 (steering diagnostics) landed and did not fix the steer-fifo failures. - CI selects these tests for this PR only through the shared embedded-runner files. Neither failing path is touched here. ### Local proof on the current head All runs below were local and focused on the touched files: - `chatgpt-v2-compaction`: 13/13. - The other affected `src/agents/embedded-agent-runner/run/` unit files: 208/208. These are `attempt-midturn-precheck`, `attempt-prompt-submit.*`, `attempt-stream-*`, `preemptive-compaction*`, `attempt-execution-phase`, `attempt-prompt-preflight` and `attempt-context-guards`. - `agent-runner.runreplyagent.e2e`: 231/231. - The 3 repaired Gateway e2e files: all passed. - `node scripts/check-changed.mjs -- <touched files>` exited 0. That run includes `tsgo` for core and core tests. - Codex protocol check (read directly in `../codex`): `codex-rs/core/src/compact_remote_v2_attempt.rs:70-84` and `compact_remote_v2.rs:65,398-450`. ### Unrelated failures on the current head (b3a7405, which merges `origin/main` at `3dc543d9ee8`) The two failures above (prompt-cache and steer-fifo) no longer fail on this head; main has since landed actor-append fixes. Two other unrelated failures remain: 1. **`src/agents/embedded-agent-runner/run.harness-auth-failover.test.ts`** (5 tests, `checks-node-changed-compact-large-4`): - Fails the same way on a clean `origin/main` checkout at `3dc543d9ee8`, and passes at `596e31d1764` (10/10). - `git bisect` names `70e895e21606` as the first bad commit: openclaw#168992, "perf(agents): reduce repeated SQLite work during agent preparation". - This PR does not touch native harness auth. 2. **`extensions/codex/src/app-server/run-attempt.steering-settlement.test.ts`** (`checks-node-changed-extensions-bundle-3`, 180s hook timeout): - Also fails on the unrelated PR openclaw#169026 (CI run 38137511377). - Passes locally (2/2) on this head, on clean `origin/main` `3dc543d9ee8`, and on this branch merged with that main. - This PR touches no `extensions/codex` files. Two other failures were flaky: `build-artifacts` (`sqlite-sessions-transcripts-flip-proof.built-cli`) and `gateway-completion-replay`. Each passed on rerun, and each passes locally after `pnpm build` on this head. Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
scribe-dandelion-cult
added a commit
to karmaterminal/openclaw
that referenced
this pull request
Oct 16, 2026
Step 29 absorbed upstream openclaw#168539, whose session actor replica trusts the scoped write token of its own session keys. Our recipient-authority epoch write ran outside any write scope, so it counted as unscoped and advanced every session's token: an owner change on one session revoked every unrelated replica on the database. Upstream's session-actor-replica.test.ts ("retains unrelated session postimages but invalidates a shared physical session window") failed on the absorb and passes on plain upstream 5843d60; with the advance disabled it passed, which isolates the cause. Scope the epoch write to its own session key inside advanceSessionRecipientAuthorityInTransaction, so every caller (owner, visibility narrowing, membership removal, lifecycle delete, capture) is covered. Also keep session-accessor.sqlite-entry-read.ts under its line cap (our raw-row reader pushed it 700 -> 704 after upstream growth): the owner path reads the exact-row query cache directly, and its call site already explains why it skips participant projection. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
SessionManager repeatedly prepares writers and reloads transcript facts while appending messages and tool results. Cut these durable points over to the session actor without losing committed receipts, live authority, or accepted-write settlement.
User Impact
No intentional user-visible behavior change. The warmed append path removes 26 SQLite statements and one committed transaction with zero added requests. No schema, durability, retention, or permission change; no operator action required. This lane does not by itself reach the campaign's under-500 warmed-turn aim.
Why This Change Was Made
Stacked on
dbasync/actorb1. The measured B1 base isb11f7c318270752376f0129528c6a589b5bd6c51; candidate is0a5499ea1645ca4fb007ab304ccfe1fde7449351. Those measurements describe the original approved lane head. Landing subsequently incorporated main through merge commits and retained the upstream native-incognito owner.Retain one exact physical/session actor for the attempt, including accepted descendants after a teardown timeout. Route SessionManager messages, metadata, tool-result persistence before acknowledgement, and bound transcript appends through
appendToolResult/appendTranscriptEvent. Each durable append has one transaction. Capture the native receipt before fallible publication, preserveSessionTranscriptMessageCommittedError, and never repeat an unknown-outcome append.B1 contract update 3 permits a synchronous replica snapshot and validates the optional expected preimage inside the command. The pre-append read is gone. Only a typed stale-version result, proving no mutation ran and carrying the current postimage, permits one retry; authority is checked again. The captured commit always wins over a contradictory reply. Session-scoped invalidation leaves unrelated sessions resident.
Preparation, anchors, watermarks, and context membership consume the actor's admitted metadata. Historical message payload hydration stays bounded; no full-history cache saving is claimed. After integrating #168602, native-incognito stays on its existing transcript owner and does not acquire an actor. Durable sessions use the actor append path. Released unbound SDK/native calls and explicit compaction maintenance keep named compatibility adapters; actor-bound callers have no parallel old writer path. Writer-lease types move to a leaf owner, with existing exports retained.
Deliberate compromises
The final audit against "Choose good compromises" retained the existing ownership contract rather than adding another coordination layer. This cutover removes the pre-append read and superseded actor-bound writer; it adds no fencing token, revocation generation, durable command ledger, caller-side reconciliation loop, or per-write cross-thread handshake. The existing writer-lease/navigation checks are preserved, not newly invented. Native-incognito keeps its existing owner after #168602 removed the adapter. The drain callback releases durable actors through the existing accepted-work lifecycle rather than introducing a second settlement mechanism.
Accepted edge case: a durable append can succeed while local view/receipt publication fails. The caller reports the existing committed-error contract and does not replay the append. An unknown result likewise stops this attempt. The current actor contract explicitly forbids command replay and does not make command IDs durable idempotency keys; message-level idempotency remains intact where supplied. General automatic retry is therefore not safe for every metadata/event append and is intentionally not built here. Only the typed stale-version outcome proves no mutation ran and allows the bounded retry above.
Statement and request evidence
Four required alternating B1/C pairs ran on one Hetzner runner, followed by the required fifth pair because the initial first-turn median rose. All ten complete workloads passed. The tables below include all five pairs; medians are computed separately for each side. A warmed sample is its ten-turn sum divided by ten, then the five-sample median. All-thread counts include MAIN. MAIN requests identify the sender; MAIN statements identify the executing thread. Actor commands, logical requests, transfer frames, native calls/statements, and committed transactions are distinct counters.
The fifth pair alone is +2 requests, not a request saving. Under the campaign's median granularity, the whole-workload comparison after that confirmation is −492 statements, −1 worker request, −2 DB requests. The remaining first-turn +16 statements / +8 worker requests is redistribution, not reported as an improvement. Recorded stacks locate the shifted work in memory-index admission/indexing and memory-workspace locks, not the append path. The affected unchanged families have equal whole-workload medians:
schema.admitcron.mutateJobspluginState.compareDeletepluginState.compareUpdatepluginState.observecache.writeAll gated duration ratios are below 1.5 (maximum observed phase-median ratio 1.046). Boot/connect/first combined statements are 4665 → 4702 (+0.79%); control/cron and compaction/shutdown are also reported in retained evidence. Non-turn increases are within the campaign tolerance and come from unchanged owners. No saving is credited merely for thread movement.
Exact append attribution
This attributes −26 statements, zero added requests, −1 committed transaction per warmed turn. The extra 1.8 raw warmed-statement reduction is not credited to this cutover. Across the complete workload, old metadata append/initialize is 51 requests / 1145 statements / 70 commits. Retained compatible appends plus 41 actor transcript appends and one actor tool result are 47 / 574 / 47: −4 requests, −571 statements, −23 commits in the touched families. Other-owner variation accounts for the difference from the raw workload medians. The first-turn append families themselves are 4 → 4 requests and 86 → 50 statements.
Per-phase all-thread and MAIN census: B1 → candidate, median [min–max]
Executed SQLite statements and committed outer transactions
Logical requests
Actor commands and native API calls (prepares included in native calls, not executed statements)
Transfer frames (a received frame is not counted again as another transfer)
Evidence
d6046834d513for the intended reason: two actor reads observed.pnpm test src/agents/embedded-agent-runner/run/attempt-transcript-lifecycle-prepare.test.ts --maxWorkers=1: B1 38 tests, 56.69 s Vitest / 81.47 s wall; candidate 47 tests, 85.16 s / 109.94 s. Peak RSS 3,408,672 → 3,424,968 KiB. Hosted CI seconds were not separately measured.6903d37cebb1758831e6b508cca5fedcc4335c0622764671742a203be89cf431. Existing exports and released synchronous/unbound behavior are retained.qaRuntimebuilds pass. The full build/core types hit the inherited B1 error below, so this is not an all-green full-build claim.bb394679a1fb06625e633c21a03a08b7581e0afa(620 s). The service finished updating, readiness returned 200, the running version was verified, and durable plus native-incognito sessions survived.Original lane inherited failures and gaps
Reproduced on the pinned B1 base: the assertion-safety baseline still expects two comments for
session-accessor.sqlite-transcript-store.ts, whose extraction leaves one; core/build/test types encountersession-accessor.sqlite-entry-store.ts:731using out-of-scopesessionRow(fixed later upstream by1cbcc4aca38e); coercion guard reportssession-accessor.sqlite-entry-facts.worker.ts:30 readString; deprecated-API guard reportsgateway/server-methods/agents.ts:2 internal-config-api; Knip/dead exports reportreadSqliteDatabasePendingWriteRevisionandsettleFailedSqliteWorkerJobs. These paths are untouched by B3. No guard was weakened and no failure is labeled green. Later test-type graphs did not run past the inherited first-graph error; earlier pre-extraction proof passed all 27 selected graphs.Proof ran remotely. Testbox final-head tests/static reports are at https://github.com/openclaw/openclaw/actions/runs/38062140278; subsequent sync retries timed out before executing checks. AWS quota fell back to an undersized runner, which was released without proof. The final census ran on one Hetzner lease with direct exact-commit fetch after raw sync stalled; no local Docker or heavy local proof. The shared workload is unchanged (SHA-256
1de5109a7b89eaf8c10ef943bde724a89bd44772b7d70419bd344caf18d92cd1). The lane observer avoids runtime source-map expansion, then symbolicates offline; counter calibration and exact phase/thread/SQL conservation pass. All 192 observed request kinds are source-classified; all ten workloads have zero transaction-pairing anomalies. Raw traces are deleted after compaction; compact proof is below 2 GB.LOC versus measured B1: production +1401/−598 (net +803), tests +386/−32 (net +354), docs +22/−6 (net +16). Growth carries the receipt/admission bridge and named native/SDK compatibility owner plus durability/authority/drain regressions; superseded actor-bound writers are deleted. This is a caller cutover, not a new storage owner.
Landing integration
Merged current main with a merge commit and preserved its removal of the native-incognito actor adapter. The existing incognito transcript persistence and tool-result acknowledgement cases remain; actor-specific append assertions cover durable sessions. A subsequent CI failure exposed durable actor acquisition for detached helper attempts. The final head
bb394679a1fb06625e633c21a03a08b7581e0afaskips actor/database acquisition when persistence is detached and extends the existing runtime-facts test to assert that no durable store is created. The original 31-file Bun group passes (366 tests, 88 s), focused preparation/runtime-facts proof passes (97 s), and scoped Codex P0/P1 review is clean. Final-head type-aware lint, full Knip export scans, and the export-name collision guard pass. Final-head package build/tarball integrity and the published-driver update cell also pass. CI run 38118306733 on final head stopped with two inherited failures. Both reproduce on pinned main390f0f0acb98c577d5ccf71cd04201a6c4083c7b, independently on the same Hetzner runner:test/gateway-openai-compaction-replay.e2e.test.ts—replays persisted provider state on the next embedded turn: expected continuation input to containContinue from the compacted transcript.src/gateway/server-methods/sessions-files.repository.test.ts—keeps stopped inspection limited to verified changed artifacts: expected a rejected promise, received a successful file result.Neither test file is changed by this PR; both assertion failures match CI. No CI rerun was requested. The operator-authorized inherited-failure override applies. Native initialization repeatedly stalled during worktree allocation/checkout; its interrupted operation lock was recovered, and the explicitly authorized exact-head REST squash fallback is used. Independent dependency/security review statuses passed.
ClawSweeper follow-up: the suggested turnover-after-submission scenario is retained as a follow-up. No demonstrated data-loss, security, or money-risk finding requires new fencing or settlement machinery; the existing accepted-write lifecycle remains the owner.