Skip to content

fix(slack): recover bot identity after transient auth.test failure - #117253

Merged
steipete merged 3 commits into
mainfrom
fix/slack-identity-latebind
Aug 1, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/slack-identity-latebind

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A single transient failure of Slack's boot-time auth.test (one 429, one >10s network blip) leaves the account permanently connected but unable to recognize mentions. The startup auth client used retries: 0 + rejectRateLimitedCalls: true; the failure was swallowed; the empty botUserId was frozen into the monitor context for the process lifetime; the socket then connected and published connected: true with a healthState: "degraded" string no core consumer reads. With requireMention defaulting to true for channels, every non-app_mention room message was dropped as mention-detection-unavailable, forever. Nothing retried; nothing restarted; status looked healthy. This exact terminal state was asserted by the shipped test provider.auth-test-token.test.ts.

Two adjacent status lies: HTTP mode never published connected/health status at all, and relay mode hardcoded healthState: "healthy" over a degraded identity.

Why This Change Was Made

Identity now recovers instead of freezing, fixed at the plugin's ownership boundary:

  • Boot retry: the startup auth client uses the plugin's standard retry options within a bounded 35s budget (10s per attempt), with a fetch wrapper that refuses to sleep through a Retry-After longer than the remaining budget.
  • Late-bound identity: botUserId/botId/identityHealth live as mutable state on the monitor context (the existing channelsConfig post-construction pattern). A single resolveSlackRuntimeIdentity helper encodes the identity rules once: user identity needs no bot_id (its human id is both mention target and self-send dedupe source); bot identity stays bot_id-gated fail-closed; enterprise installs never adopt from runtime context.
  • Two recovery paths: Bolt already re-resolves auth.test per event (tokenVerificationEnabled: false) — a new onContextIdentity middleware seam adopts that identity when degraded; and socket onStarted re-runs auth.test when degraded, so recovery does not require inbound traffic. Adoption only ever fires while degraded — a healthy identity is never overwritten. Recovery republishes status, clearing the degraded state; mention gating reads the context per message, so detection resumes automatically.
  • Status honesty: HTTP mode publishes connected status with identity health after webhook registration (never publishing connected: false — tri-state rules preserved); relay mode reports actual identity health instead of hardcoded healthy.
  • Enterprise Grid boot validation (enterpriseOrgInstall throw) and bot/user identity selection are unchanged.

User Impact

A Slack account that boots during a rate limit or network blip now heals itself — on the next inbound event or socket (re)connect — instead of silently ignoring mentions until an operator notices and restarts. Operators see truthful status in all three transport modes.

Evidence

  • provider.auth-test-token.test.ts — 21/21; assertion changes are deliberate and inverted on purpose: transient boot failure now expects recovery (previously asserted permanent degradation); invalid bot-token fixtures remain persistently degraded, proving missing bot_id is never adopted; boot warning asserts "while unresolved" wording.
  • New HTTP-mode test: initial degraded readiness → first-event identity adoption → healthy status → successful required-mention dispatch. Relay test verifies degraded health is preserved.
  • Full Slack monitor directory: 977/977 across 48 files; Slack client tests 43/43; extension prod+test typechecks, targeted lint, formatting all green.
  • Structured autoreview (Codex, gpt-5.6-sol, high): clean, twice — after implementation and again after rebasing onto latest main.
  • Prod diff +150/−20 within extensions/slack only; no core, SDK, or config surface changes.

🤖 Generated with Claude Code

Dependency contract + live-proof status (added post-review)

Direct @slack/[email protected] source inspection confirming the retry semantics this PR relies on (429 sleeps the full Retry-After inside the attempt where maxRetryTime cannot interrupt it — the startup fetch wrapper is what enforces the 35s budget; old rejectRateLimitedCalls: true made one 429 immediately fatal at boot): #117253 (comment)

No Slack credentials exist on the implementing host, so an after-fix real-workspace transcript is not included; the end-to-end HTTP-mode adoption test plus 977/977 monitor tests are the standing behavioral evidence. Maintainer call on sufficiency is explicitly open.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 06:04
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 2:37 AM ET / 06:37 UTC.

ClawSweeper review

What this changes

The PR makes Slack retry and later recover its bot identity after a transient startup auth.test failure, so required-mention messages and connection health can recover without a restart.

Merge readiness

⛔ Blocked until real behavior proof is added - 5 items remain

Keep this PR open for human merge review. Current main still has the reported permanent-degraded startup path, and the proposed repair appears to address it at the Slack plugin boundary, but the required after-fix real Slack behavior proof is still absent and this review environment could not retrieve the PR head object for a complete local diff audit.

Priority: P1
Reviewed head: 7dc09b7302e5dc93deaab90d620fe21aca0ab774
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The current-main defect is well supported and the stated patch is focused, but missing real Slack behavior proof and incomplete exact-head inspection leave it below merge-ready confidence.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR has reported mocked and integration-harness evidence, but the contributor confirms no redacted after-fix Slack workspace transcript, runtime output, or recording is attached; add real proof with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR has reported mocked and integration-harness evidence, but the contributor confirms no redacted after-fix Slack workspace transcript, runtime output, or recording is attached; add real proof with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main startup behavior: Current main creates the startup auth client with rejectRateLimitedCalls: true; its adjacent comment states that an auth.test failure leaves startup identity degraded until restart.
Current-main frozen identity path: Current main initializes empty bot identity, catches startup auth.test failure, computes degraded health, and constructs the monitor context with those values before Socket Mode later reports that degraded health as connected.
Regression contract on current main: Current tests explicitly preserve the behavior: one test says required-mention channels fail closed without another trusted activation signal, and the reconnect-loop test expects degraded health to remain after a recoverable reconnect.
Findings None None.
Security None None.

How this fits together

The bundled Slack plugin authenticates at startup, records the account identity in its monitor context, and uses that identity to evaluate mentions and publish channel health. Incoming Slack events then pass through mention filtering before they are dispatched to the OpenClaw agent runtime.

flowchart LR
  A[Slack API] --> B[Startup auth check]
  B --> C[Slack monitor identity]
  C --> D[Mention evaluation]
  D --> E[Agent message dispatch]
  C --> F[Connection health status]
  A --> G[Incoming Slack event]
  G --> D
Loading

Decision needed

Question Recommendation
Should this Slack availability fix require a redacted real-workspace recovery transcript before merge, or is the supplied HTTP-mode integration test and dependency inspection sufficient? Require real Slack proof: Request a redacted workspace run showing the degraded-to-healthy recovery and restored required-mention delivery before merge.

Why: Repository policy makes real after-fix behavior proof a merge gate for external non-doc PRs, while the contributor has explicitly left sufficiency to maintainers because no Slack credentials were available.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR has reported mocked and integration-harness evidence, but the contributor confirms no redacted after-fix Slack workspace transcript, runtime output, or recording is attached; add real proof with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P0) - A transient Slack outage and later identity recovery alter channel availability; mocked coverage does not yet show the after-fix behavior in a real Slack workspace.
  • Resolve merge risk (P1) - The branch is behind current main, and the local promisor checkout could not retrieve its head, so the exact merge result and complete final diff need a refreshed review before landing.
  • Complete next step (P2) - A protected maintainer label and the explicit real-proof gate require human merge judgment rather than an automated repair job.
Agent review details

Security

None.

PR surface

Source +140, Tests +115. Total +255 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 166 26 +140
Tests 7 145 30 +115
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 311 56 +255

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: extensions/slack/src/client.web-api.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Capture Slack recovery proof (recommended)
    Run the branch against a credentialed Slack workspace and attach redacted evidence of transient auth failure followed by recovery and required-mention dispatch.
  2. Accept the remaining proof risk
    A maintainer can explicitly accept the mock-backed integration coverage if obtaining a workspace transcript is impractical.

Technical review

Best possible solution:

Add a redacted real Slack proof that shows transient startup authentication failure, degraded readiness, later identity recovery, healthy status, and a required-mention message reaching the agent; then refresh the exact-head review after rebasing or GitHub’s merge result is current.

Do we have a high-confidence way to reproduce the issue?

Yes from current source: startup auth failure leaves an empty identity in the monitor context, and current tests assert continued degraded operation after reconnect. This read-only review did not execute a Slack workspace reproduction.

Is this the best way to solve the issue?

Unclear. The proposed late-bound recovery is at the Slack plugin ownership boundary and fits the observed frozen-state defect, but missing real behavior proof and inability to retrieve the exact PR head prevent a full best-fix confirmation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 51c41c25c8c3.

Labels

Label justifications:

  • P1: A transient startup failure can leave a connected Slack account silently unable to process normal required-mention traffic until restart.
  • merge-risk: 🚨 availability: The branch changes startup authentication retry and recovery behavior that governs whether a Slack channel becomes usable after a transient outage.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR has reported mocked and integration-harness evidence, but the contributor confirms no redacted after-fix Slack workspace transcript, runtime output, or recording is attached; add real proof with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main startup behavior: Current main creates the startup auth client with rejectRateLimitedCalls: true; its adjacent comment states that an auth.test failure leaves startup identity degraded until restart. (extensions/slack/src/client.ts:39, a7e0ebe8e68e)
  • Current-main frozen identity path: Current main initializes empty bot identity, catches startup auth.test failure, computes degraded health, and constructs the monitor context with those values before Socket Mode later reports that degraded health as connected. (extensions/slack/src/monitor/provider.ts:407, 51c41c25c8c3)
  • Regression contract on current main: Current tests explicitly preserve the behavior: one test says required-mention channels fail closed without another trusted activation signal, and the reconnect-loop test expects degraded health to remain after a recoverable reconnect. (extensions/slack/src/monitor/provider.auth-test-token.test.ts:215, 51c41c25c8c3)
  • History provenance: Blame attributes the current startup-client behavior, including the rate-limit rejection setting, to commit a7e0ebe8e68e76ff917b4b06ebdef7882db118bd by Peter Steinberger on July 31, 2026. (extensions/slack/src/client.ts:44, a7e0ebe8e68e)
  • PR proof status: The PR body and follow-up explicitly say that no real Slack workspace transcript, runtime output, or recording is available; the prior ClawSweeper review therefore requested real behavior proof before merge. (7dc09b7302e5)
  • Review-environment limitation: The local checkout is a promisor clone without the PR head object; attempts to inspect it caused Git to fetch, but DNS could not resolve GitHub. GitHub and gitcrawl network reads were likewise unavailable, so this review used the supplied PR context plus checked-out current main.

Likely related people:

  • steipete: Current-main blame assigns the startup auth-client behavior to Peter Steinberger, and the same contributor authored the proposed Slack recovery work. (role: current behavior author and recent Slack-area contributor; confidence: high; commits: a7e0ebe8e68e, 3513d0dc5309, 7dc09b7302e5; files: extensions/slack/src/client.ts, extensions/slack/src/monitor/provider.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted real Slack recovery transcript, terminal output, or recording that directly shows restored required-mention delivery.
  • Refresh review against the exact current PR head after the base drift is resolved.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-01T06:19:22.450Z sha 7dc09b7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T06:29:07.014Z sha 7dc09b7 :: needs real behavior proof before merge. :: none
  • reviewed August 1, 2026, 2:37 AM ET / 06:37 UTC sha unknown :: needs real behavior proof before merge. :: none

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Dependency retry-contract inspection (@slack/[email protected], direct source)

Per review: the retry semantics this PR relies on, verified in the installed package (node_modules/@slack/web-api/dist/):

  • Constructor defaults (WebClient.js:123): retryConfig = tenRetriesInAboutThirtyMinutes, timeout = 0, rejectRateLimitedCalls = false. The plugin's SLACK_DEFAULT_RETRY_OPTIONS (extensions/slack/src/client-options.ts:24) replaces the default policy; the startup client adds maxRetryTime: 35_000 and timeout: 10_000.
  • 429 handling (WebClient.js:431-452): with rejectRateLimitedCalls: false, the client emits RATE_LIMITED, pauses its queue, then await delay(retrySec * 1000) — the full Retry-After sleep happens inside the attempt, then a plain Error is thrown to trigger a p-retry retry. With rejectRateLimitedCalls: true (the OLD startup behavior), it throws AbortError(WebAPIRateLimitedError) — immediately fatal, which is exactly how one 429 at boot froze identity permanently.
  • Budget semantics (WebClient.js:475): pRetry(task, this.retryConfig) — maxRetryTime is evaluated between attempts and cannot interrupt the in-attempt Retry-After sleep. This is why the PR's startup fetch wrapper refuses to hand the client a 429 whose retry-after exceeds the remaining budget: without it, a single retry-after: 300 would sleep the boot path for 5 minutes regardless of maxRetryTime. The wrapper is what makes the 35 s startup budget enforceable.
  • timeout maps to a per-request abort signal — 10 s per attempt, unchanged from the old behavior.

Live-proof status (honest gap)

This session ran its other Phase-0 live proofs on an ephemeral gateway from an integration build (boot, readiness, close-race). For this PR, no Slack credentials exist on this host (~/.openclaw absent), so an after-fix run against a real Slack workspace could not be captured here without reaching into another machine's live gateway state, which is out of bounds without explicit operator action. What stands instead: the end-to-end HTTP-mode test (degraded boot → first-event identity adoption → healthy status → successful required-mention dispatch through the real Bolt receiver path), 977/977 monitor tests, 43/43 client tests, dual clean autoreviews, and the dependency-contract inspection above. A real-workspace transcript can be added by running any Slack-credentialed gateway on this branch; the maintainer decision on whether the current evidence suffices is explicitly left open.

🤖 Generated with Claude Code

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer decision (explicit): landing on the standing evidence — end-to-end Bolt-path recovery test (degraded boot → first-event identity adoption → healthy status → required-mention dispatch), 977/977 monitor suite, dual clean autoreviews, green CI on this exact head, and the direct @slack/[email protected] retry-contract inspection above. The real-workspace transcript requires Slack credentials not present on the implementing host; the operator has directed completion on this evidence. Post-land verification on a credentialed gateway remains welcome and any regression reverts cleanly (change is isolated to extensions/slack).

@steipete
steipete merged commit 7aacd13 into main Aug 1, 2026
107 of 111 checks passed
@steipete
steipete deleted the fix/slack-identity-latebind branch August 1, 2026 07:23
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant