Skip to content

fix(telegram): resolve native command names from the loaded registry only - #123607

Merged
obviyus merged 1 commit into
mainfrom
t3code/fix-telegram-vitest-import-hang
Aug 14, 2026
Merged

obviyus merged 1 commit into
mainfrom
t3code/fix-telegram-vitest-import-hang

Conversation

@obviyus

@obviyus obviyus commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Telegram extension CI jobs die at exit 143 with zero output: extensions/telegram/src/bot-native-commands.test.ts and bot-native-command-plugins.test.ts sit silent for 300s, hit the no-output watchdog, retry, and fail again (e.g. run 31787829476, jobs 14/15). This holds back every Telegram PR, including #123528.

Why This Change Was Made

CPU profile of the hang (95% of worker samples) shows the real cause — not a cache deadlock and not a slow-but-legitimate import:

  • Both files call registerTelegramNativeCommands(...) at module scope, so the cost lands in Vitest's silent import phase.
  • That call reaches listNativeCommandSpecsForConfig → resolveNativeName → getChannelPlugin("telegram"). The tests install an empty plugin registry, so the lookup falls through to getBundledChannelPlugin, which jiti-loads extensions/telegram/channel-plugin-api.ts from TypeScript source — Babel-transpiling the whole plugin plus core graph inside the worker (~190s CPU locally, >300s on CI runners).
  • Telegram defines no resolveNativeCommandName hook (only Slack/Discord do), so the load resolves undefined and the default name is used anyway: a ~190s no-op.

Discord hit this class before and used the existing includeBundledChannelFallback: false escape hatch one-sidedly (extensions/discord/src/monitor/native-command.ts). This PR threads that option through listNativeCommandSpecs/listNativeCommandSpecsForConfig and applies loaded-registry-only lookups in the Telegram plugin.

User Impact

None at runtime: a live gateway always has the Telegram channel plugin in the loaded registry, and Telegram has no native-name hook, so resolved command names are byte-identical. Dev/test checkouts stop paying a hidden multi-minute jiti transpile; Telegram CI shards stop timing out.

Evidence

  • Before: bot-native-command-plugins.test.ts alone = 197s (import 195s, tests 1.4s); identical with warm or disabled fs-module-cache, disproving the cache theory. After: 5.8s. bot-native-commands.test.ts: 202s → 5.1s.
  • Grouped focused run on final tree: src/auto-reply/commands-registry.test.ts (39), Discord native-command.think-autocomplete.test.ts (5), and 7 Telegram bot-native/menu files (99) — all pass.
  • tsgo:core, tsgo:extensions, all test type lanes, check:test-types, oxlint, oxfmt, git diff --check clean.

…only

Telegram's native-command registration resolved provider names through
getChannelPlugin's bundled fallback. With no loaded registry entry (tests,
dev tools), that fallback jiti-loads the entire Telegram plugin plus core
graph from TypeScript source (~190s CPU, silent), which tripped the 300s
no-output CI watchdog on the two test files that register at module scope.
Telegram defines no resolveNativeCommandName hook, so the load resolved
nothing.

Thread the existing includeBundledChannelFallback option through
listNativeCommandSpecs/listNativeCommandSpecsForConfig and use
loaded-registry-only lookups in the Telegram plugin, matching the
Discord sibling fix.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@obviyus
obviyus marked this pull request as ready for review August 14, 2026 10:40
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Aug 14, 2026
@obviyus
obviyus enabled auto-merge (squash) August 14, 2026 10:44
@clawsweeper clawsweeper Bot added 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 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 6:45 AM ET / 10:45 UTC.

ClawSweeper review

What this changes

The PR threads an existing loaded-registry-only lookup option through native command listing and uses it for Telegram command registration and dispatch.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still uses the bundled fallback for Telegram native-command resolution; this active maintainer PR narrowly avoids that source-load path without changing Telegram’s current default command names. No blocking correctness or security finding was identified.

Priority: P2
Reviewed head: 07c6c70ff11f8fa6d42d217c5b5b1b0e02e0e091

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with source-backed equivalence to current Telegram command names.
Proof confidence 🌊 off-meta tidepool Not applicable: The item is maintainer-owned; its PR body nevertheless supplies focused before/after timing and validation claims for the internal CI path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The item is maintainer-owned; its PR body nevertheless supplies focused before/after timing and validation claims for the internal CI path.
Evidence reviewed 5 items Current-main fallback path: The current registry resolves provider names through getChannelPlugin unless the existing option is explicitly false; getChannelPlugin falls back to bundled channel loading when no loaded registry entry exists.
PR fixes the implicated owner boundary: The PR passes loaded-registry-only lookup options through both native-spec list functions and all Telegram registration, login, and dispatch lookups.
Fallback is materially expensive in source checkouts: Bundled channel loading resolves a generated entry and uses the source-module loader/cache fallback for TypeScript paths, matching the PR’s diagnosis of expensive source loading.
Findings None None.
Security None None.

How this fits together

Telegram builds its native Bot API command menu from the shared command registry, optionally consulting a channel plugin for provider-specific names. The resulting names are registered as handlers and later resolved back into core command definitions.

flowchart LR
  A[Telegram bot startup] --> B[Native command registry]
  B --> C[Channel plugin lookup]
  C --> D[Command names and menu]
  D --> E[Telegram command handlers]
  F[Bundled plugin fallback] --> C
Loading

Before merge

  • Resolve merge risk (P2) - Production code grows by 41 net lines for a bug fix; the growth appears necessary to preserve the existing fallback default for other channels while making Telegram’s loaded-only policy explicit.
  • Complete next step (P2) - No repair job is needed: the active maintainer PR already owns the narrow fix and only needs normal exact-head validation.
Agent review details

Security

None.

PR surface

Source +41, Tests +5. Total +46 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 62 21 +41
Tests 1 6 1 +5
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 68 22 +46

Review metrics

Metric Value Why it matters
Production versus test LOC production +41 (62 added, 21 removed); tests +5 (6 added, 1 removed) The production growth carries a pre-existing lookup policy through shared list APIs while preserving their default fallback behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the shared default fallback for other channel consumers and land the explicit loaded-registry-only policy at Telegram’s native command boundary once exact-head CI is green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the shared default fallback for other channel consumers and land the explicit loaded-registry-only policy at Telegram’s native command boundary once exact-head CI is green.

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

Yes, source-reproducible: the affected Telegram tests install an empty registry before module-scope registration, while current main falls through from the shared registry to bundled loading. The review is read-only, so it did not rerun the timing scenario.

Is this the best way to solve the issue?

Yes. This is the narrowest maintainable fix: Telegram has no current name-resolver hook, while the shared default fallback remains necessary for sibling channels that do override native names.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded Telegram CI reliability repair that blocks a channel-specific development workflow but does not show a current end-user delivery regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The item is maintainer-owned; its PR body nevertheless supplies focused before/after timing and validation claims for the internal CI path.

Label justifications:

  • P2: This is a bounded Telegram CI reliability repair that blocks a channel-specific development workflow but does not show a current end-user delivery regression.
  • 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: The item is maintainer-owned; its PR body nevertheless supplies focused before/after timing and validation claims for the internal CI path.

Evidence

What I checked:

  • Current-main fallback path: The current registry resolves provider names through getChannelPlugin unless the existing option is explicitly false; getChannelPlugin falls back to bundled channel loading when no loaded registry entry exists. (src/auto-reply/commands-registry.ts:70, c2269f7a6c41)
  • PR fixes the implicated owner boundary: The PR passes loaded-registry-only lookup options through both native-spec list functions and all Telegram registration, login, and dispatch lookups. (src/auto-reply/commands-registry.ts:70, 07c6c70ff11f)
  • Fallback is materially expensive in source checkouts: Bundled channel loading resolves a generated entry and uses the source-module loader/cache fallback for TypeScript paths, matching the PR’s diagnosis of expensive source loading. (src/channels/plugins/bundled.ts:255, c2269f7a6c41)
  • Sibling and regression coverage: Discord already uses the same loaded-registry-only lookup; the Telegram test fixture creates an empty registry before module-scope registration, directly covering the reported setup. (extensions/discord/src/monitor/native-command.ts:118, c2269f7a6c41)
  • Feature provenance: Blame ties the current registry lookup and Telegram registration code to the same recent commit, establishing the central ownership trail. (src/auto-reply/commands-registry.ts:54, 129c06d81195)

Likely related people:

  • Peter Steinberger: Current blame attributes the relevant command-registry and Telegram registration lines to the same commit. (role: introduced the current registry and Telegram native-command path; confidence: medium; commits: 129c06d81195; files: src/auto-reply/commands-registry.ts, extensions/telegram/src/bot-native-commands.ts)

Rank-up moves

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

  • Let exact-head CI complete successfully before merge.

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.

@obviyus
obviyus merged commit e826501 into main Aug 14, 2026
270 of 277 checks passed
@obviyus
obviyus deleted the t3code/fix-telegram-vitest-import-hang branch August 14, 2026 10:47
obviyus added a commit that referenced this pull request Aug 14, 2026
…m shards (#123649)

Hosted CI runners restored the boundary-artifact cache and rebuilt it anyway: fresh checkouts re-stamp every input mtime, so mtime freshness never passed. Stamp files now record the input content digest and byte-identical inputs skip the rebuild (~60s saved per hosted lint/boundary job, 0.17s verify). Telegram CI shards pack ten files per job instead of five now that per-file import cost is back to seconds (#123607), halving the ~42-job fanout.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
…only (openclaw#123607)

Telegram native-command registration resolved provider names through the bundled channel-plugin fallback, which jiti-transpiles the entire plugin plus core graph from source when no registry entry is loaded (~190s silent CPU) — tripping the 300s no-output CI watchdog on the two Telegram test files that register at module scope. Telegram defines no resolveNativeCommandName hook, so the load resolved nothing. Thread the existing includeBundledChannelFallback option through the spec-listing helpers and use loaded-registry-only lookups in the Telegram plugin, matching the Discord sibling. Runtime names are byte-identical; both files drop from 200s to ~5s.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
…m shards (openclaw#123649)

Hosted CI runners restored the boundary-artifact cache and rebuilt it anyway: fresh checkouts re-stamp every input mtime, so mtime freshness never passed. Stamp files now record the input content digest and byte-identical inputs skip the rebuild (~60s saved per hosted lint/boundary job, 0.17s verify). Telegram CI shards pack ten files per job instead of five now that per-file import cost is back to seconds (openclaw#123607), halving the ~42-job fanout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram 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