bellows

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package bellows monitors open PRs for status changes, CI results, and reviews.

Bellows periodically polls all open PRs in the state DB and updates their status. It triggers downstream actions: CI fix workers, review comment forwarding, and PR lifecycle state tracking.

Index

Constants

View Source
const (
	EventCIPassed       = "ci_passed"
	EventCIFailed       = "ci_failed"
	EventReviewApproved = "review_approved"
	EventReviewChanges  = "review_changes_requested"
	EventPRMerged       = "pr_merged"
	EventPRClosed       = "pr_closed"
	EventPRConflicting  = "pr_conflicting"
	EventPRReadyToMerge = "pr_ready_to_merge"
)

Event types emitted by the Bellows monitor.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(ctx context.Context, event PREvent)

Handler is called when a PR event is detected.

type Monitor

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

Monitor watches open PRs and dispatches events on status changes.

func New

func New(db *state.DB, interval time.Duration, anvilPaths map[string]string, autoLearnRules func() bool, maxCIFixAttempts func() int) *Monitor

New creates a Bellows monitor. The autoLearnRules function is called on each PR merge to check whether warden rule learning is enabled, so hot-reloaded config changes take effect without restarting the daemon. The maxCIFixAttempts function returns the current max CI fix attempts from config (may be nil, in which case the state.DefaultMaxCIFixAttempts is used).

func (*Monitor) OnEvent

func (m *Monitor) OnEvent(h Handler)

OnEvent registers a handler for PR events.

func (*Monitor) Refresh

func (m *Monitor) Refresh()

Refresh triggers an immediate poll cycle.

func (*Monitor) ResetPRState

func (m *Monitor) ResetPRState(anvil string, prNumber int)

ResetPRState clears the internal status cache for a PR. This should be called when a PR is manually reset so that status changes (e.g. from failing back to passing) are re-detected on the next poll cycle even if the state is the same as it was before the reset.

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context) error

Run starts the polling loop. Blocks until ctx is canceled.

func (*Monitor) UpdateAnvilPaths

func (m *Monitor) UpdateAnvilPaths(paths map[string]string)

UpdateAnvilPaths replaces the set of monitored anvil paths. This is safe to call while Run is active and takes effect on the next poll cycle.

type PREvent

type PREvent struct {
	PRNumber  int
	BeadID    string
	Anvil     string
	Branch    string
	EventType string
	Details   string
	Timestamp time.Time
	// PRURL is the GitHub URL of the PR, populated for events that need it
	// (e.g. pr_ready_to_merge).
	PRURL string
}

PREvent is emitted when a PR status changes.

Jump to

Keyboard shortcuts

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