Skip to content

fix(channels): fail-fast headless channel setup with plugin-declared env contracts - #122530

Merged
steipete merged 10 commits into
mainfrom
steipete/channels-add-headless
Aug 12, 2026
Merged

steipete merged 10 commits into
mainfrom
steipete/channels-add-headless

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Headless/cloud bootstrap needs scriptable channel provisioning, and channels add had three silent-failure defects in that path:

  1. Selection-only openclaw channels add --channel <id> enters the interactive wizard with no TTY guard — an unattended script hangs forever (src/commands/channels/add.ts, src/wizard/clack-prompter.ts).
  2. Most --use-env setups bypass required-credential validation without checking the environment variable actually exists (e.g. Telegram, extensions/telegram/src/setup-core.ts). A typo'd or missing env var yields a "configured" channel that never connects, with nothing explaining why. Buzz and Matrix already validated env presence locally — the policy existed, duplicated, in two plugins.
  3. Nostr --use-env was broken end-to-end: setup cleared the stored key while runtime account resolution never read NOSTR_PRIVATE_KEY (extensions/nostr/src/setup-adapter.ts, extensions/nostr/src/types.ts) — a guaranteed dead channel.

Why This Change Was Made

Second step of the cloud-container deployment track (after #122477): make openclaw channels add --channel <id> --use-env a safe, fail-fast primitive for scripted deployments.

  • Non-TTY fail-fast: guided channels add without a TTY now exits 1 with the non-interactive alternative named, instead of hanging. Guard placed in channels add (not createClackPrompter, which has 14 other production consumers).
  • Plugin-declared env contract (additive SDK surface): the setup contract's useEnv boolean field gains optional envVars: readonly string[] and envVarMode: "all" | "any" (src/channels/plugins/setup-contract.ts). Core validates presence generically at the shared account-config seam (src/channels/plugins/account-config-mutation.ts) and fails fast naming the exact missing variables. Channels without the declaration behave exactly as before, so third-party plugins are unaffected. Core stays plugin-agnostic — no channel names or env names in core.
  • 13 in-tree contracts migrated (Telegram, Discord, Slack SLACK_BOT_TOKEN+SLACK_APP_TOKEN, Google Chat with any-of value/file, IRC, LINE, Mattermost, Nextcloud Talk, Synology Chat, Zalo, ClickClack, Buzz, Nostr). Buzz's duplicate local check is removed in the same change. Matrix keeps its account-scoped MATRIX_* validation — that contract is per-account and not expressible as a static list.
  • Nostr fix: a shared resolveNostrPrivateKey resolver now honors NOSTR_PRIVATE_KEY in both setup and runtime, matching the Telegram/Discord ambient-fallback pattern.
  • Docs: headless provisioning recipe (non-interactive onboard → channels add --use-env → gateway env requirements → config hot-reload behavior) on the channels CLI and Docker install pages.

User Impact

  • Scripted/cloud deployments fail fast with actionable errors instead of hanging or silently producing dead channels.
  • --use-env semantics are otherwise unchanged (ambient runtime fallback; no SecretRef changes).
  • Third-party channel plugins: no behavior change without opting into the new optional metadata.

Evidence

  • Focused Vitest: 258 tests across 7 shards, all passing.
  • Plugin SDK surface gate (pnpm plugin-sdk:surface:check) and API gates: pass (28 generated surface baselines updated for the additive fields).
  • Docs build: 770 MDX files pass, 6448 links, 0 broken.
  • Built-CLI black-box checks: non-TTY wizard exits 1 with remediation; missing TELEGRAM_BOT_TOKEN / Slack token pair exit 1 naming the variables; present env succeeds and commits config exactly as before.
  • Regression coverage: non-TTY guard, per-channel missing/present env, undeclared-contract passthrough (third-party compat), Nostr env fallback (fails on pre-fix code), Buzz coverage moved to the shared seam.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 12, 2026 07:32
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo commands Command implementations docker Docker and sandbox tooling channel: irc channel: synology-chat channel: buzz extensions: clickclack size: M maintainer Maintainer-authored PR labels Aug 12, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 1:10 PM ET / 17:10 UTC.

ClawSweeper review

What this changes

The PR makes non-interactive channel setup fail clearly when a wizard would be required, validates plugin-declared environment credentials before writing config, and documents headless provisioning.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still permits a headless wizard path and lacks generic plugin-declared environment validation; this branch repairs those paths with no blocking correctness finding. The remaining gate is exact merge-result validation for the additive plugin setup contract.

Priority: P1
Reviewed head: a3318171d6a2dd8c0c40f2f19060c1b2ed67a4f3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has coherent ownership boundaries and described black-box evidence; final exact merge-result checks remain useful compatibility assurance.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports built-CLI and focused regression evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports built-CLI and focused regression evidence.
Evidence reviewed 7 items Current main remains affected: Current main has neither the non-interactive wizard guard nor generic optional environment validation, so the central failure mode remains unresolved outside this PR.
Headless failure is repaired before mutation: The branch emits actionable TTY remediation before loading the wizard, and prepares/validates the channel setup before the later config-write path.
Shared validation has the right owner boundary: The generic channel layer reads optional boolean-field environment metadata and checks any/all requirements; plugins retain their own semantic validation.
Findings None None.
Security None None.

How this fits together

The channels CLI selects either guided or headless setup, then asks the owning channel plugin to validate credentials before persisting account configuration. Plugin setup metadata describes portable requirements while channel-specific conditional rules remain with the plugin.

flowchart LR
  A[Operator runs channels add] --> B[Choose wizard or headless setup]
  B --> C[Terminal interactivity check]
  B --> D[Plugin setup metadata]
  D --> E[Credential validation]
  E --> F[Plugin-specific validation]
  F --> G[Persist channel config]
  G --> H[Refresh plugin registry]
Loading

Before merge

  • Resolve merge risk (P1) - The additive envVars/envVarMode plugin setup contract is compatibility-sensitive for bundled and installed plugins; exact merge-result channel, SDK-baseline, and documentation checks should finish before landing.
  • Complete next step (P2) - The patch is correct but changes a public plugin setup contract, so it needs ordinary maintainer review and exact-head validation rather than automated repair dispatch.
Agent review details

Security

None.

PR surface

Source +103, Tests +229, Docs +54, Config +14, Generated 0, Other +41. Total +441 across 72 files.

View PR surface stats
Area Files Added Removed Net
Source 20 118 15 +103
Tests 7 247 18 +229
Docs 3 54 0 +54
Config 13 27 13 +14
Generated 28 28 28 0
Other 1 53 12 +41
Total 72 527 86 +441

Review metrics

Metric Value Why it matters
Production versus test delta production +175/-33; tests +247/-17; generated +81/-40 The production growth establishes a shared setup-contract boundary and Nostr resolver; the substantial test coverage exercises headless behavior and plugin compatibility.
Setup contract surface 2 additive metadata properties envVars and envVarMode become serializable plugin-facing metadata, so installed-plugin compatibility needs merge-result verification.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/channels/plugins/account-config-mutation.test.ts, vector/embedding metadata: src/channels/plugins/account-config-mutation.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate the merged plugin contract (recommended)
    Run the exact merge-result channel setup, plugin SDK baseline, and documentation checks before merge because installed plugins consume the additive setup metadata.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run exact merge-result checks for channel setup, plugin SDK surface, and docs.

Technical review

Best possible solution:

Land the single generic metadata path after exact merge-result validation, keeping mode-dependent credential rules inside their owning channel plugins.

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

Yes, from source: current main can enter wizard setup without a terminal guard and has no generic pre-write environment validation; this review did not run artifact-producing commands.

Is this the best way to solve the issue?

Yes: portable credential presence belongs in shared setup metadata and validation, while Slack's mode-specific requirements remain in the Slack plugin rather than leaking provider policy into core.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The patch addresses a broken headless channel-provisioning path that affects real operator setup workflows.
  • merge-risk: 🚨 compatibility: Bundled and installed channel plugins consume the new additive setup metadata during non-interactive provisioning.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports built-CLI and focused regression evidence.

Evidence

Acceptance criteria:

  • [P1] Run exact merge-result channel setup tests.
  • [P1] Run plugin SDK API-baseline validation.
  • [P1] Run documentation validation for headless channel provisioning.

What I checked:

  • Current main remains affected: Current main has neither the non-interactive wizard guard nor generic optional environment validation, so the central failure mode remains unresolved outside this PR. (src/commands/channels/add.ts:156, bea0e398fa07)
  • Headless failure is repaired before mutation: The branch emits actionable TTY remediation before loading the wizard, and prepares/validates the channel setup before the later config-write path. (src/commands/channels/add.ts:156, a3318171d6a2)
  • Shared validation has the right owner boundary: The generic channel layer reads optional boolean-field environment metadata and checks any/all requirements; plugins retain their own semantic validation. (src/channels/plugins/account-config-mutation.ts:33, a3318171d6a2)
  • Conditional Slack policy remains plugin-owned: Slack keeps socket-mode app-token and HTTP signing-secret conditions in its setup validation while the portable declaration requires only the unconditional bot token. (extensions/slack/src/setup-core.ts:189, a3318171d6a2)
  • External plugin metadata is preserved: Installed package manifests normalize the optional envVars and envVarMode fields, with coverage for installed external-plugin metadata. (src/plugins/manifest-registry-installed.ts:356, a3318171d6a2)
  • Nostr uses one config-or-environment resolver: The resolver prefers configured secrets and falls back to NOSTR_PRIVATE_KEY only when configuration is absent; runtime account resolution and setup status use that same path. (extensions/nostr/src/private-key.ts:7, a3318171d6a2)

Likely related people:

  • Amp: Current shared account-mutation and Nostr-resolution lines are attributed to this recent area commit; the wider ownership trail is limited. (role: recent area contributor; confidence: medium; commits: 41732aaccdd4; files: src/channels/plugins/account-config-mutation.ts, extensions/nostr/src/types.ts)

Rank-up moves

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

  • Complete exact merge-result checks covering channel setup, SDK baselines, and docs.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-12T08:05:44.896Z sha ccaa508 :: found issues before merge. :: [P1] Preserve Slack HTTP credential mode under --use-env
  • reviewed 2026-08-12T09:07:02.724Z sha 858921c :: needs changes before merge. :: [P1] Preserve Slack HTTP credential mode under --use-env
  • reviewed 2026-08-12T14:25:30.325Z sha 33249a1 :: needs changes before merge. :: [P1] Preserve Slack HTTP and relay modes under --use-env
  • reviewed 2026-08-12T16:12:26.046Z sha d60df60 :: needs changes before merge. :: [P1] Synchronize Slack's manifest env contract
  • reviewed 2026-08-12T17:02:37.461Z sha 6602a7e :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/channels-add-headless branch from ccaa508 to 858921c Compare August 12, 2026 08:38
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 12, 2026
@steipete
steipete force-pushed the steipete/channels-add-headless branch 2 times, most recently from 61a6c4f to 33249a1 Compare August 12, 2026 14:18
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed docker Docker and sandbox tooling size: L labels Aug 12, 2026
@steipete
steipete force-pushed the steipete/channels-add-headless branch from 18392b4 to 6602a7e Compare August 12, 2026 16:56
@openclaw-barnacle openclaw-barnacle Bot added docker Docker and sandbox tooling size: L and removed size: M labels Aug 12, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@steipete
steipete force-pushed the steipete/channels-add-headless branch from 6602a7e to a331817 Compare August 12, 2026 17:03
@steipete
steipete merged commit 99d6624 into main Aug 12, 2026
120 checks passed
@steipete
steipete deleted the steipete/channels-add-headless branch August 12, 2026 17:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
…env contracts (openclaw#122530)

* fix(channels): validate headless channel setup

* docs(channels): document headless provisioning

* fix(channels): repair setup metadata typing

* chore(channels): regenerate official channel catalog for env metadata

* fix(slack): keep mode-conditional env contract plugin-owned

Static --use-env declaration keeps only the unconditional SLACK_BOT_TOKEN;
socket-vs-HTTP conditional requirements (app token, signing secret) stay in
Slack's own setup validation so HTTP mode no longer demands an irrelevant
SLACK_APP_TOKEN.

* chore(sdk): regenerate api baselines and catalog after rebase

* fix(slack): align manifest env declaration with runtime contract

* chore(sdk): regenerate api baselines after rebase

* chore(sdk): regenerate api baselines after rebase

* chore(sdk): regenerate api baselines after rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: buzz channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: irc channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: slack Channel integration: slack channel: synology-chat channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: clickclack maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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