Skip to content

manager

diapason.operators.manager

Operator manager — lifecycle management for autonomous operators.

OperatorManager

Manages operator manifests and their lifecycle via the TaskScheduler.

Parameters

system: A DiapasonSystem instance (used to access scheduler, session_store, memory_backend, and to run operators via system.ask()).

manifests property

All registered manifests.

activate(operator_id)

Activate an operator by creating a scheduler task.

Returns the scheduler task ID (deterministic: operator:{id}). Raises KeyError if the operator is not registered, or RuntimeError if the scheduler is not available.

collect_metrics(operator_id, *, since=None, until=None)

Collect telemetry metrics declared in the operator's manifest.

Reads the metrics list from :class:OperatorManifest and queries the system's TelemetryAggregator (when available) for matching statistics. Only fields explicitly listed in manifest.metrics are returned, giving operators fine-grained control over what data they expose.

Parameters

operator_id: ID of the registered operator. since: Optional Unix timestamp; restrict stats to records after this time. until: Optional Unix timestamp; restrict stats to records before this time.

Returns

Dict[str, Any] Mapping of {metric_name: value} for every metric declared in the manifest that could be resolved. Unknown metric names are silently skipped and logged at DEBUG level.

Raises

KeyError If operator_id is not registered.

deactivate(operator_id)

Deactivate an operator by cancelling its scheduler task.

discover(directory)

Discover and register operator manifests from a directory.

Scans for *.toml files in directory and loads each as an operator manifest.

get_manifest(operator_id)

Return the manifest for an operator, or None.

pause(operator_id)

Pause an active operator.

register(manifest)

Register an operator manifest.

resume(operator_id)

Resume a paused operator.

run_once(operator_id)

Execute a single tick of an operator immediately.

Useful for development and testing. Returns the agent's response.

status()

Return status of all registered operators.

Merges manifest info with scheduler task state.