Skip to main content

lanekeep_core/
lib.rs

1//! Core types and execution engine for lanekeep.
2//!
3//! File walking, query evaluation, the facts pipeline, violations, and the `Rule` trait.
4//!
5//! This crate owns the contract every other crate is written against. `Rule` is treated as
6//! public API that happens not to be published: no built-in rule may reach past it into
7//! walker internals or cache state, because that boundary is what keeps future rule sources
8//! additive. See `docs/architecture.md` §14.
9//!
10//! # What is here so far
11//!
12//! Rule identity, severity, source locations, rule cards, violations with their canonical
13//! ordering, and the facts a per-file pass hands to the reduce phase.
14//!
15//! These types are foundational in a specific sense: they are what appears in JSON output,
16//! in cache entries, and in suppression comments users type by hand. Getting them wrong is
17//! expensive in a way that getting the walker wrong is not, because only these are visible
18//! from outside.
19//!
20//! Tracked, confined file reads (`FileAccess`) live here too, alongside `tracked` rather
21//! than inside whichever engine happened to need them first — every engine that runs a rule
22//! needs the identical confinement and tracking rules, and a copy per engine is exactly the
23//! kind of drift lanekeep's own self-check rules exist to catch elsewhere.
24//!
25//! So do the execution budgets (`Limits`, `RunClock`) and their enforcement (`Budget`,
26//! `Trip`), for a related but sharper reason: there is exactly one global run budget, not
27//! one per engine, so two independent `RunClock`s would each be correct in isolation while
28//! the run as a whole overran both. See [`limits`] for why that failure needs no maintenance
29//! drift to happen — unlike the per-engine-instance types above, it is wrong the moment a
30//! second copy exists at all.
31
32pub mod card;
33pub mod changed;
34pub mod discovery;
35pub mod fact;
36pub mod files;
37pub mod fix;
38pub mod gates;
39pub mod limits;
40pub mod location;
41pub mod query_cover;
42pub mod rule_id;
43pub mod severity;
44pub mod suppression;
45pub mod tracked;
46pub mod violation;
47
48pub use card::{CardProblem, Examples, RuleCard};
49pub use changed::ChangeError;
50pub use discovery::{Discovery, DiscoveryError};
51pub use fact::Fact;
52pub use files::{FileAccess, ReadError};
53pub use fix::Fix;
54pub use gates::{CompiledGates, GateError, Gates};
55pub use limits::{
56    DEFAULT_GLOBAL_TIMEOUT, DEFAULT_MEMORY_BYTES, DEFAULT_RULE_TIMEOUT, Limits, RunClock,
57};
58pub use location::{FilePath, Location, Position};
59pub use rule_id::{Namespace, ParseRuleIdError, RuleId};
60pub use severity::{ParseSeverityError, Severity};
61pub use suppression::{Suppression, Suppressions};
62pub use tracked::{ContentHash, TrackedRead};
63pub use violation::{Violation, any_failing, sort};