approval

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInput

type CreateInput struct {
	ToolName string
	ArgsJSON string
	Reason   string
	TTL      time.Duration
}

CreateInput contains fields needed to create an approval request.

type DecisionInput

type DecisionInput struct {
	DecidedBy string
	Note      string
}

DecisionInput contains fields needed to approve/reject a request.

type Query

type Query struct {
	ID       string
	Status   RequestStatus
	ToolName string
}

Query filters approval requests when listing.

type Request

type Request struct {
	ID           string        `json:"id"`
	ToolName     string        `json:"tool_name"`
	ArgsJSON     string        `json:"args_json"`
	Reason       string        `json:"reason,omitempty"`
	DecisionNote string        `json:"decision_note,omitempty"`
	Status       RequestStatus `json:"status"`
	RequestedAt  time.Time     `json:"requested_at"`
	ExpiresAt    time.Time     `json:"expires_at,omitempty"`
	DecidedAt    time.Time     `json:"decided_at,omitempty"`
	DecidedBy    string        `json:"decided_by,omitempty"`
}

Request is a persisted approval request record.

type RequestStatus

type RequestStatus string

RequestStatus is the lifecycle state of an approval request.

const (
	StatusPending  RequestStatus = "pending"
	StatusApproved RequestStatus = "approved"
	StatusRejected RequestStatus = "rejected"
	StatusExpired  RequestStatus = "expired"
)

type Service

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

Service orchestrates approval lifecycle operations.

func NewService

func NewService(workspace string) *Service

NewService creates a service backed by <workspace>/state/approvals.json.

func (*Service) Approve

func (s *Service) Approve(id string, decision DecisionInput) (Request, error)

Approve marks a pending request as approved.

func (*Service) Create

func (s *Service) Create(input CreateInput) (Request, error)

Create inserts a new pending approval request.

func (*Service) ExpirePending

func (s *Service) ExpirePending() ([]Request, error)

ExpirePending marks pending requests as expired when TTL has elapsed.

func (*Service) List

func (s *Service) List(query Query) ([]Request, error)

List returns requests filtered by query values.

func (*Service) Reject

func (s *Service) Reject(id string, decision DecisionInput) (Request, error)

Reject marks a pending request as rejected.

type Store

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

Store persists approval requests to disk.

func NewStore

func NewStore(workspace string) *Store

NewStore creates an approval store under <workspace>/state/approvals.json.

func (*Store) Load

func (s *Store) Load() (fileData, error)

Load reads persisted data from disk.

func (*Store) Save

func (s *Store) Save(data fileData) error

Save writes persisted data to disk.

Jump to

Keyboard shortcuts

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