store

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 9 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 store provides the content-addressed decision memo behind the cache-guard contract.

Why it exists: provider prompt caches give ~90% discounts for stable prefixes. The engine's transforms are deterministic today, but determinism is a property of CURRENT parameters — config reloads, preset changes or algorithm upgrades would silently rewrite previously-sent blocks and break caches mid-session. The memo pins decisions by content hash: the same original bytes always yield the exact same compressed bytes for the lifetime of the process, regardless of what parameters say now.

Package store — originals: the reversibility half of the quality contracts. Every squeezed blob's full original text is kept locally, content-addressed by SHA256, so any elision can be resolved back to exact bytes ("reversible" contract).

Persistence is an append-only JSONL file (one record per original) in a user-owned directory; nothing ever leaves the machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RefOf

func RefOf(orig []byte) string

RefOf computes the content reference for an original text.

Types

type Memo

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

Memo is a bounded LRU map from SHA256(original) to compressed bytes. Safe for concurrent use.

func NewMemo

func NewMemo(capacity int) *Memo

NewMemo returns an LRU holding up to cap entries (cap <= 0 = disabled).

func (*Memo) Get

func (m *Memo) Get(orig []byte) ([]byte, bool)

Get returns the pinned output for orig, if seen before.

func (*Memo) Len

func (m *Memo) Len() int

Len reports current occupancy.

func (*Memo) Put

func (m *Memo) Put(orig, comp []byte)

Put pins a decision. Overwrites on re-put of the same key (should not happen when used correctly, but must never corrupt state).

type Originals

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

Originals keeps full source texts keyed by content hash.

func NewOriginals

func NewOriginals() *Originals

NewOriginals returns a memory-only store.

func OpenOriginals

func OpenOriginals(dir string) (*Originals, error)

OpenOriginals returns a store persisted to <dir>/originals.jsonl, loading existing records. Directory is created if missing.

func (*Originals) Get

func (o *Originals) Get(ref string) (string, bool)

Get resolves a ref to the full original text.

func (*Originals) Put

func (o *Originals) Put(orig []byte) (string, error)

Put stores an original and persists it when backed by a directory. Returns the content ref.

func (*Originals) Resolve

func (o *Originals) Resolve(prefix string) (string, error)

Resolve finds an original by a (possibly truncated) ref prefix as it may appear in markers typed by humans or models. Ambiguous prefixes error.

Jump to

Keyboard shortcuts

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