pub fn load(
conn: &Connection,
year: i32,
) -> Result<(Loaded, Option<StaleNote>), CliError>Expand description
Resolve the working return for year (§6.1 precedence + §6.3 stale split).
A draft row takes precedence over the committed row. If the draft is at a schema version this build does
not read (d.version != SCHEMA_VERSION), the split is by parked:
- WIP (
parked = 0) → the draft is regenerable, so DISCARD it: delete the stale row (an in-memory delete the caller’s nextsave_draftpersists — this is a read path, nosess.save()here) and fall through to committed/Fresh, RETURNING aStaleNoteso the caller (not this store fn) can surface the discard (I-1). - parked (
parked = 1) → it may hold carryover that exists ONLY in the draft (C-1), so REFUSE withCliError::StaleParkedDraft(fail closed) rather than destroy irreplaceable data.
A version-current draft yields Draft { ri, parked }. With no draft, the committed row (if any) is
Committed, else Fresh. The second tuple element is Some(StaleNote) ONLY on the stale-WIP discard
path; every other path returns None.