runrequest

package
v0.59.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 32 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

View Source
const AmendMirrorTimeout = 25 * time.Second

AmendMirrorTimeout bounds an amendment's mirror call, header wait included: the factory retries the issue comment inside the request (three attempts of at most 7 s and 1.5 s of backoff, 22.5 s worst case), and the answer must outlast them.

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 ChatTaskAct added in v0.59.0

type ChatTaskAct struct {
	Kind, Task, OnBehalfOf, Text, Proof string
	Deeper                              bool
	Decision                            string
	Check                               bool
	Seq                                 int64
}

ChatTaskAct is one chat action on a task for a linked chat user (v5 §1.2): its kind (stop, retry, answer, plan, split or amend), the identity it acts for, the proof word the factory records on the task (signed or unsigned), and each kind's own fields: an answer's or an amendment's Text, a plan revise's note (Text again), a retry's Deeper, a plan or split Decision, and an amendment's Check (standing only, nothing posted) or Seq (the appended event to mirror).

type ErrCodifyRefused added in v0.59.0

type ErrCodifyRefused struct {
	Status    int
	Reason    string
	Message   string
	Current   int
	Resulting int
}

ErrCodifyRefused is returned by CodifyLesson when the factory refuses a codify request. It unwraps to ErrRefused with the HTTP status and bounded reason code.

func (ErrCodifyRefused) Error added in v0.59.0

func (e ErrCodifyRefused) Error() string

Error implements error.

func (ErrCodifyRefused) Unwrap added in v0.59.0

func (e ErrCodifyRefused) Unwrap() error

Unwrap returns the underlying ErrRefused value.

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 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) CatalogRoutines added in v0.57.2

func (f Factory) CatalogRoutines(ctx context.Context, accessToken string) (json.RawMessage, error)

CatalogRoutines forwards GET /v1/routines/catalog with the caller's token.

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) ChatAct added in v0.59.0

func (f Factory) ChatAct(ctx context.Context, a ChatTaskAct, accessToken string) (RetryResult, error)

ChatAct posts a chat action to its factory route with accessToken, carrying its proof word. An amendment's mirror call (Seq set) waits on the factory's in-request retries: it goes through the client bounded by AmendMirrorTimeout, every other call through the factory client's own.

func (Factory) CodifyLesson added in v0.59.0

func (f Factory) CodifyLesson(ctx context.Context, accessToken, repository, class, lessonID, text string, meta ...codify.Meta) (codify.Result, error)

CodifyLesson calls POST /v1/lessons/codify with the human caller's own bearer token to open or reuse a steering-note pull request for lessonID.

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) GetRoutine added in v0.57.1

func (f Factory) GetRoutine(ctx context.Context, accessToken, owner, name, routine string) (json.RawMessage, error)

GetRoutine forwards GET /v1/routines/{owner}/{name}/{routine} with the caller's token.

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) (InstallInfo, error)

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

func (Factory) ListRoutines added in v0.57.1

func (f Factory) ListRoutines(ctx context.Context, accessToken, repo string) (json.RawMessage, error)

ListRoutines forwards GET /v1/routines[?repository=owner/name] with the caller's token.

func (Factory) PauseRoutine added in v0.57.1

func (f Factory) PauseRoutine(ctx context.Context, accessToken, owner, name, routine string, body json.RawMessage) (json.RawMessage, error)

PauseRoutine forwards POST /v1/routines/{owner}/{name}/{routine}/pause with the caller's token.

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

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

PolicyRepositories is GET /v1/policy/repositories with the caller's own token.

func (Factory) PreviewRoutine added in v0.57.2

func (f Factory) PreviewRoutine(ctx context.Context, accessToken, owner, name string, body json.RawMessage) (json.RawMessage, error)

PreviewRoutine forwards POST /v1/routines/{owner}/{name}/preview with the caller's token.

func (Factory) PutRoutine added in v0.57.2

func (f Factory) PutRoutine(ctx context.Context, accessToken, owner, name, routine string, body json.RawMessage) (json.RawMessage, error)

PutRoutine forwards PUT /v1/routines/{owner}/{name}/{routine} with the caller's token.

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) ResumeRoutine added in v0.57.1

func (f Factory) ResumeRoutine(ctx context.Context, accessToken, owner, name, routine string, body json.RawMessage) (json.RawMessage, error)

ResumeRoutine forwards POST /v1/routines/{owner}/{name}/{routine}/resume with the caller's 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) RoutineDigest added in v0.57.1

func (f Factory) RoutineDigest(ctx context.Context, accessToken string, repos []string, window string) (json.RawMessage, error)

RoutineDigest forwards GET /v1/routines/digest with optional repositories and window filters.

func (Factory) RunRoutine added in v0.57.1

func (f Factory) RunRoutine(ctx context.Context, accessToken, owner, name, routine, idempotencyKey string, body json.RawMessage) (int, json.RawMessage, error)

RunRoutine forwards POST /v1/routines/{owner}/{name}/{routine}/runs with the caller's token.

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 InstallInfo added in v0.58.0

type InstallInfo struct {
	Unsafe          []string `json:"unsafe"`
	Version         string   `json:"version,omitempty"`
	Factory         string   `json:"factory,omitempty"`
	Namespace       string   `json:"namespace,omitempty"`
	DefaultHarness  string   `json:"defaultHarness,omitempty"`
	PolicyStage     string   `json:"policyStage,omitempty"`
	Hardening       string   `json:"hardening,omitempty"`
	RoutinesUIWrite *bool    `json:"routinesUIWrite,omitempty"`
	Demo            bool     `json:"demo,omitempty"`
}

InstallInfo is the factory's GET /v1/install answer: its banner codes and bounded non-sensitive environment metadata (never a repository name).

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 PolicyDrillResult added in v0.54.0

type PolicyDrillResult struct {
	Number int    `json:"number"`
	URL    string `json:"url"`
}

PolicyDrillResult is a rollback drill's pull request.

type PolicyIndex added in v0.57.1

type PolicyIndex struct {
	Repositories []string `json:"repositories"`
	Maintains    []string `json:"maintains"`
}

PolicyIndex is the configured repositories a caller reads, and the ones of them they maintain. Maintains is nil from a factory that does not say (an older release).

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 RetryResult added in v0.54.0

type RetryResult struct {
	Result          string `json:"result"`
	Workflow        string `json:"workflow,omitempty"`
	CeilingMicroUSD int64  `json:"ceilingMicroUSD,omitempty"`
	Mirror          string `json:"mirror,omitempty"`
}

RetryResult is the factory's answer to a task act: POST /v1/tasks/{task}/retries (WR4) and the others. Mirror is an amendment's: what became of its issue comment (one of amendMirrors).

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
	// WithoutRecall skips direct prior-lesson recall while keeping the current factory variant (Q31).
	WithoutRecall bool
}

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