Skip to content

fix(sqlite): preserve Unicode in worker stderr tails - #137675

Merged
obviyus merged 5 commits into
openclaw:mainfrom
ly85206559:codex/sqlite-readonly-stderr-utf16
Sep 8, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
ly85206559:codex/sqlite-readonly-stderr-utf16

Conversation

@ly85206559

@ly85206559 ly85206559 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Long SQLite worker errors could contain a lone surrogate when the retained stderr tail started inside an astral Unicode character. Node's child-output buffer limit can also split a pair at the other end.

Why This Change Was Made

Keep the shared Unicode-safe suffix helper and normalize any remaining lone surrogate in the selected tail. The 4,000 UTF-16-unit limit, whitespace trimming, error selection, child execution, timeout, cancellation, and database behavior stay unchanged. Extend the real-child regression to cover both boundaries.

User Impact

Doctor and other SQLite snapshot callers receive well-formed diagnostics without an extra replacement glyph at the start of the tail. Normalizing Node's already-truncated output preserves its existing UTF-8 rendering.

Evidence

  • Reproduced both failures on pinned current main with real SQLite child processes on Node 24.19.0.
  • Reproduced the operator-visible start-boundary failure through ordinary doctor --non-interactive and doctor --lint --json; the rebuilt candidate returns the exact complete suffix.
  • The start-boundary regression fails on main. The added overflow regression fails on the contributor's helper-only code and passes with normalization.
  • All 75 focused tests passed, plus changed-file formatting and lint.
  • All 33 candidate integration controls passed: Unicode boundary cases, ASCII/BMP text, trimming, empty stderr, parser faults, nonzero exits, signals, real 30-second timeouts, cancellation, and usable snapshots. These source-entrypoint controls complement the ordinary CLI proof.
  • Independent source-blind acceptance ran 30 ordinary CLI cases, observed 66 real workers, and matched all 19 fully visible diagnostic tails exactly. Its raw-parent-string and source-only limits are covered separately by the integration controls and source review.
  • Fresh source review found no actionable issues. The final typed Node API calls the same normalizer used by the retained runtime proof; both real-child boundary tests passed again after that API adjustment. Hosted CI and the final landing review are enforced on the published head.

AI-assisted repair; contributor ancestry and credit are preserved.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 10:48 AM ET / 14:48 UTC.

ClawSweeper review

What this changes

Preserves well-formed Unicode in shortened SQLite worker error messages and adds real-child regression coverage for both truncation boundaries.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and the latest release retain the unsafe truncation. No actionable correctness or security findings remain, and the retained runtime evidence covers the changed behavior.

Priority: P2
Reviewed head: 97c16c13f3651a668c853b12aba10af315251099

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant real-process evidence and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The retained Node 24.19.0 Doctor and real-worker observations exercise the changed formatter and report exact corrected suffixes; both boundary tests were rerun after the equivalent typed Node API adjustment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The retained Node 24.19.0 Doctor and real-worker observations exercise the changed formatter and report exact corrected suffixes; both boundary tests were rerun after the equivalent typed Node API adjustment.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base comparison confirms that the production change only replaces stderr suffix formatting; process execution, timeout, cancellation, result selection, and database operations are unchanged.
Current main still needs the repair: The fetched main revision still uses stderr.trim().slice(-SQLITE_READONLY_STDERR_TAIL_CHARS), which can retain a low surrogate without its preceding high surrogate.
Latest release retains unsafe slicing: The v2026.9.3 worker formatter also uses plain slice; the requested fix is not present in the supplied latest release.
Findings None None.
Security None None.

How this fits together

SQLite snapshot workers isolate database inspection from the calling process. Their errors flow back to Doctor and other callers through a shared formatter that retains a bounded stderr suffix.

flowchart LR
  A[Doctor or snapshot caller] --> B[SQLite child worker]
  B --> C[Result and stderr]
  C --> D{Worker succeeded?}
  D -->|Yes| E[Snapshot location]
  D -->|No| F[Unicode-safe stderr tail]
  F --> G[Caller diagnostic]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +32. Total +35 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 32 0 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 36 1 +35

Review metrics

None.

Technical review

Best possible solution:

Keep diagnostic normalization in the shared worker error formatter, preserving the existing size bound and snapshot lifecycle.

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

Yes: current-main slicing splits the surrogate pair in an emoji followed by 3,999 ASCII characters; the PR also records real-worker and Doctor reproductions. This review established the source mechanism without executing target code.

Is this the best way to solve the issue?

