Skip to content

fix(plugins): native commands execute the selected plugin - #121544

Merged
steipete merged 26 commits into
mainfrom
steipete/plugin-command-identity
Aug 11, 2026
Merged

steipete merged 26 commits into
mainfrom
steipete/plugin-command-identity

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a native command shown by Discord, Telegram, or Slack could execute a different plugin command than the one selected for that channel's command catalog. This could happen when normalized names or provider aliases collided, discovery order differed, channel scopes excluded one candidate, or the active plugin registry changed between catalog construction and invocation.

Why This Change Was Made

The command catalog now returns a closed decision: either an opaque dispatch capability bound to the selected plugin registration and registry generation, or an explicit non-plugin winner. Discord, Telegram, Slack, and core reply dispatch carry that decision through to execution instead of reconstructing command text and rematching a global registry.

The focused openclaw/plugin-sdk/plugin-command-runtime surface keeps plugin identity private while sharing candidate metadata and registry-bound execution. Channel plugins explicitly retain a finalized plugin-command catalog, and the Gateway records that fact at the exact account task that owns its handlers. Registry replacement therefore pre-stops and restarts only those accounts, leaves native-disabled siblings untouched, binds replacement starts to the newly active registry, and drains admitted command executions before cleanup. Existing shipped command APIs remain compatibility wrappers around the canonical runtime.

Maintainer contract decision: this focused subpath is accepted as the durable third-party channel-plugin interface. Opaque dispatch identity, exact registry-generation binding, explicit catalog retention, and retirement semantics are intentional compatibility guarantees; the generic reply pipeline carries only the closed ownership decision through a dependency-free leaf contract.

User Impact

Native commands now execute the same plugin owner that won menu and interaction planning. Built-in commands, skills, /login, provider aliases, and channel-scoped exclusions cannot accidentally fall through to a differently scoped plugin. Plugin reload preserves in-flight command ownership, restarts only accounts retaining registry-bound handlers, and cannot revive a retired generation through inherited request scope.

Evidence

  • Final landing head: d5dfd3744f55cfad3a198ece72323ed8b4b4708f.
  • Previous exact-head CI at 50ce9380411427318403525ef05b867651443db3 passed: https://github.com/openclaw/openclaw/actions/runs/31450631414. This is retained as historical proof and is not final-head CI.
  • Reviewed/green patch-identical head: 7bb22191d8abd6fed4c160963ee57451d65d1fc1.
  • Historical patch-identical run https://github.com/openclaw/openclaw/actions/runs/31449479959; this does not claim final-head CI.
  • Earlier patch-identical exact-head CI: https://github.com/openclaw/openclaw/actions/runs/31445705484
  • Broad selected-owner proof: 637 focused hosted tests passed across plugin runtime, core auto-reply, Gateway reload, Discord, Telegram, and Slack command paths.
  • Account-lifecycle proof: 396 focused tests passed, covering account-task ownership, stale predecessor cleanup, exact account pre-stop/restart and rollback, active-registry rebinding, and final catalog retention in Discord, Telegram, and Slack.
  • Final conflict-free replay: all 25 behavioral commits remained patch-identical across range-diff; only the generated Plugin SDK API baseline changed and was regenerated canonically.
  • Final focused replay: 443 focused tests passed, followed by an 11-test plugin-runtime sanity run; Plugin SDK API and surface checks and git diff --check passed.
  • The real memory-dreaming-sweep QA scenario passed after config reload; Telegram returned ready on the replacement registry instead of remaining in recovery with a retired-generation error.
  • Plugin SDK API and surface checks retain 152 public entrypoints, 4,856 public exports, and 2,919 callable exports. The public change is one method on the focused runtime, with no new entrypoint or export.
  • Import-cycle validation passed with zero runtime value cycles.
  • A private-QA full build passed, including all public Plugin SDK subpaths and Control UI performance limits.
  • Broad changed-gate proof passed on Blacksmith Testbox, including formatting, typecheck, lint, import cycles, SDK contracts, deadcode dependency/export checks, and repository guards.
  • Fresh Codex-backed autoreview reported no accepted/actionable findings. The latest durable ClawSweeper review also reported no findings; its rank-up request to tighten the description is addressed here.
  • Final delta against the landing base: production/tooling +1,408/-622 (net +786); tests and test support +1,675/-1,105 (net +570); docs +28; generated +105/-96 (net +9). The growth establishes the selected-owner public runtime and account-lifecycle boundary while deleting global rematching and whole-channel restart inference.
  • No credentialed live Telegram capture was available. The change does not alter Telegram transport protocols or Bot API payloads; collision, provider override, channel scope, registry retirement, reload, and visible ready-state behavior are covered through real registry, channel-lifecycle, and QA Gateway boundaries. This is recorded as a proof gap, not described as live-channel proof.

AI-assisted; the implementation, public SDK commitment, proof, and remaining gap were reviewed and understood before submission.

@clawsweeper

clawsweeper Bot commented Aug 10, 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 docs Improvements or additions to documentation channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram gateway Gateway runtime scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Aug 10, 2026
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 9:59 PM ET / August 11, 2026, 01:59 UTC.

