pub fn promote_export_gate(
state: &LedgerState,
events: &[LedgerEvent],
year: Option<i32>,
) -> Result<(), CliError>Expand description
BG-D8 (Task 14) — the export COMPLETENESS gate. REFUSES the export (writing ZERO bytes: called
FIRST in each export fn, before any mkdir_out/file write) when a promoted-basis DISPOSAL leg is filed
in the exported range but its Form 8275 disclosure is absent or INCOMPLETE (an empty/scaffold-only Part
II). Reg §1.6662-4(f) makes a disclosure adequate only on a COMPLETED Form 8275; a promoted leg filed
without one is inadequate disclosure — a HARD refusal, never a warning.
Mirrors the pseudo-active attestation slot (if state.pseudo_active() { require_attestation(...)? }):
a real refuse-before-bytes gate. It is deliberately NOT the always-written basis_methodology.txt
pattern (which unconditionally writes and can never refuse) — a refused export leaves out_dir
untouched.
year: Some(y) scopes the check to y (the per-year PDF packets). year: None — the non-year-scoped
CSV/snapshot export — means “ANY year with a promoted filed disposal leg in the exported range” (N-3),
so an all-years dump can never smuggle out an inadequately-disclosed promoted position either.
The refusing state is only reachable via a hand-crafted raw-vault write (an empty part_ii_narrative):
the T10 promote-tranche verb refuses an empty narrative at record time (BG-D7), so a CLI-recorded
promote is complete by construction — this gate is the type-level backstop for the corner it cannot.