Repository navigation
fix(discord): rejoin threads on unarchive to restore MESSAGE_CREATE events - #111148
fuller-stack-dev merged 3 commits into
Conversation
2db0c92 to
4ee9d6b
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 9:53 PM ET / September 17, 2026, 01:53 UTC (Revision 12). ClawSweeper reviewWhat this changesThe Discord plugin rejoins active threads with bounded lifecycle tracking and regression coverage, while accompanying Slack changes separate an internal lifecycle type and preserve an approval callback’s receiver. Merge readiness✅ Ready for maintainer review This repair remains necessary: current main and v2026.9.4 still ignore active-thread updates. The earlier lifecycle concerns are addressed, Discord’s documentation resolves the previous inspection gap, and no actionable introduced defect was found. Priority: P1 Review scores
Verification
How this fits togetherThe Discord monitor receives thread lifecycle events and maintains the bot’s thread membership so messages can reach OpenClaw. Incoming messages then pass through the existing channel and sender authorization checks before agent dispatch. flowchart TD
A[Discord thread and READY events] --> B[Thread lifecycle listener]
B --> C{Thread archived?}
C -->|Yes| D[Clear claim and close thread sessions]
C -->|No| E[Bounded per-client rejoin claim]
E --> F[Discord membership request]
F --> G[Incoming message authorization]
G --> H[Authorized agent turns]
A -->|Fresh READY clears claims| E
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +39, Tests +190. Total +229 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep thread membership recovery in the existing Discord lifecycle listener, with bounded account-local tracking and unchanged downstream authorization. Do we have a high-confidence way to reproduce the issue? Yes: restart while a thread is archived, then unarchive it through user activity; current source skips membership recovery, and the contributor supplies production before/after evidence. This review did not independently execute that scenario. Is this the best way to solve the issue? Yes: the patch extends the existing lifecycle owner, reuses the REST client, and addresses repeated-update and stale-failure races without introducing configuration or a parallel recovery service. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1fbb41545ec5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
4ee9d6b to
d1d8a2d
Compare
Real behavior proof — production deploymentDeployed this patch to a production OpenClaw gateway (Discord channel, mojo agent). Here's the observed lifecycle: Before patch (2026-07-18): threads archived, never rejoinedUser reported bot unresponsive in thread After patch deployed (2026-07-19 01:35+08:00): unarchive → rejoin → messages receivedSummary
|
d1d8a2d to
90bd57a
Compare
90bd57a to
1ff1b96
Compare
1ff1b96 to
fc504b9
Compare
|
Addressed the lifecycle blocker in
Validation:
The earlier production proof remains applicable; this update bounds when membership reconciliation runs. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Security-sensitive guard clearedThis PR no longer has blocked security-sensitive file changes. A future security-sensitive change requires a fresh
|
|
Merged via squash.
|
Reuse the published UI and native closure fixes from openclaw#150026 and openclaw#114032. Match the landed Slack correction from openclaw#111148, including openclaw#150457. Keep the qualified ACP production code and SDK proof unchanged. Co-authored-by: pash-openai <[email protected]>
* fix(acp): order new session response before updates Change-Id: I162e6670e72e5e2aa9d1b2a70d8a02f18dd82e05 * test(acp): prove stdio session ordering * test(acp): close startup input before ordering proof * fix(acp): use canonical record guard for session ordering * fix(acp): bound session tracking and route sink failures to shutdown Two lifecycle defects remained on the ordering boundary. observeInbound recorded params.sessionId for every inbound message, so a valid-shaped session/prompt naming a session the translator later rejects still added an ID that was never reaped -- a peer could grow the set for the lifetime of the process. Only session/load and session/resume assert a session that already exists; session/new is now correlated by JSON-RPC request ID so an ID is established by the response that introduces it. Every collection is peer-driven, so all three are bounded and fail open: overflow writes the update through in arrival order, because dropping one loses session content while emitting one early only restores the pre-fix ordering. session/close releases anything still buffered instead of stranding it. pipeTo rejects when the NDJSON writer or stdout fails, and that promise was discarded. The ACP client is already unreachable at that point, but the Gateway connection and shared state database stayed open. It now flows through the same idempotent shutdown owner as EOF and SIGTERM. * fix(acp): only buffer updates a new-session response can still release The previous round bounded the collections but not the consequences of those bounds, leaving two ways an update could be held forever. Evicting the oldest correlation to admit the 65th session/new dropped the only thing that could drain that session's buffered initial update: the client received the result and never received the update, which is the silent stall this boundary exists to fix. Correlations are no longer evicted. Past the cap a request is left uncorrelated and its response is matched by count instead, falling back to the session ID the response already carries -- our own outbound payload rather than peer input. establishedSessionIds was never bounded or released, so a long-lived bridge grew it for every loaded, resumed, and created session. It is now released on session/close and bounded; past the bound, established and pending are no longer distinguishable, so buffering stops rather than holding updates that might never come back out. Underneath both: an update is only ever buffered while some session/new response can still release it. Nothing else introduces a session ID, so buffering outside that window strands it by construction. When the last correlation resolves, anything still buffered is written through in arrival order. * fix(acp): retire an overflow correlation slot on a failed creation The count-based fallback for session/new requests past the correlation cap was only consumed by a response that carried a session ID. A creation that failed returned a JSON-RPC error instead, so its slot stayed behind and the next unrelated response carrying a session ID was mistaken for it, flushing a session the protocol never introduced. The slot is now retired by the first uncorrelated response whatever it carries: a result establishes the session, an error simply frees the slot. Retiring it can also remove the last thing able to release a buffered update, so the reachability check runs on that path too. * fix(acp): fail open when new-session correlation saturates The count-based fallback for requests past the correlation cap could be consumed by any uncorrelated response. An ordinary RPC reply arriving while the overflowed session/new was still outstanding took its slot, so that session's own result no longer established it, and its update could ship ahead of the result -- the ordering failure this boundary exists to prevent, reached from the other side. A response is now matched only by its own request ID. Past the cap the request is simply not correlated and the boundary fails open until the tracked correlations drain: while saturated no update is buffered, so ordering degrades to pre-fix behaviour rather than risking either a strand or a cross-association. Correlations are still never evicted, so every tracked request resolves and saturation always clears. This removes the counter and both of its branches rather than adding a third guard to it. * fix(acp): keep buffered updates in global arrival order The buffer was a map keyed by session, so releasing it walked one session at a time. Two creations emitting A1, B1, A2 and then both failing put A1, A2, B1 on the wire, reordering updates across sessions against the arrival-order guarantee this boundary is supposed to provide. Buffered updates now live in a single array in arrival order, and that array is the only thing that decides ordering. Draining one session filters it in place, preserving the order of everything left behind. The per-session counts that enforce the bounds move to a separate map that is never consulted for ordering, so there is one ordering path rather than two. * refactor(acp): rebuild the ordering boundary around two invariants Six rounds of point fixes each introduced the next defect, so the state machine is rebuilt rather than patched again. Everything now follows from two rules: An update is queued only while some session/new response can still release it. Nothing else introduces a session ID, so queuing outside that window strands it by construction. The queue drains strictly from the front and stops at the first update that is still blocked, so releasing never emits an update ahead of one that arrived earlier. Three defects fall out of that directly. Correlations now settle only on frames shaped like JSON-RPC responses, so an agent-initiated request whose client-chosen id collides with an in-flight session/new no longer releases that session's updates early. Draining no longer lifts one session's entries out of the middle of the queue, so a later update cannot overtake an earlier one when its own creation settles first. Tracking saturation is recomputed rather than latched, so session/close frees capacity and ordering resumes instead of failing open for the life of the process. The released-updates side channel is gone: inbound events only change state, and the next outbound frame drains the one queue. * fix(acp): never clear correlation saturation Saturation was cleared once the tracked correlations drained, on the claim that this was the first provable quiescent point. It is not: an overflowed session/new is by definition not in that set, so the set emptying says only that the tracked requests finished. A later tracked creation could then re-enable queuing and drain the overflowed session's update ahead of its own result, which is the failure this boundary exists to prevent. There is no point at which an uncorrelated creation is provably gone, so the flag is never cleared. Once correlation has overflowed the boundary stays failed open, trading ordering for a guarantee it can still honour. * fix(acp): size the ordering bounds above what the bridge admits The 64-request correlation cap sat below the agent's own admission limit, which allows well over a hundred creations in its default window. An ordinary accepted burst therefore overflowed it and, since saturation is never cleared, permanently disabled ordering for the rest of the process: the exact-head trace recorded 140 updates ahead of their results. The correlation set is now uncapped. An entry is one short string, it is removed by the response to its own request, and every entry costs the peer a real session creation, so the agent's admission limit bounds it long before memory does. Saturation and its permanent fail-open go with it. MAX_QUEUED_SESSIONS had the same defect for the same reason and is raised above the admission limit; the per-session bound is unchanged. * fix(acp): track established sessions until they close The 1,024-session bound was the third instance of the same defect: once a long-lived bridge reached it, established and pending sessions became indistinguishable and ordering was given up for the rest of the process. It is removed rather than raised. Every entry corresponds to a session that is live on the Gateway side, which costs orders of magnitude more than the ID string held here, and session/close releases it, so this set can never be the binding constraint. Two bounds remain, both on the queue itself, which holds messages rather than identifiers: MAX_QUEUED_SESSIONS sits above what the agent admits, and MAX_QUEUED_UPDATES_PER_SESSION bounds a single session's initial burst. Both fail open in the direction that only degrades ordering, never delivery. * fix(acp): follow the session store's lifecycle and drop the last cap Two owner-boundary defects, both at the seam between this boundary and the work the bridge actually accepts. MAX_QUEUED_SESSIONS was the fourth cap to sit below accepted traffic. The admission limit is a rate, not a concurrency bound; a slow backend can hold more accepted creations outstanding than any fixed number, and update N+1 then bypassed the queue ahead of its own result. It is removed. The number of sessions with queued updates is the number of accepted creations still outstanding, which the bridge already bounds. The per-session cap stays: it is the one bound that holds messages rather than work the bridge admitted. establishedSessionIds was released only by an inbound session/close, but the store reaps idle sessions and evicts at capacity without producing any ACP request, so a long-lived bridge kept recognizing sessions the store had discarded. The store now reports every removal through onSessionRemoved, and server.ts injects a store wired to the boundary's forget(), so recognition follows the store's own lifecycle rather than only the close requests a client chooses to send. The injected store is disposed on the bridge's shutdown path since injected stores stay caller-owned. Rebased onto current main. * fix(acp): retire a loaded session the agent rejects session/load and session/resume were established on arrival, before the agent validated them. A rejected load -- one carrying per-session MCP servers, for instance -- left its client-chosen ID recognized until close or store removal. With the established set now uncapped, that is a growth vector a peer controls. The ID is still established provisionally on arrival so a loaded session's updates are never delayed; the request is remembered by JSON-RPC ID, and an error response retires the session it named. Bounded by in-flight loads, each of which is real work, and cleared by its own response. * fix(acp): only retire recognition a rejected request introduced The previous commit retired the session named by any failing load or resume. A session that was already established and merely reloaded lost its recognition when that reload failed, so its later updates waited behind an unrelated pending creation -- the delay this boundary exists to avoid, and which it explicitly promises not to impose on existing sessions. Only recognition a request introduces is provisional now: the request is remembered for retirement only when it established the ID itself. * fix(acp): keep updates behind their session's backlog; separate claims from confirmation Two concurrency defects at the boundary, both introduced by earlier repairs. Strict front-of-queue draining preserved cross-session order but let a session overtake itself: with A1, B1, A2 queued and A's result in, the drain emitted A1 and stopped at B1, leaving A2; a later A3 then passed straight through because A was established, so the client saw A3 before A2. A session with updates still queued now keeps queuing regardless of recognition, so its later updates wait behind its own backlog. The per-session overflow fails open by releasing that session's backlog in order first, so even the overflow path never reorders within a session. Provisional load/resume claims shared the confirmed set, so "already established" could not distinguish a succeeded request from a pending one. Two overlapping loads on one session: the second succeeds, the first is rejected, and the first's retirement erased the second's valid recognition. Claims are now counted per session, separately from confirmation. A session is recognized while confirmed or while any claim is outstanding; a rejection retires exactly its own claim; acceptance confirms. * fix(acp): release a session's backlog when its own result is written Holding one session behind another let a prompt outrun its own output. With A1, B1, A2 queued and A introduced, the global front-only drain emitted A1 and stopped at B1, so A kept queuing; a prompt's end_turn response carries no session ID, never enters the queue, and therefore reached the client ahead of the agent_message_chunk it completed. A session's queue is now released whole when its own result is written, rather than only the run at the head of the shared queue. Sessions are independent streams, so ordering one against another buys nothing the client can observe, while it does delay a session past frames that bypass the queue entirely. Order within a session is unchanged and still exact. The shared queue keeps global arrival order only on the path where no creation can introduce anything, which spans sessions that were never introduced and is the one place a cross-session rule is meaningful. * test(acp): pin the wire order of a prompt response against its own text Captures the ordering boundary at the ACP stdio boundary itself rather than through the ordering class alone: two session/new requests are outstanding at once, so an update for either is held, and the prompt response that completes one of them carries no session ID and so passes through the boundary untouched. Asserted as one five-frame sequence. Frame-by-frame assertions stop at the first divergence, which hides where a displaced frame actually lands - and where it lands is the defect. * test(acp-core): stop shadowing the suite store in the removal-hook test oxlint eslint(no-shadow) flagged the local store in the onSessionRemoved test against the suite-level one. Renamed rather than reusing the outer store: the test needs its own maxSessions and idleTtlMs to reach the eviction paths. * test(acp): keep ordering fixtures type-safe * fix(ci): consume canonical ACP landing prerequisites Reuse the published UI and native closure fixes from #150026 and #114032. Match the landed Slack correction from #111148, including #150457. Keep the qualified ACP production code and SDK proof unchanged. Co-authored-by: pash-openai <[email protected]> * test(update): await report staging before cleanup race --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: pash-openai <[email protected]>
…w#111148) Co-authored-by: Jason (Json) <[email protected]>
* fix(acp): order new session response before updates Change-Id: I162e6670e72e5e2aa9d1b2a70d8a02f18dd82e05 * test(acp): prove stdio session ordering * test(acp): close startup input before ordering proof * fix(acp): use canonical record guard for session ordering * fix(acp): bound session tracking and route sink failures to shutdown Two lifecycle defects remained on the ordering boundary. observeInbound recorded params.sessionId for every inbound message, so a valid-shaped session/prompt naming a session the translator later rejects still added an ID that was never reaped -- a peer could grow the set for the lifetime of the process. Only session/load and session/resume assert a session that already exists; session/new is now correlated by JSON-RPC request ID so an ID is established by the response that introduces it. Every collection is peer-driven, so all three are bounded and fail open: overflow writes the update through in arrival order, because dropping one loses session content while emitting one early only restores the pre-fix ordering. session/close releases anything still buffered instead of stranding it. pipeTo rejects when the NDJSON writer or stdout fails, and that promise was discarded. The ACP client is already unreachable at that point, but the Gateway connection and shared state database stayed open. It now flows through the same idempotent shutdown owner as EOF and SIGTERM. * fix(acp): only buffer updates a new-session response can still release The previous round bounded the collections but not the consequences of those bounds, leaving two ways an update could be held forever. Evicting the oldest correlation to admit the 65th session/new dropped the only thing that could drain that session's buffered initial update: the client received the result and never received the update, which is the silent stall this boundary exists to fix. Correlations are no longer evicted. Past the cap a request is left uncorrelated and its response is matched by count instead, falling back to the session ID the response already carries -- our own outbound payload rather than peer input. establishedSessionIds was never bounded or released, so a long-lived bridge grew it for every loaded, resumed, and created session. It is now released on session/close and bounded; past the bound, established and pending are no longer distinguishable, so buffering stops rather than holding updates that might never come back out. Underneath both: an update is only ever buffered while some session/new response can still release it. Nothing else introduces a session ID, so buffering outside that window strands it by construction. When the last correlation resolves, anything still buffered is written through in arrival order. * fix(acp): retire an overflow correlation slot on a failed creation The count-based fallback for session/new requests past the correlation cap was only consumed by a response that carried a session ID. A creation that failed returned a JSON-RPC error instead, so its slot stayed behind and the next unrelated response carrying a session ID was mistaken for it, flushing a session the protocol never introduced. The slot is now retired by the first uncorrelated response whatever it carries: a result establishes the session, an error simply frees the slot. Retiring it can also remove the last thing able to release a buffered update, so the reachability check runs on that path too. * fix(acp): fail open when new-session correlation saturates The count-based fallback for requests past the correlation cap could be consumed by any uncorrelated response. An ordinary RPC reply arriving while the overflowed session/new was still outstanding took its slot, so that session's own result no longer established it, and its update could ship ahead of the result -- the ordering failure this boundary exists to prevent, reached from the other side. A response is now matched only by its own request ID. Past the cap the request is simply not correlated and the boundary fails open until the tracked correlations drain: while saturated no update is buffered, so ordering degrades to pre-fix behaviour rather than risking either a strand or a cross-association. Correlations are still never evicted, so every tracked request resolves and saturation always clears. This removes the counter and both of its branches rather than adding a third guard to it. * fix(acp): keep buffered updates in global arrival order The buffer was a map keyed by session, so releasing it walked one session at a time. Two creations emitting A1, B1, A2 and then both failing put A1, A2, B1 on the wire, reordering updates across sessions against the arrival-order guarantee this boundary is supposed to provide. Buffered updates now live in a single array in arrival order, and that array is the only thing that decides ordering. Draining one session filters it in place, preserving the order of everything left behind. The per-session counts that enforce the bounds move to a separate map that is never consulted for ordering, so there is one ordering path rather than two. * refactor(acp): rebuild the ordering boundary around two invariants Six rounds of point fixes each introduced the next defect, so the state machine is rebuilt rather than patched again. Everything now follows from two rules: An update is queued only while some session/new response can still release it. Nothing else introduces a session ID, so queuing outside that window strands it by construction. The queue drains strictly from the front and stops at the first update that is still blocked, so releasing never emits an update ahead of one that arrived earlier. Three defects fall out of that directly. Correlations now settle only on frames shaped like JSON-RPC responses, so an agent-initiated request whose client-chosen id collides with an in-flight session/new no longer releases that session's updates early. Draining no longer lifts one session's entries out of the middle of the queue, so a later update cannot overtake an earlier one when its own creation settles first. Tracking saturation is recomputed rather than latched, so session/close frees capacity and ordering resumes instead of failing open for the life of the process. The released-updates side channel is gone: inbound events only change state, and the next outbound frame drains the one queue. * fix(acp): never clear correlation saturation Saturation was cleared once the tracked correlations drained, on the claim that this was the first provable quiescent point. It is not: an overflowed session/new is by definition not in that set, so the set emptying says only that the tracked requests finished. A later tracked creation could then re-enable queuing and drain the overflowed session's update ahead of its own result, which is the failure this boundary exists to prevent. There is no point at which an uncorrelated creation is provably gone, so the flag is never cleared. Once correlation has overflowed the boundary stays failed open, trading ordering for a guarantee it can still honour. * fix(acp): size the ordering bounds above what the bridge admits The 64-request correlation cap sat below the agent's own admission limit, which allows well over a hundred creations in its default window. An ordinary accepted burst therefore overflowed it and, since saturation is never cleared, permanently disabled ordering for the rest of the process: the exact-head trace recorded 140 updates ahead of their results. The correlation set is now uncapped. An entry is one short string, it is removed by the response to its own request, and every entry costs the peer a real session creation, so the agent's admission limit bounds it long before memory does. Saturation and its permanent fail-open go with it. MAX_QUEUED_SESSIONS had the same defect for the same reason and is raised above the admission limit; the per-session bound is unchanged. * fix(acp): track established sessions until they close The 1,024-session bound was the third instance of the same defect: once a long-lived bridge reached it, established and pending sessions became indistinguishable and ordering was given up for the rest of the process. It is removed rather than raised. Every entry corresponds to a session that is live on the Gateway side, which costs orders of magnitude more than the ID string held here, and session/close releases it, so this set can never be the binding constraint. Two bounds remain, both on the queue itself, which holds messages rather than identifiers: MAX_QUEUED_SESSIONS sits above what the agent admits, and MAX_QUEUED_UPDATES_PER_SESSION bounds a single session's initial burst. Both fail open in the direction that only degrades ordering, never delivery. * fix(acp): follow the session store's lifecycle and drop the last cap Two owner-boundary defects, both at the seam between this boundary and the work the bridge actually accepts. MAX_QUEUED_SESSIONS was the fourth cap to sit below accepted traffic. The admission limit is a rate, not a concurrency bound; a slow backend can hold more accepted creations outstanding than any fixed number, and update N+1 then bypassed the queue ahead of its own result. It is removed. The number of sessions with queued updates is the number of accepted creations still outstanding, which the bridge already bounds. The per-session cap stays: it is the one bound that holds messages rather than work the bridge admitted. establishedSessionIds was released only by an inbound session/close, but the store reaps idle sessions and evicts at capacity without producing any ACP request, so a long-lived bridge kept recognizing sessions the store had discarded. The store now reports every removal through onSessionRemoved, and server.ts injects a store wired to the boundary's forget(), so recognition follows the store's own lifecycle rather than only the close requests a client chooses to send. The injected store is disposed on the bridge's shutdown path since injected stores stay caller-owned. Rebased onto current main. * fix(acp): retire a loaded session the agent rejects session/load and session/resume were established on arrival, before the agent validated them. A rejected load -- one carrying per-session MCP servers, for instance -- left its client-chosen ID recognized until close or store removal. With the established set now uncapped, that is a growth vector a peer controls. The ID is still established provisionally on arrival so a loaded session's updates are never delayed; the request is remembered by JSON-RPC ID, and an error response retires the session it named. Bounded by in-flight loads, each of which is real work, and cleared by its own response. * fix(acp): only retire recognition a rejected request introduced The previous commit retired the session named by any failing load or resume. A session that was already established and merely reloaded lost its recognition when that reload failed, so its later updates waited behind an unrelated pending creation -- the delay this boundary exists to avoid, and which it explicitly promises not to impose on existing sessions. Only recognition a request introduces is provisional now: the request is remembered for retirement only when it established the ID itself. * fix(acp): keep updates behind their session's backlog; separate claims from confirmation Two concurrency defects at the boundary, both introduced by earlier repairs. Strict front-of-queue draining preserved cross-session order but let a session overtake itself: with A1, B1, A2 queued and A's result in, the drain emitted A1 and stopped at B1, leaving A2; a later A3 then passed straight through because A was established, so the client saw A3 before A2. A session with updates still queued now keeps queuing regardless of recognition, so its later updates wait behind its own backlog. The per-session overflow fails open by releasing that session's backlog in order first, so even the overflow path never reorders within a session. Provisional load/resume claims shared the confirmed set, so "already established" could not distinguish a succeeded request from a pending one. Two overlapping loads on one session: the second succeeds, the first is rejected, and the first's retirement erased the second's valid recognition. Claims are now counted per session, separately from confirmation. A session is recognized while confirmed or while any claim is outstanding; a rejection retires exactly its own claim; acceptance confirms. * fix(acp): release a session's backlog when its own result is written Holding one session behind another let a prompt outrun its own output. With A1, B1, A2 queued and A introduced, the global front-only drain emitted A1 and stopped at B1, so A kept queuing; a prompt's end_turn response carries no session ID, never enters the queue, and therefore reached the client ahead of the agent_message_chunk it completed. A session's queue is now released whole when its own result is written, rather than only the run at the head of the shared queue. Sessions are independent streams, so ordering one against another buys nothing the client can observe, while it does delay a session past frames that bypass the queue entirely. Order within a session is unchanged and still exact. The shared queue keeps global arrival order only on the path where no creation can introduce anything, which spans sessions that were never introduced and is the one place a cross-session rule is meaningful. * test(acp): pin the wire order of a prompt response against its own text Captures the ordering boundary at the ACP stdio boundary itself rather than through the ordering class alone: two session/new requests are outstanding at once, so an update for either is held, and the prompt response that completes one of them carries no session ID and so passes through the boundary untouched. Asserted as one five-frame sequence. Frame-by-frame assertions stop at the first divergence, which hides where a displaced frame actually lands - and where it lands is the defect. * test(acp-core): stop shadowing the suite store in the removal-hook test oxlint eslint(no-shadow) flagged the local store in the onSessionRemoved test against the suite-level one. Renamed rather than reusing the outer store: the test needs its own maxSessions and idleTtlMs to reach the eviction paths. * test(acp): keep ordering fixtures type-safe * fix(ci): consume canonical ACP landing prerequisites Reuse the published UI and native closure fixes from openclaw#150026 and openclaw#114032. Match the landed Slack correction from openclaw#111148, including openclaw#150457. Keep the qualified ACP production code and SDK proof unchanged. Co-authored-by: pash-openai <[email protected]> * test(update): await report staging before cleanup race --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: pash-openai <[email protected]>
What Problem This Solves
When a Discord thread is auto-archived and the gateway later restarts, the bot is no longer a thread member (archived threads are excluded from
THREAD_LIST_SYNC). If a user subsequently sends a message — which causes Discord to unarchive the thread — theDiscordThreadUpdateListenerreceives theTHREAD_UPDATEevent but returns early becauseisThreadArchived(data)isfalse. The bot never rejoins the thread, so all subsequentMESSAGE_CREATEevents for that thread are silently lost.This means the bot becomes permanently unresponsive in any thread that happened to be archived at the time of a gateway restart, even after the thread is unarchived by user activity.
Why This Change Was Made
The existing
DiscordThreadUpdateListeneronly handles the archive transition (closing sessions). It has no handling for the unarchive transition. This is a gap in the thread lifecycle management that causes silent message loss — the hardest kind of bug to diagnose because there are no errors in the logs.User Impact
Before: Bot silently stops responding in threads that were archived during a gateway restart. Users see no error, no reaction, nothing — messages simply vanish into the void.
After: When a thread is unarchived, the bot automatically rejoins it via
PUT /channels/{id}/thread-members/@me(idempotent — Discord returns 204 if already a member). A log line confirms the rejoin for observability.Changes
extensions/discord/src/monitor/listeners.ts— restructuredDiscordThreadUpdateListener.handleto branch on archive vs unarchive:Evidence
thread archived — reset sessionsevents but no corresponding rejoin on unarchiveDiscord thread unarchived — rejoined threadappears in logs and the bot resumes respondingTest plan
Maintainer integration — 2026-09-17
Rebound the contributor's repair onto current main while preserving contributor ancestry, current slow-listener/error handling, dynamic reaction policy, account-scoped thread deletion, and unchanged downstream message authorization. Claims remain bounded to 10,000, are acquired before REST, reset on archive/fresh READY, and released only by their own failed request. Production delta is +38 lines; this is the missing lifecycle capability, using the existing REST client and bounded-map helper.
Upstream contract verification
/channels/{channel.id}/thread-members/@me, active-thread requirement, and HTTP 204 success.Current-source verification
New regressions run production listener registration through the real Client event queue and REST client, stubbing only transport responses and session closing. They cover ordinary updates/204, overlapping jobs, archive and READY resets, REST failure/retry, stale failures across both resets, and independent account clients. On unmodified current main: eight intended failures and one passing archive control. Integrated candidate: nine owner-boundary tests plus eight startup tests passed.
The 57 sibling message/interaction/deletion/provider tests also passed, for 74 distinct focused tests. The three deferred-concurrency cases passed again after switching to the repository-supported typed helper. Final independent autoreview of the five-file candidate is scoped-clean with zero actionable P0–P2 findings. Required production/test types and remaining local repository guards passed. The nested native worktree cannot complete local declaration-boundary lint because it detects ancestor-checkout dependency resolution; clean-checkout hosted lint and extension-package-boundary checks passed on the first integration head. Exact-head hosted CI remains required before native preparation and landing. No Discord account calls, operator Gateway restart, or historical proof replay.
CI integration prerequisites
The first hosted run exposed two existing Slack failures in its newer-main merge context. This update incorporates that main revision and repairs both without changing Slack policy: the lifecycle type moves to a leaf contract to break the static ingress/thread-resolution cycle, and the approval-event callback retains its receiver instead of passing an unbound method. The static graph reproduced one cycle before and zero after; 54 existing Slack ingress/thread-resolution tests and both extension typechecks passed. The callback is covered by the existing requested/resolved approval-flow test. The existing approval requested/resolved scenario passed (one selected test; 207 unselected), and scoped typed lint passed with zero warnings/errors. Final eleven-file independent review is scoped-clean with zero actionable P0–P2 findings. The update is published as
e83454baf984cac8ddcd796e9b52699bbaabc8c1; exact-head CI remains required before native preparation.