Skip to content

Keep Slack messages through temporary authorization failures - #150457

Merged
pash-openai merged 1 commit into
mainfrom
pash/retry-slack-auth-outages
Sep 17, 2026
Merged

pash-openai merged 1 commit into
mainfrom
pash/retry-slack-auth-outages

Conversation

@pash-openai

Copy link
Copy Markdown
Contributor

Slack's Bolt SDK wraps temporary auth.test failures in AuthorizationError. OpenClaw treated every such wrapper as permanent, so an acknowledged message could be discarded when Slack returned a rate limit or briefly lost connectivity.

Inspect the underlying error using the existing Slack retry classification and leave temporary failures in the durable queue. Invalid credentials and other permanent authorization failures still stop delivery. The same message must successfully authorize before any listener runs.

Regression tests exercise the real Bolt and Web API clients against an isolated durable queue: rate limits, service outages, and connection resets survive a restart and deliver exactly once after recovery; invalid credentials remain rejected. All 27 related ingress tests and the extension type check pass. No dependencies change.

@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T01:24:52.052898Z c657e7e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: S maintainer Maintainer-authored PR labels Sep 17, 2026
@pash-openai
pash-openai merged commit edc1fa8 into main Sep 17, 2026
89 of 91 checks passed
@pash-openai
pash-openai deleted the pash/retry-slack-auth-outages branch September 17, 2026 01:24
pash-openai added a commit that referenced this pull request Sep 17, 2026
…ranch (#150472)

* fix(channels): hide intermediate tool failures in quiet progress (#145345)

* fix(channels): hide intermediate tool failures in quiet progress

Keep authored plans, progress text, approvals, and terminal task errors visible while quiet/default progress omits individual failed-tool and nonzero-exit rows. Preserve explicit tool-log diagnostics and remove obsolete quiet failure recovery handling.

Fixes #140037. Reported by @stemkat100 and @joncursi. Validated with 359 focused tests, changed checks, and independent review.

* test(channels): align quiet failure visibility coverage

Keep explicit diagnostic, approval, plan, and terminal-error coverage while requiring quiet progress to omit intermediate failures across downstream adapters. Assert Mattermost observations after monitor shutdown so a failure cannot be swallowed until timeout.

(cherry picked from commit 3bfac2f)

* fix(channels): keep deeper queued messages alive through long turns (#133248)

The contributor’s original description follows. Historical heads, scope and open decisions in this section refer to that implementation; the reviewed current implementation, compatibility decision and proof are recorded in the maintainer update below.

Closes #133245.

Related: #127950. This supersedes the current-main-incompatible queue-owned approach in #125385 while preserving today's canonical timeout retry disposition.

A durably claimed channel message can wait behind another follow-up turn for longer than the five-minute claim-to-adoption watchdog. Existing liveness renewal covers queue-head active-run admission checks, but not an ingress-backed lifecycle waiting deeper in the follow-up queue. The claim can therefore be retired before the message reaches the model.

The follow-up queue now owns periodic deferred heartbeats for the exact ingress lifecycle while it remains in pending items, in-flight delivery, summary sources, or compacted summary elisions.

Ingress supplies a cadence derived from one third of its adoption-stall timeout. Debounce, Plugin SDK fan-in, and channel lifecycle wrappers preserve the shortest applicable cadence. Queue ownership triggers an immediate renewal, then periodic renewal; it stops after successful adoption, completion, ownership loss, or callback failure. A rejected adoption callback keeps renewal alive for the supported retry path.

The existing watchdog and canonical timeout retry policy remain unchanged, so silent handlers and orphaned claims still recover normally.

Messages accepted by durable channel ingress remain adoptable while they wait behind long-running work instead of silently disappearing before model execution. No setting or migration is required.

SDK documentation polish (2026-09-10, head `76097fef9397a04c10637e06dfaf64ebb6ca104a`): the public channel SDK guide now documents forwarding both heartbeat fields, the shortest-positive-finite fan-in cadence, renewal termination, and compatibility when older wrappers omit the optional cadence. The documentation-only addition passed changed-page formatting, MDX sanity, and `git diff --check`; production code and the previously tested runtime head below are unchanged. Current-head hosted CI has completed successfully; the final exact-head ClawSweeper review accepts the implementation and proof, leaving only SDK-owner acceptance of the documented contract.

Refreshed on 2026-09-08 for exact head `57c4faff0ed7bb2d9b4fd308aa46b19ae4095e61`, rebased onto `1ff45cad5ae`.

- Preserved upstream's ingress-monitor type extraction and gateway-suspension repair; the optional cadence field follows its new type owner.
- Repaired the retry integration fixture: after real enqueue and initial renewal, only the abandoned message's heartbeat callback fails. The real watchdog then recovers it. Retry delivery, healthy sibling cleanup, and true duplicate assertions remain intact; no production behavior or timeout changed for this repair.
- 102 focused tests pass: dispatch ingress retry, queue in-flight/dedupe, ingress lifecycle/watchdog, Plugin SDK fan-in, Discord queue handling, and Slack handler.
- Changed-file gates pass: core/core-test/extension typechecks, formatting, changed core/extension lint, SDK boundaries/exports, dead-export scans, and repository guards.
- Fresh independent source review found no actionable P0–P2 defects. The standalone autoreview CLI failed at startup without a verdict and is not counted as review coverage.
- Current-head CI run [34520397963](https://github.com/openclaw/openclaw/actions/runs/34520397963) completed successfully. The earlier startup subprocess timeout is historical, not a current failing gate. Exact-head ClawSweeper review (September 10, 20:00 UTC) reports no actionable correctness or proof findings; explicit SDK-owner acceptance remains required before merge.
- Existing regressions cover immediate renewal after late handoff, periodic deeper-queue renewal, stopping after owner loss, and continuing across a rejected adoption callback.

Exact-head durable-ingress boundary proof used isolated SQLite with the production ingress drain/lifecycle binder, follow-up queue, and canonical adoption helper. The model callback was synthetic; this is not live Telegram or Discord transport proof. No production Gateway, channel state, or configuration was touched. Temporary state and queue ownership were cleaned up.

```json
{
  "schema": "openclaw.pr133248.durable-ingress-proof.v1",
  "exactHead": "57c4faff0ed7bb2d9b4fd308aa46b19ae4095e61",
  "setup": {
    "durableStore": "isolated OpenClaw SQLite state",
    "executor": "production follow-up queue with synthetic model callback",
    "transportLifecycle": "production ingress drain lifecycle",
    "adoptionStallTimeoutMs": 180
  },
  "queuedBehindLongTurn": {
    "heldMs": 620,
    "formerDeadlineCrossed": true,
    "heartbeatCount": 11,
    "claimStillOwnedAtCheckpoint": [
      "queued-event"
    ],
    "retryRowsAtCheckpoint": 0,
    "failedRowsAtCheckpoint": 0,
    "executionCount": 1,
    "duplicateAfterAdoption": "completed"
  },
  "orphanRecovery": {
    "status": "released-for-retry",
    "attempts": 1,
    "lastErrorContainsHandlerTimeout": true
  },
  "productionTouched": false
}
```

Owner acceptance:
- Intended behavior: accepted messages remain adoptable while their exact lifecycle is owned by the queue; ownerless claims retain canonical timeout recovery.
- Boundary: one optional cadence field propagated through existing shared lifecycle and channel wrappers; no configuration, schema, or migration change.
- Maintainer decision remains open: accept the additive public Plugin SDK lifecycle field and its queue-owned cadence semantics. Bot review is not that acceptance.
- Rollback: revert the renewal fix and its companion retry-fixture adjustment.
- Scope: 23 files, +273/-2. The width is required lifecycle forwarding; renewal policy stays in the queue and ingress drain.

AI-assisted.

---

Messages accepted while a long reply is running can expire in the follow-up queue and consume a retry. The reproduction confirmed expiry and retry; all three messages eventually arrived. It did not reproduce the older permanent-loss report in #133245.

The queue starts one heartbeat when it accepts a lifecycle and stops it on adoption, completion, cancellation, or callback failure. Heartbeats no longer scan queue collections or copy the in-flight set. Ingress remains responsible for the watchdog and retry settlement, and a heartbeat cannot undo the watchdog pause during adoption finalization.

Ingress derives the cadence from its adoption timeout. The optional lifecycle metadata remains necessary because wrappers rebuild callbacks and combine abort signals, losing the original timeout. No channel setting, schema, migration, dependency, or protocol change is added.

The simplification removes 110 lines net from the initial implementation plus main merge. Total production growth is 40 lines. Existing lifecycle types are reused, and the queue cases share the existing lifecycle test fixtures.

- Real Gateway and Discord: three marked messages on one route, with a queued reply held for 330 seconds. Main expired the third claim after 300.004 seconds. This head retained the same claim at 322.257 seconds with zero attempts; replies arrived once, in order, at 17.804, 349.201, and 350.223 seconds.
- Real SQLite/drain/binder/queue controls: explicit abandonment releases the claim; callback failure stops renewal and lets the watchdog retry without model execution.
- 191 core owner/sibling tests and 190 channel tests passed. All five new regression cases failed on plain main for the intended reasons.
- The local preflight passed core/extension type-aware lint, production and test types, script types, and protocol checks in an isolated checkout of this head.
- External consumers compiled and ran against published 2026.9.4 and this head, including omitted metadata, forwarding, optional return fields, and asynchronous abandonment.

Shared ingress binding, batching, reply dispatch, and the Feishu, Slack, Telegram, and Twitch wrappers preserve the source cadence. The fan-in uses the shortest valid cadence. Legacy wrappers that omit the optional field retain their existing head-only heartbeat behavior. Adoption, queue clearing, overflow, cancellation, summaries, and drain replacement retain or finish the same lifecycle owner.

Closes #133245.

Original implementation and report by @PollyBot13 (#133245). The contributor's commits and authorship are retained.

AI-assisted.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit dba4da1)

* fix(slack): join deferred replay settlement on shutdown (#150073)

Recheck cancellation before message preparation after replay claims and lazy pipeline imports, releasing every acquired claim on failure. Keep deferred reply settlement owned through ingress stop and settle failed routed deliveries through the existing failure lifecycle without rejecting successful publication.

(cherry picked from commit 82d4d1c)

* Restore Slack’s quiet preamble previews (#150407)

* Restore Slack’s quiet preamble previews

* Keep quiet preambles visible without admitting tool telemetry

(cherry picked from commit a90b969)

* fix(slack): retry temporary authorization failures (#150457)

(cherry picked from commit edc1fa8)

* Regenerate release metadata with its pinned schema generator

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: PollyBot13 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
fuller-stack-dev added a commit to superdiaodiao/openclaw that referenced this pull request Sep 17, 2026
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]>
fuller-stack-dev added a commit that referenced this pull request Sep 17, 2026
* 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant