Repository navigation
fix(workers): keep task diagnostics off JSON stdout - #159351
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 10:55 PM ET / September 27, 2026, 02:55 UTC. ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherDoctor 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +76. Total +79 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
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.
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-lintfailed withUnexpected 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:JSON.parsewith 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.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 asc5b1eee718431609d13ab14633ea60a44c102c5fafter exact-head CI36289682662passed atfc35d7d89556ed406b87a0a8f1ab161e27ad350f. The canonical package and full published-updater cell have now passed on merged main, as recorded below.HTTP Ingress Stack
Final Merged-Main Proof
All six HTTP slices and the worker-output repair #159351 are merged. The final proof passed on pinned main
a6b5ed882cb5e7a10e9346d0e1152878a55653a4(tree9cbab37566c97b4c13219d87f65153cfe1ea7377), 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.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.legacyWebhook: false, before/after restartBindings matched the shipped defaults: Telegram
127.0.0.1:8787, Feishu127.0.0.1:3000, Teams wildcard:3978, Nextcloud0.0.0.0:8788. Explicit legacy objects selected their configured endpoint; false consistently closed it. Implicit defaults stayed runtime-derived, without materializinglegacyWebhookin config.Doctor's explicit-port migration passed for enabled and disabled channels.
openclaw.json.bak.2retained every original port before mutation; canonicallegacyWebhookvalues 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 exact200 okresponses 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: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.