Skip to main content

btctax_cli/
cli.rs

1//! The clap-4 command surface for `btctax`, extracted into the library so tooling
2//! (the `xtask` man-page generator) can obtain the `Command` via `Cli::command()`
3//! (`clap::CommandFactory`). The binary (`main.rs`) is a thin dispatch over these types.
4//!
5//! FILE-FORMAT DOCS — SINGLE SOURCE OF TRUTH: the long-help (`///` doc-comments with
6//! `#[arg(verbatim_doc_comment)]`) on the file/format-taking args below is rendered BOTH
7//! into `--help` (clap) AND into the per-subcommand man page (clap_mangen), zero drift.
8//! Formats were read from the writers, never from stale comments: export CSVs from
9//! `render.rs`, the classify-raw serde shape from `btctax-core::EventPayload`, the key
10//! armor from `btctax-store::Vault::backup_key`, the selections header from
11//! `cmd::reconcile::import_selections`, the lot pick from `eventref::parse_lot_pick`.
12use btctax_core::{FilingStatus, LotMethod};
13use clap::{Parser, Subcommand, ValueEnum};
14use std::path::PathBuf;
15
16#[derive(Parser)]
17#[command(name = "btctax", about = "Offline US Bitcoin tax ledger (Phase 1)")]
18pub struct Cli {
19    /// Path to the encrypted vault (vault.pgp).
20    #[arg(long, global = true, default_value = "vault.pgp")]
21    pub vault: PathBuf,
22    #[command(subcommand)]
23    pub command: Command,
24}
25
26#[derive(Subcommand)]
27pub enum Command {
28    /// Create the encrypted vault + force a key backup.
29    Init {
30        /// File to write the forced key backup to: an ASCII-armored, passphrase(S2K)-encrypted
31        /// private key, owner-only (mode 0600). Identical format to `backup-key --out`. Store it
32        /// offline — it is the only way to recover the vault if you lose `vault.key`.
33        ///
34        /// FORMAT (structure — NOT a real key):
35        ///   -----BEGIN PGP PRIVATE KEY BLOCK-----
36        ///   ... base64 armor of the S2K-encrypted secret key ...
37        ///   -----END PGP PRIVATE KEY BLOCK-----
38        #[arg(long, verbatim_doc_comment)]
39        key_backup: PathBuf,
40        /// Clear an interrupted/half-created init (orphan `vault.key`, no encrypted store) and start fresh.
41        #[arg(long, default_value_t = false)]
42        repair: bool,
43    },
44    /// Import one or more export files (auto-groups Swan).
45    Import { files: Vec<PathBuf> },
46    /// FR9 integrity check (non-zero exit on hard blockers).
47    Verify,
48    /// Show holdings + realized disposals/removals/income. With --tax-year: standalone TaxResult.
49    #[command(alias = "show")]
50    Report {
51        /// Filter realized disposals/removals/income to a specific calendar year (display path).
52        #[arg(long)]
53        year: Option<i32>,
54        /// Compute the crypto-attributable federal tax for the given tax year (B.5 / Task 9).
55        /// Requires a stored tax profile (`tax-profile --year Y ...`) and the bundled TY table.
56        /// Independent of --year; the two flags are not aliased.
57        #[arg(long)]
58        tax_year: Option<i32>,
59        /// Cumulative prior-year TAXABLE gifts (post-annual-exclusion Form 709 amounts), not
60        /// gross gifts. Used for the §2505 lifetime-exclusion consumption advisory. Defaults to
61        /// $0 when omitted (the advisory discloses this assumption). Must not be negative.
62        #[arg(long)]
63        prior_taxable_gifts: Option<String>,
64    },
65    /// Emit a reconciliation decision event.
66    #[command(subcommand)]
67    Reconcile(Reconcile),
68    /// Show or set projection config (TP8 fee treatment / pre-2025 lot method / forward method).
69    Config {
70        #[arg(long, value_enum)]
71        set_fee_treatment: Option<FeeArg>,
72        #[arg(long, value_enum)]
73        set_pre2025_method: Option<MethodLotArg>,
74        #[arg(long, default_value_t = false)]
75        attest_pre2025_method: bool,
76        /// §A.5(a): append a MethodElection decision (the forward standing order). Not a flag
77        /// mutation — this is an event in the ledger. Use --effective-from to set the date
78        /// (default: today / the decision's made-date).
79        #[arg(long, value_enum)]
80        set_forward_method: Option<MethodLotArg>,
81        /// §A.5(a) per-ACCOUNT scope for --set-forward-method (IRS 2025+ per-account rule):
82        /// exchange:PROVIDER:ACCOUNT (the canonical wallet grammar). Omit for a GLOBAL election
83        /// (the existing behavior). Only exchange accounts are electable (a method election is a
84        /// brokerage-account concept; self:LABEL is rejected). The account MUST already exist in the
85        /// vault — an unknown/typo'd account is rejected LOUDLY so it can't create a dead election.
86        #[arg(long)]
87        exchange: Option<String>,
88        /// Effective-from date for --set-forward-method (YYYY-MM-DD). Defaults to made-date.
89        #[arg(long)]
90        effective_from: Option<String>,
91    },
92    /// FR10: export decrypted SQLite + CSV (the NFR2 plaintext exception).
93    ///
94    /// WARNS (does not refuse) on unresolved Hard blockers: any Hard blocker makes every affected
95    /// tax year NOT COMPUTABLE, so the exported Form 8949 / Schedule D / figures are INFORMATIONAL,
96    /// not final. A warning is printed to stderr and the export still succeeds (exit 0). Automation
97    /// that must GATE on unresolved blockers should check `btctax verify` (which exits non-zero),
98    /// since export-snapshot itself stays exit 0.
99    ExportSnapshot {
100        /// Output DIRECTORY receiving the decrypted SQLite DB (snapshot.sqlite) + projection CSVs
101        /// (the NFR2 plaintext exception; created owner-only). ALWAYS writes: lots.csv,
102        /// disposals.csv, removals.csv, income.csv. With --tax-year it ALSO writes form8949.csv,
103        /// schedule_d.csv, form8283.csv, and schedule_se.csv (schedule_se only when there is
104        /// business self-employment income). The `event` column in disposals.csv / removals.csv /
105        /// income.csv is the event-ref that reconcile commands consume (select-lots,
106        /// set-donation-details, reclassify-income, …).
107        ///
108        /// FORMAT (removals.csv header + one sample donation row):
109        ///   event,kind,removed_at,lot,sat,basis,fmv_at_transfer,term,acquired_at,claimed_deduction,donee
110        ///   import|coinbase|X,donation,2025-03-01,import|coinbase|X#0,25000,120.00,150.00,long,2023-01-05,150.00,Charity Y
111        #[arg(long, verbatim_doc_comment)]
112        out: PathBuf,
113        /// Also emit the per-tax-year Form 8949 + Schedule D CSVs (form8949.csv / schedule_d.csv),
114        /// scoped to this calendar year. Omit to write only the all-years projection CSVs.
115        #[arg(long)]
116        tax_year: Option<i32>,
117        /// Attestation phrase required to export while the ledger is PSEUDO-RECONCILED (a synthetic
118        /// default contributes to the projection). Pass the exact phrase `I attest this is true`
119        /// (trimmed, case-sensitive) to export the fictional draft ON PURPOSE. Omit on a fully-real
120        /// ledger (never gated). Omit on an interactive terminal to be prompted; omit when piped
121        /// (non-TTY) while pseudo-active and the export is refused.
122        #[arg(long)]
123        attest: Option<String>,
124    },
125    /// Fill the OFFICIAL IRS fillable PDFs for a tax year (a whole packet).
126    ///
127    /// Writes (owner-only) into --out, populated from btctax's already-computed projection — no
128    /// capital-gains figure is recomputed:
129    ///   - f8949.pdf + schedule_d.pdf — ALWAYS. On the 2025 (1099-DA) revision Bitcoin is filed under
130    ///     Box I (short-term) / Box L (long-term) — the digital-asset boxes; on the pre-1099-DA 2024
131    ///     and 2017 revisions it is Box C / Box F ("not reported on a 1099-B"). Never the wrong pair
132    ///     for the year. More rows than a part's grid holds (11 in 2025, 14 in 2024/2017) paginate
133    ///     onto multiple copies, each with its own totals.
134    ///   - schedule_se.pdf — when there is business self-employment income and net earnings are ≥ the
135    ///     $400 floor. Line 12 (SE tax) = Social Security + regular Medicare ONLY; the 0.9% Additional
136    ///     Medicare Tax is a Form 8959 item (flagged on stderr, not put on Schedule SE). Requires a
137    ///     stored `tax-profile` for the year (filing status); missing profile ⇒ a NOTE, not a form.
138    ///   - form_8283.pdf — when there are BTC donations. Fills the donee/appraiser IDENTITY + per-
139    ///     donation property rows (Section A ≤ $5,000 or Section B > $5,000). The property-type box is
140    ///     "k Digital assets" on the Rev. 12-2023/2025 forms (2024/2025); the 2017 Rev. 12-2014 form
141    ///     has no such box, so BTC uses "j Other" + a printed note. Leaves every OTHER party's
142    ///     declaration/signature BLANK — a Section B 8283 is NOT filing-ready without those signed.
143    ///     Overflows onto additional copies.
144    ///   - form_1040_capgains.pdf — when there is reportable capital/digital-asset activity. Fills the
145    ///     capital-gain line (line 7a in 2025 / line 7 in 2024 / line 13 in 2017, when Schedule D is
146    ///     active and line 16 ≥ 0; active-and-zero → "-0-"; a net loss leaves it blank — the §1211
147    ///     line-21 cap is yours) and, on 2024/2025, the Digital-Asset question (YES iff any disposal,
148    ///     income, gift, or donation; never a "No"). The 2017 form has no Digital-Asset question, so an
149    ///     income-only 2017 year produces no 1040. 7b checkboxes are untouched.
150    ///
151    /// Every written value is read back GEOMETRICALLY against the blank PDF's own field coordinates and
152    /// the fill FAILS CLOSED on any mis-placement — a wrong tax form is never written. The engine drops
153    /// the forms' XFA layer (else Acrobat opens them blank) and sets NeedAppearances so a viewer
154    /// regenerates the visible values. Schedule D lines 17-22 (28%-rate / unrecaptured-§1250 / QDI
155    /// worksheet, incl. the line-21 loss limit) are OUT OF SCOPE. Rows on an exchange that MAY carry
156    /// 1099-DA broker reporting are flagged on stderr (btctax files them all under Box I/L and says so).
157    ///
158    /// PSEUDO-RECONCILED ledgers: the same attestation gate as export-snapshot applies, AND every
159    /// page is stamped with a diagonal `DRAFT — ESTIMATE, NOT FOR FILING` watermark.
160    ExportIrsPdf {
161        /// Output DIRECTORY receiving the filled official PDFs (created owner-only): f8949.pdf,
162        /// schedule_d.pdf, and — when applicable — schedule_se.pdf, form_8283.pdf,
163        /// form_1040_capgains.pdf. These contain your unencrypted tax data — write --out OUTSIDE any
164        /// git repo.
165        #[arg(long, verbatim_doc_comment)]
166        out: PathBuf,
167        /// The tax year to fill (this build bundles TY2017, TY2024 and TY2025; other years are
168        /// refused). TY2024/TY2017 are pre-1099-DA revisions: Bitcoin is filed under Box C/F (not Box
169        /// I/L). TY2017 additionally uses the OLD forms — the §B long Schedule SE, Form 8283 Rev.
170        /// 12-2014 ("j Other", no digital-asset box), the 1040 capital gain on line 13, and NO
171        /// Digital-Asset question.
172        #[arg(long)]
173        tax_year: i32,
174        /// Restrict the packet to specific forms (repeat or comma-separate). Default = every
175        /// applicable form (f8949 + schedule-d always; schedule-se when SE income ≥ the $400 floor;
176        /// form-8283 when there are donations; form-1040 when there is reportable digital-asset
177        /// activity). A named form is still skipped when it does not apply.
178        #[arg(long, value_enum, value_delimiter = ',')]
179        forms: Vec<FormArg>,
180        /// Attestation phrase required to export while the ledger is PSEUDO-RECONCILED (a synthetic
181        /// default contributes to the projection). Pass the exact phrase `I attest this is true`
182        /// (trimmed, case-sensitive) to fill the DRAFT-watermarked forms ON PURPOSE. Omit on a
183        /// fully-real ledger (never gated). Omit on an interactive terminal to be prompted; omit when
184        /// piped (non-TTY) while pseudo-active and the export is refused.
185        #[arg(long)]
186        attest: Option<String>,
187    },
188    /// Export the passphrase-protected key.
189    BackupKey {
190        /// File to write the exported key to: an ASCII-armored, passphrase(S2K)-encrypted private
191        /// key, owner-only (mode 0600). Identical format to `init --key-backup`.
192        ///
193        /// FORMAT (structure — NOT a real key):
194        ///   -----BEGIN PGP PRIVATE KEY BLOCK-----
195        ///   ... base64 armor of the S2K-encrypted secret key ...
196        ///   -----END PGP PRIVATE KEY BLOCK-----
197        #[arg(long, verbatim_doc_comment)]
198        out: PathBuf,
199    },
200    /// Lot-specific-identification optimizer (§C — read-only proposal or gated persistence).
201    #[command(subcommand)]
202    Optimize(Optimize),
203    /// Read-only what-if tax planning (task #43): posit a HYPOTHETICAL, NON-persisted transaction and
204    /// see its MARGINAL federal-tax effect on the current-year position. Routes through the same audited
205    /// tax engine as `report --tax-year`; invents no tax authority. Writes NOTHING — no event, no
206    /// side-table row, no vault mutation. Tax decision-support (consequences), not buy/sell/hold advice.
207    #[command(subcommand)]
208    WhatIf(WhatIf),
209    /// Set or show the per-tax-year tax profile (filing status, income, MAGI, etc.).
210    TaxProfile {
211        /// The tax year (e.g. 2025).
212        #[arg(long)]
213        year: i32,
214        /// IRS filing status.
215        #[arg(long, value_enum)]
216        filing_status: Option<FilingStatusArg>,
217        /// Ordinary taxable income EXCLUDING all app-computed crypto items (net ST gains,
218        /// mining/staking ordinary income). The engine adds the crypto items on top (B.1 / I5).
219        #[arg(long)]
220        ordinary_taxable_income: Option<String>,
221        /// Modified AGI excluding crypto items, for the §1411 NIIT threshold comparison.
222        ///
223        /// IMPORTANT (§1411 contract): this value MUST already include the taxpayer's qualified
224        /// dividends and non-crypto net capital gains (and any other MAGI add-backs from
225        /// §1411(d)). The engine adds ONLY the crypto AGI delta on top (ambiguity #5 in the
226        /// design). Omitting QD or non-crypto cap gains from this figure understates NIIT.
227        #[arg(
228            long,
229            long_help = "Modified AGI excluding crypto items, for the §1411 NIIT \
230            threshold comparison.\n\nIMPORTANT (§1411 contract): this value MUST already \
231            include the taxpayer's qualified dividends and non-crypto net capital gains (and \
232            any other MAGI add-backs from §1411(d)). The engine adds ONLY the crypto AGI \
233            delta on top (ambiguity #5 in the design). Omitting QD or non-crypto cap gains \
234            from this figure understates NIIT."
235        )]
236        magi_excluding_crypto: Option<String>,
237        /// Qualified dividends + other preferential-rate income sharing the §1(h) 0/15/20 LTCG
238        /// rate stack. Required when setting a profile.
239        #[arg(long)]
240        qualified_dividends: Option<String>,
241        /// Non-crypto net LT-character capital gain already in the profile (optional; defaults
242        /// to 0 when omitted).
243        #[arg(long)]
244        other_net_capital_gain: Option<String>,
245        /// §1212(b) short-term capital loss carryforward into this year (optional; defaults to 0).
246        #[arg(long)]
247        carryforward_short: Option<String>,
248        /// §1212(b) long-term capital loss carryforward into this year (optional; defaults to 0).
249        #[arg(long)]
250        carryforward_long: Option<String>,
251        /// Form W-2 Social Security wages (Box 3 + Box 7 tips; Schedule SE line 8a).
252        /// Reduces the §1401(a) SS cap: ss_cap = max(0, wage_base − w2_ss_wages). Optional;
253        /// defaults to $0. Must not be negative.
254        #[arg(long)]
255        w2_ss_wages: Option<String>,
256        /// Medicare wages (Box 5; Form 8959 line 1).
257        /// Reduces the Additional-Medicare threshold: addl_threshold = max(0, threshold − w2_medicare_wages)
258        /// (§1401(b)(2)(B)/Form 8959 Part II). Optional; defaults to $0. Must not be negative.
259        #[arg(long)]
260        w2_medicare_wages: Option<String>,
261        /// Schedule C deductible business expenses for the year — reduces net SE earnings;
262        /// the income-tax stack above is NOT adjusted (see the advisory).
263        /// Optional; defaults to $0. Must not be negative.
264        #[arg(long)]
265        schedule_c_expenses: Option<String>,
266        /// Show the stored profile for `--year` instead of setting it.
267        #[arg(long, default_value_t = false)]
268        show: bool,
269    },
270}
271
272/// `optimize` subcommand tree.  Task 9 adds `Run`; Task 10 adds `Accept`; Task 11 adds `Consult`.
273#[derive(Subcommand)]
274pub enum Optimize {
275    /// Mode-1 what-if: print the tax-saving lot-selection proposal. NOTHING is filed or bound.
276    Run {
277        /// The tax year to optimize (must be 2025 or later).
278        #[arg(long)]
279        tax_year: i32,
280    },
281    /// Mode-1 gated persistence: recompute the optimum and persist the proposed LotSelection(s),
282    /// gated per disposal (§1.1012-1(j)). A genuinely-contemporaneous pick (made ≤ sale) persists
283    /// freely; an already-executed disposal persists ONLY with a narrow per-disposal `--attest`
284    /// scoped to one `--disposal`; a 2027+ broker-held pick is refused. Revoke via `reconcile void`.
285    Accept {
286        /// The tax year to accept (must be 2025 or later).
287        #[arg(long)]
288        tax_year: i32,
289        /// Restrict to ONE disposal (required to carry `--attest`).
290        #[arg(long)]
291        disposal: Option<String>,
292        /// Narrow contemporaneous-ID attestation for an already-executed disposal. Requires
293        /// `--disposal` (no blanket attestation across all disposals).
294        #[arg(long)]
295        attest: Option<String>,
296    },
297    /// Mode-2 read-only pre-trade what-if (§C.3): tax-min lots + ST/LT split + federal tax + ST→LT
298    /// timing. NOTHING is written — no event, no side-table row. Tax decision-support only;
299    /// not buy/sell/hold advice.
300    Consult {
301        /// Hypothetical sale amount in satoshis (required).
302        #[arg(long)]
303        sell: String,
304        /// Wallet to sell from, e.g. `self:cold` or `exchange:coinbase:default` (required; per-wallet
305        /// pool is mandatory post-2025).
306        #[arg(long)]
307        wallet: Option<String>,
308        /// Sale date for the what-if (YYYY-MM-DD; defaults to today UTC if omitted).
309        #[arg(long)]
310        at: Option<String>,
311        /// Explicit USD proceeds for the hypothetical sale. Required when `--at` is a future date
312        /// with no bundled dataset price and `--fmv` is not used. Mutually exclusive with `--fmv`.
313        #[arg(long, conflicts_with = "fmv")]
314        proceeds: Option<String>,
315        /// Use the bundled daily-close FMV for `--at` instead of an explicit proceeds amount.
316        /// A future date with no dataset price will return a ProceedsRequired error. Mutually
317        /// exclusive with `--proceeds`.
318        #[arg(long, conflicts_with = "proceeds")]
319        fmv: bool,
320    },
321}
322
323/// `what-if` subcommand tree (task #43). READ-ONLY hypothetical-transaction tax planning: NOTHING is
324/// filed, appended, or persisted. Mirrors the `optimize consult` shape, plus an ad-hoc `TaxProfile`
325/// (so you can plan without `tax-profile set`).
326#[derive(Subcommand)]
327pub enum WhatIf {
328    /// Posit a hypothetical, NON-persisted SALE and see its MARGINAL federal tax: the lots it would
329    /// consume, the ST/LT split, which §1(h) LTCG bracket (0/15/20) it lands in + room to the next
330    /// breakpoint, the exact marginal tax (with-hypothetical minus baseline — the sale's OWN effect,
331    /// not the whole-year figure), the effective rate, the §1212(b) carryforward carried to next year,
332    /// this year's ordinary offset, and the §1411 NIIT delta. A net loss surfaces the carryforward
333    /// disclosure (its value is NOT this-year tax). Writes NOTHING.
334    Sell {
335        /// Hypothetical sale amount in satoshis (required).
336        #[arg(long)]
337        sell: String,
338        /// Wallet to sell from, e.g. `self:cold` or `exchange:coinbase:default` (required; the
339        /// per-wallet pool is mandatory post-2025).
340        #[arg(long)]
341        wallet: Option<String>,
342        /// Sale date for the what-if (YYYY-MM-DD; defaults to today UTC if omitted).
343        #[arg(long)]
344        at: Option<String>,
345        /// USD price per WHOLE BTC for the hypothetical sale (proceeds = price × sat / 1e8). Omit to
346        /// use the bundled daily-close FMV for `--at`; REQUIRED for a future/off-dataset `--at` with no
347        /// bundled price (else the what-if returns a ProceedsRequired error).
348        #[arg(long)]
349        price: Option<String>,
350        /// Lot-selection method for the hypothetical sale: fifo|lifo|hifo. Omit to consume by the
351        /// STANDING method (the account's in-force election / the default), exactly as a real disposal
352        /// on that date would.
353        #[arg(long, value_enum)]
354        method: Option<MethodLotArg>,
355        /// AD-HOC filing status (single|mfj|mfs|hoh|qss). Supplying this (with `--income`) builds a
356        /// NON-persisted profile for the plan instead of the stored `tax-profile`. Omit ALL ad-hoc
357        /// flags to use the stored profile for the sale year.
358        #[arg(long, value_enum)]
359        filing_status: Option<FilingStatusArg>,
360        /// AD-HOC ordinary taxable income EXCLUDING crypto (the base the crypto stacks on). Required
361        /// when building an ad-hoc profile.
362        #[arg(long)]
363        income: Option<String>,
364        /// AD-HOC modified AGI excluding crypto, for the §1411 NIIT threshold. DEFAULTS TO `--income`
365        /// when omitted (never $0 — a $0 MAGI would silently suppress every NIIT disclosure); a printed
366        /// caveat notes the assumption. Supply the true MAGI (incl. QD + non-crypto cap gains) to avoid
367        /// understating NIIT.
368        #[arg(long)]
369        magi: Option<String>,
370        /// AD-HOC §1212(b) LONG-TERM capital-loss carryforward INTO the sale year (optional; defaults
371        /// to $0). The dominant BTC case; short-term carryforward-in is out of scope for the ad-hoc
372        /// profile (set a stored `tax-profile` for that).
373        #[arg(long)]
374        carryforward_in: Option<String>,
375    },
376    /// Posit a hypothetical, NON-persisted HARVEST and find the MAX BTC to sell such that a target holds
377    /// on the ENTIRE prefix [0, N]: `--target zero-ltcg` (sell all that fits in the §1(h) 0% bracket),
378    /// `fifteen-ltcg` (stay at/under 15%), `gain=$X` (realize at most $X of gain WITH this sale), or
379    /// `tax=$X` (add at most $X of marginal federal tax; `tax=$0` is the flagship "zero-tax harvest").
380    /// Uses the STANDING lot method's consumption order (never re-optimized). Discloses the §1212(b)
381    /// carryforward burn, the §1411 NIIT kink (a 0%/15% answer can still cost +3.8%), and the plateau
382    /// notes. The answer is ALWAYS engine-verified. Writes NOTHING.
383    Harvest {
384        /// The harvest target: `zero-ltcg` | `fifteen-ltcg` | `gain=$X` | `tax=$X` (X >= 0). `$` and
385        /// commas are optional (e.g. `gain=25000`, `tax=$0`, `gain=$1,000`).
386        #[arg(long)]
387        target: String,
388        /// Wallet to harvest from, e.g. `self:cold` or `exchange:coinbase:default` (required; the
389        /// per-wallet pool is mandatory post-2025).
390        #[arg(long)]
391        wallet: Option<String>,
392        /// Harvest date for the what-if (YYYY-MM-DD; defaults to today UTC if omitted).
393        #[arg(long)]
394        at: Option<String>,
395        /// USD price per WHOLE BTC. Omit to use the bundled daily-close FMV for `--at`; REQUIRED for a
396        /// future/off-dataset `--at` with no bundled price.
397        #[arg(long)]
398        price: Option<String>,
399        /// AD-HOC filing status (single|mfj|mfs|hoh|qss). Supplying this (with `--income`) builds a
400        /// NON-persisted profile for the plan instead of the stored `tax-profile`. Omit ALL ad-hoc
401        /// flags to use the stored profile for the harvest year.
402        #[arg(long, value_enum)]
403        filing_status: Option<FilingStatusArg>,
404        /// AD-HOC ordinary taxable income EXCLUDING crypto (the base the crypto stacks on). Required
405        /// when building an ad-hoc profile.
406        #[arg(long)]
407        income: Option<String>,
408        /// AD-HOC modified AGI excluding crypto, for the §1411 NIIT threshold. DEFAULTS TO `--income`
409        /// when omitted (never $0 — a $0 MAGI would silently suppress every NIIT disclosure); a printed
410        /// caveat notes the assumption.
411        #[arg(long)]
412        magi: Option<String>,
413        /// AD-HOC §1212(b) LONG-TERM capital-loss carryforward INTO the harvest year (optional; defaults
414        /// to $0) — expands the harvestable-gain room (gains are absorbed before touching the pref stack).
415        #[arg(long)]
416        carryforward_in: Option<String>,
417    },
418}
419
420#[derive(Subcommand)]
421pub enum Reconcile {
422    /// Confirm a self-transfer (TransferLink).
423    LinkTransfer {
424        out: String,
425        #[arg(long, conflicts_with = "to_wallet")]
426        to_event: Option<String>,
427        #[arg(long)]
428        to_wallet: Option<String>,
429    },
430    /// Classify an inbound TransferIn as income.
431    ClassifyInboundIncome {
432        in_ref: String,
433        #[arg(long)]
434        kind: String,
435        #[arg(long)]
436        fmv: Option<String>,
437        #[arg(long)]
438        business: bool,
439    },
440    /// Classify an inbound TransferIn as a received gift.
441    ClassifyInboundGift {
442        in_ref: String,
443        #[arg(long)]
444        fmv_at_gift: String,
445        #[arg(long)]
446        donor_basis: Option<String>,
447        #[arg(long)]
448        donor_acquired: Option<String>,
449    },
450    /// Classify an inbound TransferIn as an inbound self-transfer ("my own coins" returning) —
451    /// non-taxable, creates a fresh lot. `--basis` defaults to $0 (conservative; fires the honest
452    /// zero-basis advisory when omitted); `--acquired` defaults to 1 year + 1 day before receipt
453    /// (assumed long-term for a cold-storage deposit; discloses an advisory so you can correct it).
454    ClassifyInboundSelfTransfer {
455        in_ref: String,
456        #[arg(long)]
457        basis: Option<String>,
458        #[arg(long)]
459        acquired: Option<String>,
460    },
461    /// Reclassify a pending TransferOut.
462    ReclassifyOutflow {
463        out: String,
464        #[arg(long, value_enum)]
465        as_kind: OutKindArg,
466        #[arg(long)]
467        amount: String,
468        #[arg(long)]
469        fee: Option<String>,
470        #[arg(long)]
471        appraisal: bool,
472        /// Free-form donee identifier (e.g. "Alice", "Charity X"). Carried through to
473        /// removals.csv and Form 8283; does not affect tax math.
474        #[arg(long)]
475        donee: Option<String>,
476    },
477    /// Set a manual FMV on an event.
478    SetFmv {
479        event: String,
480        #[arg(long)]
481        fmv: String,
482    },
483    /// Void a revocable decision.
484    Void { target: String },
485    /// Resolve an Unclassified row from a JSON imported payload.
486    ClassifyRaw {
487        target: String,
488        /// A JSON-encoded imported EventPayload (serde externally-tagged: `{"Variant":{...}}`) to
489        /// resolve the Unclassified target as. Must be an IMPORTED variant — Acquire, Income,
490        /// Dispose, TransferOut, TransferIn, or Unclassified. USD fields (usd_cost, fee_usd, …) are
491        /// decimal STRINGS; `sat` is an integer.
492        ///
493        /// FORMAT (Acquire example):
494        ///   {"Acquire":{"sat":2000000,"usd_cost":"1680.00","fee_usd":"5.00","basis_source":"ExchangeProvided"}}
495        #[arg(long, verbatim_doc_comment)]
496        payload_json: String,
497    },
498    /// Accept an import conflict.
499    AcceptConflict { conflict: String },
500    /// Reject an import conflict.
501    RejectConflict { conflict: String },
502    /// Path-B safe-harbor allocate (from the actual pre-2025 position).
503    SafeHarborAllocate {
504        #[arg(long, value_enum, default_value_t = MethodArg::Actual)]
505        method: MethodArg,
506        #[arg(long)]
507        attest: bool,
508    },
509    /// Attest an existing allocation as timely.
510    SafeHarborAttest,
511    /// §A.4 Specific-ID: pick the exact lots a disposal consumes.
512    SelectLots {
513        disposal: String,
514        /// One lot pick per --from flag (repeatable). Each PICK is
515        /// `<origin_event_id>#<split_sequence>:<sat>`. The origin_event_id + split come from the
516        /// `lot` column of disposals.csv or the `origin_event`/`split` columns of lots.csv
517        /// (export-snapshot). The total sat across the picks must equal the disposal's principal
518        /// (validated in the fold).
519        ///
520        /// FORMAT (two picks):
521        ///   --from import|coinbase|X#0:25000 --from import|river|Y#1:5000
522        #[arg(long = "from", required = true, verbatim_doc_comment)]
523        from: Vec<String>,
524    },
525    /// §A.4 Batch import LotSelections from a CSV (disposal_ref,origin_event_id,split_sequence,sat).
526    ImportSelections {
527        /// CSV of lot picks imported as LotSelection decisions (§A.4). The header is REQUIRED and
528        /// validated loudly; rows sharing a disposal_ref are grouped into a single decision.
529        /// disposal_ref is the disposal event's ref (disposals.csv `event` column); origin_event_id
530        /// is the lot's origin (lots.csv `origin_event` column).
531        ///
532        /// FORMAT (header + one sample row):
533        ///   disposal_ref,origin_event_id,split_sequence,sat
534        ///   import|gemini|trade|T-2.O-2,import|coinbase|X,0,1000000
535        #[arg(verbatim_doc_comment)]
536        csv: PathBuf,
537    },
538    /// SE-completion Chunk C: flip `business` (and optionally `kind`) on an already-imported Income event.
539    ///
540    /// Corrects the `business: false` hard-code that River (and other adapters) emit at ingest time,
541    /// enabling SE-tax treatment for professional miners / stakers. The engine validates that the target
542    /// event exists and is an Income event — a missing or non-Income target fires a Hard DecisionConflict
543    /// blocker (decision excluded). For TransferIn rows use `classify-inbound-income` instead.
544    ///
545    /// DecisionConflict is Hard — to re-decide, `void` the prior decision first, then re-issue.
546    ReclassifyIncome {
547        /// The Income event reference (from `report` or `income_recognized.csv` 'event' column).
548        income_event: String,
549        /// Whether this income is from a trade or business (true → SE-tax eligible).
550        /// Must be supplied explicitly: `--business true` or `--business false`.
551        #[arg(long, required = true, action = clap::ArgAction::Set)]
552        business: bool,
553        /// Optional income kind correction: mining|staking|interest|airdrop|reward.
554        /// Omit to keep the original kind (only flip `business`).
555        #[arg(long)]
556        kind: Option<String>,
557    },
558    /// Store Form 8283 Section-B donation + appraiser details for a donation event.
559    /// The event ref is the TransferOut EventId from the removals.csv 'event' column.
560    SetDonationDetails {
561        /// TransferOut event reference for the donation (from removals.csv 'event' column).
562        out_event_ref: String,
563        /// Donee organization name (Part IV; required).
564        #[arg(long, required = true)]
565        donee_name: String,
566        /// Donee mailing address (Part IV; optional).
567        #[arg(long)]
568        donee_address: Option<String>,
569        /// Donee EIN (Part IV; required for Section-B completeness).
570        #[arg(long)]
571        donee_ein: Option<String>,
572        /// Qualified appraiser name (Part III; required).
573        #[arg(long, required = true)]
574        appraiser_name: String,
575        /// Appraiser mailing address (Part III; optional).
576        #[arg(long)]
577        appraiser_address: Option<String>,
578        /// Appraiser TIN/SSN/EIN (Part III §6695A; satisfies the TIN-or-PTIN requirement).
579        #[arg(long)]
580        appraiser_tin: Option<String>,
581        /// Appraiser PTIN (Part III §6695A; satisfies the TIN-or-PTIN requirement).
582        #[arg(long)]
583        appraiser_ptin: Option<String>,
584        /// Appraiser qualifications declaration (§170(f)(11)(E)).
585        #[arg(long)]
586        appraiser_qualifications: Option<String>,
587        /// Date the qualified appraisal was made (YYYY-MM-DD).
588        #[arg(long)]
589        appraisal_date: Option<String>,
590        /// FMV determination method override (overrides the section-derived default on the
591        /// Form 8283 carrier row; resolves the Section-A fmv_method deferral when supplied).
592        #[arg(long)]
593        fmv_method: Option<String>,
594    },
595    /// Show stored Form 8283 donation details for a donation event.
596    ShowDonationDetails {
597        /// TransferOut event reference for the donation (from removals.csv 'event' column).
598        out_event_ref: String,
599    },
600    /// Bulk-confirm self-transfers: link every PENDING outbound transfer in a time frame to one
601    /// destination wallet (non-taxable). Shows a preview + requires --yes (or interactive y/N).
602    BulkLinkTransfer {
603        /// Destination wallet every selected outflow links to.
604        #[arg(long)]
605        to_wallet: String,
606        /// Restrict to a single tax year (mutually exclusive with --from/--to).
607        #[arg(long, conflicts_with_all = ["from", "to"])]
608        year: Option<i32>,
609        /// Range start (YYYY-MM-DD; requires --to).
610        #[arg(long, requires = "to")]
611        from: Option<String>,
612        /// Range end (YYYY-MM-DD, inclusive; requires --from).
613        #[arg(long, requires = "from")]
614        to: Option<String>,
615        /// Only outflows FROM this source wallet.
616        #[arg(long)]
617        from_wallet: Option<String>,
618        /// Print the preview and exit without writing.
619        #[arg(long)]
620        dry_run: bool,
621        /// Skip the interactive confirmation (non-interactive apply).
622        #[arg(long)]
623        yes: bool,
624    },
625    /// Bulk-classify unknown-basis inbound deposits as self-transfer-ins ("my own coins"): apply
626    /// Cycle A's `SelfTransferMine` ($0 conservative basis, non-taxable) to MANY pending inbounds in a
627    /// time frame at once. Shows a preview surfacing the total USD given $0 basis (the over-tax
628    /// exposure) + requires --yes (or interactive y/N). Each is a voidable decision; for a deposit
629    /// whose real cost you can substantiate, classify it single-item with `classify-inbound-self-transfer --basis`.
630    BulkClassifyInboundSelfTransfer {
631        /// Restrict to a single tax year (mutually exclusive with --from/--to).
632        #[arg(long, conflicts_with_all = ["from", "to"])]
633        year: Option<i32>,
634        /// Range start (YYYY-MM-DD; requires --to).
635        #[arg(long, requires = "to")]
636        from: Option<String>,
637        /// Range end (YYYY-MM-DD, inclusive; requires --from).
638        #[arg(long, requires = "from")]
639        to: Option<String>,
640        /// Only inbounds received INTO this wallet.
641        #[arg(long)]
642        wallet: Option<String>,
643        /// Print the preview and exit without writing.
644        #[arg(long)]
645        dry_run: bool,
646        /// Skip the interactive confirmation (non-interactive apply).
647        #[arg(long)]
648        yes: bool,
649    },
650    /// Bulk-classify unknown-basis inbound deposits as INCOME (mining|staking|interest|airdrop|reward):
651    /// recognize MANY pending inbounds as ordinary income at their auto-FMV (the daily-close market
652    /// value at receipt) in one confirmed batch, with a UNIFORM `--kind` + `--business` flag. Shows a
653    /// preview surfacing the total income recognized + the count of inbounds EXCLUDED because no price
654    /// was available for their date (those stay pending — an income row with no FMV would year-gate).
655    /// Each is a voidable decision; for a single deposit use `classify-inbound-income`.
656    BulkClassifyInboundIncome {
657        /// Income kind for the whole batch: mining|staking|interest|airdrop|reward.
658        #[arg(long)]
659        kind: String,
660        /// Whether this income is from a trade or business (true → SE-tax eligible).
661        #[arg(long)]
662        business: bool,
663        /// Restrict to a single tax year (mutually exclusive with --from/--to).
664        #[arg(long, conflicts_with_all = ["from", "to"])]
665        year: Option<i32>,
666        /// Range start (YYYY-MM-DD; requires --to).
667        #[arg(long, requires = "to")]
668        from: Option<String>,
669        /// Range end (YYYY-MM-DD, inclusive; requires --from).
670        #[arg(long, requires = "from")]
671        to: Option<String>,
672        /// Only inbounds received INTO this wallet.
673        #[arg(long)]
674        wallet: Option<String>,
675        /// Print the preview and exit without writing.
676        #[arg(long)]
677        dry_run: bool,
678        /// Skip the interactive confirmation (non-interactive apply).
679        #[arg(long)]
680        yes: bool,
681    },
682    /// Bulk-reclassify unknown pending OUTFLOWS as dispositions (Sell|Spend): reclassify MANY pending
683    /// `TransferOut`s as a `Dispose` in one confirmed batch, with the daily-close market value at the
684    /// outflow date as the ESTIMATED proceeds. Shows a preview surfacing the total ESTIMATED proceeds
685    /// AND the total ESTIMATED gain (sum(fmv) - sum(basis)) + the count of outflows EXCLUDED because no price
686    /// was available for their date (those stay pending — a Sell with fabricated proceeds would be a
687    /// SILENT misreport). `--kind` is UNIFORM and accepts ONLY sell|spend (gift/donate are out of
688    /// scope). Each is a voidable decision; for a single outflow use `reclassify-outflow`.
689    BulkReclassifyOutflow {
690        /// Disposition kind for the whole batch: sell|spend (gift/donate rejected — out of scope).
691        #[arg(long)]
692        kind: String,
693        /// Restrict to a single tax year (mutually exclusive with --from/--to).
694        #[arg(long, conflicts_with_all = ["from", "to"])]
695        year: Option<i32>,
696        /// Range start (YYYY-MM-DD; requires --to).
697        #[arg(long, requires = "to")]
698        from: Option<String>,
699        /// Range end (YYYY-MM-DD, inclusive; requires --from).
700        #[arg(long, requires = "from")]
701        to: Option<String>,
702        /// Only outflows from this SOURCE wallet.
703        #[arg(long)]
704        wallet: Option<String>,
705        /// Print the preview and exit without writing.
706        #[arg(long)]
707        dry_run: bool,
708        /// Skip the interactive confirmation (non-interactive apply).
709        #[arg(long)]
710        yes: bool,
711    },
712    /// Bulk-resolve import conflicts: ACCEPT (adopt each new payload) or REJECT (keep each current
713    /// payload) MANY flagged `ImportConflict`s in one confirmed batch. Shows a `current → new` preview,
714    /// then requires --yes (or interactive y/N). Exactly one of --accept / --reject is required. Each
715    /// resolution is NON-REVOCABLE (`SupersedeImport`/`RejectImport` cannot be voided); to resolve a
716    /// conflict differently, exclude it and use single-item `accept-conflict`/`reject-conflict`.
717    #[command(group(clap::ArgGroup::new("resolve_action").required(true).args(["accept", "reject"])))]
718    BulkResolveConflict {
719        /// Accept every listed conflict (adopt each new payload onto its target).
720        #[arg(long)]
721        accept: bool,
722        /// Reject every listed conflict (keep each target's current payload).
723        #[arg(long)]
724        reject: bool,
725        /// Print the preview and exit without writing.
726        #[arg(long)]
727        dry_run: bool,
728        /// Skip the interactive confirmation (non-interactive apply).
729        #[arg(long)]
730        yes: bool,
731    },
732    /// Bulk-void MANY revocable reconcile decisions in one confirmed batch (bulk-void). Shows a preview
733    /// of every voidable decision (the SHARED `voidable_decisions` predicate — effective safe-harbor
734    /// allocations are OMITTED, #7), then requires --yes (or interactive y/N). Each void is
735    /// NON-REVOCABLE (a `VoidDecisionEvent` cannot itself be voided — re-apply the original decision to
736    /// restore). Voiding a `LotSelection` also re-exposes its disposal to the default method and clears
737    /// its optimizer attestation.
738    BulkVoid {
739        /// Print the preview and exit without writing.
740        #[arg(long)]
741        dry_run: bool,
742        /// Skip the interactive confirmation (non-interactive apply).
743        #[arg(long)]
744        yes: bool,
745    },
746    /// Match unreconciled inbound + outbound legs as self-transfers (self-transfer-passthrough C3).
747    /// With no --in/--out: PREVIEW the proposed pairs (read-only). With --in and --out: confirm ONE
748    /// pair (DROP for a same-wallet passthrough, RELOCATE for a cross-wallet transfer). NEVER automatic.
749    MatchSelfTransfers {
750        /// Confirm this in-leg (TransferIn eventref); requires --out.
751        #[arg(long = "in", requires = "out_ref")]
752        in_ref: Option<String>,
753        /// Confirm this out-leg (TransferOut eventref); requires --in.
754        #[arg(long = "out", requires = "in_ref")]
755        out_ref: Option<String>,
756        /// Override the suggested action (else the proposal's topology-derived action is used).
757        #[arg(long, value_enum)]
758        action: Option<SelfTransferActionArg>,
759        /// Print the preview and exit without writing (conflicts with --in/--out).
760        #[arg(long, conflicts_with_all = ["in_ref", "out_ref"])]
761        dry_run: bool,
762    },
763    /// Pseudo-reconcile MODE (sub-project 2): fill deliberately-fictional default decisions at
764    /// projection time (NEVER persisted) to clear the Hard classification blockers — a loudly-flagged
765    /// `[PSEUDO]` on-screen estimate you correct toward truth. `on`/`off` toggle the mode; `approve`
766    /// promotes chosen defaults to real (attested) decisions.
767    #[command(subcommand)]
768    Pseudo(Pseudo),
769}
770
771/// `reconcile pseudo <action>` — the pseudo-reconcile mode sub-verbs (sub-project 2).
772#[derive(Subcommand)]
773pub enum Pseudo {
774    /// Turn pseudo-reconcile mode ON. Projection now synthesizes non-persisted default decisions for
775    /// unresolved unknown-basis inbounds (self-transfer $0), unclassified rows, and import conflicts
776    /// (accept-first); every synthetic contribution is flagged `[PSEUDO]` on screen and BLOCKS export.
777    On,
778    /// Turn pseudo-reconcile mode OFF. Projection reverts to real-only instantly and totally (no
779    /// fictional events were ever written). Already-approved decisions REMAIN (they are real now).
780    Off,
781    /// Promote pseudo default decisions to REAL (attested) decisions in bulk. Shows a preview + requires
782    /// `--yes` (or `--dry-run` to preview only). Optional filters restrict which defaults are approved.
783    Approve {
784        /// Only approve defaults of this TYPE: `self-transfer` (unknown-basis inbound → $0 self-transfer),
785        /// `raw` (unclassified row placeholder), `conflict` (import conflict accept-first), or `fmv`
786        /// (native income FMV synthesized from the daily close). Omit = all.
787        #[arg(long, value_enum)]
788        kind: Option<PseudoKindArg>,
789        /// Only approve defaults whose target event is in this wallet (e.g. `exchange:coinbase:main`).
790        #[arg(long)]
791        wallet: Option<String>,
792        /// Only approve defaults whose target event falls in this tax year.
793        #[arg(long)]
794        year: Option<i32>,
795        /// Print the preview and exit without writing.
796        #[arg(long)]
797        dry_run: bool,
798        /// Skip the interactive confirmation (non-interactive apply).
799        #[arg(long)]
800        yes: bool,
801    },
802}
803
804/// The pseudo-default TYPE filter for `reconcile pseudo approve --kind`.
805#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum)]
806pub enum PseudoKindArg {
807    /// Unknown-basis inbound defaulted to a $0-basis self-transfer-in.
808    SelfTransfer,
809    /// Unclassified row defaulted to a zero-value placeholder (ClassifyRaw).
810    Raw,
811    /// Import conflict defaulted to accept-first (SupersedeImport).
812    Conflict,
813    /// Native income with a missing FMV defaulted to the daily-close value (ManualFmv).
814    Fmv,
815}
816
817#[derive(Copy, Clone, ValueEnum)]
818pub enum SelfTransferActionArg {
819    /// Same-wallet passthrough → SelfTransferPassthrough (both legs skipped, non-taxable).
820    Drop,
821    /// Cross-wallet transfer → TransferLink (relocate the lots to the destination wallet).
822    Relocate,
823}
824
825/// One official form in the `export-irs-pdf` packet (the `--forms` opt-in filter).
826#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
827pub enum FormArg {
828    /// Form 8949 (per-disposition capital-gains rows).
829    F8949,
830    /// Schedule D (aggregated capital-gains totals).
831    ScheduleD,
832    /// Schedule SE (self-employment tax).
833    ScheduleSe,
834    /// Form 8283 (noncash charitable contributions).
835    Form8283,
836    /// Form 1040 (capital-gains cells + the digital-asset question).
837    Form1040,
838}
839
840#[derive(Copy, Clone, ValueEnum)]
841pub enum FilingStatusArg {
842    Single,
843    Mfj,
844    Mfs,
845    Hoh,
846    Qss,
847}
848
849impl From<FilingStatusArg> for FilingStatus {
850    fn from(a: FilingStatusArg) -> Self {
851        match a {
852            FilingStatusArg::Single => FilingStatus::Single,
853            FilingStatusArg::Mfj => FilingStatus::Mfj,
854            FilingStatusArg::Mfs => FilingStatus::Mfs,
855            FilingStatusArg::Hoh => FilingStatus::HoH,
856            FilingStatusArg::Qss => FilingStatus::Qss,
857        }
858    }
859}
860
861#[derive(Copy, Clone, ValueEnum)]
862pub enum FeeArg {
863    C,
864    B,
865}
866
867#[derive(Copy, Clone, ValueEnum)]
868pub enum MethodLotArg {
869    Fifo,
870    Lifo,
871    Hifo,
872}
873
874#[derive(Copy, Clone, ValueEnum)]
875pub enum OutKindArg {
876    Sell,
877    Spend,
878    Gift,
879    Donate,
880}
881
882impl From<MethodLotArg> for LotMethod {
883    fn from(a: MethodLotArg) -> Self {
884        match a {
885            MethodLotArg::Fifo => LotMethod::Fifo,
886            MethodLotArg::Lifo => LotMethod::Lifo,
887            MethodLotArg::Hifo => LotMethod::Hifo,
888        }
889    }
890}
891
892#[derive(Copy, Clone, ValueEnum)]
893pub enum MethodArg {
894    Actual,
895    ProRata,
896}
897
898#[cfg(test)]
899mod tests {
900    use super::*;
901    use clap::CommandFactory;
902
903    /// Render the LONG help (`--help`) of a subcommand identified by its path, recursing into
904    /// nested subcommands (e.g. `["reconcile", "import-selections"]`). Mirrors what a user sees at
905    /// `btctax <path...> --help`, which includes each argument's verbatim long-help.
906    fn long_help_of(path: &[&str]) -> String {
907        let mut cmd = Cli::command();
908        for name in path {
909            cmd = cmd
910                .find_subcommand(name)
911                .unwrap_or_else(|| panic!("subcommand {name:?} exists"))
912                .clone();
913        }
914        cmd.render_long_help().to_string()
915    }
916
917    // Requirement 3, `--help` half: each file/format-taking arg's long-help carries its FORMAT +
918    // a text EXAMPLE. Tokens are comma/brace-joined (no spaces) so help-wrapping can never break
919    // them (verified against the real binary output). This is the single source of truth that
920    // clap_mangen also renders into the per-subcommand man page (Task 2).
921
922    #[test]
923    fn help_documents_key_backup_format() {
924        let h = long_help_of(&["init"]);
925        assert!(
926            h.contains("-----BEGIN PGP PRIVATE KEY BLOCK-----"),
927            "init --key-backup help must document the ASCII-armored key format:\n{h}"
928        );
929    }
930
931    #[test]
932    fn help_documents_backup_key_format() {
933        let h = long_help_of(&["backup-key"]);
934        assert!(
935            h.contains("-----BEGIN PGP PRIVATE KEY BLOCK-----"),
936            "backup-key --out help must document the ASCII-armored key format:\n{h}"
937        );
938    }
939
940    #[test]
941    fn help_documents_export_snapshot_format() {
942        let h = long_help_of(&["export-snapshot"]);
943        // The exact removals.csv header read from the render.rs writer.
944        assert!(
945            h.contains("event,kind,removed_at,lot,sat,basis,fmv_at_transfer"),
946            "export-snapshot --out help must document the projection CSV headers:\n{h}"
947        );
948    }
949
950    #[test]
951    fn help_documents_import_selections_format() {
952        let h = long_help_of(&["reconcile", "import-selections"]);
953        assert!(
954            h.contains("disposal_ref,origin_event_id,split_sequence,sat"),
955            "import-selections help must document the required CSV header:\n{h}"
956        );
957    }
958
959    #[test]
960    fn help_documents_classify_raw_format() {
961        let h = long_help_of(&["reconcile", "classify-raw"]);
962        // The exact externally-tagged serde shape (Usd = decimal string, sat = integer).
963        assert!(
964            h.contains(r#"{"Acquire":{"sat":2000000,"usd_cost":"1680.00","fee_usd":"5.00","basis_source":"ExchangeProvided"}}"#),
965            "classify-raw --payload-json help must document the JSON payload shape:\n{h}"
966        );
967    }
968
969    #[test]
970    fn help_documents_select_lots_format() {
971        let h = long_help_of(&["reconcile", "select-lots"]);
972        assert!(
973            h.contains("import|coinbase|X#0:25000"),
974            "select-lots --from help must document the <event>#<split>:<sat> pick format:\n{h}"
975        );
976    }
977}