Repository navigation
Expand file tree
/
Copy pathIConfirmationGate.cs
More file actions
64 lines (58 loc) · 2.1 KB
/
Copy pathIConfirmationGate.cs
File metadata and controls
64 lines (58 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MissionController.Core.Interfaces;
/// <summary>
/// A pending confirmation for a state-mutating tool call. The calling agent sees the summary
/// and presents it to the human operator; the operator approves or lets it expire.
/// </summary>
public sealed record PendingConfirmation(
string Token,
string ToolName,
string Summary,
string MutationVerb,
string EgressTarget,
string? SecretScope,
DateTimeOffset ExpiresUtc,
string RequestingActor)
{
/// <summary>Hash of the serialised EXECUTE_TOOL frame this token is bound to.</summary>
public required string RequestHash { get; init; }
}
public enum ConfirmationOutcome
{
Granted,
Expired,
AlreadyConsumed,
NotFound,
RequestMismatch
}
/// <summary>
/// Human-in-the-loop gate for state-mutating leases. A RequiresConfirmation template cannot
/// dispatch until an operator has approved the exact request through this gate.
/// </summary>
public interface IConfirmationGate
{
/// <summary>
/// Create a pending confirmation for a tool call. Returns the token the caller must present
/// to <see cref="ConsumeAsync"/> after human approval.
/// </summary>
Task<PendingConfirmation> RequestAsync(
string toolName,
string summary,
string mutationVerb,
string egressTarget,
string? secretScope,
string requestHash,
string actor,
TimeSpan? ttl = null,
CancellationToken ct = default);
/// <summary>
/// Consume a confirmation token. Single-use: a second call returns <see cref="ConfirmationOutcome.AlreadyConsumed"/>.
/// The requestHash must match the one the token was created with.
/// </summary>
Task<ConfirmationOutcome> ConsumeAsync(string token, string requestHash, CancellationToken ct = default);
/// <summary>All pending (unconsumed, unexpired) confirmations for the given actor.</summary>
Task<IReadOnlyList<PendingConfirmation>> ListPendingAsync(string actor, CancellationToken ct = default);
}