runrequest

package
v0.53.8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 28 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 runrequest asks for the next run. Only the factory creates AgentRuns (C3): with SP3, the broker calls POST /v1/runs with the human's own access token (C4); before SP3, it renders the claim for the owner to create (ruling P14).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBudget is the factory refusing a run over the principal's budget (429).
	ErrBudget = errors.New("over_budget")
	// ErrForbidden is the factory refusing the principal (403), or no token to present.
	ErrForbidden = errors.New("forbidden")
	// ErrNoKey is a factory request with no idempotency key, refused before the call.
	ErrNoKey = errors.New("runrequest: a factory request needs an idempotency key")
)

Functions

func NewID

func NewID() string

NewID is a fresh C2 id: 8 characters of [a-z2-7], 40 random bits.

Types

type ErrRefused

type ErrRefused struct {
	Status int
	Reason string
}

ErrRefused is the factory refusing a task request: its status and its code, "refused" for a code outside POST /v1/tasks's closed list. A value, so errors.As matches it as written.

func (ErrRefused) Error

func (e ErrRefused) Error() string

type Factory

type Factory struct {
	URL    string
	CAFile string
	HC     *http.Client
}

Factory is SP3's run API at URL. HC, when set, is the client (tests). Otherwise each call builds the audited egress client, trusting the PEM CA in CAFile, read at that call so a rotated CA needs no restart (S-1), or the system roots when CAFile is empty.

func (Factory) AnswerTask added in v0.53.0

func (f Factory) AnswerTask(ctx context.Context, task, onBehalfOf, text, accessToken string) (string, error)

AnswerTask posts onBehalfOf and text to the factory's POST /v1/tasks/{task}/answers with accessToken.

func (Factory) Catalogue added in v0.45.0

func (f Factory) Catalogue(ctx context.Context, accessToken, repository, onBehalfOf string) (catalogue.Catalogue, error)

Catalogue is GET /v1/catalogue/{owner}/{name} with the caller's own token: what the repository offers at intake (P2). A sponsored principal names the Slack user it acts for in onBehalfOf ("slack:<team>/<user>"); a human leaves it empty. A refusal is an ErrRefused with its bounded reason (not_found, human_only, not_linked, link_unverified).

func (Factory) CoordinationConfirm added in v0.39.0

func (f Factory) CoordinationConfirm(ctx context.Context, accessToken, parent string,
	in coordination.CoordinationConfirmation) (coordination.CoordinationConfirmation, error)

CoordinationConfirm is POST /v1/coordinations/{parent}/confirmations (MR5) with the caller's own token: exactly one of the parent's confirmation or one child's authorization, decided by the factory against that repository's maintainer and its current write.

func (Factory) CoordinationDraft added in v0.39.0

func (f Factory) CoordinationDraft(ctx context.Context, accessToken, parent string, in coordination.CoordinationConfirmation,
	onBehalfOf string) (coordination.CoordinationConfirmation, error)

CoordinationDraft is PUT /v1/coordinations/{parent}/draft (v4 MR4) with the caller's own token: a plan version stored on its parent, never a confirmation. onBehalfOf is a sponsored principal's user; the factory refuses it from anyone else. The broker asserts no login or actor.

func (Factory) CoordinationRecover added in v0.39.0

func (f Factory) CoordinationRecover(ctx context.Context, accessToken, parent, code string, planVersion int32) error

CoordinationRecover is POST /v1/coordinations/{parent}/recovery (MR11) with the caller's own token: the parent's one proposed action at the plan version it was proposed under. The factory re-reads who may perform it and answers 204; the broker asserts nothing.

func (Factory) CreateTask

func (f Factory) CreateTask(ctx context.Context, r TaskRequest) (TaskResult, error)

CreateTask posts r to the factory's POST /v1/tasks with the caller's own token, as Request does.

func (Factory) HTTPClient added in v0.47.0

func (f Factory) HTTPClient() (*http.Client, error)

HTTPClient is f's HTTP client to the factory, trusting factoryCAFile: forge_read posts with it.

func (Factory) Install added in v0.47.0

func (f Factory) Install(ctx context.Context, accessToken string) ([]string, error)

Install is GET /v1/install with the caller's own token: the factory's banner codes (v4 D3).

func (Factory) Policy added in v0.47.0

func (f Factory) Policy(ctx context.Context, accessToken, name string) (evidence.PolicyReport, error)

Policy is GET /v1/policy/policies/{name} with the caller's own token (B16).

func (Factory) PolicyDecisions added in v0.40.0

func (f Factory) PolicyDecisions(ctx context.Context, accessToken, repository string, pr int) (policyview.Timeline, error)

PolicyDecisions is GET /v1/policy/decisions with the caller's own token: a pull request's decision timeline, for a reader of the repository.

func (Factory) PolicyEvidence added in v0.40.0

func (f Factory) PolicyEvidence(ctx context.Context, accessToken, repository string) (evidence.Report, error)

