Skip to content

fix(config): surface the SQLite worker launch failure instead of a trim TypeError - #165373

Merged
steipete merged 1 commit into
mainfrom
upd/upd-config-read-trim-typeerror
Oct 5, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-config-read-trim-typeerror

Conversation

@steipete

@steipete steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Config diagnostics can replace a failed read-only SQLite worker launch with Cannot read properties of undefined (reading 'trim'), hiding the actual runtime failure. Refs #164404. Thanks @nnljl2003 for the report and the clarification about intermittency.

User Impact

The diagnostic names the config path and reports the underlying worker launch error. The original exception remains available through cause for in-process diagnostics, without exposing raw exception metadata in config JSON. Read failures retain their existing write-safety behavior.

Why This Change Was Made

A failed spawnSync call can return absent stdout/stderr despite Node's string declarations. The launch owner now produces a closed launched { stdout, stderr, status } | launch-failed { error } result before parsing. The config snapshot owner preserves the cause, and the shared read-error constructor carries it through all callers. The worker's on-wire response format is unchanged.

Evidence

  • A real failed executable launch between successful reads of the same unchanged empty database reproduced the exact trim TypeError before the fix. Three config snapshot regressions also failed before the fix because the original cause was discarded.
  • The three config/worker suites each passed three times: 225 tests across nine file runs. Last-run wall times for pnpm test <file> --maxWorkers=1: config snapshot 39.37 s; SQLite worker 39.07 s; worker protocol 25.32 s. Shared compiler preparation accounts for much of the wall time; the worker suite additionally exercises real child-process and SQLite snapshot lifecycles.
  • Runtime rebuild passed the CLI bootstrap import guard; runtime postbuild verified 53 modules and Doctor closures. Both closure guard files passed (20 tests). The dynamically importing Doctor interruption suite and the SQLite compile-cache subprocess suite passed (10 tests).
  • All 97 direct/one-barrel importer files were selected in their original order: 94 files passed, two files retain four failed cases (details below), and one existing file was skipped. The extra compile-cache subprocess suite passed. Local node scripts/check-changed.mjs --timed --base 678572811dd8b10c19ee69e2107947d099dd33c1 -- <all 15 changed paths> completed successfully: all 34 steps passed, including production/test types, lint, dead exports, and ownership guards (1844.64 s).
  • The importer run exposed a macOS fixture defect in update-command-service.integration.test.ts: it published a real macOS Gateway namespace, then checked it while simulating Linux. The fixture now invokes the real namespace/ancestry classifiers under the host platform, retaining all ownership checks. The original run failed 12 cases in a 297.63 s three-file shard; after the fixture repair, the complete 121-test suite passed three times (363 tests). Single-file invocation wall times were 352.87 s including runtime preparation, 268.56 s, and 233.30 s.
  • Local proof limitation: src/cli/gateway-cli/pre-bootstrap.process.test.ts failed the Doctor-repaired escaped-reference case and both fast/Commander --dev cases. The file took 425.07 s across 17 isolated Node+TSX launches. The two --dev children were still progressing at 48.5/50.1 s; the existing 60 s subprocess deadline is suspected, but the raw child error did not expose termination metadata. Follow-up: use the existing prepared-runtime fixture pattern while preserving fresh children, private state, Doctor repair, dispatch, and config-drift assertions.
  • doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts also hit its existing 30 s guard in “runs legacy state migrations in yes mode without prompting”; the other five cases passed (54.19 s test time, 62.78 s invocation). The migration itself is mocked, but yes-mode executes real database/archive preflight and maintenance admission after lazy imports. The maintenance-phase diagnostic did not appear, so the precise stalled phase remains unknown. Preparing/reusing the lazy Doctor graph while preserving admission and cleanup is follow-up work that needs phase-level diagnosis.
  • Slow passing integration fixtures: update-command-original-service.test.ts took 545.10 s (54 cases each seed and close real session databases); state-migrations.skill-workshop.test.ts took 544.87 s (33 cases, 50 full migration calls plus seven direct Workshop migrations). Fixture-lifecycle optimization remains follow-up work; the required schema, ordering, and artifact-preservation coverage is retained.
  • Independent review was unavailable with HTTP 401 and explicitly waived. Hosted CI results and timing were not yet available at publication.

The reporter's underlying Windows launch trigger is unverified. @nnljl2003, please retry the affected diagnostics on a build containing this fix so the real launch-failure reason prints.

Classify worker launches before parsing their output, and retain config read
causes with their paths. Keep native identity checks on the host platform in
the update-service fixture.

Refs #164404. Thanks @nnljl2003 for reporting the intermittent failure.
@clawsweeper

clawsweeper Bot commented Oct 5, 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 gateway Gateway runtime cli CLI command changes commands Command implementations size: M labels Oct 5, 2026
@steipete
steipete marked this pull request as ready for review October 5, 2026 06:10
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 2:22 AM ET / 06:22 UTC (Revision 2).

ClawSweeper review

What this changes

The PR reports SQLite worker launch failures directly, preserves their causes through config diagnostics, adds regression coverage and documentation, and corrects a host-platform test fixture.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: fetched main still masks failed SQLite worker launches and discards config-read causes. No introduced correctness defect was found; the underlying Windows launch trigger remains separate, unresolved work.

Priority: P2
Reviewed head: 692f012f7b2287f28a8f13a0f076f2a9f4e03959

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regressions and no identified introduced defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. Reported validation includes the real synchronous worker owner handling an actual failed native launch and succeeding afterward; it does not prove the original Windows trigger. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. Reported validation includes the real synchronous worker owner handling an actual failed native launch and succeeding afterward; it does not prove the original Windows trigger. No stored-data contract changes.
Evidence reviewed 10 items Pinned introduction: Reviewed the merge-base-to-head delta. The original head has the recorded parent supplied by the host; endpoint drift was excluded from PR ownership.
Launch failure classified before parsing: The synchronous launcher returns a launch-failed error with the original exception as cause. The response reader throws that error before trimming stdout or stderr; successful launches retain response validation.
Private cause and existing write guard: Config snapshot failures attach a non-enumerable cause and retain the existing fallbackRaw-based readError classification. The shared constructor and its production callers carry that cause without changing stored configuration or the worker wire format.
Findings None None.
Security None None.

How this fits together

Config diagnostics inspect settings and shared SQLite state before CLI commands or Gateway startup proceed. Worker failures feed into config snapshots, which produce operator-facing errors and determine whether recovery is appropriate.

flowchart TD
  A[CLI or Gateway startup] --> B[Config snapshot]
  B --> C[SQLite inspection worker]
  C --> D{Launch succeeded?}
  D -->|Yes| E[Parse worker response]
  D -->|No| F[Preserve launch error]
  E --> B
  F --> G[Config path and original cause]
  B --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +40, Tests +67, Docs +2. Total +109 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 10 96 56 +40
Tests 4 82 15 +67
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 180 71 +109

Review metrics

None.

Technical review

Best possible solution:

Keep launch classification and cause preservation in their existing owners, then use the exposed Windows error to diagnose the remaining runtime failure.

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

Yes for the diagnostic defect: a failed synchronous executable launch reaches trimming of absent output on fetched main, and the regression exercises that boundary with Node's actual launch result. The reporter's specific Windows trigger remains unverified; no reviewer runtime reproduction was executed.

Is this the best way to solve the issue?

Yes: classify failure at the launch owner and preserve causes through the existing snapshot/error owners, without bypassing validation or changing write safety.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9151e48c4f9c.

Labels

Label changes:

  • add P2: This repairs diagnostic error reporting while the linked reporter confirms Gateway and channel operation remain available.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. Reported validation includes the real synchronous worker owner handling an actual failed native launch and succeeding afterward; it does not prove the original Windows trigger. No stored-data contract changes.

Label justifications:

  • P2: This repairs diagnostic error reporting while the linked reporter confirms Gateway and channel operation remain available.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. Reported validation includes the real synchronous worker owner handling an actual failed native launch and succeeding afterward; it does not prove the original Windows trigger. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction: Reviewed the merge-base-to-head delta. The original head has the recorded parent supplied by the host; endpoint drift was excluded from PR ownership. (692f012f7b22)
  • Launch failure classified before parsing: The synchronous launcher returns a launch-failed error with the original exception as cause. The response reader throws that error before trimming stdout or stderr; successful launches retain response validation. (src/infra/sqlite-readonly-worker.ts:655, 692f012f7b22)
  • Private cause and existing write guard: Config snapshot failures attach a non-enumerable cause and retain the existing fallbackRaw-based readError classification. The shared constructor and its production callers carry that cause without changing stored configuration or the worker wire format. (src/config/io.snapshot.ts:139, 692f012f7b22)
  • Real child-process regression: The new regression invokes the production synchronous worker owner, injects Node's actual missing-executable launch result, checks the ENOENT cause, and confirms successful reads before and after with unchanged source bytes. The captured body reports repeated passing suites; reviewer execution was intentionally not performed. (src/infra/sqlite-readonly-worker.test.ts:336, 692f012f7b22)
  • Fixture retains the real classifier: The updater fixture temporarily restores the host platform while invoking the actual namespace and ancestry classifiers, then restores the simulated platform. Production authorization logic is unchanged. (src/cli/update-cli/update-command-service-recovery.test-support.ts:107, 692f012f7b22)
  • Still necessary on fetched main: Comparison against fetched main shows the old synchronous launcher still passes potentially absent child output into parsing, and config snapshots still discard causes. No merged fixing PR or shipped fix was established. (src/infra/sqlite-readonly-worker.ts:644, 9151e48c4f9c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-10-05T06:15:53.883Z sha 692f012 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@steipete
steipete merged commit 97430de into main Oct 5, 2026
212 of 219 checks passed
@steipete
steipete deleted the upd/upd-config-read-trim-typeerror branch October 5, 2026 06:46
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
 backport)

(cherry picked from commit 7daf4de)
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

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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