approval

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package approval is the human-in-the-loop tool-approval seam: a turn that hits a not-pre-authorized tool emits an approval_request and blocks on the Broker until an inbound approve/deny control resolves it (or the turn's context/timeout fires). It mirrors turncancel.Canceller — an inbound control reaching an in-flight turn — and is shared between the transport (which calls Resolve on inbound) and the turn runner (which calls Await).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Awaiter

type Awaiter interface {
	Await(ctx context.Context, taskID, requestID string) (Decision, error)
}

Awaiter is the turn-facing surface: block until a decision for (taskID, requestID) arrives. The runner wraps the call in the approval timeout.

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

Broker correlates pending approval requests with inbound decisions, keyed by (taskID, requestID). Safe for concurrent use.

func New

func New() *Broker

func (*Broker) Await

func (b *Broker) Await(ctx context.Context, taskID, requestID string) (Decision, error)

Await registers a waiter for (taskID, requestID) and blocks until Resolve delivers a decision or ctx is done (cancel/timeout). The waiter is always cleaned up. A nil broker blocks only on ctx (no decision can arrive).

func (*Broker) Resolve

func (b *Broker) Resolve(taskID, requestID string, d Decision) bool

Resolve delivers a decision to a pending Await for (taskID, requestID). Returns true if a waiter received it (false when none is pending — a stale or duplicate response, which is a harmless no-op).

type Decision

type Decision struct {
	Granted bool
	// Scope is the grant breadth the user chose: "once" | "session" | "always".
	// Empty/ignored when Granted is false.
	Scope string
}

Decision is the outcome of an approval request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL