Documentation
¶
Overview ¶
Package completion defines the completion-gate extension contract (design §6, R8). Gates observe a bounded buffered canonical event slice for one attempt and return a typed outcome; core enforces buffer limits and fail-open behavior on errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BufferLimits ¶
type BufferLimits struct {
// MaxEvents is the maximum number of canonical stream events retained; exceeding fails open to live passthrough.
MaxEvents int
}
BufferLimits bounds memory retained while completion gating buffers before first output (R8). Zero value applies DefaultBufferLimits.
func DefaultBufferLimits ¶
func DefaultBufferLimits() BufferLimits
DefaultBufferLimits returns conservative defaults for production composition roots.
func (BufferLimits) OverCapacity ¶
func (l BufferLimits) OverCapacity(events int) bool
OverCapacity reports whether len(events) exceeds MaxEvents after normalization.
type Buffered ¶
type Buffered struct {
// contains filtered or unexported fields
}
Buffered is an immutable view of canonical events passed to a gate (defensive copy).
func NewBuffered ¶
NewBuffered returns a view backed by a copy of events.
type Gate ¶
type Gate interface {
ID() string
Order() int
FailureMode() sdkhooks.FailureMode
Handle(ctx context.Context, meta Meta, buf Buffered, svc Services) (Outcome, error)
}
Gate performs whole-completion control after bounded buffering (R8, design §6).
func MaterializeSorted ¶
MaterializeSorted returns a copy of gates sorted for stable execution (design §17).
type Meta ¶
type Meta struct {
TraceID string
ALegID string
BLegID string
AttemptSeq int
Scope scope.PrincipalScopeView
Session session.SessionView
Workspace workspace.WorkspaceView
}
Meta carries attempt-scoped identifiers and safe decision context for completion gates (no transport types). Scope is the authoritative principal/scope attribution; Session and Workspace provide the lifecycle context needed for completion-gate decision evidence (requirement 2.1, 2.6). Existing identifiers are preserved; a zero Scope preserves local/anonymous identity semantics.
type Outcome ¶
type Outcome struct {
Kind OutcomeKind
// Events is the replacement stream when Kind == OutcomeReplace.
Events []lipapi.Event
// Err is required when Kind == OutcomeReject.
Err error
}
Outcome is the result of one gate invocation.
func PassOriginalOutcome ¶
func PassOriginalOutcome() Outcome
PassOriginalOutcome returns OutcomePassOriginal.
func ReplaceOutcome ¶
ReplaceOutcome builds an OutcomeReplace. Events must be non-empty; callers should end with EventResponseFinished.
func ReplayOriginalOutcome ¶
func ReplayOriginalOutcome() Outcome
ReplayOriginalOutcome returns OutcomeReplayOriginal.
type OutcomeKind ¶
type OutcomeKind int
OutcomeKind is the typed gate decision (design §6).
const ( // OutcomePassOriginal leaves the current buffered completion unchanged for downstream gates / emit. OutcomePassOriginal OutcomeKind = iota // OutcomeReplace substitutes the completion with Events (must end with EventResponseFinished when stream completed). OutcomeReplace // OutcomeReplayOriginal resets the working buffer to the original completion snapshot (design §17 incomplete replay). OutcomeReplayOriginal // OutcomeReject fails the response path with Err (surfaced like hook rejection). OutcomeReject )