Repository navigation
fix(gateway): Gateway refuses to start with a misleading 'another Gateway' hint when its state database is not writable - #178107
Conversation
|
🦞👀 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0ab27b752
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const storageFailure = collectNestedErrorCandidates(err) | ||
| .map((cause) => { | ||
| // Generic errno is storage evidence only within state-database acquisition. | ||
| if (err.databasePath) { |
There was a problem hiding this comment.
Scope errno classification to database operations
When gateway ownership fails because the owner/legacy lock file itself is inaccessible—for example, the existing acquireGatewayLock path can receive EACCES from the lock file openSync—the wrapper still attaches databasePath, so this condition reclassifies that unrelated failure as SQLITE_READONLY. Startup then reports openclaw.sqlite as the failing path and skips the lock diagnostics, while openclaw doctor cannot repair the actual lock path; only errors originating from the database permission/open operation should carry this storage context.
AGENTS.md reference: AGENTS.md:L75-L75
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR hardens state permissions before Gateway database acquisition and gives path-specific guidance for storage failures. Example: Start the Gateway with a user-owned openclaw.sqlite file at mode 0444.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful: current main still opens state before permission hardening and can give misleading contention guidance. The integrated head addresses the earlier findings without introducing a new actionable defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway CLI acquires physical state custody, checks database ownership, and starts its listener; acquisition failures become CLI diagnostics and supervisor exit codes. flowchart TD
A[Gateway CLI] --> B[Acquire physical custody]
B --> C[Existing permission owner]
C --> D[Inspect database ownership]
D --> E[Start Gateway]
D --> F[Classify acquisition failure]
F --> G[Path-specific CLI guidance]
Technical reviewBest possible solution: Retain the existing permission owner and scoped storage diagnostics, with Doctor diagnosis handled by its separate follow-up. Do we have a high-confidence way to reproduce the issue? Current main performs lease inspection before this permission repair and presents GatewayLockError failures with contention guidance; the supplied regressions exercise real read-only SQLite acquisition. Is this the best way to solve the issue? The patch repairs ordering through the existing permission owner, scopes filesystem errno handling to database operations, and preserves shared classification and offline-maintenance behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1f31394cc6d4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +84, Tests +271, Docs +1, Other -1. Total +355 across 16 files. Added test files: 1. View PR surface stats
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 (3 earlier review cycles)
Reviewed October 20, 2026, 3:05 AM ET / 07:05 UTC (Revision 4). |
5f336af to
39d708e
Compare
|
@clawsweeper re-review Please review current head |
|
🦞👀 Re-review progress:
|
… storage Use the existing permission owner before Gateway database acquisition, and report path-specific storage failures without contention hints. Preserve shared ENOSPC classification and chmod-incompatible writable volumes. Skip redundant chmod calls and keep startup hardening out of offline maintenance so newer-schema refusals preserve source contents and metadata.
39d708e to
259db97
Compare
|
@clawsweeper re-review Please review exact head |
|
🦞👀 Re-review progress:
|
Preserve current main nested storage classification and Gateway owner-liveness handling. Resolve the classifier overlap by retaining shared EIO and ENOSPC semantics alongside SQLite CANTOPEN normalization, and align the provider regression with current main behavior.
|
@clawsweeper re-review Please review exact integrated head |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
… storage (openclaw#178107) Use the existing permission owner before Gateway database acquisition, and report path-specific storage failures without contention hints. Preserve shared ENOSPC classification and chmod-incompatible writable volumes. Skip redundant chmod calls and keep startup hardening out of offline maintenance so newer-schema refusals preserve source contents and metadata.
Related: #34710
What Problem This Solves
Fixes Gateway startup failing on a user-owned read-only state database and suggesting that another Gateway is running.
User Impact
Startup restores user-owned database files to mode
0600through the existing permission owner. Storage failures that remain identify the affected path and explain how to fix permissions, make the volume writable, or free disk space. Existing exit codes and supervisor restart behavior are preserved.Why This Change Was Made
Gateway ownership acquisition opened SQLite before the normal permission-hardening owner ran. It now uses that owner before opening the database, including its existing tolerance for writable filesystems that reject chmod. Database-operation failures carry their path to startup presentation; filesystem lock failures retain their own diagnostics. Shared ENOSPC classification is preserved, and new filesystem errno handling stays scoped to database startup.
Doctor permission diagnosis is deferred to a separate follow-up. That follow-up must check effective write access before treating foreign ownership as a problem, so writable Docker/fsGroup and NFS volumes remain usable. This PR adds no Doctor permission detector, schema, protocol, or config changes. Acquisition-time hardening is limited to Gateway starts; offline Doctor can refuse a newer schema without changing its source files.
Evidence
Regression proof on Node and Bun: offline Doctor refuses newer-schema databases at modes
0600and0444without changing mode, ctime, or contents. Already-correct private modes cause no chmod call.Before the fix, a read-only shared-state database produced this misleading startup message:
The coordinator live-tested the retained acquisition behavior: an owned
0444database starts successfully and becomes0600; an immutable (uchg) database produces a storage error. The revised message gives path-specific repair guidance without promising Doctor diagnosis.Focused regressions cover real SQLite acquisition for owned read-only files and writable filesystems that reject chmod, immutable storage failure presentation without supervisor/port contention handling, projection-lock failure context, and existing ENOSPC/provider/workspace behavior. The focused Gateway, Doctor, permissions, snapshot, and capture-store suites passed, along with the wrapper inventory, affected type graphs, core types, lint, formatting, and import-cycle checks. Production change: +84 net lines. The separate max-lines check reports three unchanged UI files; no new suppression was added.
Main integration validation
Merged current main to resolve the SQLite classifier conflict. Main's nested-error traversal, shared EIO and ENOSPC handling, and Gateway owner-liveness changes are preserved. The provider regression now follows main's EIO behavior while continuing to verify that EACCES, EPERM, and EROFS are not treated as Gateway storage failures.
The integrated candidate passed 198 tests across 11 focused files, including Doctor newer-schema refusal at 0600 and 0444, real owned-read-only and immutable startup cases, physical/projection lock behavior, embedded retained state, and provider/workspace storage consumers. Core types, targeted lint and formatting passed; independent review found no actionable P0-P2 defects. Exact-head ClawSweeper review completed without findings or before-merge items. All selected CI jobs completed; the inherited failure is documented below.
Inherited CI failure
Exact-head CI 39383655434 completed on
ba1cc7483af486f6136f64ff9edd9cf8d8c1d4db. Its only failing test job, 118498781510, reports the two foreign Doctor/schema maintenance checkpoint cases insrc/state/openclaw-state-db-open.test.ts:370. They receive an ownership-namespace error instead of an undefined checkpoint status.The same cases and error occur on scheduled main 39382483409 / 118494854815. The failing test and ownership-record source blobs are identical across main and the actual CI merge checkout. The failure table labels it unknown because main uses a different shard name; independent log and source comparison confirms it is inherited. The aggregate CI gate is red solely because of that job. Security, all other selected test/type/lint jobs, and all three PostgreSQL conformance shards passed. The older UI TS2367 failure did not recur. Landing uses the authorized native inherited-failure exception; no CI rerun or branch push was used to chase green.