Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cache stores finished reviews on disk, keyed by everything that shapes them, so an unchanged spec reviewed again with unchanged settings costs nothing and gets the same verdict.

Agents and CI re-run the gate on the same spec over and over. A model asked the same question twice may answer differently, so caching also makes the gate stable: the verdict changes only when the spec or the settings do.

Index

Constants

View Source
const DefaultMaxAge = 30 * 24 * time.Hour

DefaultMaxAge is how long a stored review is used. Older entries are ignored and removed.

Variables

View Source
var ErrUnknownBuild = errors.New("cannot identify this build of speccritic")

ErrUnknownBuild is returned by Key when the running program cannot be identified. Caching is then off: a review from another build could be served after an upgrade.

Functions

func Key

func Key(material any) (string, error)

Key returns the key for material, which must hold everything that can change the review: the prompts sent, the model and its settings, and the build of this program.

Types

type Store

type Store struct {
	Dir    string
	MaxAge time.Duration
	// contains filtered or unexported fields
}

Store keeps reviews in one directory, one file per key.

func Default

func Default() (*Store, error)

Default returns the store in SPECCRITIC_CACHE_DIR if set, and otherwise in the user's cache directory.

func New

func New(dir string) *Store

New returns a store in dir.

func (*Store) Get

func (s *Store) Get(key string) (*schema.Report, time.Time, bool)

Get returns the review stored under key and when it was stored. A missing, unreadable, stale or corrupt entry is a miss.

func (*Store) Put

func (s *Store) Put(key string, report *schema.Report) error

Put stores report under key. The file is written whole or not at all, so a concurrent reader never sees half of it. Entries past their age are removed on the way.

Jump to

Keyboard shortcuts

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