Skip to content

Poller

patchula serve keeps one row per catalog and OSV query any repository’s answer was computed from (the watch and input rows). A poller re-reads each row once for the whole fleet, at the freshness the Count already promises, and writes what it read to the same catalog and osv-listing state a run would. Runs and quiet checks then serve fresh inputs from the store, and read through when a row is past its bound or its view lacks the versions a run needs. The sweep still runs on sweepCron; a change the poller finds only updates its row, and nothing is woken by it yet.

The CLI and the Action have no poller. They keep the reuse rules in catalog views and the OSV listing’s freshness window, and write no watch rows.

Input Watched Bound
Catalog with a release-age wait yes reuse_hours(wait): clamp(waitHours - 1, 1, 24) hours
Catalog with no wait yes one poll interval, server.pollSecs (an hour by default)
OSV query (direct, lockfile and SBOM packages) yes http.advisoryFreshnessSecs
mise listings and flake inputs no —
Git refs, mutable tags, image tags no —

A row’s bound, max_age_ms, is the shortest among its dependents: each input row carries the bound its own repository’s run promises (for a catalog, from the shortest wait among the repository’s dependencies on it), and every settle that adds, drops or changes one recomputes the row’s. A repository that stops reading a key, or starts waiting longer for it, relaxes the bound at its next complete run, and removing a repository or its installation relaxes it at once.

mise listings and flake inputs run tools under a repository’s token; they stay unwatched (a bound of 0), as do digests, which every run reads live. An unwatched input is read by runs as it was before the poller: its row is never polled, and a run never serves it from the store. An OSV query is unwatched too when advisoryFreshnessSecs is 0.

The poller is a task of its own beside the queue workers, supervised like them: if it fails or panics, the server stops. It never takes an installation’s engine slot, so a long lockfile run does not hold polling back. Every ten seconds, or straight away after a full batch, it reads up to 1,000 rows whose poll_at has passed, oldest first, groups them by kind and scope, and re-reads each group:

  • Catalogs go through the engine’s catalog path, the one a run uses, with the candidates the stored view’s lookup described, so the poller describes the same versions a batch would, and stores the view the same way. A row with no stored view to describe is left to the runs.
  • OSV queries go out in one querybatch per group (1,000 queries a request), through advisory_listing, and store osv-listing rows.

Both read through the HTTP cache revalidating, as a manual retry does: the poller is what keeps rows fresh now, so a freshness floor never answers it, though a 304 still saves the body.

A success replaces the row’s content (a hash of the answer, the same hash a run’s input records), sets observed_at to now and changed_at when the content differs, resets failures, and schedules the next poll inside the bound: now + max_age_ms, less up to a tenth of it, spread by the row so rows observed together are not all due in one tick. Polling slightly early is what lets a run at any moment find the row fresh while the poller keeps up. A failure keeps the content, counts the failure and retries after a minute, doubling each time up to the row’s bound (or a minute, for a bound shorter than that). A row the poller cannot read (its installation is no longer served, its scope no longer matches the installation’s entries, or it has no stored view) is polled again after its bound, and the runs that list it read it themselves meanwhile. A row with no dependents is not polled from the hourly pass that marks it.

Each tick logs, at debug level, the polls by kind, the changes found, the failures and the deferred rows.

A row’s scope decides which engine reads it, following the threat model:

  • A public row (empty scope) is read by an engine built from the operator settings with no registry entries and GitHub credentials that never yield a token, so nothing it reads can carry a credential. A view it reads is stored public only when no request sent one; otherwise nothing is stored and the poll fails.
  • A scoped row (the owning installation and a digest of its credential scope and registry entries) is read by that installation’s own polling engine, built from the same key as its batch engine (the http settings and its registry credentials), and only while that engine’s digest matches the row’s. Rotating or removing an entry therefore leaves the row to the runs, which read under the new scope. A row is never read through another installation’s engine.

On the server, a queued batch’s run (full or quiet) serves a catalog from its stored view when the view’s watch row, under the same scope the view was read from, holds content upstream confirmed within the shorter of the row’s bound and the run’s own bound for the key (by the same rule its settle records), and the view’s candidates cover what the run needs. The run’s own bound counts because the row’s covers only dependents already settled: a repository that starts reading a catalog, or waits less for it, is never served by a bound a slower reader set. Otherwise the run reads through exactly as before (the stored view inside its reuse window, else a lookup), stores the view, and its settle records the observation, so a late or stopped poller costs requests, never freshness. When it reads a key through, the run describes the versions the stored view described as well as its own, so readers whose floors differ do not take turns reading the catalog through.

An OSV listing’s fetched_at is the row’s observation time and its window is the row’s bound, so a run that finds the listing inside advisoryFreshnessSecs serves exactly what the watch row would; past it, the run posts the query as before.

Manual retries (rechecks, ticked boxes, dashboard controls), the vulnerable-dependency second pass and remote runs still read live.

A settle moves a watch row only on a newer observation than the row holds: a run that read the store, or an older view, leaves what the poller wrote. Likewise a poll’s result is dropped for a row a run observed after the poll started. A row the orphan pass stopped polling is scheduled again when a run lists it, and removing a repository or an installation recomputes the bound of every row it read.

A catalog read from a stored view may have changed since: a release published, yanked, deprecated or removed. Before a PR is opened or updated, the write reads live the catalog of every version a planned write carries (a proposal, or a batch target) where the lookup served that catalog from a stored view, and compares it with the catalog the run evaluated, by the same content hash a watch row keeps. The run keeps that hash per reused catalog, so the write never compares against a view the poller replaced meanwhile.

When any of them differs, the run settles and writes nothing derived from the stale catalog: the repository’s write stops there and it ends stale, naming the catalogs that changed. A stale repository records no schedule turn and no stored answer for the sweep, and the server runs it again after a minute, as it does for any other race. The fresh views are stored when they can be, and the catalogs that changed are remembered for the repository (changed-catalogs state): its next run reads them live in its lookup, as a manual retry does, so its own re-read has nothing of them left to find, and a run that completes having read them all fresh, not from a registry’s quota fallback, forgets them. A catalog found changed therefore costs one extra run: each rerun reads live every catalog an earlier re-read found changed, and the set only grows until a run completes. A different catalog that changes before the rerun’s write costs another. After three requeues the claim fails instead (requeue-limit) and retries with the failure backoff, so a repository whose catalogs keep changing never retries every minute.

Only plans about to be written are checked: an unchanged PR settled from its receipt, a held plan or a dry run sends nothing. A catalog that cannot be read again, or only from a registry’s quota fallback, counts as unchanged. This applies to every writing run, the CLI’s included, where run then exits 5; a catalog the run itself just read is not read again. The one write before the re-read is closing obsolete PRs, those on branches no plan of the run wants.

A batch target the run’s catalog lists as yanked or deprecated holds the batch, whether the catalog was read live or served from a stored view; proposals never name such a release.

The poller keeps each bound the Count promised before it, with one interim exception: a catalog with no release-age wait. A run before the poller read such a catalog on every sweep, so a release was seen within one sweep. Now a run serves the catalog the poller confirmed within pollSecs, and a change the poller finds waits for the next sweep, since nothing wakes the repository yet. A release, prerelease or deprecation of a no-wait package is therefore acted on within pollSecs plus one sweep, up to two hours at the defaults. This covers every repository whose rules give a package no wait, including security.apply.waitHours = 0. It does not delay a fix for a known advisory: while a dependency is vulnerable, the second pass reads its catalog live on every run, so a fix release is seen at the next sweep as before. Advisory listings keep their bound, advisoryFreshnessSecs plus one sweep, which is what runs before the poller had, and catalogs with a wait keep reuse_hours(wait) plus one sweep.

Once a changed row wakes the repositories that read it, the no-wait bound comes back to about one poll interval plus the wake delay.

A repository without a config reads no catalog or advisory. The sweep skips it while its probe finds no patchula.pkl (see the quiet sweep), so a config added by a push whose webhook was lost is acted on at the next sweep; with the webhook it is acted on at once.

Every sweep probes the repositories it would skip: one batched GraphQL query per sweep batch (server.batchSize repositories, 32 by default) reads each repository’s default-branch head, the Count’s branches under his prefix with their first two open pull requests, his open issues with their updatedAt, and, for a repository without a config, whether patchula.pkl exists. Owner, name, prefix and login are variables, never query text. A repository whose answer differs from what its last run left runs in full, so a push, a pull request merge, close or edit, a dashboard tick or an added config whose webhook was lost is acted on within one sweep, about an hour.

A check run finishing changes none of that. So a run records which of its open pull requests the Count merges himself once their checks pass (merge rules, prs.batchMerge), and for those repositories alone the probe also reads each pull request’s head commit check rollup (statusCheckRollup { state }). When an awaiting pull request’s head went SUCCESS, the repository runs, and the head is remembered: a run that still cannot merge it (GitHub reports it blocked, say) is not run again for the same head. A lost check delivery is therefore acted on within one sweep too.

A run’s inventory is read before its writes, so a run that wrote leaves an observation the probe would find different. The run therefore also stores its receipts: the tip of each branch it pushed or that it deleted one, the pull requests it opened and those it closed or merged, and when its writes ended, and the dashboard issue it created, edited or closed. The probe accepts a difference that matches them — a branch at the tip the run pushed or gone because it deleted or merged it, a pull request it closed, a dashboard it closed, anything else last updated no later than the run’s writes — and stores its answer as the new observation without running the repository. A pull request the run opened that is no longer open, a pull request that appeared on one of his branches that the run did not open, or anything updated after the run’s writes, runs it.

A person’s edit to one of his pull requests’ title, body or labels between the run’s inventory read and the end of its writes is last updated before the writes ended, so the probe takes it as the run’s own and does not run the repository for it. The Count acts on none of those fields, except the re-check and batch boxes, which arrive as edited deliveries; a lost one inside that window waits for the repository’s next run.

The probe asks for one more branch than the run saw, so a new branch shows without paying for a page of a hundred. A repository with a full page of his branches, or a prefix that is not a directory (matched by a search), reads a whole page and compares only the head and issues when GitHub has more. A missing or null connection is never read as empty: it is a failed read, and a repository whose probe fails twice in a row runs in full. A probe answer reporting the GraphQL budget under half stops the probing until the budget resets.

  • Digests (refs, mutable tags, image tags) are read by every run.
  • A changed row wakes nothing: runs still come from sweepCron, so a change is acted on at the next sweep, and a no-wait catalog’s bound is pollSecs plus one sweep (see bounds).
  • With the sweep still hourly, a run reads through any row past its bound. The guard that enqueues the fleet when the oldest overdue poll_at is more than two intervals late belongs with the timer that replaces the sweep.