spdl.autoresearch.core.TaskSpec

class TaskSpec(id: str, priority: float = 0.0, kind: str = 'default', payload: dict[str, object] = <factory>)[source]

Serializable unit of work for the async engine.

Methods

from_dict(data)

Reconstruct a TaskSpec from a dictionary.

to_dict()

Serialize this spec to a JSON-compatible dictionary.

Attributes

kind

Category tag used by the adapter to distinguish spec types without inspecting the payload.

priority

Scheduling priority.

id

Unique identifier for this work item.

payload

Arbitrary key-value data that travels with the spec through the engine lifecycle (enqueue → checkpoint → make_coro → on_result).

classmethod from_dict(data: dict[str, object]) TaskSpec

Reconstruct a TaskSpec from a dictionary.

Missing keys fall back to field defaults. A non-dict payload value is replaced with an empty dictionary.

Parameters:

data – Dictionary previously produced by to_dict().

Returns:

A new TaskSpec instance.

id: str

Unique identifier for this work item.

kind: str = 'default'

Category tag used by the adapter to distinguish spec types without inspecting the payload. For example, the SPDL workflow sets this to "experiment" so the policy layer can filter experiment specs from other internal bookkeeping specs.

payload: dict[str, object]

Arbitrary key-value data that travels with the spec through the engine lifecycle (enqueue → checkpoint → make_coro → on_result). The adapter stores domain-specific state here — for example, the SPDL workflow stores the full HypothesisNode dict under payload["node"].

priority: float = 0.0

Scheduling priority. Lower values are dequeued first. The engine uses a min-heap, so priority=-1000 runs before priority=0.

to_dict() dict[str, object]

Serialize this spec to a JSON-compatible dictionary.

Returns:

A dictionary with keys "id", "priority", "kind", and "payload".