Skip to content

refactor: await bundled skill command discovery - #169089

Merged
steipete merged 11 commits into
mainfrom
dbasync/sdkasync-skills
Oct 11, 2026
Merged

steipete merged 11 commits into
mainfrom
dbasync/sdkasync-skills

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bundled channel command registration still uses synchronous skill discovery, forcing managed skill-library SQLite reads onto the Gateway main thread.

User Impact

Discord, Slack, Mattermost, and Telegram await skill command discovery through the existing worker-backed preparation owner. Released synchronous Plugin SDK methods remain supported and deprecated; plugin authors should await the documented preparation methods.

Why This Change Was Made

Export the existing prepareSkillCommandsForAgents and prepareSkillCommandsForWorkspace through the narrow skill SDK entrypoints, then migrate all bundled native command registration/dispatch callers in the same change. Telegram bot construction awaits registration completion. There is one selection owner and no new database, cache, worker protocol, or sync fallback.

The released listSkillCommandsForAgents / listSkillCommandsForWorkspace contracts retain their immediate array result during the deprecation window and emit a bounded migration warning. Three public callable export instances are replacement pairs (two entrypoints), not new capabilities. The approved global allowances increase by exactly three exports, three callables, and three deprecated slots (3,669/2,130/158 → 3,672/2,133/161), matching those replacement pairs; per-entrypoint allowances identify the retained contracts. No spare budget margin or new capability is added. The mock baseline change is a canonical one-entry shrink after documenting the existing Mattermost isolation.

Evidence

Both implementation and the follow-up static metadata repair received clean independent Codex reviews (two rounds total). Formatting and diff checks pass. All bundled references to the old native discovery calls have been migrated; external compatibility exports remain.

Final head c0aeabb8a57246fe0e0b1f66d2bc6ab0530d1e74 integrates main through b1f3eac43cf663c3daf3c170f4587d104f2f2bbe. Earlier integrations inherited the landed UI Knip cleanup and combined independent SDK allowances. The final integration only conflicted in generated worker inventory, which was regenerated canonically; the automatic Discord fixture merge preserves the async discovery expectations and main's test cleanup. The skills owner/caller delta is unchanged by integration. The Telegram lazy loader remains byte-identical to main. An attempted explicit export projection was removed after proving the Knip findings already exist on the baseline. The measurements at 235180427416df7cc4d4a6fc6d7dd05a9e3b5126 remain source-equivalent for the changed skill owner.

Remote full pnpm build passed (4m30s). The focused selection covering every changed/mock-dependent suite passed: 50 files across 13 Vitest shards, 1,572 seconds total. The SDK surface check passed (6s), as did the SDK API comparison (332s): no entrypoints added or removed, and exactly three async export instances added (command-auth-native.prepareSkillCommandsForAgents, plus both preparation functions in skill-commands-runtime). Integrated candidate and baseline builds also passed (68s and 66s), plus 81 Telegram tests (131s), type-aware core/Telegram lint, export-collision checks, Madge, worker inventory, and T1/dialect ratchets. Discord, Mattermost, Slack, and Telegram cold-entrypoint profiles passed. On the final merged head, all 30 Discord provider tests passed (40s), SDK surface (6s) and runtime API guardrails (25s) passed, core/extension type-aware lint passed (18s/140s), export collisions passed (32s), Madge passed (19s), and worker inventory/T1/dialect ratchets passed. Full-tree Knip reports exactly the seven independently proven baseline findings listed below; production and script scans report zero. The shared harness ran three valid alternating pairs (M,C,M,C,M,C) on baseline 23ad242958a4dd4601660e3933dc6e663c89c7a1 versus measured candidate 235180427416df7cc4d4a6fc6d7dd05a9e3b5126. The later conflict-only integrations preserve the measured skill-owner behavior. Values are median [min–max]:

Metric Baseline Candidate
Warmed all-thread statements/turn 335.9 [335.1–337.0] 335.8 [334.9–336.9]
Warmed requests/turn 89.3 [89.0–89.3] 88.9 [88.7–89.3]
Warmed MAIN statements/turn 0 0
Whole-workload statements 9,833 [9,793–9,847] 9,814 [9,790–9,820]
Whole-workload requests 1,730 [1,719–1,731] 1,716 [1,712–1,727]
Whole-workload MAIN statements 2,054 2,054

Warmed duration ratio is 1.0048; pre-run CPU idle was at least 99.875%. All six runs passed calibration, 13 turns, child completion, cron, compaction, shutdown, and cleanup. These measurements are neutral within the turn noise floor; no query reduction is claimed.

The subsystem operation counts are identical in all six runs: first-turn skillLibrary.read is 2 requests / 4 statements and skills.workshop.changes.list is 1 request / 1 statement; neither appears in the warmed window. First-turn median falls from 1,201 statements / 192 requests to 1,009 / 184. Connect increases from 898 / 50 to 1,067 / 53 because deferred lifecycle work moves between adjacent windows; connect+first statements fall from 2,099 to 2,080 (boot+connect+first: 4,132 to 4,113). Boot (2,033 / 66), control (13 / 3), cron (552 / 125), compaction (180 / 33), and shutdown (102 / 14) are unchanged; the second turn falls from 1,495 / 353 to 1,485 / 349. Moving reads to a worker is not claimed as a query saving. The measured T1 inventory is 616 → 616 overall; after integrating current main it is 612 → 612 (b1f3eac → final head), with 1 → 1 in src/skills/library in both comparisons: the released synchronous host tool-surface API still requires selection-read.kernel.ts. Bundled native command discovery stops using that synchronous path; complete lexical removal is a separate host tool-surface SDK cutover. No authority or bookkeeping check was removed in this slice.

At the measured head, QA passes and the sole required CI failure is the unrelated UI test Control UI chat panel layout > preserves live content and saved geometry across main, dock, focus, and narrow layouts: a 30-second wait for the terminal canvas to become visible at ui/src/e2e/chat-panel-layout.e2e.test.ts:379. The identical test/line/hidden-canvas timeout occurs on scheduled main run 38147604740 at 6233a19ea75bbcd079ec4dbe4660bfef9b9321ed. This PR changes no UI source. Required CI passed on integrated head 657462bcb70609282190a828f818262c984fcb67 (CI run 38152681341); the final source-only removal of the ineffective lazy-loader projection reuses that passing CI under the campaign's relaxed landing policy, with final-head focused tests and static gates independently rerun. Final-head CI is not claimed as passing.

Earlier CI at 020681ac7a6d14373a79e6c5496d53741b3d0607 had two inherited QA failures: subagent-empty-completion-recovery (profile 2/4) and subagent-completion-direct-fallback (profile 4/4), both timing out after 180 seconds waiting for config restart readiness. The same scenarios fail with the same timeout on scheduled main run 38143525086 at 96a5e338a79d0c0f8c809f23b43b29eb6072efd5 (jobs 114482207562 and 114482207612). Their owners are outside this PR. These earlier failures are retained as history, not reported as passing.

Knip inherited findings are proven on the exact baseline 23ad242958a4dd4601660e3933dc6e663c89c7a1: the same six exports in extensions/telegram/src/bot-native-commands.runtime.ts (ensureConfiguredBindingRouteReady, getAgentScopedMediaLocalRoots, getSessionEntryAsync, recordDeliveredCommandExchange, resolveChunkMode, resolveStorePath) and loadSubagentMaintenanceCandidatesInDatabase in src/agents/subagents/registry/subagent-registry.store.sqlite.ts. Production and script scans report zero. Their source/consumer graph is unchanged by this PR; no ignore or baseline suppression was added.

No schema, migration, update, or service lifecycle policy change. Release-note context: third-party plugins should await the skill command preparation APIs; synchronous command list helpers are deprecated until the next Plugin SDK major.

LOC: 40 files, +225/−138, including bundled caller and test-fixture migration and wrapper manifest registration.

Expose async skill-command preparation through the existing SDK entries and migrate bundled Discord, Mattermost, Slack, and Telegram callers. Retain deprecated synchronous SDK methods through the next Plugin SDK major with bounded warnings.
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram scripts Repository scripts size: M labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR makes bundled channel skill-command discovery asynchronous while retaining deprecated synchronous Plugin SDK methods.

Example: Telegram prepares the native skill menu for agent main.

  • Before: Skill discovery returns synchronously and can read managed-library SQLite on the Gateway thread.
  • After: Bot construction awaits shared asynchronous preparation before registering command handlers.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The useful migration retains a channel-startup regression; required Telegram behavior evidence is also absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Synchronous managed-library discovery can stall the Gateway during channel command registration.
Reason: The supplied maintainer-authored direction follows worker-thread database policy, reuses existing preparation, and preserves released SDK contracts.

Regression provenance

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

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this PR open: the worker-backed migration is useful, but the previously reported remote-workspace startup regression remains.

Priority: P1
Reviewed head: 235180427416df7cc4d4a6fc6d7dd05a9e3b5126

Before merge

  • Preserve native-menu isolation from remote workspace failures (P1) - This earlier finding remains: with native skills enabled and agent main bound to a remote workspace whose loadSkills rejects, prepareSkillCommandsForAgents enables remote discovery and propagates rejection before Telegram registers handlers, causing createTelegramBotCore to fail. A stopped binding throws even earlier during workspace resolution. Discord and native Slack propagate the same failure; Mattermost discards otherwise available Gateway skill commands. The previous synchronous path deliberately used Gateway-only discovery, and the existing remote-skill-menu fixture protects that behavior. Preserve this boundary through shared asynchronous preparation without a synchronous fallback, while retaining remote discovery for agent tasks.
  • Explain or restore the original intent of Native menus for remote workspaces - e1976b0: Keep native menus available from Gateway-owned skills without depending on remote task discovery or exposing stale local workspace copies.

Findings

  • [P1] Preserve native-menu isolation from remote workspace failures — extensions/telegram/src/bot-native-commands.ts:71-74

Provenance

  • Native menus for remote workspaces changes intended behavior without addressing why it exists (e1976b0: Keep native menus available from Gateway-owned skills without depending on remote task discovery or exposing stale local workspace copies.)

Tests

  • Missing end-to-end proof: Telegram Test Server evidence for awaited native-menu registration and command pagination is absent, and no failing-before/passing-after regression demonstrates asynchronous native-menu isolation.
Agent review details

How this fits together

Channel registration passes agent configuration to shared skill discovery, which selects eligible skills and returns command descriptors for native menus.

flowchart TD
  A[Agent configuration] --> B[Channel registration]
  B --> C[Shared skill preparation]
  C --> D[Library database worker]
  C --> E[Workspace skill owner]
  D --> F[Command descriptors]
  E --> F
  F --> G[Native menus]
Loading

Technical review

Best possible solution:

Use shared worker-backed preparation while preserving Gateway-only native menus for remote workspaces and remote discovery for agent tasks.

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

Source establishes the regression with native skills enabled and a remote binding whose loadSkills rejects or has stopped; no runtime reproduction was executed in this read-only review.

Is this the best way to solve the issue?

Reusing asynchronous preparation is appropriate, but bundled menus must retain their existing source selection and failure isolation.

Full review comments:

  • [P1] Preserve native-menu isolation from remote workspace failures — extensions/telegram/src/bot-native-commands.ts:71-74
    This earlier finding remains: with native skills enabled and agent main bound to a remote workspace whose loadSkills rejects, prepareSkillCommandsForAgents enables remote discovery and propagates rejection before Telegram registers handlers, causing createTelegramBotCore to fail. A stopped binding throws even earlier during workspace resolution. Discord and native Slack propagate the same failure; Mattermost discards otherwise available Gateway skill commands. The previous synchronous path deliberately used Gateway-only discovery, and the existing remote-skill-menu fixture protects that behavior. Preserve this boundary through shared asynchronous preparation without a synchronous fallback, while retaining remote discovery for agent tasks.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ea576bd11d8c.

Provenance checked

  • Asynchronous skill preparation keeps the original intent (e15e7e5: Prepare Gateway skill commands asynchronously while sharing assembly with synchronous public SDK consumers.)

Testing

Proof path: none.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/skills/discovery/chat-commands.discovery.test.ts --maxWorkers=1
  • pnpm test extensions/discord/src/monitor/provider.commands.test.ts extensions/mattermost/src/mattermost/monitor-slash.test.ts --maxWorkers=1
  • pnpm test extensions/telegram/src/bot-native-command-dispatch.routing.test.ts extensions/telegram/src/bot-native-commands.registry.test.ts --maxWorkers=1
  • pnpm build
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e15e7e5 adds src/skills/discovery/chat-commands.ts:231 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e15e7e5de66c; files: src/skills/discovery/chat-commands.ts)
  • Kimi Yu: Raw commit e1976b0 adds src/skills/discovery/chat-commands.ts:74 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e1976b0bef5e; files: src/skills/discovery/chat-commands.ts)

PR surface

Source +53, Tests +14, Docs +14, Other +6. Total +87 across 41 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 16 98 45 +53
Tests 20 103 89 +14
Docs 2 16 2 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 3 10 4 +6
Total 41 227 140 +87

Labels

Label changes:

No label changes.

Label justifications:

  • P1: An unavailable remote workspace can prevent otherwise working channel accounts from starting.
  • merge-risk: 🚨 availability: The introduced awaited dependency propagates remote workspace failures into Telegram, Discord, and native Slack startup.
  • merge-risk: 🚨 compatibility: The PR changes native-menu selection behavior and adds asynchronous SDK replacements, although released synchronous methods remain supported.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Skill selection affects Telegram native menus and command-pagination output, including behavior for remote workspaces.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (6 earlier review cycles)
  • reviewed 2026-10-11T12:13:17.713Z sha e5f5726 :: needs changes before merge. :: [P1] Restore the exported model-header function | [P1] Preserve native-menu isolation from remote workspace failures | [P2] Await registration in the remaining native-command test driver
  • reviewed 2026-10-11T12:35:28.098Z sha 58be5aa :: needs changes before merge. :: [P1] Restore the exported model-header function | [P1] Preserve native-menu isolation from remote workspace failures | [P2] Await registration in the remaining native-command test driver | [P2] Account for the replacement exports in all SDK surface budgets | [P2] Include the compatibility record in the extracted wrapper inventory
  • reviewed 2026-10-11T13:09:02.945Z sha dc5ee7d :: needs changes before merge. :: [P1] Preserve native-menu isolation from remote workspace failures | [P2] Await registration in the remaining native-command test driver | [P2] Account for the replacement exports in all SDK surface budgets | [P2] Include the compatibility record in the extracted wrapper inventory
  • reviewed 2026-10-11T13:28:48.523Z sha 2eae69c :: needs changes before merge. :: [P1] Preserve native-menu isolation from remote workspace failures
  • reviewed 2026-10-11T13:46:44.158Z sha 020681a :: needs changes before merge. :: [P1] Preserve native-menu isolation from remote workspace failures
  • reviewed 2026-10-11T15:12:08.280Z sha 5f87200 :: needs changes before merge. :: [P1] Preserve native-menu isolation from remote workspace failures

Reviewed October 11, 2026, 11:33 AM ET / 15:33 UTC (Revision 7).

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Oct 11, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Oct 11, 2026
@steipete
steipete merged commit eed70ee into main Oct 11, 2026
146 checks passed
@steipete
steipete deleted the dbasync/sdkasync-skills branch October 11, 2026 16:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
Await worker-backed skill command preparation in bundled Discord, Slack, Mattermost, and Telegram command registration and dispatch. Telegram bot construction waits for native registration to settle.

Expose the existing preparation APIs through the narrow Plugin SDK entrypoints and deprecate synchronous list helpers with bounded migration warnings. Retain released synchronous contracts through the next SDK major; document the async replacements and exact replacement-pair surface allowances.

The synchronous external host tool-surface API still retains the selection kernel's lexical T1 implementation. This cutover removes bundled channel discovery from that path without adding a cache, database, worker protocol, or synchronous fallback.
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: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram docs Improvements or additions to documentation 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. P1 High-priority user-facing bug, regression, or broken workflow. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant