Skip to content

refactor(retry): add full-jitter mode and adopt it for mattermost client retries - #104594

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

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

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #104318

What Problem This Solves

Mattermost was the last Phase-1 retry holdout: its full-jitter schedule (uniform [delay, 2·delay) with cap-after-draw and a minimum floor, pinned by tests) was inexpressible in core retryAsync, so #104431 had to skip it and it kept a hand-rolled loop.

Why This Change Was Made

Core RetryConfig.jitter widens from number to number | "full" — no parallel field, no new config surface (config schemas stay number-only; the mode is code-declared). An injectable random source follows the existing streaming/tagline pattern for deterministic tests. Mattermost's client loop then migrates onto retryAsync via the standard SDK seam with its classification unchanged; its schedule-pinning test passes byte-identical. Two review-driven hardenings shipped with it: the documented cap now beats the floor when initialDelayMs > maxDelayMs (valid config the schema refine doesn't catch), and over-cap Retry-After draws spread downward in [cap/2, cap) so full-jitter retries don't collapse into an anti-herd-defeating lockstep at the cap — that spread is a deliberate design choice worth a reviewer glance.

User Impact

No behavior change for existing callers (jitter: number semantics untouched); mattermost retry cadence unchanged by test proof.

Evidence

  • Testbox tbx_01kx922d7amd3fqj33whea7b0g: extensions/mattermost/src + src/infra suites (262+44 files) + full pnpm check:changed green; client.retry.test.ts unmodified and passing (the acceptance bar).
  • New unit tests: full-jitter bounds, cap-after-draw, floor clamp regression, over-cap spread.
  • Autoreview (codex gpt-5.6-sol, xhigh): two accepted findings fixed + verified; final run clean (0.95).
  • SDK surface pins unaffected (option/type members aren't counted exports — verified against the report script).

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: M maintainer Maintainer-authored PR labels Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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, 1:44 PM ET / 17:44 UTC.

Summary
The PR adds a full-jitter strategy and injectable randomness to the shared retry helper, adds focused timing tests, and migrates Mattermost direct-channel creation from its hand-written retry loop to retryAsync.

PR surface: Source +27, Tests +162. Total +189 across 4 files.

Reproducibility: yes. at source level: the current Mattermost loop, schedule-pinning tests, callback contract, and shared retry helper provide a high-confidence equivalence path. No real Mattermost service failure-and-recovery run is attached.

Review metrics: 1 noteworthy metric.

  • Plugin SDK option changes: 1 widened, 1 added. The public retry entrypoint gains the "full" jitter value and a callable random-source option, which matters for long-term external plugin compatibility.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104318
Summary: This PR is the candidate implementation for Mattermost's Phase-1 shared-retry adoption within the channel refactor program.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • [P1] Add a redacted real Mattermost run or runtime log showing transient failure, observed retry delays, and eventual success.
  • Obtain owner direction on the public random option or narrow it to an internal test seam.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Testbox and deterministic unit tests are supplemental only; add a redacted live Mattermost retry transcript or runtime log showing the changed path, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] RetryConfig.jitter and RetryOptions.random are exported plugin SDK surface; external plugins may compile against and adopt them before maintainers confirm the permanent API shape.
  • [P1] The PR has deterministic tests and Testbox results but no after-fix run against a real Mattermost transient failure, so real service behavior and timing have not been demonstrated.
  • [P1] The head is behind current main; GitHub reports it mergeable, so this is review-refresh work rather than evidence that the merged result would delete current behavior.

Maintainer options:

  1. Narrow the public contract (recommended)
    Keep full-jitter support and the Mattermost migration but move deterministic randomness out of exported RetryOptions before merge.
  2. Accept the additive API
    Merge both new options only after an owner explicitly confirms they are intended permanent plugin SDK surface.
  3. Pause the consolidation
    Retain the Mattermost-owned retry loop if maintainers do not want to expand the shared retry API now.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve `jitter: "full"` and the Mattermost migration, but remove `random` from the public `RetryOptions` contract by using an internal or test-only deterministic randomness seam; keep focused full-jitter tests and existing numeric-jitter behavior unchanged.

Next step before merge

  • [P1] A maintainer should decide the permanent public retry API shape, and the contributor should add real Mattermost behavior proof before merge.

Maintainer decision needed

  • Question: Should the injectable random source become permanent public RetryOptions API, or should deterministic randomness remain internal while only jitter: "full" is exposed?
  • Rationale: The runtime migration is bounded and coherent, but the shipped plugin SDK currently exports RetryOptions; repository policy requires maintainer intent before accepting a new permanent plugin contract that is primarily motivated by deterministic tests.
  • Likely owner: Vincent Koc — The current shared retry API and Mattermost retry behavior both trace to Vincent Koc's implementation commit, making this the strongest available contract-owner signal.
  • Options:
    • Keep random internal (recommended): Expose full-jitter as the shared strategy but test it through an internal deterministic-random seam so plugins do not gain an unnecessary option.
    • Approve both options: Accept jitter: "full" and random as intentional additive public plugin SDK contracts.
    • Retain local retry: Keep the current Mattermost-owned loop until maintainers approve a broader shared retry API.

Security
Cleared: The four-file patch changes retry implementation and tests only, with no dependency, workflow, permission, secret, downloaded-code, package-resolution, or publishing changes.

Review details

Best possible solution:

Use the canonical shared retry engine for Mattermost, keep full-jitter semantics explicitly tested, and expose only the smallest maintainer-approved plugin SDK contract—preferably retaining deterministic randomness as an internal test seam unless external consumers need it.

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

Yes at source level: the current Mattermost loop, schedule-pinning tests, callback contract, and shared retry helper provide a high-confidence equivalence path. No real Mattermost service failure-and-recovery run is attached.

Is this the best way to solve the issue?

Mostly yes: consolidating the loop into retryAsync is the narrowest maintainable owner boundary, and the patch preserves the inspected behavior. The public scope of the deterministic-random hook should be narrowed or explicitly approved before merge.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P3: This is a low-urgency internal retry consolidation with no reported user-facing regression or outage.
  • add merge-risk: 🚨 compatibility: The PR expands exported plugin SDK retry option types that external plugins may compile against and adopt.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Testbox and deterministic unit tests are supplemental only; add a redacted live Mattermost retry transcript or runtime log showing the changed path, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.

Label justifications:

  • P3: This is a low-urgency internal retry consolidation with no reported user-facing regression or outage.
  • merge-risk: 🚨 compatibility: The PR expands exported plugin SDK retry option types that external plugins may compile against and adopt.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Testbox and deterministic unit tests are supplemental only; add a redacted live Mattermost retry transcript or runtime log showing the changed path, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +27, Tests +162. Total +189 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 75 48 +27
Tests 2 162 0 +162
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 237 48 +189

What I checked:

Likely related people:

  • Vincent Koc: Current-main blame ties both the shared retry contract and the Mattermost direct-channel retry loop to the same implementation commit. (role: introduced behavior; confidence: high; commits: e8c83ac0b4fd; files: src/infra/retry.ts, extensions/mattermost/src/mattermost/client.ts)
  • steipete: Shortlog shows the most touches across both central files, and the merged sibling retry migration plus this branch establish recent ownership of the consolidation program. (role: recent area contributor; confidence: high; commits: 3902adf9f673, ef4ef1cd05b0; files: src/infra/retry.ts, extensions/mattermost/src/mattermost/client.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 d4adddb into main Jul 11, 2026
151 of 158 checks passed
@steipete
steipete deleted the claude/chanref-p1-retry-jitter branch July 11, 2026 17:56
@steipete

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: mattermost Channel integration: mattermost maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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