JuliusBrussee/caveman · error
store recovery for oversized memory %s: %w
Error message
store recovery for oversized memory %s: %w
What it means
In headHit, when a memory's compressed form exceeded the whole budget and no CCR handle existed, storing the byte-exact original for recovery failed. The head would drop the tail irrecoverably, so the hit is abandoned to uphold the reversible invariant.
Source
Thrown at mem/store.go:554
// headHit builds a single recall hit for a memory whose compressed form exceeds
// the entire token budget: it truncates the compressed text to a head that fits
// and guarantees a CCR handle to the byte-exact original. When the engine passed
// the payload through without compressing (so it left no handle), the original
// is stored here — a head drops the tail, so the dropped detail must stay
// recoverable, upholding cavemem's reversible invariant.
func (s *Store) headHit(m Memory, compressedText []byte, handle string, score float64, budget int) (Hit, error) {
head := truncateToTokens(compressedText, budget)
if handle == "" {
h, err := s.ccr.Put(ccr.Recovery{
ContentType: "text",
Compressor: "cavemem-head",
TokensBefore: tokenCounter.Count([]byte(m.Text)),
TokensAfter: tokenCounter.Count(head),
Original: []byte(m.Text),
})
if err != nil {
return Hit{}, fmt.Errorf("store recovery for oversized memory %s: %w", m.ID, err)
}
handle = h
}
return Hit{
ID: m.ID,
Text: string(head),
Score: score,
TokensAdded: tokenCounter.Count(head),
Basis: engine.BasisInferred,
RecoveryHandle: handle,
}, nil
}
// truncateToTokens returns the longest byte prefix of b whose inferred token
// count does not exceed budget, ending on a UTF-8 rune boundary. Recovery of the
// dropped tail is byte-exact through the hit's CCR handle.
func truncateToTokens(b []byte, budget int) []byte {
if budget <= 0 {View on GitHub (pinned to 766dce6b13)
Solutions
- Check ccr.db writability and space
- Retry the recall
- Inspect the wrapped storage error
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at mem/store.go:554 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/e7ef2d1c6e45b18b.
Report an issue: GitHub.