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 ¶
- Variables
- func NewID() string
- type ErrRefused
- type Factory
- func (f Factory) Catalogue(ctx context.Context, accessToken, repository, onBehalfOf string) (catalogue.Catalogue, error)
- func (f Factory) CoordinationConfirm(ctx context.Context, accessToken, parent string, ...) (coordination.CoordinationConfirmation, error)
- func (f Factory) CoordinationDraft(ctx context.Context, accessToken, parent string, ...) (coordination.CoordinationConfirmation, error)
- func (f Factory) CoordinationRecover(ctx context.Context, accessToken, parent, code string, planVersion int32) error
- func (f Factory) CreateTask(ctx context.Context, r TaskRequest) (TaskResult, error)
- func (f Factory) HTTPClient() (*http.Client, error)
- func (f Factory) Install(ctx context.Context, accessToken string) ([]string, error)
- func (f Factory) Policy(ctx context.Context, accessToken, name string) (evidence.PolicyReport, error)
- func (f Factory) PolicyDecisions(ctx context.Context, accessToken, repository string, pr int) (policyview.Timeline, error)
- func (f Factory) PolicyEvidence(ctx context.Context, accessToken, repository string) (evidence.Report, error)
- func (f Factory) PolicyList(ctx context.Context, accessToken string) ([]evidence.PolicyReport, error)
- func (f Factory) PolicyPreview(ctx context.Context, accessToken, repository, file string) (policyview.Preview, error)
- func (f Factory) PolicyPreviewBindings(ctx context.Context, accessToken, repository string, bindings []config.Binding) (policyview.BindingPreview, error)
- func (f Factory) PolicyPreviewPolicy(ctx context.Context, accessToken, name string, spec config.PolicySpec) (policyview.PolicyPreview, error)
- func (f Factory) PolicyRepositories(ctx context.Context, accessToken string) ([]string, error)
- func (f Factory) Request(ctx context.Context, r Request) (Result, error)
- type Manifest
- type Request
- type Requester
- type Result
- type TaskRequest
- type TaskResult
Constants ¶
This section is empty.
Variables ¶
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 ¶
Types ¶
type ErrRefused ¶
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 ¶
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) 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
HTTPClient is f's HTTP client to the factory, trusting factoryCAFile: forge_read posts with it.
func (Factory) Install ¶ added in v0.47.0
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
PolicyRepositories is GET /v1/policy/repositories with the caller's own token: the configured repositories they read.
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.
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 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 ¶
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).