btctax_cli/cmd/inspect.rs
1//! `verify` (FR9) + `report`/`show` (FR4) โ read-only inspection of the pure projection. `verify`
2//! arrives in Task 6; this file starts with `report`.
3use crate::render::{build_verify, VerifyReport};
4use crate::{CliError, Session};
5use btctax_core::LedgerState;
6use btctax_store::Passphrase;
7use std::path::Path;
8
9/// FR4: project the ledger for display. `year` filters realized sections in the renderer; holdings are
10/// always the current per-lot position.
11pub fn report(
12 vault_path: &Path,
13 pp: &Passphrase,
14 _year: Option<i32>,
15) -> Result<LedgerState, CliError> {
16 let session = Session::open(vault_path, pp)?;
17 let (state, _cfg) = session.project()?;
18 Ok(state)
19}
20
21/// FR9: project the ledger โ compute the sat-conservation report, partition blockers by severity, and
22/// summarize pending reconciliation + safe-harbor status. The binary maps `has_hard_blockers()` to a
23/// non-zero exit (a hard blocker gates downstream tax computation, ยง7.1).
24///
25/// Uses `Session::load_events_and_project` to load the event log exactly once (avoiding the
26/// double `load_all` that the old `project()` + separate `load_all(conn)` pattern incurred).
27/// Task 8: also reads the CLI config (declared `pre2025_method` + attestation flag) and passes
28/// it to `build_verify` so that `render_verify` can surface them.
29pub fn verify(vault_path: &Path, pp: &Passphrase) -> Result<VerifyReport, CliError> {
30 let session = Session::open(vault_path, pp)?;
31 let (events, state, _cfg) = session.load_events_and_project()?;
32 let cli = session.config()?;
33 Ok(build_verify(&state, &events, &cli))
34}