frontendpipe

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: 27 Imported by: 0

Documentation

Overview

Package frontendpipe provides a shared HTTP create pipeline for wire frontends.

Package frontendpipe provides a shared HTTP create pipeline for wire frontends.

Index

Constants

View Source
const DefaultMaxSemanticFactBytes int64 = 256 * 1024

DefaultMaxSemanticFactBytes is the default ceiling on profile-derived facts (256 KiB; Requirement 4, design section 3).

View Source
const OpenAICancellationPrefix = "resp_lip_"

OpenAICancellationPrefix is the prefix used for carrier-bound OpenAI Responses IDs (Requirement 18.6).

Variables

This section is empty.

Functions

func CandidatePrerequisites

func CandidatePrerequisites[Opts any](spec *Spec[Opts]) (largebody.LargeBodyExecutor, bool)

CandidatePrerequisites evaluates the cheap pre-capture prerequisites for the large-body fast path (Task 7.1, 7.3). Returns the LargeBodyExecutor and true if and only if:

  • spec != nil
  • spec.Profile != nil
  • spec.Exec implements largebody.LargeBodyExecutor

Otherwise, returns (nil, false), directing the request immediately to the unchanged canonical path with zero spool allocation.

func FormatOpenAICancellationCarrier

func FormatOpenAICancellationCarrier(aLegID, sessionID string) string

FormatOpenAICancellationCarrier encodes authoritative A-leg and session identifiers into an OpenAI Responses cancellation carrier string (Requirement 18.6).

func MapAnthropicExecuteError

func MapAnthropicExecuteError(out execerr.Outcome) (status int, message, errType string)

MapAnthropicExecuteError maps executor outcomes to Anthropic wire error.type strings.

func MapGeminiExecuteError

func MapGeminiExecuteError(out execerr.Outcome) (status int, message, gstatus string)

MapGeminiExecuteError maps executor outcomes to Gemini error.status strings.

func MapGeminiWireStatus

func MapGeminiWireStatus(out execerr.Outcome) string

MapGeminiWireStatus returns the Google RPC status string for a classified executor outcome.

func MapOpenAIExecuteError

func MapOpenAIExecuteError(out execerr.Outcome) (status int, message, errType, code string)

MapOpenAIExecuteError returns wire fields for OpenAI-shaped execute errors (for tests).

func ParseOpenAICancellationCarrier

func ParseOpenAICancellationCarrier(carrierID string) (aLegID, sessionID string, ok bool)

ParseOpenAICancellationCarrier parses an OpenAI Responses cancellation carrier string and extracts the authoritative A-leg and session identifiers (Requirement 18.6).

func ServeHTTP

func ServeHTTP[Opts any](spec *Spec[Opts], w http.ResponseWriter, r *http.Request)

ServeHTTP runs the shared decode → execute → encode pipeline.

Types

type CandidateAssessmentResult

type CandidateAssessmentResult struct {
	// Assessment is the outcome returned by LargeBodyAssessor.AssessLargeBody.
	Assessment largebody.Assessment
	// PermitHeld reports whether the decode-admission permit was held during assessment.
	PermitHeld bool
	// Err is any error returned by AssessLargeBody or assessor resolution.
	Err error
}

CandidateAssessmentResult carries the outcome of candidate proof assessment under decode admission (Task 11.9).

type CandidateCaptureResult

type CandidateCaptureResult struct {
	// Outcome reports whether capture completed, declined, or failed.
	Outcome largebody.CaptureOutcome
	// Source is the completed replay source (non-nil on CaptureOutcomeCompleted).
	Source largebody.Source
	// Completed is the concrete CompletedSource (non-nil on CaptureOutcomeCompleted).
	Completed *largebody.CompletedSource
	// Continuation is the lossless continuation reader (non-nil on CaptureOutcomeDeclined).
	Continuation *largebody.CaptureReader
	// Digest is the replay source integrity digest computed incrementally during capture.
	Digest largebody.SourceDigest
	// BytesRead is the total client body bytes read during capture.
	BytesRead int64
	// ScannerResult carries token and depth facts from the shared streaming JSON scanner.
	ScannerResult jsonshape.Result
	// ScannerErr reports any syntax or limit error from the shared streaming JSON scanner.
	ScannerErr error
	// Err is any underlying error that caused decline or failure.
	Err error
}

CandidateCaptureResult reports the outcome of candidate request body capture (Task 7.4).

func CaptureCandidateBody

func CaptureCandidateBody[Opts any](
	ctx context.Context,
	spec *Spec[Opts],
	w http.ResponseWriter,
	r *http.Request,
	maxBytes int64,
) (CandidateCaptureResult, []byte, error)

CaptureCandidateBody captures the request body for a candidate request while concurrently feeding chunks to the shared streaming JSON scanner (Task 7.4, Requirements 1, 2, 3, 20).

Invariants:

  • Logical spool reservation: early for known content-length, incremental for unknown/chunked.
  • Bounded memory + secure temporary file spill via largebody.SpillBuffer.
  • Shared streaming JSON scanner fed per chunk.
  • Enforces the same request body ceiling as canonical reqbody path (*http.MaxBytesError).
  • On EOF, produces CompletedSource with source integrity digest and finishes scanner.
  • Recoverable decline (budget exhaustion, spill failure, scanner uncertainty) yields a lossless continuation via largebody.CaptureReader.
  • Unknown/chunked final size below threshold declines to canonical from source.

type CandidateProofResult

type CandidateProofResult struct {
	// Output is the compiled proof output (valid when Err is nil).
	Output ProofOutput
	// PermitHeld indicates that the decode-admission permit was held during proof compilation.
	PermitHeld bool
	// Err is any proof compilation or validation error.
	Err error
}

CandidateProofResult carries the outcome of candidate protocol proof under decode admission (Task 7.5).

type Config

type Config struct {
	Exec                    lipsdk.ExecutorView
	DefaultRouteSelector    string
	RoutePrefixes           routeselect.PrefixSet
	MaxRequestBodyBytes     int64
	Log                     *slog.Logger
	TrafficPorts            traffic.PortBundle
	DecodeAdmission         lipsdk.DecodeAdmission
	PreRequestKeepalive     lipsdk.FrontendKeepaliveConfig
	FrontendID              string
	HTTPHeaders             lipsdk.HTTPHeaders
	StreamKeepaliveInterval time.Duration
	LargePayload            LargePayloadConfig
}

Config holds shared handler dependencies for the create pipeline.

type DecodeContext

type DecodeContext struct {
	Ctx              context.Context
	Body             []byte
	RouteSelector    string
	Headers          http.Header
	Path             PathMatch
	URLPath          string
	AnthropicVersion string
}

DecodeContext supplies request inputs for protocol decode.

type Decoded

type Decoded struct {
	Call   *lipapi.Call
	Stream bool
	// RouteSelector is the resolved routing selector used for decode/logging.
	RouteSelector string
	// Extra holds per-request protocol state (continuation, response IDs).
	Extra any
}

Decoded is the outcome of protocol decode + canonical validation prep.

type FrontendProfile

type FrontendProfile interface {
	// ProfileID returns the static identifier for this certified profile
	// (e.g., "openai_responses_v1", "openai_chat_v1", "openresponses_v1").
	ProfileID() string

	// CompileProof compiles protocol proof and response seeds from the
	// captured request replay under decode admission. If the request shape
	// cannot be certified or exceeds semantic-fact bounds, it returns an error
	// to select canonical fallback under the held permit (Requirements 4, 16.7).
	CompileProof(ctx context.Context, in ProofInput) (ProofOutput, error)
}

FrontendProfile is the optional internal contract implemented by certified frontends to support the large-payload fast path (Task 7.1, Requirements 4, 8, 9, 14, 16, 18).

A profile owns:

  • profile identity (ProfileID)
  • protocol semantic proof compilation over captured replay bytes
  • canonical semantic identity digest calculation
  • normalized client-turn shape derivation (ClientTurnShape)
  • session precedence facts (SessionInput)
  • body mode and rewrite semantics (BodyMode, RewriteSemantics, model Span)
  • response-state seeds for post-execution frontend response building

Invariants (Task 7.1, Requirements 8.5, 18.8):

  • No backend selection or provider network I/O inside the profile.
  • Carries bounded facts only; exceeding bounds declines to canonical.
  • Nil profile or missing executor capability => canonical with zero spool allocation.

type FrontendWireState

type FrontendWireState struct {
	ProfileID string
	Proof     largebody.Proof
	Seeds     ResponseStateSeeds
	Extra     any
}

FrontendWireState is the bounded frontend-owned state for a wire request. It couples the provider-neutral Proof with frontend-owned response seeds and optional protocol-specific metadata (Requirement 18.8). Core contracts never import this type.

func (FrontendWireState) Validate

func (s FrontendWireState) Validate(maxFactBytes int64) error

Validate enforces bounds and structural consistency between Proof, Seeds, and ProfileID.

type HookErrorWriter

type HookErrorWriter interface {
	WriteHookError(w http.ResponseWriter, err error) error
}

HookErrorWriter optionally writes AfterDecode/WrapStream errors with protocol envelopes.

type LargePayloadConfig

type LargePayloadConfig = httpcontract.LargePayloadInput

LargePayloadConfig parameterizes the large-payload fast path for a frontend create pipeline (Task 7.3, 7.4, Requirements 1, 2, 20; design section 3, 5).

type OpenAIWire

type OpenAIWire struct{}

OpenAIWire implements WireErrors for OpenAI Responses and legacy Chat Completions shapes.

func (OpenAIWire) WriteAdmissionReject

func (OpenAIWire) WriteAdmissionReject(w http.ResponseWriter, d decodeqos.Decision) error

func (OpenAIWire) WriteBodyTooLarge

func (OpenAIWire) WriteBodyTooLarge(w http.ResponseWriter) error

func (OpenAIWire) WriteEncodeFailed

func (OpenAIWire) WriteEncodeFailed(w http.ResponseWriter) error

func (OpenAIWire) WriteExecuteError

func (OpenAIWire) WriteExecuteError(w http.ResponseWriter, out execerr.Outcome) error

func (OpenAIWire) WriteExecutorNotConfigured

func (OpenAIWire) WriteExecutorNotConfigured(w http.ResponseWriter) error

func (OpenAIWire) WriteInvalidJSON

func (OpenAIWire) WriteInvalidJSON(w http.ResponseWriter) error

func (OpenAIWire) WriteInvalidRequest

func (OpenAIWire) WriteInvalidRequest(w http.ResponseWriter) error

func (OpenAIWire) WritePreflightCanceled

func (OpenAIWire) WritePreflightCanceled(w http.ResponseWriter) error

func (OpenAIWire) WriteReadBodyFailed

func (OpenAIWire) WriteReadBodyFailed(w http.ResponseWriter) error

type PathMatch

type PathMatch struct {
	Model  string
	Stream bool
	Extra  any
}

PathMatch carries path-derived inputs for decode (e.g. Gemini model/stream flag).

type PreCaptureGate

type PreCaptureGate uint8

PreCaptureGate identifies which cheap pre-capture gate made the decision.

const (
	// PreCaptureGateNone represents an unassigned gate (or passed all gates).
	PreCaptureGateNone PreCaptureGate = iota
	// PreCaptureGateFeatureProfileExecutor is Gate 1: feature, profile, and two-phase executor availability.
	PreCaptureGateFeatureProfileExecutor
	// PreCaptureGateKnownLengthThreshold is Gate 2: known identity/uncompressed request length below threshold.
	PreCaptureGateKnownLengthThreshold
	// PreCaptureGateGzipWave1 is Gate 3: gzip compression in Wave 1.
	PreCaptureGateGzipWave1
	// PreCaptureGateStaticDisposition is Gate 4: frozen static disposition DefinitelyCanonical.
	PreCaptureGateStaticDisposition
	// PreCaptureGateLegacyRouteResolver is Gate 5: legacy full-body ResolveRouteSelector configured.
	PreCaptureGateLegacyRouteResolver
)

func (PreCaptureGate) String

func (g PreCaptureGate) String() string

type PreCaptureResult

type PreCaptureResult struct {
	// Candidate reports whether all cheap pre-capture gates passed.
	Candidate bool
	// Gate indicates which gate declined or completed evaluation.
	Gate PreCaptureGate
	// Reason reports the bounded decline reason (matches largebody.StaticWireReason).
	Reason largebody.StaticWireReason
	// Executor is the probed LargeBodyExecutor (non-nil when Candidate is true).
	Executor largebody.LargeBodyExecutor
}

PreCaptureResult carries the outcome of cheap pre-capture candidate evaluation (Task 7.3).

func EvaluatePreCaptureGates

func EvaluatePreCaptureGates[Opts any](spec *Spec[Opts], r *http.Request) PreCaptureResult

EvaluatePreCaptureGates applies cheap pre-capture gates in the exact specification order:

  1. feature/profile/two-phase executor available;
  2. parsed known identity/uncompressed request length below threshold => canonical;
  3. gzip wave 1 => canonical;
  4. frozen static disposition DefinitelyCanonical => canonical;
  5. configured legacy full-body ResolveRouteSelector without bounded contract => canonical;

only then allocate capture/scanner state. Do not trust compressed Content-Length as decoded length. (Requirements 1, 2, 5, 11, 13, 21; design section 2).

func (PreCaptureResult) Declined

func (r PreCaptureResult) Declined() bool

Declined reports whether the request was declined to canonical processing.

type ProofInput

type ProofInput struct {
	Ctx                  context.Context
	Headers              http.Header
	URLPath              string
	Path                 PathMatch
	RouteSelector        string
	RoutePrefixes        routeselect.PrefixSet
	DefaultRouteSelector string
	RouteFromBodyModel   bool
	Source               largebody.Source
	BodyBytes            int64
	AnthropicVersion     string
}

ProofInput supplies request inputs and replay source to the profile proof compiler.

type ProofOutput

type ProofOutput struct {
	State FrontendWireState
}

ProofOutput is the result of profile proof compilation over the captured replay source.

func (ProofOutput) Proof

func (o ProofOutput) Proof() largebody.Proof

Proof returns the underlying provider-neutral largebody.Proof.

func (ProofOutput) Seeds

func (o ProofOutput) Seeds() ResponseStateSeeds

Seeds returns the underlying bounded ResponseStateSeeds.

func (ProofOutput) Validate

func (o ProofOutput) Validate(maxFactBytes int64) error

Validate validates the underlying bounded FrontendWireState.

type ResponseContext

type ResponseContext struct {
	// State is the frontend-owned proof state including response seeds and extra protocol state.
	State FrontendWireState
	// ResponseFacts contains bounded provider-neutral facts returned by ExecuteLargeBody.
	ResponseFacts largebody.ResponseFacts
	// Session carries sensitive session response carriers returned by ExecuteLargeBody.
	Session largebody.SessionResponseCarrier
	// Stream is the canonical event stream returned by ExecuteLargeBody.
	Stream lipapi.EventStream
}

ResponseContext is the bounded shared frontend response context (Task 14.1, Requirement 18). It couples frontend-owned proof state (FrontendWireState) with ExecutionResult (ResponseFacts, sensitive SessionResponseCarrier, and canonical EventStream) to supply stream wrapping and response writers without fabricating a partial or fake lipapi.Call. Core contracts never import this type (Requirement 18.8).

func NewResponseContext

func NewResponseContext(state FrontendWireState, res largebody.ExecutionResult) ResponseContext

NewResponseContext creates an initialized ResponseContext from frontend wire state and wire execution result.

func (ResponseContext) ALegID

func (c ResponseContext) ALegID() string

ALegID returns the authoritative A-leg identifier.

func (ResponseContext) AnthropicMessageID

func (c ResponseContext) AnthropicMessageID() string

AnthropicMessageID returns the Anthropic message ID ("msg_" + DeterministicToken()).

func (ResponseContext) CallID

func (c ResponseContext) CallID() string

CallID returns the effective request / call ID: explicit request ID if present, otherwise the deterministic call ID derived from canonical semantic identity.

func (ResponseContext) CancellationID

func (c ResponseContext) CancellationID() string

CancellationID returns the authoritative cancellation ID. If an authoritative A-leg ID is present, it returns the carrier-bound cancellation ID (Requirement 18.6). Otherwise, it falls back to any explicit seed cancellation ID, or OpenAIChatCompletionID() for Chat completions, or OpenAIResponseID().

