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) AnswerTask(ctx context.Context, task, onBehalfOf, text, accessToken string) (string, error)
- func (f Factory) AnswerTaskHuman(ctx context.Context, task, text, accessToken string) (string, error)
- func (f Factory) CancelTask(ctx context.Context, task string, discard bool, accessToken string) (string, error)
- 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) PlanTaskHuman(ctx context.Context, task, decision, note, accessToken string) (string, error)
- func (f Factory) Policy(ctx context.Context, accessToken, name string) (evidence.PolicyReport, error)
- func (f Factory) PolicyBacktest(ctx context.Context, accessToken, repository string, ...) (policyview.Backtest, error)
- func (f Factory) PolicyDecisions(ctx context.Context, accessToken, repository string, pr int) (policyview.Timeline, error)
- func (f Factory) PolicyDrill(ctx context.Context, accessToken, repository string, number int) (PolicyDrillResult, 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) PolicyPromote(ctx context.Context, accessToken, repository, class string, minimum int) (promote.Result, error)
- func (f Factory) PolicyPromotionStatus(ctx context.Context, accessToken, repository, class string, number int) (promote.Status, error)
- func (f Factory) PolicyRecentDecisions(ctx context.Context, accessToken, repository, since string) (policyview.Recent, error)
- func (f Factory) PolicyRepositories(ctx context.Context, accessToken string) ([]string, error)
- func (f Factory) Repositories(ctx context.Context, accessToken string) ([]string, error)
- func (f Factory) Request(ctx context.Context, r Request) (Result, error)
- func (f Factory) RetryTask(ctx context.Context, task, onBehalfOf, accessToken string) (string, error)
- func (f Factory) RetryTaskDeeper(ctx context.Context, task, onBehalfOf string, deeper bool, accessToken string) (RetryResult, error)
- func (f Factory) RetryTaskHuman(ctx context.Context, task string, deeper bool, accessToken string) (RetryResult, error)
- func (f Factory) SplitTaskHuman(ctx context.Context, task, decision, accessToken string) (string, error)
- func (f Factory) Stages(ctx context.Context, accessToken, repository, class string, last int) (stages.Report, error)
- func (f Factory) StopTask(ctx context.Context, task, onBehalfOf, accessToken string) (string, error)
- func (f Factory) WorkflowDryRun(ctx context.Context, accessToken string, in stages.DryRunRequest) (stages.DryRunResult, error)
- type Manifest
- type PolicyDrillResult
- type Request
- type Requester
- type Result
- type RetryResult
- 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 calls share a cached audited egress transport per CAFile, trusting the PEM CA in CAFile and reloading the pool when CAFile changes 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) AnswerTaskHuman ¶ added in v0.54.0
func (f Factory) AnswerTaskHuman(ctx context.Context, task, text, accessToken string) (string, error)
AnswerTaskHuman posts a human's own answer to the factory's POST /v1/tasks/{task}/answers with accessToken.
func (Factory) CancelTask ¶ added in v0.53.10
func (f Factory) CancelTask(ctx context.Context, task string, discard bool, accessToken string) (string, error)
CancelTask posts the caller's own cancel, or with discard their discard, to the factory's POST /v1/tasks/{task}/cancellations with accessToken (#644).
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) PlanTaskHuman ¶ added in v0.54.0
func (f Factory) PlanTaskHuman(ctx context.Context, task, decision, note, accessToken string) (string, error)
PlanTaskHuman posts a human's plan decision (approve, revise with note, or split) to POST /v1/tasks/{task}/plans.
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) PolicyBacktest ¶ added in v0.54.0
func (f Factory) PolicyBacktest(ctx context.Context, accessToken, repository string, request policyview.BacktestRequest, since string) (policyview.Backtest, error)
PolicyBacktest replays an edited policy over a repository's recorded diffs.
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) PolicyDrill ¶ added in v0.54.0
func (f Factory) PolicyDrill(ctx context.Context, accessToken, repository string, number int) (PolicyDrillResult, error)
PolicyDrill opens a labelled rollback-drill revert for a maintainer.
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) PolicyPromote ¶ added in v0.54.0
func (f Factory) PolicyPromote(ctx context.Context, accessToken, repository, class string, minimum int) (promote.Result, error)
PolicyPromote opens a one-line promotion pull request for a maintainer.
func (Factory) PolicyPromotionStatus ¶ added in v0.54.0
func (f Factory) PolicyPromotionStatus(ctx context.Context, accessToken, repository, class string, number int) (promote.Status, error)
PolicyPromotionStatus reads the facts that close a promotion record.
func (Factory) PolicyRecentDecisions ¶ added in v0.54.0
func (f Factory) PolicyRecentDecisions(ctx context.Context, accessToken, repository, since string) (policyview.Recent, error)
PolicyRecentDecisions is GET /v1/policy/decisions with no pr: a repository's recent per-policy decisions, for a reader of it.
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.
func (Factory) Repositories ¶ added in v0.53.0
Repositories is GET /v1/catalogue with the caller's own token: the names of the repositories the factory serves (WF12).
func (Factory) Request ¶
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) RetryTaskDeeper ¶ added in v0.54.0
func (f Factory) RetryTaskDeeper(ctx context.Context, task, onBehalfOf string, deeper bool, accessToken string) (RetryResult, error)
RetryTaskDeeper posts a sponsored retry (optionally deeper) to POST /v1/tasks/{task}/retries.
func (Factory) RetryTaskHuman ¶ added in v0.54.0
func (f Factory) RetryTaskHuman(ctx context.Context, task string, deeper bool, accessToken string) (RetryResult, error)
RetryTaskHuman posts a human's own retry (optionally deeper) to POST /v1/tasks/{task}/retries.
func (Factory) SplitTaskHuman ¶ added in v0.54.0
func (f Factory) SplitTaskHuman(ctx context.Context, task, decision, accessToken string) (string, error)
SplitTaskHuman posts a human's split decision (accept or decline) to POST /v1/tasks/{task}/splits.
func (Factory) Stages ¶ added in v0.54.0
func (f Factory) Stages(ctx context.Context, accessToken, repository, class string, last int) (stages.Report, error)
Stages is GET /v1/stages?repository=<owner/name>[&class=<c>][&last=<n>] with the caller's token (WR5).
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.
func (Factory) WorkflowDryRun ¶ added in v0.54.0
func (f Factory) WorkflowDryRun(ctx context.Context, accessToken string, in stages.DryRunRequest) (stages.DryRunResult, error)
WorkflowDryRun is POST /v1/workflows/dry-run with the caller's token (WR11).
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 PolicyDrillResult ¶ added in v0.54.0
PolicyDrillResult is a rollback drill's pull request.
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 RetryResult ¶ added in v0.54.0
type RetryResult struct {
Result string `json:"result"`
Workflow string `json:"workflow,omitempty"`
CeilingMicroUSD int64 `json:"ceilingMicroUSD,omitempty"`
}
RetryResult is the factory's answer to POST /v1/tasks/{task}/retries (WR4).
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
// StepUpShown is true when the confirmed plan showed the "if it steps up" cost figure (WR4).
StepUpShown bool
// Outcome is the task outcome the confirmed plan carried (phase F); empty is change.
Outcome string
// DependsOn lists earlier issue numbers in the same repository that must merge first (phase H2).
DependsOn []int32
}
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).