Skip to main content

Crate pedant_core

Crate pedant_core 

Source
Expand description

Analysis engine for pedant: IR extraction, capability detection, and style checks.

pedant-core provides the core analysis pipeline without CLI dependencies. It presents two surfaces over one module tree, selected by feature.

The substrate is present in every configuration. It answers factual questions about source text: ir extracts facts, capabilities resolves them to capabilities, resolution models the Cargo project those files belong to, and hash and pattern support them. No substrate entry point accepts policy input.

The judgment surface sits behind the checks feature, which is on by default. It answers acceptability questions and owns every type whose shape is determined by an opinion: the check catalog, the gate rules engine, check configuration, violations, and the orchestrating lint entry points. A consumer that wants facts without opinions takes default-features = false.

semantic is a third, orthogonal axis. It combines with either surface, and enabling checks does not enable it.

§Quick start

use pedant_core::capabilities::detect_capabilities;
use pedant_core::ir::extract;
use pedant_types::Capability;

let syntax = syn::parse_file("use std::fs;").expect("source parses");
let ir = extract("example.rs", &syntax, None);
let profile = detect_capabilities(&ir, None);

assert_eq!(profile.findings[0].capability, Capability::FileRead);

Re-exports§

pub use analysis_result::AnalysisResult;
pub use check_config::CheckConfig as Config;
pub use check_config::ConfigFile;
pub use check_config::GateConfig;
pub use check_config::GateRuleOverride;
pub use check_config::NamingCheck;
pub use check_config::PatternCheck;
pub use check_config::PatternOverride;
pub use checks::ALL_CHECKS;
pub use checks::CheckInfo;
pub use gate::GateInputSummary;
pub use gate::GateRuleInfo;
pub use gate::GateSeverity;
pub use gate::GateVerdict;
pub use gate::all_gate_rules;
pub use gate::evaluate_gate_rules;
pub use lint::LintError;
pub use lint::analyze;
pub use lint::analyze_build_script;
pub use lint::analyze_build_script_with_shape;
pub use lint::analyze_with_build_script;
pub use lint::analyze_with_shape;
pub use lint::determine_analysis_tier;
pub use lint::discover_build_script;
pub use lint::discover_crate_root;
pub use lint::discover_workspace_root;
pub use lint::lint_file;
pub use lint::lint_str;
pub use violation::CheckRationale;
pub use violation::Violation;
pub use violation::ViolationType;
pub use violation::lookup_rationale;
pub use ir::semantic::FunctionAnalysisSummary;
pub use ir::semantic::SemanticContext;
pub use ir::semantic::SemanticFileAnalysis;

Modules§

analysis_result
Violations + capabilities produced by a single analysis run.
capabilities
Path-based capability detection over extracted IR facts.
check_config
.pedant.toml schema, loading, and per-path override resolution.
checks
Check catalog: metadata, rationale, and the ViolationType enum.
gate
Security gate rules that fire on suspicious capability combinations. Gate rules engine: evaluates capability profiles and data flows against security rules.
hash
SHA-256 hashing of source contents for attestation.
ir
Intermediate representation extracted from the AST in one pass.
json_format
JSON serialization for machine-readable violation output.
lint
High-level analysis entry points and error types.
pattern
Glob and wildcard matching for AST node text and file paths.
project
Whole-workspace structural checks over the file tree and Cargo metadata.
resolution
Language-scoped project and symbol-resolution models. Language-scoped resolution models over a repository’s declared structure.
style
Style checks that consume IR facts and produce violations.
violation
The Violation type, display formatting, and check rationale.

Structs§

ParseError
Alias for syn::Error, used by consumers that parse source themselves. Error returned when a Syn parser cannot parse the input tokens.