T-043: Long-run setup: unattended runs lasting days
Goal
Let the orchestrator start a simulation that runs for hours or days with nobody watching,
using no model quota, and come back to trustworthy data. Evan wants idle machine time used
this way. See "Long runs" in docs/RUNBOOK.md.
Scope
scripts/longrun.shwithstart,status,pause,resume,stopandlist.starttakes a name, a config, seeds, a length in steps or wall time, and a thread count.- Runs survive everything: they are supervised by launchd, resume from the last checkpoint after a crash or a reboot, and keep the Mac awake.
- Low priority, so agent work is not slowed.
pauseandresumefree the machine quickly for a heavy ticket. - Several seeds side by side as separate processes, within a total thread budget.
- Progress without a model: a time series file per run (step, wall time, steps per second,
population, biomass, energy-source mix, and the measures from T-022 once they exist) and
a one-line-per-run
status. - Guards: thin old checkpoints so spacing grows with age, stop cleanly when free disk drops below 20 GB, stop when memory use passes a cap, and stop when the world is dead.
- When a run finishes or fails, send one message to the orchestrator thread with
t3 thread send, starting with[long-run], giving the run name, the outcome and the path of its summary. Copy the pattern inscripts/watchdog.sh. - A summary file per run, written at the end: what happened, in numbers, with charts.
docs/LONG-RUNS.md: how to start one, read one and clean up after one.
Done when
- ☐ A test run survives
kill -9and a launchd restart, and its final state equals an uninterrupted run with the same seed. - ☐
pausefrees the cores within seconds andresumecontinues correctly. - ☐ Checkpoint thinning and the disk guard are shown working.
- ☐ The finish message arrives. Test it against a file, not the real thread, until the last check.
Notes
- Use only pieces that exist when you start. If T-022 has not merged, leave a clear hook for its measures.
Added 2026-12-02: what the runner already does (from T-012)
runner run,resume,info,packandunpackexist, with atomic checkpoints, thinning by age, clean stops on signals and exact resume afterkill -9. Readdocs/RUNS.mdand build on it. Do not write a second copy of any of it in shell.- A build whose settings or saved-state versions differ refuses to continue a run. Main will change many times during a run that lasts days. Decide how a long run survives that and write it down. One simple way is to keep the exact program that started the run inside the run folder and always resume with it.
--every autopicks the checkpoint interval from the speed in the first 2 seconds. A world that grows slows down, so check that the interval still makes sense days later.
Added 2026-12-02: publishing and speed tools now exist (from T-020 and T-050)
scripts/publish-run.sh runs/NAMEputs a run on alife-runs.pages.dev and prints a link that opens it in the browser (docs/RUNS.md, "Publishing a run"). A long run should publish itself every few hours without a model, so Evan can open the latest state from his phone. Each publish keeps earlier states linked: decide how many to keep.scripts/perf.shanddocs/perf/README.md: the runner can report instructions, cycles and memory for a process. Use them for the time series instead of writing new probes.- A long run on this busy machine gets a median of 39 against a best of 89 steps per second on one thread. T-063 looks at whether a higher scheduling class helps. Leave a setting for it.
Added 2026-12-02: the lineage log exists (from T-019)
- A run folder now has
lineage/with births, deaths, genomes and a census (docs/RUNS.md). Thelineagetool incrates/analysishassummary,check,ancestors,treeandcensus. Uselineage checkas a health test for a long run, andsummaryfor the time series. - Size: about 13 bytes per birth with unchanged genomes, 45 with mutated ones. A billion births is about 45 GB. The disk guard has to count the log, not only checkpoints.
- Testbed churn makes the number of organisms grow without limit (a 20,000-cell soup reached 500,000 organisms by step 16,000). Do not use long churn runs as a stand-in for a living world when testing: they measure that growth.
Result
scripts/longrun.sh (start, status, list, pause, resume, stop, plus publish,
summary, remove, budget, notify-test), documented in docs/LONG-RUNS.md. The work is
in scripts/longrun.py; scripts/longrun-selftest.sh tests it end to end with real launchd
jobs. No Rust code changed. scripts/publish-run.sh now takes RUNNER= and VIEWER= from
the environment so a long run publishes with its own programs.
How it works, in short: one launchd job per seed runs a supervisor (a copy of
longrun.py kept in the run's folder). The supervisor runs the run's own copy of runner
at utility priority under caffeinate, samples it every minute into series.tsv,
applies the guards, publishes every 6 hours, and at the end writes summaries with charts
and sends one [long-run] message. Runs live in ~/.alife/longruns/NAME/, outside every
checkout.
Done when:
- ☑ Survives
kill -9and a launchd restart, final state equal to an uninterrupted run: the self-test kills the runner (kill -9), kills the supervisor (kill -9, launchd restarts it and it takes over the runner left behind), restarts the job (launchctl kickstart -k), unloads and loads it (as at logout and login), and pauses and resumes it. Final state hashef621bd9e901e9b6equals an uninterruptedrunner runon another thread count; the final checkpoint, all four lineage files andlogs/stats.tsvare byte-identical. A real reboot was not tried. - ☑
pausefrees the cores within seconds: runner gone 0.2 to 1.1 s afterpause, no runner process left, job unloaded;resumecontinues (and the exact-state check above includes a pause and resume). - ☑ Thinning and the disk guard shown: a run with
--every 100 --per-doubling 2over 400 intervals kept 18 checkpoints (the rule predicts about 19), growing 10, 12, 13, 14, 15, 15, 16, 17, 17, 17, 18 over the run; the disk guard stopped a run cleanly when a 6 GB file pushed free space under its floor (checkpoint saved, message sent). Also shown: memory cap, dead world, wall-time limit, crash loop (failedafter 3 tries), checkpoint-interval retune (every 10,000 to 500 when one interval took 24 s against an aim of 1.2 s). - ☑ The finish message: tested against a file throughout (one message per run, 6 of 6),
then one short test message to the real thread (
longrun.sh notify-test).
Decisions (each written in docs/LONG-RUNS.md):
- Main changing under a run: a run keeps its own
runner,lineageand supervisor inNAME/bin/, copied atstart, and always resumes with them.resume --rebuildmoves a run to a newer build on purpose. - Disk guard: counts free space on the volume (floor 20 GB plus twice the newest checkpoint), not the run's own size; the run's checkpoints and lineage log are recorded every minute so the summary shows which grows.
- Publishing: every 6 hours and at the end, 6 states per publish (newest plus five spread across the run), replacing the previous publish of the same run. No thumbnail by default (it needs the native viewer; never built by an unattended job).
- Priority:
utilityby default (measured: about 80% of normal speed on a busy machine;background10 to 50%). Thread budget of 6 for all long runs together. - One message per run, when its last seed ends; a seed failing or stopped by a guard while others run reports at once.