Skip to content

fix(gateway): disk-full write requests return raw SQLite worker errors - #176832

Merged
steipete merged 1 commit into
mainfrom
codex/stab-disk-full-write-rpc
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/stab-disk-full-write-rpc

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When the state volume fills, Gateway write requests such as sessions.create failed with a raw internal broker message: UNAVAILABLE / SqliteWorkerError: SQLite worker stopped before its result was received: database or disk is full: code=outcome-unknown. It named no next step, while a turn failing on the same full disk already showed "OpenClaw could not write local session data because the disk is full. Free some disk space and try again." Found by the stability campaign with the state directory on a deliberately filled 3 GB APFS volume (main 7ef2a23).

User Impact

Clients now get UNAVAILABLE with the existing disk-full recovery guidance and details.code: "SQLITE_FULL" instead of internal broker text. Retry semantics are unchanged: unknown dispatched writes stay nonretryable and queued, unexecuted writes stay retryable.

Why This Change Was Made

Gateway write requests such as sessions.create exposed raw SQLite worker outcome-unknown errors when the state volume filled. They now return UNAVAILABLE with the existing disk-full recovery guidance and details.code: "SQLITE_FULL", reusing the storage classifier and copy owner. ENOSPC is classified by that same owner. Queued worker failures retain their native cause so classification survives wrappers.

Unknown dispatched writes remain nonretryable; queued, unexecuted writes remain retryable. Worker retirement, transaction settlement, recovery, durable state, and replay are unchanged. Non-storage messages and existing request-error metadata retain their prior behavior.

