bellows

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 15 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, vcsLookup func(anvil string) vcs.Provider, interval time.Duration, anvilPaths map[string]string, autoLearnRules func() bool, maxCIFixAttempts func() int) *Monitor

New creates a Bellows monitor. The vcsLookup function returns the VCS provider for a given anvil name, enabling per-anvil platform support. 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) SetAutoMergeHandler added in v0.8.0

func (m *Monitor) SetAutoMergeHandler(h func(ctx context.Context, anvil string, pr state.PR))

SetAutoMergeHandler registers a callback invoked when a PR transitions to the ready-to-merge state. The daemon uses this to trigger automatic merging for anvils that have auto_merge enabled.

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