PolicyEvidence is GET /v1/policy/evidence (merge policy stage 6) with the caller's own token: the repository's promotion evidence, which the factory reads for a reader of it on GitHub.

func (Factory) PolicyList added in v0.47.0

func (f Factory) PolicyList(ctx context.Context, accessToken string) ([]evidence.PolicyReport, error)

PolicyList is GET /v1/policy/policies with the caller's own token: the MergePolicies they read a consumer of (B16).

func (Factory) PolicyPreview added in v0.40.0

func (f Factory) PolicyPreview(ctx context.Context, accessToken, repository, file string) (policyview.Preview, error)

PolicyPreview is POST /v1/policy/preview with the caller's own token: a proposed policy file checked, compared and simulated by the factory for a maintainer of the repository.

func (Factory) PolicyPreviewBindings added in v0.47.0

func (f Factory) PolicyPreviewBindings(ctx context.Context, accessToken, repository string, bindings []config.Binding) (policyview.BindingPreview, error)

PolicyPreviewBindings is POST /v1/policy/preview of kind binding with the caller's own token: one repository's proposed mergePolicies, for a maintainer of it (B16).

func (Factory) PolicyPreviewPolicy added in v0.47.0

func (f Factory) PolicyPreviewPolicy(ctx context.Context, accessToken, name string, spec config.PolicySpec) (policyview.PolicyPreview, error)

PolicyPreviewPolicy is POST /v1/policy/preview of kind policy with the caller's own token: a proposed MergePolicy and the consumers they read (B11, B16).

func (Factory) PolicyRepositories added in v0.40.0

func (f Factory) PolicyRepositories(ctx context.Context, accessToken string) ([]string, error)

PolicyRepositories is GET /v1/policy/repositories with the caller's own token: the configured repositories they read.

func (Factory) Repositories added in v0.53.0

func (f Factory) Repositories(ctx context.Context, accessToken string) ([]string, error)

Repositories is GET /v1/catalogue with the caller's own token: the names of the repositories the factory serves (WF12).

func (Factory) Request

func (f Factory) Request(ctx context.Context, r Request) (Result, error)

Request posts r to the factory as the human it names, with their own token.

func (Factory) RetryTask added in v0.53.0

func (f Factory) RetryTask(ctx context.Context, task, onBehalfOf, accessToken string) (string, error)

RetryTask posts onBehalfOf to the factory's POST /v1/tasks/{task}/retries with accessToken.

func (Factory) StopTask added in v0.53.0

func (f Factory) StopTask(ctx context.Context, task, onBehalfOf, accessToken string) (string, error)

StopTask posts onBehalfOf to the factory's POST /v1/tasks/{task}/stops with accessToken.

type Manifest

type Manifest struct {
	// Kind is the runs kind, required: the claim rendered is one of its runs.
	Kind runwatch.Kind
}

Manifest renders the AgentRun claim for the owner to create (ruling P14), of Kind: its GVK and namespace, and the name prefix runwatch parses.

func (Manifest) Request

func (m Manifest) Request(_ context.Context, r Request) (Result, error)

Request renders r as a claim, its run id derived from r's idempotency key.

type Request

type Request struct {
	Role, Repository, BaseRef, Branch, TaskText, TaskURL, DataClass, RoomRef, Principal, AccessToken string
	IdempotencyKey                                                                                   string
	EgressProfiles                                                                                   []string
}

Request is one run to start: the claim's fields, the principal asking, and that principal's own access token for the factory (C4). IdempotencyKey names the act that asks (review 4.4 I1): the same key always means the same run.

type Requester

type Requester interface {
	Request(ctx context.Context, r Request) (Result, error)
}

Requester asks for a run.

type Result

type Result struct {
	RunID    string          `json:"runId"`
	Via      string          `json:"via"`
	Manifest json.RawMessage `json:"manifest,omitempty"`
}

Result is the requested run: its id, how it was requested ("manifest" or "factory"), and before SP3 the rendered claim.

type TaskRequest

type TaskRequest struct {
	Repository, Title, Text, DataClass, OnBehalfOf, Ref string
	MaxCostUSD                                          float64
	AccessToken, IdempotencyKey                         string
	// Class and Suggested are a planned task's class and suggested profile (P7), and Profile the
	// profile its plan pinned (P5); empty otherwise.
	Class, Suggested, Profile string
}

TaskRequest is one api task to create: the factory's POST /v1/tasks fields, the caller's own access token (C4) and the key that names the act. Neither of the last two is in the body.

type TaskResult

type TaskResult struct {
	Task, Room string
	Issue      int
	Duplicate  bool
	Sponsor    string
}

TaskResult is the factory's answer: the task and its room (the same id), the issue filed (0 when none), whether the key had already created it, and the GitHub login that sponsors it ("" on a duplicate, or when the factory's answer is not a login).

Jump to

Keyboard shortcuts

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