func (ResponseContext) ClientModel

func (c ResponseContext) ClientModel() string

ClientModel returns the client-requested model name.

func (ResponseContext) DeterministicCallID

func (c ResponseContext) DeterministicCallID() string

DeterministicCallID returns the path-stable call ID derived from canonical semantic identity.

func (ResponseContext) DeterministicTime

func (c ResponseContext) DeterministicTime() time.Time

DeterministicTime returns the UTC time derived from canonical semantic identity (Requirement 16.4).

func (ResponseContext) DeterministicTimestamp

func (c ResponseContext) DeterministicTimestamp() int64

DeterministicTimestamp returns the Unix timestamp derived from canonical semantic identity.

func (ResponseContext) DeterministicToken

func (c ResponseContext) DeterministicToken() string

DeterministicToken returns the 16-hex-character token derived from canonical semantic identity (Requirement 16.4).

func (ResponseContext) EffectiveModel

func (c ResponseContext) EffectiveModel() string

EffectiveModel returns the candidate/provider effective model if resolved, otherwise the client model.

func (ResponseContext) ExplicitRequestID

func (c ResponseContext) ExplicitRequestID() string

ExplicitRequestID returns any caller-provided or header-supplied request ID.

func (ResponseContext) Extra

func (c ResponseContext) Extra() any

Extra returns any frontend-owned per-request protocol state.

func (ResponseContext) Facts

Facts returns the bounded provider-neutral response facts.

func (ResponseContext) Format

func (c ResponseContext) Format(f fmt.State, verb rune)

