Gnome toolbar for Tangled code review.

Cap event-driven refreshes at one per 30 seconds #7

targeting main from azurite-frogmouth.test.pds.did.bot/gnome-shell-extension-tangled-reviewer:fix/throttle-event-refreshes
Closed opened by and assigned to azurite-frogmouth.test.pds.did.bot
targeting main from azurite-frogmouth.test.pds.did.bot/gnome-shell-extension-tangled-reviewer:fix/throttle-event-refreshes

Your live helper had been refreshing back to back since about 17:40, with each refresh starting within a second of the last one ending. That's ~6 refreshes and ~290 requests a minute to api.tangled.org, at Bobbin's rate limit and on the IP your other tools share.

Cause. Agents push to watched repos (didbot, vibescrobble, …) a few times a minute; a 60 s Jetstream sample had 4 Tangled commits. Each relevant event scheduled two full refreshes, at +4 s (settle) and +20 s (recheck). They were only collapsed when they fell within 2 s of each other. A refresh takes ~8.5 s and refetches everything (~50 requests), so they never stopped.

Fix. A pure nextDeadline(pending, last, now, ms) that the driver uses for every schedule effect:

  • A request already covered by a pending deadline (one at or up to 30 s after the time asked for) adds nothing.
  • Otherwise the new deadline is no sooner than MIN_SCHEDULED_GAP_MS (30 s) after any other deadline, pending or fired.

A quiet event still refreshes 4 s after it arrives, and its recheck comes 30 s after that. Under constant events, refreshes run every 30 s, and the last event still gets one after it.

Tested.

  • New engine tests simulate a quiet event, and an event every 15 s for ten minutes: no two refreshes are under 30 s apart, there are no gaps much longer than that, and the last event still gets a refresh after it. 67 pass; the typecheck passes.
  • Live, for 3 minutes, against permadeath.com and lance.blue, with 14 relevant events: after the cold start, refreshes came at 18:15:58, 18:16:28 and 18:16:58, with 0 failed requests.

The real fix is refreshing just the repo an event names; that's added to BACKLOG (P2).

🤖 Generated with Claude Code

Commits 0