Skip to content

fix(sqlite): allow verified shared wal backports - #108287

Closed
eugene-harold-krabs wants to merge 5 commits into
openclaw:mainfrom
eugene-harold-krabs:fix/shared-sqlite-wal-override
Closed

eugene-harold-krabs wants to merge 5 commits into
openclaw:mainfrom
eugene-harold-krabs:fix/shared-sqlite-wal-override

Conversation

@eugene-harold-krabs

@eugene-harold-krabs eugene-harold-krabs commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Node builds that link against a distribution-provided SQLite can receive the WAL-reset corruption fix through distro backports even when sqlite_version() still reports an older upstream version such as 3.46.1. The current guard treats those runtimes like unsafe embedded SQLite builds and blocks operators who have verified their distribution backported the fix.

This keeps the default safety check strict, but adds an explicit operator override for shared-system SQLite only: OPENCLAW_ASSUME_SYSTEM_SQLITE_WAL_RESET_SAFE=1. Embedded SQLite builds remain blocked unless their embedded SQLite version is known safe.

Fixes #108273

Summary

  • allow operators to opt into a verified shared-system SQLite WAL-reset backport with OPENCLAW_ASSUME_SYSTEM_SQLITE_WAL_RESET_SAFE=1
  • keep vulnerable embedded SQLite builds blocked because they cannot inherit distro SQLite backports
  • expand the SQLite safety tests around the explicit shared-library override
  • rebase the PR branch onto current main so the node test shards include the latest test-runtime support changes

Evidence

  • Added focused unit coverage for the shared-system override path.
  • Added coverage that the same override does not bypass vulnerable embedded SQLite builds.
  • Local validation after rebasing with Node 24.18.0:
    • node scripts/run-vitest.mjs run --config test/vitest/vitest.infra.config.ts src/infra/node-sqlite.test.ts passed: 1 file, 22 tests.
    • node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts src/gateway/server-startup-web-fetch-bind.test.ts passed: 1 file, 1 test.
  • git diff --check passed.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 15, 2026
@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch from 5a78b1a to f4c502f Compare July 15, 2026 12:51
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 15, 2026
@xrow

xrow commented Jul 15, 2026

Copy link
Copy Markdown

