Skip to content

fix(logs): clean up gateway and channel startup/shutdown log output - #104174

Merged
steipete merged 3 commits into
mainfrom
claude/improve-log-output-657964
Jul 11, 2026
Merged

steipete merged 3 commits into
mainfrom
claude/improve-log-output-657964

Conversation

@steipete

@steipete steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Routine gateway boots print duplicated, mislabeled, and zero-information log lines that bury real problems. Observed on a live pnpm gateway:watch session (see linked issue): voice-state probes logged as slash-command deploy errors, the same deploy failure logged twice with the JSON body repeated inside it, unresolved-channel lines printed with no timestamp/subsystem prefix, Slack "resolved" lines that map an id to itself, five log lines for one SIGTERM, doctor printing the backup path twice, and nine runtime-postbuild timing rows per rebuild.

Fixes #104163.

Why This Change Was Made

Each fix targets a specific defect rather than a style preference:

  • Mislabeled REST diagnostics — provider.deploy.ts monkeypatches the shared client.rest for the whole deploy window, so unrelated concurrent startup traffic (voice-state probes, channel lookups) picked up the native-slash-command-deploy-rest label and was re-logged at error level even when its owner (e.g. the voice manager) already treats the failure as an expected state. The wrapper now passes non-/applications/**/commands paths straight through.
  • Double logging of deploy failures — the per-request rest:*:error line is now verbose-only; the single owner-level warning (slash command deploy failed (message send/receive unaffected): ...) is the one non-verbose line per failure.
  • Redundant body= — Discord error envelopes that only contain message + code are no longer appended, since both already appear in the line.
  • Multi-line prefix loss — summarizeMapping logged resolved+unresolved as one \n-joined message; the console logger only prefixes the first line. It now logs one call per line.
  • Identity-mapping noise — allowlist summaries skip lookups that resolved to themselves with no display name (U0ATMLTKMC3→U0ATMLTKMC3 (id:U0ATMLTKMC3) said nothing three times per boot), and the (id:...) suffix is only added when the id isn't already visible in the line.
  • Embedded subsystem prefixes — [discord] discord: ... messages had the channel name baked into the message; the logger already prefixes the subsystem. (The theme-colored warn() wrapper defeats the console's redundant-prefix stripper, so this has to be fixed at the call sites.)
  • Shutdown chatter — signal SIGTERM received and shutdown started: ... demoted to debug; received SIGTERM; shutting down + shutdown completed cleanly in Nms remain.
  • Doctor backup duplicate — logConfigUpdated already prints the .bak line; the second print in doctor-health-contributions.ts is removed.
  • Control UI assets — the two near-identical messages (pre-warning in run.ts, build notice in control-ui-assets.ts) are merged into one line at build time carrying the pnpm ui:build/pnpm ui:dev guidance.
  • force: no listeners — demoted to debug when nothing was actually killed.
  • Telegram polling [diag] isolated polling ingress started — intentionally kept at info: the test/e2e/qa-lab telegram-bot-token runtime waits for this exact marker on the injected runtime log, so demoting it would time out that live proof. The contract is now commented at the call site.
  • runtime-postbuild — one summary line by default (9 phases completed in 903ms (slowest: ...)); per-phase rows via OPENCLAW_RUNTIME_POSTBUILD_TIMINGS=verbose, 0 still silences.
  • Actionability — the recurring transcripts autoStart failed config error now names the config surface to fix (transcripts.autoStart); command-limit warnings name the platform limit (112 commands exceed the 100-command Telegram limit; ...).

A "startup issues summary block" was considered and deliberately not built: channel config findings trickle in for 60s+ after [gateway] ready (transcripts autoStart fires a minute later), and aggregated reporting already exists in openclaw channels status / openclaw doctor. The per-line fixes make each remaining line correctly attributed and actionable instead of adding a second, racy aggregator.

User Impact

Operators watching gateway logs get one correctly-labeled line per event. Example (default verbosity, from the observed session):

Before

03:29:23 [gateway] Control UI assets are missing; first startup may spend a few seconds building them before the gateway binds. `pnpm gateway:watch` does not rebuild Control UI assets, so rerun `pnpm ui:build` after UI changes or use `pnpm ui:dev` while developing the Control UI. For a full local dist, run `pnpm build && pnpm ui:build`.
03:29:23 [gateway] force: no listeners on port 18789
03:29:24 [gateway] Control UI assets missing; building (ui:build, auto-installs UI deps)…
03:29:28 [telegram] 112 commands exceeds limit; removing per-skill commands and keeping /skill.
03:29:28 [telegram] [diag] isolated polling ingress started spool=/Users/steipete/.openclaw/telegram/ingress-spool-default
03:29:28 [slack] channels resolved: C0AUXUC5AGN→maintainers (id:C0AUXUC5AGN)
03:29:28 [slack] users resolved: U0ATMLTKMC3→U0ATMLTKMC3 (id:U0ATMLTKMC3)
03:29:28 [slack] channel users resolved: U0ATMLTKMC3→U0ATMLTKMC3 (id:U0ATMLTKMC3)
03:29:29 [discord] channels resolved: 1456350064065904867/1456744319972282449 (guild:Friends of the Crustacean 🦞🤝; channel:maintainers), …
discord channels unresolved: 1456350064065904867/1501689839878275142 (guildId:1456350064065904867; channelId:1501689839878275142)
03:29:30 [discord] discord: 110 commands exceeds limit; removing per-skill commands and keeping /skill.
03:29:30 [discord] startup [default] native-slash-command-deploy-rest:get:error 3147ms path=/channels/1501689839878275142 requestMs=177 error=Missing Access (status=403, code=50001, body={"message":"Missing Access","code":50001})
03:29:30 [discord] startup [default] native-slash-command-deploy-rest:post:error 3411ms path=/applications/1456406468898197625/commands requestMs=198 error=Maximum number of application commands reached (100). (status=400, code=30032, body={"message":"Maximum number of application commands reached (100).","code":30032})
03:29:30 [discord] discord: native slash command deploy warning (not message send): Maximum number of application commands reached (100). (status=400, code=30032, body={"message":"Maximum number of application commands reached (100).","code":30032})
03:29:31 [discord] startup [default] native-slash-command-deploy-rest:get:error 3528ms path=/guilds/1456350064065904867/voice-states/387380367612706819 requestMs=177 error=Unknown Voice State (status=404, code=10065, body={"message":"Unknown Voice State","code":10065})
03:30:10 [gateway] signal SIGTERM received
03:30:10 [gateway] received SIGTERM; shutting down
03:30:10 [shutdown] started: gateway stopping
03:30:11 [shutdown] completed cleanly in 736ms

After

03:29:24 [gateway] Control UI assets missing; building them now (rerun `pnpm ui:build` after UI changes, or use `pnpm ui:dev` while developing the Control UI)…
03:29:28 [telegram] 112 commands exceed the 100-command Telegram limit; removing per-skill commands and keeping /skill.
03:29:28 [telegram] [diag] isolated polling ingress started spool=/Users/steipete/.openclaw/telegram/ingress-spool-default
03:29:28 [slack] channels resolved: C0AUXUC5AGN→maintainers
03:29:29 [discord] channels resolved: 1456350064065904867/1456744319972282449 (guild:Friends of the Crustacean 🦞🤝; channel:maintainers), …
03:29:29 [discord] channels unresolved: 1456350064065904867/1501689839878275142 (guildId:1456350064065904867; channelId:1501689839878275142)
03:29:30 [discord] 110 commands exceed the 100-command Discord limit; removing per-skill commands and keeping /skill.
03:29:30 [discord] [default] slash command deploy failed (message send/receive unaffected): Maximum number of application commands reached (100). (status=400, code=30032)
03:30:10 [gateway] received SIGTERM; shutting down
03:30:11 [shutdown] completed cleanly in 736ms

The Missing Access probe and Unknown Voice State lines don't disappear from the product — they were never deploy events. The channel probe still surfaces as channels unresolved (now correctly prefixed), and the voice manager keeps handling its expected 404s verbose-only, as it already did.

Doctor no longer prints the backup twice:

Updated config: ~/.openclaw/openclaw.json
  Backup: ~/.openclaw/openclaw.json.bak

Rebuilds print one postbuild line instead of nine (captured from the remote proof build):

runtime-postbuild: 9 phases completed in 246ms (slowest: stable root runtime imports 87ms)

OPENCLAW_RUNTIME_POSTBUILD_TIMINGS=verbose restores the per-phase rows; 0 still silences timings entirely.

Evidence

  • New regression tests: extensions/discord/src/monitor/provider.deploy.test.ts (non-command REST passthrough keeps caller-owned error handling, exactly one warning per deploy failure at default verbosity, redundant-body dedupe), identity-skip coverage in src/channels/allowlists/resolve-utils.test.ts and extensions/slack/src/monitor/provider.allowlist.test.ts.
  • Updated assertions for the reworded lines in provider.test.ts, provider.allowlist.test.ts, bot-native-commands.test.ts, resolve-utils.test.ts; subsystem-logger test mocks gained the debug method the demoted lines now use.
  • Blacksmith Testbox via Crabbox (tbx_01kx7nc2abm64vxh7gwzeghx9r): focused suites green — discord provider/deploy/allowlist, slack allowlist, telegram native commands, channel resolve-utils, gateway run/run-loop/server-close, run-node (7 shards); pnpm check:changed exit 0 (typecheck core/tests/extensions + lint fan-out + guards); pnpm build exit 0.
  • Codex autoreview (gpt-5.6-sol): two accepted findings were fixed in follow-up commits — Slack bare-name resolutions (general → id) are no longer suppressed by the identity filter, and the Telegram isolated-ingress readiness marker stays on the runtime log because the test/e2e/qa-lab bot-token runtime waits for it. The remaining changelog finding is rejected per repo policy (CHANGELOG.md is release-only; release-note context lives in this PR body and the commit messages).
  • Focused reruns after the review fixes: extensions/slack/src/monitor/provider.allowlist.test.ts 8/8 green.

Scope Discord slash-command deploy REST diagnostics to command routes so
concurrent startup traffic (voice-state probes, channel lookups) keeps its
owner's error handling; make per-request deploy error lines verbose-only and
drop JSON bodies that only repeat message+code. Log allowlist summaries one
line per call so unresolved lines keep their timestamp/subsystem prefix, and
skip identity lookups that resolved to themselves. Remove embedded subsystem
prefixes, demote routine signal/shutdown/force/postbuild/diag chatter to
debug or verbose, merge the duplicate Control UI build notices, drop doctor's
duplicate backup line, and name the config surface or platform limit in the
transcripts autoStart and command-limit warnings.

Fixes #104163
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 11, 2026
steipete added 2 commits July 11, 2026 05:41
Only omit identity lookups where the input already is the resolved id;
name-based lookups that translated to an id stay logged even when the
display name matches the input.
test/e2e/qa-lab telegram-bot-token-runtime waits for this line via the
injected RuntimeEnv.log; verbose-only logging would deterministically time
out that live proof. Comment the contract at the call site.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 11, 2026, 1:03 AM ET / 05:03 UTC.

Summary
The PR cleans up gateway and channel startup/shutdown logging, narrows Discord deploy diagnostics to command routes, reduces duplicate and no-op output, and adds focused regression coverage.

PR surface: Source +34, Tests +168, Other +19. Total +221 across 26 files.

Reproducibility: yes. from source inspection: comparing the base and proposed conditionals shows that values such as 1 or the string true change from detailed rows to summary-only output. I did not execute the build path during this read-only review.

Review metrics: 1 noteworthy metric.

  • Diagnostic mode change: 1 environment variable changed from binary to three modes. The proposed interpretation changes established behavior for existing non-0 values and therefore needs upgrade-safe mode coverage.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104163
Summary: This PR is the direct candidate fix for the linked issue's observed gateway and channel lifecycle logging defects.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Preserve legacy non-0 timing aliases and add focused mode tests.
  • [P2] Refresh and re-review the repaired exact head before merge.

Risk before merge

  • [P1] Existing scripts or developer environments using OPENCLAW_RUNTIME_POSTBUILD_TIMINGS=1, true, or another previously accepted non-0 value will silently lose detailed phase rows after merge.

Maintainer options:

  1. Preserve existing timing aliases (recommended)
    Treat previously accepted non-0 values as detailed timing mode, keep unset as the new summary mode, and add focused compatibility tests.
  2. Accept changed timing semantics
    Intentionally restrict detailed rows to verbose and document that existing truthy aliases now produce only the summary.

Next step before merge

  • [P2] The known compatibility defect remains and the protected maintainer label requires explicit owner handling rather than automated repair routing.

Security
Cleared: The diff changes logging and tests without modifying dependencies, workflows, permissions, credentials, package resolution, publishing, or downloaded code execution.

Review findings

  • [P2] Preserve existing truthy timing values — scripts/runtime-postbuild.mjs:557
Review details

Best possible solution:

Keep the new one-line summary when the variable is unset, preserve all previously accepted non-0 values as detailed timing aliases, retain 0 as disabled, and add focused tests for unset, 0, 1, true, and verbose.

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

Yes from source inspection: comparing the base and proposed conditionals shows that values such as 1 or the string true change from detailed rows to summary-only output. I did not execute the build path during this read-only review.

Is this the best way to solve the issue?

No as currently written. The owner-local logging corrections are narrower and safer than a new startup aggregator, but the runtime-postbuild mode change must preserve its existing environment contract.

Full review comments:

  • [P2] Preserve existing truthy timing values — scripts/runtime-postbuild.mjs:557
    Before this change every environment value except 0 enabled per-phase rows, so existing setups using OPENCLAW_RUNTIME_POSTBUILD_TIMINGS=1, true, or another non-0 value silently switch to summary-only output. Preserve those prior aliases and add focused mode coverage while reserving the unset value for the new summary default.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is a low-blast-radius operator and developer logging cleanup rather than an urgent broken runtime or channel workflow.
  • merge-risk: 🚨 compatibility: Merging the PR as written silently changes the established behavior of existing OPENCLAW_RUNTIME_POSTBUILD_TIMINGS values.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes after-fix live gateway output and remote Testbox build and focused-suite transcripts that directly demonstrate the logging changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live gateway output and remote Testbox build and focused-suite transcripts that directly demonstrate the logging changes.
Evidence reviewed

PR surface:

Source +34, Tests +168, Other +19. Total +221 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 16 99 65 +34
Tests 9 197 29 +168
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 22 3 +19
Total 26 318 97 +221

What I checked:

  • Unresolved compatibility regression: The new three-mode parser only enables per-phase rows for the literal verbose value or boolean true, while the prior implementation enabled them for every environment value except 0; values such as 1 and the string true therefore silently change behavior. (scripts/runtime-postbuild.mjs:557, 9ade171f66bb)
  • Prior finding remains on current head: The two follow-up commits changed only Slack allowlist formatting and the Telegram readiness marker; scripts/runtime-postbuild.mjs is unchanged since the earlier reviewed SHA, so the prior blocker was not repaired. (scripts/runtime-postbuild.mjs:557, 9ade171f66bb)
  • Existing contract provenance: Current main introduced the binary timing behavior in commit c34ada3: timing rows are enabled unless the value is exactly 0. (scripts/runtime-postbuild.mjs:552, c34ada31c5b5)
  • Proof and validation: The PR body provides observed before/after gateway logs and remote Blacksmith Testbox output for focused suites, changed checks, and the build on the proposed branch. (9ade171f66bb)
  • Current-main drift check: The base-to-current-main changes touching the PR file set are limited to CI workflow files, not the runtime logging files under review; GitHub reports the PR mergeable but behind. (c4f46baec317)

Likely related people:

  • steipete: Peter introduced the current runtime-postbuild timing path in merged commit c34ada3 and has recent merged history across the central logging and gateway files, making him the strongest routing candidate beyond authorship of this proposal. (role: introduced behavior and recent area contributor; confidence: high; commits: c34ada31c5b5; files: scripts/runtime-postbuild.mjs, src/cli/gateway-cli/run-loop.ts, src/gateway/server-close.ts)
  • Josh Avant: Commit fbd330b recently changed shared channel policy behavior near the allowlist resolution surface, so this contributor is a useful secondary reviewer for shared channel logging semantics. (role: recent adjacent channel contributor; confidence: medium; commits: fbd330b7aa4a; files: src/channels/allowlists/resolve-utils.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-11T04:51:45.159Z sha 703935e :: found issues before merge. :: [P2] Preserve existing truthy timing values

@steipete
steipete merged commit 36e0ac3 into main Jul 11, 2026
108 checks passed
@steipete
steipete deleted the claude/improve-log-output-657964 branch July 11, 2026 05:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…penclaw#104174)

* fix(logs): clean up gateway and channel startup/shutdown log output

Scope Discord slash-command deploy REST diagnostics to command routes so
concurrent startup traffic (voice-state probes, channel lookups) keeps its
owner's error handling; make per-request deploy error lines verbose-only and
drop JSON bodies that only repeat message+code. Log allowlist summaries one
line per call so unresolved lines keep their timestamp/subsystem prefix, and
skip identity lookups that resolved to themselves. Remove embedded subsystem
prefixes, demote routine signal/shutdown/force/postbuild/diag chatter to
debug or verbose, merge the duplicate Control UI build notices, drop doctor's
duplicate backup line, and name the config surface or platform limit in the
transcripts autoStart and command-limit warnings.

Fixes openclaw#104163

* fix(slack): keep bare-name allowlist resolutions in startup log summary

Only omit identity lookups where the input already is the resolved id;
name-based lookups that translated to an id stay logged even when the
display name matches the input.

* fix(telegram): keep isolated-ingress readiness marker on the runtime log

test/e2e/qa-lab telegram-bot-token-runtime waits for this line via the
injected RuntimeEnv.log; verbose-only logging would deterministically time
out that live proof. Comment the contract at the call site.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway startup logs: mislabeled Discord deploy diagnostics, duplicated lines, and zero-information output

1 participant