fix(msteams): reset sessions on app removal lifecycle#104690
fix(msteams): reset sessions on app removal lifecycle#104690jimmypuckett wants to merge 38 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 19, 2026, 9:51 PM ET / July 20, 2026, 01:51 UTC. Summary PR surface: Source +950, Tests +1098, Docs +4, Generated 0, Other +2. Total +2054 across 25 files. Reproducibility: no. high-confidence current-main reproduction was run in this review. The pre-fix path is source-reproducible and the PR provides a concrete live Teams removal/re-add observation, but confirming the current-main failure still requires a real Teams deployment. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Keep one generic, documented lifecycle-reset primitive only if plugin and session owners explicitly accept it as the stable cross-plugin contract; otherwise redesign the Teams repair behind an existing owner-local seam. Do we have a high-confidence way to reproduce the issue? No high-confidence current-main reproduction was run in this review. The pre-fix path is source-reproducible and the PR provides a concrete live Teams removal/re-add observation, but confirming the current-main failure still requires a real Teams deployment. Is this the best way to solve the issue? Unclear. The Teams behavior is a focused repair, but exposing a new public lifecycle-reset and harness-owner contract is only the best solution if owners want that generic Plugin SDK capability. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 27f05c8993fb. Label changesLabel justifications:
Evidence reviewedPR surface: Source +950, Tests +1098, Docs +4, Generated 0, Other +2. Total +2054 across 25 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (48 earlier review cycles; latest 8 shown)
|
|
Updated this PR branch to address ClawSweeper's author action on the published personal-fork PR head. What changed:
The blocker is addressed by rotating matching Teams lifecycle entries even when Local validation on
I will wait for GitHub CI on this pushed head before requesting ClawSweeper re-review. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Refreshed this PR branch again because New pushed head: What changed in this refresh:
Local validation on
I will wait for GitHub CI on this refreshed head before requesting another ClawSweeper re-review if needed. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Addressed ClawSweeper's current P1 author action on exact head New pushed head: What changed:
Local validation:
I will wait for GitHub CI on |
|
Fixed the two exact-head CI failures from New pushed head: Root cause:
Fix:
Local verification:
I will wait for GitHub CI on |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Addressed ClawSweeper's current P1 on exact head New pushed head: What changed:
Local validation:
I will wait for GitHub CI on |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head validation for
This addresses ClawSweeper's concrete P1 session-mutation guard finding. The remaining item is the maintainer decision on the public lifecycle-reset and locked-harness handoff contract. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head validation for
The restored ownership guards for |
|
Exact-head CI status for
This is a transient runner timeout outside the contribution diff. I attempted a failed-job-only rerun, but GitHub requires repository admin rights for this workflow. No unrelated CLI change is being added to this PR. |
|
Exact-head CI status for
This is a timing-sensitive process test outside the contribution diff. Two failed-job-only rerun attempts were also blocked by transient GitHub Actions API 503 responses. No unrelated process change is being added to this PR. |
|
Exact-head validation for
The merge preserves upstream's settled-turn Plugin SDK exports plus this PR's |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head validation for
The merge preserves upstream's current Plugin SDK setup surfaces while retaining the public |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head CI status for
This is a timing-sensitive upstream CI failure. No unrelated system-agent or TUI change is being added to this PR. |
…neage-20260713 # Conflicts: # docs/.generated/plugin-sdk-api-baseline.sha256 # scripts/plugin-sdk-surface-report.mjs
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(msteams): reset sessions on app removal lifecycle This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Exact head 0622029: CI is otherwise complete, but security-fast fails its production-dependency audit on upstream's brace-expansion advisory GHSA-mh99-v99m-4gvg (range <=5.0.7). This PR does not modify package manifests or pnpm-lock.yaml, so there is no scoped branch repair to apply. |
Closes #99054
What Problem This Solves
Fixes an issue where Microsoft Teams users who remove a personal app/bot and later add it again can continue the same OpenClaw server-side DM session, allowing the bot to use prior conversation context after an app lifecycle boundary.
This targets Teams app-management lifecycle signals that the bot can actually observe. Live capture showed Teams' local "Remove chat history" action can arrive later as an ordinary message in the same personal
conversation.id, with noinstallationUpdate,conversationUpdate,membersAdded, ormembersRemovedactivity. This PR does not claim to detect that fully local clear-chat action when Teams gives the bot no lifecycle or conversation-boundary signal.Why This Change Was Made
Teams now routes
installationUpdateremoval activities and botmembersRemovedconversation updates into a lifecycle handler. On a removal boundary, the handler removes the cached Teams conversation reference, rotates the matching OpenClaw session entry to a new session id withupdatedAt: 0, and clears provider-owned route/delivery/origin metadata so the next inbound message cannot resume the removed chat transcript.The handler also treats a personal
installationUpdate action=addas a reinstall boundary only when an existing route-matched Teams DM session is already active. That catches tenants or flows where the re-add signal is visible but the prior remove signal was missed, without resetting first-time installs. Finally, inbound personal DMs check for a stored same-user/same-bot conversation reference with a different Teamsconversation.id; when Teams exposes that boundary, OpenClaw removes the previous reference and rotates the DM session.User Impact
After a true Teams app removal and re-add, the next inbound message starts from a fresh OpenClaw session instead of silently resuming prior DM or channel context. Operators also avoid retaining a cached proactive-send reference for the removed Teams conversation.
For Teams clear-chat/reopen flows, the patch protects the observable case where Teams gives the bot a new personal conversation id. If Teams reuses the same server-side conversation id and sends no lifecycle event, there is no bot-visible signal in the captured payloads; that remains a Teams platform limitation rather than a claim made by this PR.
Existing welcome-card behavior, normal messages, reactions, and unrelated lifecycle events are unchanged.
Evidence
installationUpdate action=remove.msteams lifecycle remove handled,reason=installation-remove,conversationType=personal,conversationRemoved=true,sessionsReset=1.updatedAt: 0and no Teams route/delivery/origin metadata.Remove chat historyfollow-up after deploying this branch:Remove chat history, opened the app/chat again, and sent a verification prompt.installationUpdate add, lifecycle/remove activity, or DM conversation-boundary handler log appeared.installationUpdate/removeinstallationUpdate/remove-upgradeinstallationUpdate/addwith no active sessioninstallationUpdate/addwhen an existing session is activeinstallationUpdate/addmembersRemovedmembersRemovedinstallationUpdateandmembersRemovedactivities to registered lifecycle handlers.pnpm test extensions/msteams/src/monitor-handler/lifecycle-handler.test.ts- 11 tests passed.pnpm test extensions/msteams/src/monitor-handler/message-handler.authz.test.ts- 18 tests passed.pnpm test extensions/msteams- 71 files passed, 1007 tests passed.pnpm run lint:extensions:bundled- passed.pnpm format:check extensions/msteams/src/monitor-handler/lifecycle-handler.ts extensions/msteams/src/monitor-handler/lifecycle-handler.test.ts extensions/msteams/src/monitor-handler/message-handler.ts- passed.git diff --check- passed.Migration note: This PR replaces #100371 with the same published head commit, moved from
spinen/openclawtojimmypuckett/openclawso OpenClaw maintainers and repository automation can update the contribution without transferring authorship. Prior review, proof, and CI history remain available on #100371.