Repository navigation
refactor(channels): deslop telegram, matrix and feishu second pass - #158164
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 25, 2026, 2:22 PM ET / 18:22 UTC (Revision 8). ClawSweeper reviewWhat this changesConsolidates Telegram, Matrix, and Feishu plugin flows, updates related tests and Matrix documentation, and enables reaction decisions for Matrix system-agent approvals. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: current main still rejects Matrix system-agent approval reaction targets, and the branch contains distinct work beyond the three merged first-pass cleanups. The recorded channel, authority, and upgrade evidence supports this head; the inspected paths yielded no concrete blocking defect. Priority: P2 Review scores
Verification
How this fits togetherIncoming Telegram, Matrix, and Feishu events enter bundled channel plugins, which apply channel policy before handing authorized work to the Gateway. The plugins persist channel state and send replies through their respective transports. flowchart LR
A[Channel events and config] --> B[Channel plugins]
B --> C{Policy and approval checks}
C --> D[Gateway agent and approval runtime]
D --> E[Channel replies and edits]
B --> F[SQLite channel state]
F --> C
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Preserve the consolidated channel owners and public plugin contracts while routing Matrix system-agent reactions through the existing Gateway approval authority. Do we have a high-confidence way to reproduce the issue? Yes for the embedded Matrix defect: current main rejects system-agent targets at registration and persisted reads, and the PR records a failing pre-fix regression. The broader cleanup has no separate failure to reproduce. Is this the best way to solve the issue? Yes: the branch reuses channel-local and existing SDK owners, and the Matrix fix stays on the established Gateway approval path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cac0c021273a. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
8a1c8a8 to
37657e2
Compare
|
@clawsweeper re-review The PR body now records completed boundary proof for head |
|
🦞👀 Re-review progress:
|
Consolidate channel-local control flows and use documented SDK owners directly. Remove redundant forwarding layers and declarations while preserving transport, authorization, credential, formatting, and persistence contracts. Accept the existing Matrix system-agent approval kind during registration and persisted lookup. Stabilize Telegram album replay proof by controlling the existing flush timer after real durable admission. Preserve negative controls and complete media assertions.
Leave the complete legacy thread-binding lifecycle unchanged from main. Its path helper participates in the existing migration boundary; inlining it surfaced runtime file retirement to the database-first guard and would require a broader ownership change.
6a0a9ac to
9a7d42c
Compare
|
@clawsweeper re-review The PR body now records the required real Telegram Test Server userbot evidence on the unchanged reviewed head: same-message streaming with native formatting, reply-context hydration, an authorized native callback, disabled-DM rejection, and confirmed credential/process cleanup. It preserves the initial compound fixture mismatch and distinguishes two agent requests from three Activity recap calls; it does not claim that scripted two-response scenario passed. The Matrix upgrade/approval evidence remains unchanged. Both strict native changed scopes, the final build, and exact-head CI are green. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
81 upstream commits, including the Feishu cleanup in openclaw#158164, which touched 54 Feishu files. Eight of them are files this branch changes too. Three conflicted and were resolved by hand, keeping this branch's behavior and taking upstream's refactor wherever it applies: - presentation-card.ts: upstream folded the per-block returns into one switch. This branch returns several sized elements per text, context and table block, which one return cannot carry, so the branch's bodies stay and upstream's spread push is taken with the branch's argument. - outbound.ts: upstream's createFeishuReplyFanout helper is used at all four call sites, sendMedia takes upstream's parameter type, and upstream's comment trims are kept. The helpers this branch had moved out of the file stay moved. - reply-dispatcher.ts: the card condition keeps this branch's table-aware shouldUseCard. Upstream's void return for rememberStreamingStartFailure auto-merged. Upstream moved the old shouldUseCard into markdown.ts as shouldUseFeishuCard. Its only two callers are the ones this branch replaces with shouldUseCard from card-table-shapes.ts, so nothing called it after the merge and it is removed. markdown.ts now matches this branch. The other files both sides changed, channel.ts, config-schema.ts, send.ts, send.test.ts and the database-workers test list, auto-merged and each equals this branch plus upstream's own hunks. The lockfile and every generated file are unchanged upstream, and build:docker in a separate detached checkout followed by config:channels:gen and config:docs:gen changed nothing. The three generated-file checks pass there. Feishu: 105 files and 2161 tests in the extension project, 15 files and 347 tests in the database-workers project. The forwarder test and the routing guards pass, 2007 tests. oxlint on the 43 changed code files, oxfmt, tsgo:core, tsgo:extensions, tsgo:extensions:test, tsgo:test:root, the line-cap, max-lines and assertion-safety ratchets against upstream/main, and deadcode:exports all pass.
The formatter refactor in #158164 folded format-render.ts into format.ts. Keep the existing format.ts code reference and remove the obsolete path so the scenario catalog reference check follows the current owner.
* refactor: share filesystem admission, walks, and cleanup with fs-safe * style: satisfy lint in fs-safe adoption changes * test(daemon): map fs-safe reads into launchd fixtures Keep the real fs-safe reader and its descriptor admission on the fixture backing files. Load fixture mocks before filesystem consumers and move shared state out of the oversized launchd suite. * test(gateway): assert missing transferred manifest by errno * fix(qa): drop retired Telegram formatter reference The formatter refactor in #158164 folded format-render.ts into format.ts. Keep the existing format.ts code reference and remove the obsolete path so the scenario catalog reference check follows the current owner. * fix(qa): preserve exact worktree cleanup identity Keep the original bigint device and inode comparison when replacing the local forwarding helper. The general fs-safe matcher tolerates unknown Windows identity fields and cannot authorize destructive cleanup. Four real-directory receipt regressions fail the previous candidate; 35 cleanup/runtime cases and changed checks pass, with clean independent review.
…penclaw#158164) * refactor(channels): deslop telegram, matrix and feishu second pass Consolidate channel-local control flows and use documented SDK owners directly. Remove redundant forwarding layers and declarations while preserving transport, authorization, credential, formatting, and persistence contracts. Accept the existing Matrix system-agent approval kind during registration and persisted lookup. Stabilize Telegram album replay proof by controlling the existing flush timer after real durable admission. Preserve negative controls and complete media assertions. * refactor(matrix): retain existing thread binding migration owner Leave the complete legacy thread-binding lifecycle unchanged from main. Its path helper participates in the existing migration boundary; inlining it surfaced runtime file retirement to the database-first guard and would require a broader ownership change.
…aw#158313) * refactor: share filesystem admission, walks, and cleanup with fs-safe * style: satisfy lint in fs-safe adoption changes * test(daemon): map fs-safe reads into launchd fixtures Keep the real fs-safe reader and its descriptor admission on the fixture backing files. Load fixture mocks before filesystem consumers and move shared state out of the oversized launchd suite. * test(gateway): assert missing transferred manifest by errno * fix(qa): drop retired Telegram formatter reference The formatter refactor in openclaw#158164 folded format-render.ts into format.ts. Keep the existing format.ts code reference and remove the obsolete path so the scenario catalog reference check follows the current owner. * fix(qa): preserve exact worktree cleanup identity Keep the original bigint device and inode comparison when replacing the local forwarding helper. The general fs-safe matcher tolerates unknown Windows identity fields and cannot authorize destructive cleanup. Four real-directory receipt regressions fail the previous candidate; 35 cleanup/runtime cases and changed checks pass, with clean independent review.
What Problem This Solves
Telegram, Matrix, and Feishu still carried duplicate control flow, private forwarding modules, and repeated type/parameter plumbing after their first cleanup passes. This is the maintainer-requested second pass following #156752, #156777, and #156832.
User Impact
The cleanup preserves channel authorization, verification order, credentials and diagnostics, formatting/media/retry behavior, transport status, public configuration and tools, and stored state. Matrix system-agent approval prompts now accept their advertised reaction decisions, including after persisted-target lookup.
Why This Change Was Made
Cleanup details and ownership
The refreshed head is
9a7d42c5818655eb5e978cdc9794fbe091f7e59a, based ond07b710d85220c18b2186d57cd33e2276ba2da38.git range-diffreports both lane commits unchanged, and the complete Telegram, Matrix and Feishu Git trees match the tested6a0a9accandidate. Existing component/upgrade proofs are retained with their original identities. Current-head hosted CI is green (117 passed, 20 skipped), both strict native check scopes passed, and the final build passed in 521s.The public plugin artifacts retain their exports. No SDK exports, dependencies, manifests, configuration keys, or model-facing tool schemas change.
Config and upgrade compatibility confirmed: a complete local audit of the 315-file base-to-head diff (not GitHub's truncated file list) verifies unchanged manifests, package metadata, public config keys, schema declarations and defaults. Telegram retains token admission/precedence and effective inherited policy validation; Feishu retains setup defaults and ordered webhook-secret inheritance; Matrix retains auth precedence, encryption defaults, credential revocation guards, the registered Doctor adapter and legacy-state precedence. The published-updater proof below covers the refactored Matrix migration paths. No new configuration or operator migration action is required.
Fixes found along the way
Matrix's native approval runtime already emits system-agent prompts, but reaction-target registration and persisted reads accepted only exec/plugin kinds. Both guards now accept the existing system-agent kind. The regression exercises registration, decision lookup, and persisted recovery without weakening sender authorization.
The Telegram durable album replay E2E fixture raced its real 40 ms flush deadline against asynchronous SQLite-backed admission. It now holds that existing timer, waits for real backlog admission, verifies both claims and no downstream turn, then flushes with unchanged two-photo and tombstone assertions. The adjacent live-admission case no longer sleeps 5 ms. No production timing, assertion, or retry budget is relaxed.
Evidence
Measured change: 2,934 net production lines removed (271 production files; +2,341 / -5,275). Tests/support add 31 net lines (41 files; +304 / -273). No SDK exports, dependencies, manifests, configuration keys, or model-facing tool schemas change.
pnpm test:extensions:batch matrix: 160 files, 2,518 tests passed; 289s wall.pnpm test:extensions:batch feishu: 110 files, 2,174 tests passed; 103s wall.pnpm test:extensions:batch telegram: 164 files passed; its one failing voice-fixture file needed the SDK mock cutover. The corrected file passed all 50 tests (75s), and all ten shared-fixture consumers passed another 153 tests (286s). The initial batch reported 2,579 passing tests and four failures in that one file (1,955s).release→holdlane-occupancy mutation failed the two-claim assertion, admitting only update 201 instead of 201 and 202. The restored implementation passed 20 targeted Linux repetitions. Six completed before a provider lease ended; fourteen completed on the next lease. The interrupted attempt is not counted.node scripts/check-changed.mjspassed the changed-file policy/format/Doctor/config/boundary checks, then both scopes stopped at the pre-existingagents-roottypecheck budget: 721 roots against 720, introduced by fix(models): retain discovery failures across provider aliases #158139. Hosted CI treats this limit as advisory; the native route remains strict. Main subsequently fixed the overflow ind07b710d85220c18b2186d57cd33e2276ba2da38by reassigning session roots with unchanged limits/coverage. This PR is rebased onto that fix; no duplicate follow-up is needed. Both strict native scopes passed withGITHUB_ACTIONSandGITHUB_STEP_SUMMARYunset: complete plugin/docs/baseline scope in 914s, core export-consumer scope in 318s. Together they cover all 315 changed paths without relaxing limits. Earlier runs passed all 25 core test typecheck shards, extension types and all three unused-export scans. The eight final lint consumers passed 206 tests in 87s; rebased lifecycle/storage consumers passed 437 tests across 20 files in 988s. The exact stale Drive max-lines exemption was removed.pnpm check:architecturepassed in 236s. Current-headpnpm buildpassed in 521s, including SDK export and artifact checks; current strict changed checks also passed the database-first and import-cycle guards.[email protected]→ candidate-tarball update passed (420s including package/registry preparation). Immediately after the installed updater and before standalone Doctor, the dedicated read-only probe verified all four Matrix migrations: eight byte-exact archived JSON files, five correct fresh-import rows including the sync digest, and five pre-existing canonical rows preserved byte-for-byte with timestamps/expiries. Native update outcome wassuccess, with no recovery. The later native Gateway checks passed: startup 22s; health, readiness and RPC status 1s each. The genericfirstHopPostCorefield was unavailable in this scenario; the dedicated Matrix probe supplied the boundary observation. No idempotence or live Matrix transport claim is made.Observed Telegram Test Server proof
Real Telegram Test Server userbot capture on head
9a7d42c5818655eb5e978cdc9794fbe091f7e59a(verified tree838956c75d02a87081f48b59101d761b2c437efd, carrier7a9e75b9b78c2b012dd572960631dc87b08567d7) used the canonical runner, a leased QA user/bot, an isolated built Gateway, and the local mock model provider. The recording completed; all four sends, one callback click, and the run-owned policy patch completed. This is real channel transport with synthetic model output.Sanitized command:
node .agents/skills/telegram-e2e-userbot/scripts/run-mock-sut-user-e2e.mjs --backend mock --dm --gateway-port <isolated-port> --mock-port <isolated-port> --scenario <synthetic-scenario.json> --timeout-ms 95000 --record <private-events.ndjson> --output <private-summary.json>.messageTextcontains bold overReply context probe, italic oversecond streaming turn, and inline code oversource retained. These are native entities, not inferred Markdown appearance.[reply target]and[Replying to: ...]; its reply at 13,177ms targets the follow-up's own receipt./models openaiproduced the native model menu; the completed Back callback (37ms) changed that same observed message toSelect a provider:.dmPolicy: disabledpatch completed readiness before the final send. No denied input appears in any provider request, and no SUT content appeared during the remaining 32,957ms of complete recording.Fixture mismatch retained: the initial compound judge expected two provider requests and two specific scripted streaming responses. The capture actually contains two agent requests plus three Activity recap utility requests; those utility calls consumed global mock response slots. The first chat turn therefore streamed the second prepared response, and the second returned the mock's fallback marker. This is not reported as a passing two-response script. The observed first streaming reply, receipt-linked reply context, native callback, and disabled-DM rejection above provide the required touched-flow proof without rerunning solely to polish the fixture. No incoming-user-edit, second streamed reply, client screenshot/appearance, live Matrix, or live Feishu claim is made. The native runner leaves its synthetic DM messages; message deletion is not claimed.
The fixtures use the canonical SDK owners and complete Matrix events. Existing assertions, timeouts, and retry budgets remain intact. The oversized Matrix handler test now uses its shared reaction harness.
Remote execution and lease lifecycle
All heavy commands ran through
node scripts/crabbox-wrapper.mjswith providerblacksmith-testbox, frozen-lockfile installation, and one active command per lease. Initial source snapshots used basee6df676ad11163215954b234aa3238536586534cplus the wrapper-verified lane patch. The earlier package-proof candidate was rebased onto9e5c2e2458416d5491be7135757f92151592bfe2, preserving the intervening async Telegram binding and Matrix filesystem changes. Final package proof used carrier3ec924ccbb8cdefe085ea71fa2eb7bdea0da5c07, whose tree53a015d745f9475d3cc28412f54c8af9a48a2b21was verified equal to PR head6a0a9acce3c0c039e0192c877365f1fd0e44a7d6. The shallow-checkout preflight was repaired by supplying the exact hash-checked original commit object; no identity check was removed. All eight Testbox leases are stopped after the final checks and live capture. Testbox workflow conclusions reflect lease teardown; command results above are the validation evidence.tbx_01m3bt183r43vsztg778mg70hbtbx_01m3bzczk1vvcjnj9c1en8gy33tbx_01m3c2b3dkxc5b51f7w0b7acrytbx_01m3c8d0pjxhbe7zzkvr3n79pjtbx_01m3cd77bg7senq9r1wpdgytadtbx_01m3cgr61daa19exsgfg7vqqq1tbx_01m3cjrxhgs9arcr8cdwtpvdedtbx_01m3cqkehcyj5rq0d8h3291m5nChanged test costs on Linux Testbox
Each file was run individually with
pnpm test <file> --maxWorkers=1; these are command wall times including preparation. The CI case-time column records the available per-test measurements. Initial head CI stopped at the database-first guard: inlining the legacy binding-path helper exposed its existing runtime retirement. The complete thread-binding migration module is now unchanged from main. Pre-rebase CI then completed 1,174 Node tests in compact-large-8 before Bun canary1.4.3-canary.1(ddfce5d01) crashed during worker startup with SIGSEGV (429ms, before tests). Fail-fast cancelled the remaining checks, including architecture. The exact-input diagnostic replay passed the 17-file Bun subset (232 tests; 44.38s). CI attempt 2 is green on6a0a9acce3c0c039e0192c877365f1fd0e44a7d6: 118 checks passed, 20 skipped. That pre-rebase PR rollup had 140 passing and 47 intentionally skipped checks. No source, assertion, timeout, retry budget or runtime pin changed for that replay; the original native crash remains unexplained. Current-head CI is green on9a7d42c5818655eb5e978cdc9794fbe091f7e59a: 117 passed, 20 skipped.extensions/telegram/src/bot-message-context.body.test.tssrc/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.tsextensions/matrix/src/matrix/monitor/handler.group-history.test.tsextensions/matrix/src/matrix/monitor/handler.reaction-owner.test.tsextensions/matrix/src/matrix/monitor/handler.test.tsextensions/feishu/src/app-registration.test.tsextensions/feishu/src/bot.test.tsextensions/feishu/src/send.test.tsextensions/matrix/src/approval-reactions.test.tsextensions/matrix/src/channel.resolve.test.tsextensions/matrix/src/doctor.test.tsextensions/matrix/src/matrix/client.test.tsextensions/matrix/src/matrix/client/backfill.test.tsextensions/matrix/src/matrix/monitor/handler.reply-presentation.test.tsextensions/matrix/src/matrix/monitor/replies.presentation.test.tsextensions/matrix/src/matrix/monitor/reply-context.test.tsextensions/matrix/src/matrix/monitor/thread-context.test.tsextensions/matrix/src/matrix/probe.test.tsextensions/matrix/src/matrix/sdk/client-transaction-scope.test.tsextensions/matrix/src/matrix/sdk/transport.authority-integration.test.tsextensions/matrix/src/matrix/send.test.tsextensions/telegram/src/bot-handlers.inbound-pipeline.test.tsextensions/telegram/src/bot-message-dispatch.progress-lifecycle.telegram-http.test.tsextensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.tsextensions/telegram/src/bot.forum-ingress.response-body-timeout.integration.test.tsextensions/telegram/src/bot.media.downloads-media-file-path-no-file-download.test.tsextensions/telegram/src/fetch.socks.test.tsextensions/telegram/src/fetch.test.tsextensions/telegram/src/model-callback.loopback.integration.test.tsextensions/telegram/src/outbound-adapter.telegram-http.test.tsextensions/telegram/src/probe.test.tsextensions/telegram/src/rich-plain-fallback.test.tsextensions/telegram/src/send.proxy.test.tsextensions/telegram/src/send.recovery.telegram-http.test.tsextensions/telegram/src/telegram-ingress-coalescing.e2e.test.tsextensions/telegram/src/telegram-ingress-supersede.test.tsCI case time sums reported test-case durations from the exact-head plugin jobs; it excludes shared startup/build work and is not per-file wall time. “Not attributed” means these CI logs do not provide a matching measurement.