meta_package_manager.cooldown module¶
Vocabulary and resolution of the release-age cooldown gate.
The cooldown is a supply-chain safeguard with two independent axes:
the window: the minimum age a package version must reach before it can be installed or upgraded, expressed as a duration;
the policy: what happens to managers that cannot natively enforce an active window (
CooldownPolicy).
The CLI spells both axes on the single --cooldown option (a duration, or
one of the policy keywords), while the configuration file spells them as the
two keys of the [mpm.cooldown] table (period and policy). Resolution
(resolve_cooldown()) merges the two sources axis by axis: a value set
on one side only leaves the other axis to the configuration, so –cooldown
best-effort``reuses the configured window, and`–cooldown 7d` reuses the
configured policy.
The gate itself (per-manager environment injection, the fail-closed skips)
lives in meta_package_manager.execution and
meta_package_manager.cli_maintenance.cooldown_permits(); this module
only owns the input grammar and the merge rules.
- meta_package_manager.cooldown.POLICY_CONFIG_KEYS = ('period', 'policy')¶
Recognized keys of the
[mpm.cooldown]configuration table.periodcarries the window as a duration string,policyone of theCooldownPolicykeywords accepted in configuration files. Kept here as the single enumeration both the parser and the error messages read.
- class meta_package_manager.cooldown.CooldownPolicy(*values)[source]¶
Bases:
StrEnumEnforcement posture of an active release-age cooldown window.
Only applies to managers without native release-age support; managers that can enforce the window natively always do, whatever the policy. The values double as the CLI keywords of the
--cooldownoption and (exceptoff) as thepolicyvalues of the[mpm.cooldown]configuration table, so they spell exactly like the user types them.- enforce = 'enforce'¶
Skip the managers that cannot enforce the window (fail-closed). The default posture: nothing slips in unguarded.
- best_effort = 'best-effort'¶
Run the managers that cannot enforce the window anyway, without the supply-chain safeguard.
- off = 'off'¶
Disable the gate entirely for this run, on every manager. A CLI-only keyword, equivalent to a
0duration: the configuration expresses the same state withperiod = "0"(or noperiodat all).
- class meta_package_manager.cooldown.Cooldown[source]¶
Bases:
ParamTypeParse the
--cooldownvalue: a window duration or a policy keyword.Returns a
datetime.timedeltafor a duration, aCooldownPolicyfor a keyword (0collapses toCooldownPolicy.off, matching the “zero disables the gate” rule of click-extra’sDuration), andNonefor an empty value, which reads as “unspecified”: resolution then inherits both axes from the configuration.
- class meta_package_manager.cooldown.CooldownSettings(duration, policy, legacy=False)[source]¶
Bases:
objectThe cooldown axes carried by the configuration, before merging.
An axis left unset is
None: resolution substitutes the default only after the CLI flag had a chance to override the other axis.- policy: CooldownPolicy | None¶
The configured posture (
policykey), orNonewhen unset.
- meta_package_manager.cooldown.parse_policy_token(token)[source]¶
Map
tokento aCooldownPolicy, case-insensitively.Returns
Nonewhen the token names no policy, so callers decide how to report the miss.- Return type:
- meta_package_manager.cooldown.parse_cooldown_section(section)[source]¶
Parse the
[mpm.cooldown]configuration section into settings.Accepts the table shape (
periodandpolicykeys) and, as a migration aid, the deprecated top-level string spelling, read as the window. Pure parsing: no logging, so the load-time validator and the runtime resolution can share it without duplicated diagnostics.- Raises:
ValueError – on an unknown key, an unparsable
period, apolicythat is notenforceorbest-effort(offis a CLI-only keyword), or apolicywithout aperiod, which would be a standing no-op gate.TypeError – when the section is neither a table nor a string.
- Return type:
- meta_package_manager.cooldown.resolve_cooldown(flag, settings)[source]¶
Merge the parsed
--cooldownflag with the configuration settings.Axis-by-axis precedence: a flag duration overrides the configured window but inherits the configured policy; a flag policy overrides the configured policy but inherits the configured window (
offforces the window off too); an unset flag inherits both axes. Returns the effective(window, policy)pair, the policy defaulted toCooldownPolicy.enforcewhen neither side sets it.- Return type: