Repository navigation
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this PR targets the same Mattermost thread-history recovery bug as the open canonical sibling, but its process-lifetime root gate misses same-process session-clear recovery that the sibling handles with a session-aware gate and stronger proof. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this branch and consolidate review on #93243 as the canonical Mattermost thread-history recovery fix. So I’m closing this here and keeping the remaining discussion on #93243. Review detailsBest possible solution: Close this branch and consolidate review on #93243 as the canonical Mattermost thread-history recovery fix. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main keeps Mattermost thread history in a process-local map, the shared turn kernel clears that map after successful turns, and this PR's gate ignores session id rotation during same-process session clear. Is this the best way to solve the issue? No. The Mattermost plugin is the right owner boundary, but this PR's process-lifetime root gate is weaker than the session-aware sibling and misses part of the reported recovery case. Security review: Security review cleared: No concrete security or supply-chain concern found; the diff uses the existing authenticated Mattermost client path and changes no dependencies, workflows, lockfiles, package metadata, or secret handling. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 1bccd2930437. |
aa37e9f to
930d6e8
Compare
|
Updated to address the review. The empty-window trigger is now gated on first-sighting recovery (per-process serviced-roots set), so active threads whose window the kernel clears post-turn are never rehydrated and ordinary follow-ups never incur the awaited server fetch. Added the requested regression test ( @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
930d6e8 to
01016e8
Compare
When re-mentioned inside an existing Mattermost thread after a gateway restart or session clear, the in-memory pending-history window is empty, so the bot replied without thread context (openclaw#93204). The original fix fetched the server thread whenever that window was empty. The turn kernel clears the pending-history window after every successful dispatch (src/channels/turn/kernel.ts), so an empty window is ALSO the normal steady state for an active thread. Backfilling on a bare empty window therefore rehydrated the full server thread on ordinary follow-up mentions and added an awaited REST call to the inbound path. Gate the fetch on first-sighting recovery instead: shouldBackfillThreadFromServer tracks thread roots serviced this process and only treats the first empty window for a never-serviced root as restart/session-clear recovery. Active threads whose window the kernel cleared post-turn are never rehydrated. - Add pure shouldBackfillThreadFromServer gate (no network, set-scoped) - Wire monitor.ts to a per-process serviced-roots set - Add regression tests incl. active-thread-cleared-window does NOT rehydrate
9c241d3 to
025dcb1
Compare
Summary
Motivation
Closes #93204.
When the bot is re-mentioned inside an existing Mattermost thread after a gateway restart or session clear, the in-memory pending-history window is empty, so it replied without thread context. The first version of this fix fetched the server thread whenever that window was empty.
As @clawsweeper correctly caught, the shared turn kernel clears the pending-history window after every successful dispatch (
src/channels/turn/kernel.ts→clearPendingHistoryAfterTurn). So an empty window is also the normal steady state for an active thread — backfilling on a bare empty window therefore:The fix
New pure gate
shouldBackfillThreadFromServer(inthread-backfill.ts) distinguishes recovery from steady state by process lifetime:Set.monitor.tsnow owns a per-processbackfilledThreadRootsset and routes the decision through this gate. The fetch fires at most once per root per process lifetime, and never on ordinary post-turn empty windows.Real behavior proof
thread-backfill.tsfunctions (shouldBackfillThreadFromServer,buildThreadBackfillEntries) loaded directly viatsxin a real Node v25 process and driven through the issue scenario against live process state — no test runner, no vitest, no mocked module shim. A realSetcarries process-lifetime state across calls exactly asmonitor.tsuses it.true); the same active thread's next empty window — left behind by the kernel's post-turn clear — returnsfalse, so it does NOT re-fetch or re-inject the server thread (the P1 regression is gone); an active thread that still has in-memory context returnsfalse; andbuildThreadBackfillEntriesreturns the two prior posts in order with resolved sender labels, correctly skipping the current mention (p3). The harness asserts all four and printsPROOF_RESULT: PASS.fetchMattermostThread) is exercised by its own fetch-level unit test; the recovery decision and the mapper are pure and proven above against real process state. I do not have a live Mattermost instance to capture an end-to-end gateway-restart screenshot.Addressing the review P1s
does NOT rehydrate an active thread whose window the kernel cleared post-turn, 12/12 passing) and proven live above.