Skip to main content

Crate architecture_tests

Crate architecture_tests 

Source
Expand description

Architecture tests for the Saluki workspace.

Unit tests in this crate report violations to intended architectural invariants.

§Dependency guards

Dependency guards reject unwanted direct or transitive dependencies between crates. graph::Workspace loads the package graph from Cargo metadata, including optional, feature-gated, and target-specific dependencies. Links join package IDs, so dependency renames don’t hide them. Each guard chooses which dependency kinds to follow through graph::Links. Violations report the dependency route.

§Symbol guards

Symbol guards restrict which names code may mention, enforcing boundaries within a crate that dependency guards can’t express. symbols::SourceTree parses every .rs file under selected directories, including test code. It matches names in paths, imports, and macro or attribute tokens, but ignores comments, doc text, and strings. Guards can also collect aliases with symbols::SourceTree::aliases. Matches report the source location; unreadable, invalid, or missing sources fail the scan.

Module guards restrict which modules of a crate code may name. symbols::SourceTree::module_mentions matches only paths that start at crate, self or super, so a variable that shares a module’s name doesn’t match.

§Limits

Symbol guards don’t resolve names. Unrelated items sharing a guarded identifier cause false positives. The guards can miss:

  • types inferred without a guarded identifier at the use site
  • aliases from private glob imports below crate-root scope or private bindings in other non-root files
  • aliases defined inside blocks or macro invocations
  • modules placed outside the scanned directories by #[path]

Check for these gaps during review.

Modules§

graph
Workspace package graph and dependency queries.
symbols
Syntax-level scan of Rust sources for names.