Repository navigation
fix(gateway): honor ambient channel opt-in during config loading - #157387
Conversation
|
🦞👀 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 real behavior proof before merge. Reviewed September 25, 2026, 11:34 AM ET / 15:34 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch passes the Gateway’s ambient-channel choice into initial config loading, uses authored channel settings as explicit consent, and adds startup, reload, and operator-documentation coverage. Merge readiness⛔ Blocked before merge - 6 items remain Keep open. Current main still has the documented ambient-channel opt-in bypass. The repair appears sound, but its final channel-transport effect and upgrade behavior need proof before merge. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway combines operator configuration, inherited environment credentials, and a process flag to select channel plugins. That selection determines which messaging channels can connect to external services. flowchart LR
A[Operator channel config] --> D[Initial config loading]
B[Inherited credentials] --> D
C[Ambient opt-in flag] --> D
D --> E[Channel activation policy]
E --> F[Plugin startup]
F --> G[Channel transport]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The diff adds no supply-chain surface and narrows activation, but rejection of an inherited credential at final channel I/O remains unproven. PR surfaceSource +8, Tests +127, Docs 0. Total +135 across 10 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Complete the existing opt-in policy with a visible suppression warning and verify both final channel effects and released-version upgrade recovery before landing. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source exposes the policy omission, and the PR body records a pre-fix live Discord connection; I did not execute the checkout. Is this the best way to solve the issue? Yes in design. Carrying the selected policy through the existing loader and checking authored configuration addresses the identified bypass, subject to final-effect and upgrade proof. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 07347aca9edc. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
Carry the selected Gateway ambient policy into initial config auto-enable, matching reload preparation. Require that policy at the startup config boundary and classify explicit channel presence from authored source rather than generated runtime enablement. Remove duplicate detector defaults. Preserve explicit channel configuration and both ambient opt-in flags. Document that the policy also applies to reloads and managed services. Release-note context: env-only channel activation bypassed the documented opt-in in stable releases through v2026.9.6. Affected operators must add channels.<id> configuration or use --ambient-channels. Existing suppression warnings explain the enablement path; no config migration should infer operator consent from environment credentials. Completes the policy work from #112011 and #123174 across the loader extracted in #110779. Validation: 440 focused tests passed. Before the fix, the new suite had two expected failures (suppression bypass and generated consent) and three passes; after the fix all five pass. The authored-config/prior-release corpus run had 24 passes and five 120-second timeouts, all in the first Doctor checkpoint before Gateway config loading. No causal connection to this fix was found; migration/worker timing remains a separate follow-up. A standalone replay was stopped while waiting for the legitimate artifact lock held by check-changed, before it reached Vitest. The changed-check aggregate passed production typing, all 25 test-type graphs, formatting, config docs, plugin boundaries and earlier guards, but failed on the full-tree Knip export scan's 600-second timeout. The same scan timed out when run alone with its unchanged limit; production/script export scans passed. Changed-file lint passed with zero warnings/errors. The native-state schema guard passed. The supplemental database-first scan was stopped after over 16 minutes under host load around 179; later media, sidecar, import-cycle, webhook and pairing guards were not run. Full changed-check validation is not claimed green.
c923204 to
ffbf3e9
Compare
|
Merged via squash.
|
…nclaw#157387) Carry the selected Gateway ambient policy into initial config auto-enable, matching reload preparation. Require that policy at the startup config boundary and classify explicit channel presence from authored source rather than generated runtime enablement. Remove duplicate detector defaults. Preserve explicit channel configuration and both ambient opt-in flags. Document that the policy also applies to reloads and managed services. Release-note context: env-only channel activation bypassed the documented opt-in in stable releases through v2026.9.6. Affected operators must add channels.<id> configuration or use --ambient-channels. Existing suppression warnings explain the enablement path; no config migration should infer operator consent from environment credentials. Completes the policy work from openclaw#112011 and openclaw#123174 across the loader extracted in openclaw#110779. Validation: 440 focused tests passed. Before the fix, the new suite had two expected failures (suppression bypass and generated consent) and three passes; after the fix all five pass. The authored-config/prior-release corpus run had 24 passes and five 120-second timeouts, all in the first Doctor checkpoint before Gateway config loading. No causal connection to this fix was found; migration/worker timing remains a separate follow-up. A standalone replay was stopped while waiting for the legitimate artifact lock held by check-changed, before it reached Vitest. The changed-check aggregate passed production typing, all 25 test-type graphs, formatting, config docs, plugin boundaries and earlier guards, but failed on the full-tree Knip export scan's 600-second timeout. The same scan timed out when run alone with its unchanged limit; production/script export scans passed. Changed-file lint passed with zero warnings/errors. The native-state schema guard passed. The supplemental database-first scan was stopped after over 16 minutes under host load around 179; later media, sidecar, import-cycle, webhook and pairing guards were not run. Full changed-check validation is not claimed green. Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
docs/cli/gateway/running.mdsays a Gateway only auto-configures channels from ambient environment variables when started with--ambient-channels; otherwise channels need an explicitchannels.<id>block. In practice, a Gateway started without the flag still enables channels from the environment.Live reproduction on
main(d36ba5479c3), isolated state and port, emptychannelsconfig,DISCORD_BOT_TOKENinherited from the shell, no--ambient-channels:The throwaway QA Gateway logged into a real Discord bot and received a channel session before it was stopped. Any process that happens to inherit a bot token (a dev Gateway, an agent worker shell, CI) can silently come online as that bot.
Why This Change Was Made
openclaw gateway runalready selects the ambient policy (src/cli/gateway-cli/run.ts), and config reloads already forward it. Initial startup config loading did not:prepareGatewayServerBootstrapnever passed the policy toloadGatewayStartupConfigSnapshot, so plugin auto-enable fell back to its local"allow"default. The synthesized channel block was then classified as explicit consent inresolveConfiguredChannelPresencePolicy, escaping the ambient-only filter.This change:
ambientEnvTriggerspolicy and forwards it from bootstrap, matching the reload path;"allow"parameter defaults soconfig-presenceowns the single default.Explicit
channels.<id>config still works and can still read credentials from the environment. Explicit disables stay authoritative.--ambient-channels(and the deprecated--dev-ambient-channels) still opt in for that process, including reloads.User Impact
Gateways no longer come online on a messaging channel just because a token exists in their environment.
Compatibility (maintainer decision: land the fix; the old env-only default is not preserved): stable
v2026.7.1enabled env-only channels by default, andv2026.9.6still does through this bypass (#112011 introduced the opt-in for dev mode, #123174 extended it to every Gateway). Operators who configure a channel only through an environment token will see that channel stay off after upgrading until they addchannels.<id>config (for examplechannels.discord.enabled=true) or start with--ambient-channels. No existing config becomes invalid, so there is no Doctor migration; inferring consent from the presence of credentials would recreate the bug. The existing startup warning names the remediation. A release note should call this out.Evidence
src/gateway/server-startup-config.ambient-channels.test.tsdrives initial config loading and reload with a fake env token: default suppression, ambient opt-in, explicit channel config, and explicit disable with opt-in. The suppression cases fail on currentmain.node scripts/run-vitest.mjsover the new test plus startup recovery, plugin activation, startup plugins/log, channel plugin ids, plugin auto-enable core/channels, and gateway run option-collision suites: 440 passed.check-changed's full-tree unused-export scan timed out under extreme host load; CI covers it.Production LOC: +11 / −3. Tests: +127. Docs: +1 / −1.