extractcache

package
v0.0.57 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0, MIT 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 extractcache stores the raw output of a claim-extraction call, addressed by the content that produced it.

Extraction is 80-95% of a run's wall clock. The only reuse before this was --resume, whose ledger is named for today's date and the first source's filename — so redrafting the same paper tomorrow, or after renaming it, re-paid the whole cost. Addressing by content instead makes a redraft, a rename, and a --merge that overlaps an earlier run all free.

A cache entry is never trusted on its own account. The pipeline still runs claims.Parse over the cached text against the freshly read section, so a stale or tampered entry can only ever produce fewer verified claims, never an ungrounded one. That is the same property that makes --resume safe.

Index

Constants

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

MaxAge bounds how long an entry stays usable. Extraction output is deterministic given the same section, prompt, engine and model, so the limit is about reclaiming disk rather than correctness.

Variables

This section is empty.

Functions

func Clear

func Clear(dir string) error

Clear removes every entry. It refuses a directory that does not look like a cache, so a mistyped DRAFT_CACHE_DIR cannot delete something else.

func Key

func Key(section, reader, promptVersion, engineName, model string) string

Key derives the address of one extraction. Every input that can change the output is folded in: the reader that produced the section text, a prompt edit, an engine switch or a model change all produce a different key rather than silently serving output that different instructions produced.

The reader is included even though its effect already shows up in the section text it produces, so the key is addressed by the full extraction configuration (reader · prompt-version · engine · model · section) — the same identity the run manifest records for reproducibility. Two readers that happened to emit byte-identical section text are still keyed apart.

Types

type Cache

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

Cache is a content-addressed store under a single directory. The zero value and a nil *Cache are both usable and always miss, so a caller that could not open one does not need a branch at every call site.

func Open

func Open(dir string) *Cache

Open returns a cache rooted at dir. An empty dir, or one that cannot be created, yields a cache that always misses: losing reuse is a slow run, and a slow run is a better outcome than a failed one.

func (*Cache) Get

func (c *Cache) Get(key string) (string, bool)

Get returns the cached extraction for key. A missing, unreadable, malformed or expired entry is a miss; an expired one is also removed.

func (*Cache) Put

func (c *Cache) Put(key, text string) error

Put stores text under key. A write failure is reported but is never fatal to a run: the work it would have saved has already been done.

Jump to

Keyboard shortcuts

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