Skip to content

fix: unblock agent sessions after a Gateway owner dies - #188409

Merged
roboclaw-bot merged 1 commit into
mainfrom
roboclaw/team-r1-stale-lease-integrity
Oct 30, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
roboclaw/team-r1-stale-lease-integrity

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #183052, #182984

What Problem This Solves

Fixes agent sessions remaining unavailable for a full database integrity scan after the previous Gateway owner dies, including during startup admission. Two healthy 35 GB Team database opens blocked sessions for 15 and 21.6 minutes.

User Impact

A matching dead-owner lease on Linux now takes QUICK admission, including after interrupted startup. A subsequent successful checkpoint and clean stop seal that QUICK receipt, so the following ordinary restart also avoids the full scan. Revoked validation, dirty receipts without matching dead-owner provenance, replaced files, prior corruption, live peers, and explicit maintenance policies retain full verification or refusal. Known FULL requirements survive interrupted verification in the existing lease status. Failed recovery QUICK checks fall back to FULL. No configuration or database schema migration is needed.

QUICK omits full index consistency checking. Its receipt remains distinct from FULL. Seal identity, journal, expiration, final-close, and refusal checks remain in effect; normal SQLite access, Doctor, and later full verification retain corruption detection.

Why This Change Was Made

SQLite WAL recovery preserves committed writes after process death. Treat matching dead-owner provenance as process death instead of corruption evidence, and recheck provenance after opening the file. The existing admission facts and clean-close seal owner carry a distinct successful recovery-QUICK receipt across clean restarts. Ordinary maintenance QUICK checks never mint that receipt. This avoids moving the outage to the next deploy and adds no background-check owner or persistent store.

Evidence

  • The original regression fails on the original main base: same-boot recovery runs a full scan instead of zero. The extended regression also fails on reviewed commit 623776c93bd (replayed after rebase as 89edda72c85): after QUICK admission and clean close, reopening runs another full scan. With the receipt/seal fix, the extended regression passes.
  • Red/green command: timeout 180s node scripts/run-vitest.mjs src/state/openclaw-agent-execution.integrity.test.ts --maxWorkers=1 -t 'quickly admits matching killed owners'. Exercises real SIGKILL, native worker admission, session creation, WAL preservation and rollback, interrupted admission, dirty receipts, provenance mismatch, failed QUICK falling back to FULL, and clean restart after retiring process proof. It verifies no extra scan and no false FULL receipt on restart.
  • Rebased onto 6f098f501e6959d7688334a781a91c6964e044a0 before verification. All 174 tests across eight focused owner/consumer files passed in 122.25 s, including shared-state admission, seal rejection/expiration, ordinary QUICK/FULL policies, and native crash recovery. Final restart-regression replay passed after simplifying receipt publication. Targeted state/SQLite typecheck, changed-file lint/format, docs link audit (16,144 links; zero broken), and git diff --check pass. Broad checks ran in PR CI; the unrelated failures and landing blocker are recorded below.
  • Existing native-execution file: 42 tests, 48.5 s summed test time; lease-integrity file: 27 tests, 18.8 s; lease-owner file: 13 tests, 0.98 s. These existing real process/worker fixtures prove crash, custody, and restart behavior; no extra fixture file is needed.
  • The final staged candidate against 6f098f501e6959d7688334a781a91c6964e044a0 received scoped-clean P0–P2 autoreview with full admission/seal context. The review finding about interrupted known-FULL checks is fixed and covered by lease-status tests; earlier index-only findings were resolved by staging the complete candidate. Static review is separate from executed tests.
  • After the retained-FULL change, 22 focused lease/native recovery cases passed, covering record/completion, stale required-FULL reclamation, revoked/replaced proof, and the crash/clean-restart regression.
  • Net test line delta: 0; the existing crash regression and lease tests replace superseded assertions. No test file or persistent store was added. Simplification uses the existing admission/seal owners; production delta +65 lines, test delta 0.
  • Exact-head CI run 41069077227, attempt 1 finished with 66 successful jobs, 26 skipped jobs, two failing test jobs and their failing aggregate gate. The automatic failure table classifies both jobs as unknown because main uses different shard names. Independent attribution now covers all five assertions: the two replay-cohort signatures match scheduled-main job 124089265185 and reproduce on baseline 6f098f501e6959d7688334a781a91c6964e044a0; their focused expectation repair is separately owned by fix(ci): repair deterministic scheduled full-CI failures #188398. All three refusal-product copy expectations (bio, cyber, misalignment) also reproduce on that baseline. The completed misalignment-only replay failed at the same terminal assertion (1 failed, 3 skipped, 87.78 s total): detailed review text was expected, but the generic failure summary was received. This completes the earlier timed-out baseline gap. The reproduction baseline has no R1 patch; inspected test, fixture, replay and copy-owner inputs also match the CI main parent and tested merge. Native inherited-failure evidence is prepared; these results remain failed CI.
  • Current hosted review of 9e51e0fbdc09ceccbc601084404a8a0dcd7c200e found no actionable code defect and requests latest-stable-to-candidate data compatibility proof. The repository command pnpm test:docker:published-upgrade-survivor was submitted through the OpenClaw Crabbox wrapper to the configured Blacksmith Testbox provider. Allocation tbx_01m66mtjfgn692yqcm06kapjp3 queued and was stopped without running the upgrade payload; run 41075675938 is cancelled, and cleanup reconciliation succeeded. The requesting maintainer explicitly waived the outstanding latest-stable upgrade proof on 2026-10-30. That upgrade remains unproven; no successful upgrade result is claimed. No live Team restart or 35 GB timing benchmark was performed.
  • Merged as 6614c50b2de7 through the native inherited-failure exception after explicit investigated cancellation and native confirmation of retirement of the old auto-merge request. All five failing assertions retain baseline attribution; CI is not reported green. The requesting maintainer explicitly waived latest-stable upgrade proof. The landed tree was independently reconstructed from the actual landing parent and reviewed head and matched exactly.

Requested by @steipete.

Work sessions

@clawsweeper

clawsweeper Bot commented Oct 30, 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 docs Improvements or additions to documentation size: S labels Oct 30, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 30, 2026 14:07
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) October 30, 2026 14:12
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR admits matching dead-owner agent databases with QUICK verification and preserves that distinct receipt across clean restarts.

Example: A Linux Gateway dies while opening an existing 35 GB agent database.

  • Before: The replacement Gateway requires a full integrity scan before agent sessions become writable.
  • After: Matching process and file provenance permits QUICK admission; a subsequent clean close can preserve that admission for the next restart.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation with useful production-owner regression coverage and no identified defect; persisted-state upgrade confidence remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agent sessions remain unavailable during a full integrity scan after the previous Gateway owner dies.
Reason: The reported outages are substantial, the repair stays within existing owners, and the maintainer-authored PR records the integrity tradeoff.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a concrete restart outage, preserves existing ownership checks, and has no identified code defect.

Priority: P1
Reviewed head: 9e51e0fbdc09ceccbc601084404a8a0dcd7c200e

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence lacks a latest-stable-to-candidate upgrade preserving existing sessions and settings while exercising legacy lease/seal facts, crash recovery, and the following clean restart.
Agent review details

How this fits together

The agent database opener combines shared-state leases, physical-file provenance, schema validation, and integrity checks before exposing SQLite-backed session operations; clean-close seals preserve completed validation facts.

flowchart TD
  A[Gateway or native worker] --> B[Agent database opener]
  B --> C[Lease and provenance owner]
  C --> D[Integrity and schema admission]
  D --> E[Writable agent sessions]
  E --> F[Checkpoint and clean close]
  F --> G[Validation seal]
  G --> D
Loading

Technical review

Best possible solution:

Keep recovery in the existing lease, admission, and seal owners, with provenance-bound QUICK checks, retained FULL refusals, and distinct recovery receipts.

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

Current-main source forces the full gate after stale-owner invalidation, and the supplied regression reports failing-before/passing-after native-worker execution; this review ran no target code.

Is this the best way to solve the issue?

The change uses the existing owners and adds only the recovery classification, pending FULL status, and distinct seal fact needed to prevent the outage from recurring on the following clean restart.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Interrupted and completed dead-owner admission changes intended behavior with a stated reason (147975c: Interrupted admission previously retained the full gate so killing an unfinished verifier could not enable deferred recovery.)
  • Clean-close integrity facts changes intended behavior with a stated reason (f787a89: Clean-close seals preserve completed validation facts while retaining file identity, freshness, revocation, and successful-close requirements.)
  • Live-peer physical-file binding keeps the original intent (feee07c: A replacement file must not borrow the original file's admitted status.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +65, Tests 0, Docs +15. Total +80 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 80 15 +65
Tests 3 23 23 0
Docs 1 17 2 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 120 40 +80

Labels

Label changes:

  • add P1: The reported failure leaves agent sessions unavailable for multi-minute database scans after a Gateway owner dies.
  • add merge-risk: 🚨 session-state: Recovery changes the integrity coverage required before session writes and permits QUICK receipts across clean restarts; the maintainer-authored body explicitly accepts reduced index checking.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: The reported failure leaves agent sessions unavailable for multi-minute database scans after a Gateway owner dies.
  • merge-risk: 🚨 session-state: Recovery changes the integrity coverage required before session writes and permits QUICK receipts across clean restarts; the maintainer-authored body explicitly accepts reduced index checking.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide redacted latest-stable upgrade output showing existing sessions and settings survive, followed by successful crash recovery and clean restart.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 30, 2026, 10:25 AM ET / 14:25 UTC.

@roboclaw-bot
roboclaw-bot disabled auto-merge October 30, 2026 15:44
@roboclaw-bot
roboclaw-bot merged commit 6614c50 into main Oct 30, 2026
259 of 263 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/team-r1-stale-lease-integrity branch October 30, 2026 15:49
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
Recover matching dead Gateway owners with QUICK admission and carry a distinct recovery receipt across clean restarts. Preserve full verification for corruption evidence, unknown provenance and explicit full-check policies.

Reviewed regression is base-red/fix-green. The documented inherited-CI exception covers five independently reproduced baseline assertions; CI is not reported green. Latest-stable update proof was explicitly waived by the requesting maintainer.

Co-authored-by: steipete <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport 6614c50.
Recover matching dead owners with QUICK admission and a distinct clean-close
receipt. Preserve FULL checks for explicit policy and untrusted recovery.

Co-authored-by: steipete <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant