cooldown

Selectors

On this page

A selector scopes a policy to part of your dependency graph. The level narrows what a rule applies to. From least to most specific:

default  <  tool  <  project  <  registry  <  package  <  tool-qualified package

Within a layer, the most specific selector that matches wins. Between two matching rules of the same level, such as two package rules, the more narrowly spelled pattern wins: a literal beats a glob, and a longer literal prefix beats a shorter one — see Precedence.

Top level — the default#

Keys at the top of cooldown.toml, outside any table, are the default selector — they apply to everything unless a more specific selector overrides them:

min-age = "14d"

[tool.<name>] — per ecosystem#

Scope policy to one package manager. Every supported tool is its own name — cargo, go, uv, pip, poetry, conda, pixi, npm, pnpm, yarn, bun, deno, bundler, hex, maven, gradle, swift — and the aliases are accepted. Each alias names exactly one tool, so [tool.python] covers uv only and [tool.node] npm only:

[tool.uv]
min-age = "21d"       # a longer window for Python deps only

[tool.pnpm] single-copy#

The packages a pnpm resolve must never leave at two resolved copies:

[tool.pnpm]
single-copy = ["solid-js", "react", "typescript"]

A second copy a dependent’s own requirement pulls into the graph is ordinarily committed and reported as a duplicate_copy warning. For a listed name the settlement is refused instead: the lock is restored and the candidate whose landing added the copy is held with the copy and its requirer named (see upgrade).

The gate judges what a resolve adds, counted as distinct resolved versions, whether the new copy is a dependent’s own requirement or an importer’s own entry. It refuses two cases:

  • a listed name the graph held at one copy (or not at all) before the run and at several after it
  • a listed name already split that gains another copy

Three cases are not refused:

  • A copy that merely moves to another version: leaves the count alone.
  • A listed name that is already at several copies before a run: has that standing split reported (as a duplicate_copy warning) rather than refused — refusing would hold every upgrade forever — so converge it for the listing to hold.
  • A --lock refresh (check --lock, outdated --lock): is pnpm’s own install --lockfile-only against the manifests as written and is not gated.

--fail-on-new-duplicate gates every package for one run; on a tool without Cargo or pnpm’s settlement guard it has no effect and the run says so.

The key is pnpm-specific and accepted only here (like edge-policy under [tool.cargo]). It merges across config files the way exclude-folders does, so a nested workspace that lists one runtime of its own does not un-gate the root’s:

  • A plain array: adds to the list inherited from a farther file.
  • []: clears it.
  • { replace = ["…"] }: replaces it.

