Skip to content

install: name build_store's timing flag with an enum instead of a bool - #39157

Merged
alii merged 3 commits into
mainfrom
farm/49c6b858/build-store-timings-enum
Aug 15, 2026
Merged

alii merged 3 commits into
mainfrom
farm/49c6b858/build-store-timings-enum

Conversation

@robobun

@robobun robobun commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • build_store in src/install/isolated_install.rs takes two bools, install_root_dependencies and print_timings. Its call in src/install/prune.rs (build_store_with) reads build_store(&*manager, &manager.lockfile, true, &[], None, false): nothing at the call site says which flag is which, and swapping them would still compile.
  • mordant reports this as the bare_bool_args finding baselined for that file.

Fix

  • print_timings: bool becomes timings: Timings, a two-variant enum (Timings::Print / Timings::Quiet) declared next to build_store. install_isolated_packages passes Print when the log level is verbose (the condition it passed as a bool before); prune passes Quiet (was false).
  • install_root_dependencies stays a bool. It is threaded as a bool through the hoisted installer, Tree::Builder, Lockfile::hoist/filter and is_filtered_dependency_or_workspace as well, so changing its type is a separate, wider refactor. With one bool left there is nothing to confuse it with, and the lint no longer applies to build_store.
  • No behavior change: the timing lines are still printed only by a verbose isolated install, and prune's store builds stay silent. Neither was covered by a test before, so each call site gets one: isolated-install.test.ts ("store build timings are printed by --verbose only") checks the Print/Quiet choice in install_isolated_packages, and bun-prune.test.ts ("isolated linker: --verbose does not print the store build timings") checks prune's Quiet. They pin the existing behavior, so they pass before and after the refactor.
  • mordant-baseline.toml loses the bare_bool_args entry for src/install/isolated_install.rs, the only entry this finding accounted for (bun run rust:mordant:baseline on this branch produces the same file).
  • Verified:
    • bun run rust:mordant on the previous source with the baseline entry removed reports the build_store finding (over-baseline.txt: bun_install 1); with this change and the regenerated baseline it reports nothing across the workspace.
    • bun bd test test/cli/install/bun-prune.test.ts test/cli/install/isolated-install.test.ts (177 pass, 1 skip, including the two new tests)
    • bun bd test test/cli/install/isolated-relink.test.ts test/cli/install/frozen-lockfile-pruned.test.ts (107 pass, 1 skip)
    • The new install test also passes against a bun built before this change (USE_SYSTEM_BUN=1), as expected for a refactor. That older build has no bun prune yet, so the prune test was only run against this branch.

Background

  • build_store turns the lockfile into the isolated linker's store layout (node_modules/.bun/...) in two passes, resolving peers and then deduplicating entries. A verbose install prints how long each pass took. bun prune also builds the store (up to twice, with different feature sets) only to learn which store entry names are still wanted, and does not want those lines.
  • mordant is the advisory lint pack run by the rust-lints workflow. mordant-baseline.toml records, per lint and file, how many findings predate the job; a run fails only on findings above those counts, so fixing a baselined finding means removing its entry.

@robobun

robobun commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 1:00 PM PT - Aug 15th, 2026

@robobun, your commit afe3dcd is building: #98602

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5aa7e477-0f4e-4605-93fe-975566b98d26

📥 Commits

Reviewing files that changed from the base of the PR and between bcab5ed and 1aa0560.

📒 Files selected for processing (5)
  • mordant-baseline.toml
  • src/install/isolated_install.rs
  • src/install/prune.rs
  • test/cli/install/bun-prune.test.ts
  • test/cli/install/isolated-install.test.ts
💤 Files with no reviewable changes (1)
  • mordant-baseline.toml

Walkthrough

The change replaces boolean timing control with a Timings enum. Install and prune paths select the timing mode explicitly. CLI regression tests verify timing output behavior. Mordant baselines remove resolved findings.

Changes

Isolated install timing control

Layer / File(s) Summary
Typed timing contract
src/install/isolated_install.rs
build_store now accepts Timings. Timing reports run only for Timings::Print.
Install and prune call-site wiring
src/install/isolated_install.rs, src/install/prune.rs
Verbose installs select Timings::Print; pruning selects Timings::Quiet.
Timing behavior regression coverage
test/cli/install/isolated-install.test.ts, test/cli/install/bun-prune.test.ts, mordant-baseline.toml
Tests verify timing output for verbose installs and suppression during normal installs and pruning. The baseline removes resolved findings.

Suggested reviewers: jarred-sumner

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change to replace build_store's timing boolean with an enum.
Description check ✅ Passed The description explains the problem, fix, behavior, tests, and verification results, covering the template requirements.

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. The diff is green; the remaining CI red is unrelated to it.

  • Fixes the bare_bool_args lint finding on build_store (src/install/isolated_install.rs): print_timings is now the Timings enum, install_root_dependencies stays a bool (it is a bool everywhere else it is threaded). Rebased on main after neighbouring baseline edits landed; the baseline change is now the single line for this finding.
  • Lint verified both ways: the old source with the baseline entry removed reports the finding; this branch reports nothing workspace-wide, and regenerating the baseline on it reproduces the committed file exactly.
  • Tests: one per call site pinning when the store build timings are printed (isolated-install.test.ts, bun-prune.test.ts). Both pass on every lane in CI; the full isolated-install and bun-prune files pass locally on the rebased build.
  • CI on the current build (98602) is red only on the debian 13 x64-asan lane: test/cli/run/require-cache.test.ts (timeouts), test/js/bun/util/inspect-error-leak.test.js (timeout) and vendor/elysia/test/response/stream.test.ts, each failing the same way on all four attempts. None of them exercise the package manager, and all three passed on this lane in the previous build of this branch (98474, where every job that ran passed before it was cancelled with two darwin jobs still queued). They have been filed for triage separately; this PR needs a maintainer to merge or re-run.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — mechanical bool→enum refactor with no behavior change.

What was reviewed:

  • Confirmed install_isolated_packages and prune::build_store_with are the only callers of isolated_install::build_store; both updated with the same semantics (is_verbose() → Print, false → Quiet).
  • The two matches!(timings, Timings::Print) sites are equivalent to the old if print_timings checks.
  • Baseline drops: one is the finding this PR fixes; the other two (PackageInstall.rs, node_crypto_binding.rs) are stale entries cleared by the regeneration — if wrong, the mordant CI job would catch it.
Extended reasoning...

Overview

This PR replaces the print_timings: bool parameter of build_store in src/install/isolated_install.rs with a two-variant Timings enum (Print/Quiet), updates both call sites, and regenerates mordant-baseline.toml. The regeneration drops the bare_bool_args:src/install/isolated_install.rs entry this PR fixes plus two unrelated stale entries whose underlying code changed in already-merged PRs.

Security risks

None. This is a type-only refactor of an internal function signature in the package manager's isolated linker. No user input handling, no I/O, no auth/crypto surface is touched.

Level of scrutiny

Low. The change is purely mechanical: a bool becomes an enum, and if print_timings becomes if matches!(timings, Timings::Print). I grepped for all callers of isolated_install::build_store and confirmed there are exactly two — both updated in this diff with values that preserve the prior behavior (manager.options.log_level.is_verbose() maps to Print/Quiet; prune's hardcoded false becomes Quiet). The unrelated build_store in BunObject.rs and Timings in test_command.rs are different symbols.

Other factors

The PR description documents that the isolated-install, prune, relink, and frozen-lockfile test suites pass and that verbose output was manually verified unchanged. The two extra baseline drops are the output of bun run rust:mordant:baseline and are self-checking: if either were dropped incorrectly, the rust-lints CI job would report over-baseline findings. The bug-hunting system found no issues.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — mechanical bool→enum refactor with no behavior change.

What was reviewed:

  • Both build_store callers map their old bool to the matching Timings variant (is_verbose() → Print/Quiet; prune's false → Quiet); no other install-side callers exist.
  • The two matches!(timings, Timings::Print) gates are the only sites producing "Resolved peers"/"Created store", so the new tests' stderr assertions are anchored to real output.
  • New tests follow local harness conventions (concurrent pipe drain, registry.createTestDir/setup/prune helpers) and cover both the positive (--verbose prints) and negative (quiet install, prune --verbose) cases.
  • mordant-baseline.toml drops the fixed entry plus two stale entries from a regen — CI's mordant job would fail if those findings still existed.
Extended reasoning...

Overview

This PR replaces the print_timings: bool parameter of build_store in src/install/isolated_install.rs with a two-variant Timings enum (Print/Quiet), addressing a bare_bool_args mordant lint finding. The two call sites — install_isolated_packages in the same file and build_store_with in src/install/prune.rs — are updated to pass the enum instead. Two new tests pin the observable behavior (timing lines only under --verbose install, never under prune). mordant-baseline.toml is regenerated, dropping the fixed entry and two entries that were already stale on main.

Security risks

None. This is a type-level refactor of an internal function parameter that gates two verbose-only log lines. No user input handling, no I/O paths, no permission or auth surface is touched.

Level of scrutiny

Low. The change is a textbook bool→enum readability refactor with a 1:1 mapping at every site. I confirmed via grep that the only install-side callers of build_store are the two updated in this diff (the build_store in BunObject.rs is unrelated stdio code). The two if matches!(timings, Timings::Print) branches replace if print_timings verbatim, so behavior is preserved exactly. The install_isolated_packages caller previously passed manager.options.log_level.is_verbose() and now branches on the same predicate to pick Print/Quiet; prune previously passed false and now passes Quiet.

Other factors

  • The new tests are well-formed per repo conventions: they drain stdout/stderr/exited concurrently, use the existing setup/prune/out helpers in bun-prune.test.ts and registry.createTestDir in isolated-install.test.ts, assert output before exit code, and cover both the positive (verbose install prints both lines) and negative (non-verbose install and bun prune --verbose print neither) cases. The prune test uses --production so prune builds the store twice, exercising both build_store_with invocations.
  • The two extra baseline entries dropped (always_unwrapped_option:PackageInstall.rs, narrowed_two_ways:node_crypto_binding.rs) are explained in the PR body as already-gone findings; the mordant CI job enforces this.
  • No outstanding reviewer comments; no prior claude reviews on this PR.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — mechanical bool→enum refactor with no behavior change.

What was reviewed

  • Confirmed build_store has exactly two call sites (install_isolated_packages, prune's build_store_with); both updated with the same semantics as before (is_verbose() → Print, false → Quiet).
  • Timings is pub(crate) and correctly re-imported in prune.rs; the two matches!(timings, Timings::Print) sites are the only uses of the old bool.
  • New tests follow their files' conventions (test.concurrent in bun-prune, plain test in isolated-install), drain both pipes, use the local Verdaccio registry, and assert on the exact timing-line prefixes emitted by build_store.
  • mordant-baseline.toml changes are removals only; the two extra dropped entries are explained as already-gone-on-main.
Extended reasoning...

Overview

This PR replaces the print_timings: bool parameter of build_store in src/install/isolated_install.rs with a two-variant Timings enum (Print / Quiet) to resolve a bare_bool_args mordant lint finding. The two call sites are updated: install_isolated_packages maps log_level.is_verbose() to Timings::Print/Timings::Quiet (previously passed the bool directly), and prune's build_store_with passes Timings::Quiet (previously false). Two tests pin the existing behavior at each call site. mordant-baseline.toml is regenerated, dropping the fixed entry plus two entries that are already stale on main.

Security risks

None. The change is a type-level rename of a debug-output flag; no user input handling, no I/O, no auth/crypto/permissions paths are touched.

Level of scrutiny

Low. This is a pure refactor: the enum is compared with matches!(timings, Timings::Print) at exactly the two sites that previously tested if print_timings, and the two callers pass values that map one-to-one to the old bools. Grep confirms there are no other build_store( call sites in src/install. The remaining bool parameter (install_root_dependencies) is intentionally left alone with a stated reason (threaded as a bool through several other layers).

Other factors

  • The new tests use the existing harness helpers (setup/prune/out in bun-prune.test.ts; registry.createTestDir/spawn/rm/join in isolated-install.test.ts), all of which are already imported at file top. Both drain stdout+stderr concurrently and assert exit code last, per repo conventions.
  • The prune test's inline snapshot matches the shape of other snapshots in the same file (normalized via out()).
  • No CODEOWNERS cover the touched paths.
  • The baseline regeneration only removes entries (never adds), so it cannot mask new lint findings.

@robobun
robobun force-pushed the farm/49c6b858/build-store-timings-enum branch from 1aa0560 to afe3dcd Compare August 15, 2026 19:15

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — mechanical bool→enum refactor with no behavior change.

What was reviewed:

  • Confirmed install_isolated_packages and prune's build_store_with are the only two callers of isolated_install::build_store; both map to the same behavior as before (is_verbose() → Print, false → Quiet).
  • Both if matches!(timings, Timings::Print) sites are equivalent to the prior if print_timings checks.
  • New tests use existing file-local helpers/imports, drain pipes concurrently, and assert exit code last per repo conventions.
Extended reasoning...

Overview

This PR replaces build_store's trailing print_timings: bool parameter with a two-variant Timings enum (Print/Quiet) to resolve a mordant bare_bool_args lint finding. The two call sites — install_isolated_packages in isolated_install.rs and build_store_with in prune.rs — are updated to pass the enum equivalent of what they passed before. The corresponding baseline entry is removed from mordant-baseline.toml, and two tests are added pinning the existing timing-output behavior at each call site.

Security risks

None. This is a type-level refactor of an internal function signature controlling whether two diagnostic timing lines print to stderr. No untrusted input, no auth/crypto/permissions surface.

Level of scrutiny

Low. The change is mechanical and behavior-preserving by construction: manager.options.log_level.is_verbose() maps to Timings::Print (else Quiet), and prune's literal false maps to Timings::Quiet. The two if print_timings checks become if matches!(timings, Timings::Print), which is semantically identical. I grep-verified there are no other callers of this build_store (the BunObject.rs hit is an unrelated local function).

Other factors

The added tests follow the surrounding file conventions: bun-prune.test.ts uses the file's existing setup/prune/out helpers and test.concurrent like its neighbors; isolated-install.test.ts uses registry.createTestDir and imports already present at the top of the file. Both drain stdout/stderr/exited concurrently and assert the exit code last. The PR description explains why install_root_dependencies remains a bool (threaded widely elsewhere) and documents that mordant was verified both ways. No outstanding reviewer comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants