Skip to content

fix: guard widget recovery after Gateway crashes - #165468

Merged
steipete merged 1 commit into
mainfrom
codex/w170-widget-recovery
Oct 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/w170-widget-recovery

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Protects automatic widget-turn recovery after a Gateway crash when the session database becomes available after the initial recovery scan.

Related: #165225. The producer fix already landed in c1b9f4e while this reproduction was being developed. This PR adds the missing deterministic process-level regression; production LOC is unchanged.

User Impact

An interrupted dashboard-authoring turn resumes without reconnecting an inline-widget client, updates its pinned widget, and reaches a durable done state. No configuration, schema, or timeout changes.

Why This Change Was Made

The observed hasActiveRun: false / status: running mismatch was a missed recovery handoff: startup correctly skipped a database awaiting inspection, but never revisited it after admission succeeded. The existing live fixture failed before checking the resumed provider turn, so it could not distinguish this from lost terminal persistence.

The new local Responses provider drives the real widget and exec tools, then the test kills and replaces only its own isolated Gateway. After recovery it waits for terminal publication and verifies SQLite state, session-list state, widget revision, and exactly one final reply. The landed scheduler fix owns admission recovery; the test does not change status projection or the live fixture's expectations.

Evidence

The reproduction failed on unmodified main 56bdfc723e0d on both Node 24.21.0 and the repository-pinned Bun 1.4.3 fork: two provider calls before the crash, none after restart, and the original session row still running after database admission completed.

It passes against main afc9b8afde74, which contains the producer fix, on both runtimes. Both report persisted/projected done, hasActiveRun: false, widget revision 2, and one final transcript marker. Provider traffic is loopback-only with synthetic credentials; state, ports, and logs belong to the fixture.

Measured file cost: Node 35.2 seconds of test time / 67.2 seconds wrapper wall; Bun 66.7 seconds of test time / 127.0 seconds wrapper wall. Wrapper wall includes isolated worker compilation. The process-replacement and database-admission ordering require this E2E boundary; the landed fix separately covers scheduling with fast focused tests. This E2E file stays in the existing E2E lane, outside ordinary per-PR unit execution.

P2 autoreview is scoped-clean. Final root-test types, script/test lint, formatting, diff checks, and Madge (0 cycles) pass. check-changed stops at existing unused exports in Google Meet, memory-wiki, workboard, and meeting-bot; the same exports fail on clean main 3b8ccf88c6e1. Remaining planned type/lint checks were run directly and pass. Exact-head CI 37288698158 passed: 14 successful jobs, 30 configured skips, no retries. The ordinary PR matrix does not select this E2E file, so its CI test duration is not applicable. ClawSweeper completed the exact-head review with no findings. No live-provider replay was run.

Exercise the real widget and exec tools with a local Responses provider across an owned Gateway crash. Assert successful terminal publication, durable and projected completion, widget revision, and one final reply.

The missing database-admission handoff was already repaired by c1b9f4e (related to #165225). This regression fails before that repair on Node and Bun, and passes afterward without live provider credentials.
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 5, 2026 09:14
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 5:18 AM ET / 09:18 UTC.

ClawSweeper review

What this changes

Adds an end-to-end test that crashes an isolated Gateway during widget authoring and verifies automatic recovery, durable completion, widget updates, and one final reply.

Merge readiness

✅ Ready for maintainer review

Keep open: the production repair is already on main, but this PR adds useful process-level regression coverage that main lacks. No blocking patch defects were found.

Priority: P2
Reviewed head: ef3b8187dc5ec3dc7260d9619ebb9a95ce735e0d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused regression coverage with documented before/after runtime results and no identified blocking defects.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body records Node and Bun before/after runs through real Gateway processes and transport clients using a synthetic loopback provider. The inspected scenario crashes the owned Gateway, observes automatic recovery without inline-widget capability, and verifies durable/projected completion, widget revision, and one final reply; no stored-data contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body records Node and Bun before/after runs through real Gateway processes and transport clients using a synthetic loopback provider. The inspected scenario crashes the owned Gateway, observes automatic recovery without inline-widget capability, and verifies durable/projected completion, widget revision, and one final reply; no stored-data contract changes require migration proof.
Evidence reviewed 10 items Verified introduction boundary: The pinned merge-base-to-head diff adds only the regression test. The complete added file was read; no production, dependency, workflow, or schema changes are introduced.
Actual merge preserves current main: The test merge's raw parents are exactly the pinned main followed by the original PR head. Comparing that result against main changes only the added test, so endpoint drift does not remove intervening production fixes.
Production repair already exists: The recovery owner subscribes to database-admission publication and serializes another recovery scan for newly admitted agents. The exact patch against its raw recorded parent verifies this change independently of blame.
Findings None None.
Security None None.

How this fits together

Gateway restart recovery resumes interrupted agent turns after their session databases become available. The regression exercises that recovery through real Gateway connections, tool execution, and persisted session state.

flowchart TD
  A[Widget authoring request] --> B[Gateway agent turn]
  B --> C[Owned Gateway crash]
  C --> D[Restart and database admission]
  D --> E[Automatic turn recovery]
  E --> F[Widget update and final reply]
  E --> G[Durable session completion]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +511. Total +511 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 511 0 +511
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 511 0 +511

Review metrics

Metric Value Why it matters
Reported regression runtime Node 35.2 s; Bun 66.7 s test time The documented process-replacement requirement justifies the cost in the existing dedicated E2E lane.

Technical review

Best possible solution:

Retain the existing recovery owner and protect its durable crash-recovery contract with this isolated process-level regression.

Do we have a high-confidence way to reproduce the issue?

Not applicable to a remaining current-main defect: the producer repair is present. The author records a concrete pre-fix failure and after-fix success through an owned Gateway crash on both runtimes.

Is this the best way to solve the issue?

Yes: a process-level regression exercises startup admission, resumed tool execution, and durable terminal publication without adding another production owner or changing the live fixture.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c2e6410cd6cf.

Labels

Label changes:

  • add P2: Useful bounded regression coverage protects an already-repaired crash-recovery workflow.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured body records Node and Bun before/after runs through real Gateway processes and transport clients using a synthetic loopback provider. The inspected scenario crashes the owned Gateway, observes automatic recovery without inline-widget capability, and verifies durable/projected completion, widget revision, and one final reply; no stored-data contract changes require migration proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body records Node and Bun before/after runs through real Gateway processes and transport clients using a synthetic loopback provider. The inspected scenario crashes the owned Gateway, observes automatic recovery without inline-widget capability, and verifies durable/projected completion, widget revision, and one final reply; no stored-data contract changes require migration proof.

Label justifications:

  • P2: Useful bounded regression coverage protects an already-repaired crash-recovery workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body records Node and Bun before/after runs through real Gateway processes and transport clients using a synthetic loopback provider. The inspected scenario crashes the owned Gateway, observes automatic recovery without inline-widget capability, and verifies durable/projected completion, widget revision, and one final reply; no stored-data contract changes require migration proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records Node and Bun before/after runs through real Gateway processes and transport clients using a synthetic loopback provider. The inspected scenario crashes the owned Gateway, observes automatic recovery without inline-widget capability, and verifies durable/projected completion, widget revision, and one final reply; no stored-data contract changes require migration proof.

Evidence

What I checked:

  • Verified introduction boundary: The pinned merge-base-to-head diff adds only the regression test. The complete added file was read; no production, dependency, workflow, or schema changes are introduced. (test/gateway-widget-restart.e2e.test.ts:1, ef3b8187dc5e)
  • Actual merge preserves current main: The test merge's raw parents are exactly the pinned main followed by the original PR head. Comparing that result against main changes only the added test, so endpoint drift does not remove intervening production fixes. (test/gateway-widget-restart.e2e.test.ts:1, ed13bbb1801b)
  • Production repair already exists: The recovery owner subscribes to database-admission publication and serializes another recovery scan for newly admitted agents. The exact patch against its raw recorded parent verifies this change independently of blame. (src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts:422, c1b9f4ec91e5)
  • Current-main necessity and release check: Pinned main contains the production repair but does not contain this regression file. No local tag contains the producer-fix commit; its recorded commit timestamp is 2026-10-05T01:03:22-07:00. The prior repair therefore does not make the added coverage redundant. (src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts:422, c2e6410cd6cf)
  • Meaningful terminal-state synchronization: The provider holds the resumed turn until the observer subscribes. The test then waits for terminal publication before checking SQLite completion, session-list projection, widget revision, and exactly one final transcript marker. (test/gateway-widget-restart.e2e.test.ts:399, ef3b8187dc5e)
  • Reported production-boundary before/after results: The captured PR body reports failure on unmodified 56bdfc7 and success on afc9b8a on Node and Bun: recovery provider traffic resumes, durable/projected status becomes done, hasActiveRun is false, widget revision reaches 2, and one final marker remains. The inspected fixture uses real Gateway processes and HTTP/WebSocket clients with a synthetic loopback provider; the reviewer did not rerun it. (test/gateway-widget-restart.e2e.test.ts:378, ef3b8187dc5e)

Likely related people:

  • Peter Steinberger: Raw commit c1b9f4e adds src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts:422 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c1b9f4ec91e5; files: src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts)
  • Galin Iliev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 13c1d87 into main Oct 5, 2026
139 checks passed
@steipete
steipete deleted the codex/w170-widget-recovery branch October 5, 2026 09:30
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
)

A crash could leave widget authoring running forever when startup recovery finished before the agent database completed background admission. The producer repair is already on main in 9241c9e; add the missing deterministic process-level regression.

Use a synthetic loopback provider and owned Gateway restart to prove resumed widget publication, successful terminal notification, durable/projected done, and one final reply without an inline client.

Proof: pre-fix failure and post-fix success on Node 24 and pinned Bun; final P2 autoreview scoped-clean; exact-head CI green; ClawSweeper no findings. Production LOC unchanged. Related: openclaw#165225.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant