Precedence
On this page
When more than one rule could set a value, cooldown resolves it with an authority-first model along two orthogonal axes: which layer a value comes from, and which selector it targets. This is the model cooldown explain renders, field by field.
The two axes#
Layers — low to high authority. A higher layer overrides a lower one:
- Built-in default
- Global config
- Native manifest config (e.g. a tool’s own
exclude-newer) - Repo / project
cooldown.tomlcascade — nearer wins when several apply --configfileCOOLDOWN_*environment- CLI flags
Selectors — most to least specific. Within a single layer, a more specific selector breaks the tie:
tool-qualified package > package > registry > project > tool > defaultSo a [package."serde_*"] block beats a [tool.cargo] block beats the bare top-level default — but only within the same layer. Across layers, authority comes first: a bare --min-age on the command line still beats a [package."…"] value set in a file, because the flag is a higher layer.
Patterns — most to least narrowly spelled. When two matching rules in one layer have equally specific selectors — two [package."…"] rules, or two [project."…"] rules — their patterns decide:
- A literal pattern, one without any of
*?[]{}\, beats every glob. - Between globs, the longer literal prefix wins: the characters before the first glob character.
@corp/ui*(prefix@corp/ui) beats@corp/*(prefix@corp/). - Between equally long prefixes, the pattern whose text sorts first wins, compared character by character by code point: case-sensitive and independent of locale.
The complete order within a field is therefore:
higher layer > more specific selector > literal pattern > longer literal prefix > smaller pattern textIt depends only on the rules themselves, never on the order the tables are written in:
[package."@corp/*"]
latest = true
[package."@corp/ui"]
min-age = "30d"@corp/ui waits 30 days, and every other @corp/ package is exempt.
The prefix rule favors a namespace over a suffix: for @corp/ui-plugin, [package."@corp/ui*"] beats [package."*-plugin"], because its literal prefix is longer. That is a precedence rule, not a claim that one glob contains the other — neither does here. Where two overlapping globs set conflicting values, give the packages in the overlap a literal rule, and use explain to see which rule wins.
Project patterns rank the same way: for the project at apps/web, [project."apps/web"] beats [project."apps/*"], and below it [project."apps/web/*"] beats [project."apps/*"].
Selector specificity still comes before the pattern, and layers before both: a [tool.npm.package."@corp/*"] rule beats an unqualified [package."@corp/ui"] rule in the same layer, and a glob in a higher layer beats a literal in a lower one.
Resolution is per field#
Different fields combine differently — each is resolved on its own:
| Field | Rule | Meaning |
|---|---|---|
min-age | authority-first | The highest layer wins; within a layer, the most specific selector breaks the tie, then the most narrowly spelled pattern. |
max-major | authority-first | Like min-age, the highest layer wins, then selector specificity, then the pattern. It exists only on package rules and has no CLI or environment form. |
floor | max-clamped | The strictest value across all layers wins — it only ever ratchets stricter, never looser. |
allow | accumulated union | Exemptions from every layer are unioned together. |
Each authority-first field is ranked on its own, among only the rules that set it. A per-kind window is searched across every layer before the bare min-age fills in for it:
[package."@corp/*"]
min-age = { major = "30d" }
[package."@corp/ui"]
min-age = "10d"@corp/ui waits 10 days for its locked pin and for minor and patch updates, but a major update still waits 30 days: the literal rule sets no major window, so the glob’s is the most specific one that does. max-major is ranked the same way, independently of the windows.
This is why a floor set high in your config can’t be weakened by a more specific block lower down:
floor doesn’t follow authority-first, it takes the maximum. min-age and max-major can be
replaced by a more specific rule in the same layer or by a rule in a higher-authority layer. A repo
can therefore deliberately loosen a global max-major; it is a compatibility choice, not a
security floor.
How allow interacts with floor#
An exemption (allow) can zero a window, but a floor is a hard minimum. The two are reconciled deliberately, and an allow can bypass a floor only in two ways:
- Co-declared with it: the same config that sets the floor also grants the exemption.
- An audited override: the
--allowflag or theCOOLDOWN_ALLOWvariable.
--latest does not bypass a floor.
The effect: you can’t accidentally exempt your way under a floor that a different, higher layer set. Bypassing a floor is always a deliberate, co-located, auditable decision. explain shows the residual floor on an exempted package so the interaction is never hidden:
$ cooldown explain itertools --tool cargo
effective window: 0d (decided by repo:cooldown.toml:package=itertools)
project: .
registry: crates.io
verdict: 0.10.5 up-to-date (cooldown 1370d/0d)
──────────────────────────────────────────────────────────────────────────────────
Layer Field Selector Window Applied Note
══════════════════════════════════════════════════════════════════════════════════
default default 7d considered
──────────────────────────────────────────────────────────────────────────────────
repo:cooldown default 7d ✓ selected
.toml (highest
layer, then
most specific
selector and
pattern)
──────────────────────────────────────────────────────────────────────────────────
repo:cooldown allow package=itert 0d ✓ exemption
.toml ools zeroes the
window;
floors in
other layers
still bind
(residual)
[layer 1]
──────────────────────────────────────────────────────────────────────────────────
repo:cooldown advisories.en ✓ enabled =
.toml abled true
──────────────────────────────────────────────────────────────────────────────────
repo:cooldown advisories.mo ✓ mode =
.toml de shorten
──────────────────────────────────────────────────────────────────────────────────
repo:cooldown advisories.mi 1d ✓ min-age = 1d
.toml n-age
──────────────────────────────────────────────────────────────────────────────────Seeing the derivation#
Two commands make the model concrete:
cooldown configprints the fully-resolved policy with the origin of each value — the effective window and which layers produced it.cooldown explain <pkg>prints the layer-by-layer, selector-by-selector derivation for one package, marking which rules were considered and which won.
Reach for explain whenever you need to answer “why does this package have that window” — it is the authoritative account, not an approximation.