Skip to main content

code_ranker_graph/
lib.rs

1//! Operations over the generic property-graph model defined in
2//! `code-ranker-plugin-api`: cycle detection, Henry-Kafura coupling, aggregate
3//! stats, id relativization, and the serializable [`Snapshot`] artifact.
4//!
5//! Everything here is language-agnostic. Plugins emit a pure
6//! [`api::Graph`](code_ranker_plugin_api::graph::Graph) (structure only); this crate
7//! and the orchestrator enrich it (writing computed values into node `attrs`
8//! by id) and assemble the snapshot. Which edge kinds count as information
9//! flow is read from the level's `edge_kinds` (`EdgeKindSpec.flow`), passed in
10//! as a `flow_kinds` set — there is no hardcoded `uses`/`contains` knowledge.
11
12pub mod attrs;
13pub mod builtin;
14pub mod checks;
15pub mod cycles;
16pub mod finalize;
17pub mod hk;
18pub mod level_graph;
19pub(crate) mod nodepath;
20pub mod registry;
21pub mod relativize;
22pub mod serialize;
23pub mod snapshot;
24pub mod stats;
25
26pub use attrs::{num_attr, round_sig3};
27pub use cycles::annotate_cycles;
28pub use finalize::finalize_graph;
29pub use hk::annotate_coupling;
30pub use level_graph::{CycleGroup, LevelGraph, LevelUi};
31// The metric catalog reads the `builtin.toml` schema (module [`builtin`]). The
32// tier-1 input types (`MetricInputs` / `FunctionUnit`) are the plugin↔orchestrator
33// contract and live in `code-ranker-plugin-api` (its `metrics` module); a plugin
34// hands them back and `builtin::write_metrics` enriches the node from them.
35pub use builtin::{
36    Views, coupling_specs, cycle_specs, metric_specs, prompt_template, prompt_template_from,
37    stat_keys, views, write_derived, write_metrics,
38};
39pub use checks::{CheckCompileError, CheckDef, CheckHit, CompiledCheck, GraphView};
40pub use registry::{Engine, MetricDef, Populations, RegistryError, Scope, apply_to_node};
41pub use relativize::{relativize_graph, relativize_level};
42pub use serialize::{to_canonical_string, to_canonical_string_pretty};
43pub use snapshot::{GitInfo, Snapshot, StageTime};
44pub use stats::compute_stats;
45
46// The coupling/cycle attribute specs (`fan_in` / `fan_out` / `fan_out_external` /
47// `hk` / `cycle`) now live in the data-driven `builtin.toml` `[coupling.*]`
48// catalog and are exposed via [`builtin::coupling_specs`] (re-exported above).