injection

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

Documentation

Overview

Package injection applies a bounded, provider-neutral continuity projection to a canonical call. It owns only the pure request mutation; durable branch pending/release state remains with the preserver and coordinator layers.

Index

Constants

View Source
const (
	// ProjectionVersion is the model-facing continuity block format version.
	ProjectionVersion = 1
	// BlockStart and BlockEnd are deliberately explicit delimiters. They make
	// the proxy-owned block distinguishable from user text without exposing
	// storage integrity metadata.
	BlockStart = "<LIP-CONTINUITY version=\"1\" begin>\n"
	BlockEnd   = "\n<LIP-CONTINUITY version=\"1\" end>"
)

Variables

View Source
var (
	ErrInvalidInput      = errors.New("compactioncontinuity/injection: invalid input")
	ErrInvalidMarker     = errors.New("compactioncontinuity/injection: invalid call-local marker")
	ErrProjectionBudget  = errors.New("compactioncontinuity/injection: projection budget exceeded")
	ErrProjectionVerify  = errors.New("compactioncontinuity/injection: capsule verification failed")
	ErrProjectionInvalid = errors.New("compactioncontinuity/injection: injected call is invalid")
)

Functions

func HasProjection

func HasProjection(call lipapi.Call, e capsule.Envelope, expectedBranch string, limits ProjectionLimits) bool

HasProjection reports whether the current authority's final canonical carrier already contains this exact bounded projection. It is call-local deduplication only; durable branch release state remains coordinator-owned.

func Serialize

func Serialize(e capsule.Envelope, expectedBranch string, limits ProjectionLimits) ([]byte, error)

Serialize is a concise alias for SerializeBlock.

func SerializeBlock

func SerializeBlock(e capsule.Envelope, expectedBranch string, limits ProjectionLimits) ([]byte, error)

SerializeBlock verifies e against expectedBranch and emits the stable, delimited model-facing projection. BranchBinding and ContentDigest are integrity metadata and are intentionally absent from the projection.

func TokenEquivalent

func TokenEquivalent(b []byte) int

TokenEquivalent returns the deterministic conservative budget estimate used by this package. It is intentionally a byte-equivalent estimate, not provider tokenizer output.

Types

type AppliedMarker

type AppliedMarker = Marker

AppliedMarker is a descriptive alias for callers that want to distinguish the returned marker from durable branch watermarks.

type Input

type Input struct {
	Call                  lipapi.Call
	Capsule               capsule.Envelope
	ExpectedBranchBinding string
	BoundaryKey           string
	Limits                ProjectionLimits
	// Marker is the ephemeral marker from a prior attempt in this call-local
	// lifecycle. A matching marker makes injection an idempotent no-op.
	Marker Marker
}

Input is the pure injection request. Capsule must already be a locally available value; Inject rechecks its branch binding and content digest before creating any model-facing text.

type Limits

type Limits = ProjectionLimits

Limits is the short name used by orchestration callers.

type Marker

type Marker struct {
	BranchBinding   string
	BoundaryKey     string
	CapsuleRevision uint64
}

Marker identifies one call-local application. It deliberately contains no durable state and is returned to the caller for retry/failover preparation.

type Outcome

type Outcome struct {
	Call            lipapi.Call
	Marker          Marker
	Applied         bool
	Bytes           int
	TokenEquivalent int
	Block           []byte
}

Outcome describes one pure application attempt. On every error, Call is the exact input value and Marker is zero. On a matching marker, Call and Marker are retained and Applied is false.

func Apply

func Apply(in Input) (Outcome, error)

Apply is an expressive alias for Inject.

func Inject

func Inject(in Input) (Outcome, error)

Inject applies one continuity block to the appropriate canonical authority. The operation is transactional: all validation occurs before the cloned call is returned, and failures return the original call and a zero marker.

type ProjectionLimits

type ProjectionLimits struct {
	MaxBytes           int
	MaxTokens          int
	MaxTokenEquivalent int
}

ProjectionLimits bounds the complete serialized model-facing block. A zero bound means that dimension is not additionally constrained; negative bounds are invalid. TokenEquivalent uses the conservative one UTF-8 byte per unit convention shared by capsule bounds and extractor accounting.

Jump to

Keyboard shortcuts

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