Names in pnpm-workspace.yaml’s overrides are not gated by default: an override pins a version for every request that matches its range, which already keeps a copy single where the range is exact, and a ranged override is often about forcing a patched transitive rather than about running the package once — list the names you mean. Entries are exact package names, not globs: a pattern such as @scope/* is a config error rather than a gate that silently matches nothing.

[tool.cargo] generated-members#

The workspace members whose Cargo.toml is a generated projection of the resolved graph rather than something anyone wrote — a cargo-hakari⁠ workspace-hack, whose [dependencies] table is regenerated wholesale from the lock so that every member builds with one unified feature set:

[tool.cargo]
generated-members = ["workspace-hack"]

Such a manifest declares a crate because something else in the graph already depends on it, never because a first-party crate wants it, so its entries can only follow the lock. Without the declaration cooldown reads them as ordinary direct dependencies: every hash-aliased hashbrown-3575ec1268b04181 = { package = "hashbrown", version = "0.15" } line becomes an upgradeable row attributed to the hack, every 0.x line becomes a --major candidate, and the resolve then reports each one blocked, because the version is decided by whichever real crate pulls it in. On a large workspace that is most of the blocked set, hiding the few rows that name a real constraint.

A declared member becomes a follower, never a driver:

  • Nothing it declares is direct. A crate only the generated member declares is a transitive dependency of the members that reach it through the real graph — reported under --transitive and attributed via those members, gated by check exactly as before, but never proposed as a direct upgrade. A crate an authored member also declares is attributed to that member alone.
  • Nothing it declares holds. Its = pins, < bounds, and caret ranges are whatever its generator last wrote, so they neither mark a row held nor cap a candidate.
  • Its requirements follow every move. When upgrade/fix moves a crate an authored member declares — including across a major — the generated manifest’s entry that admitted the old version is made to project the new one, in the same step as the authored requirement and rolled back with it if the move does not land. Cargo therefore never sees the projection demand a version the lock no longer carries, which would otherwise resolve a second copy of the crate (or fail) — the workspace still resolves under cargo metadata --locked and no crate gains an extra copy. Following is what a generator does when it recomputes the projection: the entry’s requirement is bumped, with its other fields (features, default-features) kept as written, unless a differently-keyed sibling entry already projects the line the crate is moving to (the hash-aliased entry for that major), in which case the moving entry is removed instead — bumped, both would resolve to one node under two names, which cargo refuses. A feature the new major no longer has is cargo’s rejection of that one candidate, reported blocked with cargo’s explanation like any other resolver rejection.
  • The run tells you to regenerate. A rewritten projection no longer matches its generator’s output, so the report ends with a stale_lock warning naming the manifest; finish the upgrade the way the generator expects — cargo hakari generate, then re-lock — and the projection converges (the generator computes the hack from the graph without the hack’s own contribution, so a followed entry regenerates to the same line).

Detection is never inferred. A ### BEGIN HAKARI SECTION marker, a package.metadata table, or a workspace-hack name changes nothing: marking a member generated narrows what cooldown proposes and reports, and a supply-chain tool must not narrow its own scope from a heuristic that would be invisible in review and could capture a hand-written crate that merely looks similar. The marker is used in one direction only, as advice: a project that declares nothing and has a member whose manifest carries it gets a config warning suggesting the declaration (or an explicit generated-members = [], which says every member is authored and silences the hint). A declared member whose projection has gone stale — it declares crates no authored member reaches any more, which a regeneration would drop — gets a stale_lock warning too.

A move can also drag companions the plan never named — toml 0.7 → 0.8 takes toml_edit 0.19 → 0.22 with it — and the projection’s line for the old companion would keep that old copy alive alone. After the pin phase cooldown therefore follows every crate the generated members are the only ones still reaching, to the line the authored graph now resolves it to, and re-resolves so cargo drops the retained copy. A crate the authored graph no longer resolves at all is left as a stale projection line for the regeneration.

The key is cargo-specific and accepted only under [tool.cargo], like edge-policy. Entries are exact member package names (the name cargo metadata, cargo -p, and hakari’s own config use), not paths and not globs; a pattern is a config error. Every listed name must match a workspace member, or every command that reads the workspace reports a config error for the project and evaluates none of it — check, upgrade, and fix exit non-zero on it, while outdated, which never gates, carries it in its report — so a stale entry, a renamed crate, or a deleted one can never quietly stop covering a manifest that still exists. The nearest cooldown.toml that sets the key decides for the workspace below it (an explicit --config file wins over all); lists do not merge across files, since a declaration names this workspace’s members. cooldown config prints the resolved list and the file that declared it for every cargo project, so an audit can see that scope was narrowed and by which file. exclude-packages is not a substitute: it drops the member from reports but leaves its requirements alone, so an upgrade would still resolve a second copy for the projection’s sake. The two compose as excludes always do: a crate whose only authored declarers are excluded goes with them, mirrored line included — the projection never keeps a row alive that its authors are out of the run for.

[registry."<id>"] — per registry#

Scope policy to one registry, named by cooldown’s registry id, not by host:

  • crates.io
  • npm
  • jsr
  • pypi
  • rubygems
  • hexpm
  • maven-central
  • conda
  • github
  • for Go, the host of the first GOPROXY entry (proxy.golang.org by default)
[registry.pypi]
min-age = "21d"

A host such as internal.acme.io matches nothing, unless it is Go’s first GOPROXY entry. To exempt first-party packages, name them with a package selector or allow.

[project."<glob>"] — per project#

Scope policy to the projects whose path, relative to the scan root, matches the glob:

[project."apps/*"]
min-age = "21d"

A project rule takes min-age, latest, freeze and floor. It ranks above a tool rule and below a registry rule; two project rules rank by pattern like package rules (see Precedence).

Package selectors#

An unqualified package rule applies to a matching name in every ecosystem:

[package."github.com/acme/*"]
min-age = "0d"

[package.glob]
min-age = "14d"

Package globs use the same flavor as allow and exclude-packages: * is always a wildcard and crosses /, so @scope/* covers a whole npm scope and serde_* a crate family. No registry permits * in a package name, so nothing needs escaping.

When the same name exists in several ecosystems, qualify the package rule by its tool:

[tool.uv.package.glob]
min-age = "30d"
max-major = 5

[tool.cargo.package.glob]
min-age = "14d"

[tool.uv.package.glob] applies only to the package named glob in uv projects; it cannot accidentally change the Cargo crate or npm package with the same name, and it does not reach pip or Poetry projects either. A tool-qualified package rule is more specific than an unqualified [package.glob] rule in the same config layer.

When several package rules of one layer match the same name, the most narrowly spelled pattern wins, whatever order the tables are written in:

[package."@corp/*"]
latest = true

[package."@corp/ui*"]
min-age = "14d"

[package."@corp/ui"]
min-age = "30d"
  • @corp/ui: waits 30 days, because a literal beats every glob.
  • @corp/ui-kit: waits 14 days, because @corp/ui* has the longer literal prefix (@corp/ui against @corp/).
  • Every other @corp/ package: is exempt.

A namespace prefix also beats a suffix pattern: for @corp/ui-plugin, @corp/ui* beats *-plugin. Two globs with equally long prefixes fall back to their text, the one that sorts first by code point winning. The ranking is per field, and [project."…"] patterns rank the same way; Precedence has the complete order.

max-major is available only on package rules and is an integer. It is an absolute ceiling: within-major updates remain eligible, but even upgrade --major --rewrite will not cross it. For example, keep TypeScript and its Node declarations current within supported lines with:

[tool.npm.package.typescript]
max-major = 5

[tool.npm.package."@types/node"]
max-major = 24

Raising or removing the value in cooldown.toml is the only way to cross a configured max-major. There is no CLI or environment override.

The ceiling also covers versions cooldown does not plan. A resolve can lift a package across it on its own:

  • Go: minimal version selection raises an indirect module.
  • uv: moves a package to follow a requirer.
  • Cargo and npm: add a copy on a higher major beside the old one.

upgrade and fix roll such a change back and report the candidate that caused it as max_major_held, naming the capped package. A version already above the ceiling before the run is left alone, and cooldown can still move that copy within its own plan. When a project’s lock goes stale because another project in the same run changed a manifest it resolves against, and the refresh would cross the ceiling, that project fails with an error.

A package rule that applies to uv also reaches uv’s own per-package cutoff: cooldown sync writes it into exclude-newer-package, and cooldown passes it to every uv command it runs (see sync).

Choosing a level#

  • Loosen or tighten one registry? Use [registry."…"].
  • Set policy for part of a monorepo? Use [project."…"].
  • Loosen or tighten one ecosystem? Use [tool.<name>].
  • Pin the policy for one package or family? Use [package."…"].
  • Target a package name in one ecosystem only? Use [tool.<name>.package."…"].

When two rules could both apply, explain shows which one won and why.

Migration note#

exclude-folders and exclude-packages belong under [tool.*], [global], or a command table, not under package, registry, or project selector tables. Older versions accepted those keys under non-tool selectors and then silently ignored them. They now fail configuration parsing so a misspelled or misplaced exclusion cannot look active when it is not.

Esc

Type # for headings only ↑↓ move ↵ open Ctrl ↵ new tab Ctrl U/D scroll preview

Keyboard shortcuts

/ ⌘ K Ctrl K
Search
← →
Previous or next page
?
Show these shortcuts