SQLite cache
patchula-cache uses rusqlite with bundled SQLite, so the system
SQLite’s version and features never matter. HTTP bodies are stored with Zstd
level 3.
Layout
Section titled “Layout”A cache is a directory. Cache::open_dir creates it and opens
cache.sqlite (with SQLite’s -wal and -shm files) inside it. The partial
clones for lockfile tools go in worktrees/ and the tool store in tools/,
unless PATCHULA_TOOLS_DIR moves it. The package caches the tools share
between runs go in tool-caches/, partitioned as
lockfiles describes: public for a run whose
files are provably public-only, installation-<hash> for an installation’s
other runs, and private-<hash of the entries' scopes> for runs given operator
credentials, with no read-only lower layer between them. Pruning is
throttled per cache root and takes tool-caches/prune.lock so concurrent
prunes never over-evict. The server also keeps server.lock
there. The CLI’s default directory is shared by every checkout on the machine,
so concurrent local runs use one database through WAL and the busy timeout.
Opening takes an exclusive lock on cache.lock while it checks and migrates
the database, and migrations read the schema version inside an immediate
transaction. In the tool store, each tool run, and the mise install before a
version’s first run, holds patchula-store.lock shared, and removing versions
(clearing an unproven install, tools prune) holds it exclusive, so no run
loses a tool it is using. A version is proven once mise install succeeds,
however the tool then exits.
Threads and transactions
Section titled “Threads and transactions”Open one Cache per batch and clone its handle. One OS thread owns writes,
migrations and corruption recovery, with a queue of 128 jobs. Four more each
own a read-only WAL connection and a 32-job queue; round-robin dispatch runs
SQLite reads and Zstd decoding in parallel without blocking async workers.
Readers keep statements short, so decoding never holds a WAL read transaction.
Reader corruption disables the pool for that handle and retries through the
recovery coordinator.
Read access updates are coalesced and flushed in one transaction before writer
jobs and on shutdown, so reads never take SQLite’s write lock. Body inserts and
release merges are transactional. The database uses WAL, a five-second busy
timeout and synchronous=NORMAL, since cache data is reproducible. Only one
batch should own a cache path during corruption recovery: quarantine is not
coordinated across processes.
HTTP entries
Section titled “HTTP entries”Keys normalise method case, the URL (authority, default port, path, fragment)
and header names. Query order is kept, because repeated parameters can be
order-sensitive. Callers choose the vary-relevant headers; for authenticated
data they include a digest of the credential namespace, never a raw token.
GitHub’s namespace is the credential scope, which names the credential’s
reach (see token scope); hints,
catalogs, listings and inventory-actor state are keyed by it too.
The conditional-GET protocol the registry cache and the GitHub client share —
keys, entries, validators, 304 merges, Retry-After and bounded decoding —
lives in patchula_http::conditional; each client keeps its own freshness
policy, sender and error mapping on top.
An entry stores the status, validators, selected response headers such as
Link, the compressed body, fetch time, expiry and Cache-Control hints.
Expiry keeps validators. An invalid compressed body is a miss, and its
validators are never sent.
Large registry bodies use a versioned local representation in the key. npm,
Cargo sparse indexes, PyPI, GitHub REST release heads and Git trees store a
derived document with only the fields the Count reads, never the raw response.
The mise-versions mirror’s documents are stored as mise-versions, which
lookups and release notes share, so each URL is cached once.
A Helm repository’s index.yaml is one request per repository but is stored
chart by chart: a table of each chart’s byte range, then each chart’s own
document, so a lookup parses the table and its own chart and never the rest. An OCI
tags/list page is stored as its kept tags and, kept or not, the first tag
it listed, the last, which names the page’s end, and the one before the
last: oci-version-tags keeps only the tags a versioning
scheme could read and serves every lookup without an extract pattern,
oci-tags keeps every tag for those with one. The two never share an entry.
A GHCR listing that keeps only version tags resumes from ghcr-tag-cursor
state: the last tag the last full or resumed read listed, the tag listed
just before it (prev), and the version tags read up to it. A resume asks
for tags/list?last=<prev> and needs the answer’s first tag, kept or not,
to be the cursor’s last tag. last naming a deleted tag answers no tags, and a tag
deleted and pushed again is listed at the end, whatever its digest, so
either tag deleted, or re-created after other tags were pushed, shows as
another first tag or none. That, or a page after the cursor that lists a
known tag, is a full read. A forward-only cursor cannot see tags that
end up before prev: re-creating prev and then last with nothing
between leaves them adjacent at the end, the check passes, and a tag
pushed before the re-creation is skipped. There is no periodic full read
to catch it, by design. No manifest is read. Only a read with no page
answered stale from the cache moves the cursor, and a listing of one tag
stores none. The cursor is public when no operator entry, with or
without credentials, covers the image’s tags/list URL, the catalog views’
rule, and otherwise scoped to the credential scope and the entry that covers
it.
Derivation runs on spawn_blocking; a successful derived response streams
straight into its derive worker, so the raw document is never held whole.
The request’s host permit is held until its body is read, so in-flight bodies
stay inside the host limit. Reads that arrive already buffered derive under a
four-job limit. A 304 updates only metadata and reuses the compact body. A
derived representation is name@v{VERSION}~{fingerprint}, where the version
belongs to the transform’s own code rather than the release and the
fingerprint to the locked versions of the crates it depends on: a new release
keeps the cached entries of every transform whose code and dependencies did
not change, and a change to one transform misses only that representation.
tests/derived-versions.tsv guards the contract — it hashes the source files
that produce each representation’s bytes, and the owning crate’s parity test
fails when the code moves without a version bump; the maintenance step is to
bump the Derived‘s version and update the row in the same commit. The row
also lists the Cargo.lock packages the bytes depend on. Those are not hashed:
the cache crate’s build script reads Cargo.lock and both tables and
fingerprints each row’s locked versions (the first 12 hex digits of a sha256)
into its key, so a dependency bump, such as the Count’s own update PRs on
this repository, invalidates exactly the representations that list the crate
and needs no version bump. A row listing - has no fingerprint and its key is
plain name@v{VERSION}. The fingerprint covers only the listed crates’ locked
versions. A git or [patch] source whose code changes without a version
change, and a transitive dependency that is not listed, change nothing in it:
list such code in the row’s sources, or bump the version by hand. A workspace
or path crate cannot be listed at all, since Cargo.lock holds it at the
workspace version; list its files as sources. The parity test checks only that every listed package
is in Cargo.lock, so a typo fails, and the build fails outside the workspace
rather than key without the lock. The fingerprint follows ~ because + is
the retired per-build marker migration 014 deletes on sight; names may
contain none of @, ~ or +. A derive may only read code in its row’s listed files, and
since whole files are hashed a formatting or comment edit in one forces a
bump too — batch cosmetic edits in those files. The parity test also scans
the crate’s sources for Derived::new("<name>" (and the pull-token
representation constant), so a representation cannot exist without a row,
and a listed file that is renamed fails naming the row and the missing
file. Entries written
under the retired name+build scheme are never read again and are deleted
when the cache opens; raw and derived namespaces never share validators.
Opening the cache also prunes superseded keys. The build script emits each
tabled name’s version (the row’s, which the parity test holds equal to the
code’s) beside its fingerprint, so the cache knows the one key this build
reads for every row of both tables. After migrations it deletes every state
row and derived HTTP body under a tabled name whose key is not that one: an
older version, an older fingerprint, or the plain key from before
fingerprints. It is one indexed join per table: a name’s keys are the range
name@v to name@w, found through the state table’s primary key and an
index on the representation an HTTP key names (migration 015). Names that
are no longer tabled are not pruned. Two builds that share a cache directory
and differ in a version or a locked dependency prune each other’s entries for
those names, so each misses once after the other has run.
Opening returns an Opened summary, which the CLI prints before a batch and
the server logs at start: where the database came from (an existing file, a
new one, a rebuild after corruption, or memory), each tabled name the prune
dropped entries under and how many, how many HTTP responses eviction
dropped, and what is left. The counts come from COUNT(*) over indexes and
the http_bytes row, never from the HTTP timestamps, which sit after each
body and would page every body in. Instead the opened table (migration
017) holds the time of the last open, which each open reads and replaces, so
the summary says how long the cache sat unused.
The default 256 MiB budget counts compressed HTTP body bytes. An access clock
approximates LRU and evicts whole HTTP rows, validators included, until the
cache fits, also on open after the budget is lowered. A write within the
budget takes no write lock for eviction; one over it evicts in a single
immediate transaction. The total lives in the
one-row http_bytes table, kept by triggers on http inside each write’s
transaction (migration 016), so a write compares one row to the budget
instead of summing the table, and processes sharing the file see one total. Release lists and
state values are outside the budget, so it does not cap the file size.
Releases and state
Section titled “Releases and state”Release order is the upstream’s newest-first order, never inferred from semver
or dates. merge_releases starts at the head and stops at the first item
already stored. Later pages of the same scan pass the previous page’s last
inserted version to merge_release_page as after, which tells a refresh
prefix apart from initial pagination. The newest item is also kept in
release_heads.
Sources that date one version per request (Go’s .info, a Maven POM’s
Last-Modified) keep each answer as release-dates state, per package and
per operator registry entry that answered, a mirror standing in included: a
version’s date, or that the registry cannot serve it. A lookup asks only
about its candidates (the versions policy can read a date of, see
sources) with no answer yet, wherever
they sort; a failed request stores nothing, so the version stays unchecked
and the next lookup asks again. These requests bypass the HTTP table: the
answer is kept here, so writing the response there too would only cost a
writer transaction and budget an npm packument could use. They still take
the host’s permit, honour its cooldown, retry a 429 like a registry read, and
carry the operator entry’s credentials.
Typed values the Count keeps between runs (hints, extractions, catalog views,
receipts and the like) live in state; the server queue, installations and
repositories keep their own tables, indexed (migration 018) by the times
their prunes read and by the claim, priority and availability the next-work
pick orders by. The watch and input rows have their
own tables and indexes (migration 020). A state row is one value, keyed by a
namespace and a canonical-JSON scope. The value is JSON; a type that sets
COMPRESSED (catalog views, which for an image with hundreds of thousands of
tags run to tens of megabytes) keeps it zstd-compressed, serialized through
the encoder and parsed through the decoder, so no run holds the whole JSON
document in memory. A State implementation names its
NAMESPACE and VERSION, forming name@v{VERSION} (with a dependency
fingerprint for a code-versioned state, below), and declares the Scope struct
whose named fields say what the entry is about.
Values are JSON. A stored value that fails to decode is a miss, logged at
debug level; database errors remain errors. Each call site owns its value and
scope types, so a change to a stored shape bumps VERSION or NAMESPACE
rather than silently reusing entries written for the old one. The exception
is a shape that reads both ways: auto-merge history rows went from whole REST
pull requests to the five fields its readers use, and each shape decodes as
the other, so they stay at version 1.
The states derived from a repository’s files (config, config-files,
files and extract) keep one row per repository, scoped by its name alone.
The value holds the key it answers for (the commit, or the hash of the files
read, with the config’s hash), a read under any other key misses, and a write
replaces the row, so a repository’s rows stay one per state however many
commits it is scanned at. The commit a read asks for still comes from a head
read under the run’s own credential, as it did when the commit was part of
the scope. files and extract, which can hold megabytes, are kept
zstd-compressed (COMPRESSED), serialized through the encoder and parsed
through the decoder.
A value derived from an immutable input by this build’s code — an evaluated
config, an extraction, a parsed changelog, a not-ours verdict — sets
CODE_VERSIONED instead, and VERSION names the deriving code: a new
release keeps the cached entries of every state whose derivation code did not
change, and a change to one state’s derivation misses only its namespace.
tests/state-versions.tsv guards the contract — it hashes the source files
and source trees (an entry ending / covers every file under it, so a file
added to a listed tree fails too) the derivation reads, and the owning crate’s
parity test fails when the code moves without a version bump; the maintenance
step is to bump the VERSION and update the row in the same commit. The row’s
listed Cargo.lock packages key the entry the way they key a derived
representation: the namespace is name@v{VERSION}~{fingerprint}, so a
dependency bump misses exactly the states that list the crate, with no
version bump. Exempt states carry no fingerprint. A derivation may only read code in its row’s listed
files and trees; over-include rather than miss, and batch cosmetic edits in
listed files. The parity test also scans every impl State in the
workspace’s non-test sources — #[cfg(test)] modules and tests/
directories do not count — and requires each to be either a row in
tests/state-versions.tsv or an entry with a reason in
tests/state-exempt.tsv; an unlisted state, a listing whose impl is gone
and a flag that disagrees with the table all fail, so states in crates
without a parity test of their own stay covered. The rule for which table
a state lands in: a value this build’s code derives from an input whose
key does not capture the decoded result, kept without a TTL — a permanent
memo — is code-versioned. A state refetched within a bounded freshness
window, or holding facts that are not code-derived — receipts, history,
permits, run timestamps, hints — is exempt; a stale hint only costs a
wasted read and never a wrong answer. Entries written under the
retired name@vN+build scheme are never read again and are deleted when the
cache opens, and so are a code-versioned state’s entries under any key but
its current one (see the prune above).
Schema and corruption
Section titled “Schema and corruption”Migrations are transactional and tracked with SQLite’s user_version. A
migration that retires a representation costs one unconditional fetch per
affected registry. A database from a future schema is rejected untouched.
patchula cache schema prints the newest schema the binary supports; the
GitHub Action keys its saved cache by it, so a run never restores a database
its binary would reject, and a release with a new migration (such as 020’s
watch and input tables) starts the Action from a cold cache.
Opening runs quick_check. SQLITE_CORRUPT, SQLITE_NOTADB or a failed
check closes the connection, moves the file and its WAL and SHM sidecars to a
unique .corrupt-<timestamp> name, warns through tracing and rebuilds.
Corruption during an operation rebuilds and retries it once. If that fails, the
cache warns and falls back to memory so the batch keeps running. Permission,
busy and future-schema errors are not treated as corruption. The application
must initialise tracing for the warnings to show.
Host limits
Section titled “Host limits”concurrencyin the settings, or--concurrency, sets repository scan parallelism (default 8).- Registry requests use per-host semaphores,
http.defaultHostConcurrency(64) each, independent of repository work.http.hostConcurrencyoverrides single hosts, such as["api.github.com"] = 8. Limits must be 1–100. - GitHub REST and GraphQL share one governor, sized by the
api.github.comhost limit. Without one, a CLI run takes the default host limit capped at 16 and the server keeps 4. That is below GitHub’s 100 simultaneous requests, but does not by itself avoid its point and CPU secondary limits. - The shared reqwest pool keeps up to 32 idle connections per host.
- A registry 429 sets a cooldown for that host and is retried at most three
times, honouring
Retry-Afteror backing off 1, 2 and 4 seconds. Waits over 60 seconds and exhausted retries fail, and queued callers wait out the cooldown. Docker Hub pull-quota errors on manifest GETs are returned at once and hold back manifest GETs for the quota window (six hours when Docker Hub names none). HEAD and tag-list requests don’t use the pull quota, so their 429 cools the whole host only for a window the counter names; otherwise it is an ordinary throttle. Amirror.gcr.io429 means the mirror hasn’t fetched the content yet: it is returned at once, with no cooldown and no retry, and the read goes to Docker Hub (see Docker Hub mirror). - Overlapping identical registry and derived reads share one request. Each shared answer lives only while a caller waits on it, so memory follows the reads in flight, not every URL read since the server started.
- Only successful responses are cached, so a rate-limited pagination attempt never becomes a complete catalog.
Freshness floors
Section titled “Freshness floors”Three settings keep answers reusable past what upstream validators alone would allow. The user-facing summary is in sources.
http.registryFreshnessSecs(3600) applies to OCItags/listpages, whether or not they carry an ETag or Last-Modified: Docker Hub sends an ETag and no max-age, which would otherwise cost a conditional request per page on every run. After expiry every page is revalidated, so additions, deletions and retargeting anywhere are seen. It also applies to successful OCI 1.1referrers/<digest>lists from any registry. Registries send those with no validators, so each warm run would otherwise fetch them in full; a list only grows when an SBOM or signature is attached later, which can go unseen for up to the window. Theirsha256-<hex>fallback tags, manifest and tag digests keep their upstream policy.http.goFreshnessSecs(3600) applies to publicproxy.golang.org@v/listand@latest, even when the upstream max-age is shorter..infodocuments keep the upstream policy.http.advisoryFreshnessSecs(3600) keeps the(id, modified)pairs OSV’squerybatchlists for each{ecosystem, package, version}asosv-listingstate. Inside the window the listing answers locally and only stale or missing queries are posted; a failed batch stores nothing, and a revalidation (an explicit recheck, dashboard tick or retry) always asks OSV. Listings and the advisory records kept until OSV reports them modified (osv-advisory) are each public or scoped, by the catalog views’ rule (Engine::public_read) over OSV’s batch and record URLs, which are fixed. A run with no operator entry or mirror covering those URLs reads only the public row; a run with one reads only the row scoped to its credential scope and operator entries. A row is written public only when the run has no such entry and its requests sent no credential; otherwise it is written scoped. A read predicted public that sent a credential is logged. The engine hands the datasource the rule and the scope digest as anOsvAccess, so a public advisory input always stands for public rows.
Zero restores upstream freshness at once, also on an existing cache. Floors
count from the original fetch time and are never extended by reads. no-cache
and no-store still apply. No other source gets a floor. New versions,
deleted tags and new advisories can go unseen for up to the window.
Registry pull tokens
Section titled “Registry pull tokens”Anonymous registry pull tokens are keyed by registry and image, under the HTTP
body budget. Only the bearer is stored. Expiry follows issued_at,
expires_in and HTTP Age, less a ten-second margin and capped at one hour;
a missing expires_in means 60 seconds. A 401 evicts the token and allows one
shared refresh.
Docker Hub and GHCR always name the same token service (auth.docker.io/token
and ghcr.io/token), so an anonymous read there with no live token mints one
before its first request instead of after a 401, under the same lock, expiry
and storage rules. It does so only when the read would reach the registry: a
fresh cached answer needs no token. A failed mint fails the read, as it would
after the 401. When the registry refuses that just-minted token with a
challenge naming the same realm and service, the image is treated as missing
or private (even if the 401 was transient): the token is evicted and the 401
is returned for that read, with no second mint or read. Concurrent reads of
the same image that did not mint it themselves, a challenge naming another
service, or a refusal of a token from memory or the cache still get one
refresh. A read under an operator entry keeps the 401 exchange: its
first request carries the entry’s own credentials, and its tokens are an
account’s.
Registry credentials
Section titled “Registry credentials”A response read with a private registry
entry’s credentials is keyed by that entry’s prefix and a one-way digest of its
credentials as well as the request, so a read without the entry, with another
one, or after its secret or account changes never sees it. The key never holds
the secret. Such responses follow the registry’s no-store and Vary: *,
digest-addressed ones included. A response that varies on authorization is
kept only when the key names who authorized it: an operator entry’s scope
does, a token the registry issued does not. Tokens a registry issues to an account
stay in memory and are never written to the cache.
Manifest digests
Section titled “Manifest digests”Digest checks send HEAD with the same Accept negotiation as GET and their
own cache key. The top-level Docker-Content-Digest identifies the
multi-architecture index. A missing header or an unsupported HEAD (405 or 501)
falls back to GET, hashing the body if needed. Docker Hub does not count HEAD
checks against the pull quota.
Docker Hub mirror
Section titled “Docker Hub mirror”A manifest or blob of a public Docker Hub image that is addressed by digest is
read from mirror.gcr.io first (Client::content in
crates/datasource/src/docker.rs), unless Docker Hub’s own answer is already
fresh in the cache. Each answer is cached under its own URL, so a mirror answer
and a Docker Hub answer for the same digest are separate entries holding the
same bytes. Both are digest-addressed, so both stay fresh for ten years. A
mirror answer is used only when its bytes hash to the digest. For a blob, the
derived body (oci-config-notes, image-platform, sbom-os) records the
blob’s SHA-256 for that check. Anything else (a 429, a 404, another error or
other bytes) sends the read to Docker Hub. A mirror 404 is remembered for a
day like any other digest 404. A 429 is not cached, so the next run asks the
mirror again, by which time it has usually fetched the content.
The mirror is skipped when any operator entry covers the Docker Hub URL (with
or without credentials), when a mirrorOf stands in for it, and when an entry
covers the mirror.gcr.io URL. Reads by tag, tag lists and tag-to-digest
HEADs always go to Docker Hub.
Write receipts
Section titled “Write receipts”A successful branch and PR reconciliation stores a verified-write-receipts
state entry per repository and branch prefix: the commit and tree OIDs, the
base, the planned update,
the canonical PR state (a line-ending-normalised body hash, labels and the
auto-merge flag) and the commit’s tree at the plan’s paths (each path’s blob
and mode, or its absence, and whether those are every path where the tree
differs from the base the commit records), never credentials. A plan held for prs.concurrent, which
was never written, gets a held receipt instead: the actor and the planned
update. Warm runs read a fresh GraphQL inventory
of heads and open PRs, and an exact match skips history, tree and PR reads.
A stored receipt is proof every branch the Count wrote shared the prefix, so
the refs walk passes it as refs(query:): GitHub’s filter is a
case-insensitive substring match, and the client keeps only the names that
start with the prefix. The walk narrows only while a receipts-prefix state
entry, written beside every save, names the repository’s current
prs.branch: a prefix flip away and back leaves the older prefix’s receipts
in place but no longer proves the other branches, so the run walks every
branch once and the restore that verifies the receipts again marks them.
The walk also narrows only while a receipts-prefix-verified entry names
the prefix and the identity the run’s viewer.login proves: a walk of
every branch as that identity found no open PR of his outside the prefix
and no other branch but the default whose tip is a signed Count commit. The
entry keeps a seen set: the branches under the prefix that walk returned,
joined by those each later narrowed walk returns. A narrowed walk that no
longer returns a write receipt’s branch, or a closed receipt’s branch in
seen, clears the entry; a closed receipt’s branch never in seen was gone
before and says nothing new. The receipts path writes the entry after every
walk of every branch, so a branch renamed out of the prefix, or an obsolete
PR left on an old prefix, keeps runs walking every branch until nothing of
his remains outside.
Every branch the receipts name must also appear in the answer — one that
does not, renamed outside the prefix while its pull request stayed open or
deleted, takes the full write path rather than settling around a branch it
cannot see. No receipt — a first run, a cold cache or a changed prefix —
walks every branch as before, and that run is a full write whose cleanup
sees every branch. One consequence remains: a copy of a Count branch
under a name outside the prefix has no receipt, so it is invisible to a warm
run, full writes included, and is deleted by the next run that walks every
branch instead.
Any mismatch, or unknown or incomplete inventory data, falls back to full
reconciliation. A full reconciliation that rewrites a branch whose tip is
still the receipt’s commit decides from the receipt instead of reading the
branch’s history and tree; see
branch ownership. In behind mode a base move invalidates the receipt. At -vv,
diagnostics report save and restore counts and the first failed condition per
branch.
The inventory’s issue walk filters issues by filterBy.createdBy, and the
login it asks for is remembered per credential scope as inventory-actor
state: the first page’s viewer.login is stored as soon as it is read, even
when the walk goes on to fail. A read whose answer’s viewer.login does not
match the stored hint retries unfiltered once, so a wrong or stale entry
costs one request and never narrows the issue set wrongly.
Branch cleanup keeps a code-versioned not-ours entry per repository and commit
OID whose message records no base: such a commit can never be the Count’s,
so its branch is not read again while it points there. Nothing else about
ownership is cached; a compare, an author check or a signature check runs
on every full write.
Catalog views and release age
Section titled “Catalog views and release age”Successful catalog views are stored as catalog state, each either public
or scoped:
- Public views are keyed by the package and whether the versions host
may stand in, and serve every installation and credential. A view is
stored public only when its source can be (not GitHub releases or tags,
the Pkl packages read from them, mise listings or flake inputs, which
read GitHub with the run’s token or hand a tool one), no request made
for it carried credentials (an anonymous Docker Hub or GHCR pull token is
none), and no operator entry of the run, with or without credentials or
as a mirror, covered a URL it asked for. The view records those URLs, as
patchula_http::trackedsaw them, and a run reads it only when none of its own operator entries covers one of them. A lookup whose URLs no entry covered but which sent credentials anyway is stored scoped and logged. A registry the repository declared is part of the package, so a view read from it is never another host’s. - Scoped views hold everything else, keyed as before by the package, the versions-host flag, the credential scope, whom a mise listing serves and a digest of every operator registry entry’s scope (its prefix and credentials fingerprint), so adding, removing or rotating an entry misses every scoped view read before, as the HTTP cache does. A run whose public view is missing or covered by one of its entries reads its scoped view.
Sharing GitHub releases and tags across installations would need to prove
the repository public with a token that reads nothing private, so they stay
scoped; within one installation they are shared as before. A view records the candidates its lookup
described and serves only a lookup whose candidates those cover, so a
dependency on an older version than the view was read for reads the catalog
again rather than find its candidates unchecked. The candidates also say
whether the lookup lists names no versioning scheme reads, which only an
extract pattern asks for: an image view read without them never serves a
dependency with one. A
dependency with a positive effective waitHours
reuses a catalog younger than clamp(waitHours - 1, 1, 24) hours, 23 hours
for the default 24-hour wait. Zero keeps the usual HTTP freshness. Dependencies
sharing a catalog use the shortest wait among them. A release that must wait a
day does not need a fresh catalog on every run. On the server, a queued
batch’s run also serves a view whose watch row the
poller confirmed within its
bound, whatever the wait.
Only the catalog is cached; policy always uses the current time, so a known
held-back release can become eligible during reuse. The report records
metadata.lookup.catalog.fetchedAt and reused next to evaluatedAt.
Repository rechecks, checked PR boxes and selected dashboard controls bypass
reuse for the dependencies they name. Failed lookups are never cached as
views. Mutable Git tags and image digests keep their own freshness: bounded
GraphQL reads resolve the refs currently needed without revalidating the lists.
Watch and input rows
Section titled “Watch and input rows”The server records what each repository’s answer was computed from, in two tables (migration 021, which rebuilt 020’s with the poller’s columns). Only the server writes them; the CLI and the Action write none. The poller re-reads the catalog and OSV rows, and runs read their freshness.
fleet_watchholds one row per watched thing: a catalog (its lookup key), an OSV query (direct, lockfile and SBOM packages), a git ref, a mutable tag or an image tag, keyed by kind, scope and the key’s canonical JSON, with a hash of the last content a settle read (NULLafter a failed read). The scope is empty for a row whose answer is the same for every installation, which they all share. Catalogs and OSV queries follow one rule: the read sent no credential and no operator entry of the run’s, with or without credentials, or a mirror covers a URL it was read from (for a catalog, a public view; for OSV, the batch and record URLs). An image tag is public when its reads sent no credential: no mirror stands in for a registry, and an entry that sends none reads what anyone would. Everything else is scoped to the owning installation and a digest of the credential scope and operator registry entries it was read under; git refs and tags, read with the installation token, always are. The poller’s columns:observed_at, when upstream last confirmed the content (a run’s own read, or a poll);max_age_ms, the shortest bound among the row’s dependents, 0 for a kind the poller does not watch;poll_at, the next poll (i64::MAXfor a row nothing polls), indexed; andfailures, failed polls in a row.fleet_inputslists, per installation and repository, the watch rows its last complete run read, the content hash it read from each and the bound (max_age_ms) its run promises for it. It is keyed by repository and indexed by watch row, the reverse lookup from a changed row to the repositories that read it.
A run’s inputs come from the same per-repository record its lookup hint is
saved from (RepoHint in crates/engine/src/lookup.rs): the catalogs its
dependencies read, including lockfile packages a vulnerability promoted and
the second pass’s vulnerable catalogs, the OSV queries it asked, the SBOM
queries its own image comparisons asked (both sides of each replacement, on
its platforms), and the git refs, tags and image tags its own dependencies
asked to have resolved (DigestReads, set where evaluation asks for them),
forge refs included. Those are also the only digests its report reads: a
digest in the batch’s lookups that the repository did not ask for, such as
one the last run’s hint prefetched or another repository wanted, is never
read for it. A git key is a mutable tag when the repository’s own run may
reuse the package’s GitHub tag catalog under its own wait, whatever other
repositories in the batch wait. Every repository with an evaluator has that
record, complete or not, though only a complete one’s hint is saved and
only a complete one settles. Test builds enforce completeness: every
catalog lookup, OSV query, ref, tag and image digest read the lookup stages
send to a source is logged, and a run whose repositories’ inputs miss one
panics, whichever repositories failed, which fails every engine and server
scenario test that makes such a read. Each repository’s report is checked on
its own as well: every digest it reads must be one of that repository’s
inputs. The speculative digest prefetch, which reads what
the last run’s hint named before the run knows what it needs, is not
logged, and reads keyed by a digest or advisory ID an input names (SBOMs,
advisory records) are covered by that input.
The settle runs on the cache’s writer thread, in the transaction that
finishes the repository’s queue claim, and only for a claim that finishes
done after a run whose report ended complete: a run that fails, is
requeued or does not complete settles nothing and keeps the old rows, which
can only over-state what the repository depends on. A repository that is
no longer in server_repositories when its claim finishes (removed while
it ran) settles nothing either, so removal is never undone. It inserts the
watch rows new to the fleet, moves an existing row’s content only on an
observation newer than the row’s (so a run that read the store, or an
older view, never undoes a poll), replaces the repository’s input rows as a
diff against the stored set, so an unchanged repository writes no input
row, and recomputes the bound and next poll of each row whose dependents
changed. Removing a repository (a webhook, a rename’s old name, a
discovery listing that no longer names it or no longer allows it) or an
installation deletes its input rows in the transaction that updates
server_repositories, and recomputes the bound of every watch row they
listed. Every hour the server marks the watch rows with no
dependents, which stops polling them, and deletes those that have had none
for a week, then logs the
watch rows by kind, the input rows and the dependents per watch row that
has any (maximum, and median and 90th percentile by nearest rank). Each settle logs its repository’s input
count by kind at debug level.
mise listings
Section titled “mise listings”What mise ls-remote --json printed is stored as mise-ls-remote state, since
it has no validators. The scope holds the tool, its options (the bracketed
text the tool argument carries, so one set of options never shares another’s
listing), a version prefix such as lts, whom the listing serves, whether mise may read the mise-versions mirror
and the pinned mise version. A listing younger than an hour is reused without
starting mise. A manual retry replaces it, and only successful lookups are
stored.
An npm, pypi, cargo or go tool the project sends to another source (its
package’s registry: an npm registry, a Python index list, a Cargo sparse
index or a GOPROXY list) starts no mise at all: its documents are read
like that ecosystem’s packages, so the HTTP cache keys each by URL and by
the operator entry it was read under, and its catalog view stays scoped
like every mise tool’s, with the whole source in the package’s key. A go
tool’s .info dates are kept as release-dates under the proxy list and
module, with the scope of every proxy’s operator entry. None of them ever
shares the public tool’s mise-ls-remote listing or view.
Whom a listing serves follows the token mise was handed (see
scoped tokens). Sources::mise_access
decides it from the tool and the repository the lookup is made for (its name
and visibility), and it is the third element of the batch’s lookup key and
part of a scoped catalog view’s key. Release notes look a repository’s mise tools up
through a client made for that repository, so they get the same access and
read the same listings.
public, with ametadata: readtoken scoped to a repository that asked for the tool. That token reads no repository’s private releases (not even the minted one’s, should the tool name it under an old name), so the listing is public, and one lookup in the batch serves every repository that asks for it. A tool is listed this way when every GitHub repository its backend names (github:,ubi:,aqua:,packslip:,cargo:with a GitHub URL, or each backend the registry snapshot lists for a shorthand) is another one, or its backend reads a package registry or is a core tool. When the Count cannot tell (go:,http:,spm:, an unlisted shorthand, any tool with options and the like), the listing is public only for a repository GitHub reports as public.- The run’s credential scope and the repository’s numeric id otherwise, with
a
contents: readtoken: the listing of a tool released from the repository, or of an unknown one in a private repository (or one whose visibility was not read), serves that repository alone. The id is the one the mint names, so a new repository under a renamed one’s name reads none of its listings or catalogs. - The run’s credential scope for credentials that cannot mint a scoped token (a personal token, an Action’s own token) and for a local directory: mise gets the run’s token, and the listing serves only that credential, never a scoped lookup.
A batch lookup checks that its key’s access is the one the repository it is made for gives, and fails otherwise: a public key never runs without a repository to mint for. Off github.com no token reaches mise, so every listing there is public.
Options are part of the tool’s package, so they are part of the lookup key,
and a key’s via is a repository whose own entry asked for exactly that tool
and those options. A tool’s options may send mise to another host
(api_url), and mise hands its GitHub token to any host that looks like a
GitHub API. That token is always minted for a repository that wrote the
options, so it reaches no further than its writer already can. Flake inputs still hand nix the run’s token.
© 2026 Sweepy