Format formats the response context safely for all verbs (%v, %+v, %#v, %s, %q).

func (ResponseContext) GoString

func (c ResponseContext) GoString() string

GoString returns a safe Go syntax representation of ResponseContext.

func (ResponseContext) IsStream

func (c ResponseContext) IsStream() bool

IsStream reports whether streaming delivery was requested.

func (ResponseContext) LogValue

func (c ResponseContext) LogValue() slog.Value

LogValue implements slog.LogValuer to ensure structured logging never exposes sensitive tokens (Requirements 14.7, 22.3).

func (ResponseContext) OpenAIChatCompletionID

func (c ResponseContext) OpenAIChatCompletionID() string

OpenAIChatCompletionID returns the OpenAI Chat completion ID ("chatcmpl_" + DeterministicToken()).

func (ResponseContext) OpenAIMessageID

func (c ResponseContext) OpenAIMessageID() string

OpenAIMessageID returns the OpenAI Responses message ID ("msg_" + OpenAIResponseID()).

func (ResponseContext) OpenAIResponseID

func (c ResponseContext) OpenAIResponseID() string

OpenAIResponseID returns the OpenAI Responses response ID: if an authoritative A-leg ID is present, it returns the cancellation carrier ID bound to that A-leg and session (Requirement 18.6); otherwise, it falls back to the deterministic "resp_" + DeterministicToken() (Requirement 18.7).

func (ResponseContext) ProfileID

func (c ResponseContext) ProfileID() string

ProfileID returns the profile ID identifying the protocol-specific handler.

func (ResponseContext) Proof

func (c ResponseContext) Proof() largebody.Proof

Proof returns the underlying provider-neutral largebody.Proof.

func (ResponseContext) ResponseID

func (c ResponseContext) ResponseID(prefix string) string

ResponseID returns prefix followed by the deterministic token (Requirement 18.7).

func (ResponseContext) ResumeToken

func (c ResponseContext) ResumeToken() largebody.SensitiveString

ResumeToken returns the sensitive resume token carrier.

func (ResponseContext) RouteSelector

func (c ResponseContext) RouteSelector() string

RouteSelector returns the effective routing selector.

func (ResponseContext) Seeds

Seeds returns the underlying bounded ResponseStateSeeds.

func (ResponseContext) SessionCarrier

SessionCarrier returns the sensitive session response carrier.

func (ResponseContext) SessionID

func (c ResponseContext) SessionID() string

SessionID returns the authoritative session identifier.

func (ResponseContext) String

func (c ResponseContext) String() string

String returns a safe, non-sensitive string representation of ResponseContext (Requirements 14.7, 18.2, 22.3). Sensitive resume tokens are never exposed in string renderings.

func (ResponseContext) TraceID

func (c ResponseContext) TraceID() string

TraceID returns the trace identifier.

func (ResponseContext) Validate

func (c ResponseContext) Validate(maxFactBytes int64) error

Validate validates the response context under the given semantic-fact budget.

func (ResponseContext) WriteSessionHeaders

func (c ResponseContext) WriteSessionHeaders(w http.ResponseWriter)

WriteSessionHeaders sets LIP session response headers on w from the sensitive session carrier (Requirements 14.6, 18.2).

func (ResponseContext) WriteSessionHeadersTo

func (c ResponseContext) WriteSessionHeadersTo(h http.Header)

WriteSessionHeadersTo sets LIP session response headers on h from the sensitive session carrier.

type ResponseStateSeeds

type ResponseStateSeeds struct {
	// DeterministicCallID is the path-stable call ID derived from canonical semantic identity.
	DeterministicCallID string
	// DeterministicTimestamp is the Unix timestamp derived from canonical semantic identity.
	DeterministicTimestamp int64
	// DeterministicToken is the 16-hex-character token derived from canonical semantic identity.
	DeterministicToken string
	// ExplicitRequestID is any caller-provided or header-supplied request ID.
	ExplicitRequestID string
	// RouteSelector is the effective routing selector.
	RouteSelector string
	// ClientModel is the requested client model name.
	ClientModel string
	// Stream indicates whether streaming delivery was requested.
	Stream bool
	// CancellationID is the frontend cancellation identifier seed (e.g. for OpenAI Responses).
	CancellationID string
	// SessionID is the client/authoritative session identifier.
	SessionID string
	// ALegID is the authoritative A-leg identifier.
	ALegID string
}

ResponseStateSeeds carries bounded seed facts derived during protocol proof for constructing frontend response headers, IDs, timestamps, and session/cancellation carriers after wire execution (Task 7.1, Requirement 18).

func NewResponseStateSeeds

func NewResponseStateSeeds(
	digest largebody.IdentityDigest,
	explicitReqID string,
	routeSelector string,
	clientModel string,
	stream bool,
	session largebody.SessionInput,
	cancellationID string,
) ResponseStateSeeds

NewResponseStateSeeds creates initialized, bounded response-state seeds from canonical identity digest, session inputs, and route/model facts.

func (ResponseStateSeeds) EffectiveCallID

func (s ResponseStateSeeds) EffectiveCallID() string

EffectiveCallID returns the explicit request ID if non-empty, otherwise the deterministic call ID derived from canonical semantic identity.

func (ResponseStateSeeds) EffectiveTimestamp

func (s ResponseStateSeeds) EffectiveTimestamp() int64

EffectiveTimestamp returns the deterministic timestamp derived from canonical semantic identity.

func (ResponseStateSeeds) Validate

func (s ResponseStateSeeds) Validate(maxFactBytes int64) error

Validate enforces bounds on all string facts under the semantic-fact budget (Requirement 4.2, 4.5).

type Spec

type Spec[Opts any] struct {
	Config
	Wire WireErrors
	// Profile optionally enables large-payload fast-path candidate evaluation (Task 7.1).
	Profile FrontendProfile
	// OnPreCaptureGate optionally observes candidate gate decisions (Task 7.3).
	OnPreCaptureGate func(r *http.Request, res PreCaptureResult)
	// OnCandidateCapture optionally observes candidate capture outcomes (Task 7.4).
	OnCandidateCapture func(r *http.Request, res CandidateCaptureResult)
	// OnCandidateProof optionally observes candidate protocol proof outcomes (Task 7.5).
	OnCandidateProof func(r *http.Request, res CandidateProofResult)
	// OnCandidateAssessment optionally observes candidate assessment outcomes (Task 11.9).
	OnCandidateAssessment func(r *http.Request, res CandidateAssessmentResult)
	// OnWireCommit optionally observes wire commit execution outcomes (Task 11.9).
	OnWireCommit func(r *http.Request, res WireCommitResult)
	// MatchPath returns ok=false for 404. When AltServe is non-nil and invoked, the pipeline stops.
	MatchPath func(path string) (pm PathMatch, ok bool)
	AltServe  func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool
	// ResolveRouteSelector runs after body read; pm is zero when MatchPath did not apply.
	ResolveRouteSelector func(r *http.Request, body []byte, pm PathMatch) string
	Decode               func(DecodeContext) (*Decoded, error)
	AfterDecode          func(ctx context.Context, decoded *Decoded) error
	WrapStream           func(ctx context.Context, decoded *Decoded, inner lipapi.EventStream) (lipapi.EventStream, error)
	OnExecuteError       func(ctx context.Context, decoded *Decoded, err error)
	ClassifyExecute      func(err error) execerr.Outcome
	BuildEncodeOpts      func(decoded *Decoded) Opts
	WriteStream          func(ctx context.Context, w http.ResponseWriter, call *lipapi.Call, es lipapi.EventStream, opts Opts) error
	WriteNonStream       func(ctx context.Context, w http.ResponseWriter, call *lipapi.Call, es lipapi.EventStream, opts Opts) error
	// WireWrapStream optionally wraps the canonical event stream on wire execution using bounded ResponseContext (Requirement 18.4).
	WireWrapStream func(ctx context.Context, rc ResponseContext, inner lipapi.EventStream) (lipapi.EventStream, error)
	// WireWriteStream writes streaming responses on wire execution using bounded ResponseContext (Requirement 18.4).
	WireWriteStream func(ctx context.Context, w http.ResponseWriter, rc ResponseContext, es lipapi.EventStream) error
	// WireWriteNonStream writes non-streaming responses on wire execution using bounded ResponseContext (Requirement 18.4).
	WireWriteNonStream func(ctx context.Context, w http.ResponseWriter, rc ResponseContext, es lipapi.EventStream) error
	// RouteFromBodyModel defaults route selector from JSON model field when header absent.
	RouteFromBodyModel bool
}

Spec parameterizes one frontend's create path.

type StaticDispositionProvider

type StaticDispositionProvider interface {
	LargeBodyStaticDisposition(profileID string) (largebody.StaticWireDisposition, largebody.StaticWireReason)
}

StaticDispositionProvider is the optional interface an executor may implement to supply an O(1) generation-frozen pre-capture disposition (design section 4, 8; Task 3.6, 7.3).

type StatusError

type StatusError struct {
	Status  int
	Type    string
	Code    string
	Message string
	Err     error
}

StatusError is a protocol-mapped HTTP error returned from AfterDecode or WrapStream.

func (*StatusError) Error

func (e *StatusError) Error() string

func (*StatusError) HTTPStatus

func (e *StatusError) HTTPStatus() int

HTTPStatus returns a wire-safe status, never 0.

func (*StatusError) Unwrap

func (e *StatusError) Unwrap() error

type WireCommitResult

type WireCommitResult struct {
	// Assessment is the accepted assessment that authorized the wire commit.
	Assessment largebody.Assessment
	// Result is the outcome returned by LargeBodyWireExecutor.ExecuteLargeBody.
	Result largebody.ExecutionResult
	// ResponseContext is the bounded frontend response context constructed on wire execution (Task 14.1).
	ResponseContext ResponseContext
	// PermitHeld reports whether the decode-admission permit was held during ExecuteLargeBody (must be false).
	PermitHeld bool
	// Err is any error returned by ExecuteLargeBody.
	Err error
}

WireCommitResult carries the outcome of wire commit execution after decode admission permit release (Task 11.9).

type WireErrors

type WireErrors interface {
	WriteBodyTooLarge(w http.ResponseWriter) error
	WriteReadBodyFailed(w http.ResponseWriter) error
	WriteExecutorNotConfigured(w http.ResponseWriter) error
	WritePreflightCanceled(w http.ResponseWriter) error
	WriteInvalidJSON(w http.ResponseWriter) error
	WriteAdmissionReject(w http.ResponseWriter, d decodeqos.Decision) error
	WriteInvalidRequest(w http.ResponseWriter) error
	WriteExecuteError(w http.ResponseWriter, out execerr.Outcome) error
	WriteEncodeFailed(w http.ResponseWriter) error
}

WireErrors writes protocol-legal JSON (or equivalent) error bodies.

Jump to

Keyboard shortcuts

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