Repository navigation
Conversation
…n-free cache eviction - A GraphQL 200 with RATE_LIMITED and x-ratelimit-remaining: 0 is the primary limit: wait for x-ratelimit-reset on the graphql bucket instead of the secondary cooldown and an hour of one write a second. - A 401 to App installation credentials drops the cached token (Credentials::invalidate) and retries once with a fresh one. - MAX_WRITE_BURST has one definition, in patchula-config. - Drop the unreachable search resource branch. - Cache eviction reads a trigger-kept byte total (migration 016) instead of summing every body after each write. Bumps the states and derived representations whose hashed sources cover crates/github/src/, and those the bumps cascade to.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
count-patchula | 3351f91 | Commit Preview URL Branch Preview URL |
Nov 15 2026, 10:56 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
crates/github/src/governor.rs). GitHub answers an exhausted GraphQL primary limit with HTTP 200, aRATE_LIMITEDerror andx-ratelimit-remaining: 0. The governor treated every such answer as a secondary limit: it guessed a 60 s cooldown and cut writes to one a second for an hour. Now aRATE_LIMITEDanswer with a spent window, and no error message naming the secondary limit, counts as primary exhaustion. The graphql bucket waits untilx-ratelimit-resetand writes are left alone. Answers without the header, or with "secondary rate limit" in a message, still take the secondary path. The classification lives in a smallGraphqlLimithelper.app.rs,credentials.rs,lib.rs). A newCredentials::invalidate(rejected)hook defaults toNone, meaning "can't mint another token, don't retry". App installations implement it by clearing the full-installation slot, but only while it still holds the refused token, so a token another request minted in the meantime is kept. On a 401,exchangeinvalidates the token and retries once. GitHub runs nothing it refuses with 401, so this is safe for writes too. The retry doesn't count against the rate-limit retries, and a second 401 is returned.MAX_WRITE_BURSTdefined twice. Now there is one definition, inpatchula-config, andpatchula-githubuses it. I picked the directiongithub → configbecause every crate that depends on github already depends on config, so nothing gains a new transitive dependency. The other direction would pull reqwest, SQLite and jsonwebtoken into config and every crate that uses it. The unusedpubconstant in github is gone.search/branch inexchange: removed. Nothing calls search, and on an Enterprise root the branch couldn't match. The governor still keys buckets byx-ratelimit-resource.httptable (crates/cache/src/store.rs). Migration 016 adds a one-rowhttp_bytestable. It is seeded from the current sum, and AFTER INSERT/DELETE/UPDATE OF body triggers onhttpmaintain it. Several processes can share the cache file (the CLI's default directory is shared, and the cache uses WAL), so the counter lives in the database and changes inside each write's own transaction. A per-Storecounter would drift.evict()re-reads the row after each delete. A rebuilt cache after corruption recovery starts at 0 on an empty table.cache schemais now 16.Tests
x-ratelimit-reset, no secondary cooldown, no write throttle). ARATE_LIMITEDanswer without a spent window, without headers, or with a secondary message stays secondary. A GraphQL answer that spends the last point without an error is not limited.SUM(length(body))after insert, a resize through upsert, a 304 refresh, removal and eviction, including writes through a second handle on the same file. The table stays within budget over 40 puts. The migration test checks that 016 seeds the counter from existing rows.rewinddrops 016's objects.cargo test -p patchula-github -p patchula-cache, the state/derive parity tests in datasource, notes, engine and update, andcargo clippy -p patchula-github -p patchula-cache --all-targets -D warningsall pass.State versions
crates/github/src/is hashed bysource-head,tag-catalog,tag-objectandrelease-notes. Bumping those cascades throughcrates/datasource/src/andcrates/notes/src/tocatalog,catalog-controls,changelogandnotes-adapter, and to the derivedgithub-release-head,notes-adapter-listing,parsed-postgres-sgmlandparsed-go-history. All are bumped by one, with their rows updated. Expect a one-time miss on those entries.Dropped
Nothing.
Follow-ups
repos/{owner}/{repo}read for scoped mints (App::repository_id) uses the installation token directly, without the 401 retry.