refinery

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package refinery implements a deterministic merge queue loop inside pogod.

The refinery is NOT an agent. It is a mechanical loop that picks up merge-ready branches from polecats, runs quality gates (build, test, lint), and either fast-forward merges to main or rejects with notification.

It maintains its own git worktrees under ~/.pogo/refinery/worktrees/ and never touches agent or user working directories.

Index

Constants

View Source
const DefaultPollInterval = 30 * time.Second

DefaultPollInterval is how often the refinery checks for new merge requests.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Enabled controls whether the refinery loop runs.
	Enabled bool
	// PollInterval is how often the loop checks for queued items.
	PollInterval time.Duration
	// WorktreeDir is where the refinery creates git worktrees.
	// Default: ~/.pogo/refinery/worktrees/
	WorktreeDir string
}

Config holds refinery configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type MergeRequest

type MergeRequest struct {
	ID         string      `json:"id"`
	RepoPath   string      `json:"repo_path"`
	Branch     string      `json:"branch"`
	TargetRef  string      `json:"target_ref"` // e.g. "main"
	Author     string      `json:"author"`     // agent name that submitted
	Status     MergeStatus `json:"status"`
	SubmitTime time.Time   `json:"submit_time"`
	DoneTime   time.Time   `json:"done_time,omitempty"`
	Error      string      `json:"error,omitempty"`
	GateOutput string      `json:"gate_output,omitempty"`
}

MergeRequest represents a branch submitted for merging.

type MergeStatus

type MergeStatus string

MergeStatus represents the outcome of a merge attempt.

const (
	StatusQueued     MergeStatus = "queued"
	StatusProcessing MergeStatus = "processing"
	StatusMerged     MergeStatus = "merged"
	StatusFailed     MergeStatus = "failed"
)

type OnFailed

type OnFailed func(mr *MergeRequest)

OnFailed is called when a merge attempt fails quality gates.

type OnMerged

type OnMerged func(mr *MergeRequest)

OnMerged is called when a branch is successfully merged.

type Refinery

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

Refinery is the merge queue loop.

func New

func New(cfg Config) (*Refinery, error)

New creates a new Refinery with the given config.

func (*Refinery) Get

func (r *Refinery) Get(id string) *MergeRequest

Get returns a merge request by ID, or nil if not found.

func (*Refinery) GetStatus

func (r *Refinery) GetStatus() Status

GetStatus returns the current refinery status.

func (*Refinery) History

func (r *Refinery) History() []MergeRequest

History returns a snapshot of completed merge requests (most recent first).

func (*Refinery) Queue

func (r *Refinery) Queue() []MergeRequest

Queue returns a snapshot of queued merge requests.

func (*Refinery) RegisterHandlers

func (r *Refinery) RegisterHandlers(mux *http.ServeMux)

RegisterHandlers registers refinery API endpoints on the given mux.

func (*Refinery) SetOnFailed

func (r *Refinery) SetOnFailed(fn OnFailed)

SetOnFailed sets the callback for failed merge attempts.

func (*Refinery) SetOnMerged

func (r *Refinery) SetOnMerged(fn OnMerged)

SetOnMerged sets the callback for successful merges.

func (*Refinery) Start

func (r *Refinery) Start(ctx context.Context)

Start begins the merge queue loop. Blocks until ctx is cancelled or Stop is called.

func (*Refinery) Stop

func (r *Refinery) Stop()

Stop signals the refinery loop to exit.

func (*Refinery) Submit

func (r *Refinery) Submit(req MergeRequest) (string, error)

Submit adds a merge request to the queue. Returns the assigned ID.

type Status

type Status struct {
	Enabled      bool   `json:"enabled"`
	Running      bool   `json:"running"`
	PollInterval string `json:"poll_interval"`
	QueueLen     int    `json:"queue_len"`
	HistoryLen   int    `json:"history_len"`
}

Status returns a summary of the refinery state.

type SubmitRequest

type SubmitRequest struct {
	RepoPath  string `json:"repo_path"`
	Branch    string `json:"branch"`
	TargetRef string `json:"target_ref,omitempty"` // default: "main"
	Author    string `json:"author,omitempty"`
}

SubmitRequest is the JSON body for POST /refinery/submit.

Jump to

Keyboard shortcuts

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