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>