JuliusBrussee/caveman · error

broken supersession history at %s: %w

Error message

broken supersession history at %s: %w

What it means

While walking the supersession chain backwards, the predecessor id pointed at a row that could not be read (missing or unreadable). History refuses to return partial lineage, since a broken chain would misrepresent audit history.

Source

Thrown at mem/store.go:291

}

// History returns the complete oldest-to-newest supersession chain containing
// id. Broken/cyclic lineage is rejected rather than returning partial history.
func (s *Store) History(id string) ([]Memory, error) {
	if strings.TrimSpace(id) == "" {
		return nil, fmt.Errorf("history requires memory id")
	}
	current, err := s.memoryByID(id)
	if err != nil {
		return nil, err
	}
	seen := map[string]bool{current.ID: true}
	var before []Memory
	cursor := current
	for cursor.Supersedes != "" {
		prev, err := s.memoryByID(cursor.Supersedes)
		if err != nil {
			return nil, fmt.Errorf("broken supersession history at %s: %w", cursor.ID, err)
		}
		if seen[prev.ID] {
			return nil, fmt.Errorf("cyclic supersession history at %s", prev.ID)
		}
		seen[prev.ID] = true
		before = append(before, prev)
		cursor = prev
	}
	history := make([]Memory, 0, len(before)+1)
	for i := len(before) - 1; i >= 0; i-- {
		history = append(history, before[i])
	}
	history = append(history, current)
	cursor = current
	for cursor.SupersededBy != "" {
		next, err := s.memoryByID(cursor.SupersededBy)
		if err != nil {
			return nil, fmt.Errorf("broken supersession history at %s: %w", cursor.ID, err)

View on GitHub (pinned to 766dce6b13)

Solutions

  1. Inspect the named memory id and its Supersedes pointer in the db
  2. Repair or Forget the broken chain entries
  3. Restore from backup if lineage rows were deleted
Defensive patterns

Strategy: try-catch

When it happens

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