Skip to content

refactor(commands): share native plugin command merging - #120972

Merged
steipete merged 1 commit into
mainfrom
steipete/native-command-spec-merge
Aug 9, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/native-command-spec-merge

Conversation

@steipete

@steipete steipete commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord and Slack each carried their own native/plugin command merge policy. The duplicate implementations had already drifted: Discord appended /vc after collision and cap planning, while Slack used a separate normalization/deduplication loop. That made it easy for sibling channels to disagree about primary precedence, blank names, normalized duplicates, and collision diagnostics.

Why This Change Was Made

This refactor introduces one narrow mergeNativeCommandSpecs owner on the existing native-command-registry Plugin SDK subpath. The helper performs stable trimmed/lowercase deduplication: primary entries win, blank or duplicate primary entries are ignored, secondary entries append in source order, and only rejected secondary entries invoke the optional collision callback.

Discord now includes its canonical /vc descriptor in the primary catalog before plugin collision checks, the 100-command cap, and diagnostics. The interaction layer replaces that planned descriptor with the specialized voice handler in place instead of appending a second command after planning. Slack adopts the same merger while retaining its existing silent collision behavior, command registration, dispatch, and deferred reply handling.

The public seam is accepted deliberately. Bundled Discord and Slack plugins cannot import core internals, and the pure catalog policy is shared behavior rather than channel-specific runtime state. The change adds one public function on an existing SDK subpath; it adds no subpath, execution handle, plugin identity, winner metadata, configuration, or migration surface.

Task #27's selected plugin execution identity/rematching seam remains explicitly out of scope.

User Impact

Native plugin commands now use the same primary-first merge semantics across Discord and Slack. Discord /vc participates in the authoritative catalog limit and collision plan, so the registered interaction set cannot silently exceed or disagree with the catalog that was validated. Existing Slack behavior remains unchanged apart from using the shared policy owner.

No operator action, configuration change, migration, or new default is required.

Evidence

  • Current exact head: d8a06d4f0a7b1a1d9b0f6c5e22a6fde440c56375 on current base 87ba8ef82b4d4db450f4ee967b6d72fba37ae048.
  • Current-main refresh preserved one commit. The latest rebase overlapped only docs/.generated/plugin-sdk-api-baseline.sha256; it was regenerated with pnpm plugin-sdk:api:gen rather than hand-merged.
  • Current exact-head SDK checks passed:
    • pnpm plugin-sdk:api:check
    • pnpm plugin-sdk:surface:check
    • 151 public entrypoints, 4,849 public exports, 2,921 public callable exports.
  • Focused post-refresh tests passed:
    • command registry: 39/39;
    • Discord command/interaction/provider/voice: 59/59;
    • Slack slash commands: 58/58.
  • Blacksmith Testbox tbx_01kzm3n9nt8pfrks99mxv8ptg1, run https://github.com/openclaw/openclaw/actions/runs/31334541340, passed the focused suites, Plugin SDK API/export/surface checks, and pnpm build.
  • The final changed-surface gate stopped only at the unchanged current-main ui/package.json noVNC range pin. This branch has no UI or dependency delta.
  • Targeted formatting and git diff --check passed.
  • Fresh review found no accepted/actionable issue.
  • Production runtime is +128/-93 (net +35), justified by the shared Plugin SDK ownership boundary and authoritative Discord planning flow. Total patch is +610/-106 across 14 files, including tests, tooling, and generated digest updates.
  • One exact-head ClawSweeper re-review was requested after the force-push: refactor(commands): share native plugin command merging #120972 (comment)

No live Discord/Slack roundtrip was run; focused transport-owner tests, build proof, and hosted exact-head CI cover the changed registration surfaces. No changelog edit is included because changelog generation is release-owned.

@clawsweeper

clawsweeper Bot commented Aug 9, 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 scripts Repository scripts labels Aug 9, 2026
@steipete
steipete marked this pull request as ready for review August 9, 2026 07:08
@clawsweeper

clawsweeper Bot commented Aug 9, 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 the maintainer Maintainer-authored PR label Aug 9, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 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 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 5:48 PM ET / 21:48 UTC.

ClawSweeper review

What this changes

This PR centralizes native plugin-command merging for Discord and Slack and makes Discord’s voice command part of the validated command catalog.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for explicit maintainer acceptance of the new public Plugin SDK contract. The refactor removes duplicated Discord/Slack merge policy at the appropriate shared seam and fixes Discord voice-command planning; no blocking correctness or security defect was found.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and focused coverage are solid, with the remaining blocker being deliberate acceptance of an additive public SDK contract.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR; focused exact-head channel and SDK checks are supplemental validation, not contributor proof gating.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR; focused exact-head channel and SDK checks are supplemental validation, not contributor proof gating.
Evidence reviewed 7 items Current-main behavior: Current main keeps Discord plugin-command merging in the channel resolver, where it runs separately from voice-command construction; the proposed shared owner removes that duplicate policy.
Proposed owner boundary: The branch exposes one generic merger through the existing native-command registry SDK subpath and both Discord and Slack consume it.
Discord catalog proof: The branch inserts the canonical voice descriptor before plugin collision handling and cap planning, then replaces only that descriptor with the specialized handler.
Findings None None.
Security None None.

How this fits together

Core command definitions are converted into channel-native command catalogs, then Discord and Slack register those catalogs with their transports. The shared merger decides which built-in or plugin command wins before either channel exposes commands to users.

flowchart LR
  A[Core command definitions] --> B[Native command catalog]
  B --> C[Shared merge policy]
  C --> D[Discord command deployment]
  C --> E[Slack slash registration]
  D --> F[Channel users]
  E --> F[Channel users]
Loading

Decision needed

Question Recommendation
Should mergeNativeCommandSpecs become a supported public Plugin SDK function for channel plugins? Accept the shared SDK contract: Approve the additive helper as the canonical policy owner for bundled and third-party channel plugins.

Why: The implementation is additive and appropriate for two bundled plugins, but exporting it makes its merge semantics a third-party compatibility commitment.

Before merge

  • Resolve merge risk (P1) - Merging creates one additional supported third-party Plugin SDK callable export, so its primary-precedence and collision semantics become a compatibility contract.
  • Resolve merge risk (P1) - GitHub reports the branch as behind current main; refresh the merge result and exact-head gates before landing, although the supplied state is cleanly mergeable.
  • Complete next step (P2) - A maintainer must accept the additive public SDK contract and refresh the current-main merge validation; there is no narrow mechanical repair to dispatch.
Agent review details

Security

None.

PR surface

Source +40, Tests +462, Generated 0, Other +2. Total +504 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 134 94 +40
Tests 4 466 4 +462
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 6 6 0
Other 1 4 2 +2
Total 14 610 106 +504

Review metrics

Metric Value Why it matters
Plugin SDK surface 1 public callable export added The new merger becomes a compatibility commitment for external plugins.
Production versus tests production +128/-93; tests +466/-4 The positive production delta is tied to the shared SDK ownership boundary and Discord’s authoritative catalog planning.

Merge-risk options

Maintainer options:

  1. Confirm the SDK contract (recommended)
    Accept the additive public helper and its primary-first collision behavior as a maintained Plugin SDK promise.
  2. Redesign before exporting
    Pause this refactor if the repository should not support external plugins depending on this merge policy.

Technical review

Best possible solution:

Accept the generic SDK merger as the canonical cross-plugin policy, retain the focused regression coverage, and land only after the current-main merge result is validated.

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

Yes—current-main source shows Discord plans plugin commands before the interaction layer appends the voice command, so the planned catalog can differ from the deployed command set; the branch adds focused coverage for that path.

Is this the best way to solve the issue?

Yes—the shared SDK helper is the best fix because both bundled plugins need identical policy and cannot import core internals; the remaining question is whether to make that generic helper public.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The PR changes normal Discord and Slack native-command registration without evidence of an active outage.
  • merge-risk: 🚨 compatibility: An additive public Plugin SDK function establishes merge and collision semantics that third-party plugins may adopt.
  • 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 is a maintainer-authored PR; focused exact-head channel and SDK checks are supplemental validation, not contributor proof gating.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame ties the Discord resolver, Slack registration path, and native-command SDK facade to this recent command-area commit. (role: recent command-catalog contributor; confidence: high; commits: 34b8a6515d78; files: extensions/discord/src/monitor/provider.commands.ts, extensions/slack/src/monitor/slash.ts, src/plugin-sdk/native-command-registry.ts)

Rank-up moves

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

  • Obtain explicit maintainer confirmation for the public Plugin SDK contract.
  • Refresh the merge result and exact-head gates against current main before landing.

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 (2 earlier review cycles)
  • reviewed 2026-08-09T08:46:27.266Z sha 0be272e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-09T08:53:44.606Z sha 0be272e :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/native-command-spec-merge branch from 0be272e to d8a06d4 Compare August 9, 2026 21:12
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current-main refresh is complete at exact head d8a06d4f0a7b1a1d9b0f6c5e22a6fde440c56375. Runtime behavior remains equivalent to the previously reviewed patch; the refresh regenerated the current Plugin SDK digest, moved the accepted +1 public/+1 callable budget to the renamed .mts surface script, and adapted Slack fixtures to current main. Please review this exact head.

@clawsweeper

clawsweeper Bot commented Aug 9, 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:

@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready verification is complete for exact head d8a06d4f0a7b1a1d9b0f6c5e22a6fde440c56375.

Known proof gap: no live Discord or Slack roundtrip was run. Focused transport-owner tests, build proof, and exact-head hosted CI cover the changed registration surfaces.

@steipete
steipete merged commit 6ee409c into main Aug 9, 2026
127 checks passed
@steipete
steipete deleted the steipete/native-command-spec-merge branch August 9, 2026 21:57
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 docs Improvements or additions to documentation maintainer Maintainer-authored PR 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. 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