mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-11-28 01:11:03 +01:00
* Include pre-releases no longer asks GitHub about every app on every check With pre-releases on, the release feed was skipped and every app went to GitHub's API on each 12-minute check, about 95 requests an hour against GitHub's limit of 60 per network address. The feed is now fetched as usual, GitHub keeps to the fallback's pace (hourly per app once loaded), and a newer stable release in the feed replaces a saved older beta or RC between asks. Adds docs/github-budget.md (spec and plan for #713) and the glossary terms. Part of #713. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * One GitHub budget per launcher, so background checks can't use up GitHub's limit Every GitHub API request (release checks, version lists, nightly discovery) now counts against one budget: 30 an hour for the stable launcher, 15 for the Developer Builds backend, kept on disk as a rolling hour beside each one's release cache. The launcher also stops 10 short of GitHub's own X-RateLimit-Remaining, which every machine on the network shares. When requests run short, background checks wait so the user's own action still gets an answer: user, then installed apps, apps not installed, the nightly track, then nightly discovery. A check pressed again within 2 minutes reuses the last answers. While a request is held back, saved answers stay and the footer says when GitHub is next asked. Part of #713. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Pinned versions and the nightly track stop asking GitHub on every check A pinned version never changes, so once its release is in the saved version list GitHub isn't asked about it again. Version lists are now saved in the release cache on disk and stand in for an hour (was 15 minutes, in memory). An app following the nightly is asked about at most every three hours, the saved list answering in between, unless the user presses check. Part of #713. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Pre-releases on: show the feed's stable release while GitHub has nothing saved Between GitHub's asks, an app with no saved GitHub answer for the pre-release track (pre-releases just turned on) showed nothing until GitHub's next turn, though the feed listed its stable release (CodeRabbit on #1602). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Pre-releases: test the check plan's hourly pace, and ask again when the setting changes The last-asked record is now keyed by app and pre-release setting, so an answer under one setting doesn't stand in for the other. check_plan's feed decision moves into remote_plan so a test can drive it without a live feed. * GitHub budget: fix the review findings - Nightly discovery held back by the budget no longer saves a server backoff, so the user's own check on the Developer Builds page still runs (CodeRabbit, backend.rs:737). - GitHub's X-RateLimit-Reset is trusted for at most an hour, as source.rs does for refusals, so a computer clock behind GitHub's can't lock every request out. - Each request counts against GitHub's remaining count before it answers, and an older answer can't raise the count within the same window. - The 2-minute forced-check reuse starts only from a forced check, not from any check, so a check right after launch or a settings change still asks GitHub (CodeRabbit, backend.rs:782). - Requests that carry ARTCRAFT_LAUNCHER_GITHUB_TOKEN skip the budget; the token has its own limit. - The footer's clock time goes through jiff instead of hand-rolled arithmetic. - The two new footer strings get translations in every catalog instead of English copies, so the translated notice they replace doesn't regress. This departs from AGENTS.md rule 16 (English only in feature PRs): storytold/craft-i18n may replace them. Each fix has a test that fails with the fix reverted. * Pinned and nightly pacing: fix the review findings - A pressed check on the Nightly track asks GitHub now, past a saved version list however recent (chosen_within with a max age of 0) (CodeRabbit, source.rs:428). - Opening Choose version asks again for a list saved more than 15 minutes ago (CHOOSER_FRESH, the in-memory lifetime before #713); background tracks keep the hour. - The Nightly track keeps its own last-asked record, apart from the stable track's. - A request the launcher's budget held back says so instead of "GitHub's request limit was reached" (CodeRabbit, source.rs:253). - releases.json saves hold a lock across snapshot and write, so an older snapshot can't land after a newer one. Each behaviour fix has a test that fails with it reverted, except the save lock, which is a few lines checkable by reading (a stress test didn't catch the race reliably, so it isn't added). * Clock: read the hour and minute through core's jiff so the web build compiles ui-egui only depends on jiff off the web, so the clock moves to core::time::clock_from_unix beside civil_from_unix, and local_time adds the zone's offset the same way civil_at does. * GitHub budget: answer CodeRabbit's second pass - A late answer from a window GitHub has since refilled no longer lowers the new window's count; only answers naming the same window merge, and a later window replaces it. - A check pressed again within the reuse window still looks past a feed that is behind GitHub, so it keeps the newer release the forced check found instead of the feed's. - The budget-refusal tests use a client without the environment's GitHub token. * Pre-releases: a refused GitHub turn leaves the feed's release standing With pre-releases on, a due GitHub lookup that fails with nothing saved (refused by the budget, say) now answers with the stable release the feed lists instead of an error. * Pinned and nightly pacing: a list stamped ahead is never fresh, and tests skip the token - A saved version list whose time is ahead of the clock (set back since) isn't reused, so a pressed Nightly check (max age 0) always asks GitHub. - The zero-budget tests use a client without the environment's GitHub token. * Releases: keep the newer of the feed's release and GitHub's saved one A check reusing a forced one's answers, or a GitHub turn that fell back to a saved release (over budget, say), now keeps the feed's stable release when it is newer than what GitHub had saved, and keeps a saved release (an RC, say) that is newer than the feed's. A live GitHub answer is unchanged. * fmt: wrap the CacheFile test initializer after adding versions * Releases: a GitHub rate limit is not reported as a budget hold When GitHub itself refuses, held_back_why stays silent even if a budget wait is also recorded, and a stale version list is not reused. * Nightly: a due check asks GitHub past a recent version list A due automatic check was going through chosen(), which reuses a list saved up to an hour ago. If Choose version had just refreshed that list, the check still advanced the three-hour timer and could miss a Nightly published in between. Due checks now use the same chosen_within(..., 0) path as a pressed check. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
3.9 KiB
3.9 KiB
GitHub budget
Spec and plan for #713: the launcher asks GitHub's API often enough that users reach GitHub's rate limit (60 unauthenticated requests an hour per network address, shared by every machine on it; a 304 to a conditional request still counts unless the request is authenticated). Terms are in GLOSSARY.md.
Where the requests came from (main at d2d19f8)
| Path | Before |
|---|---|
| Stable, pre-releases off | Release feed; GitHub only for apps the feed lacks, hourly per app |
| Pre-releases on | Feed skipped; every app asked on every update check (5-minute throttle, 12-minute checks): about 95 an hour |
| Pinned version or Nightly track | Feed and throttle skipped; version list cached 15 minutes in memory, no ETag |
| Developer Builds copy | Every app on the Nightly track, as above, plus nightly discovery paging |
| Forced check | Every throttle skipped |
Decisions
- GitHub budget. One ceiling per launcher on GitHub API requests, shared by every path: 30 an hour for the stable launcher, 15 for a Developer Builds copy. Kept on disk as a rolling hour in each copy's own data folder; the two copies don't share a file, so the nightly storage stays separate.
- GitHub's own count. Stop at the lower of the budget and
X-RateLimit-Remainingminus 10. Each request counts against that number before GitHub answers, a lower count within one window stands, and a refill time is trusted for at most an hour. Requests that carryARTCRAFT_LAUNCHER_GITHUB_TOKENhave their own limit and skip the budget. - Priority when short. The user's own action (Choose version, installing a pinned version, a forced check, opening Developer Builds), then installed apps, then apps not installed, then the Nightly track, then nightly discovery.
- Pre-releases on. The feed still answers between GitHub's asks, which keep the fallback's pace (hourly per app once everything has loaded). A newer stable release in the feed replaces an older saved beta or RC at once.
- Pinned version. Fetched once and saved; asked again only when the pin changes or the saved copy is missing. The version list is kept an hour, on disk; opening Choose version asks again for one older than 15 minutes, and a pressed check on the Nightly track asks now.
- Nightly track. At most every 3 hours per app, with its own record apart from the stable
track's. Nightly discovery for Developer Builds already waits 6 hours between automatic sweeps (
nightly_lookup::EVERY). - Forced check. Skips the per-app throttles but not the budget; a second one within 2 minutes of a forced one reuses its answers (an automatic check doesn't count). A budget refusal of nightly discovery isn't saved as a server backoff.
- Budget spent. Saved answers stay. The footer and automation results say when GitHub is next asked ("Next GitHub check at 14:05"); a refused forced check is not reported as success.
Out of scope: the web build (it asks from the user's browser with its own logic), a user's own GitHub token (#1028), and the release feed serving betas, RCs and nightlies (a storyteller-web change).
Plan
Three pull requests, each against #713, in this order:
- Pre-releases keep to the feed's pace (decision 4):
check_planfetches the feed and keeps its GitHub pace with pre-releases on;latest_forprefers a newer stable from the feed over a saved older pre-release. Adds this document and the glossary terms. - GitHub budget (decisions 1-3, 7, 8): one budget in
GitHubSource, charged by every API request (get_api,nightly_get), saved next to the release cache, with priorities passed by the caller and the remaining-count header read inHttp; footer and automation wording. - Pinned and nightly pacing (decisions 5, 6): pinned releases saved in the release cache, the version list cached an hour on disk, and the Nightly track throttled to 3 hours.