Skip to content

refactor(channels): adopt core retryAsync for feishu and matrix retry loops - #104431

Merged
steipete merged 1 commit into
mainfrom
claude/chanref-p1-retry-sweep
Jul 11, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/chanref-p1-retry-sweep

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #104318

What Problem This Solves

Channels hand-roll retry/backoff loops instead of using the core retry engine, so retryability decisions and delay math drift per channel. This sweep migrates the two sites whose semantics map cleanly and documents exactly why the remaining three do not (that record feeds the ChannelAdapter v2 delivery design).

Why This Change Was Made

feishu's requestFeishuApi (comment send path) and matrix's retryMatrixApprovalDelivery now run on core retryAsync, keeping each channel's classification exactly (feishu re-throws fulfilled rate-limit bodies in the synthetic AxiosError shape its predicate expects; matrix keeps its caller opt-out predicate and size-limit fallback). Backoff-curve equivalence at the fixed attempt budgets is pinned in comments. Skipped with recorded gaps: mattermost (full-jitter schedule test-asserted, inexpressible in core retryAsync — needs a jitter-mode knob), imessage watch-subscribe (abort-aware sleep + teardown between attempts), feishu comment monitor (result-predicate poll, not error retry).

User Impact

No behavior change; retry cadence equivalence documented at the changed sites.

Evidence

  • Blacksmith Testbox tbx_01kx8ds5kpydq7q42mw3xc1a52: feishu/imessage/mattermost/matrix suites green + full pnpm check:changed; existing retry contract tests (feishu send.retry, matrix approval) hold unchanged.
  • Autoreview (codex gpt-5.6-sol, xhigh): clean on first pass.
  • git diff --numstat: net −20 prod LOC.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix channel: feishu Channel integration: feishu size: S maintainer Maintainer-authored PR labels Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 7:23 AM ET / 11:23 UTC.

Summary
The PR replaces Feishu and Matrix hand-written retry loops with the shared plugin SDK retryAsync helper while preserving their existing retry classification and delay schedules.

PR surface: Source -20. Total -20 across 2 files.

Reproducibility: not applicable. This PR refactors established retry control flow rather than reporting a current-main behavior failure. Equivalence is inspectable through the shared helper contract and existing focused tests.

Review metrics: none identified.

Root-cause cluster
Relationship: partial_overlap
Canonical: #104318
Summary: This PR is a bounded mechanical-adoption slice within the broader ChannelAdapter v2 program, not a duplicate or complete fix for the umbrella issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P1] No repair task is identified; this correct protected-label PR needs ordinary maintainer handling and completion of its pending required checks.

Security
Cleared: The isolated TypeScript refactor adds no dependency, workflow, secret, permission, downloaded-code, package-resolution, or publishing surface.

Review details

Best possible solution:

Land the bounded two-channel adoption of the canonical retry helper after required checks complete, retaining the focused tests that lock terminal errors, caller opt-outs, size-limit fallback, and the fixed 1×/2× delay schedules.

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

Not applicable; this PR refactors established retry control flow rather than reporting a current-main behavior failure. Equivalence is inspectable through the shared helper contract and existing focused tests.

Is this the best way to solve the issue?

Yes; using the existing plugin SDK retry helper removes duplicated channel control flow at the intended ownership boundary without adding a new API, config surface, or behavior mode.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P3: This is a low-risk internal deduplication refactor with no intended user-visible behavior change and no observed regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-directed internal refactor work, so the external-contributor real-setup proof gate does not apply; the PR body reports focused Blacksmith Testbox suites and check:changed.

Label justifications:

  • P3: This is a low-risk internal deduplication refactor with no intended user-visible behavior change and no observed regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-directed internal refactor work, so the external-contributor real-setup proof gate does not apply; the PR body reports focused Blacksmith Testbox suites and check:changed.
Evidence reviewed

PR surface:

Source -20. Total -20 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 38 58 -20
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 38 58 -20

What I checked:

  • Isolated PR patch: The PR commit changes only the Feishu API retry wrapper and Matrix approval delivery retry helper, replacing duplicated loops with the existing plugin SDK retry export. (extensions/feishu/src/comment-shared.ts:143, e5214b05fc97)
  • Feishu behavior equivalence: The new wrapper still performs three total attempts, retries only recognized Feishu rate-limit responses, converts fulfilled rate-limit bodies into the same Axios-style diagnostic shape, and applies the existing API error wrapper after exhaustion. (extensions/feishu/src/comment-shared.ts:149, e5214b05fc97)
  • Matrix behavior equivalence: The new Matrix helper retains the three-attempt budget and caller opt-out predicate; the surrounding delivery path still bypasses retries for the single-message size error so chunked fallback remains immediate. (extensions/matrix/src/approval-handler.runtime.ts:183, e5214b05fc97)
  • Retry timing contract: Current retryAsync uses zero default jitter and exponential delays of 1× then 2× the configured minimum for a three-attempt budget, exactly matching both replaced loops at their fixed attempt counts. (src/infra/retry.ts:170, c49e5c480dc2)
  • Terminal error contract: The shared retry implementation returns the final Error object while attaching prior-attempt metadata, so Matrix error identity and Feishu response diagnostics remain available to downstream classification and wrapping. (src/infra/retry.ts:45, c49e5c480dc2)
  • Existing regression coverage: Current tests cover Feishu thrown and fulfilled rate-limit retries, exhaustion and non-rate-limit failures, plus Matrix transient send and direct-room repair retries and the size-limit chunked fallback. (extensions/matrix/src/approval-handler.runtime.test.ts:349, c49e5c480dc2)

Likely related people:

  • steipete: Prior merged history shows repeated work on src/infra/retry.ts, Feishu error handling, Matrix approval delivery, and the plugin SDK retry barrel beyond authorship of this proposal. (role: shared retry and channel-area contributor; confidence: high; commits: 4eeb7bfa5766, 1ecb2fc2c72a, 05eda57b3c72; files: src/infra/retry.ts, extensions/feishu/src/comment-shared.ts, extensions/matrix/src/approval-handler.runtime.ts)
  • ladygege: Commit 84acb74a6a775caa93903153aa3c43a8f5598e77 introduced the Feishu rate-limit retry implementation and its focused regression tests that this refactor preserves. (role: introduced Feishu retry behavior; confidence: high; commits: 84acb74a6a77; files: extensions/feishu/src/comment-shared.ts, extensions/feishu/src/send.retry.test.ts)
  • vincentkoc: Recent merged commits localized the Feishu and Matrix implementation surfaces and shared retry error normalization, making this contributor relevant to the current structure and contracts. (role: recent channel and retry-area contributor; confidence: high; commits: eb721b0b306f, 4115e832d833, a29edce40954; files: extensions/feishu/src/comment-shared.ts, extensions/matrix/src/approval-handler.runtime.ts, src/infra/retry.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • 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.

@steipete
steipete merged commit 3902adf into main Jul 11, 2026
143 of 150 checks passed
@steipete
steipete deleted the claude/chanref-p1-retry-sweep branch July 11, 2026 11:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Jul 16, 2026
The inter-attempt delay in monitor.comment.ts used a bare setTimeout and
never received the owning monitor account's AbortSignal, so an account
teardown (ws disconnect, webhook stop, config reload) left the in-flight
comment reply retry running for up to ~6s after the rest of the lifecycle
settled. delayMs now wraps waitForAbortableDelay from async.ts and the
abortSignal is threaded through fetchDriveCommentContext →
resolveDriveCommentEventTurn → handleFeishuCommentEvent →
createFeishuDriveCommentNoticeHandler, sourced from
monitorSingleAccount.

The retry loop checks the waitMs return value and the abortSignal flag,
breaking out of the next 1s tick instead of running the full 6×1s poll
budget. Sibling surface monitor.bot-identity.ts already uses the same
pattern; openclaw#104431 explicitly skipped the comment-monitor retry because
it is a result-predicate poll, not an error retry, and this fix is
orthogonal to that decision.

Not tested: live Feishu tenant, real bot identity, real drive comment,
and account restart. requestFeishuOpenApi itself does not accept
AbortSignal — that is a separate, larger refactor and is out of scope.
steipete added a commit that referenced this pull request Jul 16, 2026
…8408)

* fix(feishu): honor abortSignal in drive comment reply retry loop

The inter-attempt delay in monitor.comment.ts used a bare setTimeout and
never received the owning monitor account's AbortSignal, so an account
teardown (ws disconnect, webhook stop, config reload) left the in-flight
comment reply retry running for up to ~6s after the rest of the lifecycle
settled. delayMs now wraps waitForAbortableDelay from async.ts and the
abortSignal is threaded through fetchDriveCommentContext →
resolveDriveCommentEventTurn → handleFeishuCommentEvent →
createFeishuDriveCommentNoticeHandler, sourced from
monitorSingleAccount.

The retry loop checks the waitMs return value and the abortSignal flag,
breaking out of the next 1s tick instead of running the full 6×1s poll
budget. Sibling surface monitor.bot-identity.ts already uses the same
pattern; #104431 explicitly skipped the comment-monitor retry because
it is a result-predicate poll, not an error retry, and this fix is
orthogonal to that decision.

Not tested: live Feishu tenant, real bot identity, real drive comment,
and account restart. requestFeishuOpenApi itself does not accept
AbortSignal — that is a separate, larger refactor and is out of scope.

* test(feishu): prove comment retry abort

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…nclaw#108408)

* fix(feishu): honor abortSignal in drive comment reply retry loop

The inter-attempt delay in monitor.comment.ts used a bare setTimeout and
never received the owning monitor account's AbortSignal, so an account
teardown (ws disconnect, webhook stop, config reload) left the in-flight
comment reply retry running for up to ~6s after the rest of the lifecycle
settled. delayMs now wraps waitForAbortableDelay from async.ts and the
abortSignal is threaded through fetchDriveCommentContext →
resolveDriveCommentEventTurn → handleFeishuCommentEvent →
createFeishuDriveCommentNoticeHandler, sourced from
monitorSingleAccount.

The retry loop checks the waitMs return value and the abortSignal flag,
breaking out of the next 1s tick instead of running the full 6×1s poll
budget. Sibling surface monitor.bot-identity.ts already uses the same
pattern; openclaw#104431 explicitly skipped the comment-monitor retry because
it is a result-predicate poll, not an error retry, and this fix is
orthogonal to that decision.

Not tested: live Feishu tenant, real bot identity, real drive comment,
and account restart. requestFeishuOpenApi itself does not accept
AbortSignal — that is a separate, larger refactor and is out of scope.

* test(feishu): prove comment retry abort

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…nclaw#108408)

* fix(feishu): honor abortSignal in drive comment reply retry loop

The inter-attempt delay in monitor.comment.ts used a bare setTimeout and
never received the owning monitor account's AbortSignal, so an account
teardown (ws disconnect, webhook stop, config reload) left the in-flight
comment reply retry running for up to ~6s after the rest of the lifecycle
settled. delayMs now wraps waitForAbortableDelay from async.ts and the
abortSignal is threaded through fetchDriveCommentContext →
resolveDriveCommentEventTurn → handleFeishuCommentEvent →
createFeishuDriveCommentNoticeHandler, sourced from
monitorSingleAccount.

The retry loop checks the waitMs return value and the abortSignal flag,
breaking out of the next 1s tick instead of running the full 6×1s poll
budget. Sibling surface monitor.bot-identity.ts already uses the same
pattern; openclaw#104431 explicitly skipped the comment-monitor retry because
it is a result-predicate poll, not an error retry, and this fix is
orthogonal to that decision.

Not tested: live Feishu tenant, real bot identity, real drive comment,
and account restart. requestFeishuOpenApi itself does not accept
AbortSignal — that is a separate, larger refactor and is out of scope.

* test(feishu): prove comment retry abort

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: matrix Channel integration: matrix maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant