Skip to content

fix(#2343): add post-reset spread to _github_csma_sleep_after_rate_limit - #2344

Merged
ralphbean merged 1 commit into
mainfrom
agent/2343-csma-spread-rate-limit
Jun 16, 2026
Merged

fix(#2343): add post-reset spread to _github_csma_sleep_after_rate_limit#2344
ralphbean merged 1 commit into
mainfrom
agent/2343-csma-spread-rate-limit

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

PR #2304 added post-reset spread to github_csma_sense to prevent thundering herd when runners wake after a rate-limit reset. The structurally parallel _github_csma_sleep_after_rate_limit function was missing the same treatment — multiple runners hitting a 429 would all wake at the same reset timestamp and fire simultaneously.

Extract the spread logic into a shared _github_csma_post_reset_spread helper and call it from both github_csma_sense (replacing the inline code) and _github_csma_sleep_after_rate_limit (added after the backoff sleep). Both paths now use GITHUB_CSMA_SPREAD_MAX_SEC to stagger runner wake times.

Note: pre-commit and make lint could not run due to shellcheck-py network restriction in sandbox. Scaffold Go tests pass.


Closes #2343

Post-script verification

  • Branch is not main/master (agent/2343-csma-spread-rate-limit)
  • Secret scan passed (gitleaks — df020f5fe71b7a899cd6cb391cf6e701e124548d..HEAD)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

PR #2304 added post-reset spread to github_csma_sense to prevent
thundering herd when runners wake after a rate-limit reset. The
structurally parallel _github_csma_sleep_after_rate_limit function
was missing the same treatment — multiple runners hitting a 429
would all wake at the same reset timestamp and fire simultaneously.

Extract the spread logic into a shared _github_csma_post_reset_spread
helper and call it from both github_csma_sense (replacing the inline
code) and _github_csma_sleep_after_rate_limit (added after the
backoff sleep). Both paths now use GITHUB_CSMA_SPREAD_MAX_SEC to
stagger runner wake times.

Note: pre-commit and make lint could not run due to shellcheck-py
network restriction in sandbox. Scaffold Go tests pass.

Closes #2343
@github-actions

Copy link
Copy Markdown

E2E tests did not run

E2E tests run automatically for org/repo members and collaborators on pull requests.

For other contributors, a maintainer must add the ok-to-test label after the latest push.

See E2E testing guide for details.

@github-actions

Copy link
Copy Markdown

Site preview

Preview: https://37674be6-site.fullsend-ai.workers.dev

Commit: 3ae6f72037b13610797fae4794bfbc9eb9468352

@ralphbean
ralphbean enabled auto-merge June 16, 2026 17:28
@fullsend-ai-review

fullsend-ai-review Bot commented Jun 16, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:29 PM UTC · Completed 5:39 PM UTC
Commit: 3ae6f72 · View workflow run →

@ralphbean
ralphbean added this pull request to the merge queue Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [edge-case] internal/scaffold/fullsend-repo/scripts/lib/github-api-csma.sh:182 — After this PR, a retry iteration can accumulate two spread delays: one from the new _github_csma_post_reset_spread call at the end of _github_csma_sleep_after_rate_limit, and a second from _github_csma_post_reset_spread inside github_csma_sense at the top of the next loop iteration (if the rate limit is still exhausted after the backoff). In the worst case this adds up to ~2x GITHUB_CSMA_SPREAD_MAX_SEC (default 120s) of spread delay on a single retry. This is unlikely in practice because the backoff already tries to sleep until the reset timestamp, so github_csma_sense will normally find sufficient remaining quota and return early without spreading.

  • [code-comment-accuracy] internal/scaffold/fullsend-repo/scripts/lib/github-api-csma.sh:61 — The echo message "Rate limit reset — spreading..." inside _github_csma_post_reset_spread uses "reset" which is specific to the github_csma_sense context. When called from _github_csma_sleep_after_rate_limit, the sleep may be an exponential backoff rather than a reset-timestamp wait (though the function preferentially uses the reset timestamp when available, so the message is accurate for the common path). Remediation: Optionally use a more generic message, e.g.: Post-sleep spread — adding ${spread_secs}s delay to desync from other runners...

@@ -176,6 +182,9 @@ _github_csma_sleep_after_rate_limit() {
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] edge-case

After this PR, a retry iteration can accumulate two spread delays: one from _github_csma_post_reset_spread at the end of _github_csma_sleep_after_rate_limit, and a second from _github_csma_post_reset_spread inside github_csma_sense at the top of the next loop iteration. Worst case ~2x GITHUB_CSMA_SPREAD_MAX_SEC (default 120s). Unlikely in practice because the backoff already tries to sleep until the reset timestamp.

if (( spread_max > 0 )); then
local spread_secs=$(( RANDOM % spread_max ))
echo "Rate limit reset — spreading ${spread_secs}s to desync from other runners..." >&2
sleep "${spread_secs}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] code-comment-accuracy

The echo message Rate limit reset inside _github_csma_post_reset_spread is specific to the github_csma_sense context. When called from _github_csma_sleep_after_rate_limit, the sleep may be exponential backoff rather than a reset-timestamp wait, though the function preferentially uses the reset timestamp so the message is accurate for the common path.

Suggested fix: Optionally use a more generic message, e.g.: Post-sleep spread — adding ${spread_secs}s delay to desync from other runners...

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Jun 16, 2026
Merged via the queue into main with commit 966abbf Jun 16, 2026
16 checks passed
@ralphbean
ralphbean deleted the agent/2343-csma-spread-rate-limit branch June 16, 2026 17:42
@fullsend-ai-retro

fullsend-ai-retro Bot commented Jun 16, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 5:48 PM UTC · Completed 5:56 PM UTC
Commit: 3ae6f72 · View workflow run →

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #2344 — Add post-reset spread to CSMA rate-limit sleep

Verdict: Clean workflow, no new proposals.

This PR demonstrates the full retro-to-merge pipeline working well. The retro agent on PR #2304 identified a missed thundering-herd fix in _github_csma_sleep_after_rate_limit, filed issue #2343, and the triage → code → review → merge pipeline completed in ~39 minutes with zero rework iterations.

Timeline

Stage Time (UTC) Duration Outcome
Issue filed (by retro bot) 17:03 Well-scoped bug with clear fix guidance
Triage 17:03–17:09 6 min Confirmed scope, proposed test case, labeled ready-to-code
Code 17:10–17:25 15 min Extracted _github_csma_post_reset_spread helper, called from both paths
Review (bot) 17:26–17:39 13 min Approved with 2 low findings
Human approval 17:28 Quick approval from @ralphbean
Merged 17:42 Total: 39 min issue-to-merge

What went well

  • Retro → issue → fix loop worked end-to-end: the retro agent's finding from PR fix: widen CSMA post-reset jitter to prevent thundering herd #2304 was correctly identified, triaged, coded, reviewed, and merged automatically.
  • Code quality: Clean single-file diff (+16/−7), used the helper-extraction approach recommended by triage.
  • Zero rework: No fix agent iterations needed.

Minor gaps (all covered by existing issues)

  1. Triage proposed a test case but code agent didn't write it — The triage agent suggested a specific regression test, but the code agent shipped without new tests. This pattern is tracked by #2001 (code agent should include regression tests for bug fixes) and #2313 (elevate test-adequacy findings for bug-fix PRs).
  2. Review found a valid edge case (double spread accumulation) but approved anyway — The review bot noted that a retry could accumulate ~2× GITHUB_CSMA_SPREAD_MAX_SEC delay. This was rated low and merged unresolved. The systemic pattern is tracked by #1286 (auto-file tracking issues for unresolved low-severity findings).

No new proposals filed — existing open issues already cover the improvement opportunities identified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add post-reset spread to _github_csma_sleep_after_rate_limit to prevent thundering herd on retries

1 participant