Skip to content

fix(cli): honor channel resolve agent ownership - #125109

Merged
steipete merged 3 commits into
mainfrom
steipete/inspiring-chebyshev-701054
Aug 17, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/inspiring-chebyshev-701054

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators resolving channel targets for an explicit agent could receive AGENT_SELECTION_REQUIRED in multi-agent configurations before any Gateway call. The channels resolve parser did not declare or forward --agent, and command-time secret preflight could therefore try to select a default owner for unclaimed sandbox SSH defaults before channel/plugin selection ran.

Why This Change Was Made

The CLI now declares --agent on both the channels parent and the resolve leaf, inherits the parent value only when the leaf did not provide one, and carries that explicit owner through the existing command config/secret collection boundary. The same owner reaches plugin workspace resolution and message-channel selection, so ownership is recorded at the producers that need it; the Gateway protocol is intentionally unchanged.

This is the best-fix owner boundary because it preserves one canonical resolution flow and passes the already-known optional owner through it. A downstream catch for AGENT_SELECTION_REQUIRED would leave command-time secret classification and later workspace/channel selection disagreeing about ownership.

Production LOC: +53/-10 (net +43). Tests: +101/-4. Docs: +5/-2. The production growth is direct optional owner passthrough across the existing CLI, secret-collection, workspace, and channel-selection boundaries.

User Impact

Operators can use either channels --agent <id> resolve ... or channels resolve --agent <id> ... in multi-agent setups. Explicit agent ownership now consistently controls command-time secret collection, plugin workspace lookup, and channel selection instead of failing early while trying to infer a default agent.

Evidence

  • Pre-fix regression: the new command-secret case failed 1/38 with AgentSelectionRequiredError through collectAgentSandboxAssignments / classifyConfiguredTargetRefs before any Gateway call. The same case passes after the fix.
  • node scripts/run-vitest.mjs src/cli/channels-cli.test.ts src/cli/command-config-resolution.test.ts src/cli/command-secret-gateway.test.ts src/commands/channel-setup/channel-plugin-resolution.test.ts src/commands/channels.resolve.test.ts — 87/87 passed.
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo — passed.
  • node scripts/run-tsgo-core-test-shards.mjs — passed.
  • Typed node scripts/run-oxlint.mjs over all 13 touched files — passed.
  • node_modules/.bin/oxfmt over all 13 touched files — clean; git diff --check — passed.
  • node scripts/check-changed.mjs --dry-run -- <13 touched paths> — classified the change as core / coreTests.
  • Fresh autoreview — clean, with no accepted/actionable P0 findings.
  • Black-box real CLI parser proof: channels --agent ops resolve room --help and channels resolve --agent ops room --help were both accepted; --agentx was rejected.
  • Test-audit: the changed tests independently cover parent/leaf parsing, explicit-agent secret preflight, and agent-scoped plugin workspace/channel selection; no test-only production seam was added.
  • Exact-head CI run 32001282879 exposed one attributable assertion-safety ratchet failure (src/cli/channels-cli.ts: 8 > 7). The fix replaced the new Commander cast with runtime string narrowing; focused tests remained 87/87, max-lines and assertion-safety ratchets passed, typed lint passed, and a fresh autoreview of the repair was clean.
  • ClawSweeper's --agent documentation move was applied in the Channels reference, including both parent and leaf placements. pnpm docs:list, pnpm docs:check-mdx (774 files), pnpm docs:check-links (6,498 internal links, zero broken), targeted formatting, git diff --check, and fresh autoreview all passed.

Proof gap: no live channel API credentials were needed or used. The failure is deterministic parser/owner propagation before a channel API call, and the focused regression exercises the real command secret collector that previously raised the error.

AI-assisted: yes; understood and independently reviewed.

Forward explicit channel owners through command-time secret collection and later workspace/channel resolution, preventing AGENT_SELECTION_REQUIRED in multi-agent configurations.
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: S labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 06:20
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 17, 2026
@steipete
steipete requested a review from a team as a code owner August 17, 2026 06:20
Use runtime string narrowing for the Commander option so agent-owner forwarding remains assertion-free and satisfies the assertion-safety ratchet.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 2:46 AM ET / 06:46 UTC.

ClawSweeper review

What this changes

The PR lets operators pass --agent before or after channels resolve and uses that agent for command-secret, workspace plugin, and channel-selection resolution.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer handling: current main still lacks the explicit owner path, while the PR cleanly carries that owner through the affected boundaries and resolves the prior documentation finding.

Priority: P2
Reviewed head: d0f0d3fb568d9fc2cebbaecff3e1345d527ba823

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-scoped repair with source-backed owner-boundary coverage and no blocking review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR supplies focused before/after command-path evidence; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR supplies focused before/after command-path evidence; the external-contributor proof gate does not apply.
Evidence reviewed 8 items Current-main gap: Current main registers channels resolve without an agent option and invokes the command without an agent value, so parent or leaf owner selection cannot reach resolution.
Owner propagation: The PR head declares the option on both parent and leaf, uses the shared parent-inheritance helper, and passes the result into the resolver.
Producer-boundary repair: The resolver forwards the explicit owner to secret preflight, workspace-scoped plugin resolution, and message-channel selection instead of catching a downstream selection error.
Findings None None.
Security None None.

