Repository navigation
Conversation
A transcript write naming a session key other than the transcript's owner threw a plain Error. sessions.reset (and the agent RPC's /reset) lets it escape, so the request dispatcher answered a permanent refusal as flag-less UNAVAILABLE with an "Error: " prefix and the message cut at 240 characters. Line-limited sessions.compact reaches the same check and returned it without details from its own catch. Resetting or line-compacting a cron base key whose latest isolated run owns the transcript hits it on every attempt, and clients could only recognize it by parsing English. Throw SessionTranscriptOwnerMismatchError with the same sentence, carry its fields through the SQLite worker error transport, and shape it through errorShapeFromError in handleGatewayRequest (like AgentDatabaseAdmissionError) and in the sessions.compact catch: UNAVAILABLE, retryable false, and details.code SESSION_TRANSCRIPT_OWNER_MISMATCH with sessionId, ownerSessionKey and requestedSessionKey. Declare the detail with a closed protocol schema and document it. Proof: the Gateway WebSocket regression (reset, repeated reset, and maxLines compaction) fails on main with the truncated flag-less frame and passes with the fix (about 1.3s inside the existing store-rpc suite). Worker transport and protocol schema cases pass, as do the existing compaction suites. A built loopback Gateway called through the CLI Gateway client returns the typed details.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR makes transcript-owner refusals from reset and line-limited compaction return structured details and an explicit non-retryable flag. Example: Call sessions.compact with key agent:main:cron:job and maxLines 1 when session-1 belongs to agent:main:cron:job:run:session-1.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current RPC error-contract defect while preserving transcript ownership, and I found no actionable introduced bug. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway session RPCs invoke the SQLite transcript owner; worker error transport preserves the refusal identity, and the shared Gateway mapper returns its protocol details to clients. flowchart TD
A[Gateway client] --> B[RPC authorization and dispatch]
B --> C[Reset or compaction handler]
C --> D[SQLite transcript owner]
D --> E[Typed ownership refusal]
E --> F[Worker error transport]
F --> G[Gateway error mapper]
G --> A
Technical reviewBest possible solution: Merge the additive typed refusal through the existing worker transport and Gateway mapper once the enforced maintainer approval is satisfied. Do we have a high-confidence way to reproduce the issue? Current-main source shows the plain ownership throw and generic RPC formatting; the report supplies a failing baseline WebSocket response for two rows sharing a transcript ID, and no target code was executed during this review. Is this the best way to solve the issue? The fix uses the existing ownership check, worker error transport, and canonical response mapper, preserving the refusal and top-level code while adding the missing client contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0597769e3931. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +73, Tests +69, Docs 0, Other +1. Total +143 across 14 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 HistoryReviewed October 13, 2026, 4:30 AM ET / 08:30 UTC (Revision 3). |
…ntory The worker error identity module now imports session-transcript-owner-error.ts, which puts it in the runtime closure of the extracted PR wrapper. Without the inventory line the wrapper fails to load that module: eager-import-closure reports it missing, pr-wrapper-source-closure flags the worker closure, and native PR provisioning loses its private store handoff.
|
For the reviewer, the scope of the The error has one throw site, the transcript-owner check in |
|
CI update: on The earlier red run on
|
Closes #170175
What Problem This Solves
Fixes: when a session's current transcript is owned by another session key, for example a cron session whose latest isolated run owns the transcript, the ownership refusal from
sessions.reset, and from asessions.compactthat trims tomaxLines, carries no structured details and noretryableflag. Clients cannot tell it from a transientUNAVAILABLE.User Impact
User impact:
sessions.reset, theagentRPC's/reset, and asessions.compact { maxLines }that needs to trim the transcript now refuse withUNAVAILABLE,retryable: false, anddetails: { code: "SESSION_TRANSCRIPT_OWNER_MISMATCH", sessionId, ownerSessionKey, requestedSessionKey }. Clients can stop retrying and act on the owner key without parsing English.The refusal still happens in the same cases, and the top-level
codeis unchanged. Changes that apply to reset only (compaction already returned the full message and never reached the dispatcher log):messageloses itsError:prefix and is no longer cut at 240 characters.request handler failed. The ws response log line still records it.There is no protocol version change; the detail code is additive (
ErrorShape.detailsis already open).Why This Change Was Made
The ownership check now throws a typed
SessionTranscriptOwnerMismatchErrorwith the same sentence. The class is registered with the SQLite worker error transport, so its fields survive the worker hop.handleGatewayRequestthen shapes it througherrorShapeFromError, the same pathAgentDatabaseAdmissionErroralready uses. That coverssessions.resetand theagentRPC's/reset.sessions.compactanswers from its own catch, so that catch now useserrorShapeFromErrortoo, keeping its session-changed special case. Errors the mapper doesn't recognize keep their existing formatting. Compact also picks up the mapper's existing agent-database admission and incognito mappings: admission refusals now report their canonical reason and repair hint, and a nested incognito-ended error can replace the outer message.The protocol declares the detail code with a closed schema, and the session-control protocol doc describes the refusal.
Keeping
UNAVAILABLE, withretryable: falseplusdetails.code, follows the existing typed refusals (INCOGNITO_SESSION_ENDED,STALE_INSTALL, agent-database admission) and leaves the code clients already branch on unchanged. If maintainers preferINVALID_REQUESTfor this refusal, it is a one-line change.Out of scope:
Session actor transcript window belongs to another logical owner) is still untyped. I have not shown that a public RPC can reach it.chat.injectcan also reach this check, through the cached target resolution added in perf(sessions): reuse actor replica for entry and target reads #168677, aftersessions.aborthas cached the row's entry facts. That is a separate bug, [Bug]: chat.inject is refused with "is owned by" once a session's entry facts are cached and another key owns its transcript #170136, fixed at the resolver in fix: chat.inject fails after a shared session entry is cached #170137. It is not shaped here, because the fix belongs in target resolution, not in inject's error path.Evidence
src/gateway/server.sessions.store-rpc.test.ts. It seeds a base row and a run row that name the same session id, with the run row written last, so the run key owns the transcript. That is the shape isolated cron runs leave behind.sessions.resettwice plussessions.compact { maxLines: 1 }on the base key all return the same typed refusal. Onmain(7d0c05318, and earlier87f151f6) the first reset frame is{ code: "UNAVAILABLE", message: "Error: Transcript session … resolve the ..." }, with nodetailsand noretryable. With only the dispatcher change, compaction still returned an untypedUNAVAILABLE.entry_json), the transcript owner and the transcript events after each of two refused resets. They were byte-identical, and both responses were identical. Reset still runs its hooks and runtime cleanup before the write is refused; this check does not cover those.37a244b8e,pnpm build) and started the built Gateway on127.0.0.1in a scrubbed environment (env -i) with an isolated state directory, seeded offline with the same rows. Throughopenclaw gateway callI sentsessions.resetand thensessions.compact { maxLines: 1 }on the base key. I ran this twice: once with the candidate CLI from the same build, and once with the latest published CLI,[email protected].2026.10.2CLI keepsdetailsintact with no client change.res ✗ sessions.reset … errorCode=UNAVAILABLEandres ✗ sessions.compact … errorCode=UNAVAILABLE, and norequest handler failedline.sessions.resetalone, built on87f151f6, is below. Before the fix, the Gateway also loggedrequest handler failed. The CLI printsretryable: falsein both runs because the client normalizes an absent flag. The raw-frame difference is the one shown by the regression test.[email protected]. A setting went in through its CLI (config set agents.defaults.timeoutSeconds 321), its Gateway did a first boot, and the shared-id rows plus the run transcript were written through its public plugin SDK. The released 2026.10.2 Gateway then served that install, and I stopped it. Next I ran this branch'sdoctor --fix --non-interactive, the step this branch's Gateway names when it refuses the 2026.10.2 agent database ("uses schema version 24; … run openclaw doctor --fix to migrate session identities"). Finally I started this branch's Gateway on the same state directory. The 2026.10.2 CLI was the client for every call.sessions.resetreturnsUNAVAILABLEwith a truncated"Error: Transcript session … resolve the ..."message and nodetails, and the Gateway logsrequest handler failed.sessions.compact { maxLines: 1 }returns the full message withoutdetails.details.code: "SESSION_TRANSCRIPT_OWNER_MISMATCH", the owner and requested keys,retryable: false) to the unchanged 2026.10.2 client, and nothing is logged asrequest handler failed. The top-levelcodestaysUNAVAILABLE, so a client that branches oncodebehaves as before.["user: cron run"]), andagents.defaults.timeoutSecondsis still321.doctor --fixitself editsopenclaw.json: it addsagents.entries.mainand awizardrun stamp, and it writesskills.entriesdisabling the 33 bundled skills that are unavailable on this host. None of that comes from this PR.doctor --fixmigration; it does not exerciseopenclaw updateor a rollback. After the migration, the 2026.10.2 CLI's localconfig getrefuses the newer database schema ("See …/database-schemas"), which is a migration effect rather than part of this change. Gateway calls through the 2026.10.2 client keep working.7d0c05318(pnpm test <file> --maxWorkers=1). Wall time is the full command, measured locally on macOS under heavy host load from other jobs, including cold transform.src/gateway/server.sessions.store-rpc.test.ts6/6 in 199 s.src/state/openclaw-state-worker-error.test.ts46/46 in 20 s (new transport case).packages/gateway-protocol/src/schema/error-codes.test.ts14/14 in 10 s (new schema case).server.sessions.compaction.test.ts21/21 in 157 s andsessions-compact.settlement.test.ts4/4 in 91 s.session-accessor.sqlite-data-version16/16 in 37 s,session-transcript-runtime.configured-store9/9 in 43 s,error-shape1/1 in 23 s,server-methods.stale-install4/4 in 13 s.7d0c05318:pnpm check:changed --base origin/main --head HEADpasses: format, core and core-test typecheck, oxlint on changed files, knip dead-export scans (0 entries), runtime import cycles (0), and the ratchets.pnpm protocol:checkpasses, including the Swift and Kotlin contract checks.pnpm buildpassed in round 1, on87f151f6.37a244b8eadds the new module toscripts/pr-lib/wrapper-components.txt. Hosted CI onafd032cf(run 38298916853) failed four tooling jobs on that omission, plus failures inherited frommainat the time. CI on37a244b8e(run 38342505531) passes. Locally on37a244b8e, the 8 focused files pass 126/126: the 3 changed test files, both compaction suites,eager-import-closure,pr-wrapper-source-closureandpr-worktree-provision-error.pnpm check:changedpasses too.pnpm checkandpnpm test, left to PR CI. No real isolated cron run either; the tests seed the persisted rows directly.Upgrade from 2026.10.2, condensed (2026.10.2 CLI as the client throughout; synthetic ids, token redacted)
Built Gateway
sessions.reset, before and after (synthetic ids, token redacted)Before (
main):{ "ok": false, "error": { "type": "gateway_request_error", "code": "UNAVAILABLE", "message": "Error: Transcript session 8f14e45f-ceea-4e7a-9f8b-2d5c6b1a0e93 is owned by agent:main:cron:3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d:run:8f14e45f-ceea-4e7a-9f8b-2d5c6b1a0e93, not agent:main:cron:3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d; resolve the ...", "retryable": false } }After (this branch):
{ "ok": false, "error": { "type": "gateway_request_error", "code": "UNAVAILABLE", "message": "Transcript session 8f14e45f-ceea-4e7a-9f8b-2d5c6b1a0e93 is owned by agent:main:cron:3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d:run:8f14e45f-ceea-4e7a-9f8b-2d5c6b1a0e93, not agent:main:cron:3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d; resolve the transcript target again before retrying.", "details": { "code": "SESSION_TRANSCRIPT_OWNER_MISMATCH", "sessionId": "8f14e45f-ceea-4e7a-9f8b-2d5c6b1a0e93", "ownerSessionKey": "agent:main:cron:3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d:run:8f14e45f-ceea-4e7a-9f8b-2d5c6b1a0e93", "requestedSessionKey": "agent:main:cron:3f1c9a52-7d4e-4b8a-9c21-5e6f7a8b9c0d" }, "retryable": false } }