spdl.autoresearch.core.write_engine_state¶
- write_engine_state(workdir: Path, *, queued: list[TaskSpec], running: list[TaskSpec], status: str) None[source]¶
Persist the orchestrator’s queued, running, and status fields.
Writes
<workdir>/engine_state.json(creating<workdir>if needed). Specs are serialized viaTaskSpec.to_dict(), so they round-trip throughread_engine_state().The write is atomic from a reader’s perspective: the JSON payload is written to a sibling temp file under
<workdir>and then moved into place viaos.replace(). If the process is interrupted mid-write,engine_state.jsoneither still holds the previous valid checkpoint or — on the very first checkpoint — is simply absent. It is never observed truncated or partially written, soread_engine_state()cannot fail withjson.JSONDecodeErrorfrom corrupt content on resume.- Parameters:
workdir – Directory in which to persist the JSON file.
queued – Specs currently waiting in the priority queue.
running – Specs currently scheduled as coroutines.
status – One of
"running","stopped", or"interrupted", matching the valuesOrchestrator.runpasses tocheckpoint.
- Returns:
None.