productrun

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package productrun assembles the small, client-side candidate execution slice used by the CLI. It deliberately does not claim a support tier: all built-in normative interpretations remain candidate/pending_review until the independent catalog gates are satisfied.

Index

Constants

View Source
const PersistedPlanSchema = "urn:agentapi-doctor:local-plan-snapshot:v1alpha1"

Variables

This section is empty.

Functions

func DefaultBudget

func DefaultBudget(scenarioCount int) schema.BudgetPolicy

DefaultBudget is a conservative hard budget for callers that only know the scenario count. Product plans use defaultBudgetFor to reserve the exact sum of their versioned per-scenario output caps.

func PlanJSON

func PlanJSON(planned PlannedRun) ([]byte, error)

PlanJSON validates the full exact binding and returns the canonical, persistence-safe plan snapshot used by plan-only output and run records. The snapshot preserves the immutable IntentPlan and ResolvedRunPlan plus the public endpoint fields needed to understand the run, but deliberately omits secret references and free-form target metadata.

Types

type ExactResolver

type ExactResolver struct {
	// contains filtered or unexported fields
}

ExactResolver binds one runner to one complete ArtifactPin. Name or version matches are insufficient: kind, name, exact version, and digest must all be identical to the ResolvedRunPlan decision.

func NewExactResolver

func NewExactResolver(pin schema.ArtifactPin, runner executor.Runner) (*ExactResolver, error)

func (*ExactResolver) Resolve

func (resolver *ExactResolver) Resolve(pin schema.ArtifactPin) (executor.Runner, error)

type ExecuteRequest

type ExecuteRequest struct {
	Planned     PlannedRun
	DataRoot    string
	Secrets     SecretResolver
	NetworkMode transport.NetworkMode
	Now         func() time.Time
	NewID       IDSource
	// BeforePersist completes task-owned cleanup that must succeed before a
	// report can be published as a durable run. It runs after evidence and the
	// report pass all redaction checks, and is intended for the in-process demo.
	BeforePersist func() error
}

type Execution

type Execution struct {
	ExecutorResult executor.Result `json:"executor_result"`
	Report         report.Bundle   `json:"report"`
	ReportJSON     []byte          `json:"report_json"`
	RecordDigest   schema.Digest   `json:"record_digest"`
}

func Execute

func Execute(ctx context.Context, request ExecuteRequest) (Execution, error)

Execute validates and re-derives the offline plan before making any request, then runs only the frozen exact-origin scenarios. It persists the canonical plan and redacted report together and returns any cancellation error only after preserving the partial run record.

type IDSource

type IDSource func() (schema.InstanceID, error)

type PersistedAuth

type PersistedAuth struct {
	Type                 string `json:"type"`
	Header               string `json:"header,omitempty"`
	CredentialConfigured bool   `json:"credential_configured"`
}

type PersistedPlan

type PersistedPlan struct {
	SchemaVersion string                 `json:"schema_version"`
	TargetName    string                 `json:"target_name"`
	Target        PersistedTarget        `json:"target"`
	Intent        schema.IntentPlan      `json:"intent_plan"`
	Resolved      schema.ResolvedRunPlan `json:"resolved_run_plan"`
}

PersistedPlan is the local, replay-oriented projection of a PlannedRun. It intentionally does not contain the credential reference or free-form target metadata. The public ConfigDigest binds only this safe projection; omitted inputs remain bound to the in-memory execution plan and are deliberately not exposed through a guessable digest. Target keeps the endpoint fields needed to understand the historical run.

func DecodePlanJSON

func DecodePlanJSON(raw []byte) (PersistedPlan, error)

DecodePlanJSON accepts only the canonical, closed JSON shape emitted by PlanJSON and then revalidates all nested envelope and built-in bindings.

func (PersistedPlan) Validate

func (plan PersistedPlan) Validate() error

Validate verifies both envelope projection digests and stable cross-object target/ref bindings. It deliberately does not compare an old snapshot with the currently compiled built-in pack: historical runs must remain readable after the built-ins advance. Current-pack equality is enforced by Build and validatePlanned before execution.

type PersistedTarget

type PersistedTarget struct {
	BaseURL  string         `json:"baseURL"`
	Protocol string         `json:"protocol"`
	Model    string         `json:"model"`
	Auth     *PersistedAuth `json:"auth,omitempty"`
}

type PlanRequest

type PlanRequest struct {
	TargetName string
	Target     config.Target
	Budget     schema.BudgetPolicy
	Producer   schema.Producer
	Author     string
	Now        func() time.Time
	NewID      IDSource
}

PlanRequest contains only configuration references and public target metadata. Build never resolves Auth.Token and performs no network I/O.

type PlannedRun

type PlannedRun struct {
	TargetName            string                 `json:"target_name"`
	Target                config.Target          `json:"target"`
	ExecutionConfigDigest schema.Digest          `json:"execution_config_digest"`
	Intent                schema.IntentPlan      `json:"intent_plan"`
	Resolved              schema.ResolvedRunPlan `json:"resolved_run_plan"`
}

PlannedRun is the offline result consumed by Execute. Target contains only the secret reference from config, never its resolved value.

func Build

func Build(request PlanRequest) (PlannedRun, error)

Build creates both plans without probing, dialing, resolving credentials, or writing files. The ResolvedRunPlan binds an exact digest of the selected raw scenario definitions, request templates, catalog interpretations, driver, oracle, resolver, and candidate profile.

type ScenarioDescriptor

type ScenarioDescriptor struct {
	ID                        string              `json:"scenario_id"`
	RequirementID             string              `json:"requirement_id"`
	RequirementInterpretation string              `json:"requirement_interpretation"`
	CatalogStatus             string              `json:"catalog_status"`
	CatalogReviewStatus       string              `json:"catalog_review_status"`
	Protocol                  rawdriver.Protocol  `json:"protocol"`
	Streaming                 bool                `json:"streaming"`
	Check                     rawdriver.CheckKind `json:"check"`
	AllowedValues             []string            `json:"allowed_values,omitempty"`
	RequestedOutputTokens     int64               `json:"requested_output_tokens"`
}

ScenarioDescriptor is the reviewable catalog binding for one built-in execution check. Interpretation is copied from the candidate Requirement Catalog and is part of the immutable built-in pack digest.

func BuiltinScenarios

func BuiltinScenarios(protocol string) ([]ScenarioDescriptor, error)

BuiltinScenarios returns a detached, stable view of the selected candidate scenarios. It never reads a live provider or ambient configuration.

type SecretResolver

type SecretResolver interface {
	Resolve(context.Context, string) ([]byte, error)
}

Jump to

Keyboard shortcuts

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