submission

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package submission defines the provider-neutral trust boundary for customer submission identity. A frontend or harness adapter supplies the authority; request payload fields never participate in binding.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAuthority identifies malformed or unknown authority data.
	ErrInvalidAuthority = errors.New("submission: invalid authority")
	// ErrUntrustedAuthority identifies an authority that did not come from an
	// accepted authenticated or harness source.
	ErrUntrustedAuthority = errors.New("submission: untrusted authority")
	// ErrScopeMismatch identifies a continuation bound to another call, A-leg,
	// tenant, principal, session, or store.
	ErrScopeMismatch = errors.New("submission: scope mismatch")
	// ErrLifecycleConflict identifies an attempt to reuse a closed invocation
	// for a new follow-up submission.
	ErrLifecycleConflict = errors.New("submission: lifecycle conflict")
	// ErrIncomplete identifies trusted attribution that cannot support a strict
	// submission-priced offer.
	ErrIncomplete = errors.New("submission: incomplete attribution")
)

Functions

func WithAuthority

func WithAuthority(ctx context.Context, authority Authority) context.Context

WithAuthority attaches an authority supplied by a trusted frontend or explicitly supported harness adapter. Nil contexts are tolerated.

Types

type Authority

type Authority struct {
	SubmissionID string
	// BillingCallID is optional for a trusted continuation. When omitted, the
	// runtime may allocate a fresh call grouping while retaining SubmissionID;
	// when present, it must be reused rather than replaced.
	BillingCallID string
	Kind          Kind
	Source        Source
	Scope         Scope
}

Authority is the trusted, immutable identity supplied by an authenticated frontend current-turn/continuation authority or an explicitly supported harness adapter. It contains no raw credential or request payload data.

func AuthorityFromContext

func AuthorityFromContext(ctx context.Context) (Authority, bool)

AuthorityFromContext returns a defensive value copy of the authority carried by WithAuthority. It never reads request payload metadata.

func (Authority) Clone

func (a Authority) Clone() Authority

Clone returns a value copy suitable for context or store boundaries.

type BindingInput

type BindingInput struct {
	Scope Scope
}

BindingInput carries the runtime-owned identity used to validate an authority. The runtime, not the caller payload, builds this input.

type BindingResult

type BindingResult = Result

BindingResult is the descriptive spelling of Result for adapter APIs.

type Kind

type Kind string

Kind describes how a request relates to a customer submission.

const (
	KindNewSubmission    Kind = "new_submission"
	KindToolContinuation Kind = "tool_continuation"
	KindHistoricalReplay Kind = "historical_replay"
	KindTransportRetry   Kind = "transport_retry"
	KindFollowUp         Kind = "follow_up"
	KindLocalCommand     Kind = "local_command"
	// KindNew is a short spelling for KindNewSubmission.
	KindNew = KindNewSubmission
)

type Result

type Result struct {
	Status     Status
	Authority  Authority
	ReasonCode string
}

Result is the immutable result of one attribution attempt.

func Bind

func Bind(input BindingInput, supplied *Authority) (Result, error)

Bind validates and freezes one trusted authority against the runtime-owned scope. A missing authority, or a trusted authority without enough identity material, returns an explicit unsupported/incomplete result so inference can continue without a prompt-priced offer. Malformed, untrusted, or cross-scope authorities are rejected before execution state is opened.

func (Result) Billable

func (r Result) Billable() bool

Billable reports whether a submission identity is available for a submission-scoped charge. Local commands remain explicitly non-billable.

func (Result) Trusted

func (r Result) Trusted() bool

Trusted reports whether the result can be used for submission-scoped commercial rules.

type Scope

type Scope struct {
	TenantID    string
	PrincipalID string
	SessionID   string
	ALegID      string
	StoreID     string
	CallID      string
}

Scope is the trusted isolation boundary against which a supplied authority is checked. Empty values mean that the corresponding dimension is not known at that boundary; they are never inferred from request payload data.

func (Scope) Equal

func (s Scope) Equal(other Scope) bool

Equal reports exact equality of all scope dimensions.

type Source

type Source string

Source identifies the trusted authority that classified a request.

const (
	SourceAuthenticatedCurrentTurn  Source = "authenticated_current_turn"
	SourceAuthenticatedContinuation Source = "authenticated_continuation"
	SourceHarnessAdapter            Source = "harness_adapter"
	SourceLocalCommand              Source = "local_command"
	// SourceClient is intentionally never accepted by Bind. It is exposed only
	// so adapters can classify an attempted client override explicitly.
	SourceClient Source = "client"
)

type Status

type Status string

Status is the outcome of submission attribution. Unsupported and incomplete are explicit non-billable outcomes; they do not prevent ordinary inference.

const (
	StatusTrusted     Status = "trusted"
	StatusUnsupported Status = "unsupported"
	StatusIncomplete  Status = "incomplete"
	StatusRejected    Status = "rejected"
)

Jump to

Keyboard shortcuts

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