jobrunner

package
v0.0.4-alpha.38 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: EUPL-1.2 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionResult

type ActionResult struct {
	Action      string        `json:"action"`
	RepoOwner   string        `json:"repo_owner"`
	RepoName    string        `json:"repo_name"`
	EpicNumber  int           `json:"epic"`
	ChildNumber int           `json:"child"`
	PRNumber    int           `json:"pr"`
	Success     bool          `json:"success"`
	Error       string        `json:"error,omitempty"`
	Timestamp   time.Time     `json:"ts"`
	Duration    time.Duration `json:"duration_ms"`
	Cycle       int           `json:"cycle"`
}

ActionResult carries the outcome of a handler execution.

type JobHandler

type JobHandler interface {
	Name() string
	Match(signal *PipelineSignal) bool
	Execute(ctx context.Context, signal *PipelineSignal) (*ActionResult, error)
}

JobHandler processes a single pipeline signal.

type JobSource

type JobSource interface {
	Name() string
	Poll(ctx context.Context) ([]*PipelineSignal, error)
	Report(ctx context.Context, result *ActionResult) error
}

JobSource discovers actionable work from an external system.

type Journal

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

Journal writes ActionResult entries to date-partitioned JSONL files.

func NewJournal

func NewJournal(baseDir string) (*Journal, error)

NewJournal creates a new Journal rooted at baseDir.

func (*Journal) Append

func (j *Journal) Append(signal *PipelineSignal, result *ActionResult) error

Append writes a journal entry for the given signal and result.

type JournalEntry

type JournalEntry struct {
	Timestamp string         `json:"ts"`
	Epic      int            `json:"epic"`
	Child     int            `json:"child"`
	PR        int            `json:"pr"`
	Repo      string         `json:"repo"`
	Action    string         `json:"action"`
	Signals   SignalSnapshot `json:"signals"`
	Result    ResultSnapshot `json:"result"`
	Cycle     int            `json:"cycle"`
}

JournalEntry is a single line in the JSONL audit log.

type PipelineSignal

type PipelineSignal struct {
	EpicNumber      int
	ChildNumber     int
	PRNumber        int
	RepoOwner       string
	RepoName        string
	PRState         string // OPEN, MERGED, CLOSED
	IsDraft         bool
	Mergeable       string // MERGEABLE, CONFLICTING, UNKNOWN
	CheckStatus     string // SUCCESS, FAILURE, PENDING
	ThreadsTotal    int
	ThreadsResolved int
	LastCommitSHA   string
	LastCommitAt    time.Time
	LastReviewAt    time.Time
}

PipelineSignal is the structural snapshot of a child issue/PR. Never contains comment bodies or free text — structural signals only.

func (*PipelineSignal) HasUnresolvedThreads

func (s *PipelineSignal) HasUnresolvedThreads() bool

HasUnresolvedThreads returns true if there are unresolved review threads.

func (*PipelineSignal) RepoFullName

func (s *PipelineSignal) RepoFullName() string

RepoFullName returns "owner/repo".

type Poller

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

Poller discovers signals from sources and dispatches them to handlers.

func NewPoller

func NewPoller(cfg PollerConfig) *Poller

NewPoller creates a Poller from the given config.

func (*Poller) AddHandler

func (p *Poller) AddHandler(h JobHandler)

AddHandler appends a handler to the poller.

func (*Poller) AddSource

func (p *Poller) AddSource(s JobSource)

AddSource appends a source to the poller.

func (*Poller) Cycle

func (p *Poller) Cycle() int

Cycle returns the number of completed poll-dispatch cycles.

func (*Poller) DryRun

func (p *Poller) DryRun() bool

DryRun returns whether dry-run mode is enabled.

func (*Poller) Run

func (p *Poller) Run(ctx context.Context) error

Run starts a blocking poll-dispatch loop. It runs one cycle immediately, then repeats on each tick of the configured interval until the context is cancelled.

func (*Poller) RunOnce

func (p *Poller) RunOnce(ctx context.Context) error

RunOnce performs a single poll-dispatch cycle: iterate sources, poll each, find the first matching handler for each signal, and execute it.

func (*Poller) SetDryRun

func (p *Poller) SetDryRun(v bool)

SetDryRun enables or disables dry-run mode.

type PollerConfig

type PollerConfig struct {
	Sources      []JobSource
	Handlers     []JobHandler
	Journal      *Journal
	PollInterval time.Duration
	DryRun       bool
}

PollerConfig configures a Poller.

type ResultSnapshot

type ResultSnapshot struct {
	Success    bool   `json:"success"`
	Error      string `json:"error,omitempty"`
	DurationMs int64  `json:"duration_ms"`
}

ResultSnapshot captures the outcome of an action.

type SignalSnapshot

type SignalSnapshot struct {
	PRState         string `json:"pr_state"`
	IsDraft         bool   `json:"is_draft"`
	CheckStatus     string `json:"check_status"`
	Mergeable       string `json:"mergeable"`
	ThreadsTotal    int    `json:"threads_total"`
	ThreadsResolved int    `json:"threads_resolved"`
}

SignalSnapshot captures the structural state of a PR at the time of action.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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