ClawSweeper review

What this changes

The PR carries the plugin command selected for a native Discord, Telegram, or Slack menu through execution, avoiding a later global command-name rematch across plugin-registry reloads.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for explicit maintainer review: no concrete P0–P2 defect surfaced, but this is a protected maintainer PR that creates a durable Plugin SDK contract and changes reload lifecycle behavior.

Priority: P2
Reviewed head: 50ce9380411427318403525ef05b867651443db3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proposed owner boundary and reported QA evidence are strong, but final-head source and test inspection was blocked by unavailable promisor objects and DNS.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless reports a real QA Gateway reload scenario and focused channel/lifecycle coverage.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless reports a real QA Gateway reload scenario and focused channel/lifecycle coverage.
Evidence reviewed 5 items Current rematch mechanism: Current main resolves a command from the mutable plugin registry by normalized name and aliases, which can select a different registration after catalog construction.
Discord catalog/dispatch split: Current Discord command construction performs a plugin-name match while building its command definition, leaving execution vulnerable to a later registry lookup; the supplied patch retains the selected candidate instead.
Gateway lifecycle owner: Current channel startup reserves each account with an AbortController before asynchronous work; the proposed controller-bound catalog ownership follows that established lifecycle boundary.
Findings None None.
Security None None.

How this fits together

Channel plugins build native command menus from the active plugin registry, then pass inbound command turns into the shared reply pipeline. This change preserves the selected plugin owner through that handoff and coordinates registry replacement with channel-account restarts.

flowchart LR
  A[Plugin registry] --> B[Native command catalog]
  B --> C[Selected command decision]
  C --> D[Discord Telegram Slack handler]
  D --> E[Shared reply pipeline]
  E --> F[Selected plugin execution]
  A --> G[Registry reload]
  G --> H[Restart affected channel accounts]
  H --> B
Loading

Decision needed

Question Recommendation
Should OpenClaw accept registry-generation-bound native command dispatch and account-scoped restart behavior as a durable third-party Plugin SDK contract? Confirm the focused contract: Accept the documented opaque dispatch and retirement semantics, subject to exact-head CI completion.

Why: The PR intentionally expands a public SDK surface and defines upgrade-sensitive plugin lifecycle semantics; repository policy requires explicit maintainer ownership for that contract.

Before merge

  • Resolve merge risk (P1) - The PR adds a public Plugin SDK subpath whose registry-generation and retirement semantics become a third-party compatibility contract.
  • Resolve merge risk (P1) - Production/tooling grows by net 786 lines for a bug fix; the added opaque dispatch, execution-drain, and account-lifecycle ownership are only justified if maintainers accept that durable contract.
  • Resolve merge risk (P1) - The final PR objects could not be fetched locally, so final-head source-line and test validation remains unavailable to this review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production/tooling +1,408/-622 (net +786); tests/support +1,675/-1,105 (net +570) The sizeable bug-fix expansion establishes dispatch and reload ownership boundaries, so maintainers should explicitly assess its public-contract value.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/plugins/plugin-command-metadata.ts, unknown-truncated-pull-files, vector/embedding metadata: docs/plugins/sdk-channel-plugins.md, vector/embedding metadata: src/plugins/command-specs.ts, vector/embedding metadata: src/plugins/plugin-command-execution.ts, vector/embedding metadata: src/plugins/plugin-command-matcher.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A redacted Telegram Desktop capture of a colliding command before and after reload would directly demonstrate the user-visible selected-owner guarantee. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: reproduce a colliding native plugin command, reload the registry, and capture that the selected plugin still responds.

Merge-risk options

Maintainer options:

  1. Confirm and merge the contract (recommended)
    Accept the documented Plugin SDK lifecycle guarantee after the final-head checks complete.
  2. Pause for a narrower SDK shape
    Keep the selected-owner fix but avoid publishing lifecycle semantics until maintainers define the third-party compatibility commitment.

Technical review

Best possible solution:

Confirm the focused SDK contract, then merge only after exact-head CI and a final maintainer review confirm the selected-owner and account-reload semantics; no safe net-neutral replacement is established because the new owner boundary needs explicit dispatch and lifecycle state.

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

Yes from source, at medium confidence: current main constructs native catalogs then later resolves plugin commands through mutable normalized-name matching; final-head execution was not available locally.

Is this the best way to solve the issue?

Yes, provisionally: carrying the finalized catalog decision is cleaner than re-matching command text, but maintainers must accept the resulting public SDK lifecycle contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: The patch repairs native command ownership across major channels but has no established emergency user-impact signal.
  • merge-risk: 🚨 compatibility: A new public Plugin SDK subpath defines dispatch identity and registry-retirement behavior for bundled and third-party channel plugins.
  • merge-risk: 🚨 availability: Registry replacement now selectively stops and restarts channel accounts, so an incorrect lifecycle transition could affect channel availability.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless reports a real QA Gateway reload scenario and focused channel/lifecycle coverage.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The Telegram portion changes visibly selectable native-command ownership and can be demonstrated in a short Telegram Desktop flow.

Evidence

