Skip to main content

apply_export

Function apply_export 

Source
pub fn apply_export(
    session: &Session,
    plan: ExportPlan,
) -> Result<ExportOutcomes, CliError>
Expand description

Apply a planned export: write ONE IRS-PDF packet per plan.years, each into its own out_dir/<year> subdirectory, via the ALREADY-SHIPPED export_irs_pdf_from_session (★ arch-C-1, cmd::admin) — the SAME return_inputs::exists full-vs-slice dispatch the CLI’s export_irs_pdf runs, exercised ONCE per year, INSIDE that fn (never duplicated here — ★ m-new-1). Reloads events/state fresh from session (arch-m-new-3 pattern) — a single synchronous CLI/TUI invocation cannot append anything between plan_export and apply_export, so this is behavior-preserving. attest: None throughout: plan_export already refused a pseudo-active state, so the watermark/attestation branch inside _from_session is unreachable here. NO Session::open anywhere — session is already open and held by the caller (the CLI’s thin driver, or a future TUI); a second open under a held VaultLock deadlocks (session.rs:662).

★ T3-M2 (Task 10) — PER-YEAR ISOLATION: a failure writing ONE year’s packet (e.g. a year whose Form 8275 Part I overflows this revision’s 6 rows, or an I/O fault under out_dir) does NOT abort the batch. Every year in plan.years is attempted, in ascending order (plan.years is a BTreeSet), and its outcome is reported INDIVIDUALLY as (year, Result<IrsPdfReport, CliError>). Years already written to disk before a LATER year’s failure stay correct — nothing already written is rolled back (each year’s packet is an independent, self-contained write; export performs no in-memory mutation to revert). No unattested/pseudo packet can ever escape a per-year failure: plan_export already refused a pseudo-active ledger up front, and attest: None is passed on every call regardless of outcome. The outer Result covers only the ONE failure mode common to every year — re-loading events/state from session — which, if it fails, means NOTHING could even be attempted.

plan.unsupported_years is NOT attempted here (★ whole-branch tax M-2 — plan_export already held those out): they carry no bundled IRS form templates, so an attempt could only ever fail, and the caller renders them as a “no bundled templates yet” note beside these outcomes.