Add a duplication detection.

This change introduces a duplication detection mechanism that computes
the Levenshtein distance between existing entries and new entries to
determine if they are logical duplicates. By default, this is only
applied to the top 10% of all records so that history doesn't become
sporadic. More specifically, this implementation considers records as
duplicates only if they are similar in both time and space.

This feature is mainly intended to reduce the number of duplicate values
that would otherwise clutter the history by assuming that the last
record selected is the "correct" record.
Remove conflicting history entries.

When changing history entry A to contain the same text as history entry
B, a unique constraint would be violated. This change eagerly determines
if another entry will conflict on an update and deletes it.
Removed event/history coupling.