Skip to content

refactor(telegram): remove test-only bot dependency bags - #174256

Merged
steipete merged 2 commits into
mainfrom
deslop/z19-6-telegram-seams-20261015
Oct 16, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/z19-6-telegram-seams-20261015

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Telegram threaded a single default dependency object through bot creation, message handling, reply dispatch and native commands. Alternate implementations came only from tests, and a second native-command object duplicated the same forwarding plumbing.

What Changed

Call the existing SDK and Telegram owners directly, remove both private dependency bags and the bot-construction forwarding wrapper, and move test alternatives to module boundaries. Keep actual runtime/transport inputs, prepared context handoffs, current authorization reads, lazy send loading, cancellation and delivery settlement unchanged.

This is an area slice of a wider cleanup family. Public SDK exports, Gateway protocol, config keys, CLI flags and persisted shapes do not change. No migration or user action is required. No dependency or schema change.

Against pinned main base e3278ef: 27 production files, +174/-351 (177 net production lines removed). Tests/support: 33 files, +892/-368 (524 net lines added), including the new fixture-only type file. Two ratchets shrink by three lines. Retained fixture assertions are unchanged; the added setup replaces production injection with module mocks.

Best-effort tradeoffs accepted

None. This removes test-only indirection, not runtime guards. Security-effect authority checks and write-capable work settlement remain with their current owners.

Evidence

  • Targeted Telegram package typecheck passed (175 seconds), including the touched core context-builder inventory test and the new fixture types.
  • Targeted formatting and whitespace checks passed.
  • Fresh independent P0-P2 review completed scoped-clean, including final source verification. No accepted/actionable finding remains. Review specifically checked module-boundary delegation/cleanup, preserved live authorization/config reads and lazy native-command sends.
  • Initial exact-head CI run 38908544491 had five PR-caused failures. The lint, production-type and core-test-type jobs all named one unused import, now removed. The bundle job's two localization assertions used the real menu synchronizer because its fixture mocks were installed after importing the consumer; fixture installation now precedes that import. The config job's approval retry assertion mocked a static pre-harness module instance; it now spies on the dynamically imported serving module. All existing assertions remain unchanged. The downstream CI gate reflected those five failures, not another defect.
  • Fresh independent P0-P2 review of that three-file repair completed scoped-clean, including final source verification. Targeted Telegram package types passed again (226 seconds), and formatting/whitespace checks passed. A narrow lint attempt entered package-wide declaration preparation through its wrapper and was stopped under the campaign's local budget; lint remains incomplete, not passing evidence. No prerequisite bypass was used.
  • Local focused runtime tests are unrun: the canonical runner requires compiled worker artifacts and the campaign forbids local builds. No prerequisite bypass or stale-cache rewrite is used. Exact-head PR CI owns runtime and broad proof.
  • No live Telegram claim: transport, streaming, authorization and reply behavior are preserved; this is a private plumbing cut.

Release-note context: internal simplification only; user-visible Telegram features and public contracts remain unchanged.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XL labels Oct 16, 2026
@steipete
steipete marked this pull request as ready for review October 16, 2026 13:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T14:14:50.268849Z 834422f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR replaces private Telegram dependency bags with direct owner imports and moves test substitutions to module mocks.

Example: A Telegram user sends /status.

  • Before: The command reaches existing owners through private dependency objects.
  • After: The command calls those owners directly, with the same intended reply.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful production simplification, but the fixture migration introduces two confirmed CI failures.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored private-plumbing refactor is outside the ordinary contributor proof gate; it supplies no live Telegram claim, and CI execution is assessed separately.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No user-visible defect is claimed; test-only dependency plumbing increases Telegram maintenance work.
Reason: The maintainer-authored direction removes private production indirection while retaining existing owners and public contracts.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this PR open: the maintainer-directed cleanup is useful, but two fixture migrations break existing Telegram tests and need repair.

