Skip to content

IRunCancellationRegistry

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

The in-memory registry of runs in progress on this instance; binds an incoming cancellation request to the running run’s CancellationTokenSource.

public interface IRunCancellationRegistry

The registry is in-process. In a multi-instance deployment, a request may land on the wrong instance; in that case the cancellation endpoint returns 409 Conflict. A setup that needs a distributed registry can replace this interface with its own implementation (TryAddSingleton).

Cancelling the root run (RunId == RootRunId) also cancels every record under the same RootRunId. Cancelling a single child run affects neither sibling branches nor the root.

The number of runs in progress on this instance. For diagnostics and tests.

int ActiveCount { get; }

int

The identifiers of the runs currently in progress on this instance.

IReadOnlyCollection<Guid> ActiveRunIds { get; }

IReadOnlyCollection<Guid>

RunHeartbeatWriter uses this list to write heartbeats only for runs THIS process is actually executing. Another instance marking a Running row as “alive” by mistake would defeat the entire purpose of reconciliation.

Register(Guid, Guid, string?, CancellationTokenSource)

Section titled “ Register(Guid, Guid, string?, CancellationTokenSource)”

Writes a running run into the registry.

IDisposable Register(Guid runId, Guid rootRunId, string? tenantId, CancellationTokenSource source)

runId Guid

The run’s identifier.

rootRunId Guid

The identifier of the run at the root of the tree. Equals runId for the root.

tenantId string?

The run’s tenant.

source CancellationTokenSource

The source that triggers the run’s cancellation. Ownership stays with the caller; this method does not dispose it.

IDisposable

The object to dispose to remove the record from the registry.

Requests a run’s cancellation. If it is the tree root, child runs are also cancelled.

bool TryCancel(Guid runId, string? tenantId)

runId Guid

The identifier of the run whose cancellation is requested.

tenantId string?

The requesting tenant. If it does not match the record’s tenant, the request is ignored.

bool

true if the cancellation request reached a record.