Documentation
¶
Overview ¶
Package localturn defines the trusted extension contract for generic proxy-local turn handling.
Handlers are explicitly contributed via FeatureBundle and frozen into an immutable runtime snapshot. Match is a pure examination of the normalized canonical ingress call; it may only claim complete message indexes with bounded reason codes. Handle returns bounded assistant text (≤64KiB) from which core constructs the canonical assistant message and local stream. No arbitrary streams or provider calls are produced by handlers.
Handler.FailureMode uses pkg/lipsdk/hooks.FailureMode (FailOpen/FailClosed) applied to Match errors before claim; after claim all failures are fail-closed by the runtime. Package localturn does not import internal packages.
Index ¶
Constants ¶
const ( MaxReasonCodeBytes = 64 MaxReplyTextBytes = 64 * 1024 MaxHandlerIDBytes = 128 )
Bounds: consistent with steering's 64KiB cap.
const ( FailureModeUnspecified = hooks.FailureModeUnspecified FailOpen = hooks.FailOpen FailClosed = hooks.FailClosed )
Variables ¶
This section is empty.
Functions ¶
func IsNilHandler ¶
IsNilHandler reports whether h is nil or a typed-nil handler value.
func ValidateHandlerID ¶
ValidateHandlerID reports whether id is a bounded ascii identifier for a handler. Exported for feature-bundle validation; keeps vet/lint from flagging unused helper.
Types ¶
type FailureMode ¶
type FailureMode = hooks.FailureMode
Re-export hooks failure mode for convenience; handlers must not import internal.
type HandleInput ¶
type HandleInput struct {
Call lipapi.Call
Meta Meta
Match MatchResult
}
HandleInput is the input to Handler.Handle after successful source tagging.
type Handler ¶
type Handler interface {
ID() string
Order() int
FailureMode() hooks.FailureMode
Match(ctx context.Context, call lipapi.Call, meta Meta) (MatchResult, error)
Handle(ctx context.Context, input HandleInput) (Reply, error)
}
Handler is the generic local-turn extension seam contributed via FeatureBundle.
func MaterializeSorted ¶
MaterializeSorted returns a defensive copy of handlers sorted by Order ascending and then ID. Stable sorting preserves original order for exact ties.
type MatchResult ¶
type MatchResult struct {
Claimed bool
Indexes []int
Reason ReasonCode
}
MatchResult claims zero or more complete normalized source messages for local handling. When Claimed is false, the handler passes and Indexes/Reasons must be empty. When Claimed is true, Indexes identifies the complete message indexes in the normalized ingress call and Reason is the bounded identifier for source tagging.
func (MatchResult) Validate ¶
func (m MatchResult) Validate(meta Meta) error
Validate reports whether the match result is well-formed for the given Meta. It enforces: claimed => non-empty indexes with bounded reason and each index in range, all indexes are distinct, non-claimed => empty indexes and empty reason.
type Meta ¶
Meta carries authoritative per-request context for Match. MessageCount is the number of complete normalized messages in the ingress call available for claiming. Handlers must not claim indexes outside [0, MessageCount).
type ReasonCode ¶
type ReasonCode string
ReasonCode is a bounded non-secret identifier for diagnostics.
func (ReasonCode) Validate ¶
func (r ReasonCode) Validate() error
Validate reports whether the reason code is a bounded ascii identifier.