Skip to main content

Crate codelore_lib

Crate codelore_lib 

Expand description

codelore-lib — Behavioral Code Analyzer library.

See docs/superpowers/specs/2026-06-06-codelore-design.md.

Re-exports§

pub use analysis::AnalysisName;
pub use analysis::UnknownAnalysisError;
pub use error::CodeLoreError;
pub use error::Result;
pub use facts::FactsDb;
pub use options::Options;
pub use repo::Repo;
pub use repo::TagInfo;
pub use types::ChangeType;
pub use types::CommitEvent;
pub use types::FileChange;
pub use types::Hunk;
pub use types::KameiFeatures;

Modules§

analyses
Analysis implementations. Each is a SQL view over the fact store plus a thin Rust orchestrator.
analysis
The closed set of analyses codelore supports. Enum, not string, so the compiler catches typos that code-maat’s string dispatch silently misroutes.
arch_rules
Layered-architecture rule validation.
arrow_facade
Single source of truth for Arrow types throughout the workspace.
bands
Shared health and risk band constants used across analyses and the SPA.
cache
Persistent fact-store cache: key derivation + XDG path resolution.
calibration
Corpus-calibration artifact: per-language quantile breakpoints for raw per-function metrics, plus the interpolation lookup that turns a metric value into a corpus-relative percentile (“your cyclomatic complexity sits at P74 versus the reference corpus”).
change_context
Temporal pre-write briefing: what an agent should know about a set of files before it edits them.
change_set
Delta-scoped change-set engine: what a set of working-tree edits does to the repository’s health before they are committed.
cli_api
The single API surface codelore-cli imports through. Internal modules stay pub because the integration-test crate needs deep white-box access, but the CLI binary reaches the library only via these re-exports — so the CLI↔library contract is enumerated in exactly one place.
clones
Clone detection.
complexity
Per-language complexity metric computation via vendored codelore-rca.
constants
Single source of truth for Options default values + clap default_value_t annotations. Without this module the same number had to be edited in two places, and drift went unnoticed at compile time — a hand-cross-reference of every default was the only catch.
defect_calibration
Own-repo defect calibration: the fix-commit oracle, the AG-SZZ linkage engine, and the defects.calib.json artifact model.
enrichment
Advisory enrichment layer — deterministic fact sheets and (in later units) grounded LLM narratives assembled on top of the existing analyses.
error
Public error type. Drives CLI exit codes at the lib/cli boundary.
external
External-findings integration — parse, store, and fuse external SARIF scanner output with CodeLore’s behavioral signal.
facts
DuckDB-backed fact store. See spec §3.2 + §3.2.1 invariants.
hashing
Stable content-fingerprint primitive shared across the fingerprint-emitting modules (SARIF row identity in output::sarif, external-finding self-hash in external::sarif_parse).
identity
Identity resolution: mailmap (in repo/), bots.toml default-deny list, team-map projection, AI attribution stub.
imports
Architecture import-graph extraction.
kamei
Kamei 14-feature JIT-SDP canonical change vector enrichment.
options
Run-time configuration for the codelore pipeline. Defaults match code-maat for parity; see spec §1.1.
output
Output emitters: CSV, SARIF, JSON, Markdown, Parquet, SQLite. The banner module renders the stderr pre-flight banner shown at the start of every analyze run.
paths
Path-string utilities. Centralised here so the two HEAD-time walks (facts::ingest::populate_clones_at_head and analyses::clones’s relative-path helper) use the same forward-slash normalisation rule — before this lived in two places, and a Windows-specific bug in clone_coupling‘s same_parent_dir filter (rfind(’/’)) could resurface if one site forgot to normalise.
paths_filter
Combined exclusion filter for HEAD-time path walks.
provenance
Provenance manifest — documents every choice that affected an analysis run. Per spec §3.2 provenance table + §5 differentiator.
quality_gates
Quality-gates: parse .codelore-thresholds.toml at the repo root and evaluate a fact store against the declared gates. Used by codelore check to power CI quality-gate enforcement.
repo
VCS-reading abstraction. The default impl is gix; a GitCliRepo differential-test oracle cross-checks it.
stats
Statistical helpers used by the analyses.
types
Public types for the codelore-lib API. These are the contract every pipeline stage agrees on. See spec §3.1.