Skip to main content

ai_memory/cli/
export.rs

1// Copyright 2026 AlphaOne LLC
2// SPDX-License-Identifier: Apache-2.0
3
4//! v0.7.0 L2-5 (issue #670) — `ai-memory export-forensic-bundle` and
5//! `ai-memory verify-forensic-bundle` CLI surface.
6//!
7//! Thin dispatch wrappers over [`crate::forensic::bundle`]. The heavy
8//! lifting (substrate reads, tar assembly, signature creation /
9//! verification) lives in the substrate module so it can be exercised
10//! from unit tests without spawning a subprocess. This module exists
11//! solely to keep the `Command` enum tidy and to make the two verbs
12//! discoverable under `src/cli/`.
13
14use std::path::Path;
15
16use anyhow::Result;
17
18use crate::cli::CliOutput;
19use crate::forensic::bundle::{
20    ExportForensicBundleArgs, VerifyForensicBundleArgs, run_export, run_verify,
21};
22
23/// Dispatch `ai-memory export-forensic-bundle`. See
24/// [`run_export`](crate::forensic::bundle::run_export).
25///
26/// # Errors
27///
28/// Propagates DB / I/O / signing errors from the substrate.
29pub fn export(
30    db_path: &Path,
31    args: &ExportForensicBundleArgs,
32    out: &mut CliOutput<'_>,
33) -> Result<i32> {
34    run_export(db_path, args, out)
35}
36
37/// Dispatch `ai-memory verify-forensic-bundle`. See
38/// [`run_verify`](crate::forensic::bundle::run_verify).
39///
40/// # Errors
41///
42/// Propagates I/O / parse errors. Verification failure returns
43/// `Ok(non-zero)` rather than an `Err`.
44pub fn verify(args: &VerifyForensicBundleArgs, out: &mut CliOutput<'_>) -> Result<i32> {
45    run_verify(args, out)
46}