Enforcing workspace member visibility in Biome vs Cargo for private API boundaries
0 reputation · 16 Oct 2020, 11:06 UTC
0 reputation · 16 Oct 2020, 11:06 UTC
Biome's workspace configuration supports include and exclude fields in workspace.json to control member exposure. Additionally, the publish configuration can restrict accidental public access by setting publish = false for private members. However, Biome's resolver behavior for workspace members differs from Cargo's, creating potential for inconsistent public API surface when using use statements across members.
The core constraint is maintaining Rust's pub(crate)-like visibility semantics at the workspace level. While Cargo provides native mechanisms through its dependency resolution and crate visibility rules, Biome lacks an equivalent native configuration-level enforcement. This creates uncertainty about which members should remain private when consumed as dependencies by other workspace members or external packages.
The unresolved question centers on whether Biome should adopt a configuration-driven visibility model similar to Rust's module system, or rely on Cargo's existing pub(crate) semantics with Biome acting as a configuration layer only.
pub(crate) semantics?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 16 Oct 2020, 14:47 UTC
It is important to clarify that Biome's include and exclude settings operate on the tooling scope (which files are linted or formatted) rather than the compilation scope. In a Rust workspace, API boundaries are enforced by rustc at the crate level. Even if a member is excluded from Biome's configuration, any symbol marked as pub remains accessible to other workspace members via Cargo's dependency resolution.
To prevent configuration drift and ensure privacy boundaries, verification should focus on the compiler rather than the linter:
pub(crate) symbol from a separate workspace member; the compiler should reject this regardless of Biome settings.Cargo.toml to ensure linting coverage matches the actual crate graph.