Skip to content

chore: decompose cargo-hack feature sweep into per-crate parallel targets#2741

Draft
benfdking wants to merge 3 commits into
mainfrom
claude/great-bell-eyf0rr
Draft

chore: decompose cargo-hack feature sweep into per-crate parallel targets#2741
benfdking wants to merge 3 commits into
mainfrom
claude/great-bell-eyf0rr

Conversation

@benfdking

@benfdking benfdking commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refactors the monolithic cargo hack check --each-feature Bazel test into a decomposed, parallelizable suite of per-crate, per-feature targets. Instead of one all-or-nothing serial action, each crate owns its feature variations in a hack.bzl file, and Bazel generates individual cargo check targets with better failure attribution and caching.

Key Changes

  • New cargo_build.bzl helpers:

    • each_feature(features): builds the --each-feature variation map for a crate
    • hack_command(manifest, args): formats a single cargo-hack-equivalent command line
    • cargo_hack_suite(name, manifest, variations, closure, vendor, size): generates one cargo check test per feature variation plus a public aggregating suite
  • New hack.bzl files in each crate:

    • declare MANIFEST, FEATURES, and CLOSURE
    • derive the HACK map via each_feature(FEATURES)
    • scope generated test inputs to the crate's in-workspace dependency closure for better cache reuse
  • Updated crate BUILD.bazel files:

    • load cargo_hack_suite and each crate's hack.bzl
    • generate per-feature targets via cargo_hack_suite(name = "hack", ...)
    • each crate's hack suite is runnable via bazel test //crates/<name>:hack
  • Root BUILD.bazel changes:

    • adds //:hack_reconcile to verify the decomposed maps match cargo hack check --each-feature --print-command-list
    • replaces the monolithic cargo_hack_check with a test_suite aggregating all per-crate hack suites plus the reconciliation guard
    • exposes shared cargo filegroups/providers needed by crate-level targets

Readiness Fixes

  • Generated per-crate :hack suites are explicitly public so the root //:cargo_hack_check suite can depend on them.
  • //:hack_reconcile is sized as medium; it exceeded the small timeout locally while producing the command list.

Validation

  • bazel test //:hack_reconcile --test_output=errors
  • bazel test //:cargo_hack_check --test_output=errors
  • git diff --check

The full aggregate cargo-hack suite passes locally: 41/41 targets green.

Replace the monolithic `cargo hack check --each-feature` Bazel action with
one `cargo check` target per feature per crate, generated from a per-crate
hack.bzl variation map via the new cargo_hack_suite macro. This lets Bazel
run the feature checks in parallel and attribute failures per feature.

Each crate owns a hack.bzl declaring its FEATURES; the //:hack_reconcile test
diffs the union of those maps against `cargo hack ... --print-command-list`
(enumerated without compiling) so the decomposition stays a one-to-one match
with cargo-hack and no feature combination is silently dropped.

The //:cargo_hack_check test_suite aggregates the whole sweep plus the
reconciliation guard, preserving the existing target name for CI.

https://claude.ai/code/session_01LtWNfZpPpUfbW9xuGPrrSy
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@benfdking benfdking requested a review from Copilot June 14, 2026 20:16
@benfdking benfdking changed the title Decompose cargo-hack feature sweep into per-crate parallel targets chore: decompose cargo-hack feature sweep into per-crate parallel targets Jun 14, 2026

Copilot AI 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.

Pull request overview

Refactors the existing monolithic Bazel cargo hack check --each-feature verification into per-crate, per-feature Bazel test targets, with a root-level reconciliation test to ensure the decomposed enumeration matches cargo-hack’s own --print-command-list output.

Changes:

  • Added each_feature, hack_command, and cargo_hack_suite helpers to generate per-feature cargo check tests and an aggregating suite.
  • Introduced per-crate hack.bzl modules declaring MANIFEST, FEATURES, and derived HACK variation maps.
  • Updated root and crate BUILD.bazel files to wire per-crate hack suites and add //:hack_reconcile, plus adjusted visibility for shared filegroups/providers.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cargo_build.bzl Adds helpers/macro to generate per-feature cargo check tests and suites.
BUILD.bazel Aggregates per-crate hack suites; adds reconciliation test; makes shared cargo filegroups/providers public.
crates/cli/hack.bzl Declares feature list + manifest for per-feature variations.
crates/cli/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/cli-lib/hack.bzl Declares feature list + manifest for per-feature variations.
crates/cli-lib/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/cli-python/hack.bzl Declares featureless crate variation map + manifest.
crates/cli-python/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/lib/hack.bzl Declares feature list + manifest for per-feature variations.
crates/lib/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/lib-core/hack.bzl Declares feature list + manifest for per-feature variations.
crates/lib-core/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/lib-dialects/hack.bzl Declares dialect feature list + manifest for per-feature variations.
crates/lib-dialects/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/lib-wasm/hack.bzl Declares featureless crate variation map + manifest.
crates/lib-wasm/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/lineage/hack.bzl Declares featureless crate variation map + manifest.
crates/lineage/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/lsp/hack.bzl Declares featureless crate variation map + manifest.
crates/lsp/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.
crates/sqlinference/hack.bzl Declares featureless crate variation map + manifest.
crates/sqlinference/BUILD.bazel Adds cargo_hack_suite(name="hack", ...) for per-feature checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cargo_build.bzl
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark for 1663ac9

Click to view benchmark
Test Base PR %
DepthMap::from_parent 59.2±0.99µs 58.1±0.81µs -1.86%
fix_complex_query 12.1±0.12ms 12.1±0.07ms 0.00%
fix_superlong 178.0±4.52ms 185.5±5.08ms +4.21%
parse_complex_query 4.1±0.04µs 4.1±0.09µs 0.00%
parse_expression_recursion 6.8±0.12µs 6.8±0.10µs 0.00%
parse_simple_query 1057.2±11.49ns 1059.4±33.45ns +0.21%

@benfdking benfdking closed this Jun 14, 2026
@benfdking benfdking reopened this Jun 14, 2026
@benfdking benfdking marked this pull request as draft June 14, 2026 20:48
Each crate's hack targets now take only their dependency-closure sources as
action inputs (the crate plus its transitive in-workspace deps, declared as
CLOSURE in hack.bzl), instead of the whole workspace. cargo_hack_suite trims
the workspace members/default-members to the same closure in-sandbox so cargo
loads only those crates rather than validating every member.

This isolates Bazel cache keys per closure: editing an unrelated crate (e.g.
lineage) no longer invalidates another crate's feature checks (e.g.
lib-dialects), maximising cache hits while still checking every feature.

https://claude.ai/code/session_01LtWNfZpPpUfbW9xuGPrrSy
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark for 5998b03

Click to view benchmark
Test Base PR %
DepthMap::from_parent 58.0±0.42µs 57.4±0.56µs -1.03%
fix_complex_query 12.0±0.06ms 11.9±0.08ms -0.83%
fix_superlong 192.6±6.55ms 186.0±6.38ms -3.43%
parse_complex_query 4.0±0.04µs 4.1±0.11µs +2.50%
parse_expression_recursion 7.1±0.14µs 6.9±0.11µs -2.82%
parse_simple_query 1052.9±18.98ns 1060.6±14.60ns +0.73%

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Benchmark for c98bc2a

Click to view benchmark
Test Base PR %
DepthMap::from_parent 58.7±0.97µs 59.5±0.97µs +1.36%
fix_complex_query 12.1±0.17ms 12.1±0.18ms 0.00%
fix_superlong 119.5±3.44ms 120.0±5.28ms +0.42%
parse_complex_query 4.2±0.49µs 4.2±0.05µs 0.00%
parse_expression_recursion 6.8±0.06µs 6.8±0.12µs 0.00%
parse_simple_query 1039.9±12.46ns 1040.7±15.19ns +0.08%

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.

3 participants