Skip to content

IPendingApprovalStore

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

The store for pending approval requests.

public interface IPendingApprovalStore

IPendingApprovalStore.ListPendingAsync, IPendingApprovalStore.GetAsync and IPendingApprovalStore.DecideAsync are limited to the tenant of the caller (ITenantContext): the operator of one tenant can neither see nor decide the approvals of another tenant. IPendingApprovalStore.ExpireAsync is a maintenance operation and scans every tenant — the same reason as IRunStore.ClaimOrphanedRunsAsync.

CreateAsync(PendingApproval, CancellationToken)

Section titled “ CreateAsync(PendingApproval, CancellationToken)”

Creates a new pending approval request.

ValueTask CreateAsync(PendingApproval approval, CancellationToken cancellationToken = default)

approval PendingApproval

The request to save. PendingApproval.Status must be ApprovalStatus.Pending.

cancellationToken CancellationToken

The cancellation token.

ValueTask

DecideAsync(Guid, bool, string, DateTimeOffset, CancellationToken)

Section titled “ DecideAsync(Guid, bool, string, DateTimeOffset, CancellationToken)”

Writes a decision on a pending request.

ValueTask<bool> DecideAsync(Guid id, bool approved, string decidedBy, DateTimeOffset decidedAt, CancellationToken cancellationToken = default)

id Guid

The request id.

approved bool

Whether the request is approved.

decidedBy string

The actor that made the decision.

decidedAt DateTimeOffset

The time of the decision.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true when the decision is written; false when the request is not found in the caller’s tenant or is no longer in the ApprovalStatus.Pending state (a second decision is rejected silently).

ExpireAsync(DateTimeOffset, int, CancellationToken)

Section titled “ ExpireAsync(DateTimeOffset, int, CancellationToken)”

Closes the requests that expired before olderThan and are still in the ApprovalStatus.Pending state, marking them ApprovalStatus.Expired.

ValueTask<IReadOnlyList<PendingApproval>> ExpireAsync(DateTimeOffset olderThan, int max, CancellationToken cancellationToken = default)

olderThan DateTimeOffset

Requests that expired before this time are closed (UTC).

max int

The upper number of requests closed in this round.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<PendingApproval>>

The records of the closed requests.

[TenantAgnostic]: this is maintenance work and scans the expired requests of every tenant; filtering by the ambient tenant would leave the requests of the other tenants ApprovalStatus.Pending forever.

Returns a single pending approval request.

ValueTask<PendingApproval?> GetAsync(Guid id, CancellationToken cancellationToken = default)

id Guid

The request id.

cancellationToken CancellationToken

The cancellation token.

ValueTask<PendingApproval?>

The request, or null when it is not found in the caller’s tenant.

Lists the pending requests of the caller’s tenant, ordered from oldest to newest.

ValueTask<IReadOnlyList<PendingApproval>> ListPendingAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<PendingApproval>>