1pub mod algo;
2mod db;
3pub mod history;
4mod ingest;
5pub mod mask;
6pub mod reader;
7pub mod roles;
8pub mod schema;
9mod shared;
10pub mod subscription;
11
12pub use algo::{
13 AlgoDir, DegreeConfig, DegreeReport, PageRankConfig, PageRankReport, WccConfig, WccReport,
14};
15pub use core_query::{CmpOp, Dir, Filter, ResultSet};
16pub use core_rules::suggest::DEFAULT_SEED as SUGGEST_DEFAULT_SEED;
17pub use core_rules::{
18 default_max_edges, is_keymatch_rooted, AggFn, Predicate, RuleDef, RuleSuggestion,
19 SuggestConfig, SuggestReport, ViewDef, ViewSource, ViewStore, DEFAULT_KEYMATCH_TOP_K,
20 DEFAULT_SCORED_TOP_K,
21};
22pub use core_storage::{Direction, GraphError, Result, Value};
23pub use db::{
24 snapshot_version_at, write_snapshot_bak, BackupReport, BatchBuilder, BatchOp, DeleteReport,
25 EdgeInfo, Explanation, ExportEdge, FsyncPolicy, GraphDb, MaskedEdge, MaskedNodeResult,
26 MutationEvent, NodeInfo, NodeRef, OpenOptions, Precondition, PredicateSummary, RuleStats,
27 SnapshotOptions, Stats, WriteAuthz,
28};
29
30pub const SNAPSHOT_VERSION: u16 = core_storage::snapshot::VERSION;
35pub use history::{EdgeEvent, EdgeHistoryEvent, HistoryChange, HistoryEntry, HistoryResult};
36pub use ingest::{
37 json_to_rows, json_to_value, AutoFk, FkSkip, IngestOptions, IngestReport, JsonRows,
38};
39pub use mask::{MaskMode, NodeMask};
40pub use reader::{CommitDelta, FrozenOverlay, ReaderSnapshot, FOLD_EVERY_K};
41pub use roles::{RoleDef, WriteScope};
42pub use schema::{Schema, SchemaDiff};
43pub use shared::SharedDb;
44pub use subscription::{DbEvent, Subscription, DEFAULT_SUB_CAPACITY};
45
46pub type SectionVerifyResult = (u8, &'static str, usize, std::result::Result<(), String>);
50
51pub fn verify_snapshot(dir: &std::path::Path) -> crate::Result<Vec<SectionVerifyResult>> {
60 let snap_path = dir.join("snapshot.bin");
61 let mapped = core_storage::v8::MappedBase::map(&snap_path)?;
62 mapped.validate_section_bounds()?;
68 let results = mapped.verify_integrity();
69 mapped.validate_hot_sections()?;
70 Ok(results)
71}
72
73pub fn is_write_query(cypher: &str) -> std::result::Result<bool, String> {
78 let toks = core_query::cypher::lex(cypher).map_err(|e| format!("lex: {e}"))?;
79 Ok(core_query::cypher::is_write_tokens(&toks))
80}
81
82pub fn wal_commit_count_at(dir: &std::path::Path) -> crate::Result<u64> {
88 let wal_path = dir.join("wal.bin");
89 let bytes = match std::fs::read(&wal_path) {
90 Ok(b) => b,
91 Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
92 Err(e) => return Err(core_storage::GraphError::Io(e)),
93 };
94 Ok(core_storage::wal::wal_commits(&bytes))
95}