Skip to content

fix(update): prevent debug logs from blocking Gateway updates - #177563

Merged
steipete merged 2 commits into
mainfrom
codex/nodew-r9-handoff-logs
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/nodew-r9-handoff-logs

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes managed Gateway updates failing before startup when debug console logging emits a SQLite diagnostic during the handoff handshake.

User Impact

Updates can start with debug logging enabled. This repairs future installed updaters; a candidate cannot change an already-published updater's pre-activation handshake. No protocol, configuration, or schema changes.

Why This Change Was Made

The helper reserves stdout for control responses, but the imported recovery runtime can log before READY. Initialize the existing stderr route inside the sealed handoff runtime so diagnostics remain available without entering the control pipe. Ownership checks and control parsing stay unchanged. Net production delta: +3 lines; five files changed.

Evidence

Two real cross-machine attempts from published 2026.10.5 reproduced the failure with a node-local tool active. A bounded syscall capture confirmed a SQLite debug line preceded READY; the Gateway kept serving. The requested stable-to-main/version-skew sequence remains blocked by that installed-driver defect; no successful upgrade is claimed.

The regression extends the existing legacy SQLite recovery case: READY must be first on stdout, the actual recovery-module diagnostic must survive on stderr, and recovery must complete. Base failed on the wrong first line (24.92 s wrapper). The focused suite passed six tests, with five PostgreSQL-server cases skipped (27.08 s wrapper / 23.59 s Vitest). After the final sealed-runtime relocation, the real helper regression passed again (43.62 s wrapper / 39.50 s Vitest, including cold worker preparation). Oxfmt, oxlint, diff check, commit hooks, and independent review passed. Broader validation runs in PR CI.

CI run 39304400855 passed on refreshed head 02f817ca8587c19198c17e351b583a8ec892d490, including selected tests, all PostgreSQL conformance shards, types, lint, source contracts, security, and docs. Current main was merged once without conflicts; the authored patch is unchanged. The earlier inherited formatter failure is resolved on this head.

Published-driver compatibility

The stdout writer is the installed handoff helper, not the candidate service. In published 2026.10.5, update-managed-service-handoff.ts loads the installed recovery module, calls the foreground-owner assertion, and only then writes READY. The actual update command starts after READY and ownership transfer. Neither the handoff marker nor the sentinel metadata can make candidate code run before that point, so this fix protects subsequently installed drivers; it cannot repair an already-published driver's handshake.

Source-audited affected releases: regular stable 2026.9.6–2026.9.9 and 2026.10.1–2026.10.5; extended-stable 2026.9.33; prereleases 2026.10.1-beta.1–2, 2026.10.5-beta.1–4, and 2026.10.10-beta.1–2. Only 2026.10.5 has been live reproduced. The immediately preceding 2026.9.5 lacks this foreground-helper path.

Workaround for affected installed drivers: temporarily set logging.consoleLevel to info and remove or override any inherited OPENCLAW_LOG_LEVEL=debug before retrying the update. File logging can remain at debug. This is an operator workaround, not a passing DEBUG-enabled upgrade result.

Post-merge follow-up: merged as 60f7650683f74c3f47a528ec396557b26d8a9f9c after exact-head CI/security passed. Native retained-request recovery refused twice; used the authorized head-pinned REST squash. A fresh 2026.10.5 install passed Gateway health with DEBUG console/file logging enabled. Its update RPC was not dispatched because the lease finished; the replacement queued and was cancelled under the immediate-capacity rule. No fresh published-to-candidate or version-skew pass is claimed. The two existing live failures and the published source identify the installed helper as the pre-READY writer; no candidate-side mitigation can execute that early.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 19, 2026 18:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T18:44:24.307624Z 02f817c 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.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 19, 2026
@steipete steipete changed the title fix(update): keep handoff diagnostics off control pipe fix(update): prevent debug logs from blocking Gateway updates Oct 19, 2026
@steipete
steipete enabled auto-merge (squash) October 19, 2026 18:10
@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR routes managed-update helper diagnostics to stderr so debug logs cannot corrupt its stdout control handshake.

