repo_trust/lib.rs
1//! Repo Trust — a CLI tool that produces a multi-dimensional Trust Report
2//! for any public GitHub repository.
3//!
4//! See [the README](https://github.com/Dmitrze/repo-trust) for an overview.
5//!
6//! # Crate organisation
7//!
8//! - [`cli`] — command-line interface and argument parsing
9//! - [`api`] — HTTP clients for GitHub, deps.dev, Scorecard, OSV
10//! - [`collectors`] — module-specific data collection from APIs
11//! - [`features`] — normalisation of raw data into per-module feature structs
12//! - [`modules`] — the five trust modules (stars, activity, maintainers, adoption, security)
13//! - [`scoring`] — pure scoring functions; aggregates module results
14//! - [`models`] — shared data types (reports, evidence, scores)
15//! - [`reports`] — output writers (terminal, JSON, Markdown, CSV)
16//! - [`storage`] — SQLite-backed cache and connection pool
17//! - [`config`] — layered configuration loader
18//! - [`utils`] — cross-cutting helpers (sampling, time, ratelimit, tracing)
19//!
20//! # Determinism
21//!
22//! See ADR-0007. Same inputs + same upstream API state ⇒ byte-identical JSON.
23//! All sampling uses [`rand_chacha::ChaCha20Rng`] seeded from
24//! `(repo, scoring_version)` via blake3.
25
26#![deny(unsafe_code)]
27#![warn(missing_debug_implementations)]
28#![warn(rust_2018_idioms)]
29//
30// Pedantic-clippy lint posture for v0.1.0 (Day 5 polish per
31// `docs/day-5-polish.md` §1):
32//
33// We enable `clippy::pedantic` at the warn level (CI gate) but
34// crate-level allow specific lints whose firings are domain-justified
35// patterns rather than real defects:
36// - `cast_possible_truncation` / `cast_sign_loss` / `cast_precision_loss`
37// fire on the score arithmetic where the input is already
38// `.clamp(0.0, 100.0)`-bounded (so `as u8` is safe), on `i64→u64`
39// after `.max(0)`, and on `usize→f64` for vec lengths bounded by
40// the rate-limit budget. Local rationale comments at use sites
41// document each.
42// - `cast_possible_wrap` fires on `usize→i64` for date arithmetic
43// where the series length is bounded by the sample window.
44// - `must_use_candidate` is a stylistic preference; we mark
45// fallible-by-design return values explicitly elsewhere.
46// - `missing_errors_doc` / `missing_panics_doc`: we document errors
47// and panics in the function body comment rather than via separate
48// rustdoc sections; pedantic's heuristic is over-broad.
49// - `module_name_repetitions`: our module-name → type-name pattern
50// (e.g. `scoring::activity::ActivityThresholds`) is intentional.
51// - `result_large_err`: `figment::Error` is large but we don't
52// control its layout; boxing it crate-wide has no benefit.
53// - `struct_excessive_bools`: clap-derived CLI args structs naturally
54// accumulate boolean flags.
55// - `similar_names`: deps.dev DTO field names mirror the upstream
56// wire format and are intentionally close.
57#![warn(clippy::pedantic)]
58#![allow(
59 clippy::cast_possible_truncation,
60 clippy::cast_sign_loss,
61 clippy::cast_precision_loss,
62 clippy::cast_possible_wrap,
63 clippy::must_use_candidate,
64 clippy::missing_errors_doc,
65 clippy::missing_panics_doc,
66 clippy::module_name_repetitions,
67 clippy::result_large_err,
68 clippy::struct_excessive_bools,
69 clippy::similar_names,
70 clippy::doc_markdown,
71 clippy::too_many_lines,
72 clippy::float_cmp,
73 clippy::unused_async,
74 clippy::unreadable_literal,
75 clippy::needless_pass_by_value,
76 clippy::ref_option,
77 clippy::match_same_arms,
78 clippy::items_after_statements,
79 clippy::manual_let_else,
80 clippy::uninlined_format_args,
81 clippy::unnecessary_debug_formatting
82)]
83
84pub mod api;
85pub mod cli;
86pub mod collectors;
87pub mod config;
88pub mod features;
89pub mod models;
90pub mod modules;
91pub mod reports;
92pub mod scoring;
93pub mod storage;
94pub mod utils;
95
96#[cfg(feature = "web")]
97pub mod web;
98
99/// Library version string — useful for `--version` output.
100pub const VERSION: &str = env!("CARGO_PKG_VERSION");
101
102/// SemVer of the scoring model. Bumped independently of the CLI version.
103///
104/// See `docs/scoring-model.md` for the change log.
105pub const SCORING_VERSION: &str = "1.1.1";
106
107/// JSON report schema version. Bumped on any breaking schema change.
108pub const REPORT_SCHEMA_VERSION: &str = "1.0.0";