Priority: P3
Reviewed head: 44d0db2e26376fe4b1137d489542051373d8e94f

Before merge

  • Load the registry fixture mocks before production registration (P2) - The new menu mock is installed only when this support module is imported, but bot-native-commands.registry.test.ts imports bot-native-commands.js first at line 93 and this module afterward at line 101. Registration therefore retains the real syncTelegramMenuCommands instead of the fixture implementation that previously arrived through telegramDeps. The real synchronizer converts localization metadata into separate Telegram menu calls, so both normalized-winner cases now receive a default command without descriptionLocalizations and fail, as exact-head CI confirms. Import the mock support before production registration, or install these mocks in the registry test before loading the subject.
  • Preserve the binding resolver spy across the harness mock (P2) - bot.create-telegram-bot.test.ts already imports conversation-runtime with spy:true and injects a rejected binding resolver result for its callback-retry test. This later harness factory spreads importOriginal, replacing the module for subsequent production imports with an unspied resolvePluginConversationBindingApproval. The test and callback owner then use different resolver functions, so binding boom never reaches the callback and the required rejection disappears; exact-head CI reports that failure at line 2660. Use one shared spy-backed export for the test and production module, while retaining the three fixture overrides.

Findings

  • [P2] Load the registry fixture mocks before production registration — extensions/telegram/src/bot-native-commands.menu-test-support.ts:72-77
  • [P2] Preserve the binding resolver spy across the harness mock — extensions/telegram/src/bot.create-telegram-bot.test-harness.ts:486-487
Agent review details

How this fits together

The Telegram plugin receives Bot API updates, prepares authorized conversation context, dispatches agent or native-command work, and delivers replies through Telegram and shared SDK owners.

flowchart LR
  A[Telegram update] --> B[Bot and handlers]
  B --> C[Authorization and context]
  C --> D[Agent or native command]
  D --> E[SDK and Telegram owners]
  E --> F[Telegram reply]
Loading

Technical review

Best possible solution:

Keep the direct-owner refactor and repair mock initialization and resolver identity without weakening the existing assertions.

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

This refactor reports no product defect; exact-head CI annotations establish the two fixture failures, and source inspection explains their triggers.

Is this the best way to solve the issue?

Direct imports are a reasonable replacement for test-only production injection, provided module mocks preserve initialization order and shared function identity.

