Path: redb-route/redb.Route.Llm/Engine/Governance/IApprovalGate.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Engine/Governance/IApprovalGate.cs ---- using redb.Route.Abstractions; using redb.Route.Llm.Abstractions.Tools; namespace redb.Route.Llm.Engine.Governance; /// /// Gate that blocks a tool call until an approver responds. The agent loop calls /// before dispatching a tool whose /// is set — that flag is the only trigger in this /// release; a tool's side-effect class does not reach the gate on its own. /// public interface IApprovalGate { /// /// Awaits an approval decision for the given tool call. /// /// Pending approval request. /// Cancellation token. /// The approver's decision. Task AwaitAsync(ApprovalRequest request, CancellationToken ct = default); } /// Pending tool-call approval request handed to the gate. public sealed class ApprovalRequest { /// Conversation identifier (when persistence is on). public string? ConversationId { get; init; } /// Tool that will be executed. public required LlmToolCapability Tool { get; init; } /// Tool input JSON exactly as it would be passed to the bridged endpoint. public required string InputJson { get; init; } /// Parent exchange owning the call (carries principal, headers, scope). public required IExchange Exchange { get; init; } /// Tool-use id from the model response — propagated to the approver and audit. public required string ToolUseId { get; init; } } /// Outcome of an approval decision. public sealed class ApprovalDecision { /// True = proceed with the tool call; false = abort. public required bool Approved { get; init; } /// Identifier of the approval (for audit / receipt). May be null. public string? ApprovalId { get; init; } /// Optional reason supplied by the approver (especially on rejection). public string? Reason { get; init; } /// Convenience factory for an auto-approval decision. public static ApprovalDecision Approve(string? approvalId = null) => new() { Approved = true, ApprovalId = approvalId }; /// Convenience factory for a denial decision. public static ApprovalDecision Deny(string reason) => new() { Approved = false, Reason = reason }; } /// /// Default gate that auto-approves every request — used in development and in /// fully-trusted scenarios. **Do not use in production** for tools with /// or . /// public sealed class AutoApproveGate : IApprovalGate { /// public Task AwaitAsync(ApprovalRequest request, CancellationToken ct = default) => Task.FromResult(ApprovalDecision.Approve("auto")); } /// /// Gate that denies every approval request. Opt-in: it is not registered by default /// (the shipped default is ), and nothing picks it up automatically /// when mutating tools are present. Swap it in explicitly when a host wants approvals to fail closed: /// services.Replace(ServiceDescriptor.Singleton<IApprovalGate, DenyAllGate>()); /// public sealed class DenyAllGate : IApprovalGate { /// public Task AwaitAsync(ApprovalRequest request, CancellationToken ct = default) => Task.FromResult(ApprovalDecision.Deny("no approval gate configured")); }