Repository navigation
perf(lockfiles): persistent package caches, partitioned by credentials - #189
Merged
Merged
Conversation
…edentials Lockfile tools used to start every run with empty per-run caches. They now write to tool-caches/<partition>/<tool> under the runner's cache directory: public when a run holds no registry credentials, private-<hash of the credentials' scopes> when it does, so packages fetched with one installation's credentials never reach another's cache. Private Go and NuGet runs read the public partition as a read-only lower layer. A run holds its partition's lock shared, so eviction never removes one in use; tools whose caches do not document concurrent use take an exclusive lock per partition. Partitions unused for 14 days are pruned, and lockfiles.cacheGiB (default 20, 0 disables) caps their size, evicting least-recently-used private partitions first and public last. Credential helpers now also return the entries a run receives, which name its partition and decide whether a failure shows its output. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
A repository can supply its own credentials in committed config, which would let a run without operator credentials fetch private packages into the shared public tool cache partition. Refuse such repositories outright: patchula_manager::committed_credentials scans every file the Count reads for credentialed URLs and each tool's documented credential settings; the engine errors the repository's report (no lookups, no branches), and the lockfile runner fails the plan before any tool runs as the backstop. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Remove the read-only lower layers: a file:// GOPROXY prefix could resolve latest from a stale cache list, and NUGET_FALLBACK_PACKAGES could satisfy a private run from public packages without the private feed. Private runs never touch public now; their partition warms after the first run. Also: GOFLAGS merges -modcacherw for Go runs and eviction restores owner write permission recursively before deleting read-only partitions; pruning is throttled once per process per cache root and takes an exclusive try_lock on tool-caches/prune.lock so concurrent prunes never over-evict; lockfiles.cacheGiB validates >= 1. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
count-patchula | 8d717f0 | Commit Preview URL Branch Preview URL |
Nov 05 2026, 12:51 AM |
A `$VAR`, `${VAR}` or `${{ expression }}` userinfo is resolved by the
environment or CI at run time, not committed, so it stays allowed for
the same reason `${VAR}` keys are. Literal throwaway passwords in the
corpus's copied CI files (Forgejo's `admin1234`, Home Assistant's test
database `password`) would refuse the whole corpus and are removed, as
the corpus README now notes.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The engine refused a repository when any file it scanned held a credentialed URL, so CI workflows carrying throwaway test passwords — the Forgejo corpus copies among them — refused the whole repository, though no lockfile tool or registry lookup ever reads them. Restrict the repository scan to the files that can steer a fetch: registry settings, package manifests and lockfiles (credential_scope). The lockfile runner's backstop still scans every file it materializes, since those are exactly what its tools read, and command substitutions join variable references as allowed userinfo. Restore the corpus copies as upstream ships them.
Source files are checked out so tools can build, and a test's connection string in a .go or .rs file would otherwise stop lockfile regeneration for the whole repository.
The committed-credential scan could not keep the shared `public` cache partition safe: tokens in URL paths are undetectable, and the text scan had bypasses while refusing legitimate repositories over test DSNs and user-only userinfo. Partition safety now comes from construction, not scanning. Partitions: - `public`, shared across installations and the CLI, only when the extraction decided every file the run can read is public-only: every registry, index or fetch source its manifests, settings and lockfiles name is the well-known public registry, a well-known public forge, or a local source. Missing or unreadable information fails closed. - `installation-<sha256 of the GitHub credentials scope>` (`installation-local` for the CLI) for uncredentialed runs that are not provably public-only; two installations naming the same private registry never share one. - `private-<hash of credential scopes>` for runs given operator credentials, as before. `Extraction` gains per-file `public_only` verdicts built on the existing registry-origin analysis (`Origins`, `Named::Public`, configured, uncertain, lock origins); the runner checks every materialized file a group covers, at or below the run's directory or above it for settings. Go needs no verdicts: the repository cannot move its fetches off the sandbox's proxy. The committed-credential refusal narrows to hygiene: only the settings a tool or lookup reads as a credential refuse a repository — auth keys in `.npmrc`, `pnpm-workspace.yaml`, `.yarnrc.yml`, `composer.json` (with `forgejo-token` and the other keys Composer documents), `nuget.config` `packageSourceCredentials` (`%VAR%` allowed), `poetry.toml`/`pyproject.toml`, `.cargo/config*` registry tokens, and a user **and** password in a field that names a registry, index or source URL, read from parsed values. Arbitrary text scans, non-registry fields, user-only userinfo, `.bundle/config` `BUNDLE_*` keys and empty values no longer refuse. Cache fixes: `unreadonly` uses `symlink_metadata` and never follows links; an evicted partition's `<name>.lock` is removed while the exclusive lock is held; `due()` records a prune only when it actually ran. Extraction namespace bumped to `extract-v27`. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Review findings on the tool-cache partitions:
- A URL is not public when its userinfo is not entirely an environment
placeholder ($NAME, ${NAME}, ${{ ... }}, $(...) or %NAME%): forges take
a token as the username, with no password. ssh keeps its plain-user
allowance; a literal password in it still fails.
- public_only()/steers() no longer bound the check to the run's subtree:
every materialized file of the ecosystem's kinds anywhere in the
snapshot needs a true verdict, so a sibling project with a private
source fails every directory's run closed.
- A .gemspec is a Ruby kind with no verdict (arbitrary Ruby), so a Ruby
run that can read one is not public. dotnet's packages.lock.json,
.sln/.slnx, global.json and dotnet-tools.json get verdicts (true: they
carry no sources), and a project/props/targets file holding a <Target,
<UsingTask or <Exec element is not public.
- A PEP 508 URL requirement in [project].dependencies,
[project.optional-dependencies], [dependency-groups] or
[build-system].requires makes a pyproject.toml not public.
- Bun catalogs under workspaces.catalog/workspaces.catalogs are checked
like the top-level ones.
- Go comments no longer claim fetches are env-only: the sandbox sets no
GOPROXY, so Go fetches anonymously from any VCS host and stays public
because anonymous fetches reach only public content.
- .npmrc and pnpm-workspace.yaml username/email beside a ${VAR} password
and empty values are allowed; the lockfile-runner backstop checks only
files the engine would check, skipping paths the repository excludes
(a fixture .npmrc under test/fixtures never refuses a run), and reason
strings embed no repository text beyond the path.
- After a shared lock lands on <name>.lock the path is re-checked against
the held file's inode/device, and a replaced lock file is re-opened, so
a run never holds a lock on an inode eviction already removed.
- Docs state plainly that partitions keep honest repositories' private
packages apart but are not isolation: lockfile tools run repository
code unsandboxed, so code from any installed repository can read every
partition. Stale betterleaks:allow comments on '),' lines are gone and
credential fixtures are built at runtime instead.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Each per-key verdict walker checked the fields it knew and passed everything else, so fetch sources it had no arm for slipped through: Cargo dependency tables past the git/registry-index check, uv's requirement lists and sources, yarn catalogs and package extensions, bun.lock tuples and npm lockfileVersion 1 version/from URLs. The verdicts now parse each steering file — JSON, TOML, YAML, XML or a line grammar for .npmrc, Gemfile, yarn.lock and text locks — and walk every string and key, ruling on each possible fetch source with fetch_ok. Only a small allowlist of inert metadata keys per format goes unchecked; a key missing from it costs a run its public partition, never safety. The fail-closed rules stay on top: unreadable files, .gemspec, MSBuild Target/UsingTask/Exec and restore-source overrides remain not public, and Go stays public. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Keys that always hold a fetch location — Composer repositories, Yarn
and pnpm registry settings, uv/Poetry/pdm index URLs, Cargo registry
indexes and NuGet packageSources — now get a rule on their value: the
ecosystem's public registry itself, or a local path where the format
allows one, or a scheme'd source fetch_ok accepts. A bare host, a
${VAR} or an unparseable value there is not public, closing the
scheme-less source gap the string walk could not see. Composer
repositories are ruled on by type: composer+Packagist and local
path/artifact only; vcs, git, package and the rest are not public.
pyproject.toml treats the fancy-pypi-readme hook and the pure-lint
tool tables as inert instead of missing them to the string walk.
A Go run in the public partition now gets GOPROXY=https://proxy.golang.org
with no `direct`, so only modules Google's proxy can serve are fetched
— an anonymous fetch to a host only the server's network reaches, such
as a cluster-internal Git host, can no longer land in the shared cache.
A public Go run that fails is rerun in the installation partition with
Go's environment as before, so repositories with internal modules keep
working. The extraction cache namespace moves to extract-v28.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…tive local sources as public NuGet reads element and attribute names in any case, so a <PackageSources> share fell through to the generic walk. An absolute folder, UNC share or drive path could name a directory outside the checkout.
Merged
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.
Summary
Lockfile tools used to start every run with empty caches —
sandbox_envpointedCARGO_HOME,GOPATH/GOMODCACHE, the npm cache andBUN_INSTALL_CACHE_DIRat the per-runHOME, and Composer, Yarn, NuGet, uv, Poetry and Bundler did the same through their own env. Every branch and every installation paid the full download each time.Each tool's cache now persists in
tool-caches/<partition>/<tool>under the runner's cache directory, and the partition a run gets is decided by what it can fetch — safety by construction, not by scanning the repository for credentials:public— shared by every installation and the CLI. A run may use it only when the extraction decided every file it can read is public-only: every registry, index or fetch source its manifests, settings and lockfiles name is the ecosystem's well-known public registry, a well-known public forge (github.com, gitlab.com, bitbucket.org, gist), or a local source that fetches nothing. Uncertain, unreadable or undecided files fail closed.installation-<hash>— one partition per installation (installation-<sha256 of the GitHub credentials scope>;installation-localfor the CLI). Every uncredentialed run that is not provably public-only lands here: a private or unknown.npmrcregistry, a Gemfury-style index URL, a lockfileresolvedURL on a non-public host — and two installations naming the same private registry never share one.private-<hash>— a run given operator credentials; the hash covers the sortedCredential::scope()s of exactly the entries it receives, so packages fetched with one credential set never reach another's cache, and a credential for one tool never privatises another tool's cache.Extractiongains a per-filepublic_onlyverdict map built on the existing registry-origin analysis (Origins,Named::Public,configured,uncertain, lock origins) — reusing the machinery that already classifies registries rather than a new scanner. The runner checks every materialized file of the run's ecosystem kinds anywhere in the snapshot — a sibling project reached through aProjectReference, a.sln, afile:../x, a uv or Poetry path dependency or a Composer path repository can steer the run, so the run's directory does not bound the check. Go needs no verdicts: in thepublicpartition it runs withGOPROXY=https://proxy.golang.org— nodirect— so a fetch can only reach modules Google's proxy serves; a run that fails there is retried in the installation partition with Go's default environment. The extraction cache namespace is bumped toextract-v28.Credential files (
.npmrc,.netrc,COMPOSER_AUTH, token env vars) still live only in the per-runHOMEor environment — never in a partition.Committed-credential refusal is now hygiene, not a safety boundary
The text scan could not keep
publicsafe anyway (tokens in URL paths are invisible to it, Gemfiles can build credentials in code), and it refused legitimate repositories over test DSNs and user-only userinfo. It narrows to refusing exactly what a tool or lookup reads as a credential — each format parsed, so escapes cannot hide one:.npmrc/pnpm-workspace.yaml_authToken/_auth/_password,.yarnrc.ymlnpmAuthToken/npmAuthIdent, Composerconfigauth keys (http-basic,bearer,github-oauth,gitlab-oauth,gitlab-token,bitbucket-oauth,forgejo-oauth/forgejo-token,gitea-oauth/gitea-token),nuget.configpackageSourceCredentialsliterals (%VAR%allowed), Poetryhttp-basic/pypi-token, Cargo registrytoken..npmrcregistry/@scope:registry,npmRegistryServer, pyproject/uv/poetry index and source URLs, Composerrepositories[].url,nuget.configpackageSources, pip index URLs, Gemfilesource, Cargo registryindex.Dropped: arbitrary text and non-registry fields (scripts, env, git dependency URLs, CI files), user-only userinfo (
https://[email protected]),.bundle/configBUNDLE_*keys no tool reads, and empty values.${VAR}/%VAR%placeholders stay allowed.The scan still runs in engine extraction (repository refused with a reason naming what was found, never the value) and as the runner's backstop over the materialized baseline — scoped to the files the engine would check, so paths the repository excludes (
test/fixtures/examplesand configuredexclude) are never checked, and reason strings carry no repository text beyond the path..npmrc/pnpm-workspace.yamlusername/emailbeside a${VAR}password and empty values are contact details, not credentials.No read-only lower layers
The Go
file://GOPROXY prefix (stale@v/listcould resolvelatestwrong) andNUGET_FALLBACK_PACKAGES(a public package could satisfy a private run without the private feed — dependency confusion) are gone. A run never reads a partition it did not choose; private and installation partitions warm after their first run.Fixes
GOFLAGS=-modcacherw(merged with any existingGOFLAGS), andunreadonlynow usessymlink_metadataand never follows links, so a symlinked directory is removed, not descended into.try_lockontool-caches/prune.lock;due()records a prune only when it actually ran, and an evicted partition's<name>.lockis removed while the lock is held.lockfiles.cacheGiBminimum 1 validated in settings (and everywhere the CLI reads it).Concurrency and pruning
<partition>.lockshared for its whole execution, so an evictor's exclusivetry_locknever removes an in-use partition. Serialized tools get a second, per-tool lock inside the partition.lockfiles.cacheGiB(default 20, minimum 1) evicts least-recently-used private and installation partitions first,publiclast.Per-tool table
CARGO_HOME→<partition>/cargoGOMODCACHE→<partition>/gomod,GOFLAGS=-modcacherwNPM_CONFIG_CACHE→<partition>/npmAUBE_CACHE_DIR+AUBE_STORE_DIR→<partition>/aube/{cache,store}BUN_INSTALL_CACHE_DIR→<partition>/bunYARN_GLOBAL_FOLDER→<partition>/yarnCOMPOSER_CACHE_DIR→<partition>/composerUV_CACHE_DIR→<partition>/uvPOETRY_CACHE_DIR→<partition>/poetryNUGET_PACKAGES+NUGET_HTTP_CACHE_PATH→<partition>/nuget/{packages,http-cache}BUNDLE_USER_CACHE→<partition>/bundlerproviders lockverified to keep no package cachemise lock, gradlewDocs
guide/lockfiles.md"Tool caches" (the three partitions and who sharespublic; trust note that repo-running tools could plant content in the shared cache, which the every-installation-trusted model accepts);guide/sources.mdandrenovate/departures.mdon the narrowed hygiene refusal;reference/settings.mdx(cacheGiBminimum 1);internals/cache.mdlayout.Review hardening (follow-up commit)
$NAME,${NAME},${{ ... }},$(...),%NAME%) makes the URL not public, password or not — forges take a token as the username. Applies infetch_okand every URL verdict (Cargo git deps,git+https, Gemfilegit:/github:, PEP 508). ssh keeps its plain-user allowance (ssh://git@host,git@host:); a literal ssh password still fails.public_only/steers: the subtree rule is gone — a run is public only when every file of its ecosystem's kinds anywhere in the snapshot has atrueverdict..gemspecis a Ruby kind with no verdict, so a run that can read one is not public.packages.lock.json,.sln,.slnx,global.json,dotnet-tools.jsoncarry no sources and gettrueverdicts; any project/props/targets file containing a<Target,<UsingTaskor<Execelement is not public.[project].dependencies,[project.optional-dependencies],[dependency-groups]or[build-system].requiresmakes the file not public.workspaces.catalog/workspaces.catalogsare checked like top-level catalogs..npmrc/pnpm-workspace.yamlusername/emailbeside a${VAR}password and empty values are allowed; the runner backstop reuses the engine's file selection (a fixture.npmrcunder an excluded directory never refuses a run); reason strings carry no repository text beyond the path.<name>.lockthe path is re-checked against the held file's inode/device, and a replaced lock file is re-opened, so a run never holds a lock on an inode eviction already removed.partition's comment no longer claims partition names are unpredictable (installation scopes are guessable);guide/lockfiles.mdstates plainly that partitions keep honest repositories' private packages apart but are not isolation — lockfile tools run repository code unsandboxed, so code from any installed repository can read every partition. Stale// betterleaks:allowcomments are gone; credential fixtures are built at runtime withformat!/concat.Tests
public; private/unknown npm registry, Gemfury index URL, unreadable.npmrc, non-public lockfileresolvedhost →installation-<…>; two installations, same private registry, no operator credentials → different partitions; operator credentials →private-<…>.package.json/pyproject.tomlenv,https://[email protected],.bundle/config,${VAR}/%VAR%, CI files do not; an escaped password in a JSON registry URL does.unreadonlyskips symlinks, evicted<name>.lockremoved,due()records only a real prune.clippy -D warnings,cargo test -p patchula-manager -p patchula-update -p patchula-engine -p patchula-server -p patchula-cli,mise run test:tools,mise run corpus:snapshot(no corpus diff —public_onlyis not in the TSV), andcorpus:checkdry run completing without refusals.Generated with Devin
Public-only verdicts are now deny-by-default (follow-up commit)
The per-key verdict walkers checked the fields they knew and passed
everything else, so fetch sources without a dedicated arm slipped
through: Cargo dependency tables past the
git/registry-indexcheck(
{ git = … }anywhere,[patch.*],[workspace.dependencies]),uv's requirement lists and
[tool.uv.sources]/indexes, Yarn catalogsand
packageExtensions,bun.locktuples and npm lockfileVersion 1version/fromURLs.The verdicts now parse each file that steers a run — JSON, TOML, YAML,
XML, or a line grammar for
.npmrc,Gemfile,yarn.lockand thetext locks — and walk every string and key, deciding each possible
fetch source with
fetch_ok. Only a small per-format allowlist ofinert metadata keys (
homepage,[project] urls,PackageProjectUrland their like) goes unchecked: a URL there reaches a web page, not a
download, and a key missing from the allowlist can only cost a run its
publicpartition, never safety. Lockfiles are walked the same way, soa private registry recorded only in a lock fails.
The fail-closed rules stay on top: unreadable files,
.gemspec,MSBuild
<Target>/<UsingTask>/<Exec>and restore-source overridesremain not public,
.npmrcregistryvalues must still name thepublic registry itself, Composer's merge plugin and plugin packages
still fail, and Go stays public.
Corpus partitions under the new walkers:
if/elseRACKselection was already unreadable to the Gemfile reader)Generated with Devin
Key-aware sources and Go's public proxy (follow-up commit)
repositories[].url,.yarnrc.ymlnpmRegistryServer(top level and undernpmScopes.*) andnpmRegistrieskeys, pnpm-workspaceregistry/registries,[[tool.uv.index]].urland[tool.uv]/uv.toml/[pip]index-url/extra-index-url/find-links,[[tool.poetry.source]]/[[tool.pdm.source]]url, pixipypi-optionsindex keys, poetry.toml[repositories.*]url, pdm.toml[pypi]url, Cargoregistry-index,[registries.*]indexand[source.*]registry, Gemfilesourcelines, and nuget.configpackageSourcesvalues. The value must name the ecosystem's public registry itself (the.npmrcrule), or a local path where the format allows one, or carry a scheme and passfetch_ok; a bare host, a${VAR}or an unparseable value is not public.composernaming Packagist,path/artifactnaming a local path, and"packagist.org": false-style switches are public;vcs,git,packageand every other type is not — including avcsrepo on github.com, which was public before.tool.hatch.metadata.hooks.fancy-pypi-readmeand the pure-lint tables (tool.ruff,black,isort,mypy,pytest,coverage,pyright,towncrier,codespell) are inert at any depth;[tool.*]in general stays checked, so a[tool.flit.metadata]URL is not public. pydantic's pyproject.toml now comes outpublic.publicpartition Go runs withGOPROXY=https://proxy.golang.org(nodirect, GOSUMDB default), so an anonymous fetch can only reach modules Google's proxy serves — a cluster-internal Git host reachable only from the server's network can no longer put modules in the shared cache. A public run that fails is rerun in the installation partition with Go's environment as before (GOPROXY unset), so repositories with internal modules keep working. Verified: the public run's env has GOPROXY withoutdirect, and a failing public run retries ininstallation-local.extract-v28.