Pixir.Delegate.Async (pixir v0.1.7)

Copy Markdown View Source

Async/liveness helpers for pixir delegate service commands.

This module is intentionally not a second scheduler. It projects delegate state from the durable Session Log for status, and uses the existing Subagent Manager only for bounded lifecycle actions such as cancel. The Log remains the source of truth; Manager access is live-handle evidence that may be unavailable after a process restart.

TODO(delegate-service-v1)

Grow this into richer daemon/IPC-backed attach progress once Delegate needs cross-invocation streaming observation. Current owner-backed start, status, attach, and cancel can report daemon residency when routed through a manual workspace daemon, but attach remains a bounded snapshot rather than a stream.

The next slice should preserve the current split:

  • status stays a durable Log projection and must remain useful after restart;
  • cancel should route through a live Delegate owner when one exists, and report an explicit owner_unavailable/stale_handle shape when it cannot affect running children;
  • attach should stream or snapshot progress without polling through shell loops;
  • response metadata should separate "request accepted" from "work complete" so long-running service clients do not treat ok: false running snapshots as errors.

Summary

Functions

Attach to Delegate evidence by returning a bounded durable snapshot.

Cancel live Subagent children for a Delegate handle when the Manager has handles.

Start a Delegate run with a current-runtime owner.

Return a durable Delegate status snapshot for a Delegate handle or parent Session.

Functions

attach(handle_or_session_id, opts \\ [])

@spec attach(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}

Attach to Delegate evidence by returning a bounded durable snapshot.

cancel(handle_or_session_id, opts \\ [])

@spec cancel(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}

Cancel live Subagent children for a Delegate handle when the Manager has handles.

start(request, spec, spec_meta, opts \\ [])

@spec start(map(), map(), map(), keyword()) :: {:ok, map()} | {:error, map()}

Start a Delegate run with a current-runtime owner.

status(handle_or_session_id, opts \\ [])

@spec status(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, map()}

Return a durable Delegate status snapshot for a Delegate handle or parent Session.