JuliusBrussee/caveman · error

supersede commit: %w

Error message

supersede commit: %w

What it means

Committing the supersede transaction failed after the insert and expiry succeeded in-transaction. On commit failure everything rolls back: the old memory stays current and no partial lineage is left behind.

Source

Thrown at mem/store.go:257

		 VALUES (?, ?, ?, ?, ?)`,
		newID, newText, now, now, oldID,
	); err != nil {
		return Memory{}, fmt.Errorf("insert replacement memory: %w", err)
	}
	res, err := tx.Exec(
		`UPDATE memories
		    SET valid_until = ?, superseded_by = ?
		  WHERE id = ? AND valid_until IS NULL`,
		now, newID, oldID,
	)
	if err != nil {
		return Memory{}, fmt.Errorf("expire old memory: %w", err)
	}
	if n, _ := res.RowsAffected(); n != 1 {
		return Memory{}, fmt.Errorf("memory %s changed during supersede", oldID)
	}
	if err := tx.Commit(); err != nil {
		return Memory{}, fmt.Errorf("supersede commit: %w", err)
	}
	return Memory{
		ID:         newID,
		Text:       newText,
		CreatedAt:  now,
		ValidFrom:  now,
		Supersedes: oldID,
	}, nil
}

func validateMemorySize(text string) error {
	if len(text) > MaxMemoryBytes {
		return fmt.Errorf("%w: memory is %d bytes, over the %d-byte cap", ErrMemoryTooLarge, len(text), MaxMemoryBytes)
	}
	return nil
}

// History returns the complete oldest-to-newest supersession chain containing

View on GitHub (pinned to 766dce6b13)

Solutions

  1. Retry the supersede from the start
  2. Check disk I/O errors and db locks
  3. Verify db integrity if it recurs
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at mem/store.go:257 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/a98902ba9b65677b. Report an issue: GitHub.