Yes: reusing the existing Unicode-safe slicer and Node normalizer repairs both boundaries at their shared diagnostic owner without changing database behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs malformed operator diagnostics with a narrow error-formatting change and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The retained Node 24.19.0 Doctor and real-worker observations exercise the changed formatter and report exact corrected suffixes; both boundary tests were rerun after the equivalent typed Node API adjustment.
  • proof: sufficient: Contributor real behavior proof is sufficient. The retained Node 24.19.0 Doctor and real-worker observations exercise the changed formatter and report exact corrected suffixes; both boundary tests were rerun after the equivalent typed Node API adjustment.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base comparison confirms that the production change only replaces stderr suffix formatting; process execution, timeout, cancellation, result selection, and database operations are unchanged. (src/infra/sqlite-readonly-worker.ts:37, 97c16c13f365)
  • Current main still needs the repair: The fetched main revision still uses stderr.trim().slice(-SQLITE_READONLY_STDERR_TAIL_CHARS), which can retain a low surrogate without its preceding high surrogate. (src/infra/sqlite-readonly-worker.ts:49, f3271158f8d7)
  • Latest release retains unsafe slicing: The v2026.9.3 worker formatter also uses plain slice; the requested fix is not present in the supplied latest release. (src/infra/sqlite-readonly-worker.ts:36, 1391f7cd2d40)
  • Final API adjustment preserves normalization: The patch directly imports node:util.toUSVString. Node v24.19.0 implements it using StringPrototypeToWellFormed, supporting continuity with the previous head's .toWellFormed() proof. The tag was separately resolved to this commit. (lib/util.js:623, cdc1b38d40cb)
  • Meaningful boundary regressions: The added cases invoke the public snapshot entrypoint with real child stderr and assert exact diagnostic suffixes for a split at the retained tail start and a split at Node's output-buffer end. No production injection seam is added. Tests were inspected, not executed during this read-only review. (src/infra/sqlite-readonly-location.test.ts:539, 97c16c13f365)
  • Retained real behavior evidence: The fully supplied PR body reports before/after ordinary doctor --non-interactive and doctor --lint --json runs on Node 24.19.0, exact matching of 19 visible diagnostic tails across 30 CLI cases, 33 integration controls, and successful reruns of both real-child boundary tests after the typed API adjustment. This assessment preserves captured sourceRevision 94db159a9e6eef9d632f1f807f271c1d0b3785b308bbd7db925004987b629ca3; these are reported observations, not reviewer-executed tests. (97c16c13f365)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: 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 (5 earlier review cycles)
  • reviewed 2026-09-04T00:34:54.806Z sha c031195 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T12:01:02.582Z sha c031195 :: blocked before merge. :: none
  • reviewed 2026-09-07T06:28:18.583Z sha c3e9d8c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T01:59:31.415Z sha ea25536 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T14:26:33.309Z sha 6cbc0bc :: needs maintainer review before merge. :: none

@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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. labels Sep 4, 2026
…675-20260907

# Conflicts:
#	src/infra/sqlite-readonly-location.ts
@ly85206559

Copy link
Copy Markdown
Contributor Author

Exact-head conflict-resolution evidence (c3e9d8c904d408b695e08ed4278dcb3d0a510873): merged current origin/main and moved the UTF-16-safe stderr-tail truncation to main's new src/infra/sqlite-readonly-worker.ts owner. The focused surrogate-boundary regression passes; oxfmt and git diff --check pass; narrowed exact-head autoreview is scoped-clean (0.98). The broader test file still has unrelated pre-existing Windows temp-drive/permission failures, so I am not claiming a full-file pass.

…675-20260907

# Conflicts:
#	src/infra/sqlite-readonly-worker.ts
@obviyus obviyus self-assigned this Sep 8, 2026
@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

The completed CI run, attempt 2 remains red for three failures unrelated to this two-file diagnostic repair. The guarded standing CI exception will record all three; no failed check is being called green.

  • Extensions bundle 28: the unchanged Matrix crypto dependency received HTTP 500 while downloading its native release asset. Its error handler then referenced an undefined variable. This occurred during dependency installation, before tests. The PR changes no dependency, lockfile, install script, request input or download policy.
  • Extensions bundle 29: the first MiniMax selection case exceeded 120 seconds. The selector, MiniMax entry, loader/setup/dispatch boundaries and lockfile match earlier failed executions, including this independent failure, whose source contains neither this repair nor its new test. Retained main profiling and a boundary control identify expensive synchronous plugin loading. The SQLite formatter does not control selection, registration or cache generation, and its test is absent from the failing group. Exact timing attribution remains incomplete; identical whole-run or cache instances are not claimed.
  • Windows: npm --version exceeded its 10-second limit inside the package-inventory checker’s empty sandbox. The test packages a synthetic export {}; fixture, not the OpenClaw runtime. Its helpers and inputs are unchanged, and this PR’s new test is not selected in that job. The underlying npm startup stall is not identified.

The tested merge was 63bb7a3f645d28227c4955115b06b80b6ea6174c, with main parent d559bcda4f9d45ee0c610c8e109e80ffdbb8fcd5 and reviewed head 97c16c13f3651a668c853b12aba10af315251099. The MiniMax test/shared-selector path came from #142023 (335e87235d1426ec4ad862bdbebcb35829b0a02f); that is source provenance, not attribution of a particular timeout to its author. The Matrix error-handler defect belongs to the unchanged upstream dependency; Windows timing cause remains unknown.

The SQLite repair retains real-worker/Doctor proof, 75 focused tests, final-source boundary checks, independent CLI acceptance and a clean exact-head review. No timeout, assertion, dependency or workflow was changed to accommodate these failures.

@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 137675
head: 97c16c1
run: 34239971456 attempt: 2
failed: checks-node-changed-extensions-bundle-28 job=102114007782 conclusion=failure
failed: checks-node-changed-extensions-bundle-29 job=102114007885 conclusion=failure
failed: checks-windows-node-test-1 job=102114001720 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit abad347 into openclaw:main Sep 8, 2026
238 of 244 checks passed
@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @ly85206559!

Proof: Real Doctor commands and SQLite child workers, 75 focused tests, both final-source boundary regressions, and 30 independent CLI cases. The final review found no actionable issues.

  • Bug: A bounded stderr suffix could contain a lone surrogate at its start; Node's output-buffer limit could leave another at its end.
  • Fix: Keep the shared safe suffix helper and normalize the bounded result through Node's typed Unicode API. The 4,000-unit limit and worker/database behavior stay unchanged.
Before After
A split starting pair left a malformed diagnostic prefix. The exact complete suffix remains.
Node overflow could leave a lone ending surrogate. The tail is well formed and keeps its existing UTF-8 rendering.

CI exception: The completed run 34239971456, attempt 2 remains red. The guarded merge uses the exact standing approval record, with complete causal details:

No introducing OpenClaw commit is attributed for the external HTTP error or unresolved Windows stall. No failed check was relabeled passed, and no timeout, assertion, dependency or workflow was weakened.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
## What Problem This Solves

Long SQLite worker errors could contain a lone surrogate when the retained stderr tail started inside an astral Unicode character. Node's child-output buffer limit can also split a pair at the other end.

## Why This Change Was Made

Keep the shared Unicode-safe suffix helper and normalize any remaining lone surrogate in the selected tail. The 4,000 UTF-16-unit limit, whitespace trimming, error selection, child execution, timeout, cancellation, and database behavior stay unchanged. Extend the real-child regression to cover both boundaries.

## User Impact

Doctor and other SQLite snapshot callers receive well-formed diagnostics without an extra replacement glyph at the start of the tail. Normalizing Node's already-truncated output preserves its existing UTF-8 rendering.

## Evidence

- Reproduced both failures on pinned current main with real SQLite child processes on Node 24.19.0.
- Reproduced the operator-visible start-boundary failure through ordinary `doctor --non-interactive` and `doctor --lint --json`; the rebuilt candidate returns the exact complete suffix.
- The start-boundary regression fails on main. The added overflow regression fails on the contributor's helper-only code and passes with normalization.
- All 75 focused tests passed, plus changed-file formatting and lint.
- All 33 candidate integration controls passed: Unicode boundary cases, ASCII/BMP text, trimming, empty stderr, parser faults, nonzero exits, signals, real 30-second timeouts, cancellation, and usable snapshots. These source-entrypoint controls complement the ordinary CLI proof.
- Independent source-blind acceptance ran 30 ordinary CLI cases, observed 66 real workers, and matched all 19 fully visible diagnostic tails exactly. Its raw-parent-string and source-only limits are covered separately by the integration controls and source review.
- Fresh source review found no actionable issues. The final typed Node API calls the same normalizer used by the retained runtime proof; both real-child boundary tests passed again after that API adjustment. Hosted CI and the final landing review are enforced on the published head.

AI-assisted repair; contributor ancestry and credit are preserved.

Co-authored-by: Ayaan Zaidi <[email protected]>
@ly85206559
ly85206559 deleted the codex/sqlite-readonly-stderr-utf16 branch October 5, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants