Repository navigation
refactor(channels): deslop Telegram, Matrix and Feishu fifth pass - #160970
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 29, 2026, 1:35 AM ET / 05:35 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch removes duplicate parsing, state, and delivery plumbing in the Telegram, Matrix, and Feishu plugins while aiming to preserve their message and configuration behavior. Merge readiness⛔ Blocked before merge - 2 items remain Keep open. This is a distinct, maintainer-requested cleanup that current main does not contain. The prior review reported no findings, and this review found no definite patch defect. Telegram-specific live parity evidence remains the merge blocker. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s channel plugins turn platform events into authorized agent turns and send agent replies back through each platform’s API. The changed helpers also serve Feishu document tools and channel directory lookups. flowchart LR
A[Platform events] --> B[Channel plugin intake]
B --> C{Authorize and parse}
C --> D[Agent session]
D --> E[Reply planning]
E --> F[Platform APIs]
G[Agent tool calls] --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource -459, Tests -65, Other 0. Total -524 across 63 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the cutover to existing plugin owners while preserving authorization, message bytes, and stored-state contracts across all three channels. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR reports a behavior-preserving refactor rather than a bug. The changed paths are identifiable in source and covered by focused boundary tests. Is this the best way to solve the issue? Yes: reusing the existing join, identity, directory, and send owners is a narrow maintainable direction; Telegram platform parity remains to be observed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ec101d561e2c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
94 upstream commits, including the Telegram, Matrix and Feishu cleanup (openclaw#160970), the removal of unused Feishu send test fixtures (openclaw#160913) and hosted network access for the agentsapi plugin (openclaw#161004). Four conflicts. Two are in Feishu code. In extensions/feishu/src/send.ts, openclaw#160970 has sendMessageFeishu resolve its target from params and pass the whole target to sendReplyOrFallbackDirect. That shape is kept. The target still carries accountId from this branch's send-target.ts, so the table mode keeps following the delivering account. In extensions/feishu/src/reply-dispatcher.ts, openclaw#160970 inlined markVisibleReplySent at six call sites. This branch moved those senders into reply-senders.ts, which marks a visible reply through that callback, so the helper and the createFeishuReplySenders call are kept. The inlined assignments that merged cleanly elsewhere in the file behave the same. The other two are generated, docs/.generated/config-baseline.counts.json and docs/.generated/config-baseline.sha256. openclaw#161004 takes plugin from 4431 to 4436. This branch keeps channel at 3788 and core stays at 2475. Both files came from upstream and were regenerated. build:docker ran in a separate detached checkout of this commit outside the nested node_modules install. Regenerating there changed those two files and nothing else, giving the predicted counts, the upstream core and plugin hashes, this branch's channel hash and a new combined hash. The three generated-file checks pass there. Upstream deleted 28 test files in this range. None of them were added or changed by this branch. Feishu: 107 files and 1858 tests in the extension project, 17 files and 311 tests in the database-workers project. Each is one lower than the previous merge because openclaw#160913 removed a card edit test from send.test.ts and openclaw#160970 removed a botName test from monitor.reaction.test.ts, neither touched by this branch. The forwarder test and the routing guards pass, 431 tests. tsgo:core, tsgo:extensions, tsgo:extensions:test, tsgo:test:root, the line-cap, max-lines and assertion-safety ratchets against upstream/main, oxlint and oxfmt on the 43 changed code files all pass.
What Problem This Solves
This maintainer-requested fifth pass removes remaining duplicate owners, unused forwarding and repeated projections across Telegram, Matrix and Feishu after the earlier channel sweeps.
User Impact
No user-visible behavior change. Request/event bytes, callback formats, authorization and allowlists, rate limits, chunking, crypto/device state, persisted state, manifests and configuration keys remain unchanged. No migration or operator action is required.
Why This Change Was Made
The measured candidate removes 459 net production lines (320 added, 779 removed), plus 65 net test/support lines. The full large-file sweep found a smaller safe result than the 1,000-line target. The coverage log below accounts for every one of the 204 baseline production files over 200 lines, sorted by size; untouched files over 150 lines were inspected first.
The dedicated WebSocket wait remains because a generic promise race changes same-turn abort/terminal-error ordering. Persisted identity-name fields and probe/UI output are also retained; only the unused in-memory name mirror is removed.
Related earlier passes: #160032, #158923, #159430. Their merged name-only diffs were read before this pass; this PR does not replay those changes.
Fixes Found Along the Way
No product bug or flaky-test fix is claimed. The removed bot-name test only asserted forwarding of an unused private argument; the ID-based mention regression remains. Existing batch and poll assertions were updated to follow the canonical owners, and the Telegram dispatch fixture now mocks the shared sticker-vision owner.
Evidence
Linux / Node 24.19.0 / pnpm 12.5.1, Blacksmith Testbox. The full extension/boundary run used
tbx_01m3ndgfhrma5t8nm8ra0fxjmf(run); final validation used replacement leasetbx_01m3nkw0s40z21hw6kwwgefytt(run). Commands ran sequentially with frozen source and dependency verification.pnpm build: passed on the final source tree, 275.68 s wall.pnpm test:extensions:batch telegram,matrix,feishu: passed, 451 test files / 6,569 tests, 2,878.83 s wall. The normal batching and database-worker isolation were preserved.node scripts/run-vitest.mjs src/infra/fs-safe-import-boundary.test.ts test/plugin-extension-import-boundary.test.ts test/extension-test-boundary.test.ts test/test-helper-extension-import-boundary.test.ts src/plugins/contracts/core-extension-facade-boundary.test.ts: passed, 5 files / 49 tests, 44.96 s wall.git diff --check: passed.node scripts/check-changed.mjs: passed on the final source tree, 569.26 s wall, including production/test types, dead exports, lint and runtime import-cycle checks. Three assertion-safety baseline counts shrink; no new exception was added.Changed-test costs, measured with
pnpm test <file> --maxWorkers=1(all passed, no new tests):extensions/feishu/src/bot.checkBotMentioned.test.tsextensions/feishu/src/docx-batch-insert.test.tsextensions/feishu/src/monitor.bot-menu.test.tsextensions/feishu/src/monitor.reaction.test.tsextensions/matrix/src/matrix/poll-types.test.tsextensions/feishu/src/monitor.bot-identity.test.tsextensions/feishu/src/monitor.cleanup.test.tsextensions/feishu/src/monitor.webhook-routing.test.tsextensions/feishu/src/monitor.vc-meeting-invited-handler.test.tsThe full extension run preceded the final removal of the write-only name map. After that cutover, all four changed monitor suites above passed again, plus
monitor.bot-identity.rejection.test.ts,bot-identity-cache.test.ts,monitor.startup.test.tsandmonitor.lifecycle.test.ts(35 cases, 47.73 s wall). The account/reply dispatcher follow-up also passed 188 cases. The final build, changed gate and independent review bind the finished source tree4772e48821c80156ffd1847d15daaa35ed088d8c.The removed Telegram fixture mocks are covered by the full Telegram suite; no test cases were added there. Hosted PR CI timings are not available yet. The Testbox hosting Actions runs can show cancelled after lease cleanup; the recorded command exits are authoritative.
Coverage log: all 204 production files over 200 lines
l158 Telegram, Matrix and Feishu fifth-pass coverage
Baseline: 58e1481. Recent merged PRs and their name-only diffs were inspected first; untouched files over 150 lines were read before previously touched large owners. Each production source file over 200 lines is listed by baseline size. READ denotes complete source inspection, with callers and shared owners checked as relevant. Test/support files are excluded.
extensions/feishu/src/channel.tsextensions/feishu/src/bot.tsextensions/feishu/src/reply-dispatcher.tsextensions/feishu/src/monitor.comment.tsextensions/telegram/src/channel.tsextensions/feishu/src/docx.tsextensions/telegram/src/action-runtime.tsextensions/telegram/src/bot-message-context.session.tsextensions/telegram/src/message-cache.tsextensions/telegram/src/bot/delivery.replies.tsextensions/feishu/src/doctor.tsextensions/telegram/src/draft-stream.tsextensions/feishu/src/media.tsextensions/feishu/src/outbound.tsextensions/telegram/src/fetch.tsextensions/feishu/src/monitor.transport.tsextensions/matrix/src/matrix/sdk/verification-manager.tsextensions/telegram/src/bot-message-dispatch-delivery.tsextensions/matrix/src/matrix/sdk/client-base.tsextensions/feishu/src/drive.tsextensions/telegram/src/bot-native-command-menu.tsextensions/matrix/src/matrix/thread-bindings.tsextensions/telegram/src/bot-message-dispatch-reply.tsextensions/matrix/src/matrix/client/config.tsextensions/telegram/src/bot-handlers.callback-router.tsextensions/feishu/src/streaming-card.tsextensions/telegram/src/webhook.tsextensions/telegram/src/bot-handlers.callback-router-controls.tsextensions/telegram/src/thread-bindings.tsextensions/matrix/src/onboarding.tsextensions/telegram/src/rich-blocks.tsextensions/feishu/src/send.tsextensions/telegram/src/bot-message-context.tsextensions/telegram/src/lane-delivery-text-deliverer.tsextensions/telegram/src/doctor.tsextensions/matrix/src/cli-shared.tsextensions/telegram/src/format.tsextensions/telegram/src/bot/helpers.tsextensions/matrix/src/matrix/sdk.tsextensions/matrix/src/matrix/client/shared.tsextensions/matrix/src/matrix/monitor/handler.tsextensions/matrix/src/matrix/format.tsextensions/telegram/src/polling-session.tsextensions/matrix/src/channel.tsextensions/telegram/src/send-message.tsextensions/telegram/src/bot-message-dispatch-draft.tsextensions/matrix/src/matrix/monitor/verification-events.tsextensions/matrix/src/matrix/send.tsextensions/feishu/src/bitable.tsextensions/telegram/src/bot-handlers.inbound-authorization.tsextensions/telegram/src/bot-handlers.message-pipeline.tsextensions/telegram/src/bot-handlers.message-context.tsextensions/matrix/src/approval-handler.runtime.tsextensions/feishu/src/monitor.account.tsextensions/matrix/src/matrix/crypto-state-store.tschunked-state.ts, so no sound larger reduction remains here.extensions/matrix/src/matrix/actions/verification.tsextensions/matrix/doctor-contract-api.tsextensions/matrix/src/tool-actions.tsextensions/telegram/src/outbound-adapter.tsextensions/matrix/src/matrix/monitor/index.tsonSyncStateforwarding wrapper by making it the health-state implementation directly, preserving its single-argument signature and timestamp capture. Client retirement, lease release and setup-closed checks guard different awaited boundaries and remain unchanged.extensions/telegram/src/send-context.tsextensions/matrix/src/matrix/sdk/recovery-key-store.tsextensions/telegram/src/bot-message-dispatch.tsextensions/feishu/src/presentation-card.tsextensions/telegram/src/rich-blocks-html-map.tsextensions/telegram/src/bot-handlers.inbound-media.tsextensions/matrix/src/matrix/client/storage.tsprepareStorageMetaMutation/mutateStorageMetaowner with published-host fallback, and legacy migration ordering cannot be collapsed safely.extensions/feishu/src/client.tsextensions/telegram/src/telegram-ingress-drain.tsextensions/telegram/src/bot-message.tsextensions/matrix/src/matrix/monitor/events.tsextensions/matrix/src/matrix/sdk/client-core.tsextensions/feishu/src/feishu-ingress.tsextensions/telegram/src/bot-handlers.event-bindings.tsextensions/matrix/src/matrix/monitor/handler-ingress-content.tsextensions/matrix/src/matrix/sdk/decrypt-bridge.tsextensions/telegram/src/bot-message-context.body.tsextensions/feishu/src/monitor.message-handler.tsextensions/matrix/src/matrix/monitor/config.tsextensions/matrix/src/matrix/sdk/transport.tscleanup(); await closeDispatcher(dispatcher);pairs before missing-location, cross-protocol and redirect-loop throws; the enclosing catch already performs both calls, saving six production lines with error decisions and request bodies unchanged.extensions/telegram/src/bot/body-helpers.tsextensions/matrix/src/matrix/delivery-plan.tsextensions/matrix/src/matrix/monitor/inbound-dedupe-migration.tsextensions/telegram/src/account-throttler.tsextensions/telegram/src/bot-native-command-dispatch.tsextensions/telegram/src/bot-native-command-menu-state.tsextensions/feishu/src/setup-surface.tsextensions/telegram/src/bot/delivery.resolve-media.tsextensions/telegram/src/rich-block-model.tsextensions/matrix/src/cli-verification.tsextensions/feishu/src/card-action.tsextensions/feishu/src/config-schema.tsextensions/telegram/src/bot-core.tsextensions/matrix/src/matrix/poll-types.tsextensions/matrix/src/matrix/sdk/crypto-bootstrap.tsextensions/telegram/src/bot-handlers.inbound-pipeline.tsextensions/telegram/src/send-prepared.tsextensions/telegram/src/interactive-fallback.tsextensions/telegram/src/doctor-contract.tsextensions/telegram/src/message-cache-codec.tsextensions/feishu/src/comment-shared.tsextensions/matrix/src/matrix/sdk/idb-persistence.tsextensions/telegram/src/telegram-ingress-worker.runtime.tsextensions/matrix/src/matrix/monitor/room-history.tsHistoryEntryis already reused; custom tracker adds semantics absent from basic reply-history helpers.extensions/telegram/src/bot-native-command-builtins.tsextensions/feishu/src/app-registration.tsextensions/matrix/src/approval-reactions.tsextensions/matrix/src/matrix/monitor/startup-verification.tsextensions/telegram/src/bot-message-dispatch-progress.tsextensions/telegram/src/bot-message-dispatch-turn.tsextensions/matrix/src/matrix/actions/messages.tsextensions/telegram/src/network-errors.tsextensions/feishu/src/thread-bindings.tsextensions/telegram/src/bot-handlers.inbound-processing.tsextensions/matrix/src/approval-native.tsextensions/telegram/src/approval-handler.runtime.tsextensions/telegram/src/bot-native-command-login.tsextensions/matrix/src/matrix/monitor/handler-context.tsextensions/telegram/src/channel-actions.tsextensions/matrix/src/matrix/sdk/client-verification.tsextensions/telegram/src/send-message-text.tsextensions/telegram/src/bot-native-commands.tsextensions/matrix/src/matrix/client/sync-cache-state.ts/syncnormalization plus malformed-generation fallback encode persisted formats, integrity and clean-shutdown behavior that must remain identical.extensions/matrix/src/matrix/monitor/handler-ingress-access.tsextensions/telegram/src/bot-update-tracker.tsextensions/feishu/src/bot-content.tsextensions/feishu/src/accounts.tsextensions/feishu/src/policy.tsextensions/matrix/src/cli-account.tsextensions/telegram/src/config-schema.tsextensions/feishu/src/read-policy.tsextensions/feishu/src/monitor.vc-meeting-invited-handler.tsextensions/telegram/src/button-types.tsextensions/matrix/src/matrix/send/chunking.tsextensions/telegram/src/sendchataction-401-backoff.tsextensions/feishu/src/comment-handler.tsextensions/telegram/src/bot-handlers.inbound-buffer.tsextensions/matrix/src/matrix/direct-management.tsextensions/feishu/src/docx-markdown.tsextensions/matrix/src/matrix/monitor/direct.tsextensions/matrix/src/matrix/monitor/handler-reply-dispatcher.tsextensions/telegram/src/bot-native-command-plugins.tsextensions/telegram/src/probe.tsextensions/matrix/src/matrix/monitor/reaction-events.tsextensions/matrix/src/outbound.tsextensions/telegram/src/outbound-media.tsextensions/feishu/src/bot-broadcast.tsextensions/feishu/src/chat.tsextensions/telegram/src/model-buttons.tsextensions/feishu/src/post.tsextensions/telegram/src/send-special.tsextensions/matrix/src/cli-verification-backup.tsextensions/matrix/src/exec-approvals.tsextensions/telegram/src/conversation-route.tsextensions/telegram/src/send-edit.tsextensions/telegram/src/bot/inbound-text-entities.tsextensions/telegram/src/miniapp/routes.tsextensions/matrix/src/matrix/read-policy.tsextensions/telegram/src/account-inspect.tsextensions/matrix/src/matrix/config-update.tsextensions/telegram/src/history-policy.tsextensions/feishu/src/wiki.tsextensions/matrix/src/matrix/client/file-sync-store.tsextensions/telegram/src/rich-block-split.tsextensions/telegram/src/sequential-key.tsextensions/telegram/src/status-reaction-variants.tsextensions/feishu/src/docx-table-ops.tsextensions/matrix/src/matrix/send/media.tsextensions/feishu/src/markdown.tsextensions/telegram/src/send-actions.tsextensions/feishu/src/subagent-hooks.tsextensions/matrix/src/matrix/monitor/mentions.tsextensions/matrix/src/matrix/format-spoiler-ranges.tsextensions/telegram/src/ingress.tsextensions/telegram/src/rich-blocks-html.tsextensions/feishu/src/comment-reaction.tsextensions/feishu/src/interactive-message-content.tsextensions/matrix/src/matrix/deps.tsruntime/confirmarguments on dependency-check-onlyensureMatrixSdkInstalledcan be removed together with its onboarding caller's unused confirmation closure after checking the runtime-api export's history/contract; the existing test only proves confirmation is unused and is not itself a retention contract.extensions/telegram/src/telegram-text-delivery.tsextensions/matrix/src/matrix/accounts.tsextensions/telegram/src/bot-message-dispatch-context.tsextensions/matrix/src/matrix/monitor/handler-draft-controller.tsextensions/telegram/src/send-outbound.tsextensions/feishu/src/native-card.tsextensions/telegram/src/update-offset-store.tsextensions/telegram/src/status-issues.tsextensions/matrix/src/doctor-contract.tsextensions/telegram/src/history-read.tsextensions/telegram/src/polling-lease.tsextensions/feishu/src/dynamic-agent.tsextensions/telegram/src/bot-processing-outcome.tsextensions/matrix/src/setup-config.tsextensions/matrix/src/matrix/draft-stream.tsextensions/matrix/src/matrix/sdk/client-support.tsextensions/matrix/src/matrix/monitor/handler-helpers.tsextensions/telegram/src/monitor.tsextensions/telegram/src/topic-name-cache.tsextensions/telegram/src/format-html.tsextensions/matrix/src/config-schema.tsextensions/telegram/src/progress-draft-preview.tsextensions/feishu/src/doctor-contract.tsextensions/feishu/src/probe.tsextensions/matrix/src/matrix/sdk/types.tsextensions/telegram/src/target-writeback.tsFinal cutover follow-through: read monitor.state.ts, monitor.bot-identity.ts and monitor.ts with all setter/prefetch callers; removed the write-only in-memory bot-name map after its readers were retired. Kept persisted identity-name fields, provider/probe outputs, open-ID state and identical identity-revision bumps. Lifecycle proofs retain same-ID successor ownership, recovery and drain assertions.