Fix LT-21598: Find and Fix repairs LexReferences with duplicate Targets#381
Merged
Conversation
A LexReference could list the same Target object more than once, leading to a crash. Find and Fix now counts distinct Targets. It removes duplicate Targets from a LexReference (keeping the first occurrence), and removes the LexReference altogether when fewer than two distinct Targets remain. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jasonleenaylor
approved these changes
Jun 25, 2026
jasonleenaylor
left a comment
Contributor
There was a problem hiding this comment.
@jasonleenaylor reviewed 6 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on mark-sil).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
LexReference(lexical relation) could list the same Target object more thanonce. This invalid state can lead to crashes — the incoming-reference index
deduplicates, so the duplicated Target and the relation's references get out of
sync, leaving stale references to objects when they are later processed.
This is the data-repair companion to the runtime fix in #380: that PR makes the
model robust against the corrupt data, and this PR teaches Find and Fix to
repair it.
Change (
SequenceFixer)Find and Fix now counts distinct Targets of a
LexReference:Targets are removed (the first occurrence of each is kept).
LexReferenceisremoved (and the owning
LexRefType's reference to it). This generalizes theexisting "too few Targets" rule, which previously counted raw entries and so
missed e.g. a relation listing one sense twice.
Testing
DuplicateLexReferenceTargetscovering the three cases:duplicate removed (relation kept), all-duplicate (relation removed), and a
valid relation left untouched. Existing fixer tests still pass.
FwDataFixermade 42 repairs (38 duplicate Targets removed, 4 now-invalidrelations removed), leaving 0 LexReferences with duplicate or fewer-than-two
distinct Targets.
🤖 Generated with Claude Code
This change is