How this fits together

The Channels CLI parses an operator command, prepares only relevant secrets, selects a plugin/workspace, then resolves provider target names. The chosen agent must remain consistent across those steps in multi-agent setups.

flowchart LR
  A[Operator command] --> B[Channels CLI parser]
  B --> C[Explicit agent owner]
  C --> D[Secret preflight]
  C --> E[Workspace plugin lookup]
  C --> F[Channel selection]
  D --> G[Target resolution]
  E --> G
  F --> G
Loading

Before merge

  • Complete next step (P2) - No repair is needed; this protected maintainer PR should continue through normal exact-head CI and maintainer review.
Agent review details

Security

None.

PR surface

Source +43, Tests +97, Docs +3. Total +143 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 53 10 +43
Tests 5 101 4 +97
Docs 1 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 159 16 +143

Review metrics

Metric Value Why it matters
Production vs test LOC production +53/-10; tests +101/-4; docs +5/-2 The production growth carries one optional CLI owner across existing resolution boundaries; regression tests cover each boundary.

Technical review

Best possible solution:

Land this as the single canonical explicit-owner path after the exact-head checks complete, preserving existing default-agent behavior when --agent is absent.

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

Yes, source-reproducible: current main has no parser-to-resolver agent path, and the supplied regression covers the prior secret-preflight selection failure.

Is this the best way to solve the issue?

Yes: propagating the already explicit owner through the producer boundaries is cleaner than handling AGENT_SELECTION_REQUIRED after secret or plugin resolution.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This fixes a bounded multi-agent CLI workflow that otherwise fails before channel target resolution.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR supplies focused before/after command-path evidence; the external-contributor proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame for the parser and resolver lines points to Peter Steinberger, who also authored the focused repair. (role: recent CLI and channel-resolution contributor; confidence: high; commits: 21a38851fbda; files: src/cli/channels-cli.ts, src/commands/channels/resolve.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-17T06:36:05.796Z sha c757001 :: found issues before merge. :: [P3] Document the new channels resolve --agent option

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 17, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof

Head: d0f0d3fb568d9fc2cebbaecff3e1345d527ba823

The repair keeps one explicit agent owner from CLI parsing through command-time secret classification, workspace-scoped plugin lookup, and message-channel selection. Gateway protocol behavior is unchanged.

Proof:

  • Pre-fix: the focused command-secret regression failed 1/38 with AgentSelectionRequiredError through collectAgentSandboxAssignments / classifyConfiguredTargetRefs before any Gateway call. It passes after the owner propagation repair.
  • node scripts/run-vitest.mjs src/cli/channels-cli.test.ts src/cli/command-config-resolution.test.ts src/cli/command-secret-gateway.test.ts src/commands/channel-setup/channel-plugin-resolution.test.ts src/commands/channels.resolve.test.ts — 87/87 passed.
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo — passed.
  • node scripts/run-tsgo-core-test-shards.mjs — passed.
  • Typed node scripts/run-oxlint.mjs over all touched code files — passed; node_modules/.bin/oxfmt and git diff --check — clean.
  • node --import tsx scripts/check-max-lines-ratchet.mts --base refs/remotes/origin/main — 904 grandfathered suppressions, passed.
  • node --import tsx scripts/check-assertion-safety-ratchet.mts --base refs/remotes/origin/main — 4,324 files / 13,753 grandfathered assertions, passed.
  • node scripts/check-changed.mjs --dry-run -- <touched paths> — core / coreTests.
  • pnpm docs:list, pnpm docs:check-mdx (774 files), pnpm docs:check-links (6,498 internal links, zero broken), targeted docs formatting, and git diff --check — passed.
  • Fresh autoreview after the CI repair and again after the docs move — clean, no accepted/actionable findings.
  • Black-box real CLI parser: channels --agent ops resolve room --help and channels resolve --agent ops room --help were accepted; --agentx was rejected.
  • Exact-head required CI: run 32002554829 — GREEN. Dependency Guard run 32002551929 initially hit a bare GitHub HTTP 500 and passed on a failed-only rerun; no dependency finding was reported.

ClawSweeper moves: applied the Channels-reference --agent entry with parent and leaf examples; exact-head CI is complete. The latest exact-head review has no findings, and there are no review conversations to resolve. No moves were skipped.

Production LOC: +53/-10 (net +43). Tests: +101/-4. Docs: +5/-2. The positive production delta is direct optional owner passthrough across existing ownership boundaries.

Proof gap: no live channel API credentials were needed or used. The failure occurs deterministically in parser/owner propagation before a channel API call, and the focused regression exercises the real command secret collector that previously raised the error.

@steipete
steipete merged commit 83d279a into main Aug 17, 2026
222 of 224 checks passed
@steipete
steipete deleted the steipete/inspiring-chebyshev-701054 branch August 17, 2026 06:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
* fix(cli): honor channel resolve agent ownership

Forward explicit channel owners through command-time secret collection and later workspace/channel resolution, preventing AGENT_SELECTION_REQUIRED in multi-agent configurations.

* fix(cli): narrow explicit agent option value

Use runtime string narrowing for the Commander option so agent-owner forwarding remains assertion-free and satisfies the assertion-safety ratchet.

* docs(cli): document channel resolve agent owner
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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