fix(scripts): require source keys for build approvals#858
Conversation
📝 WalkthroughWalkthroughThis PR extends the build-policy approval system to support source-backed packages. It updates the ChangesSource-backed package approval in build policies
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Greptile SummarySource-backed dependencies (
Confidence Score: 5/5The change is safe to merge; the security model is internally consistent and all install/ignored-builds/graph-hash call sites have been updated. The logic is well-structured and the registry_git_hosted concern from the prior thread is addressed. Both findings are stylistic/test-coverage gaps, not functional regressions. The bats tests were updated to match the new behavior, and new unit tests cover the primary approval scenarios. No files require special attention; the two observations are in policy.rs. Important Files Changed
Reviews (3): Last reviewed commit: "test(install): update source build appro..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/aube/src/commands/ignored_builds.rs (1)
150-162:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftSource-backed variants are still collapsed before the source-key decision.
collect_ignorednow makes a source-awaredecide_package(...)call, butseenstill dedupes on(pkg.name, pkg.version)first. That collapses distinctfile+/git+variants that share a version but have differentsource_approval_key()values, so whichever variant is iterated first decides whether the entry is reported. In practice this can hide an ignored source-backed build, andapprove-buildsinherits the same blind spot because it reuses this list.Please switch the ignored-build identity/dedup key to the exact approval identity (
source_approval_key()when present, otherwise the existing registry key) instead of(name, version).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/aube/src/commands/ignored_builds.rs` around lines 150 - 162, The dedup key currently stored in seen (used in collect_ignored) collapses source-backed variants by using (pkg.name, pkg.version); change the key to use the package approval identity: compute an approval_key = pkg.source_approval_key().unwrap_or_else(|| format!("{}:{}", pkg.registry_name(), pkg.version)) and use that approval_key (and version/registry as needed) in the BTreeSet insert/check instead of (pkg.name, pkg.version), so each unique source_approval_key() is considered distinct before calling policy.decide_package and emitting IgnoredEntry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/aube-lockfile/src/lib.rs`:
- Around line 391-399: source_approval_key() currently returns Some(dep_path)
whenever registry_git_hosted is true which produces keys that BuildPolicy
(crates/aube-scripts/src/policy.rs) never recognizes; restrict
source_approval_key() to only return a key for dep_paths that are actually
source-backed by checking dep_path prefixes used by the policy parser (e.g.
"file+", "link+", "portal+", "exec+", "git+", "url+") and return None otherwise
(preserve the existing split_once('(') trimming for those valid prefixes); this
keeps the approval key vocabulary aligned with BuildPolicy's allowed_sources
handling.
---
Outside diff comments:
In `@crates/aube/src/commands/ignored_builds.rs`:
- Around line 150-162: The dedup key currently stored in seen (used in
collect_ignored) collapses source-backed variants by using (pkg.name,
pkg.version); change the key to use the package approval identity: compute an
approval_key = pkg.source_approval_key().unwrap_or_else(|| format!("{}:{}",
pkg.registry_name(), pkg.version)) and use that approval_key (and
version/registry as needed) in the BTreeSet insert/check instead of (pkg.name,
pkg.version), so each unique source_approval_key() is considered distinct before
calling policy.decide_package and emitting IgnoredEntry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 61a5b942-c0d0-4b07-9708-c4d8e17cb618
📒 Files selected for processing (7)
crates/aube-lockfile/src/graph_hash.rscrates/aube-lockfile/src/lib.rscrates/aube-scripts/src/policy.rscrates/aube/src/commands/ignored_builds.rscrates/aube/src/commands/install/lifecycle.rscrates/aube/src/commands/install/link.rscrates/aube/src/commands/install/materialize.rs
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8f5144c. Configure here.
…val jdx#858/jdx#860 Merge (not rebase) of jdx/aube main @ ab844b5 into nub-integration. Resolved 9 conflicts preserving nub's embedder behavior: - errors.rs / error-codes.data.json: kept nub's lockfile codes (OUTDATED/DECLARATION_MISMATCH/AMBIGUOUS, exit 13/14/15) AND took upstream's ERR_AUBE_RESOLUTION_SHAPE_MISMATCH, reassigning its exit code 13->16 to avoid colliding with nub's OUTDATED_LOCKFILE. - aube-scripts/lib.rs: ScriptSettings carries BOTH nub's env_overlay/path_prepends embedder overlay AND upstream's node_bin_dir/node_exe; run_script composes both PATH layers. - script_settings.rs: carry-forward embedder overlay + upstream runtime. - lifecycle.rs / default_trust.rs: adopt jdx#860 decide_package(source_key) AND keep nub's defaultTrust floor (Unspecified => floor.trusts) arm; decide_with_floor now threads the source key internally. - install/mod.rs + resolve.rs: kept nub's default_lockfile_kind seam, added upstream's refresh_lockfile_pin (inert under nub). - startup.rs: kept nub's configurable PackageManagerNames policy, folded in upstream's managePackageManagerVersions self-switch guard. - main.rs stays nub's thin lib-wrapper; ported jdx#861 CLI surface (Runtime subcommand, self_version::maybe_switch) into lib.rs; added mod runtime / mod self_version to lib.rs. jdx#861 dormancy gate (the one aube behavior change, default==upstream): runtime::set_runtime_switching_enabled(bool) OnceLock, default TRUE. ensure / ensure_for_cwd / refresh_lockfile_pin short-circuit to path_fallback when false, before any .nvmrc/.node-version/devEngines read. Re-exported from lib.rs; nub flips it false so aube's runtime resolver stays compiled-but-inert and nub keeps owning Node. Tests: aube cargo test 1965 passed / 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Summary
Tests
Note
High Risk
Changes security-sensitive lifecycle script gating and can alter virtual-store graph hashes for local/git deps; installs may skip builds or use new store paths until policies use source keys.
Overview
Source-backed dependencies (
file:,git:, tarballs, etc.) no longer inherit lifecycle build approval from bare package names orname@semverpins. They must be explicitly allowed via exact lockfile source keys (e.g.esbuild@file+abc123), parsed into separateallowed_sources/denied_sourcessets inBuildPolicy.LockedPackage::source_approval_key()supplies that key (peer suffix stripped); install, ignored-builds, jail checks, and strict-dep-build prompts all calldecide_packagewith it.Graph hashing now takes a full
LockedPackagein the allow-build callback and folds local source specifiers intofull_pkg_id, so different file/git bytes at the same manifest version get distinct virtual-store hashes (with cascade to parents).Integration tests expect workspace
onlyBuiltDependenciesby name to skipfile:postinstalls until a source key is approved, and strict-dep-build messages to referencepkg@file+…identities.Reviewed by Cursor Bugbot for commit 0c00d92. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Refactor
Behavior
Tests