[PR #7] [MERGED] fix(native): let cargo add the lock edges a crate's features need #10

Closed
opened 2026-11-02 15:32:28 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-mixins/pull/7
Author: @reservedbytes
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix/complete-lock-for-crate-features


📝 Commits (2)

  • 60174ca fix(native): let cargo add the lock edges a crate's features need
  • f419c9c Merge remote-tracking branch 'origin/main' into fix7

📊 Changes

9 files changed (+201 additions, -8 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -0)
➕ crates/horizon-mixins-cli/src/lockfile.rs (+60 -0)
📝 crates/horizon-mixins-cli/src/main.rs (+2 -0)
📝 crates/horizon-mixins-cli/tests/cases/native.rs (+49 -1)
📝 crates/horizon-mixins-core/src/native.rs (+38 -0)
📝 docs/crates-data-and-named-hooks.md (+13 -7)
📝 fixtures/native/Cargo.lock (+30 -0)
📝 fixtures/native/README.md (+2 -0)
📝 fixtures/native/driver/Cargo.toml (+6 -0)

📄 Description

What and why

A bundle crate with a normal dependency like hashbrown = "0.15" can't build on #3964, even though everything it needs is in Horizon's lock.
Horizon locks hashbrown without its default features, and the defaults also need allocator-api2 and equivalent (both already locked for other crates).
native::stage can't know which optional deps a feature turns on, so two dependency lines are missing and --locked refuses the stage.
The launcher then says the crate "isn't in Horizon's Cargo.lock", which isn't true.

apply and check now run cargo update --workspace on a scratch copy of the stage (offline first, no crate downloads), then compare with Horizon's lock.
Only dependency edges between already locked packages can be added.
Any new or changed package is still E_CRATE_DEPENDENCY, so the lock stays the allow list.
Costs about 0.7 s per apply, only for bundles with crates.

Checks

cargo fmt --all --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked (90 passed, new test default_features_may_link_locked_packages_but_never_add_one).

Also checked against #3964's source: a crate with hashbrown = "0.15" stages and cargo check --locked passes.
Same test file as #8 , so the second to merge needs a one-line rebase.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-mixins/pull/7 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/complete-lock-for-crate-features` --- ### 📝 Commits (2) - [`60174ca`](https://github.com/horizon-rust/horizon-mixins/commit/60174ca2119f208fafb94057b551a8292a96f690) fix(native): let cargo add the lock edges a crate's features need - [`f419c9c`](https://github.com/horizon-rust/horizon-mixins/commit/f419c9c919e34862eff3d332d59cc1058380ad05) Merge remote-tracking branch 'origin/main' into fix7 ### 📊 Changes **9 files changed** (+201 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -0) ➕ `crates/horizon-mixins-cli/src/lockfile.rs` (+60 -0) 📝 `crates/horizon-mixins-cli/src/main.rs` (+2 -0) 📝 `crates/horizon-mixins-cli/tests/cases/native.rs` (+49 -1) 📝 `crates/horizon-mixins-core/src/native.rs` (+38 -0) 📝 `docs/crates-data-and-named-hooks.md` (+13 -7) 📝 `fixtures/native/Cargo.lock` (+30 -0) 📝 `fixtures/native/README.md` (+2 -0) 📝 `fixtures/native/driver/Cargo.toml` (+6 -0) </details> ### 📄 Description ## What and why A bundle crate with a normal dependency like `hashbrown = "0.15"` can't build on #3964, even though everything it needs is in Horizon's lock. Horizon locks `hashbrown` without its default features, and the defaults also need `allocator-api2` and `equivalent` (both already locked for other crates). `native::stage` can't know which optional deps a feature turns on, so two dependency lines are missing and `--locked` refuses the stage. The launcher then says the crate "isn't in Horizon's Cargo.lock", which isn't true. `apply` and `check` now run `cargo update --workspace` on a scratch copy of the stage (offline first, no crate downloads), then compare with Horizon's lock. Only dependency edges between already locked packages can be added. Any new or changed package is still `E_CRATE_DEPENDENCY`, so the lock stays the allow list. Costs about 0.7 s per apply, only for bundles with crates. ## Checks `cargo fmt --all --check` `cargo clippy --workspace --all-targets --locked -- -D warnings` `cargo test --workspace --locked` (90 passed, new test `default_features_may_link_locked_packages_but_never_add_one`). Also checked against #3964's source: a crate with `hashbrown = "0.15"` stages and `cargo check --locked` passes. Same test file as #8 , so the second to merge needs a one-line rebase. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:32:28 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-mixins#10
No description provided.