Repository navigation
fix: pause interrupted shell turns when their result is unknown - #205859
Conversation
Record native shell dispatch before work can start. On restart, continue after a saved terminal result, or report uncertainty without asking the model to repeat or confirm an unknown effect. Refs #187354
|
🦞👀 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 changesThis PR records shell dispatch receipts and pauses interrupted turns whose terminal results were not durably saved. Example: A reminder command creates one job, then the Gateway restarts before saving its result.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a demonstrated recovery defect that remains on main; the prior findings are resolved and no new actionable defect was found. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherManaged embedded turns dispatch shell commands through the exec owners, persist accepted observations through the session writer, and let Gateway restart recovery choose between ordinary continuation and an uncertainty notice. flowchart TD
A[Managed chat turn] --> B[Session writer admits shell receipt]
B --> C[Gateway or node execution]
C --> D[Accepted terminal observation]
D --> E[Session receipt reconciliation]
E --> F[Gateway restart recovery]
F --> G[Continue verified turn]
F --> H[Pause uncertain turn]
Technical reviewBest possible solution: Keep shell admission, accepted-result reconciliation, and restart settlement under the existing session writer while preserving independent queued-input admission. Do we have a high-confidence way to reproduce the issue? The linked maintainer reproduction records duplicate scheduling after restart, and current main still sends ambiguous shell work through ordinary model recovery; this read-only review ran no target code. Is this the best way to solve the issue? The coherent fix connects pre-dispatch identity to durable terminal observations and recovery through existing owners; a prompt-only repair already failed the recorded control. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dde39b1b091f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +874, Tests +401, Docs +2, Other -1. Total +1276 across 44 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 (2 earlier review cycles)
Reviewed November 26, 2026, 5:06 AM ET / 10:06 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* commit '399057400013dcfa1923db08be96c6bf46cf7079': fix: keep known speakers on meeting notes with missing labels (#205923) fix(codex): let saved conversations recover after a remote failure (#201621) fix: distinguish namesakes in Google Meet transcript exports (#205915) refactor: share Discord meeting transcript publication (#205921) test: trim workflow and runtime performance coverage (#205782) fix(android): settle startup before checking archive refresh (#205891) fix: Gateway retains completed reply runtimes after catalog reloads (#195479) fix: clear unused-export failures in dependency checks (#205905) refactor: share browser routing for meeting captions and cleanup (#205916) fix(ui): update Workshop file preview mode (#205872) refactor(android): decouple shared JSON values from node handlers (#202840) fix(ci): remove bot credit from release notes (#205914) fix: pause interrupted shell turns when their result is unknown (#205859) fix(ui): skip publication options for removed workspaces (#205909) fix: preserve indentation in document previews (#205834) improve(ci): avoid full fixture builds for volume checks (#205903) refactor(android): derive connection readiness from its owner (#202898)
…oid-chat-preview-grapheme-boundary * commit '0bea7ecb3029583dd49d83f760d4f40c9e1f543c': (129 commits) fix(android): settle startup before checking archive refresh (#205891) fix: Gateway retains completed reply runtimes after catalog reloads (#195479) fix: clear unused-export failures in dependency checks (#205905) refactor: share browser routing for meeting captions and cleanup (#205916) fix(ui): update Workshop file preview mode (#205872) refactor(android): decouple shared JSON values from node handlers (#202840) fix(ci): remove bot credit from release notes (#205914) fix: pause interrupted shell turns when their result is unknown (#205859) fix(ui): skip publication options for removed workspaces (#205909) fix: preserve indentation in document previews (#205834) improve(ci): avoid full fixture builds for volume checks (#205903) refactor(android): derive connection readiness from its owner (#202898) fix: preserve side chat text when dictating at the limit (#205710) improve(telegram): polling workers start faster and use half the memory (#190890) fix: keep speaker identities distinct in meeting notes (#205860) fix: wait for cancellation before releasing ACP test preparation (#205893) fix: bound workers retained after deleting sessions across agents (#197409) fix(memory): keep a child's memory audience after its parent resets (#205887) refactor(android): give installed skills one data owner (#202892) fix(cli): share process failure listeners across invocations (#205732) ...
…offline (#205977) ## Problem An update that crosses an agent database schema version keeps the Gateway down while the pre-migration check scans the whole database. Doctor's migration default is QUICK, but QUICK runs a whole-file `PRAGMA quick_check` plus a whole-file `PRAGMA foreign_key_check` before it checks the tables the migration touches. `quick_check` reads every page, and `transcript_events` carries a foreign key, so both scans grow with the whole agent history. On a production deploy, a 67.4 GiB agent database spent 34 minutes in this check while the Gateway was stopped. An earlier deploy hit the service start timeout during the same check and needed manual recovery. The migration step itself only added a nullable column. A clean-close proof does not help here: the migration gate never reads it. Pending migrations always run this check ("Pending migrations cannot inherit an earlier runtime verification"). ## Solution The migration policy owner, `resolveSchemaMigrationIntegrityCheck`, already marks agent version steps 38-42 as `schemaOnly`, because those steps only read and write their declared tables. This change applies the same rule to every agent version step. The `schemaOnly` check now runs `integrity_check('sqlite_schema')`, then a full `integrity_check(T)` and `foreign_key_check(T)` for each table the step declares. It does not scan other pages. Before, it checked only `schema_meta`. The migration finalizer (`finishAgentSchemaMigration`) used the same scope only for steps 40-42 and otherwise ran an unqualified `foreign_key_check` inside the migration transaction. A schema-only step now checks only its declared, existing tables there too. A captured whole-file QUICK proof from the pre-migration backup still covers a schema-only step, so the check is not repeated. A QUICK result never publishes a full-verification receipt. So the next Gateway start owes the whole-database check. It runs in the existing deferred background verifier, the same as any restart without a clean-close proof. Unchanged: state databases, same-version repairs, unscoped migrations and `--full-integrity-check` keep the whole-file checks. ## Impact - Offline time for an agent schema step no longer grows with unrelated agent history. - Corruption in the schema catalog or in a table that the step declares still refuses the migration. - Accepted tradeoff (maintainer decision): a migration restart now verifies only the schema catalog plus the tables the migration declares before the agent database serves. The whole-file check runs afterwards in the existing deferred background verifier, the same as any restart without a clean-close proof. If a table the migration never touched is corrupt, that check quarantines the agent database when it finishes, and the existing corruption handling applies. Until then the agent serves from the database. In exchange, the Doctor migration phase on a 35.5 GB v43 database without a proof went from 365 s to 5.2 s (see Evidence). - Docs updated: integrity and recovery, updating, and CLI update. ## Evidence Measured on a 35.5 GB (33.1 GiB) synthetic agent database at schema v43 with no clean-close proof and an empty WAL. Bulk data sits in a table outside the v43 to v45 scope. Same machine (local NVMe), same fixture bytes (APFS clones), `openclaw doctor --fix --non-interactive` from built `dist/`, one run each: | Phase | Base `315b916f` | This change | | --- | --- | --- | | Doctor "database migrations" (pre-migration check plus v43 to v45) | 365 s, of which about 360 s is the whole-file check | 5.2 s | | Whole Doctor run | 866 s | 445 s | The remaining head time is Doctor's archive and original-state copies of the 33 GiB file. Limit: this fixture keeps its bulk in a table without a foreign key, so the base number excludes the whole-file foreign-key scans that FK-bearing history (`transcript_events`) adds in production, before and after the migration. The head run predates the finalizer change, which only removes work. After the migration, the agent integrity gate logs `mode=deferred, outcome=pending`: the whole-database check runs in the background at the next start. The base check cost grows with file size and disk speed. In production the same check took 34 minutes for 67.4 GiB. The scoped check depends only on the declared tables. Tests: - New corrupt-fixture test in `src/infra/sqlite-integrity.test.ts`, using the real policy for a v43 to v45 agent step. Corruption in a declared table (`session_nodes`) refuses the step. Corruption in an undeclared table (`cache_entries`) passes the step, and the owed FULL check refuses it. - New `openclaw-agent-pending-inputs-schema.test.ts` case: a v43 store with an orphan row in an undeclared FK table (`board_tabs`) migrates to the current schema. Base refuses at the pre-migration foreign-key check. With only the pre-migration change, it still refuses in the finalizer ("Agent schema migration failed foreign key validation"). Head passes. - `openclaw-agent-cold-navigation-migration.test.ts` now expects the scoped sequence for a v38 to current step: the catalog, then each declared table's integrity and foreign-key check, with no whole-file pass. - The state-database Doctor test that refuses an orphan foreign-key row in an untouched table still passes: state databases keep the whole-file check. - `pnpm check:changed`: typecheck, lint, format and guards pass. The dead-export scan reports `RecordDeferredShellOutcome` in `src/config/sessions/transcript-shell-receipt.ts`, which comes from `main` (#205859); this branch does not touch that file. Test cost: about +77 net test lines in existing files; the new cases use one small temporary database each. Not shown end to end: a later Gateway start detecting untouched-table damage. That path is the existing deferred background verification (production logs show `mode=deferred, outcome=pending` after this kind of migration); this change does not modify it. ## CI: release-update-survivor CI's `docker-seed-e2e` failed because the `release-update-survivor` lane hit its 3300 s budget (killed at 3310 s). It is not a product failure. I ran the same lane locally (Docker, `OPENCLAW_DOCKER_ALL_LANES=release-update-survivor`, CI env, one lane at a time) on this head and on the base: | Phase | Head `cb1fb104` | Base `315b916f` | | --- | --- | --- | | Release fixture (in-lane candidate build) | ≤ 973 s | 812 s | | Migration-chain vitest | 54 s | not selected | | Base install + build + pack (downgrade source) | 867 s | not selected | | healthy | 227 s, pass (update succeeded, serving schema 43) | 191 s, pass | | crash | 195 s, pass (update failed, rolled back to schema 42 as designed) | 196 s, pass | | downgrade | 158 s, pass (`mode=enforced`) | not selected | | Total | 2516 s, pass | 1222 s, pass | Every product phase passes, and healthy and crash take about the same time as on the base. The extra time on head is lane work that #205857 added for PRs that change `src/state` schema or migration files: the migration-chain vitest, a full install, build and pack of the base, and the downgrade case. The base does not select it. Every passing CI run of this lane today had it unselected. The CI runner took 2.2x as long as the local machine for the same package build. At that rate this lane's 2516 s is an estimated 90 min on CI, well over the 3300 s budget. This is an estimate: CI did not record per-phase times before it killed the lane. The `docker-seed-e2e` override (and the `openclaw/ci-gate` result that follows from it) is authorized on this evidence. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#205859) * fix(gateway): pause interrupted shell turns without a verified outcome Record native shell dispatch before work can start. On restart, continue after a saved terminal result, or report uncertainty without asking the model to repeat or confirm an unknown effect. Refs openclaw#187354 * fix(gateway): settle deferred shell outcomes in the session store Refs openclaw#187354 * fix(agents): retain shell receipts when process cleanup is uncertain Refs openclaw#187354
…offline (openclaw#205977) ## Problem An update that crosses an agent database schema version keeps the Gateway down while the pre-migration check scans the whole database. Doctor's migration default is QUICK, but QUICK runs a whole-file `PRAGMA quick_check` plus a whole-file `PRAGMA foreign_key_check` before it checks the tables the migration touches. `quick_check` reads every page, and `transcript_events` carries a foreign key, so both scans grow with the whole agent history. On a production deploy, a 67.4 GiB agent database spent 34 minutes in this check while the Gateway was stopped. An earlier deploy hit the service start timeout during the same check and needed manual recovery. The migration step itself only added a nullable column. A clean-close proof does not help here: the migration gate never reads it. Pending migrations always run this check ("Pending migrations cannot inherit an earlier runtime verification"). ## Solution The migration policy owner, `resolveSchemaMigrationIntegrityCheck`, already marks agent version steps 38-42 as `schemaOnly`, because those steps only read and write their declared tables. This change applies the same rule to every agent version step. The `schemaOnly` check now runs `integrity_check('sqlite_schema')`, then a full `integrity_check(T)` and `foreign_key_check(T)` for each table the step declares. It does not scan other pages. Before, it checked only `schema_meta`. The migration finalizer (`finishAgentSchemaMigration`) used the same scope only for steps 40-42 and otherwise ran an unqualified `foreign_key_check` inside the migration transaction. A schema-only step now checks only its declared, existing tables there too. A captured whole-file QUICK proof from the pre-migration backup still covers a schema-only step, so the check is not repeated. A QUICK result never publishes a full-verification receipt. So the next Gateway start owes the whole-database check. It runs in the existing deferred background verifier, the same as any restart without a clean-close proof. Unchanged: state databases, same-version repairs, unscoped migrations and `--full-integrity-check` keep the whole-file checks. ## Impact - Offline time for an agent schema step no longer grows with unrelated agent history. - Corruption in the schema catalog or in a table that the step declares still refuses the migration. - Accepted tradeoff (maintainer decision): a migration restart now verifies only the schema catalog plus the tables the migration declares before the agent database serves. The whole-file check runs afterwards in the existing deferred background verifier, the same as any restart without a clean-close proof. If a table the migration never touched is corrupt, that check quarantines the agent database when it finishes, and the existing corruption handling applies. Until then the agent serves from the database. In exchange, the Doctor migration phase on a 35.5 GB v43 database without a proof went from 365 s to 5.2 s (see Evidence). - Docs updated: integrity and recovery, updating, and CLI update. ## Evidence Measured on a 35.5 GB (33.1 GiB) synthetic agent database at schema v43 with no clean-close proof and an empty WAL. Bulk data sits in a table outside the v43 to v45 scope. Same machine (local NVMe), same fixture bytes (APFS clones), `openclaw doctor --fix --non-interactive` from built `dist/`, one run each: | Phase | Base `6eac76fb` | This change | | --- | --- | --- | | Doctor "database migrations" (pre-migration check plus v43 to v45) | 365 s, of which about 360 s is the whole-file check | 5.2 s | | Whole Doctor run | 866 s | 445 s | The remaining head time is Doctor's archive and original-state copies of the 33 GiB file. Limit: this fixture keeps its bulk in a table without a foreign key, so the base number excludes the whole-file foreign-key scans that FK-bearing history (`transcript_events`) adds in production, before and after the migration. The head run predates the finalizer change, which only removes work. After the migration, the agent integrity gate logs `mode=deferred, outcome=pending`: the whole-database check runs in the background at the next start. The base check cost grows with file size and disk speed. In production the same check took 34 minutes for 67.4 GiB. The scoped check depends only on the declared tables. Tests: - New corrupt-fixture test in `src/infra/sqlite-integrity.test.ts`, using the real policy for a v43 to v45 agent step. Corruption in a declared table (`session_nodes`) refuses the step. Corruption in an undeclared table (`cache_entries`) passes the step, and the owed FULL check refuses it. - New `openclaw-agent-pending-inputs-schema.test.ts` case: a v43 store with an orphan row in an undeclared FK table (`board_tabs`) migrates to the current schema. Base refuses at the pre-migration foreign-key check. With only the pre-migration change, it still refuses in the finalizer ("Agent schema migration failed foreign key validation"). Head passes. - `openclaw-agent-cold-navigation-migration.test.ts` now expects the scoped sequence for a v38 to current step: the catalog, then each declared table's integrity and foreign-key check, with no whole-file pass. - The state-database Doctor test that refuses an orphan foreign-key row in an untouched table still passes: state databases keep the whole-file check. - `pnpm check:changed`: typecheck, lint, format and guards pass. The dead-export scan reports `RecordDeferredShellOutcome` in `src/config/sessions/transcript-shell-receipt.ts`, which comes from `main` (openclaw#205859); this branch does not touch that file. Test cost: about +77 net test lines in existing files; the new cases use one small temporary database each. Not shown end to end: a later Gateway start detecting untouched-table damage. That path is the existing deferred background verification (production logs show `mode=deferred, outcome=pending` after this kind of migration); this change does not modify it. ## CI: release-update-survivor CI's `docker-seed-e2e` failed because the `release-update-survivor` lane hit its 3300 s budget (killed at 3310 s). It is not a product failure. I ran the same lane locally (Docker, `OPENCLAW_DOCKER_ALL_LANES=release-update-survivor`, CI env, one lane at a time) on this head and on the base: | Phase | Head `cb1fb104` | Base `6eac76fb` | | --- | --- | --- | | Release fixture (in-lane candidate build) | ≤ 973 s | 812 s | | Migration-chain vitest | 54 s | not selected | | Base install + build + pack (downgrade source) | 867 s | not selected | | healthy | 227 s, pass (update succeeded, serving schema 43) | 191 s, pass | | crash | 195 s, pass (update failed, rolled back to schema 42 as designed) | 196 s, pass | | downgrade | 158 s, pass (`mode=enforced`) | not selected | | Total | 2516 s, pass | 1222 s, pass | Every product phase passes, and healthy and crash take about the same time as on the base. The extra time on head is lane work that openclaw#205857 added for PRs that change `src/state` schema or migration files: the migration-chain vitest, a full install, build and pack of the base, and the downgrade case. The base does not select it. Every passing CI run of this lane today had it unselected. The CI runner took 2.2x as long as the local machine for the same package build. At that rate this lane's 2516 s is an estimated 90 min on CI, well over the 3300 s budget. This is an estimate: CI did not record per-phase times before it killed the lane. The `docker-seed-e2e` override (and the `openclaw/ci-gate` result that follows from it) is authorized on this evidence. Co-authored-by: Ayaan Zaidi <[email protected]>
…chiving (#205026) * fix(sessions): keep inactive chats eligible for cold storage after archiving * test(sessions): align archive fixtures and identity baseline * test(sessions): create a private cold backup restore target (cherry picked from commit 81d69df) Follow-ups: 7cb8975 fix: keep forked Claude chats separate after a Gateway crash (#208048) [separately ordered lane row]; ece7a74 improve(workboard): apply the Control UI glossary and style to Workboard copy [not selected for this narrow backport]; b616036 refactor(subagents): simplify ACP spawn relay ownership (#207023) [not selected for this narrow backport]; 93ca762 improve: reduce allocations when preparing session rows (#207109) [not selected for this narrow backport]; 9993328 refactor(subagents): simplify kill claim and ownership handling (#207025) [not selected for this narrow backport]; 97815bd refactor(subagents): consolidate registry cleanup and publication guards (#207064) [not selected for this narrow backport]; e94f799 refactor(subagents): centralize requester turn matching (#206584) [not selected for this narrow backport]; ea77ca3 refactor: report update failures from recorded runs (#206700) [not selected for this narrow backport]; 4d7e00b fix: let started participant runs and requests finish after an access change (#206747) [not selected for this narrow backport]; f89ae43 refactor(subagents): use cleanup and terminal owners in sweeps (#206533) [not selected for this narrow backport]; a882e0f fix(agents): preserve task answers when sessions are reused (#126263) [not selected for this narrow backport]; 81fc833 refactor(subagents): own dormant child Stop decisions (#206479) [not selected for this narrow backport]; 91d4912 fix(update): stop using foreign recovery records as admission (#206295) [not selected for this narrow backport]; be3c73e fix(subagents): finish claimed stops after session rotation (#206405) [not selected for this narrow backport]; ed8b883 fix(update): settle after plugins and share one completion summary (#205987) [not selected for this narrow backport]; 1de306e fix: pause interrupted shell turns when their result is unknown (#205859) [separately ordered lane row]; 16a6aa4 fix(memory): keep a child's memory audience after its parent resets (#205887) [not selected for this narrow backport]; 50a7368 feat: let agents snooze a conversation after replying [not selected for this narrow backport]; 40f3903 fix(ci): remove unused role and workflow exports (#205720) [not selected for this narrow backport]; e43debf refactor(state): migrate in place and remove copy-and-swap (#205165) [not selected for this narrow backport]; 8027293 refactor(plugins): plugin tools take the turn's owner bit; delete the requester-owner continuation (OA2 PR 6j) (#205483) [not selected for this narrow backport]; 13e2ec3 feat: let participants publish through the session's shared GitHub account (#204914) [not selected for this narrow backport]; 5434992 fix: use the configured runtime when switching model providers (#203973) [not selected for this narrow backport]; 5271519 fix(feishu): honor the filename override on sent attachments (#205287) [not selected for this narrow backport]; ca087d4 refactor(admission): drop the replay automationAdmin bit and the R7 source re-check (#205268) [not selected for this narrow backport] Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
A Gateway restart can interrupt a shell command after it creates a reminder but before the chat saves the result. In a reproduced case the agent repeated the command, created a second reminder and told the user the work was complete. The same confirmation was possible when the command had never reached the scheduler.
User Impact
When a managed chat has an interrupted shell command with no verified terminal result, the Gateway tells the user that the effect is unknown and pauses that turn. A separate queued message can still receive a reply. A saved terminal result lets ordinary restart recovery continue. A command that cannot record its session ownership is refused before dispatch.
Why This Change Was Made
The native shell records a private invocation identity before local execution, remote dispatch or a deferred approval. The session store checks the writer, run and lifecycle revision before admitting the command. An accepted tool result, a terminal poll of the same process, or a recorded terminal decision from its deferred approval can settle it. Gateway and node approvals record a definite denial or an observed exit before attempting follow-up delivery. An approval still waiting, a lost node response and uncertain process cleanup leave the receipt outstanding.
Restart reconciles accepted observations in the session store. If an original call is still pending, it saves the uncertainty notice, uses the admitted input’s verified return route and acknowledges the exact restart marker. The receipt contains no command text. The change uses the existing session row and transcript indexes.
Evidence
112970b976eb7479479a8125a0272e2bc3803666. Scoped lint reported zero errors and warnings. Gateway test types passed. The identity ratchet decreased from 6,205 comparisons in 1,557 files to 6,200 in 1,556. The before-exit and post-exit assertions both passed. Commit review reported no actionable P0/P1 findings. Exact tree, authenticated upgrade and focused checksAcross the PR, production source changed by +991/−117 lines and tests by +430/−29. The production additions give the session writer one bounded way to connect dispatch, accepted results and restart reporting across direct, nested, background and deferred execution.
The same WebChat conversation is shown immediately before and after the fixture Gateway restarted. The temporary fixture path is redacted.
Related to issue 187354, reported by @fonchaves. Their scheduler catalog fix and the typed restart fix landed separately. The reported ARM container OOM and SQLite lease contention remain unverified.