Skip to content

fix: gateway diagnostics hide startup failures behind unrelated log lines - #166946

Merged
RomneyDa merged 1 commit into
mainfrom
fix/gateway-startup-diagnostics
Oct 9, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/gateway-startup-diagnostics

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Related: #144845

What Problem This Solves

Gateway diagnostics could hide Gateway failed to start: behind a later cleanup message, then present unrelated output as the last Gateway error. Status suggested brief warm-up solely because a service process was running.

User Impact

Status and Doctor retain recognized startup failures after cleanup messages. Unconfirmed readiness directs operators to deeper diagnostics. Matching log errors are labeled as potentially belonging to an earlier run.

Why This Change Was Made

A running service process does not establish Gateway readiness. Bounded log-tail selection should report recognized error evidence rather than arbitrary trailing output. Remove the obsolete fallback option and its caller together.

Matching log evidence remains unbound to the boot generation. Downstream classifiers, including onboarding, are not converted to generation-bound evidence in this change.

Evidence

  • New Darwin/Linux reader regressions failed before the fix and passed afterward. The actual status renderer also reproduced unsupported warm-up guidance before the fix.
  • Targeted reader, status renderer and status gathering suites: 107 passed, 1 existing skip through the repository runner with one worker. Runner wall was 242.13 s, including cold compilation and verification; reader tests took 0.577 s, renderer 0.350 s, gathering 11.821 s. CI timing is not yet measured.
  • Full selected check:changed passed, including production/test types, lint, dead-export scans and repository guards. The canonical mock baseline prune removes one obsolete fingerprint.
  • Independent P2 autoreview: scoped-clean, no actionable P0–P2 findings. The subsequent baseline prune is shrink-only.
  • git diff --check passed.

Proof uses synthetic logs and actual command renderer inputs. It did not operate the live Gateway or prove live recovery. Ownership, timeout and persistent-state policies are unchanged.

Exact-head CLI × actual failed native Gateway proof

Unchanged head 454cbf95b0e4cedfdbfdfe5af87cdc54041ee283 passed the official complete pnpm build; generated runtime build ID 2026.9.8-454cbf95b0e4-2026-10-08T05-31-00.668Z. Ran the distributed dist/entry.js CLI against its actual candidate dist/index.js Gateway managed by macOS launchd (gui/501/ai.openclaw.proof166946, canonical isolated profile proof166946, loopback port 19646, fresh generated token, plugins/browser disabled).

The failure used a real private Tailscale CLI/daemon 1.102.5 from official immutable image tailscale/tailscale@sha256:c507f3a2a6ab1cabd8d809b98edeb41edbd5c3fb6ad9632ffd098b4c7d0b4065. Its Docker container had network none, zero host mounts, userspace networking, in-memory state and real BackendState=NeedsLogin. A transparent task-owned tailscale executable on this profile's service PATH forwarded commands to that real vendor CLI via docker exec; it supplied no synthetic JSON or mocked status. The selected Gateway had gateway.tailscale.mode="serve" and genuinely failed startup.

Actual production log sequence (no fabricated/appended lines):

[tailscale] serve failed: Logged out.
[gmail-watcher] gmail watcher stopped
[shutdown] completed cleanly in 46ms
[gateway] wrote stability bundle: [owned profile path]
Gateway failed to start: Logged out.. Run openclaw --profile proof166946 gateway status --deep for diagnostics.
Automatic managed recovery is unavailable on this supervisor; saved diagnostics and manual triage remain available.

The final physical log line is informational recovery guidance. The prior arbitrary-tail fallback could report that as the last error; the actual candidate instead selected the real startup failure. Ran:

node /Users/dallin/openclaw-native-diagnostics/dist/entry.js --profile proof166946 gateway status --deep

Actual CLI result (exit 0, diagnostic command rather than health-success assertion):

Runtime: running (pid 73796)
Readiness is not confirmed. A running service process does not prove the Gateway is available; inspect the service logs and openclaw gateway status --deep.
Connectivity check: failed
  connect ECONNREFUSED 127.0.0.1:19646
Gateway port 19646 is not listening (service appears running).
Recent Gateway log error (may be from an earlier run): [timestamp] Gateway failed to start: Logged out.. Run openclaw --profile proof166946 gateway status --deep for diagnostics.

Assertions over captured real output: startup failure selected; historical/generation uncertainty qualified; no generic Warm-up: launch agents message; no informational cleanup/recovery line labeled as the error. Stopped only this proof service to bound the crash loop.

Healthy/no-error control: archived the actual failed log, emptied only this stopped task profile's log, set its Tailscale mode off, and started the real native Gateway. Independent /healthz and /readyz both returned HTTP 200 (PID 85684). The same actual status command reported Connectivity check: ok, Listening: 127.0.0.1:19646, and no Recent Gateway log error or Last gateway error, despite ordinary startup/health-monitor lines in the log. This checks removal of arbitrary-tail fallback through the distributed CLI rather than only the parser unit test.

Limits: this is actual macOS Gateway/native-service evidence with a genuine isolated Linux Tailscale backend transported through the vendor CLI. It does not claim operator backend mutation, database corruption, a new updater replay, native Linux/Windows service coverage, or that historical log evidence identifies the current generation. An initial fixture setup attempt lacked the private PATH and hit a real existing route ownership refusal; the guard explicitly left that route unchanged. That attempt is excluded from the claimed NeedsLogin proof.

@clawsweeper

clawsweeper Bot commented Oct 8, 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: S labels Oct 8, 2026
@clawsweeper clawsweeper Bot added 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. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 1:54 AM ET / 05:54 UTC (Revision 4).

ClawSweeper review

What this changes

The PR selects recognized Gateway startup errors instead of informational log tails and replaces unsupported warm-up guidance with qualified readiness diagnostics.

Example: Run gateway status --deep after Tailscale startup fails

  • Before: Status can label “Automatic managed recovery is unavailable on this supervisor” as the last error and suggest waiting for warm-up.
  • After: Status selects “Gateway failed to start: Logged out.”, qualifies it as possibly historical, and reports that readiness is not confirmed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, worthwhile diagnostic repair with shipped CLI failure and healthy-control proof, useful regressions, and no remaining findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Exact-head distributed gateway status --deep exercised the changed reader and renderer against a genuinely failed macOS launchd Gateway, selected the startup error over later informational output, and qualified readiness and historical uncertainty. A real healthy control reported successful connectivity and no log error; source inspection confirms no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators investigating a failed Gateway can receive an informational log line as the error and misleading advice to wait for warm-up.
Reason: The change completes the explicitly clarified startup-diagnostics scope with a small shared-owner repair. It appropriately leaves the broader outage linked as Related and does not claim complete incident recovery.

Merge readiness

✅ Ready for maintainer review

This PR is ready within the clarified startup-diagnostics scope: the native CLI proof covers the changed behavior, and no actionable findings remain. Current main still needs this repair; the broader outage remains separate work.

Priority: P2
Reviewed head: 454cbf95b0e4cedfdbfdfe5af87cdc54041ee283

Before merge

None.

Findings

None.

Provenance

  • src/commands/doctor-gateway-daemon-flow.ts: original intent not found (unknown: The extended git log -S search for the original error label failed on unavailable promisor blobs with HTTP 403; supplied latest-line provenance does not establish its introduction.)
  • src/commands/onboard-non-interactive/local/output.ts: original intent not found (unknown: The extended git log -S search for the original error label failed on unavailable promisor blobs with HTTP 403. The supplied merged redaction PR establishes that output redaction and classification must remain separate, which this change preserves.)
  • src/commands/status-all/diagnosis.ts: original intent not found (unknown: The git log -S search for the original log-line label encountered unavailable promisor blobs with HTTP 403 and was stopped; its introducing rationale remains unknown.)
Agent review details

How this fits together

Gateway diagnostics combine native service state, connection checks, and recent service logs to help operators investigate startup failures. The shared log reader supplies error evidence to status, Doctor, and onboarding.

flowchart TD
  A[Native service state] --> D[Gateway status collection]
  B[Connection check] --> D
  C[Bounded service log tail] --> E[Recognized error selection]
  E --> D
  D --> F[Qualified readiness and error output]
  E --> G[Doctor and onboarding diagnostics]
Loading

Technical review

Best possible solution:

Keep one bounded error reader and accurate readiness guidance, while tracking generation-bound diagnostics and crash-loop recovery separately.

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

Yes: current-main source omits the startup-failure pattern and falls back to arbitrary trailing output; the supplied regressions and actual failed-Gateway CLI transcript exercise that mechanism. This review did not execute target code.

Is this the best way to solve the issue?

Yes: extending the existing error selector and removing its misleading fallback is a focused repair, with qualified output that accurately preserves historical uncertainty.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • src/daemon/diagnostics.ts changes intended behavior with a stated reason (b367ed7: Wire Gateway authentication diagnostics into Doctor, selecting recognized errors with a generic log-tail fallback.)
  • src/cli/daemon-cli/status.gather.ts keeps the original intent (fix(gateway): show last error when status probe fails #95902: Surface matching Gateway errors when a running, listening service has a failed status probe without labeling arbitrary output as an error.)
  • src/cli/daemon-cli/status.print.ts changes intended behavior with a stated reason (fix(gateway): distinguish reachable gateway from failed status probe #98183: Distinguish owned-listener probe failures from ambiguous service states and avoid claiming ownership when stale Gateway PIDs remain.)

Testing

Proof path: shipped entry point. Added test files: 3.

Security

None.

Evidence

What I checked:

Likely related people:

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

PR surface

Source +5, Tests +16, Docs +7, Other -1. Total +27 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 6 18 13 +5
Tests 4 39 23 +16
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 12 64 37 +27

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded diagnostic repair that improves startup-failure investigation without changing Gateway availability or recovery policy.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-08T03:40:58.942Z sha 454cbf9 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-08T03:55:42.830Z sha 454cbf9 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-08T05:47:42.483Z sha 454cbf9 :: needs maintainer review before merge. :: none

@RomneyDa
RomneyDa marked this pull request as ready for review October 8, 2026 03:50
@RomneyDa

RomneyDa commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

Completed the previously missing exact-head distributed CLI proof against actual macOS launchd. Full provenance, controlled failure, actual terminal results, independent PID/readiness checks and healthy controls are now in the PR body. No code/head change or proof waiver.

Exact-head CLI × actual failed native Gateway proof

Unchanged head 454cbf95b0e4cedfdbfdfe5af87cdc54041ee283 passed the official complete pnpm build; generated runtime build ID 2026.9.8-454cbf95b0e4-2026-10-08T05-31-00.668Z. Ran the distributed dist/entry.js CLI against its actual candidate dist/index.js Gateway managed by macOS launchd (gui/501/ai.openclaw.proof166946, canonical isolated profile proof166946, loopback port 19646, fresh generated token, plugins/browser disabled).

The failure used a real private Tailscale CLI/daemon 1.102.5 from official immutable image tailscale/tailscale@sha256:c507f3a2a6ab1cabd8d809b98edeb41edbd5c3fb6ad9632ffd098b4c7d0b4065. Its Docker container had network none, zero host mounts, userspace networking, in-memory state and real BackendState=NeedsLogin. A transparent task-owned tailscale executable on this profile's service PATH forwarded commands to that real vendor CLI via docker exec; it supplied no synthetic JSON or mocked status. The selected Gateway had gateway.tailscale.mode="serve" and genuinely failed startup.

Actual production log sequence (no fabricated/appended lines):

[tailscale] serve failed: Logged out.
[gmail-watcher] gmail watcher stopped
[shutdown] completed cleanly in 46ms
[gateway] wrote stability bundle: [owned profile path]
Gateway failed to start: Logged out.. Run openclaw --profile proof166946 gateway status --deep for diagnostics.
Automatic managed recovery is unavailable on this supervisor; saved diagnostics and manual triage remain available.

The final physical log line is informational recovery guidance. The prior arbitrary-tail fallback could report that as the last error; the actual candidate instead selected the real startup failure. Ran:

node /Users/dallin/openclaw-native-diagnostics/dist/entry.js --profile proof166946 gateway status --deep

Actual CLI result (exit 0, diagnostic command rather than health-success assertion):

Runtime: running (pid 73796)
Readiness is not confirmed. A running service process does not prove the Gateway is available; inspect the service logs and openclaw gateway status --deep.
Connectivity check: failed
  connect ECONNREFUSED 127.0.0.1:19646
Gateway port 19646 is not listening (service appears running).
Recent Gateway log error (may be from an earlier run): [timestamp] Gateway failed to start: Logged out.. Run openclaw --profile proof166946 gateway status --deep for diagnostics.

Assertions over captured real output: startup failure selected; historical/generation uncertainty qualified; no generic Warm-up: launch agents message; no informational cleanup/recovery line labeled as the error. Stopped only this proof service to bound the crash loop.

Healthy/no-error control: archived the actual failed log, emptied only this stopped task profile's log, set its Tailscale mode off, and started the real native Gateway. Independent /healthz and /readyz both returned HTTP 200 (PID 85684). The same actual status command reported Connectivity check: ok, Listening: 127.0.0.1:19646, and no Recent Gateway log error or Last gateway error, despite ordinary startup/health-monitor lines in the log. This checks removal of arbitrary-tail fallback through the distributed CLI rather than only the parser unit test.

Limits: this is actual macOS Gateway/native-service evidence with a genuine isolated Linux Tailscale backend transported through the vendor CLI. It does not claim operator backend mutation, database corruption, a new updater replay, native Linux/Windows service coverage, or that historical log evidence identifies the current generation. An initial fixture setup attempt lacked the private PATH and hit a real existing route ownership refusal; the guard explicitly left that route unchanged. That attempt is excluded from the claimed NeedsLogin proof.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@RomneyDa

RomneyDa commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

Maintainer-requested product scope clarification: the restart/Doctor incident was deliberately split into five independent PRs (#166942, #166946, #166947, #166948, #166950). This PR completes the startup diagnostic opportunity: select actual startup failure lines, reject arbitrary informational tails, qualify historical log evidence, and avoid claiming warm-up from a PID. The other incident repairs and generation-bound diagnostics remain separate work; this PR does not claim to close the entire linked outage report.

Revision 3 accepts the exact-head native failed-Gateway and healthy/no-error controls with diamond proof and patch quality, no findings, and no before-merge items. Please assess completeness against this maintainer-requested diagnostic scope. No proof exemption or rating override is requested.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 8, 2026
@RomneyDa
RomneyDa enabled auto-merge (squash) October 9, 2026 18:30
@RomneyDa
RomneyDa merged commit bb5a405 into main Oct 9, 2026
219 checks passed
@RomneyDa
RomneyDa deleted the fix/gateway-startup-diagnostics branch October 9, 2026 18:31
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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