Skip to content

fix: recovery tests wait for committed outcomes - #154995

Merged
steipete merged 3 commits into
mainfrom
codex/fix-recovery-observer-errors
Sep 21, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/fix-recovery-observer-errors

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #154424

What Problem This Solves

Recovery tests can hide database-read failures or fail while valid startup recovery is still running.

User Impact

No production behavior changes. Tests report the original read error promptly, wait for committed recovery state, and join their scheduler before finishing.

Why This Change Was Made

The session-change bus intentionally isolates listener exceptions, so the test observer must reject its own promise on a read failure. Admission and terminal-state waits now share that observer and remove subscriptions when settled.

CI exposed one-second polling deadlines in the final-startup-retry test and its adjacent two-store case. They expired before recovery changed the seeded sessions. Both now observe committed failure state, keep their charge, reservation, tombstone, session identity, and dispatch assertions, and use Vitest cancellation to stop and join the scheduler. No timeout was increased.

Evidence

The original read-error case fails before the fix. Seven observer cases cover successful admission, terminal recovery, read errors, cancellation, listener removal, cleanup joining, and both completion orders for two physical stores sharing a logical session key.

The original CI failure left the session running at its seeded revision and charge count. An unchanged replay passed with the target taking 770 ms, close to its 1,000 ms cutoff; that replay is not a fix claim. A controlled startup pause beyond 1,001 ms of virtual time reproduced the exact failure, while the fixed test waits for real recovery and preserves its original outcome assertions.

The second CI failure was the adjacent two-store case; the first repaired case passed. Its controlled delayed-start reproduction failed with the same charge-count mismatch in 16.23 seconds; the fix passed in 14.81 seconds. Both store identities and final assertions are preserved.

The final original-order replay passes all 229 cases: seven observer, four admission, and 218 recovery tests, in 131.30 seconds total single-worker wall time. The two-store case took 1,241 ms in the full file. The final observer loop cleanup was then verified separately: seven cases in 2.19 seconds. The first delayed-start regression also failed before its fix (16.21 seconds) and passed afterward (13.03 seconds). Exact CI host latency was not separately attributed; the demonstrated defects are polling over asynchronous startup, not production recovery failures.

The owning test type graph, scoped lint, formatting, and size ratchets pass. Fresh independent review is clean through P2. Exact-head hosted CI passed with 27 successful jobs and 19 skipped; the changed-node test job took 177 seconds. ClawSweeper found no actionable correctness or security issues. Merged as 5406706770346421dea3ddf37ce47d3d3c546071.

Reject the pending admission observer when a session-change read throws, preserving the original error and existing listener cleanup. A deterministic regression reproduces the swallowed failure and covers successful admission and teardown.
@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 16:26
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 1:51 PM ET / 17:51 UTC (Revision 3).

ClawSweeper review

What this changes

Recovery tests now propagate database-read errors, wait for committed outcomes in each physical session store, and await scheduler cleanup.

Merge readiness

✅ Ready for maintainer review

The repair remains useful: current main retains the faulty test waits. No actionable correctness or security defects were found, and the patch preserves the existing recovery assertions.

Priority: P3
Reviewed head: a12a3068a248306605ab9cf0a6d92b75baa16f45

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported test repair with preserved assertions and no actionable review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer test-only repair changes the recovery fixture, not a production owner; the body documents controlled failure and recovery-suite validation, and no separate live-product proof gate applies.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer test-only repair changes the recovery fixture, not a production owner; the body documents controlled failure and recovery-suite validation, and no separate live-product proof gate applies.
Evidence reviewed 7 items Introduced scope: The pinned merge-base-to-head diff changes only recovery test support and two test files; it does not change production recovery, persisted schemas, dependencies, or authority. The diff whitespace check passed.
Read-error and settlement contract: The observer rejects its deferred promise when reading a session throws, unregisters its listener and abort handler on settlement, and awaits recovery.stop() in finally. The event bus deliberately isolates listener exceptions, which establishes why the original observer could remain pending.
Production boundary supports the chosen wait: Session-change publication follows committed owner state. The scheduler's stop operation aborts further work and awaits its running promise; the fixture uses that existing lifecycle operation without changing it.
Findings None None.
Security None None.

How this fits together

Startup recovery resumes interrupted agent sessions and records their outcomes in session storage. The changed test fixture observes those committed rows so recovery assertions and cleanup run at the correct time.

flowchart TD
  A[Seeded interrupted sessions] --> B[Startup recovery scheduler]
  B --> C[Committed session rows]
  C --> D[Session change events]
  D --> E[Test outcome observer]
  E --> F[Recovery assertions]
  E --> G[Stop and join scheduler]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +174. Total +174 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 236 62 +174
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 236 62 +174

Review metrics

Metric Value Why it matters
Observer coverage cost 7 cases; reported 2.19 seconds The new suite covers error propagation and lifecycle cleanup without adding database or Gateway boots.

Technical review

Best possible solution:

Use the shared committed-state observer for these recovery waits while preserving exact store identities, outcome assertions, and joined scheduler cleanup.

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

Yes, source establishes the failure path: a session read thrown from the original listener is swallowed by the event bus, leaving its promise pending; asynchronous recovery can also exceed the existing one-second polling cutoff. No tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes. Extending the existing observer removes the timing assumption and preserves the original error and recovery assertions without changing production code or increasing timeouts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a focused test-reliability repair with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer test-only repair changes the recovery fixture, not a production owner; the body documents controlled failure and recovery-suite validation, and no separate live-product proof gate applies.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-21T16:50:10.744Z sha 2905296 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T17:21:05.340Z sha 9904337 :: needs maintainer review before merge. :: none

@steipete steipete changed the title fix: report recovery fixture read failures promptly fix: recovery tests wait for committed outcomes Sep 21, 2026
@steipete
steipete enabled auto-merge (squash) September 21, 2026 17:59
@steipete
steipete merged commit 5406706 into main Sep 21, 2026
104 checks passed
@steipete
steipete deleted the codex/fix-recovery-observer-errors branch September 21, 2026 18:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit '8a26ae487b5fb9b72ea2c12bf384e9c776659429': (154 commits)
  fix(ui): preserve skill group expansion when filtering (#150911)
  test(gateway): consolidate server history and lifecycle fixtures (#155063)
  test(codex): select HTTP fallback in native finalizer fixtures (#155008)
  improve: reduce isolated Gateway CI test time (#154366)
  test(gateway): await approval registration acknowledgments
  fix(workboard): explain blocked-card claim recovery (#154990)
  perf(agents): consolidate exec target policy tests (#155060)
  perf(config): consolidate environment test fixtures (#155062)
  fix(ui): keep the chat rail anchored through composer resize
  fix: recovery tests wait for committed outcomes (#154995)
  fix(codex): keep inference bursts from failing turns (#154945)
  fix(memory): keep generated REM reflections out of promotion rankings (#154994)
  fix(sqlite): reclaim scratch files when storage is full (#154937)
  test(cli): spawn the compiled Doctor entry in the output process test (#155055)
  fix(update): distinguish config validation execution failures (#154892)
  test(doctor): await session cleanup before deleting fixture state
  fix(update): report unavailable service inspection accurately (#154896)
  test(gateway): observe plugin approval response completion
  perf(msteams): reduce file-consent test scaffolding (#155050)
  fix(ui): retain saved permissions during delayed startup reads (#154982)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
* test: report recovery fixture read failures promptly

Reject the pending admission observer when a session-change read throws, preserving the original error and existing listener cleanup. A deterministic regression reproduces the swallowed failure and covers successful admission and teardown.

* test: await committed recovery before checking final charges

* test: await recovery across physical session stores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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