diff --git a/docs/dev/architecture/dependency-flow.md b/docs/dev/architecture/dependency-flow.md index 675741734..dec314c44 100644 --- a/docs/dev/architecture/dependency-flow.md +++ b/docs/dev/architecture/dependency-flow.md @@ -103,12 +103,18 @@ The controller checks the latest operation before continuing runtime work and computes each plan from a fresh observation. Shared records avoid conversion between separate store, API, and client operation models. -`just boundary` (`cargo xtask boundary`) checks that `piqueld-core` depends on no -server, Docker, database, or browser framework (`axum`, `bollard`, `sqlx`, -`leptos`), including through build and development dependencies. It also -checks that the daemon's crates don't depend on those they build alongside: -`piqueld-config` depends on no Docker, database, or browser framework, nor on -the daemon or its store; `piqueld-store` on no server, Docker, or browser -framework, nor on the daemon or its configuration, even in its tests; and -`piqueld-docker` on no server, database, or browser framework, nor on the -daemon, its configuration, or its store. +`just boundary` (`cargo xtask boundary`) checks each crate's dependencies on +every target, wasm32 included. `piqueld-core` depends on no server, Docker, +database, or browser framework (`axum`, `bollard`, `sqlx`, `leptos`), including +through build and development dependencies. `piqueld-client` depends on no +workspace crate but `piqueld-core` and `piqueld-probe`, so neither on the +daemon's crates nor on the CLI, dashboard or tooling, and on no Docker, +database, or browser framework, again including through build and development +dependencies. Only its native tests may use a server framework: they serve +their requests with `axum`. It also checks that the daemon's crates don't +depend on those they build alongside: `piqueld-config` depends on no Docker, +database, or browser framework, nor on the daemon or its store; +`piqueld-store` on no server, Docker, or browser framework, nor on the daemon +or its configuration, even in its tests; and `piqueld-docker` on no server, +database, or browser framework, nor on the daemon, its configuration, or its +store. diff --git a/docs/dev/rust-conventions.md b/docs/dev/rust-conventions.md index f8476d10e..a05b8efbf 100644 --- a/docs/dev/rust-conventions.md +++ b/docs/dev/rust-conventions.md @@ -10,9 +10,11 @@ logic instead of copying it. [Module boundaries](architecture/dependency-flow.md) describes each crate and what it may depend on, and `just boundary` checks it. Shared contracts live in -`piqueld-core`, which knows no server, database, Docker or browser framework; -the daemon's crates (`piqueld-config`, `piqueld-store`, `piqueld-docker`) -don't depend on the ones they build alongside. A new dependency between +`piqueld-core`, which knows no server, database, Docker or browser framework. +`piqueld-client` depends on no workspace crate but `piqueld-core` and +`piqueld-probe`, and on none of those frameworks, except the server framework +its tests use. The daemon's crates (`piqueld-config`, `piqueld-store`, +`piqueld-docker`) don't depend on the ones they build alongside. A new dependency between crates updates both that page and `tools/xtask/src/boundary.rs`. A feature reaches every surface it applies to, from the checklist in diff --git a/tools/xtask/src/boundary.rs b/tools/xtask/src/boundary.rs index faa322dec..5ecbfa0ef 100644 --- a/tools/xtask/src/boundary.rs +++ b/tools/xtask/src/boundary.rs @@ -1,7 +1,11 @@ //! `just boundary`: checks the workspace's dependency boundaries. //! `piqueld-core` holds the shared contracts, so it must not depend on the -//! server, Docker, database, or browser frameworks. The daemon's own crates -//! build in parallel only while they don't depend on each other. +//! server, Docker, database, or browser frameworks. `piqueld-client` builds +//! for wasm32 too, so it must not depend on any other workspace crate but +//! `piqueld-core` and `piqueld-probe`, nor on those frameworks, except for the +//! server framework its native tests use. +//! The daemon's own crates build in parallel only while they don't depend on +//! each other. use std::process::ExitCode; @@ -11,7 +15,7 @@ use crate::Workspace; use crate::process::checked_stdout; /// A package that must not depend on any of `forbidden`, through the -/// dependency kinds of `edges`. +/// dependency kinds of `edges`, on any target. struct Boundary { package: &'static str, /// `cargo tree --edges` kinds. @@ -21,7 +25,7 @@ struct Boundary { reason: &'static str, } -const BOUNDARIES: [Boundary; 4] = [ +const BOUNDARIES: [Boundary; 6] = [ Boundary { package: "piqueld-core", // The client and dashboard build it, so its build and development @@ -38,6 +42,37 @@ const BOUNDARIES: [Boundary; 4] = [ ], reason: "holds the shared contracts, without server, Docker, database, or browser frameworks", }, + Boundary { + package: "piqueld-client", + // It builds for wasm32 and is published, so its build and development + // dependencies count too; its server framework is checked below. + edges: "all", + forbidden: &[ + "bollard", + "bollard-stubs", + "leptos", + "sqlx", + "sqlx-core", + // Every workspace crate but `piqueld-core` and `piqueld-probe`. + "piquelctl", + "piqueld", + "piqueld-build", + "piqueld-config", + "piqueld-docker", + "piqueld-generated", + "piqueld-store", + "piqueld-ui", + "xtask", + ], + reason: "is the published client the CLI and dashboard share, without the other workspace crates or Docker, database, or browser frameworks", + }, + Boundary { + package: "piqueld-client", + // Its native tests serve their requests with axum. + edges: "normal,build", + forbidden: &["axum", "axum-core"], + reason: "is the published client, which builds for wasm32, so only its tests may use a server framework", + }, Boundary { package: "piqueld-config", edges: "normal,build", @@ -73,7 +108,14 @@ pub fn check(workspace: &Workspace) -> Result { let output = workspace .cargo() .args(["tree", "--locked", "--package", boundary.package]) - .args(["--edges", boundary.edges, "--prefix", "none"]) + .args([ + "--edges", + boundary.edges, + "--target", + "all", + "--prefix", + "none", + ]) .output() .context("run cargo tree")?; let tree = checked_stdout("cargo tree", output)?; @@ -86,7 +128,10 @@ pub fn check(workspace: &Workspace) -> Result { }) .collect(); if forbidden.is_empty() { - println!("{} dependency boundary is intact", boundary.package); + println!( + "{} dependency boundary is intact ({} dependencies)", + boundary.package, boundary.edges + ); } else { eprintln!( "{} {}, but depends on:\n{}",