Skip to content

feat(scripts): allow git repository build approvals - #1010

Merged
jdx merged 2 commits into
mainfrom
codex/allow-git-build-repos
Jul 13, 2026
Merged

jdx merged 2 commits into
mainfrom
codex/allow-git-build-repos

Conversation

@jdx

@jdx jdx commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • support allowBuilds rules keyed by a package and normalized Git repository URL
  • retain exact source approvals and make all deny rules win
  • apply repository rules consistently to lifecycle execution, jailing, ignored-build reporting, and graph hashes

Tests

  • cargo fmt --check
  • cargo test -p aube -p aube-scripts -p aube-lockfile
  • cargo clippy -p aube -p aube-scripts -p aube-lockfile --all-targets -- -D warnings

This pull request was generated by Codex.


Note

Medium Risk
Changes dependency lifecycle allow/deny logic for Git sources; scope is limited to explicit repo keys with denies still overriding allows.

Overview
Adds repository-scoped allowBuilds rules for Git dependencies, e.g. native-addon@git+https://github.com/acme/native-addon.git, so an audited repo can move to new commits without re-approving each resolved SHA. Keys omit the commit (LockedPackage::git_repository_approval_key); exact per-source keys and name-only registry approvals stay unchanged.

BuildPolicy parses these into separate allow/deny sets, evaluates them in decide_package_with_git_repository (repo deny/allow with existing deny-wins precedence), and documents the new key shape. Install paths share package_build_is_allowed for lifecycle runs, script jailing, ignored-build reporting, and graph-hash “build allowed” checks. Security docs describe the YAML pattern.

Reviewed by Cursor Bugbot for commit c40a0ae. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Added Git repository–based build approvals for Git dependencies that don’t depend on resolved commits.
    • Git repository allow/deny rules are now applied consistently during dependency lifecycles and installation graph/hash checks.
    • Repository-level denies take precedence, and repository-level allows are granted before existing package/source rules.
  • Bug Fixes
    • Improved approval matching to treat Git URLs with an existing git+ prefix correctly.
  • Documentation
    • Clarified allowBuilds guidance with examples for approving package and repository URL keys (not commits).

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Git-backed packages now expose approval keys based on repository identity rather than resolved commits. Build policies classify and evaluate these keys, and lifecycle, ignored-build, graph-hash, and security-documentation paths use the repository-aware approval flow.

Changes

Git repository build approvals

Layer / File(s) Summary
Repository approval key contract
crates/aube-lockfile/src/lib.rs
LockedPackage generates and tests a Git repository approval key containing the registry name and repository URL without the resolved commit.
Repository policy classification and decisions
crates/aube-scripts/src/policy.rs
BuildPolicy stores Git repository allow/deny rules, classifies matching entries, evaluates repository rules, merges them, and tests commit-independent precedence.
Lifecycle and ignored-build decisions
crates/aube/src/commands/ignored_builds.rs, crates/aube/src/commands/install/lifecycle.rs, crates/aube/src/commands/install/mod.rs
Lifecycle jobs, jail checks, unreviewed dependency filtering, and ignored-build filtering pass Git repository keys to policy decisions through a shared helper.
Install hashing integration and approval guidance
crates/aube/src/commands/install/link.rs, crates/aube/src/commands/install/materialize.rs, docs/security.md
Graph-hash allow predicates use repository-aware policy checks, and security guidance documents repository URL approvals for branch-tracking Git dependencies.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LockedPackage
  participant BuildPolicy
  participant InstallLifecycle
  LockedPackage->>BuildPolicy: derive repository URL approval key
  InstallLifecycle->>BuildPolicy: evaluate package with source and repository keys
  BuildPolicy->>InstallLifecycle: return allow, deny, or jail decision
Loading

Possibly related PRs

  • jdx/aube#858: Extends the same build-approval pipeline with source approval keys.

Poem

A bunny found a Git repo bright,
Its commit changed from day to night.
“Approve the path,” the bunny said,
“Not every hash beneath the thread!”
Policies now hop branch to branch. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Git repository build approvals in scripts.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c6489be. Configure here.

Comment thread crates/aube-lockfile/src/lib.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/aube/src/commands/install/materialize.rs (1)

151-158: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting the duplicated allow closure into a shared helper.

This closure is identical in logic to the one in link.rs:269-276. Both extract source_approval_key() + git_repository_approval_key() and call decide_package_with_git_repository with the same parameter order. Divergence between the two would cause inconsistent build-approval decisions across the prewarm and link phases — a security-relevant risk.

♻️ Proposed shared helper
/// Returns `true` if `pkg` is explicitly allowed to build under `policy`,
/// considering both source and git-repository approval keys.
fn is_package_build_allowed(
    pkg: &aube_lockfile::LockedPackage,
    policy: &aube_scripts::BuildPolicy,
) -> bool {
    let source_key = pkg.source_approval_key();
    let git_repository_key = pkg.git_repository_approval_key();
    matches!(
        policy.decide_package_with_git_repository(
            pkg.registry_name(),
            &pkg.version,
            source_key.as_deref(),
            git_repository_key.as_deref(),
        ),
        aube_scripts::AllowDecision::Allow
    )
}

Then both call sites reduce to:

 let allow = |pkg: &aube_lockfile::LockedPackage| {
-    let source_key = pkg.source_approval_key();
-    let git_repository_key = pkg.git_repository_approval_key();
-    matches!(
-        build_policy_for_hash.decide_package_with_git_repository(
-            pkg.registry_name(),
-            &pkg.version,
-            source_key.as_deref(),
-            git_repository_key.as_deref(),
-        ),
-        aube_scripts::AllowDecision::Allow
-    )
+    is_package_build_allowed(pkg, &build_policy_for_hash)
 };
🤖 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/install/materialize.rs` around lines 151 - 158,
Extract the duplicated package-approval closure into a shared
`is_package_build_allowed` helper, colocated in an appropriate common module.
Have it accept `LockedPackage` and `BuildPolicy`, extract both approval keys,
and call `decide_package_with_git_repository` with the existing parameter order;
update the prewarm logic here and the corresponding closure in `link.rs` to use
it.
🤖 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/src/commands/ignored_builds.rs`:
- Around line 161-168: In `ignored-builds` processing, `seen` is updated before
the source-specific decision, allowing an approved repository to suppress an
unapproved one with the same package coordinates. Evaluate
`policy.decide_package_with_git_repository` first, then perform the `(name,
version)` deduplication and update `seen` only after the policy check identifies
the entry for reporting.

---

Nitpick comments:
In `@crates/aube/src/commands/install/materialize.rs`:
- Around line 151-158: Extract the duplicated package-approval closure into a
shared `is_package_build_allowed` helper, colocated in an appropriate common
module. Have it accept `LockedPackage` and `BuildPolicy`, extract both approval
keys, and call `decide_package_with_git_repository` with the existing parameter
order; update the prewarm logic here and the corresponding closure in `link.rs`
to use it.
🪄 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: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ed385ca-4297-4de3-946a-e86877c3ac16

📥 Commits

Reviewing files that changed from the base of the PR and between 10c4081 and c6489be.

📒 Files selected for processing (7)
  • crates/aube-lockfile/src/lib.rs
  • crates/aube-scripts/src/policy.rs
  • crates/aube/src/commands/ignored_builds.rs
  • crates/aube/src/commands/install/lifecycle.rs
  • crates/aube/src/commands/install/link.rs
  • crates/aube/src/commands/install/materialize.rs
  • docs/security.md

@greptile-apps

greptile-apps Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces repository-scoped allowBuilds rules for Git dependencies, so users can approve builds by normalized repo URL rather than pinning every resolved commit.

  • Policy layer (policy.rs): Adds allowed_git_repositories/denied_git_repositories sets, a decide_package_with_git_repository API, and an is_git_repository_key classifier covering all git+<scheme>:// prefixes. Deny-wins semantics are preserved; bare package-name approvals still cannot approve Git-sourced packages.
  • Lockfile layer (lib.rs): Adds git_repository_approval_key() which normalises stored Git URLs to a canonical name@git+<url> key.
  • Install wiring: All callsites (lifecycle execution, jail policy, ignored-build reporting, graph-hash folding) thread git_repository_key through the new decision API via a shared package_build_is_allowed helper. The deduplication order in ignored_builds.rs was also corrected so the policy check runs before dedup, preventing a denied package from being silently skipped when an approved package with the same (name, version) pair appears earlier in the graph.

Confidence Score: 5/5

Safe to merge — the implementation is complete, internally consistent, and well-tested across all affected code paths.

All six affected callsites correctly thread both keys into the new decision API. The deny-wins invariant is maintained at every check level: bare-name, wildcard, source-key, git-repository, and versioned-name denies are all evaluated before any allow is returned. The deduplication ordering fix in ignored_builds.rs is a genuine correctness improvement with no observable regression. Comprehensive unit tests cover the new code paths including native-git transport, cross-repo isolation, and the interaction between repository allows and package-name denies.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube-scripts/src/policy.rs Core policy engine: adds allowed/denied_git_repositories sets, new decide_package_with_git_repository API, and is_git_repository_key classifier including git+git:// transport. Deny-wins ordering is correct throughout; comprehensive tests added.
crates/aube-lockfile/src/lib.rs Adds git_repository_approval_key() which normalizes all git URL variants (with or without git+ prefix) to a consistent git+:// key; tests cover both normalization paths.
crates/aube/src/commands/ignored_builds.rs Ordering fix: policy check now precedes deduplication, so a denied package is no longer silently skipped when an allowed package with the same (name, version) appeared first in graph traversal order.
crates/aube/src/commands/install/mod.rs Extracts shared package_build_is_allowed helper that threads both source_key and git_repository_key into the new API, eliminating duplication across link.rs and materialize.rs.
crates/aube/src/commands/install/lifecycle.rs Threads git_repository_key through JailBuildPolicy::should_jail and get_script_jail; stored on the job struct at enqueue time and consumed correctly in the worker.
crates/aube/src/commands/install/link.rs Replaces inline decide_package call with package_build_is_allowed helper for graph-hash computation; no functional change beyond incorporating git_repository_key.
crates/aube/src/commands/install/materialize.rs Same refactor as link.rs — replaces inline decide_package call with package_build_is_allowed for the GVS prewarm graph-hash closure.
docs/security.md Documents the new repository-URL approval syntax for branch-tracking Git deps; accurate and consistent with the implementation.

Reviews (2): Last reviewed commit: "fix(scripts): normalize git repository a..." | Re-trigger Greptile

Comment thread crates/aube-scripts/src/policy.rs Resolved
@jdx
jdx merged commit c3a535a into main Jul 13, 2026
18 checks passed
@jdx
jdx deleted the codex/allow-git-build-repos branch July 13, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant