gate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gate defines the extraction-ready vocabulary shared by durable human gates and checkpoints.

Gate declarations describe presentation and policy subjects; they never embed product approver lists or authenticate responders. Applications own presentation, payload persistence, and authority resolution through the interfaces in this package. Durable suspension and resume remain owned by workflow/wait and the runtime wait coordinator.

This package may import only extraction-safe workflow contracts and the Go standard library. Its exported vocabulary is stable; concrete application policy and UI models must remain outside workflow/.

Index

Constants

View Source
const (
	PolicyEnvironment   = "environment"
	AuthorityGatePolicy = "gate_policy"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorityResolver

type AuthorityResolver interface {
	ResolveGateAuthority(context.Context, AuthorizationRequest) (workflowwait.ResponderAuthority, error)
}

AuthorityResolver selects the durable responder authority enforced by the runtime's generic resume authorizer. Implementations must be concurrency-safe and must not return bearer credentials in Authority fields.

type AuthorityResolverFunc

AuthorityResolverFunc adapts a function to AuthorityResolver.

func (AuthorityResolverFunc) ResolveGateAuthority

ResolveGateAuthority implements AuthorityResolver.

type AuthorizationRequest

type AuthorizationRequest struct {
	RunID      string     `json:"run_id"`
	NodeID     string     `json:"node_id"`
	Iteration  string     `json:"iteration,omitempty"`
	Attempt    int        `json:"attempt"`
	Checkpoint Checkpoint `json:"checkpoint"`
}

AuthorizationRequest supplies a validated immutable checkpoint to an application-owned authority resolver. Identity values are opaque execution references and must not be interpreted by workflow core.

type Behavior

type Behavior struct {
	Optional bool `json:"optional"`
	Blocking bool `json:"blocking"`
}

Behavior describes whether a manual gate is required and whether it blocks graph readiness. Non-blocking gates must be optional. The v1 human-gate executor intentionally rejects non-blocking behavior because W07-T09 owns lowering it to ordinary wait/readiness graph semantics.

func (Behavior) Validate

func (b Behavior) Validate() error

Validate rejects the incoherent required-but-non-blocking combination.

type Checkpoint

type Checkpoint struct {
	Prompt       string                 `json:"prompt"`
	Options      []Option               `json:"options"`
	ResumeSchema workflowwait.SchemaRef `json:"resume_schema"`
	Subject      PolicySubject          `json:"subject"`
	Correlation  string                 `json:"correlation"`
	Behavior     Behavior               `json:"behavior"`
	Escalations  []Escalation           `json:"escalations,omitempty"`
}

Checkpoint is the immutable application-neutral gate declaration. Resume schema is digest-bound and must accept an object containing the selected decision. Prompt and options are suitable for a private gate payload; they are not responder credentials.

func CloneCheckpoint

func CloneCheckpoint(checkpoint Checkpoint) Checkpoint

CloneCheckpoint returns a defensive copy suitable for passing to a host.

func (Checkpoint) Validate

func (c Checkpoint) Validate() error

Validate checks the complete shared gate contract deterministically.

type Escalation

type Escalation struct {
	After   string        `json:"after"`
	Subject PolicySubject `json:"subject"`
}

Escalation is portable escalation vocabulary. After is a positive Go duration string; Subject identifies policy, routing, or notification logic supplied by an application.

func (Escalation) Validate

func (e Escalation) Validate() error

Validate checks the bounded escalation declaration without performing it.

type Option

type Option struct {
	ID    string     `json:"id"`
	Label string     `json:"label"`
	Kind  OptionKind `json:"kind,omitempty"`
}

Option is one stable decision that a presentation layer may render. IDs are workflow data; labels are presentation text. Product-specific UI metadata is intentionally absent.

func (Option) Validate

func (o Option) Validate() error

Validate checks the portable option declaration.

type OptionKind

type OptionKind string

OptionKind distinguishes an ordinary decision from the explicit skip path required by an optional blocking gate.

const (
	OptionDecision OptionKind = "decision"
	OptionSkip     OptionKind = "skip"
)

func (OptionKind) Valid

func (k OptionKind) Valid() bool

Valid reports whether k belongs to the closed gate option vocabulary.

type PayloadRequest

type PayloadRequest struct {
	RunID      string     `json:"run_id"`
	NodeID     string     `json:"node_id"`
	Iteration  string     `json:"iteration,omitempty"`
	Attempt    int        `json:"attempt"`
	Checkpoint Checkpoint `json:"checkpoint"`
}

PayloadRequest describes private checkpoint material to store before a wait is suspended. The returned immutable reference enters wait.Record.Payload.

type PayloadStore

type PayloadStore interface {
	StoreGatePayload(context.Context, PayloadRequest) (values.ValueSetRef, error)
}

PayloadStore persists prompt/options as a private, run-retained value set. Implementations must be concurrency-safe and idempotent for the same immutable PayloadRequest, returning the same immutable ref on executor retries. The host owns cleanup for a ref stored before durable suspension.

type PayloadStoreFunc

type PayloadStoreFunc func(context.Context, PayloadRequest) (values.ValueSetRef, error)

PayloadStoreFunc adapts a function to PayloadStore.

func (PayloadStoreFunc) StoreGatePayload

func (f PayloadStoreFunc) StoreGatePayload(ctx context.Context, request PayloadRequest) (values.ValueSetRef, error)

StoreGatePayload implements PayloadStore.

type PolicySubject

type PolicySubject struct {
	Kind       string            `json:"kind"`
	Reference  string            `json:"reference"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

PolicySubject names application-owned policy without embedding its rules. Environment-bound gates use Kind=environment and Reference=<environment>.

func (PolicySubject) Validate

func (s PolicySubject) Validate() error

Validate checks that a policy subject is stable and transport-safe.

Jump to

Keyboard shortcuts

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