The worker does not retire on every SQLITE_FULL. It retires when settlement cannot establish a usable native connection. Nested automatic rollback can remove its savepoint; the transaction owner deliberately fences that handle to prevent later autocommit after a caught failure (#139700). Healthy pre-commit automatic rollback is already handled separately (#157241). Definite job rollback or keeping such workers alive needs an owning recovery decision, outside this fix.

Evidence

Coordinator live proof used the state directory on a filled 3 GB APFS volume. Stock main 7ef2a23236aa returned:

res ✗ sessions.create errorCode=UNAVAILABLE errorMessage=SqliteWorkerError: SQLite worker stopped before its result was received: database or disk is full: code=outcome-unknown <- Error: database or disk is full: code=ERR_SQLITE_ERROR

The candidate (main 0211fa29bf49 + this PR + #176831) returned:

res ✗ sessions.create errorCode=UNAVAILABLE errorMessage=OpenClaw couldn't save your conversation because the disk is full. Free up space on the computer running OpenClaw before continuing.

Separately tracked F82: an outcome-unknown agent write on a full disk can wedge that agent's shared-state lease until restart (Shared-state cleanup is waiting for accepted operations to settle). This reproduces on stock main. Its raw text is a non-SQLITE_FULL error, intentionally not reclassified by this PR; lease recovery is outside this fix.

Validation: the real WAL worker/broker fixture reproduces the reported error using max_page_count, without filling the host disk or calling a model. Temporarily reverting only the four production changes makes both Gateway assertions fail with the original internal messages; restoring the fix makes both pass. The broker test also proves preserved native causes, unchanged outcome classification, no retained failed row, and a successful write after reopening.

All tests ran individually with OPENCLAW_VITEST_RUNTIME=node TMPDIR=/private/tmp/oc-W92 pnpm test <file> --maxWorkers=1:

File Result Command wall time
src/gateway/server/ws-connection/authenticated-request-dispatch.storage.test.ts 2 passed 440.28 s
src/infra/sqlite-worker-broker.test.ts 17 passed 131.97 s
src/infra/sqlite-worker-broker-reply.test.ts 7 passed 88.11 s
src/infra/sqlite-worker-broker-reply.cleanup.test.ts 7 passed 90.21 s
src/gateway/error-shape.test.ts 5 passed 133.03 s
src/gateway/server/ws-connection/authenticated-request-dispatch.metrics.test.ts 46 passed 183.23 s
src/agents/embedded-agent-helpers/provider-runtime-failure.test.ts 15 passed 146.58 s
src/agents/embedded-agent-helpers/error-text.test.ts 9 passed 126.00 s
src/gateway/chat-display-projection.test.ts 52 passed 47.57 s

Core types (pnpm tsgo:core), targeted core oxlint, touched-file oxfmt, git diff --check, and Madge all pass; Madge reports zero cycles. Cold worker compilation, artifact verification, and the first router import dominate wall time. The new Gateway file's assertions take 42.2 s including cold initialization; the second case takes 4.6 s. Real worker settlement plus the authenticated response boundary is the required contract; a mocked worker error would miss it.

Both isolated Codex reviews are scoped-clean through P2. Production delta is +28/-10 (net +18), needed to connect existing classification and rendering while retaining outcome safety; tests/fixtures/routing are +113/-1. No new runtime module, dependency, schema, protocol schema, or configuration option.

Health probes are unchanged: liveness is intentionally independent of free capacity, readiness has no owned disk-pressure signal, and session disk budgets measure retained bytes rather than filesystem free space. Disk-aware readiness remains a separate follow-up.

CI attribution for native landing

Exact-head PR CI 39191184139, attempt 1 has one non-aggregate failure: check-test-types. It reports extensions/codex/src/app-server/native-subagent-monitor.parent-retention.test.ts(37,5): TS2353, because completionDeliveryRetryDelaysMs does not exist in MonitorOptions.

The same diagnostic fails in scheduled main CI 39191176869, attempt 1, at main a8771a5a154c67f26b5ab7e0002672ad0bfac8bd, the baseline used by this PR's tested merge. These extension inputs are untouched by this PR. The PR failure table compared the older main run 39186683798, where the job passed; direct job-log comparison against the contemporaneous completed scheduled run establishes this as inherited. The failed aggregate openclaw/ci-gate follows that single job. Native inherited-failure admission retains the red status and exact-head evidence.

Reuse storage failure classification and guidance at the Gateway RPC boundary. Preserve native causes for queued worker failures and keep unknown write outcomes nonretryable without changing worker retirement or transaction settlement.

Regression proof uses real WAL SQLITE_FULL through the worker broker; the original boundary exposed internal outcome-unknown text instead of recovery guidance.
@clawsweeper

clawsweeper Bot commented Oct 19, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T02:49:25.979135Z — PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: c443121690c4cd903ad7c482fab8efaf89412894
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server/ws-connection/authenticated-request-dispatch.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 19, 2026
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces raw disk-full worker errors in Gateway RPC responses with existing recovery guidance while preserving write-outcome retry safety.

Example: A sessions.create request encounters SQLITE_FULL after dispatch to the SQLite worker.

  • Before: The client receives UNAVAILABLE with an internal SqliteWorkerError and outcome-unknown text.
  • After: The client receives disk-full recovery guidance, details.code SQLITE_FULL, and retryable false when the write outcome is unknown.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with credible native-worker regression coverage; proof reaches the in-process dispatcher boundary.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers native SQLITE_FULL through the broker and authenticated dispatcher harness, rather than a running Gateway client.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A full Gateway disk produces an internal worker error without explaining how the user can recover.
Reason: The maintainer-authored direction restores actionable failure reporting through existing owners and keeps transaction recovery outside this focused change.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it addresses a current Gateway diagnostic defect with a focused change, and source review found no actionable introduced bug.

Priority: P2
Reviewed head: c443121690c4cd903ad7c482fab8efaf89412894

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No post-fix shipped Gateway RPC trace is supplied; the reported red/green runs exercise real SQLite workers through an injected RPC handler.
Agent review details

How this fits together

Authenticated Gateway RPC handlers use worker-owned storage; failures cross the broker and Gateway error renderer before becoming client response frames.

flowchart LR
  A[RPC client] --> B[Authenticated dispatcher]
  B --> C[Request handler]
  C --> D[SQLite worker broker]
  D --> E[SQLite database]
  D --> F[Storage error classifier]
  F --> G[Gateway error response]
  G --> A
Loading

Technical review

Best possible solution:

Use the existing storage classifier and recovery-copy owner at the RPC boundary while preserving uncertain-write refusal and transaction ownership.

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

Current-main source exposes formatted worker failures at the dispatcher boundary, and the PR supplies a bounded real-SQLite reproduction with reported red/green assertions; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is a small complete diagnostic fix: it retains native causes at their producer and reuses existing classification, copy, and unknown-outcome detection without adding another recovery mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c91b1ea adds src/infra/sqlite-error-diagnostics.ts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c91b1eaab768; files: src/infra/sqlite-error-diagnostics.ts)

PR surface

Source +18, Tests +112, Docs +2. Total +132 across 10 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 28 10 +18
Tests 5 113 1 +112
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 143 11 +132

Review metrics

Metric Value Why it matters
Production versus regression support Production +28/-10; tests, fixtures, and routing +113/-1 The production growth connects existing classification and rendering owners; regression support covers native cause retention, dispatched versus queued retry safety, and reopening.

Labels

Label changes:

  • add P2: This improves actionable diagnostics during disk exhaustion without changing storage recovery or normal request execution.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This improves actionable diagnostics during disk exhaustion without changing storage recovery or normal request execution.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 18, 2026, 10:57 PM ET / October 19, 2026, 02:57 UTC.

@steipete
steipete merged commit f0e683c into main Oct 19, 2026
178 of 182 checks passed
@steipete
steipete deleted the codex/stab-disk-full-write-rpc branch October 19, 2026 04:14
@steipete

Copy link
Copy Markdown
Contributor 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 19, 2026
Reuse storage failure classification and guidance at the Gateway RPC boundary. Preserve native causes for queued worker failures and keep unknown write outcomes nonretryable without changing worker retirement or transaction settlement.

Regression proof uses real WAL SQLITE_FULL through the worker broker; the original boundary exposed internal outcome-unknown text instead of recovery guidance.
steipete added a commit that referenced this pull request Oct 19, 2026
Align the plugin subagent persistence regression with f0e683c (#176832).
That PR intentionally makes Gateway clients receive disk-full guidance and
structured SQLITE_FULL details instead of raw broker text. Its body states:
"Retry semantics are unchanged: unknown dispatched writes stay nonretryable
and queued, unexecuted writes stay retryable."

Keep every no-dispatch, no-registration, paused-owner adoption, and subsequent
successful retry assertion. Assert the structured disk-full code and queued
failure retryability, and require the original storage cause in the warning.
The unclassified adoption failure still retains its specific diagnostic.
No production behavior changes.

Current main reproduces the exact hourly message mismatch. Replacing only the
shared error formatter with its pre-#176832 version makes the unchanged case
pass, confirming the intended copy change as the cause.

Validation: pnpm test src/gateway/server-methods/agent.test.ts
src/gateway/error-shape.test.ts --maxWorkers=1 passed 412 tests in 193.64s
Vitest time. Targeted gateway-methods tsgo, typed core and boundary lint,
formatting, whitespace checks, and independent P2 autoreview passed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
Align the plugin subagent persistence regression with 1603942 (openclaw#176832).
That PR intentionally makes Gateway clients receive disk-full guidance and
structured SQLITE_FULL details instead of raw broker text. Its body states:
"Retry semantics are unchanged: unknown dispatched writes stay nonretryable
and queued, unexecuted writes stay retryable."

Keep every no-dispatch, no-registration, paused-owner adoption, and subsequent
successful retry assertion. Assert the structured disk-full code and queued
failure retryability, and require the original storage cause in the warning.
The unclassified adoption failure still retains its specific diagnostic.
No production behavior changes.

Current main reproduces the exact hourly message mismatch. Replacing only the
shared error formatter with its pre-openclaw#176832 version makes the unchanged case
pass, confirming the intended copy change as the cause.

Validation: pnpm test src/gateway/server-methods/agent.test.ts
src/gateway/error-shape.test.ts --maxWorkers=1 passed 412 tests in 193.64s
Vitest time. Targeted gateway-methods tsgo, typed core and boundary lint,
formatting, whitespace checks, and independent P2 autoreview passed.
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 gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: S 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