Skip to content

fix(http): bound coalesced reads and make throttle and token states explicit - #204

Merged
sweepies merged 4 commits into
mainfrom
fix/network-state
Nov 9, 2026
Merged

sweepies merged 4 commits into
mainfrom
fix/network-state

Conversation

@sweepies

@sweepies sweepies commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

First of several PRs that replace implicit state machines with explicit ones.

Changes

  • Coalesced reads no longer grow for the process lifetime. derived_reads kept the last full Response for every registry and derived read key, and the engine (with its HTTP client) lives across server batches. Each entry now lives only while a caller holds a lease on it, and is removed on drop, cancellation included. This is a plausible contributor to one failing repository retries the whole batch every minute, and memory grows until OOMKill #193's growth, but not a confirmed one.
  • Docker Hub 429s go through one explicit Throttle (Pulls, Host, Retry). Only manifest GETs use the pull counter, so a bare HEAD or tag-list 429 is now an ordinary throttle instead of a six-hour block on registry-1.docker.io.
  • Docker pull tokens: the persisted anonymous row has a key only for anonymous scopes, so a 401 on an account-credentialed request can't delete it. Expiry is checked in one place (live).
  • GitHub governor: while a bucket is spent, its reset only moves later, so a response still in flight can't cut short a rate-limit wait. The "probe once" comment now says what the code actually does.
  • OSV advisory paging fails on a repeated page token or after 100 pages per query. Before, it had no bound.
  • Release catalog: an explicit Head::Page / Head::Newest replaces the count == 100 test that decided whether the head page could be reused.
  • Release notes: a single Fences type tracks code fences for changelog parsing, sanitising, heading demotion and block closing. The changelog parser used to miss fences inside list items and block quotes.
  • cache_hits now counts answers taken from the cache (fresh, stale on 429, or 304), matching the GitHub side. It no longer counts every revalidation.
  • Cached's unnamed bool is now revalidating. The one-way readers_valid latch is documented: it is deliberate, because readers keep the moved-aside file open.

Looked at, no change

  • Installation-token expiry error type, installation-mapping TTL, and the digest:{tag} stale key: these work as intended.
  • The from_chart flag with empty sections: rendering already handles it.

Tests

New tests cover lease cleanup (finished and cancelled callers), the bare HEAD 429, the monotone governor reset, and fences inside lists and quotes. The patchula-http, patchula-github and patchula-datasource suites pass.

View guided diff Turn on auto-fix

…xplicit

- Coalesced registry and derived reads kept every response body for the
  life of the process. Each entry now lives only while a caller holds it,
  removed on every exit path including cancellation.
- Docker Hub 429s are classified once into an explicit Throttle. A bare
  HEAD or tag-list 429 is an ordinary throttle, not a six-hour host block.
- A 401 on an account-credentialed registry request no longer deletes the
  shared anonymous token row: only anonymous scopes have a persisted key.
- The GitHub governor keeps a spent bucket's reset monotone, so a response
  in flight can't shorten a rate-limit wait.
- OSV advisory paging fails on a repeated page token or after 100 pages.
- The release catalog's head says whether it is a reusable first page,
  instead of inferring it from the page size.
- One Fences type tracks code fences for every release-notes reader, so
  changelog sections agree with sanitising about fences in lists and quotes.
- cache_hits counts answers taken from the cache, not every revalidation.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula f7b397b Commit Preview URL

Branch Preview URL
Nov 08 2026, 08:08 PM

…counter

Review findings on #204:
- The shared fence tracker opened fences inside block quotes and list
  items but only a fence line closed them, so an unclosed fence in a quote
  swallowed every later changelog version. A fence now records its
  container and ends with it, and only a fence line in the same container
  closes it, as in CommonMark.
- A Docker Hub counter written `00` was read as non-zero by one check and
  zero by the other; both now parse it as a number.
Second-pass review findings on #204:
- `fit` closed a cut fence with a bare delimiter. For a fence inside a
  quote or list item that line ended the container and opened a new
  document-level fence, so everything after it rendered as code. The
  closer now carries the fence's quote markers and list indentation.
- Leading tabs counted as no indentation, so a tab-indented line ended a
  list item's fence early; a tab now reaches the next multiple of four.
- The cut-point check used its own fence detector; it now asks Fences, and
  the old helper is gone.
A tab between a list marker and a fence counted as one column, so the
closer `fit` writes landed outside the list item on GitHub and opened a
new fence. The content column now counts tabs to the next tab stop.
@sweepies
sweepies merged commit ef64dc4 into main Nov 9, 2026
11 checks passed
@sweepies
sweepies deleted the fix/network-state branch November 9, 2026 01:01
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant