guibiao 0.9.0

圭表 (Guibiao) — Tianheng's dependency-light static observation core (derived from modou). Declare crate, module, and dependency-source boundaries in Rust — dependencies by name, module imports, and each dependency's declared source kind (git/registry/path) for manifest hygiene — observed from cargo metadata and source use-scans, reacted in CI. No AST: the syn-free gnomon of the family.
Documentation
use serde_json::Value;

use crate::cargo_metadata::find_package;
use crate::errors::crate_not_found_error;
use crate::{BoundaryKind, CrateBoundary, Violation, ViolationId};

/// Check a single crate boundary against workspace metadata.
///
/// Violations carry no `file`: a crate-dependency violation is an edge in the dependency
/// graph rather than a single source line, so `file` remains `None`.
pub(crate) fn check_crate_boundary(
    metadata: &Value,
    workspace: &[String],
    boundary: &CrateBoundary,
    violations: &mut Vec<Violation>,
) -> Result<(), String> {
    let package = find_package(metadata, &boundary.target.package)
        .ok_or_else(|| crate_not_found_error(&boundary.target.package))?;

    for fact in boundary.rule.facts(package, workspace, boundary.kind) {
        let finding = fact.into_finding();
        violations.push(
            Violation::new(
                BoundaryKind::Crate,
                ViolationId::new(
                    boundary.target.package.clone(),
                    boundary.rule.key(),
                    finding.fact().clone(),
                ),
                boundary.rule.label(),
                finding.text(),
                boundary.reason.clone(),
                boundary.severity,
            )
            .with_anchor(boundary.anchor.clone())
            .with_polarity(boundary.rule.polarity()),
        );
    }
    Ok(())
}