Skip to content

fix(workers): keep task diagnostics off JSON stdout - #159351

Merged
steipete merged 1 commit into
mainfrom
fix/worker-task-json-diagnostics
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/worker-task-json-diagnostics

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The published 2026.9.6 updater can reject an otherwise valid candidate because SQLite snapshot diagnostics appear before the JSON-only Doctor readiness report. This reproduced during the merged HTTP-ingress stack's published-updater proof: candidate-doctor-lint failed with Unexpected token 's', "[state/sqli"... is not valid JSON.

User Impact

Nested task-worker diagnostics go to stderr, keeping structured CLI stdout parseable. The diagnostics remain visible. Task results, log levels, file logging, storage authority, and Doctor's strict JSON parser are unchanged.

Why This Change Was Made

The Doctor process already routes its own diagnostics, but each worker isolate has independent logging state. The SQLite writer carrier already enforces stderr routing (#150184); shared task workers did not. The existing routing operation now runs at the shared task-server entry point, only when a parent port exists, and stays active for that worker's lifetime. Results continue over the existing parent-port protocol.

The regression uses a real child process and task worker, calls the actual SQLite snapshot-budget diagnostic producer, parses the entire stdout stream as JSON, and also requires the diagnostic on stderr. It cannot pass by dropping the message. There are no new mocks, retries, sleeps, production test seams, configuration keys, migrations, schemas, or SDK signatures.

Update behavior: the correction runs in the candidate, so published updater versions do not need a patch or a new marker. It preserves the existing JSON readiness contract. No operator state is mutated by this change.

Evidence

Blacksmith Testbox tbx_01m3gab1gkgd6t3kxyf4wq0ytg, run 36288000374, Node 24.19.0, 8 CPUs / 33.23 GB:

  • New regression with original production: fails at whole-stdout JSON.parse with the same snapshot-prefix error; 17.800 s wall.
  • pnpm test src/infra/worker-task-pool.logging.test.ts --maxWorkers=1: passes; 18.749 s wall, including native fixture preparation; the case itself took 301 ms.
  • pnpm test src/infra/sqlite-worker-logging.test.ts src/commands/doctor-lint-process.test.ts src/infra/worker-task-pool.resources.test.ts --maxWorkers=1: 20 tests pass; 22.142 s wall.
  • Source identities and eleven raw log hashes were verified. The rebase preserves the reviewed patch exactly; the intervening logging change only preserves GLIBC loader diagnostics, not worker routing.
  • Formatting and diff checks pass. Deslop found no further change. Independent Codex review is scoped-clean through P2.

Production +3 / -0 / net +3; tests/helpers +76 / -0 / net +76; docs 0. This small growth restores an existing machine-output contract.

The four-channel Gateway live matrix already passed on merged main b8e5c0e0eadf4c5d85b1cb4e4aafdb35cc3a2876. The published-updater failure remains recorded as the motivating red result. The repair merged as c5b1eee718431609d13ab14633ea60a44c102c5f after exact-head CI 36289682662 passed at fc35d7d89556ed406b87a0a8f1ab161e27ad350f. The canonical package and full published-updater cell have now passed on merged main, as recorded below.

HTTP Ingress Stack

  1. HTTP admission preparation: merged.
  2. Gateway compatibility listener: merged.
  3. Telegram: merged.
  4. Feishu: merged.
  5. Microsoft Teams: merged.
  6. Nextcloud Talk: merged.
  7. This separate worker-output repair closes the failure discovered by the published-updater cell.

Final Merged-Main Proof

All six HTTP slices and the worker-output repair #159351 are merged. The final proof passed on pinned main a6b5ed882cb5e7a10e9346d0e1152878a55653a4 (tree 9cbab37566c97b4c13219d87f65153cfe1ea7377), after verifying every stack merge is an ancestor. No real Gateway or operator state was used.

Provider: Blacksmith Testbox, lease tbx_01m3gab1gkgd6t3kxyf4wq0ytg, run 36288000374, Node 24.19.0, measured 8 CPUs / 33.23 GB. Commands ran sequentially in a clean detached checkout with isolated home/state and synthetic vendor HTTP/JWKS fixtures; channel signature verification remained real.

pnpm install --frozen-lockfile
node scripts/package-openclaw-for-docker.mjs --allow-unreleased-changelog \
  --output-dir /tmp/http-ingress-final-package-a6b5ed882cb5 \
  --output-name openclaw-http-ingress-candidate.tgz
OPENCLAW_LOCAL_CHECK=0 node --import tsx scripts/profile-extension-memory.mts \
  --extension telegram --extension feishu --extension msteams \
  --extension nextcloud-talk --skip-combined --concurrency 1 \
  --json /tmp/http-ingress-final-results-a6b5ed882cb5/entrypoint-profile.json
node /tmp/http-ingress-final-results-a6b5ed882cb5/harness/run.mjs
HTTP_INGRESS_CANDIDATE_TGZ=/tmp/http-ingress-final-package-a6b5ed882cb5/openclaw-http-ingress-candidate.tgz \
  node /tmp/http-ingress-final-results-a6b5ed882cb5/harness/run.mjs --published-update

Frozen install passed in 2.220 s; canonical package/build passed in 340.232 s; all four native entrypoint profiles passed in 1.093 s and were qualified against the exact unchanged build. Profiling did not trigger another build and is cold-import evidence, not a runtime-performance claim. Candidate tarball SHA-256: 2d29ad91cd7d6ee6dfca498d7eff003991afbf2348eb791751cfdb1be516e7a7 (99,022,084 bytes).

The real Gateway harness (pnpm openclaw gateway run --allow-unconfigured) passed all ten scenarios in 360.370 s. For each of the four channels, valid signed callbacks reached the channel admission/handler and invalid signatures returned 401 on both the Gateway route and its implicit or explicit legacy endpoint. Teams additionally required a correlated handler-entry log; its gzip, deflate and Brotli callbacks passed, and validly signed tokens with incorrect audience, issuer or service URL were rejected.

Scenario Observed Gateway-owned listening ports
Implicit defaults, before/after restart 3000, 3978, 8787, 8788, 24891
legacyWebhook: false, before/after restart 24891 only
Explicit ports after Doctor migration 24881, 24882, 24883, 24884, 24891
Disabled channels 24891 only
Telegram polling / Feishu WebSocket mode 3978, 8788, 24891
Parent/account opt-out inheritance 24891 only
Account object overriding parent opt-out 24881, 24882, 24884, 24891

Bindings matched the shipped defaults: Telegram 127.0.0.1:8787, Feishu 127.0.0.1:3000, Teams wildcard :3978, Nextcloud 0.0.0.0:8788. Explicit legacy objects selected their configured endpoint; false consistently closed it. Implicit defaults stayed runtime-derived, without materializing legacyWebhook in config.

Doctor's explicit-port migration passed for enabled and disabled channels. openclaw.json.bak.2 retained every original port before mutation; canonical legacyWebhook values preserved the effective hosts and ports. Informational guidance identified the Gateway route and opt-out. Health-checked reverse proxies passed through Telegram and Nextcloud legacy ports, preserving exact 200 ok responses and the audited Content-Type difference.

The published-driver cell passed in 110.195 s. It installed actual npm [email protected], proved the implicit Telegram endpoint before update, then executed that installed binary's command:

openclaw update --tag /tmp/http-ingress-final-package-a6b5ed882cb5/openclaw-http-ingress-candidate.tgz \
  --yes --no-restart --json

The installed updater returned exit 0 in 73.934 s. Installed build-info exactly matched the candidate commit and tarball; signed Telegram callbacks then passed on Gateway and legacy routes after update and after restart. This published-driver cell covers Telegram; the four-channel matrix above covers all four through the real Gateway.

All 13 Gateway runs shut down gracefully, with no force-kill. Independent final checks found all 15 captured Gateway/harness PIDs absent and all 11 owned product/fixture ports free. Seven clean source snapshots, ten raw log hashes, three immutable checkpoints and the package identity were verified.

Telegram Test Server userbot proof was unavailable: uv, broker credentials/authentication and a usable no-install Convex launcher were absent. No login, credential lease or actual Telegram network interaction was claimed. The signed synthetic Gateway harness is the authorized fallback.

The first published-driver attempt exposed snapshot diagnostics contaminating JSON stdout. That red result is preserved in the task history; #159351 fixes the shared task-worker output owner. The successful cell above uses the merged repair and keeps strict JSON parsing, diagnostics and all original proof assertions intact.

Lease cleanup is verified: native stop exited 0, the provider is completed, and its GitHub lease workflow is completed/cancelled. All product proof commands above exited 0. No task-owned Gateway process or listening socket remained before stop.

Task results use parentPort IPC. Route diagnostics to stderr in the shared
worker server so nested readers cannot corrupt Doctor's JSON readiness
report during a published-driver update.

Exercise the real snapshot-budget diagnostic in a child process and worker,
requiring both parseable stdout and retained stderr output.
@clawsweeper

clawsweeper Bot commented Sep 27, 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.

@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 10:55 PM ET / September 27, 2026, 02:55 UTC.

ClawSweeper review

What this changes

The branch routes shared task-worker diagnostics to stderr and adds a child-process regression that checks parseable JSON stdout and retained diagnostics.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still lacks stderr routing in the shared task-worker server; the merged SQLite writer repair covers a separate worker. The focused patch addresses a real JSON-output failure, with no actionable review finding.

Priority: P2
Reviewed head: fc35d7d89556ed406b87a0a8f1ab161e27ad350f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-level fix has direct process-boundary regression evidence, with the complete updater replay still scheduled after integration.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR reports a pre-fix JSON parse failure and an after-fix Testbox pass on Node 24 using a real child process, task worker, production SQLite diagnostic, and captured stdout and stderr; the regression asserts the exact output contract. The full published-updater replay is planned after merge. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports a pre-fix JSON parse failure and an after-fix Testbox pass on Node 24 using a real child process, task worker, production SQLite diagnostic, and captured stdout and stderr; the regression asserts the exact output contract. The full published-updater replay is planned after merge. No stored-data contract changes.
Evidence reviewed 9 items Introduced worker routing: The PR adds stderr routing after confirming a parent port and leaves task results on the existing message-port protocol.
Current-main gap: Current main returns after the parent-port check without routing task-worker console diagnostics to stderr.
Distinct prior repair: The merged SQLite writer worker routes its own diagnostics to stderr; that does not cover the shared task-worker server.
Findings None None.
Security None None.

How this fits together

Doctor can launch task workers while preparing an update readiness report. Workers return task results through a parent message port, while the updater parses Doctor's process stdout as JSON.

flowchart LR
  A[Update Doctor process] --> B[Task worker pool]
  B --> C[Shared worker server]
  C --> D[Results over parent port]
  C --> E[Diagnostics on stderr]
  D --> F[JSON readiness report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +76. Total +79 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 3 76 0 +76
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 79 0 +79

Review metrics

None.

Technical review

Best possible solution:

Preserve Doctor's strict JSON parser and record the planned published-updater recheck against merged main after this worker fix lands.

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

Yes. The regression defines a real child-process and task-worker path to the SQLite diagnostic, and the reported pre-fix parse failure matches current main's missing worker-local routing; this review did not execute it.

Is this the best way to solve the issue?

Yes. Routing at the shared task-worker entry point addresses the producer while retaining the existing result protocol and Doctor parser.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2a293e5c0b69.

Labels

Label changes:

  • add P2: A worker diagnostic can invalidate machine-readable update readiness output, but the observed failure is from integration proof rather than a confirmed shipped-user regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a pre-fix JSON parse failure and an after-fix Testbox pass on Node 24 using a real child process, task worker, production SQLite diagnostic, and captured stdout and stderr; the regression asserts the exact output contract. The full published-updater replay is planned after merge. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports a pre-fix JSON parse failure and an after-fix Testbox pass on Node 24 using a real child process, task worker, production SQLite diagnostic, and captured stdout and stderr; the regression asserts the exact output contract. The full published-updater replay is planned after merge. No stored-data contract changes.

Label justifications:

  • P2: A worker diagnostic can invalidate machine-readable update readiness output, but the observed failure is from integration proof rather than a confirmed shipped-user regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports a pre-fix JSON parse failure and an after-fix Testbox pass on Node 24 using a real child process, task worker, production SQLite diagnostic, and captured stdout and stderr; the regression asserts the exact output contract. The full published-updater replay is planned after merge. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a pre-fix JSON parse failure and an after-fix Testbox pass on Node 24 using a real child process, task worker, production SQLite diagnostic, and captured stdout and stderr; the regression asserts the exact output contract. The full published-updater replay is planned after merge. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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.

@steipete
steipete enabled auto-merge (squash) September 27, 2026 03:13
@steipete
steipete merged commit c5b1eee into main Sep 27, 2026
225 checks passed
@steipete
steipete deleted the fix/worker-task-json-diagnostics branch September 27, 2026 03:14
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Task results use parentPort IPC. Route diagnostics to stderr in the shared
worker server so nested readers cannot corrupt Doctor's JSON readiness
report during a published-driver update.

Exercise the real snapshot-budget diagnostic in a child process and worker,
requiring both parseable stdout and retained stderr output.
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: S 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