Full review comments:

  • [P2] Load the registry fixture mocks before production registration — extensions/telegram/src/bot-native-commands.menu-test-support.ts:72-77
    The new menu mock is installed only when this support module is imported, but bot-native-commands.registry.test.ts imports bot-native-commands.js first at line 93 and this module afterward at line 101. Registration therefore retains the real syncTelegramMenuCommands instead of the fixture implementation that previously arrived through telegramDeps. The real synchronizer converts localization metadata into separate Telegram menu calls, so both normalized-winner cases now receive a default command without descriptionLocalizations and fail, as exact-head CI confirms. Import the mock support before production registration, or install these mocks in the registry test before loading the subject.
    Confidence: 0.98
  • [P2] Preserve the binding resolver spy across the harness mock — extensions/telegram/src/bot.create-telegram-bot.test-harness.ts:486-487
    bot.create-telegram-bot.test.ts already imports conversation-runtime with spy:true and injects a rejected binding resolver result for its callback-retry test. This later harness factory spreads importOriginal, replacing the module for subsequent production imports with an unspied resolvePluginConversationBindingApproval. The test and callback owner then use different resolver functions, so binding boom never reaches the callback and the required rejection disappears; exact-head CI reports that failure at line 2660. Use one shared spy-backed export for the test and production module, while retaining the three fixture overrides.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared bot dependency injection changes intended behavior with a stated reason (b85d97f: The historical module centralizes shared dependency injection; Telegram: stabilize pairing/session/forum routing and reply formatting tests #50155 later documents its role in stable routing and test coverage.)
  • Narrow native-command dependencies changes intended behavior with a stated reason (1337be3: The historical change narrows native-command test seams and loads sending lazily; this PR moves substitutions to tests and retains lazy send loading.)
  • Current authorization and delivery ownership keeps the original intent (refactor(channels): consolidate private transport paths #173128: The preceding consolidation retained complete private inputs, current authority checks, lazy native-command binders, and delivery settlement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/telegram/src/bot-native-commands.registry.test.ts extensions/telegram/src/bot.create-telegram-bot.test.ts --maxWorkers=1
  • pnpm tsgo:extensions
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit ace1908 adds extensions/telegram/src/bot.create-telegram-bot.test-harness.ts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ace190874ae3; files: extensions/telegram/src/bot.create-telegram-bot.test-harness.ts)

PR surface

Source -176, Tests +524, Other -3. Total +345 across 61 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 27 174 350 -176
Tests 32 886 362 +524
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 4 -3
Total 61 1061 716 +345

Review metrics

Metric Value Why it matters
Production versus test growth Production +174/-350; tests/support +886/-362 Production shrinks by 176 lines; fixture growth moves substitutions out of production, but currently introduces two test failures.

Labels

Label changes:

  • add P3: This is internal maintenance with no intended user-visible behavior change.
  • add merge-risk: 🚨 automation: The introduced module-mock migration breaks existing registry and callback tests used by PR CI.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is internal maintenance with no intended user-visible behavior change.
  • merge-risk: 🚨 automation: The introduced module-mock migration breaks existing registry and callback tests used by PR CI.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 16, 2026, 9:53 AM ET / 13:53 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head landing evidence for 834422f888bea3a50b1c31aa4b3f8d00554534c1.

The full hosted CI run 38913795276 completed successfully: every planned runtime, type, lint, architecture, boundary and ratchet job passed, including the three jobs and two fixture suites that failed on the original head. Those original failures were PR-caused and repaired, not classified as inherited. All exact-head check runs were enumerated; no failure, cancellation or running suite remains. The CodeQL aggregate is neutral with its six applicable Security High checks successful; inapplicable jobs are skipped. Current dependency, security-sensitive-review and CI status contexts are successful.

Targeted package types and formatting passed. Fresh independent P0-P2 review of the area and its three-file repair completed scoped-clean. The local runtime/lint wrappers attempted broader artifact preparation than the campaign's host budget allows; those attempts were stopped and are not claimed as passes or code failures. Exact-head hosted CI supplies the broad/runtime proof. Existing assertions, real authorization, lazy sends, cancellation and settlement remain.

Native preparation is unavailable under shared provisioning capacity. Two earlier lane attempts stalled on that same capacity. This PR's first attempt then lost its process during the coordinator restart, without review artifacts or a merge intent. Its resumed attempt spent about fifteen minutes in startup/managed-worktree capacity admission and was stopped by its owner. It returned an aborted allocation state lease and no READY/preparation result; this is not represented as a completed native review or an automatic deadline verdict. All prior owned processes and their process group were verified gone. Exact-token native lock recovery is running separately; it has no merge intent and cannot submit a merge. No merge request was submitted by the preparation attempts.

Using the coordinator's explicitly authorized exact-head REST fallback for the broken native workflow. Checks, security and required reviews are not waived. No CI rerun, dispatch or push was made to chase green. Production delta: +174/-351, 177 net lines removed; tests/support: +892/-368.

@steipete
steipete merged commit d0d1f4c into main Oct 16, 2026
129 checks passed
@steipete
steipete deleted the deslop/z19-6-telegram-seams-20261015 branch October 16, 2026 15:00
he-yufeng added a commit to he-yufeng/openclaw that referenced this pull request Oct 16, 2026
gloss-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 16, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…4256)

* refactor(telegram): remove test-only bot dependency bags

* test(telegram): install mocks before importing command handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL 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