Skip to main content

opensession_git_native/
lib.rs

1pub mod error;
2pub mod ops;
3pub mod shadow;
4pub mod store;
5pub mod url;
6
7#[cfg(test)]
8pub(crate) mod test_utils;
9
10pub use error::{GitStorageError, Result};
11pub use shadow::{
12    CheckpointInfo, FileRemoval, FileSnapshot, ShadowMeta, ShadowStorage, SHADOW_REF_PREFIX,
13};
14pub use store::NativeGitStorage;
15pub use url::generate_raw_url;
16
17use std::path::Path;
18
19/// Branch name used for storing session data.
20pub const SESSIONS_BRANCH: &str = "opensession/sessions";
21
22/// Ref path for the sessions branch.
23pub const SESSIONS_REF: &str = "refs/heads/opensession/sessions";
24
25/// Trait for git-based session storage backends.
26pub trait GitStorage: Send + Sync {
27    /// Store a session in the git repository at `repo_path`.
28    ///
29    /// Creates the orphan branch if it doesn't exist, then adds/updates blobs
30    /// for the HAIL JSONL and metadata JSON under `v1/<prefix>/<id>.*`.
31    ///
32    /// Returns the relative path within the branch (e.g. `v1/ab/abcdef.hail.jsonl`).
33    fn store(
34        &self,
35        repo_path: &Path,
36        session_id: &str,
37        hail_jsonl: &[u8],
38        meta_json: &[u8],
39    ) -> Result<String>;
40
41    /// Load a session's HAIL JSONL bytes from the git branch.
42    fn load(&self, repo_path: &Path, session_id: &str) -> Result<Option<Vec<u8>>>;
43
44    /// List all stored session IDs.
45    fn list(&self, repo_path: &Path) -> Result<Vec<String>>;
46}