pub async fn fold_due(
runs: &Path,
home: &Path,
_worktrees_root: &Path,
disk: &Disk,
now: Timestamp,
) -> Result<(usize, usize)>Expand description
Fold every run that is finished, older than the grace period, and not being
worked on; return (folded, unreadable).
A run whose run.json genuinely cannot be parsed — missing fields, broken
JSON, a schema newer than this build has ever heard of — is left exactly
as it is. Automatic housekeeping cannot tell a mid-write file from one that
will never parse again, and <home>/runs/<id>/ is the evidence magi stats and the deck read; when unsure whether it is safe to touch, the
janitor keeps rather than deletes (see the module docs). Discarding a
record this unreadable is an explicit operator action (magi fold, or the
equivalent phone route), never something that happens unattended. Every
such skip is counted in the returned unreadable and logged through
tracing::warn with the parse failure that caused it - silence here is
exactly the failure mode that let 90 of 93 runs sit unfolded with nothing
to show for it.
A run merely written by a different schema number is not unreadable: as
long as run.json still parses, it folds like any other terminal run (see
the module docs for why the two are different questions).
Runnable statuses and runs newer than the grace period are also left
alone; folding them would throw away work that is still the answer to
somebody’s question. Merged runs forget their winner’s worktree (the
merge already landed it); Ready and Failed runs keep it.