What I checked:

  • Current rematch mechanism: Current main resolves a command from the mutable plugin registry by normalized name and aliases, which can select a different registration after catalog construction. (src/plugins/commands.ts:55, 58a538767c4c)
  • Discord catalog/dispatch split: Current Discord command construction performs a plugin-name match while building its command definition, leaving execution vulnerable to a later registry lookup; the supplied patch retains the selected candidate instead. (extensions/discord/src/monitor/native-command.ts:108, 58a538767c4c)
  • Gateway lifecycle owner: Current channel startup reserves each account with an AbortController before asynchronous work; the proposed controller-bound catalog ownership follows that established lifecycle boundary. (src/gateway/server-channels.ts:581, 58a538767c4c)
  • History provenance: Blame attributes the current matcher and native command construction to the recent command/runtime refactor, providing the relevant ownership trail. (src/plugins/commands.ts:55, c39abcecdab7)
  • Final-head inspection limitation: The local partial clone lacks both the reviewed head and base objects; git attempted a promisor fetch, but DNS could not resolve github.com. Assessment therefore combines current-main source with the supplied patch and PR evidence.

Likely related people:

  • steipete: Current matcher and native-command lines blame to Peter Steinberger's recent command-runtime work, and the PR's lifecycle and SDK changes are in the same ownership area. (role: recent command-runtime and channel lifecycle contributor; confidence: high; commits: c39abcecdab7; files: src/plugins/commands.ts, extensions/discord/src/monitor/native-command.ts, src/gateway/server-channels.ts)

Rank-up moves

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

  • Complete exact-head CI and have a maintainer explicitly confirm the public SDK compatibility contract.

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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-10T13:55:52.090Z sha af0a5d5de39a447422cb6c2350b08c60fae67044 :: found issues before merge. :: [P2] Record native catalog registration per account
  • reviewed 2026-08-10T15:54:38.976Z sha e44bf49ebbb507165b74b0c29b615c10047504e5 :: found issues before merge. :: [P2] Track native catalog registrations per account
  • reviewed 2026-08-10T17:54:48.172Z sha eef8242aeaf013099f010eefb1b8d6a9ec1e6dc4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T18:52:43.611Z sha 89e312d3a8d7c6d62ce51c0b7208906348051c4e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T20:01:34.237Z sha 33ea76387d4d765f7bff497186434a18f564c4a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T21:56:43.812Z sha 02c1730 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T23:09:07.035Z sha 63188210ab369934a988c69c99094183e0224963 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T00:02:26.884Z sha 8386da278833ac4e33461d11431d9f16d795c704 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/plugin-command-identity branch from bc45769 to ac23392 Compare August 10, 2026 09:46
@steipete
steipete marked this pull request as ready for review August 10, 2026 09:51
@steipete
steipete force-pushed the steipete/plugin-command-identity branch from c25cffd to cc21801 Compare August 10, 2026 10:11
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Maintainer decision recorded in the PR body: approve openclaw/plugin-sdk/plugin-command-runtime as the durable focused channel-plugin contract. Opaque selected-command identity, exact registry-generation binding, and registry-retirement semantics are intentional compatibility guarantees.

The exact head is cc218018684641032083fe2975372b05e75eec74. The prior architecture failure was repaired by moving the generic reply-option carrier to a dependency-free leaf contract and removing the direct registry projection type cycle. pnpm check:architecture, core tsgo, Plugin SDK API checks, 71 focused plugin/auto-reply tests, and fresh branch-wide autoreview are green.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@steipete
steipete force-pushed the steipete/plugin-command-identity branch 2 times, most recently from 0b28cc0 to d14b293 Compare August 10, 2026 11:43
@steipete
steipete force-pushed the steipete/plugin-command-identity branch from 50ce938 to d5dfd37 Compare August 11, 2026 02:13
@steipete
steipete merged commit d6f70a9 into main Aug 11, 2026
132 checks passed
@steipete
steipete deleted the steipete/plugin-command-identity branch August 11, 2026 02:30
@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 11, 2026
…21544)

* fix(plugins): preserve selected command identity

* test(telegram): use scoped command registries

* test(telegram): isolate command runtime fixtures

* test(telegram): warm native command runtime

* refactor(plugins): keep command metadata private

* fix(plugins): accept synchronous command handlers

* fix(plugins): scope command drain bypass to live execution

* test(telegram): use scoped command registry fixtures

* test(telegram): isolate native menu runtime fixtures

* test(telegram): isolate login session store

* test(telegram): surface login flow failures

* test(telegram): preload native login module

* test(telegram): scope native command registries

* fix(plugins): complete command dispatch contracts

* fix(plugins): break command dispatch import cycles

* fix(plugins): stabilize command dispatch contracts

* fix(channels): keep plugin dispatch options internal

* fix(plugins): keep command dispatch carrier opaque

* test(channels): align delivery adapter fixtures

* test(delivery): align custody ownership coverage

* test(delivery): align latest queue reconciliation

* test(channels): drop obsolete delivery wrappers

* fix(plugins): rebind channel reload starts

* fix(plugins): scope command catalog reloads

* fix(ci): align current runtime contracts

* chore(plugin-sdk): refresh API baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL 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