isolated install: name the entry-hash DFS indices after the table they index - #39129
Conversation
…y index In the global store entry-hash DFS in install_isolated_packages, the dependency's store entry index was a local called dep_idx. That name already means two other things nearby: StackFrame.dep_idx was the cursor into the entry's dependency list, and build_store's dep_idx is a lockfile DependencyID, which is what indexes `dependencies` on the line above. states[dep_idx] was correct (states has one slot per store entry and dep_idx came from dep.entry_id), but nothing in the names said so. Rename the three entry indices to entry_idx, root_entry_idx and dep_entry_idx, and the per-frame cursor to next_dep. No behavior change. Drops the index_of_other_kind entry for this file from the mordant baseline; the lint no longer fires here.
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
There was a problem hiding this comment.
LGTM — pure variable renames, no behavior change.
What was reviewed:
- Verified each rename maps 1:1 (
_root_id→root_entry_idx,idx→entry_idx, localdep_idx→dep_entry_idx,StackFrame.dep_idx→next_dep) with no logic drift. - Confirmed
StackFrameis only referenced inside this DFS, so the field rename has no other consumers. - The remaining
dep_idxat isolated_install.rs:367-380 is a genuineDependencyIDinbuild_store, correctly left alone. - Baseline removal matches the lint being resolved.
Extended reasoning...
Overview
This PR renames four local variables / one struct field in the entry-hash DFS of install_isolated_packages (src/install/isolated_install.rs) so that every index into the per-store-entry tables (states, entry_hashes, entry_node_ids, entry_dependencies) is named with an entry prefix, and the per-frame dependency-list cursor is renamed from dep_idx to next_dep. It also drops the corresponding index_of_other_kind suppression from mordant-baseline.toml. No control flow, expressions, or types change — I walked each hunk and every renamed identifier substitutes into the identical position with the identical value.
Security risks
None. This is a rename-only change in the isolated-install linker's hash-computation DFS; no inputs, boundaries, or error paths are touched.
Level of scrutiny
Low. The diff is mechanical and self-contained. StackFrame is a private struct defined and consumed only within this file (grep confirms three reference sites, all inside the diff), so the field rename cannot break anything elsewhere. The other dep_idx occurrences in the file (lines ~367-380) are in build_store where the variable is explicitly a DependencyID — leaving those unchanged is consistent with the PR's stated rule that dep_* names are reserved for DependencyIDs.
Other factors
The PR description shows the mordant lint firing before the rename and clean after, and cargo check / cargo fmt --check passing. No new tests are needed since there is no behavioral change to observe — the existing isolated-install suite covers this code path. The one added doc comment on next_dep is accurate and useful (disambiguates from DependencyID). The deliberate decision to leave the stale always_unwrapped_option baseline line for a separate regenerate is reasonable scope hygiene.
Problem
index_of_other_kindinsrc/install/isolated_install.rs: "statesis indexed bydep_idxhere. Elsewhere in this function it is indexed by_root_id(1 place), anddep_id(the same kind asdep_idx) indexesdependencies. This looks like the wrong table" (install_isolated_packages, thematch states[dep_idx]in the entry-hash DFS).states[dep_idx]is correct.stateshas one slot per store entry, and thatdep_idxisdep.entry_id.get(), the store entry index of the dependency being visited. The lockfileDependencyID(dep.dep_id) is the one used to indexdependencieson the line above.dep_idxmeant two different things (StackFrame.dep_idxis the cursor into the entry's dependency list; the local is a store entry index), and earlier in the same file (build_store's workspace loop)dep_idxis aDependencyID. The root loop variable_root_idis a store entry index too, named as if unused.Fix
entry_idx,root_entry_idxanddep_entry_idx, and the per-frame cursorStackFrame.dep_idxtonext_dep. Every index intostates/entry_hashes/entry_node_ids/entry_dependenciesnow saysentry; nothing index-shaped is calleddep_*unless it is aDependencyID. No behavior change: renames only.store::entry::Id, aNewId<Entry>distinct fromNewId<Node>), and the per-entry tables areMultiArrayListcolumn slices indexed withid.get() as usizeat roughly 120 sites across this crate. Wrapping this one local scratch table would not stop a crossing on any of its siblings; making the columns typed is a crate-wide change, not this one.index_of_other_kind:src/install/isolated_install.rsfrommordant-baseline.toml.test/can fail before and pass after. The baseline line is the before/after check instead: with it removed, themordantCI job fails on the old names and passes on the new ones (shown below).cargo dylint --all -p bun_install --no-deps(therust:mordantcommand scoped to this crate) with the baseline line removed: reports the finding atstates[dep_idx]without the rename, nothing with it (output below).MORDANT_BASELINE_WRITE=1on this crate regenerates the[bun_install]section without this line. It also dropsalways_unwrapped_option:src/install/PackageInstall.rs, which is already stale on main (it disappears with or without this change), so that line is left for a later regenerate rather than folded in here.cargo check -p bun_install,cargo fmt -p bun_install -- --check.Background
node_modules/.bun, with per-entry columns (entry_hashes,entry_node_ids,entry_dependencies) indexed bystore::entry::Id. Each entry's dependency list holdsDependenciesItem { entry_id, dep_id }: the store entry the symlink points at, plus the lockfileDependencyIDthat names the alias.install_isolated_packagesruns an iterative DFS over entries to computeentry_hashes, a hash of each entry's resolved dependency closure used to share store directories across projects.statesis that DFS's per-entry visit state;StackFrameis one entry being visited, and its cursor says how far through the entry's dependency list it is.index_of_other_kindreads index kinds off names only (the prefix before_idx/_id). It flaggedstatesbecause it was indexed under two unrelated kinds (_root_id,dep_idx) whiledep_idindexed a table of its own kind; after the rename every index intostatescarries theentrykind.mordant output with the baseline line removed
Without the rename:
With the rename: no warnings,
target/mordant/over-baseline.txtnot written.