Repository navigation
fix: chat.inject fails after a shared session entry is cached - #170137
Conversation
resolveSessionTranscriptRuntimeTarget returned the requested key whenever a retained entry row named the requested session ID. That does not prove transcript ownership: an isolated cron run's row is written after its base row and owns the shared transcript. After sessions.abort retained the base row's facts, chat.inject on the base key hit the ownership check on every attempt, while the uncached path wrote to the owner. Retained facts carry no window owner, so drop the cached branch and always read the persisted session-ID index, as the uncached path does. Each resolution that used the cached branch now costs one runtime-target worker request (one SQL statement, 1.2 when qualified); measured locally that is about 0.5-1.8 ms at p50 per resolution, and the gateway concurrency benchmark shows no difference beyond its noise. Publishing a proven owner from actor state and write postimages would keep the cached branch for those sources. Proof: a Gateway WebSocket regression (sessions.abort, then two chat.inject calls) and a resolver case for the shared session ID fail on main and pass with the fix. The openclaw#168677 pin keeps its behavioral checks (current transcript and lifecycle revision) without a read-count bound. Refs openclaw#168677
|
🦞👀 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 real behavior proof before merge. What this changesThis PR resolves cached transcript targets through their persisted owner and closes a leaking test authority snapshot. Example: After sessions.abort caches agent:main:cron:job, inject "first" and "second" while agent:main:cron:job:run:selected-window owns the shared transcript.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — suspected predecessor, not a causality claim: source commit Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR fixes a deterministic transcript-owner regression still present on current main, and the reviewed diff introduces no actionable code findings. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway transcript writers submit session identities to the shared resolver, which selects the physical transcript owner before transactional append checks. flowchart TD
A[Gateway chat.inject] --> B[Transcript turn persistence]
B --> C[Runtime target resolver]
C --> D[Admitted session read worker]
D --> E[Persisted window owner]
E --> F[Transactional ownership check]
F --> G[Transcript append]
Technical reviewBest possible solution: Use the existing persisted-window owner lookup for durable transcript targets while retaining transactional ownership checks. Do we have a high-confidence way to reproduce the issue? The linked report's shared-ID fixture and Gateway failure frames match the current-main cache shortcut and transactional rejection; no target code was executed during this read-only review. Is this the best way to solve the issue? Removing the unsupported shortcut restores the established owner contract with less complexity than introducing cached ownership facts and another invalidation lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 86380bba721a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -22, Tests +46, Docs 0. Total +24 across 5 files. Added test files: 0. 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 HistoryReviewed October 15, 2026, 5:08 AM ET / 09:08 UTC (Revision 3). |
|
CI triage for run 38295714460 (19 failing 31 files fail only on the prepared-config contract from #169714. Each failing case in them either throws The other 17 files.
Summary: 13 of these 17 files fail locally with either resolver, with the same cases and messages. The 4 that pass locally (two of them failed in CI with |
Merge current main, retain the authoritative worker lookup, strengthen injected-message and owner-lifecycle regressions, and document shared-transcript behavior. Fixes openclaw#170136. Co-authored-by: Serghei <[email protected]>
Resolve durable transcript targets through the admitted owner lookup when cron base/run rows share a session ID. Preserve owner lifecycle revisions and cover two ordered chat.inject calls after sessions.abort warms the row. Close the steering fixture's extra tool-authority snapshot, which retains one entry predicate and polluted the following Goal cleanup assertions. Check zero retained facts at the originating fixture without changing the production accounting or existing Goal assertion. Fixes openclaw#170136 Co-authored-by: Serghei <[email protected]>
Preserve the original PR ancestry while retaining the independently reimplemented and reviewed maintainer tree. No source changes in this merge.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#170137) * fix(sessions): resolve cached transcript targets through their owner resolveSessionTranscriptRuntimeTarget returned the requested key whenever a retained entry row named the requested session ID. That does not prove transcript ownership: an isolated cron run's row is written after its base row and owns the shared transcript. After sessions.abort retained the base row's facts, chat.inject on the base key hit the ownership check on every attempt, while the uncached path wrote to the owner. Retained facts carry no window owner, so drop the cached branch and always read the persisted session-ID index, as the uncached path does. Each resolution that used the cached branch now costs one runtime-target worker request (one SQL statement, 1.2 when qualified); measured locally that is about 0.5-1.8 ms at p50 per resolution, and the gateway concurrency benchmark shows no difference beyond its noise. Publishing a proven owner from actor state and write postimages would keep the cached branch for those sources. Proof: a Gateway WebSocket regression (sessions.abort, then two chat.inject calls) and a resolver case for the shared session ID fail on main and pass with the fix. The openclaw#168677 pin keeps its behavioral checks (current transcript and lifecycle revision) without a read-count bound. Refs openclaw#168677 * fix(sessions): preserve transcript ownership after cached entry reads Resolve durable transcript targets through the admitted owner lookup when cron base/run rows share a session ID. Preserve owner lifecycle revisions and cover two ordered chat.inject calls after sessions.abort warms the row. Close the steering fixture's extra tool-authority snapshot, which retains one entry predicate and polluted the following Goal cleanup assertions. Check zero retained facts at the originating fixture without changing the production accounting or existing Goal assertion. Fixes openclaw#170136 Co-authored-by: Serghei <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Serghei <[email protected]>
Fixes #170136
Refs #168677
What Problem This Solves
chat.injectfails with “Transcript session … is owned by …” after a cron base row is cached when its isolated:run:<sessionId>row owns their shared transcript.User Impact
Injected notes reach the transcript owner whether or not the requested row was cached. No configuration change, migration, or protocol change is required.
Why This Change Was Made
The shortcut introduced in
3bbc221d1c8c(#168677) treated a matching cached entry session ID as proof of transcript ownership. Base and run rows can share that ID;session_windows.session_keyidentifies the owner. Removing the shortcut uses the existing admitted worker lookup, preserves the transactional ownership checks and post-await authority checks, and removes 22 production lines. Formerly cached durable targets now require one worker lookup. Memory-backed behavior is unchanged, and there is no new cache, schema, main-thread SQL, or detached/background effect.The prior PR CI's fourteen
sessions-goal.test.tsfailures exposed a separate fixture leak. The preceding steering test created a second tool-authority snapshot for the shared-secret owner and released only its operator authority. Fingerprinting retains an entry predicate owned by the tool snapshot; itsclose()was missing. The fixture now closes that snapshot infinallyand checks zero retained facts after its own cleanup. The existing “Completed handlers must release retained session sharing facts” assertion and production accounting are unchanged.Original fix by @xyrolle (Serghei); this maintainer implementation preserves contributor credit and history. The separate typed-refusal work in #170176 remains outside this fix.
Evidence
PR CI is the test gate per maintainer policy. It covers Gateway/config regressions and sibling suites, typechecks, lint, build, and repository checks. Exact head
eb5892da0815e91de8520866372ff24611bb8f7cpassed CI run 38706420593: 81 checks succeeded, 28 skipped, zero failures, on the first attempt. All typecheck and lint checks passed; no inherited-failure exception or CI rerun was needed.Exact-head test results, recovered from the cached completed-run archive:
sessions-goal.test.tschat-send-steering-custody.test.tssession-accessor.transcript-identity.test.tsserver.sessions.store-rpc.test.tsTimes above are individual CI case times, not isolated-file wall times. The new cases reuse existing fixtures and add no timer, sleep, or polling. The latest ClawSweeper review (comment 6130947649, reviewed head
3fb78b2737bf) has no code findings and reports complete fix scope; it has not reviewed this new head. No new code finding was present at closeout. PR CI supplies the proof under maintainer policy.Regression coverage:
resolves a shared session ID to its transcript owner after the requested row's facts are retainedchecks both owner key and owner lifecycle revision. Existing across-entry-write revision assertions remain; only the read-count expectation requiring the broken shortcut is removed.chat.inject writes to the transcript owner after the requested row's facts are cacheduses the base/run key shape, warms the base row withsessions.abort, injects twice, and checks exactly the ordered assistant notes in the owner's transcript.preserves authenticated chat.send steering authority across callers (shared-secret owner)now checks zero retained sharing facts at the leaking fixture's boundary; existing Goal cleanup assertions remain intact.Source/history confirmation used
git log -p -S 'const current = sessionKey'and the realchat.inject→ transcript resolver → transactional writer path. Prior CI log 38693348811 / 116284566103 shows a fixed retained count of one in all fourteen Goal cases, with the steering suite completing immediately beforehand.Changed-file
oxfmt --checkpassed (344 ms, five files). Bothnode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.jsonand directoxlinton the four changed TypeScript files exited 0. Deslop is complete. Precommit and prescribed committed-branch Codex autoreview are both scoped-clean at P0–P2 with no actionable findings. The final main merge left the five patch files and reviewed lifetime owners byte-identical to the branch-reviewed candidate;git diff --checkpassed. The installed canonical helper is used because the repository launcher is absent, retaining isolation and the requested engine/priority settings. Local unit/module tests, typechecks, negative controls, and live Gateway proof were intentionally skipped per maintainer policy. No Crabbox/Testbox lease was created. Test execution times come from CI; no local runtime measurement is claimed.