Documentation
¶
Overview ¶
Package engine runs reviews: it queues PRs from poll results, runs them with a bounded worker pool under the daily budget, and records everything.
Index ¶
- func RenderPrompt(cfg *config.Config, agentName string, pr github.PRDetail) (string, error)
- type Deps
- type Engine
- func (e *Engine) Approve(ctx context.Context, repo string, number int) error
- func (e *Engine) Changes() <-chan struct{}
- func (e *Engine) HandlePoll(r poller.Result)
- func (e *Engine) PRState(repo string, number int) PRState
- func (e *Engine) PostPending(ctx context.Context, repo string, number int) error
- func (e *Engine) Rereview(pr github.PR) error
- func (e *Engine) Run(ctx context.Context)
- func (e *Engine) SetViews(views []config.View)
- func (e *Engine) Snapshot() Snapshot
- func (e *Engine) TogglePause() bool
- type PRState
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Deps ¶
type Deps struct {
Store *store.Store
GetPR func(ctx context.Context, repo string, number int) (github.PRDetail, error)
Checkout func(ctx context.Context, repo string, number int, baseRef, headSHA string) (workspace.Workspace, func(), error)
NewReviewer func(name string, a config.Agent) (agent.Reviewer, error)
PostReview func(ctx context.Context, repo string, number int, p github.ReviewPost) (github.PostResult, error)
HasReview func(ctx context.Context, repo string, number int, marker string) (bool, error)
Approve func(ctx context.Context, repo string, number int, commitID, body string) error
Now func() time.Time
}
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Approve ¶
Approve approves a PR whose review is pending approval, or retries one whose earlier approval may not have reached GitHub.
func (*Engine) Changes ¶
func (e *Engine) Changes() <-chan struct{}
Changes signals (coalesced) whenever engine state may have changed.
func (*Engine) HandlePoll ¶
HandlePoll hands a poll result to the engine without blocking. If the engine is busy the result is dropped; the next poll carries the same PRs.
func (*Engine) PostPending ¶
PostPending posts a PR's finished review (state ready), or retries one whose earlier post may not have reached GitHub (state post-unknown).
func (*Engine) Rereview ¶
Rereview queues a fresh review of pr's head, using the PR's last agent (or the default), unless one is already queued or running.
func (*Engine) Run ¶
Run settles reviews a previous process left in flight, then processes poll results and runs reviews until ctx is cancelled. It returns once its workers have finished.
func (*Engine) TogglePause ¶
TogglePause stops or resumes starting new reviews and returns the new state.
type PRState ¶
type PRState struct {
Audit []store.AuditEvent
Latest *store.Review
Comments []agent.InlineComment // Latest's comments, decoded
}