spdl.autoresearch.core.WorkflowProtocol¶
- class WorkflowProtocol(*args, **kwargs)[source]¶
Protocol for domain-specific adapters that drive the work engine.
Implementations must provide
load,checkpoint,make_coro,on_result, andsummarize.Methods
checkpoint(queued, running, status)Persist the current scheduler state.
load()Return the initial list of work specs to process.
make_coro(spec)Create the coroutine that executes a work spec.
on_result(spec, result)Process a completed result and return specs to enqueue.
summarize(workdir)Return a human-readable summary of the workdir state.
- checkpoint(queued: list[TaskSpec], running: list[TaskSpec], status: str) None[source]¶
Persist the current scheduler state.
Called on every engine loop iteration and on interruption.
statusis one of"running","stopped", or"interrupted".
- load() list[TaskSpec][source]¶
Return the initial list of work specs to process.
Called once at the start of
Orchestrator.runwhen noinitial_specsare provided. Typically reads from a checkpoint file to resume interrupted work.
- make_coro(spec: TaskSpec) Coroutine[Any, Any, TaskResult][source]¶
Create the coroutine that executes a work spec.
The returned coroutine is scheduled as an
asyncio.Task. It should return aTaskResultwhosechildrenfield contains any follow-up specs to enqueue.
- async on_result(spec: TaskSpec, result: TaskResult) list[TaskSpec][source]¶
Process a completed result and return specs to enqueue.
Called after a work coroutine finishes. The adapter can filter duplicates, update persistent state, or transform the result’s children before they enter the priority queue.
- summarize(workdir: Path) str[source]¶
Return a human-readable summary of the workdir state.
Required. Must be safe to call at any time — before any run, in the middle of a run, after a paused or interrupted run, and after a clean exit. The framework calls this method to handle
autoresearch summary <wd>invocations on demand and writes the result to<wd>/report.mdautomatically when the engine exits cleanly.Implementations should render the summary deterministically from durable workdir state (master tables, summary files, recorded failures), without invoking long-running operations such as coding-agent calls.