stripTaskLedger function
Removes the last parseable ledger (fenced or the unfenced near-miss
shape) from text — the run's final answer must never SHOW the
checklist it self-checked with (gh-1516): the record lives in the
hidden task_ledger session record, the transcript stays clean.
Returns text unchanged when no ledger parses out of it.
Only the blank runs TOUCHING the removed span are collapsed — the rest of the answer stays byte-identical (gh-1516 review): multi-blank formatting elsewhere is user-facing text, not strip fallout.
Implementation
String stripTaskLedger(String text) =>
resolveTaskLedger(text)?.strippedText ?? text;