Context here are the current Packages of latest RH nodejs stating at the moment sqlite-libs-3.46.1-5.el10_1.x86_64 is used. So I can`t build openclaw on red hat with out the swtich present.

https://catalog.redhat.com/en/software/containers/ubi10/nodejs-24/67f6288d9700d2bde865192a#packages

@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch 5 times, most recently from 25973fc to 86a6947 Compare July 16, 2026 01:24
@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch from 86a6947 to 6d0f27b Compare July 16, 2026 02:32
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 10:39 PM ET / August 1, 2026, 02:39 UTC.

ClawSweeper review

What this changes

This branch adds OPENCLAW_ASSUME_SYSTEM_SQLITE_WAL_RESET_SAFE=1 so operators can bypass the SQLite WAL-reset version guard for Node builds using shared system SQLite, while retaining the guard for embedded SQLite.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 10 items remain

Keep this PR open for human review: it proposes a new environment-variable bypass for a data-corruption safety gate, but the bypass is not independently verifiable and the PR still lacks after-fix proof from a verified shared-system SQLite backport.

Priority: P1
Reviewed head: 9fbe83822bfcc030c9db8efd8417c3df6f93094f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch identifies a real deployment pressure, but its safety model is unsupported and it has no real after-fix distribution proof.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The body supplies unit tests and CI only; add redacted terminal output from a verified affected distribution showing the shared library identity and successful OpenClaw startup after the change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The body supplies unit tests and CI only; add redacted terminal output from a verified affected distribution showing the shared library identity and successful OpenClaw startup after the change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current fail-closed owner boundary: Current main queries the SQLite library actually loaded by node:sqlite, accepts only known fixed or backported upstream release lines, and otherwise throws before callers can open state databases; it contains no shared-library override.
Proposed bypass is not a verification mechanism: The PR adds an early return when process.config.variables.node_shared_sqlite is true and the new environment variable equals 1; neither input establishes that the loaded distribution SQLite contains the WAL-reset repair.
Current safety contract is release-line based: The shared version helper recognizes SQLite 3.51.3+, plus only the documented 3.50.x and 3.44.x maintenance backports; an arbitrary 3.46.1 build is intentionally outside that proof boundary.
Findings 1 actionable finding [P1] Keep the WAL-safety guard independently verifiable
Security Needs attention Unverified override disables SQLite corruption protection: A process environment value can admit a shared SQLite runtime whose reported version remains outside the known-safe release lines, even though no runtime evidence proves the distribution backported the WAL-reset repair.

How this fits together

OpenClaw loads Node's SQLite runtime before opening its state databases and queries the loaded library's SQLite version. The WAL-reset gate prevents state databases from using runtimes known to risk corruption; it either admits known fixed release lines or stops startup with remediation guidance.

flowchart LR
  A[Node runtime] --> B[Load node SQLite]
  B --> C[Query loaded SQLite version]
  C --> D{Known WAL-safe release line?}
  D -->|Yes| E[Open OpenClaw state database]
  D -->|No| F[Block startup with remediation]
  G[Proposed environment override] --> F
Loading

Decision needed

Question Recommendation
Should OpenClaw permit an operator-controlled override to disable the SQLite WAL corruption guard when a distribution claims a backport but Node exposes no verifiable patch identity? Require verifiable safety evidence: Keep the guard fail-closed and accept a future path only if OpenClaw can validate a supported package, build, or advisory identity for the patched library.

Why: This is a product and safety-boundary choice: the proposed runtime inputs prove only that SQLite is shared and that an operator set an environment variable, not that the loaded library contains the corruption fix.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The body supplies unit tests and CI only; add redacted terminal output from a verified affected distribution showing the shared library identity and successful OpenClaw startup after the change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep the WAL-safety guard independently verifiable (P1) - This early return disables the corruption guard whenever a shared build receives an operator-chosen environment value. node_shared_sqlite does not establish that the loaded distro library has the WAL-reset repair, so an unfixed shared SQLite build can be admitted with no trustworthy safety evidence. This remains the prior P1 blocker.
  • Resolve security concern: Unverified override disables SQLite corruption protection - A process environment value can admit a shared SQLite runtime whose reported version remains outside the known-safe release lines, even though no runtime evidence proves the distribution backported the WAL-reset repair.
  • Resolve merge risk (P1) - Merging would let any operator bypass the version-based WAL corruption guard for a shared SQLite library without a machine-verifiable indication that the backport is present.
  • Resolve merge risk (P1) - The stated Red Hat-compatible path has no after-fix runtime evidence, so maintainers cannot confirm the override reaches the reported deployment or preserves the intended startup behavior.
  • Complete next step (P2) - A maintainer must choose whether an operator-controlled waiver is acceptable for this persistent-data safety boundary; a repair worker should not decide that policy.
  • Improve patch quality - Resolve the P1 by retaining a verifiable safety gate or obtaining explicit maintainer approval for a documented waiver policy.
  • Improve patch quality - Add redacted terminal proof from the affected shared-system SQLite deployment; remove private endpoints, IPs, and credentials.
  • Improve patch quality - After updating the PR body, request a fresh ClawSweeper review if one is not triggered automatically.

Findings

  • [P1] Keep the WAL-safety guard independently verifiable — src/infra/node-sqlite.ts:19-21
  • [high] Unverified override disables SQLite corruption protection — src/infra/node-sqlite.ts:19
Agent review details

Security

Needs attention: The proposed environment variable weakens a persistent-data corruption safety boundary without independently verifying the loaded SQLite build.

PR surface

Source +4, Tests +46. Total +50 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 1 50 4 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 55 5 +50

Review metrics

Metric Value Why it matters
Safety override surface 1 environment override added This adds a new process-wide configuration path that can change whether OpenClaw opens persistent SQLite state on otherwise rejected runtimes.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/infra/node-sqlite.test.ts, migration/backfill/repair: src/infra/node-sqlite.ts, vector/embedding metadata: src/infra/node-sqlite.test.ts, vector/embedding metadata: src/infra/node-sqlite.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #108273
Summary: This PR explicitly targets the open report about Node builds using an older reported SQLite version; it is a candidate fix, not evidence that the report is already resolved.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve a verifiable safety gate (recommended)
    Replace the unconditional environment bypass with a maintainer-approved, machine-verifiable patched-library contract and prove it on the affected distribution before merge.
  2. Adopt a documented waiver policy
    Maintainers may intentionally accept an operator waiver, but should document the corruption risk, supported deployments, and upgrade behavior before landing it.
  3. Pause this override
    If no verifiable contract is available, keep the current fail-closed behavior and pause or close the PR rather than weakening the database safety boundary.

Technical review

Best possible solution:

Keep the release-line guard fail-closed unless maintainers approve a supported, documented, independently verifiable contract for identifying patched shared-system SQLite builds; then prove that contract on the affected distribution.

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

No. The current source clearly rejects an unsafe shared SQLite version, but this review has no live evidence that the reported distribution loads a backported, safe library or that the proposed override succeeds there.

Is this the best way to solve the issue?

No. The branch is a plausible operator waiver, but not the best safety repair because its only proof of a patched runtime is an environment value chosen by the same operator bypassing the guard.

Full review comments:

  • [P1] Keep the WAL-safety guard independently verifiable — src/infra/node-sqlite.ts:19-21
    This early return disables the corruption guard whenever a shared build receives an operator-chosen environment value. node_shared_sqlite does not establish that the loaded distro library has the WAL-reset repair, so an unfixed shared SQLite build can be admitted with no trustworthy safety evidence. This remains the prior P1 blocker.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7fba71eb7aeb.

Labels

Label justifications:

  • P1: The change concerns startup access to persistent SQLite state and can either block affected deployments or weaken their corruption protection.
  • merge-risk: 🚨 compatibility: A new environment-controlled startup path changes the support and deployment contract for shared-system Node SQLite builds.
  • merge-risk: 🚨 security-boundary: The proposed value disables a guard intended to prevent use of SQLite builds affected by a database-corruption bug.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body supplies unit tests and CI only; add redacted terminal output from a verified affected distribution showing the shared library identity and successful OpenClaw startup after the change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Unverified override disables SQLite corruption protection — src/infra/node-sqlite.ts:19
    A process environment value can admit a shared SQLite runtime whose reported version remains outside the known-safe release lines, even though no runtime evidence proves the distribution backported the WAL-reset repair.
    Confidence: 0.98

What I checked:

  • Current fail-closed owner boundary: Current main queries the SQLite library actually loaded by node:sqlite, accepts only known fixed or backported upstream release lines, and otherwise throws before callers can open state databases; it contains no shared-library override. (src/infra/node-sqlite.ts:32, 7fba71eb7aeb)
  • Proposed bypass is not a verification mechanism: The PR adds an early return when process.config.variables.node_shared_sqlite is true and the new environment variable equals 1; neither input establishes that the loaded distribution SQLite contains the WAL-reset repair. (src/infra/node-sqlite.ts:19, 9fbe83822bfc)
  • Current safety contract is release-line based: The shared version helper recognizes SQLite 3.51.3+, plus only the documented 3.50.x and 3.44.x maintenance backports; an arbitrary 3.46.1 build is intentionally outside that proof boundary. (src/infra/sqlite-runtime-version.ts:7, 7fba71eb7aeb)
  • Current implementation provenance: Blame attributes the current guard, shared-library detection, loaded-library query, and pre-database validation to the July 31 main-branch rewrite, showing one current owner boundary rather than a downstream workaround. (src/infra/node-sqlite.ts:32, 2f875c5ad726)
  • Proof remains mock-only: The PR body reports focused Vitest coverage and CI, but no redacted run from the affected distribution that identifies the shared SQLite library and demonstrates successful OpenClaw startup after the proposed change. (9fbe83822bfc)

Likely related people:

  • Peter Steinberger: Current-main blame attributes the SQLite runtime safety boundary and loaded-library validation to this author; older feature provenance could not be fully reconstructed from the partial local object store. (role: recent area contributor; confidence: medium; commits: 2f875c5ad726; files: src/infra/node-sqlite.ts, src/infra/node-sqlite.test.ts)

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-16T03:54:08.302Z sha 6d0f27b24f63f6107f0e793fa6353b7addd4cffd :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-16T05:17:50.739Z sha 6d0f27b24f63f6107f0e793fa6353b7addd4cffd :: needs real behavior proof before merge. :: [P1] Bind the safety bypass to the verified SQLite build | [P2] Document the corruption-guard override
  • reviewed 2026-07-16T05:59:31.774Z sha 6d0f27b24f63f6107f0e793fa6353b7addd4cffd :: needs real behavior proof before merge. :: [P1] Define the verification lifecycle for the safety bypass
  • reviewed 2026-07-18T02:29:09.053Z sha e6112aeaae99dbbb28133e299376dbe6a3d04287 :: needs real behavior proof before merge. :: [P1] Define an auditable WAL-safety bypass contract
  • reviewed 2026-07-20T06:03:50.346Z sha f6808c48fbec387f559571b4dd7a735513e24738 :: needs real behavior proof before merge. :: [P1] Do not let an unverified environment value bypass WAL safety
  • reviewed 2026-07-20T07:14:04.069Z sha 120a186801a5ec67165dd52218b4229e2cc20d26 :: needs real behavior proof before merge. :: [P1] Do not bypass WAL safety with an unverified environment value
  • reviewed 2026-07-20T08:09:53.468Z sha 120a186801a5ec67165dd52218b4229e2cc20d26 :: needs real behavior proof before merge. :: [P1] Do not rely on an unverified environment bypass
  • reviewed 2026-07-29T22:50:12.124Z sha 9fbe838 :: needs real behavior proof before merge. :: [P1] Keep the WAL-safety guard independently verifiable

@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch from 6d0f27b to e6112ae Compare July 18, 2026 02:25
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch 4 times, most recently from f6808c4 to 120a186 Compare July 20, 2026 07:09
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jul 20, 2026
@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch 3 times, most recently from 17b1fb8 to 13c4142 Compare July 21, 2026 12:30
@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch from 3666da6 to 56f7381 Compare July 22, 2026 04:43
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed cli CLI command changes commands Command implementations size: M labels Jul 22, 2026
@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch 6 times, most recently from 9fa873c to 4791d7f Compare July 22, 2026 09:53
@eugene-harold-krabs

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@eugene-harold-krabs
eugene-harold-krabs force-pushed the fix/shared-sqlite-wal-override branch 6 times, most recently from fd0b341 to f54bb93 Compare July 22, 2026 21:15
@eugene-harold-krabs

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@eugene-harold-krabs

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@eugene-harold-krabs

Copy link
Copy Markdown
Contributor Author

Closing because the owning GitLab maintainer confirmed this work is no longer needed: https://gitlab.com/xrow-public/helm-openclaw/-/work_items/38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: regression with node:sqllite version testing

2 participants