engine

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package engine hosts the squoze optimization pipeline.

v2 pipeline: detect wire format → walk message structures with targeted JSON-path edits (gjson/sjson) → squeeze only provably-safe text (machine output classified by the router) → report savings. Untouched bytes stay byte-identical: sjson edits in place instead of re-marshalling maps, which is what keeps provider prompt caches stable.

Contracts: fail-open (unknown/invalid input passes through), never-elide (error lines survive), savings floor, idempotent markers.

Index

Constants

View Source
const DefaultMemoCapacity = 4096

DefaultMemoCapacity bounds pinned decisions per process (~4k blobs).

View Source
const Version = "0.1.3"

Version is reported by `squoze version` and stamped into response headers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the pipeline with its cache-guard state attached.

func Default

func Default() *Engine

Default returns the package-level shared engine.

func NewEngine

func NewEngine(memoCapacity int) *Engine

NewEngine returns an isolated pipeline instance with memory-only originals.

func NewEngineWith

func NewEngineWith(memoCapacity int, orig *store.Originals) *Engine

NewEngineWith attaches an external originals store (e.g. persisted).

func (*Engine) Apply

func (e *Engine) Apply(body []byte) ([]byte, Result)

Apply runs the full pipeline: detect → route → squeeze (profile- and memo-aware) → report. Unknown or invalid input passes through byte-for-byte (fail-open).

type Result

type Result struct {
	Format         wire.Format
	Family         string // model family the request was optimized for
	OriginalBytes  int
	SentBytes      int
	SavedBytes     int
	BlocksSqueezed int
	MemoHits       int // blocks served byte-identical from the decision memo
	Transforms     []string
}

Result describes one processed request body.

func Process

func Process(body []byte) ([]byte, Result)

Process runs the default engine over a request body.

Jump to

Keyboard shortcuts

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