remedctrl

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package remedctrl is the remediation-controller's engine: it picks up context-enhanced findings past the accumulation window, runs the coding agent in an ephemeral Kubernetes Job, and performs every GitHub side effect on the agent's behalf — the agent pod has no GitHub credentials.

The controller consumes the runner's envelope events: a classification event lands the report, the severity/priority/recommendation labels and the routing decision (dismiss the alerts and close, assign a human, or let the same pod continue into remediation); a remediation event pushes the agent's branch and opens the pull request. Merging stays human; the merge webhook closes the issue.

Every write is driven by a fresh read of the issue's labels, so redeliveries, restarts, and the reconcile sweep converge on the same state — GitHub remains the only state store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clients

type Clients interface {
	For(ctx context.Context, repo ghclient.Repo) (Stores, error)
	All(ctx context.Context) ([]Searcher, error)
	// CloneToken mints a contents:read token for repo.
	CloneToken(ctx context.Context, repo ghclient.Repo) (string, error)
	// PushToken mints a contents:write token for repo.
	PushToken(ctx context.Context, repo ghclient.Repo) (string, error)
}

Clients resolves GitHub access and mints the short-lived, single-repo tokens the Job's init container clones with.

type Config

type Config struct {
	// MinAge is how old an issue must be before remediation picks it up —
	// DESIGN's "older than one hour" gate, belt-and-braces with the
	// accumulation label. Default one hour.
	MinAge time.Duration
	// MaxAttempts bounds Job retries per issue before it is handed to a
	// human. Default 2.
	MaxAttempts int
	// ApproveCommand is the issue comment forcing a remediation attempt.
	ApproveCommand string
}

Config tunes the controller.

type Controller

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

Controller is the remediation-controller engine; it implements webhook.Handler.

func New

func New(log *slog.Logger, clients Clients, runner Runner, pusher Pusher, cfg Config) *Controller

New builds a Controller.

func (*Controller) Handle

func (c *Controller) Handle(ctx context.Context, e webhook.Event) error

Handle implements webhook.Handler. Pickup is driven by the reconcile loop (the gate is time-based, so webhooks alone cannot trigger it); the events handled here are the human-in-the-loop ones: /approve comments and pull request closures.

func (*Controller) Reconcile

func (c *Controller) Reconcile(ctx context.Context) error

Reconcile is the primary driver: the pickup gate is time-based, so no webhook can announce it. Each pass reaps orphaned leases, then picks up every eligible finding.

type Pusher

type Pusher interface {
	Push(ctx context.Context, repo ghclient.Repo, token, branch string, cs *envelope.Changeset) error
}

Pusher applies an agent's changeset to GitHub through the API with a short-lived write token. Kept behind an interface so the controller stays testable without the network.

type Runner

type Runner interface {
	Create(ctx context.Context, spec jobs.Spec) (string, error)
	Follow(ctx context.Context, job string, fn func(envelope.Event) error) error
	Result(ctx context.Context, job string) ([]envelope.Event, error)
	Status(ctx context.Context, job string) (jobs.Status, error)
	List(ctx context.Context) ([]jobs.Owned, error)
	Delete(ctx context.Context, job string) error
}

Runner creates and observes the agent Jobs.

type Searcher

type Searcher interface {
	SearchIssues(ctx context.Context, query string) ([]*ghclient.Issue, error)
}

Searcher runs cross-repository issue searches within one installation.

type Stores

Stores is the per-repository GitHub surface the controller mutates.

Jump to

Keyboard shortcuts

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