Documentation
¶
Overview ¶
Package jobs creates and observes the ephemeral Kubernetes Jobs that run agent-runner: one Job per issue attempt, deterministically named, labelled so orphans can be reaped, and garbage collected via TTL plus an owner-referenced per-Job Secret.
The Job shape carries the isolation model: the short-lived GitHub token reaches only the init container (which clones the repository and then strips credentials from the clone), while the agent container gets the model API key and PATCHY_* configuration but no GitHub credentials at all — the remediation-controller owns every GitHub side effect. Results come back on the agent container's stdout as envelope events, followed live and re-read at completion as the idempotent fallback.
Index ¶
- func Name(repo string, issue, attempt int) string
- type Client
- func (c *Client) Create(ctx context.Context, spec Spec) (string, error)
- func (c *Client) Delete(ctx context.Context, jobName string) error
- func (c *Client) Follow(ctx context.Context, jobName string, fn func(envelope.Event) error) error
- func (c *Client) List(ctx context.Context) ([]Owned, error)
- func (c *Client) Result(ctx context.Context, jobName string) ([]envelope.Event, error)
- func (c *Client) Status(ctx context.Context, jobName string) (Status, error)
- type Config
- type Owned
- type Spec
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client creates and observes agent Jobs in one namespace.
func (*Client) Create ¶
Create builds and creates the per-Job Secret (token + issue markdown), then the Job itself, then owner-references the Secret to the Job so it is garbage collected with it. Returns the Job name.
func (*Client) Follow ¶
Follow streams the agent container's stdout, decoding envelope events and delivering them to fn as they arrive. It returns when the pod's log stream ends. If the log stream cannot be opened or breaks, the caller falls back to Result.
type Config ¶
type Config struct {
Namespace string // where Jobs run, e.g. "patchy-agents"
Image string // agent-runner image
ServiceAccount string // pod service account
Deadline time.Duration // activeDeadlineSeconds
TTL time.Duration // ttlSecondsAfterFinished
AnthropicSecret string // name of the Secret holding the model credential
AnthropicSecretKey string // key within it (default "api-key")
// AnthropicSecretEnv is the env var the credential is injected into the
// agent container as: ANTHROPIC_API_KEY (the default) for an API key, or
// CLAUDE_CODE_OAUTH_TOKEN for a `claude setup-token` OAuth token.
AnthropicSecretEnv string
// Env is extra PATCHY_* configuration passed through to every runner
// (models, timeouts, ceilings, thresholds, harness selection).
Env map[string]string
// Resource strings (Kubernetes quantities), optional.
CPURequest, MemoryRequest, CPULimit, MemoryLimit string
}
Config configures Job creation.
type Owned ¶
Owned is one Job patchy created, with the issue it belongs to parsed back out of its labels and annotations.
type Spec ¶
type Spec struct {
Repo string // "owner/name"
Issue int
Attempt int
Phase string // agentrun phase: "classify+remediate" | "remediate"
CloneURL string // https URL of the repo
// BaseSHA is the default branch's head at Job creation; the clone is
// pinned to it and the agent's commit parents it.
BaseSHA string
// Token is the short-lived scoped GitHub token; it reaches the init
// container only, via the per-Job Secret.
Token string
IssueMarkdown string // the issue handoff file content
// ClassificationMarkdown is optional: the /approve remediate-only re-run.
ClassificationMarkdown string
}
Spec is one agent Job to create.