Skip to content

feat(cargo): add opt-in workspace target ownership - #235

Merged
ark-archastro merged 1 commit into
mainfrom
ark/cargo-workspace-ownership
Oct 31, 2026
Merged

ark-archastro merged 1 commit into
mainfrom
ark/cargo-workspace-ownership

Conversation

@ark-archastro

@ark-archastro ark-archastro commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review on ArchCode

Problem and author intent

Aster deduplicates target addresses. When several Cargo members each define a command that checks their whole workspace, selecting those members launches the same operation repeatedly. Cargo then serializes those processes on its build directory. Keeping the definitions aligned also requires forwarding stanzas in every new crate.

This PR makes workspace ownership explicit and opt-in. Unconfigured workspaces retain their existing commands and dependency edges, and discovery still works without Cargo installed.

What changed

[cargo.workspace]
targets = ["deps", "build", "lint"]

Each listed target needs an explicit command at the Cargo root. Cargo metadata supplies membership; Aster generates dependency-only member entry points pointing to one owner address. Root plus member selections therefore execute the owner once. Conflicting member definitions and ownership cycles are rejected.

  • Adds general dependency-only targets: depends_on without command. They launch no process and store no artifact-cache entry, while preserving failure and dependency-hash propagation.
  • Includes member sources, embedded assets and custom source directories in owner cache and affected-file inputs. Generated walks respect repository ignores, exclude Cargo output/nested projects, and ignore personal global exclusions.
  • Removes redundant inferred intra-workspace build edges before explicit overrides merge. Preserves the source dependency graph, including inherited dependencies and valid self dev-dependencies.
  • Resolves aliases against final ownership, then infers artifact outputs from the final target names/commands. Package tests and differently named variants remain independent.

Scope: backend-only Rust CLI, configuration and documentation. Risk: medium; ownership is opt-in, but discovery, caching and dependency-only scheduling interact. Incorrect inputs could skip a required gate. Existing aliases and non-opted-in discovery have compatibility tests.

User impact: opted-in repositories can define shared Cargo gates once. Commands run as written; Aster does not add --workspace or change profiles. This PR does not enable the feature in downstream repositories.

Verification

Canonical process proof: tests/cli_tests/cargo_workspace.rs, cargo_workspace_members_share_gates_and_invalidate_unselected_inputs. Real Aster, Cargo, Git and compiler processes run a temporary workspace. Assertions cover one owner execution, warm-cache reuse, member/asset invalidation, automatic membership, independent package tests and variants, aliases, and propagation of a real compiler failure.

Integration matrix Proof
root/member entry points, multiple members, cold/warm cache, new member canonical test above
nested/package roots, excluded crates, custom sources, external-only changes/deletion through affected nested_cargo_workspace_hashes_external_modules_without_claiming_excluded_crates
no opt-in, Cargo absent from PATH, original commands/edges unconfigured_cargo_workspaces_keep_package_targets_without_invoking_cargo
conflicting/missing owners, cycles, invalid nested configuration cargo_workspace_rejects_ambiguous_or_cyclic_ownership_before_execution
commandless success/failure, downstream cache invalidation, sparse prerequisites, no separate cache entry, execution flags dependency_only_targets_follow_prerequisite_results_without_own_cache_entries

Fidelity: production discovery, scheduler, cache and affected selection; real Cargo metadata/build/test and Git. Shell wrappers only record actual gate invocations. No admission or input-selection logic is mocked.

Local results: 208 focused unit tests and all five integration tests pass. Formatting, workspace-wide Clippy with warnings denied, and documentation checks pass. Three separately compiled mutations fail the intended assertions: omitted generated affected-input selection, omitted member-file hashing, and omitted transitive dependency hashes. Independent code and test review completed.

CI result: all 13 checks pass at e4fe4baa491cf0d37bf68877aaaf751bcf69a4c2, including all five new tests on both Linux and macOS, dependency audit, MSRV, quality, CodeQL, packaging and the server container smoke test. ArchDev reported no rule violations. Its medium risk assessment identifies residual cache/discovery complexity and Unix-only process coverage, without a specific defect.

Automatic coverage: existing CI workflow on pull requests/main pushes. Linux runs cargo test --workspace --all-targets --all-features; macOS explicitly includes --test integration. The added module is discovered through tests/integration.rs -> cli_tests/mod.rs. Exhaustive tests and dependency audit run in CI.

Not proven here / limits: Windows runtime is outside these Unix fixtures. Cross-invocation serialization is unchanged. Inputs read by arbitrary build scripts outside member/custom source directories still require explicit cache declarations. Direct streaming of commandless targets is rejected; use --no-stream. Downstream configuration adoption and release are separate from this PR.

Checklist

  • Tests cover the behavior change
  • Documentation is updated where needed
  • No secrets, private fixtures, or generated artifacts are included
  • Formatting, clippy, focused tests, and docs pass locally

@ark-archastro
ark-archastro requested a review from a team October 31, 2026 01:20
@ark-archastro
ark-archastro merged commit b31ed02 into main Oct 31, 2026
13 checks passed
@ark-archastro ark-archastro mentioned this pull request Oct 31, 2026
4 tasks done
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