install: gate a 2-day default minimumReleaseAge for new projects behind configVersion 2#31608
Conversation
|
Updated 11:21 AM PT - May 30th, 2026
❌ @robobun, your commit e78489e has 1 failures in
🧪 To try this PR locally: bunx bun-pr 31608That installs a local version of the PR into your bun-31608 --bun |
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
|
Related to #28729, but intentionally a different design rather than a duplicate:
The configVersion gating + feature flag is the point of this approach. Also stacked on #30529 (the ms-style duration-string parsing), which is independent of the default-age question. |
There was a problem hiding this comment.
I didn't find any bugs, but this introduces a new product-level default (2-day minimumReleaseAge gated behind configVersion 2 / BREAKING_CHANGES_1_4) and threads new unsafe reborrows through several install entry points, so it's worth a human sign-off on both the rollout design and the aliasing invariants.
Extended reasoning...
Overview
This PR adds infrastructure to roll out a 2-day default minimumReleaseAge for new projects via a new lockfile configVersion 2. It touches:
ConfigVersion.rs: newV2variant,CURRENTgated on a new compile-timeBREAKING_CHANGES_1_4const, newMAX_KNOWNfor forward-compat clamping.PackageManager.rs: newapply_config_version_defaults()that derivesconfig_versionfrom the load result, optionally bumps fresh projects to V2 underBUN_FEATURE_FLAG_INSTALL_CONFIG_V2, applies the 2-day default, and normalizesSome(0.0)→None.install_with_manager.rs,outdated_command.rs,pm_trusted_command.rs,update_interactive_command.rs: each now calls the new helper, with newunsafe { &mut *pm_ptr }reborrows justified by disjoint-field comments.feature_flags.rs/env_var.rs: newBREAKING_CHANGES_1_4const andBUN_FEATURE_FLAG_INSTALL_CONFIG_V2env flag.- Docs and ~160 lines of new tests;
test/harness.tsstrips the new env var frombunEnv.
Security risks
The change is security-adjacent (supply-chain hardening) but doesn't itself touch auth, crypto, or permissions. The main risk surface is the new unsafe aliasing in the CLI commands — each is commented as touching only manager.options while load_result borrows manager.lockfile, which matches what apply_config_version_defaults does today, but it's another invariant that future edits to that method must preserve.
Level of scrutiny
This warrants human review because (a) it encodes a product decision — flipping every new Bun 1.4 project to a 2-day install delay by default — that someone should explicitly sign off on, (b) it introduces the BREAKING_CHANGES_1_4 / MAX_KNOWN rollout pattern that future config bumps will follow, and (c) it adds several raw-pointer reborrows in the install/outdated/trust/update-interactive paths. None of these look wrong, but they're not mechanical.
Other factors
- Gating is solid:
BREAKING_CHANGES_1_4 = falsekeepsCURRENT = V1, so today's user-visible behavior is unchanged except that a hand-writtenconfigVersion: 2lockfile now activates the default (covered by a test). - The
Some(0.0)→Nonenormalization is a small behavior change for explicitminimumReleaseAge = 0(now skips extended-manifest fetches), which seems strictly an improvement but is worth a glance. - Stacked on #30529; tests reportedly pass on debug+ASAN.
124238e to
a0b4a89
Compare
fbd6b70 to
1ebfa5f
Compare
a0b4a89 to
f491d2a
Compare
f491d2a to
296abe3
Compare
24f52cb to
29c0f0c
Compare
296abe3 to
46d53b6
Compare
|
@alii opened the |
…nd configVersion 2 Stacked on the ms-style-duration PR. Introduces ConfigVersion::V2, which carries a 2-day default minimumReleaseAge for projects whose lockfile is at configVersion >= 2 and that haven't set the option explicitly. This is how the breaking change rolls out: fresh projects and `bun pm migrate` write CURRENT, existing lockfiles keep their saved version, and an explicit `0` always disables (stored as Some(0.0), which suppresses the default). The new default is gated so it does not ship until Bun 1.4: - BREAKING_CHANGES_1_4 (compile-time) flips ConfigVersion::CURRENT to V2. - Until then, BUN_FEATURE_FLAG_INSTALL_CONFIG_V2 opts fresh projects into V2 at runtime for testing. - MAX_KNOWN (= V2) lets this build read V2 lockfiles even while CURRENT is still V1, so a lockfile written under the flag is honored without it. apply_config_version_defaults() centralizes deriving config_version and applying the gated default; it is idempotent and called from install, `bun outdated`, `bun update --interactive`, and `bun pm trust` so none of them clobber a saved configVersion.
46d53b6 to
e78489e
Compare
CI statusThe one red lane on build 59315 is flake unrelated to this diff: This PR (the configVersion-gated 2-day |
|
npm registry API doesn't support for this for the compact Content-Type. Until then, this will be a significant slowdown and so we are not doing it. |
|
Sounds good. This was the reason I stacked this into a separate PR |
|
Understood — closing. The age filter needs the The rest of the stack is unaffected: #30529 (ms-style duration strings for the existing opt-in option — no default change, no extra manifest fetches for anyone who doesn't opt in) and #31613 ( |
Stacked on #30529 (ms-style duration strings). Review/merge that one first — this PR's diff is shown against its branch.
What
Adds a gated 2-day default
minimumReleaseAgefor new projects, rolled out via a new lockfileconfigVersion:ConfigVersion::V2carries a 2-day defaultminimumReleaseAgefor projects whose lockfile is atconfigVersion >= 2and that haven't set the option explicitly.bun pm migrateand fresh installs writeConfigVersion::CURRENT; existing lockfiles keep their saved version;0always disables.Gating — does not ship until 1.4
BREAKING_CHANGES_1_4(compile-time, currentlyfalse) flipsConfigVersion::CURRENTfromV1toV2.BUN_FEATURE_FLAG_INSTALL_CONFIG_V2env var opts fresh projects intoV2at runtime (for testing).ConfigVersion::MAX_KNOWN(= V2) lets this build readV2lockfiles even whileCURRENTis stillV1, so a lockfile written under the flag is honored without it.So the code ships now and is testable, but no user sees a behavior change until 1.4 flips the flag.
How
PackageManager::apply_config_version_defaults()centralizes derivingconfig_versionfrom the lockfile load result and applying the gated default. It's idempotent and is called frominstall,bun outdated,bun update --interactive, andbun pm trustso none of them clobber a savedconfigVersion.Verification
test/cli/install/minimum-release-age.test.ts— 59 pass / 0 fail on debug+ASAN (54 base/ms + 5 configVersion-2 gated tests). Covers: new projects default to 2 days (flag on), existingconfigVersion 1unaffected,minimumReleaseAge = 0disables it, existingconfigVersion 2lockfile applies the default without the flag, and flag-off preserves legacy behavior.