Example: A managed Gateway update runs with OPENCLAW_LOG_LEVEL=debug and emits a SQLite inspection diagnostic before READY.

  • Before: The diagnostic becomes the first stdout line, and the parent rejects the readiness response.
  • After: The diagnostic goes to stderr, leaving OPENCLAW_UPDATE_HANDOFF_READY first on stdout.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful boundary coverage; successful installed-updater behavior is not demonstrated, and the formatting-check failure remains unattributed.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its reported passing evidence exercises the generated helper regression, while the published CLI attempts demonstrate only the pre-fix failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Managed Gateway updates can fail before startup when debug diagnostics enter the helper's control pipe.
Reason: The maintainer-authored direction restores the existing control-channel contract with a small change and accurately limits its effect to corrected installed updaters.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a source-supported handshake failure still present on current main; no actionable patch defect was found.

Priority: P2
Reviewed head: bc35a44f93f76e5b62e92013daf4b098e6e1bcaa

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show a successful update through a corrected installed updater with debug logging; the published-driver attempts reproduce the older driver's limitation.
Agent review details

How this fits together

The installed updater starts a detached helper that loads recovery code, exchanges control messages with the Gateway parent, and owns update handoff and recovery.

flowchart LR
  A[Installed updater] --> B[Detached helper]
  B --> C[Sealed runtime]
  B --> D[Recovery runtime]
  D --> E[Shared logging state]
  C --> E
  E --> F[Diagnostics on stderr]
  B --> G[Control responses on stdout]
Loading

Technical review

Best possible solution:

Keep control parsing strict and initialize the existing shared stderr route before loading the installed recovery runtime.

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

Source establishes a recovery import before READY and rejection of an earlier diagnostic line; the PR reports published-release reproduction and a red-on-base regression, which this read-only review did not execute.

Is this the best way to solve the issue?

The patch repairs diagnostic routing at the existing sealed-runtime boundary without weakening the handshake, changing ownership checks, or adding parallel machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced production change initializes the existing stderr route in the sealed runtime; the remaining hunks expose captured output, extend an existing recovery regression, and document the installed-driver boundary. (src/infra/update-managed-service-handoff-sealed.ts:2, bc35a44f93f7)
  • Failing production boundary: The helper imports the recovery ledger before writing READY, while the parent rejects a first response other than READY or HANDOFF_BUSY. (src/infra/update-managed-service-handoff.ts:726, bc35a44f93f7)
  • Existing logging owner: routeLogsToStderr sets the shared logging-state flag consumed by the subsystem console sink; Symbol.for keeps that state shared across separately loaded runtime copies. (src/logging/console.ts:77, bc35a44f93f7)
  • Focused regression: The existing legacy SQLite recovery case now enables debug logging, invokes the real SQLite diagnostic producer during recovery-module loading, asserts READY first on stdout and the diagnostic on stderr, and retains recovery and sentinel assertions. (src/infra/update-managed-service-handoff-engine.test.ts:168, bc35a44f93f7)
  • Current main still needs the change: The fetched main sealed entry does not initialize stderr routing. (src/infra/update-managed-service-handoff-sealed.ts:1, dc81220e46b6)
  • Installed-driver limitation: The PR reports two published-v2026.10.5 failures with a diagnostic before READY and passing helper regression runs after the fix; it explicitly claims no successful stable-to-candidate upgrade. (bc35a44f93f7)

Likely related people:

  • Peter Steinberger: Raw commit e07af71 adds src/infra/update-managed-service-handoff-sealed.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e07af7166c16; files: src/infra/update-managed-service-handoff-sealed.ts)

PR surface

Source +3, Tests +19, Docs +4. Total +26 across 5 files. Added test files: 0.

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

Labels

Label changes:

  • add P2: Debug logging can prevent managed updates from starting, but the reported failure leaves the existing Gateway serving.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Debug logging can prevent managed updates from starting, but the reported failure leaves the existing Gateway serving.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain file-level diagnostics for the failed check-docs formatting step and determine whether the failure is introduced or inherited.

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 19, 2026, 2:22 PM ET / 18:22 UTC.

@steipete
steipete disabled auto-merge October 19, 2026 18:26
@steipete
steipete merged commit 60f7650 into main Oct 19, 2026
112 checks passed
@steipete
steipete deleted the codex/nodew-r9-handoff-logs branch October 19, 2026 19:01
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…aw#177563)

Route managed handoff diagnostics to stderr before the recovery runtime runs, preserving stdout for READY and other control messages. Retain the generated-helper regression and document the installed-driver limitation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant