Repository navigation
fix(sessions): carry question answer custody into async writes - #169306
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 maintainer review before merge. What this changesThe PR carries accepted question-answer receipts into async transcript writes while preserving live authority and transcript identity checks. Example: A waiting ask_user turn receives destination Lisbon and budget 2000.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current async question-continuation failure, and no actionable introduced defect was found. The follow-up addresses the earlier commit-time revocation concern; exact-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe session persistence layer receives prepared agent messages and host-held answer receipts, validates them through the existing worker append owner, and publishes committed transcript results. flowchart TD
A[Accepted question answer] --> B[Host answer custody]
B --> C[SessionManager persistence]
C --> D[Worker append kernel]
D --> E[SQLite transcript]
C --> F[Live authority assertion]
F --> D
E --> G[Waiting agent continuation]
Technical reviewBest possible solution: Retain the explicit receipt transfer through the existing append owner and its live authority checks. Do we have a high-confidence way to reproduce the issue? Current-main source shows the worker cannot access host-held answer custody, and the PR reports the converted async regression failing with SqliteTranscriptMutationConflictError before repair; this review ran no target code. Is this the best way to solve the issue? The patch repairs the host-to-worker boundary directly, updates both async adapters and synchronous validation, and removes the replaced lookup without creating a second authority owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9607478c76a4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +27, Tests +16, Docs +5. Total +48 across 8 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 11, 2026, 3:44 PM ET / 19:44 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…law#169306) * fix(sessions): carry question answer custody into async writes * test(sessions): fence question custody at worker commit
…ound append (openclaw#174994) The settlement rebase already admits an intervening user turn when the ingress claim carries it into the blocked run's questionAnswers custody (openclaw#169306). Pin that production shape end to end: the settlement runs inside withSessionTranscriptQuestionAnswers, the answer is a real UserTurnTranscriptRecorder persisted by a claim that admits it after persistApproved(), and the toolResult lands after the inbound answer instead of dying with a rebase refusal.
First-parent upstream e63e209..0b0c2f2 (93 commits, including openclaw#169144 subagent work across gateway restarts, openclaw#169251 worker write transaction overhead, openclaw#169306 question-answer custody, openclaw#169305 fallback ordering, openclaw#169339 owner-state rechecks, openclaw#169235/openclaw#168887 Solid UI ports). Stops before openclaw#169315 (fp#248, agent schema), which is step 59 on its own. Conflicts: - embedded-agent-runner/run/payloads.ts: upstream gates the assistant-texts branch on !assistantForPayload (an empty canonical terminal stays authoritative); kept our per-hop raw-answer split for earlier continuation signals ahead of it. - session-reset-cleanup.test.ts: upstream's retainEmbeddedSessionPromptState disposable; kept our async clearSessionResetRuntimeState call. - plugin-sdk-surface-report.mts: upstream 3674/2135, ours +11/+4. - config-baseline counts/sha256 and worker-access inventory regenerated on the merged tree (core +17 fork config entries, as before). Auto-merged files that carry continuation overlay (19, incl. attempt-execution, agent-runner-fallback-candidate, session.ts, status-message, stream/update handlers) keep the overlay byte-for-byte. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…logging and tests: 41 conflict files Resolved against base v2026.10.8; each import kept only where the merged file uses it. Ported onto beta.4's reshaped code (the fork change kept, beta.4's mechanism taken): - heartbeat awareness dedupe: beta.4 (openclaw#169622) dropped the pre-send lifecycle recheck (`latest`); the dedupe compares the prepare-time worker read, the post-send re-read is readSessionEntryReadOnlyInWorker with readConsistency "latest". - prompt prelude: openclaw#166869's space-joiner ordering applies to `text`; the fork's version-3 Telegram carrier keeps the paragraph order (no joiner completes it). - directive acks: beta.4 removed the thinking-remap ack; the fork's queue-ack helper stays. - secret redaction: beta.4 (openclaw#169063) removed the registry snapshot scope; the fork's getLongestRegisteredSecretLength loses its scoped branch and its scoped test case. - committed-turn entry read (pending inputs): beta.4 replaced PendingInputScope.incognito with session-actor storage; the read goes through readSessionEntryReadOnlyInWorker. - persisted install records: beta.4 (openclaw#169714) made the reader async; install-persistence and the CLI test mocks use readPersistedInstalledPluginIndexInstallRecordsAsync. - sessions.patch and cron validation mock modules (fork line-cap extractions) take beta.4's readAcpSessionMetaForEntryAsync, cron-session-reader and inference-binding mocks. - test cases beta.4 removed as low-value (openclaw#172040) stay removed; the fork's own cases stay. Native in beta.4, fork side dropped: question-answer custody in prepared-assistant validation (openclaw#169306), the realtime-voice turn exception, the cron host test helper.
…tart-recovery conflicts Takes beta.4 where it carries a fork change natively. Elsewhere it keeps the fork's delta on top of beta.4's code. - Native on beta.4, fork copies dropped: - openclaw#169306 (e353566): session-manager-persistence.ts and session-manager-metadata.worker.ts are byte-identical to beta.4. The fork's session-manager-append-custody.ts pull-forward is deleted; it has no importers left. - openclaw#158161 (177b090): classify.legacy-provider-predicates.test.ts is byte-identical to beta.4, whose corpus carries the same three TGI rows. - runtime-read.ts is beta.4's re-export. The fork's skipInheritance option moves to runtime-read.types.ts, where beta.4 now defines LoadAuthProfileStoreOptions (store.ts and models auth clean pass it). - Fork deltas kept on beta.4's code: - auth-controller.ts: openclaw#93952's withAuthDeadline around beta.4's forceRefresh argument object; the cooldown-probe extraction and its re-export stay (it inlines beta.4's file-local resolveUnavailableAuthReason). - auth-controller.test-support.ts: beta.4's runtime-provider change, which its SIWC tests need, moves into the fork's split-out harness. - failover tests: beta.4's case moves, plus the fork's Anthropic long-context 429 overflow test and its classified-reason 5xx copy test. - assistant-failure.ts: union of imports (recordModelFallbackStop and isPreDispatchToolCallRejectionMessage). - session-store.ts: the fork's per-attempt contextSnapshot ahead of beta.4's buildMainSessionRecoveryAfterAgentRunPatch, so recovery sees its totals. - session-manager-entries.ts: the fork's checkpoint-handle formatter with beta.4's createEntry timestamp. - restart recovery (dispatch, delivery, tests): beta.4's prepareRestartRecoveryDeliveryCurrent and isCurrent structure; the fork's restart-cause wording passes cause to announceRestartRecoveryResumption. - oauth-common-mocks.test-support.ts: beta.4's importOriginal spread, keeping the fork's syncEnvBackedTokenCredentials identity override. - docs/concepts/oauth.md: the fork's dead-grant paragraph in beta.4's wording. - Tests that follow upstream's openclaw#170532 pruning: 3 of the 5 tests in the fork's transcript-file-state.compaction-checkpoint.test.ts are removed, because upstream deleted the same tests; the 2 that remain keep the checkpoint-handle pins. - runtime-context-prompt.ts: the clean merge ran the fork's carrierText through openclaw#166869's joiner-aware append, which puts late context first for a space joiner. The carrier is rendered without a joiner (prompt-prelude.ts), so it gets its own paragraph-order append. The existing joiner test now pins carrierText for both joiners. Not built here (no builds on this host); tsgo and tests run on the M4.
What Problem This Solves
The async transcript writer rejected an accepted
ask_useranswer as an unrelated new user turn. The waiting agent can now persist its tool result and continue after its answer enters history.User Impact
Structured-question continuations work through the production worker-backed session manager. Unrelated user turns, changed transcript branches, cancellation, revoked authority and rewritten answer sources still prevent stale writes. No configuration or schema migration is required.
Why This Change Was Made
Question-answer custody was held in host AsyncLocalStorage, while worker turn validation could see only the original admission. Capture the existing owner's answer receipts once and carry those facts into the shared append kernel. The host's existing transaction/commit assertions revalidate live custody; the kernel checks current row identity. The old host-only per-row lookup is removed. Deslop retained the necessary explicit worker contract rather than adding a fallback or second authority owner.
Evidence
Converting the existing partial-then-complete regression to
openAsyncandappendMessageAsyncfailed before the repair with SqliteTranscriptMutationConflictError after the answer persisted. The same positive case passed after the repair. All eight question scenarios now exercise async writes, including foreign registration, unrelated user, retired authority, changed branch, rewritten source, missing generation and cancellation.Question-answer, ancestry and ask-user rewrite-settlement proof: 28/28 pass across three files, 155.959 seconds wall time; question case bodies total 12.727 seconds. The original focused async regression took 113.410 seconds cold wall time, including 42.767 seconds preparing workers, and failed as expected. Fresh isolated Codex review through P2: scoped-clean. Production delta: +27 lines after removing superseded lookup logic. The original production head passed exact-head CI, including all source, type, lint, guard, documentation and boundary jobs. After those hosted jobs completed, the duplicate local changed-check run was interrupted with exit 130; its format, guards, core graph boundary, production types and first five test graphs had passed. This is reused hosted coverage, not a full local-check pass.
The followup strengthens the existing closed-authority case at the real worker's final commit admission. The revocation hook ran exactly once after receipt transfer, the append returned its authority conflict, persisted tool-result count was zero, and the provider did not resume. Allowed partial/final continuation, unrelated input, queued revocation and cancellation passed together: 4/4 selected cases, 28.636 seconds wall time; revoked-commit case 278 milliseconds. The owning agents-sessions test typegraph passed in 57.997 seconds, targeted type-aware lint in 65.914 seconds including artifact-lock wait, and formatting/diff checks passed. Fresh isolated final-diff review through P2 is scoped-clean (89.651 seconds). Production bytes are unchanged by this test-only followup. Final-head enforced CI passed on a3baf27; all 69 jobs completed successfully or were skipped. The final-head ClawSweeper review marked the owner-boundary proof sufficient and reported no findings.
This is production-owner transcript and authority proof: it exercises the shared async storage boundary and reads the committed transcript. The change does not alter any Telegram or other channel transport contract.