Skip to main content

Module optimize

Module optimize 

Source
Expand description

optimize run (Task 9) — §C.2 Mode-1 what-if proposal. READ-ONLY: opens the vault, projects, optimizes, and returns the proposal. Appends / persists NOTHING.

optimize accept (Task 10) — §C.2 gated persistence. The ONLY Mode-1 path that writes. It RECOMPUTES the same deterministic optimum (never trusts a stale proposal — NFR4), then for each disposal applies the §1.1012-1(j) gate: persist the proposed LotSelection ONLY when it is genuinely contemporaneous (made ≤ sale) OR — for an already-executed disposal within the own-books envelope — behind a NARROW per-disposal --attest; a 2027+ broker-held pick is CATEGORICALLY refused (own-books is insufficient; no attestation can cure it). When attested, the proposed LotSelection decision AND the attestation side-table row are co-persisted ATOMICALLY (both land in the same in-memory DB and are flushed by a SINGLE session.save()), so the persisted selection == the attested selection == the new baseline (closes the Task-8 operational note; R2-I1 holds on a later re-run). Revocation reuses the existing reconcile void on the returned decision id.

optimize consult (Task 11) — §C.3 Mode-2 read-only pre-trade what-if. Opens the vault, projects, calls consult_sale, returns a ConsultReport. READ-ONLY: appends NOTHING, no decision, no side-table write (Mode-2 produces nothing). Tax decision-support (consequences), NOT buy/sell advice.

Structs§

AcceptOutcome
The result of optimize accept — what was persisted vs skipped (for rendering). persisted carries (disposal, decision, basis): the disposal whose pick was adopted, the appended LotSelection decision id (pass it to reconcile void to revoke), and the §A.5 basis label ("Contemporaneous" / "AttestedRecording"). skipped carries (disposal, reason).

Functions§

accept
optimize accept — apply the recomputed optimum, gated per disposal (§C.2 / §1.1012-1(j)).
consult
optimize consult — §C.3 Mode-2 READ-ONLY pre-trade what-if.
run
optimize run — Mode 1 what-if. READ-ONLY: opens the vault, projects, optimizes, returns the proposal. Appends/persists NOTHING. now is the CLI clock seam → the proposed picks’ made-date (R0-C2: core stays clock-free; the proposal the user reads is judged against the REAL made-date).