Repository navigation
refactor(msteams): receive webhooks on Gateway routes - #158939
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 26, 2026, 6:03 PM ET / 22:03 UTC (Revision 9). ClawSweeper reviewWhat this changesThe branch moves Microsoft Teams callbacks onto Gateway HTTP routes, keeps a compatibility port, and migrates explicit old port settings through Doctor. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 6 items remain This PR remains useful: current main still runs a separate Teams webhook server. A previously reported route-collision defect remains in the pinned head, and the stored-config migration still needs published-updater proof before merge. Priority: P2 Review scores
Verification
How this fits togetherAzure Bot sends Teams callbacks to OpenClaw. The Gateway selects a plugin route or compatibility port, then the Teams plugin authenticates and passes accepted activities to its ingress handler. flowchart LR
A[Teams configuration] --> B[Gateway route registration]
B --> C[Gateway and compatibility ports]
D[Azure Bot callback] --> C
C --> E[Express and Teams authentication]
E --> F[Teams ingress]
F --> G[Agent response]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +188, Tests +354, Docs +74, Generated 0, Other 0. Total +616 across 39 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Let the Gateway preserve owner-bound Teams delivery on the compatibility port even when the canonical path conflicts, while Doctor remains the sole writer of migrated config. Do we have a high-confidence way to reproduce the issue? Yes, from source: register another plugin at the configured Teams path, start Teams with its default compatibility port, and send an Azure Bot callback to that port. This review did not execute that scenario. Is this the best way to solve the issue? No. Gateway ownership is the right direction, but route registration currently makes old-port delivery depend on winning the canonical path; the upgrade path also needs a published-driver check. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c147e0e6521d. LabelsLabel changes: No label 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 (8 earlier review cycles)
|
6b68dd3 to
e843a48
Compare
2b58ce1 to
643ee49
Compare
e843a48 to
bea70cb
Compare
e512d86 to
3e88755
Compare
3e88755 to
3ce6a75
Compare
121 upstream commits, including nine low-value test batches (d027, d039 to d047) and the msteams webhook move to Gateway routes (openclaw#158939). Two files outside the generated set changed on both sides and auto-merged. presentation-card.test.ts loses upstream's own "accepts cards without markdown tables" test (openclaw#159090), which this branch never edited, and keeps the branch's additions. The database-workers routing list takes upstream's new ingress entries (openclaw#159073, openclaw#158848) and keeps the branch's outbound.handoff.test.ts. Two conflicts, both generated: docs/.generated/config-baseline.sha256 and src/config/bundled-channel-config-metadata.generated.ts. Both came from upstream and were regenerated. config-baseline.counts.json auto-merged to 3746 because each side independently took the channel count from 3744 to 3746 (the branch's Feishu entries, upstream's msteams entries), and the real count with both is 3748. build:docker ran in a separate detached checkout of this commit outside the nested node_modules install. Regenerating there changed those three files and nothing else, giving core 2463, channel 3748, plugin 4349 as predicted, a channel hash neither side had, and upstream's core and plugin lines. The three generated-file checks pass there. The lockfile did not move. No test this branch moved was deleted upstream in this range, and the 15 test files upstream deleted outright are ones this branch never touched. Upstream removed 28 Feishu test declarations and this merge removes the same 28. Feishu: 105 files and 1850 tests in the extension project, 17 files and 319 tests in the database-workers project, all 122 Feishu test files on disk. The forwarder test and the routing guards pass, 1955 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 42 changed code files all pass.
* refactor(msteams): mount webhook middleware on Gateway routes * fix(msteams): preserve the default route for empty webhook paths * chore(msteams): regenerate webhook config metadata * test(msteams): retain Express adapter probe fixtures * fix(msteams): retain deprecated webhook port input typing * docs(msteams): track legacy webhook input compatibility * refactor(msteams): test the registered Doctor adapter * fix(msteams): preserve deferred typing and route proof
Related: #157553
What Problem This Solves
Microsoft Teams owns a separate webhook listener even though its HTTP middleware can run through the Gateway route registry.
User Impact
Teams callbacks work on the Gateway route while existing Azure Bot endpoints and reverse proxies keep reaching the old effective port, including implicit wildcard port 3978. After moving the Azure endpoint or proxy upstream to the Gateway route and verifying delivery, set
legacyWebhook: falseto close the compatibility port.Why This Change Was Made
The bounded Express application and the Teams SDK ExpressAdapter stay intact and become the Gateway route handler. This preserves gzip/deflate/br JSON decoding, the decoded 1 MiB limit, parser/error framing, bearer-prefix gating, SDK JWT verification, and the shipped OPTIONS 200
POST/Allow: POSTbehavior. Express remains a Teams-owned dependency.Only private listen/server lifetime and the superseded server-timeout helper are removed. Gateway owns binding and the shipped legacy timeout profile. The handler holds its request scope until response completion; account stop rejects new requests, drains admitted responses within the shipped 30-second window, then releases the route and ingress. Existing Express path patterns remain available on the compatibility port, with actionable guidance before opting out where the canonical Gateway path cannot represent them. Empty webhook paths retain the SDK's
/api/messagesdefault.Plugin-owned Doctor migration moves explicit
webhook.porttolegacyWebhook, retainingwebhook.pathand canonical settings. Existing Doctor backup/write ownership remains unchanged. Implicit defaults are runtime-derived and receive informational guidance; no eligibility/receipt migration, removal deadline or storage schema change is added. The Node request/response handler signature is unchanged.Evidence
Blacksmith Testbox lease
tbx_01m3eaktnkepydcc70cvg93mhe, run 36227573437: frozen install and canonical generators passed. That proof used head35378cae398ec23ef7cb639e5251124edb94e1ba, tree7ecbf0c8a4f35647b5c663b96222c1f4984e69c9.All 143 focused cases across thirteen files pass. Eleven files passed 137 cases before a two-line test-only correction; production bytes are unchanged. Two probe mocks had omitted the retained ExpressAdapter export, producing five failures. Restoring their original entries made both probe suites pass (four cases/14.552 s and two/14.379 s), and those files no longer appear in the final slice diff.
Measured
pnpm test <file> --maxWorkers=1wall costs for changed suites: Doctor API 17.679 s (17 cases), channel 30.036 s (44), SSO ingress 30.467 s (1), monitor status 14.243 s (1), conversation-allowlist lifecycle 16.046 s (5), monitor lifecycle 17.046 s (18), HTTP contract/lifecycle 16.677 s (19), QA adapter 1.612 s (2), private runtime 1.615 s (9). Shared migration/config-tier suites passed 21 additional cases. The channel suite proves plugin-facing Doctor wiring; the SSO boundary verifies authentication before real token I/O and persistence. Cold transforms/imports dominate their wall time; SSO's test body measured 587 ms. No new per-test Gateway boots or sleeps are introduced.SDK surface and exports passed in 3.538/0.137 s. Exact base/head API diff passed in 295.690 s: six reachable declaration effects, no changed direct public signatures, unchanged surface counts.
pnpm buildpassed in 473.853 s; the native-qualified Teams import profile passed in 0.593 s;pnpm check:docspassed in 51.889 s. The shallow-repository glossary coverage limitation is retained where reported. SDK/build artifacts and streamed terminal logs are captured and hash-verified.Deslop and independent Codex reviews are clean, including the empty-path correction and restored probe fixtures. Final merged-main proof after the last slice includes signed/invalid Teams callbacks on both ports, all three compressed encodings, handler-entry log correlation, default/opt-out sockets, explicit Doctor backups and clean shutdown. This slice's current proof is isolated boundary evidence, not a live Azure service claim.
Size
Production +329 / -141 / net +188. Tests/helpers +850 / -496 / net +354. Docs +94 / -20 / net +74. Generated production +11 / -11 / net 0. Growth preserves the approved Express and shutdown contracts while removing private listener ownership.
HTTP Ingress Stack
e693324ad36f.11a11ef164d7.84d71bf32329.5b5712e68db8.8864423309d3.5fd7c3d95e03.c5b1eee71843.Each slice lands through native GitHub-gate auto-merge after its predecessor. At most two PRs are open. Final merged-main live proof is recorded on the last slice.
Final dead-code audit: private-server timeout wrappers/tests, recovering-status publication, lifecycle re-export, QA port reservation and listen-host plumbing are gone. The remaining QA Connector server tests outbound calls, while Express remains the callback adapter required by the shipped contract; no additional deletion was warranted.
Earlier stacked head
e843a48631b8ca2e98b40232a90364763f05ee74preserves main's directmonitor.jsimport and the reviewed empty-path fallback. The final slice now targets main after Feishu merged.MSTeamsWebhookConfig.portstays as a deprecated TypeScript input until the next Plugin SDK major, with a compatibility-registry entry; runtime schemas/readers remain canonical. Its original typed Doctor fixture fails with TS2353 against the removed field and compiles with the restoration. On Blacksmith Testbox leasetbx_01m3evphydkwkf37rb027e791d, run36242669167, Doctor passed 17 cases in 16.938 s and typed-fixture compilation passed in 33.054 s; frozen install and focused docs checks passed. Both the type correction and its metadata completion passed independent Codex P0–P2 review. The final integration and corrective proof are recorded below.Hosted CI run
36248800485caught a Doctor helper exported only for tests. It is now private, and the existing migration/guidance cases exercisemsteamsDoctor.runConfigSequence, the registered production adapter. Independent Codex review of this correction is clean. The current head also incorporates Feishu's shrink-only assertion-baseline correction.On the retired lease
tbx_01m3evphydkwkf37rb027e791d, the earlierb4df59aeba5d2985c53f1b1494dfb00032c65632completed all 13 focused suites (143 cases). Their completion/count/hash records were captured locally. The provider ended the lease before full raw-log download and before test types completed; no typecheck pass is claimed for that attempt. The replacement lease runs the unfinished checks plus Doctor/dead-code checks for the correction.Merged as
8864423309d3b97e33b693f47be5ea4c330fa426after exact-head CI36274604297passed at3ce6a758919ebe7f72c24fb384b9c8d798d129f9. All ten slice commits remained patch-identical through the final rebase.Blacksmith Testbox lease
tbx_01m3f3d79pkgwz7nmzgmwqn25j, run 36250142544, verified the integration correction on exact treed5c32191b73838789c381c63863c0484d4677447before the patch-identical rebase. The focused compiler probe inherits the repository's ES2023 settings without overrides: seven raw Promise.withResolvers calls failed before conversion to the existing SDK helper, and the correction passed in 29.548 s. Full extension test types passed in 77.723 s.All 90 selected cases passed: Doctor17/16.499 s, channel35/28.431 s, lifecycle18/16.516 s, webhook lifecycle19/16.748 s, and SSO ingress1/29.552 s (
pnpm test <file> --maxWorkers=1). The full-slice review found one fixture issue: every URL was sent to the first route. The corrected fixture uses the actual Gateway path canonicalizer and preserves the original URL for Express. Removing the alias now produces404; the old fixture wrongly returned200 in the controlled red case (25.409 s). The correction passed a fresh Codex P0–P2 review; no production finding remained.Auto-merge is enabled for this exact head under the maintainer's direct-arming workflow; enforced GitHub CI remains the merge gate. The installed gh protection route requires explicit squash text, so arming used GitHub's own inspected merge-preview headline/body with the same exact-head precondition.
CI run
36255059516required two assertion-baseline reductions after the QA listener cleanup. Both entries now match the remaining casts. Canonical remote lint also identified four owned type/style issues; the final correction preserves response-promise ownership, accurately types the fixture's asynchronous callback, avoids a hoisted shadow, and stops the Promise executor returning the server object. Fresh Codex P0–P2 review is clean. No suppression or guard classification was added.Final correction proof: Blacksmith Testbox lease
tbx_01m3fb1rtegg2gnjqwphgj5w6e, run 36257977536. The tested tree4668313596ab7fb5ae8b05a69e28e5644da10ca6exactly matches the final committed head. Frozen install10.690 s; canonical three-file lint202.918 s with zero warnings/errors; focused types27.518 s; lifecycle18cases/23.777 s; webhook lifecycle19cases/17.055 s; assertion ratchet21.172 s; all three dead-code export scans43.874 s; compatibility registry12cases, docs, SDK surface, and exports passed. The exact base/head SDK API diff follows on the committed head. Auto-merge was re-armed immediately after publication under the maintainer's updated workflow.The private runtime-export inventory was reduced by the exact removed
keepHttpServerTaskAlivere-export. All classifications and remaining guard assertions stay intact, and the public SDK helper remains available. The seven guardrail cases passed in17.249 s on Testbox; independent Codex review is clean.Resolved previous CI blocker outside this slice: run
36264769039, job108467836017, failstest/scripts/update-restart-module-outcome.test.tsbecause its VM harness has no stub for../../infra/container-environment.js:isContainerEnvironment. Clean maincab45a1600d6dd77652beeba93250cb6aa3d3010reproduced it on Blacksmith Testbox leasetbx_01m3fj6685xazhdekm4s0y7z6t, run 36265303669: frozen install5.266 s;node --experimental-vm-modules --test-reporter=tap --test scripts/tests/update-restart-module-outcome.mjsfailed9of19cases in0.660 s;pnpm test test/scripts/update-restart-module-outcome.test.ts --maxWorkers=1failed with the same cause in2.838 s. Source remained clean and seven raw logs were verified. Per maintainer direction, this needs the updater owner to repair main; no unrelated updater change is included here. Auto-merge remains enabled and required CI remains enforced.The updater owner fixed the fixture in #159127, merged as
734f8658967c6389962ffe29fa1b9ad6911d4bdf. That repair is now incorporated; exact-head auto-merge was re-armed immediately after the push, and CI run36268751990is attached to3e88755b…. No updater changes were added to this slice.Fresh rebase integration proof passed on Blacksmith Testbox
tbx_01m3fnpmda2tr1datqxtzffq32, run 36268853507, pinned to3e88755b2888e6c2b7db2331883bdec1d0b77adc/ tree78a7e9843815c4fa861a85111f096feead8ae6ff: frozen install 8.033 s;pnpm test extensions/msteams/src/monitor.lifecycle.test.ts --maxWorkers=118 cases / 26.702 s;monitor.webhook-lifecycle.test.ts19 / 18.498 s;msteams-ingress.test.ts15 / 31.511 s. The registeredtest/scripts/update-restart-module-outcome.test.tswrapper passed in 2.478 s, confirming the landed owner repair; assertion safety against base734f8658passed in 23.187 s. Exact source and raw log hashes were verified throughout.Previous gate failure: exact-head CI run
36268751990, job108479181734(checks-node-compact-large-25), failed one of 406 cases insrc/gateway/talk/handlers/client-native-actions.test.ts: “keeps native generated input in current-turn custody but out of display and future calls,” withAgentDatabaseRegistryChangedErrorafter the initial asynchronous registry read. The remaining cancelled jobs are not independent failures. The same exception was independently observed on #159105 (run36268149681).Bounded investigation on Blacksmith Testbox
tbx_01m3fnpmda2tr1datqxtzffq32/ run36268853507used clean main734f8658967c6389962ffe29fa1b9ad6911d4bdf: frozen install 3.250 s; the original 17-file/config group throughnode --import tsx scripts/ci-run-node-test-shard.mtspassed 406 cases in 138.153 s;pnpm test src/gateway/talk/handlers/client-native-actions.test.ts --maxWorkers=1passed 23 in 35.504 s. This does not reproduce CI concurrency: the 4-CPU/16.55-GB Testbox admitted the plan's two-worker fallback; CI used eight workers on 8 CPUs/33.23 GB. The replay also retainedCI=1rather than literaltrueand cold task-owned caches. All 25 selected source/input hashes match the failed head. No passing replay is claimed as a fix.Source inspection confirms a memo change while the initial registry read is outstanding; the actual invalidating operation is unidentified. The fixture's local configuration versus the history worker's global configuration is a lead, not a proven cause. Those owners remain unchanged through fetched main
6a17b684c0a; no registry retry, guard weakening, or unrelated source change is included here. The owning repair was subsequently adopted, both remaining slices merged with green required gates, and the final merged-main proof passed.The registry blocker is now addressed by the existing owner repair
3d903819c5641ed8735aebe55c86844957009952. Before adopting it, a matching 8-CPU / 33,229,729,792-byte / Node 24.19.0 Testbox reproduced the original 17-file shard failure on clean main734f8658on its first eight-worker attempt: 405 passed, one failed, 74.383 s. The canonical repair retains the original state/source authority while refreshing registry metadata across registration admission and settlement; no test retry or assertion change is part of this slice.On Blacksmith Testbox
tbx_01m3fsx8p05tcdk3ekzrv4w33a, run 36273055543, the identical original group throughnode --import tsx scripts/ci-run-node-test-shard.mtsthen passed all 406 cases three times on repaired main: 66.856 s, 53.336 s and 53.346 s. Worker admission was observed at eight throughout.pnpm test src/gateway/session-history-worker-lifecycle.test.ts --maxWorkers=1passed 22 cases in 30.145 s. Clean source identities and raw log hashes were verified. An additional instrumented diagnostic passed and observed same-path voice registration, but it is not counted as failure attribution or passing regression proof. The separate fixture repair from the dependency PR was considered and not duplicated after the canonical fix landed.Final merged-main proof passed on
a6b5ed882cb5e7a10e9346d0e1152878a55653a4: all four channels on Gateway and legacy routes, signature rejection, persistent opt-out, Doctor backups/migrations, health-checked proxies, compressed Teams callbacks and clean shutdown. The actual published 2026.9.6 updater also passed after the separate worker-output repair. Exact commands, Testbox lease IDs, socket matrices, limits and observed results are recorded in the Nextcloud Talk and worker-output PRs linked above.