JuliusBrussee/caveman · error
memory is not current
Error message
memory %s is not current
What it means
Supersede looks up the target with `WHERE id = ? AND valid_until IS NULL`; when no current row matches (sql.ErrNoRows), it fails closed with 'memory %s is not current'. This covers both unknown ids and ids whose only versions are already expired/superseded, guaranteeing lineage is never corrupted.
Solutions
- Recall the current memories first and use a live id (valid_until IS NULL) as oldID.
- Make supersede scripts idempotent: skip if the current text already equals newText, or handle 'is not current' as already-done.
- Verify you are connected to the same store the id came from.
- Check the id for typos/truncation against the value returned by Remember.
Example fix
// before
_, err := store.Supersede(oldID, newText) // fails if already superseded
// after
_, err := store.Supersede(oldID, newText)
if err != nil && strings.Contains(err.Error(), "is not current") {
return nil // idempotent: already superseded
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: confirm the id is still current via Recall before superseding
cur, _ := store.Recall(oldID) // or your lookup helper
if cur.ID != oldID || cur.ValidUntil != nil { skip } Try / catch
_, err := store.Supersede(oldID, newText)
if err != nil && strings.Contains(err.Error(), "is not current") {
return nil // idempotent: unknown or already superseded
} Prevention
- Fetch a fresh id via Recall rather than caching old snapshots
- Write idempotent scripts that tolerate 'is not current'
- Never truncate or reformat ids when storing them
- Point all callers at the same store file to avoid cross-db ids
When it happens
Trigger: Calling Supersede with an id that was never stored, a typo'd/truncated id, an id whose memory was already superseded or expired, or an id from a different database file.
Common situations: Replaying a script a second time (the first run already superseded the id); using an id captured from an old Recalled snapshot that has since been replaced; environment mixups pointing at another store.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- memory exists only as an expired historical version and…
- MCP config or ownership journal changed during interrupted…
- MCP transaction journals disagree; refusing recovery
- caveman agent: baseline model unavailable
- caveman agent: unknown model
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/30dab7344e88b64c.
Report an issue: GitHub.
Appendix: source
Thrown at mem/store.go:220
if strings.TrimSpace(oldID) == "" {
return Memory{}, fmt.Errorf("supersede requires old memory id")
}
if strings.TrimSpace(newText) == "" {
return Memory{}, fmt.Errorf("cannot supersede with empty text")
}
if err := validateMemorySize(newText); err != nil {
return Memory{}, err
}
tx, err := s.db.Begin()
if err != nil {
return Memory{}, fmt.Errorf("supersede begin: %w", err)
}
defer tx.Rollback()
var old Memory
if err := scanMemory(tx.QueryRow(memorySelect+` WHERE id = ? AND valid_until IS NULL`, oldID), &old); err != nil {
if err == sql.ErrNoRows {
return Memory{}, fmt.Errorf("memory %s is not current", oldID)
}
return Memory{}, fmt.Errorf("read current memory: %w", err)
}
if old.Text == newText {
return Memory{}, fmt.Errorf("replacement text is identical to current memory")
}
newID := memID(newText)
var exists int
if err := tx.QueryRow(`SELECT COUNT(*) FROM memories WHERE id = ?`, newID).Scan(&exists); err != nil {
return Memory{}, fmt.Errorf("check replacement memory: %w", err)
}
if exists > 0 {
return Memory{}, fmt.Errorf("replacement memory %s already exists", newID)
}
now := time.Now().UTC().Format(time.RFC3339Nano)
if _, err := tx.Exec(
`INSERT INTO memories
(id, text, created_at, valid_from, supersedes)View on GitHub (pinned to 3ee70a1026)