Skip to content

fix(backup): run the SQLite header probe as a declared worker entry - #183476

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1907
Oct 25, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1907

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #148857

What Problem This Solves

Fixes backup and pre-update backup failures when OpenClaw runs under Bun or standalone without a separate Node executable.

User Impact

SQLite discovery uses the running OpenClaw runtime, including for .db and extensionless databases. No configuration or migration is required. Unreadable candidates still fail closed before archive publication.

Why This Change Was Made

The probe introduced by #148857 resolved a separate Node executable and launched an eval string. Move the same probe into a declared runtime-process worker, launched with process.execPath and the canonical runtime-worker helpers. The shared manifest supplies package, standalone, and Vitest entries.

Keep child-process isolation: closing a raw descriptor in the parent can release another SQLite connection's POSIX locks. Batched input, header semantics, timeout, and complete-result validation remain intact. The old eval script and Node lookup are removed.

Evidence

  • The real-child regression failed on the original implementation because Bun launched a different Node executable. It now passes under Bun (56 ms) and Node (92 ms), requiring the current runtime and a module entry without -e.
  • Bun: the two update files plus backup-create.sqlite-{alt-names,hardlinks,header-probe}.test.ts and backup-sqlite-snapshot.performance.test.ts passed: 6 files, 45 tests passed, 4 platform-specific skips. All four reported update regressions passed. Vitest time 378.57 s; total 459.74 s, including 70.51 s of shared worker preparation. The single Windows-autostart reproduction also passed on this macOS base; the new launch-contract regression supplies red-to-green proof.
  • Node: all four requested update regressions and the SQLite backup regressions passed. The mandatory direct/one-barrel consumer sweep ran all 104 selected files: 100 passed, 4 failed; 1,910 tests passed, 15 failed, 11 skipped in 3238.83 s. The wider run is not green; failures are detailed below.
  • Live backup through the built package launcher: isolated HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH; pnpm exec node openclaw.mjs backup create --output <isolated archive> --no-include-workspace --verify --json, then the same command through the pinned Bun executable. Both returned "verified": true, including the expected warning for an unmanaged SQLite .db. The source wrapper first encountered a build-lock timeout and runtime-artifact publication refusal, so the completed package launcher was used without rebuilding runtime artifacts or changing a Gateway.
  • The built worker ran under Bun with empty PATH: [true,false,false] for SQLite, plain, and missing files. Verified package, standalone, and Vitest manifest projections and built output. A standalone executable was not compiled.
  • pnpm build passed in 9m25.8s. Core tsgo, infra-test tsgo, targeted oxlint, oxfmt, and git diff --check passed; Madge found 0 cycles. Codex autoreview at P2 found no actionable findings. Full check:changed was omitted under the SQLite-inventory time budget; PR CI remains the broad gate.

The broader Node failures were recorded without weaker assertions, longer timeouts, or retries to chase green:

  • Three post-core continuation assertions: candidate config-change, candidate legacy-config-change, and explicit post-update Doctor advisories. A control using the exact pre-fix probe reproduced the first failure: database snapshot exit 0 and update status ok, followed by the same unsupported delegated post-core warning and missing plugin event. The transport fixture explicitly rejects that capability check in update-command-transport.test-support.ts; this patch does not change that protocol or fixture.
  • extensions/codex/isolated-completion.adapter.e2e.test.ts: synthetic app-server completion hit its 22 s deadline (runtime-unavailable). Attribution remains unresolved.
  • extensions/onepassword/src/op-client.test.ts: 11 assertions returned OP_NOT_FOUND because the synthetic executable failed the trust check before token processing or the mocked process call. No real credentials were used.

Build warnings remain in untouched UI modules: six INEFFECTIVE_DYNAMIC_IMPORT warnings (session-snapshot-invalidation, composer-draft-store.runtime, modal-dialog, sidebar-attention, app-sidebar-session-narration, chat-outbox-drain). The backup/runtime bundle emitted none. Advisory UI budgets reported startup JS gzip 273146 B vs 273120 B and total CSS raw 1595572 B vs 1595521 B; no baselines changed. The same memory-host mixed-import warning appeared in base and fixed Vitest worker preparation.

Existing slow proof: the plugin database-worker group passed 36 files / 731 tests in 882.42 s; the Prometheus install E2E took 30.2 s while exercising a real plugin install and scoped HTTP access. The added header-worker test remains subsecond.

Production delta: +47/-36 lines (net +11). Tests: +28/-2 (net +26). One probe implementation remains; the new module contains the former eval body.

Replace the separate Node eval helper from #148857 with a declared worker launched through the current runtime. Preserve process isolation for POSIX locks, batched header discovery, and fail-closed backup classification.
@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 25, 2026 09:17
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T10:00:14.338001Z e89066f New commits
ℹ️ 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.

@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Run SQLite header discovery through a declared worker using the current OpenClaw executable instead of a separately resolved Node executable.

Example: Bun runs a verified backup containing notes.db on a machine without Node installed.

  • Before: Header discovery cannot resolve Node and aborts the backup.
  • After: The declared worker runs under Bun and classifies notes.db without requiring Node.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, narrowly scoped runtime repair with shipped-entry-point evidence, held below a clean verdict by a source-established assertion-safety failure.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR records the changed backup owner running through the built CLI under Node and Bun with verified archives, and the built header worker classifying SQLite, plain, and missing files under Bun with empty PATH; standalone compilation remains explicitly outside the demonstrated coverage.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Backup and pre-update backup can fail under Bun or standalone installations that have no separate Node executable.
Reason: The maintainer-authored direction restores supported runtime behavior through the existing worker architecture without adding configuration or changing stored data.

Regression provenance

Regression provenance — verified: source commit 513597f11e25 by weiqinl; canonical PR #148857 (blame-to-merge-commit).

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this PR fixes a current backup runtime dependency, but the extracted worker introduces an assertion-safety check failure that needs a small repair.

Priority: P2
Reviewed head: 3c595fb490565255da6326b3675eb6eaecbd4c0a

Before merge

  • Document both worker assertions so the assertion-safety gate passes (P2) - The new file introduces as string[] here and as NodeJS.ErrnoException at line 22, but neither has the // SAFETY: annotation recognized by the assertion ratchet. This file has no grandfathered allowance, so it contributes two assertions against an allowance of zero and fails the required baseline check; the exact-head annotations already report assertion-safety failing. Document the private launcher's input invariant and the filesystem error invariant in the required form, without expanding the baseline.

Findings

  • [P2] Document both worker assertions so the assertion-safety gate passes — src/infra/sqlite-header-probe.worker.ts:4-5
Agent review details

How this fits together

Backup inventory supplies candidate paths to an isolated child process, which returns SQLite-header classifications before snapshotting and archive publication.

flowchart LR
  A[Backup CLI or pre-update backup] --> B[Backup resource inventory]
  B --> C[Header probe launcher]
  D[Runtime process manifest] --> C
  C --> E[Current runtime child]
  E --> F[SQLite header classifications]
  F --> G[Snapshot and archive publication]
Loading

Technical review

Best possible solution:

Keep the single manifest-owned, process-isolated probe and document its two assertion invariants without expanding the baseline.

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

Current-main source explicitly requires a separate Node executable under Bun; the PR also records a red-to-green real-child regression, but this read-only review executed no target code.

Is this the best way to solve the issue?

The extraction is the smallest complete runtime repair: it reuses existing launch and packaging owners while preserving the original probe semantics and removing the superseded eval path.

Full review comments:

  • [P2] Document both worker assertions so the assertion-safety gate passes — src/infra/sqlite-header-probe.worker.ts:4-5
    The new file introduces as string[] here and as NodeJS.ErrnoException at line 22, but neither has the // SAFETY: annotation recognized by the assertion ratchet. This file has no grandfathered allowance, so it contributes two assertions against an allowance of zero and fails the required baseline check; the exact-head annotations already report assertion-safety failing. Document the private launcher's input invariant and the filesystem error invariant in the required form, without expanding the baseline.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1bb18fd0aa51.

Provenance checked

  • SQLite header discovery keeps the original intent (513597f: Detect alternative SQLite filenames while isolating descriptor closes from live SQLite connections and refusing incomplete classification.)
  • Worker entry ownership keeps the original intent (012d92f: Centralize explicit worker identities so source, package, and standalone builds retain executable helper programs.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm check:assertion-safety --base 4d13dec --no-merge-base
  • pnpm exec oxfmt --check src/infra/sqlite-header-probe.worker.ts
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 012d92f adds src/infra/runtime-process-manifest.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 012d92f53781; files: src/infra/runtime-process-manifest.ts)

PR surface

Source +11, Tests +26. Total +37 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 47 36 +11
Tests 2 28 2 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 75 38 +37

Labels

Label changes:

  • add P2: This repairs backup and pre-update backup on supported runtimes without Node, with a focused remaining CI repair.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This repairs backup and pre-update backup on supported runtimes without Node, with a focused remaining CI repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 25, 2026, 5:32 AM ET / 09:32 UTC.

The launcher moves from sqlite-files.ts (imported by snapshot/port worker
cores) into sqlite-header-probe.ts, used only by backup discovery, so worker
cores no longer reach the runtime-process entrypoints. The worker validates
its input instead of asserting its type.
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Oct 25, 2026
@steipete
steipete merged commit bc22cdb into main Oct 25, 2026
129 of 130 checks passed
@steipete
steipete deleted the upd/upd-l1907 branch October 25, 2026 10:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…penclaw#183476)

1579c37 (openclaw#148857) made backups probe file headers in a child that ran a PATH-resolved node with an -e eval string. Under Bun that lookup could fail (four update-cli tests failed on main under Bun), and standalone builds forbid eval helpers, so backups, including the pre-update backup, failed with 'Could not determine whether backup files are SQLite databases'. The probe is now a declared runtime-process worker launched by the current runtime, in its own launcher module so database worker cores stay free of runtime-process entrypoints. Child-process lock isolation, batching and fail-closed behavior are kept. Proof: the Bun regressions and SQLite backup tests pass on Node and Bun; live backups verified on both.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…183476)

513597f (#148857) made backups probe file headers in a child that ran a PATH-resolved node with an -e eval string. Under Bun that lookup could fail (four update-cli tests failed on main under Bun), and standalone builds forbid eval helpers, so backups, including the pre-update backup, failed with 'Could not determine whether backup files are SQLite databases'. The probe is now a declared runtime-process worker launched by the current runtime, in its own launcher module so database worker cores stay free of runtime-process entrypoints. Child-process lock isolation, batching and fail-closed behavior are kept. Proof: the Bun regressions and SQLite backup tests pass on Node and Bun; live backups verified on both.

(cherry picked from commit bc22cdb)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit d875bf32b71d8843cce21c9d8b57cfb324aca1c3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant