gate

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 15 Imported by: 1

README

axon-gate

Domain package · Part of the lamina workspace

Deploy approval gate with Signal notifications. Creates time-limited approval requests, notifies operators via Signal, and serves a web UI for reviewing and approving deployments. Agents or CI pipelines request approval via the API, then poll for a decision while a human reviews and responds through the approval page.

Getting started

go get github.com/benaskins/axon-gate@latest

Requires Go 1.26+.

axon-gate is a domain package — it provides HTTP handlers and domain types that you wire into your own composition root. See example/main.go for a minimal setup.

store := gatetest.NewMemoryApprovalStore()
signal := gate.NewSignalClient(signalAPIURL, recipientNumber)
handler := gate.NewHandler(store, signal, authClient, baseURL, loginURL)

mux.HandleFunc("POST /api/approvals", handler.CreateApproval)
mux.HandleFunc("GET /api/approvals/{id}", handler.GetApproval)
mux.HandleFunc("POST /api/notifications", handler.SendNotification)
mux.HandleFunc("GET /approve/{id}", handler.ShowApprovalPage)
mux.HandleFunc("POST /approve/{id}", handler.ProcessApproval)

Key types

  • Approval, ApprovalRequest — approval domain types with status tracking and expiry
  • ApprovalStore — persistence interface (Create, Get, Resolve)
  • SignalClient — sends notifications via Signal REST API
  • Handler — HTTP handler with API endpoints and an embedded web UI
  • gatetest.MemoryApprovalStore — in-memory store for testing

License

MIT

Documentation

Overview

Package gate provides a deploy approval gate service. It creates time-limited approval requests, notifies operators via Signal, and serves a web UI for reviewing and approving deployments.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = axon.ErrNotFound
	ErrAlreadyResolved = errors.New("approval already resolved")
)

Functions

func GenerateID

func GenerateID() (string, error)

func GenerateToken

func GenerateToken() (string, error)

Types

type Approval

type Approval struct {
	ID         string         `json:"id"`
	Service    string         `json:"service"`
	Commit     string         `json:"commit"`
	Branch     string         `json:"branch"`
	Summary    string         `json:"summary"`
	Agent      string         `json:"agent"`
	Username   string         `json:"username"`
	Token      string         `json:"-"`
	Status     ApprovalStatus `json:"status"`
	CreatedAt  time.Time      `json:"created_at"`
	ExpiresAt  time.Time      `json:"expires_at"`
	ResolvedAt *time.Time     `json:"resolved_at"`
	ResolvedBy string         `json:"resolved_by,omitempty"`
}

Approval represents a deploy approval request with status tracking and expiry.

type ApprovalRequest

type ApprovalRequest struct {
	Service  string `json:"service"`
	Commit   string `json:"commit"`
	Branch   string `json:"branch"`
	Summary  string `json:"summary"`
	Agent    string `json:"agent"`
	Username string `json:"username"`
}

ApprovalRequest is the input for creating a new approval.

type ApprovalStatus

type ApprovalStatus string
const (
	StatusPending  ApprovalStatus = "pending"
	StatusApproved ApprovalStatus = "approved"
	StatusDenied   ApprovalStatus = "denied"
)

type ApprovalStore

type ApprovalStore interface {
	Create(ctx context.Context, req ApprovalRequest) (*Approval, error)
	Get(ctx context.Context, id string) (*Approval, error)
	Resolve(ctx context.Context, id string, status ApprovalStatus, resolvedBy string) error
}

ApprovalStore defines the persistence interface for approvals.

type Handler

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

Handler serves the approval API endpoints and embedded web UI.

func NewHandler

func NewHandler(store ApprovalStore, signal *SignalClient, authClient *axon.AuthClient, baseURL, loginURL string) *Handler

func (*Handler) CreateApproval

func (h *Handler) CreateApproval(w http.ResponseWriter, r *http.Request)

CreateApproval handles POST /api/approvals — create approval, send Signal message.

func (*Handler) GetApproval

func (h *Handler) GetApproval(w http.ResponseWriter, r *http.Request)

GetApproval handles GET /api/approvals/{id} — poll approval status. Returns only the status to avoid leaking metadata to unauthenticated callers.

func (*Handler) ProcessApproval

func (h *Handler) ProcessApproval(w http.ResponseWriter, r *http.Request)

ProcessApproval handles POST /approve/{id} — process approval decision.

func (*Handler) SendNotification

func (h *Handler) SendNotification(w http.ResponseWriter, r *http.Request)

SendNotification handles POST /api/notifications — send informational Signal message.

func (*Handler) ShowApprovalPage

func (h *Handler) ShowApprovalPage(w http.ResponseWriter, r *http.Request)

ShowApprovalPage handles GET /approve/{id} — serve approval page.

type SignalClient

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

SignalClient sends notifications via the Signal REST API.

func NewSignalClient

func NewSignalClient(apiURL, recipient string) *SignalClient

func (*SignalClient) Send

func (c *SignalClient) Send(message string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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