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.
go-resolution is a fourth, and it is default-off. It adds
resolution::go — the Go module project, its bounded package snapshots, and
the resolver over them — and it selects exactly one thing besides: the Go
grammar in pedant-syntax. It turns on neither checks nor semantic, so a
build without it links no Go grammar through this crate and a build with it
pays for no judgment surface it did not ask for.
§Quick start
use pedant_core::capabilities::detect_capabilities;
use pedant_core::ir::extract;
use pedant_types::{Capability, CapabilitySymbolKind, SymbolAttributionStatus};
let source = "fn load() {\n use std::fs;\n}\n";
let syntax = syn::parse_file(source).expect("source parses");
let ir = extract("example.rs", &syntax, None);
let analysis = detect_capabilities(&ir, None);
// The flat profile stays the persisted and policy authority.
assert_eq!(analysis.profile.findings[0].capability, Capability::FileRead);
// The symbol projection names the callable that contains the evidence.
assert_eq!(analysis.symbol_attribution, SymbolAttributionStatus::Complete);
assert_eq!(&*analysis.symbols[0].symbol.name, "load");
assert_eq!(analysis.symbols[0].symbol.kind, CapabilitySymbolKind::Function);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::ModuleBoundaryConfig;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::GateAnchor;pub use gate::GateEvidence;pub use gate::GateInputSummary;pub use gate::GateLocation;pub use gate::GateRuleInfo;pub use gate::GateSeverity;pub use gate::GateVerdict;pub use gate::ModuleBoundaryEntity;pub use gate::ModuleBoundaryEvidence;pub use gate::ModuleBoundaryFact;pub use gate::ModuleBoundaryInput;pub use gate::ModuleBoundaryInputError;pub use gate::ModuleBoundaryMeasurement;pub use gate::all_gate_rules;pub use gate::all_module_boundary_rules;pub use gate::evaluate_gate_rules;pub use gate::evaluate_module_boundary_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.tomlschema, loading, and per-path override resolution.- checks
- Check catalog: metadata, rationale, and the
ViolationTypeenum. - gate
- Gate rules over capability combinations, data flows, and module boundaries. Gate rules engine: judges capability profiles, data flows, and declared module boundaries against local policy.
- 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
Violationtype, display formatting, and check rationale.
Structs§
- Parse
Error - Alias for
syn::Error, used by consumers that parse source themselves. Error returned when a Syn parser cannot parse the input tokens.