Skip to main content

shardline_fsck/
lib.rs

1#![deny(unsafe_code)]
2#![cfg_attr(
3    test,
4    allow(
5        clippy::unwrap_used,
6        clippy::expect_used,
7        clippy::indexing_slicing,
8        clippy::shadow_unrelated,
9        clippy::let_underscore_must_use,
10        clippy::format_push_string
11    )
12)]
13
14//! Storage integrity checking logic for the Shardline server ecosystem.
15//!
16//! This crate provides pure fsck functions that operate on explicit
17//! store parameters rather than server configuration.
18//!
19//! # Quick start
20//!
21//! The issue and report types are pure data, so you can build and inspect them
22//! without touching any storage:
23//!
24//! ```
25//! use shardline_fsck::{
26//!     FsckIssue, FsckIssueDetail, FsckIssueKind, FsckReport,
27//! };
28//!
29//! let issue = FsckIssue {
30//!     kind: FsckIssueKind::MissingChunk,
31//!     location: "protocols/xet/global/chunks/abcd".to_owned(),
32//!     detail: FsckIssueDetail::HashMismatch {
33//!         expected_hash: "expected...".to_owned(),
34//!         observed_hash: "observed...".to_owned(),
35//!     },
36//! };
37//! assert_eq!(issue.kind.as_str(), "missing_chunk");
38//!
39//! let report = FsckReport {
40//!     latest_records: 10,
41//!     version_records: 10,
42//!     inspected_chunk_references: 20,
43//!     inspected_dedupe_shard_mappings: 0,
44//!     inspected_reconstructions: 0,
45//!     inspected_webhook_deliveries: 0,
46//!     inspected_provider_repository_states: 0,
47//!     issues: vec![issue],
48//! };
49//! assert!(!report.is_clean());
50//! assert_eq!(report.issue_count(), 1);
51//! ```
52//!
53//! To run a real check, use [`run_fsck_with_stores`] with explicit record,
54//! index, and object-store adapters, or [`run_local_fsck`] for the
55//! local-filesystem layout.
56
57mod compat;
58mod error;
59mod native_members;
60mod report;
61mod runner;
62#[cfg(test)]
63mod tests;
64mod types;
65
66// Internal submodules kept for their original structure.
67mod lifecycle_checks;
68mod record_checks;
69
70// ── Public API re-exports ────────────────────────────────────────────
71
72pub use compat::{
73    LocalFsckIssue, LocalFsckIssueKind, LocalFsckReport, WEBHOOK_DELIVERY_FUTURE_SKEW_SECONDS,
74};
75pub use error::FsckError;
76pub use report::FsckReport;
77pub use runner::{run_fsck_with_stores, run_local_fsck};
78pub use types::{
79    FsckIssue, FsckIssueDetail, FsckIssueKind, FsckReconstructionPlanDetail,
80    ProviderRepositoryStateTimestampField,
81};
82
83// ── Crate-internal re-exports (for sibling modules & tests) ──────────
84
85pub(crate) use runner::{
86    object_location_display, push_issue, push_reconstruction_plan_issue, record_path,
87    unix_now_seconds_checked,
88};
89
90#[cfg(test)]
91pub(crate) use runner::{object_key_storage_path, reconstruction_plan_error_detail};
92pub(crate) use types::{
93    FsckObjectContext, FsckReachability, PendingVersionRecordCheck, RecordKind,
94};