compression

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package compression implements the file-read compression pipeline that produces a token-optimized rendering of a file given Grove's symbols and the current session state.

Index

Constants

View Source
const MaxTokensPerFile = 50000

MaxTokensPerFile caps the size of any single compressed file response.

Variables

This section is empty.

Functions

func Hash

func Hash(content string) string

Hash returns the SHA-256 hex of content. Used as the cache key.

func SHAPointer added in v0.25.0

func SHAPointer(filePath, contentHash string, accessCount int) string

SHAPointer is the exported form of renderSHAPointer for delivery surfaces outside the compressor (prism_explore emits the same cache pointer when a file's full content was already delivered this session).

func SymbolKey added in v0.7.0

func SymbolKey(s grove.SymbolRecord) string

SymbolKey is the identity a symbol's SHA is stored under: the qualified name when present (unique within a file since Grove v0.6.0 qualifies members by parent), else the bare name. Keying by bare name alone made same-named members in one file (two receivers' Close()) collide, which could pointer a changed body inside a "lossless" delta.

Types

type Options

type Options struct {
	Task            string               // unused by file-read compression (see above)
	Symbols         []grove.SymbolRecord // symbols in this file (from Grove)
	Session         *session.Tracker
	Ledger          *session.Ledger
	TokenLedgerName string // tool name to bill ledger ("prism_read")
	Confidence      session.Confidence
	ContextUsed     int64 // agent-reported context size at this call (0 = not reported)
}

Options configures CompressFileRead.

Task is retained for API compatibility and potential future use, but it intentionally does NOT influence a first read: Prism delivers the complete file on first read and never trims symbol bodies by relevance, since a lossy first-read reconstruction silently drops content the model has never seen. All compression happens on the safe re-read paths (sha-pointer and the lossless semantic delta), which key off Session state, not relevance.

type Result

type Result struct {
	FilePath        string
	Content         string
	Strategy        string // "full-fresh" | "semantic-delta" | "session-signature" | "sha-pointer" | "escalated-full"
	OriginalTokens  int
	DeliveredTokens int
	SavingsPercent  float64
}

Result is the output of CompressFileRead.

func CompressFileRead

func CompressFileRead(filePath, content string, opts Options) Result

CompressFileRead returns the rendered output and ledger metadata.

Jump to

Keyboard shortcuts

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