Prepare occurrence chronology keys before sorting
This commit is contained in:
@@ -453,6 +453,12 @@ or stage interpreter is established by this finding.
|
|||||||
|
|
||||||
### CAT-019 — Sorting Recomputes Invariant Evidence Keys
|
### CAT-019 — Sorting Recomputes Invariant Evidence Keys
|
||||||
|
|
||||||
|
**Progress:** NPC and location occurrence normalizers prepare earliest valid
|
||||||
|
positions once per owned record; location kind rank is also prepared once.
|
||||||
|
Defensive comparators and genuine evidence tie comparisons remain. Literal
|
||||||
|
long-tie, non-monotonic, invalid-reference, duplicate, and existing validator
|
||||||
|
tests pass. Item and enemy-event work remains pending.
|
||||||
|
|
||||||
**Assessment:** Local algorithmic opportunity; original P3.
|
**Assessment:** Local algorithmic opportunity; original P3.
|
||||||
|
|
||||||
**Source:** [EFF-003](02-efficiency.md#eff-003--derive-invariant-sort-keys-once-per-normalized-record).
|
**Source:** [EFF-003](02-efficiency.md#eff-003--derive-invariant-sort-keys-once-per-normalized-record).
|
||||||
|
|||||||
@@ -823,6 +823,13 @@ Update relevant D&D internals/catalog.
|
|||||||
|
|
||||||
## Stage 30 — Prepare NPC And Location Sort Keys Once
|
## Stage 30 — Prepare NPC And Location Sort Keys Once
|
||||||
|
|
||||||
|
**Completed.** NPC and location normalization prepare earliest valid positions
|
||||||
|
once per owned record; location kind ranks are also prepared once. Defensive
|
||||||
|
comparators remain, and evidence ties retain their established comparison. Literal
|
||||||
|
long-tie, non-monotonic, invalid-reference, duplicate and existing permutation
|
||||||
|
coverage passes with the specified normalizer and validator suites. Item and
|
||||||
|
enemy sorting follow next.
|
||||||
|
|
||||||
**Coverage:** CAT-019 first families. **Prerequisites:** Stages 28–29.
|
**Coverage:** CAT-019 first families. **Prerequisites:** Stages 28–29.
|
||||||
|
|
||||||
Decorate owned records with earliest valid position/invariant scalars before sort,
|
Decorate owned records with earliest valid position/invariant scalars before sort,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func TestCollapseDuplicatesPreservesIndependentEvidenceAndOriginalIndices(t *tes
|
|||||||
a := dnd.LocationOccurrence{LocationID: "place", Name: "Inn", Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: []source.SourceRef{ref(10)}}
|
a := dnd.LocationOccurrence{LocationID: "place", Name: "Inn", Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: []source.SourceRef{ref(10)}}
|
||||||
b := dnd.LocationOccurrence{LocationID: "place", Name: "Inn", Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: []source.SourceRef{ref(20)}}
|
b := dnd.LocationOccurrence{LocationID: "place", Name: "Inn", Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: []source.SourceRef{ref(20)}}
|
||||||
invalid := dnd.LocationOccurrence{LocationID: "place", Name: "Inn", Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: []source.SourceRef{ref(999)}}
|
invalid := dnd.LocationOccurrence{LocationID: "place", Name: "Inn", Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: []source.SourceRef{ref(999)}}
|
||||||
records := []normalizedRecord{{a, 10}, {b, 20}, {invalid, 30}, {b, 40}, {invalid, 50}, {a, 60}}
|
records := []normalizedRecord{{occurrence: a, inputIndex: 10}, {occurrence: b, inputIndex: 20}, {occurrence: invalid, inputIndex: 30}, {occurrence: b, inputIndex: 40}, {occurrence: invalid, inputIndex: 50}, {occurrence: a, inputIndex: 60}}
|
||||||
output, findings := collapseDuplicates(records, source.NewDocumentIndex(doc))
|
output, findings := collapseDuplicates(records, source.NewDocumentIndex(doc))
|
||||||
if want := []dnd.LocationOccurrence{a, b, invalid, invalid}; !reflect.DeepEqual(output, want) {
|
if want := []dnd.LocationOccurrence{a, b, invalid, invalid}; !reflect.DeepEqual(output, want) {
|
||||||
t.Fatalf("output = %#v, want %#v", output, want)
|
t.Fatalf("output = %#v, want %#v", output, want)
|
||||||
@@ -25,7 +25,7 @@ func TestCollapseDuplicatesPreservesIndependentEvidenceAndOriginalIndices(t *tes
|
|||||||
if len(findings) != 2 || !strings.Contains(findings[0].Message, "retained input index 10") || !strings.Contains(findings[0].Message, "removed input index 60") || !strings.Contains(findings[1].Message, "retained input index 20") || !strings.Contains(findings[1].Message, "removed input index 40") {
|
if len(findings) != 2 || !strings.Contains(findings[0].Message, "retained input index 10") || !strings.Contains(findings[0].Message, "removed input index 60") || !strings.Contains(findings[1].Message, "retained input index 20") || !strings.Contains(findings[1].Message, "removed input index 40") {
|
||||||
t.Fatalf("findings = %#v", findings)
|
t.Fatalf("findings = %#v", findings)
|
||||||
}
|
}
|
||||||
_, reversed := collapseDuplicates([]normalizedRecord{{b, 20}, {a, 10}, {a, 60}, {b, 40}}, source.NewDocumentIndex(doc))
|
_, reversed := collapseDuplicates([]normalizedRecord{{occurrence: b, inputIndex: 20}, {occurrence: a, inputIndex: 10}, {occurrence: a, inputIndex: 60}, {occurrence: b, inputIndex: 40}}, source.NewDocumentIndex(doc))
|
||||||
if len(reversed) != 2 || !strings.Contains(reversed[0].Message, "retained input index 20") || !strings.Contains(reversed[1].Message, "retained input index 10") {
|
if len(reversed) != 2 || !strings.Contains(reversed[0].Message, "retained input index 20") || !strings.Contains(reversed[1].Message, "retained input index 10") {
|
||||||
t.Fatalf("permuted findings = %#v", reversed)
|
t.Fatalf("permuted findings = %#v", reversed)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,8 +91,11 @@ func (n *Normalizer) PrepareNormalize(ctx context.Context, req contracts.Normali
|
|||||||
}
|
}
|
||||||
|
|
||||||
type normalizedRecord struct {
|
type normalizedRecord struct {
|
||||||
occurrence dnd.LocationOccurrence
|
occurrence dnd.LocationOccurrence
|
||||||
inputIndex int
|
inputIndex int
|
||||||
|
earliest int
|
||||||
|
hasEvidence bool
|
||||||
|
kindRank int
|
||||||
}
|
}
|
||||||
|
|
||||||
type nameCanonicalization struct{ from, to string }
|
type nameCanonicalization struct{ from, to string }
|
||||||
@@ -105,7 +108,8 @@ func normalizeList(input dnd.LocationOccurrenceList, documentIndex source.Docume
|
|||||||
findings := make([]diagnostics.Finding, 0)
|
findings := make([]diagnostics.Finding, 0)
|
||||||
for index, inputOccurrence := range input.Occurrences {
|
for index, inputOccurrence := range input.Occurrences {
|
||||||
occurrence, change, found, refsChanged := normalizeOccurrence(inputOccurrence, order, registry)
|
occurrence, change, found, refsChanged := normalizeOccurrence(inputOccurrence, order, registry)
|
||||||
records[index] = normalizedRecord{occurrence: occurrence, inputIndex: index}
|
earliest, hasEvidence := order.EarliestValid(occurrence.SourceRefs)
|
||||||
|
records[index] = normalizedRecord{occurrence: occurrence, inputIndex: index, earliest: earliest, hasEvidence: hasEvidence, kindRank: kindOrder(occurrence.Kind)}
|
||||||
if change != nil {
|
if change != nil {
|
||||||
findings = append(findings, diagnostics.Finding{Scope: occurrenceScope(index), ReasonCode: ReasonCodeNameCanonicalized,
|
findings = append(findings, diagnostics.Finding{Scope: occurrenceScope(index), ReasonCode: ReasonCodeNameCanonicalized,
|
||||||
Message: fmt.Sprintf("input index %d: location name canonicalized from %s to %s", index, diagnostics.Quote(change.from), diagnostics.Quote(change.to))})
|
Message: fmt.Sprintf("input index %d: location name canonicalized from %s to %s", index, diagnostics.Quote(change.from), diagnostics.Quote(change.to))})
|
||||||
@@ -120,7 +124,14 @@ func normalizeList(input dnd.LocationOccurrenceList, documentIndex source.Docume
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.SliceStable(records, func(left, right int) bool {
|
sort.SliceStable(records, func(left, right int) bool {
|
||||||
return lessOccurrence(order, records[left].occurrence, records[right].occurrence)
|
l, r := records[left], records[right]
|
||||||
|
if l.hasEvidence != r.hasEvidence {
|
||||||
|
return l.hasEvidence
|
||||||
|
}
|
||||||
|
if l.hasEvidence && l.earliest != r.earliest {
|
||||||
|
return l.earliest < r.earliest
|
||||||
|
}
|
||||||
|
return lessOccurrenceTies(order, l.occurrence, r.occurrence, l.kindRank, r.kindRank)
|
||||||
})
|
})
|
||||||
for position, record := range records {
|
for position, record := range records {
|
||||||
if position != record.inputIndex {
|
if position != record.inputIndex {
|
||||||
@@ -236,14 +247,19 @@ func lessOccurrence(order shared.SourceRefOrder, left, right dnd.LocationOccurre
|
|||||||
if leftHasEvidence && leftPosition != rightPosition {
|
if leftHasEvidence && leftPosition != rightPosition {
|
||||||
return leftPosition < rightPosition
|
return leftPosition < rightPosition
|
||||||
}
|
}
|
||||||
|
return lessOccurrenceTies(order, left, right, kindOrder(left.Kind), kindOrder(right.Kind))
|
||||||
|
}
|
||||||
|
|
||||||
|
// The normalizer has already established equal earliest-evidence keys here.
|
||||||
|
func lessOccurrenceTies(order shared.SourceRefOrder, left, right dnd.LocationOccurrence, leftRank, rightRank int) bool {
|
||||||
if left.LocationID != right.LocationID {
|
if left.LocationID != right.LocationID {
|
||||||
return left.LocationID < right.LocationID
|
return left.LocationID < right.LocationID
|
||||||
}
|
}
|
||||||
if left.Name != right.Name {
|
if left.Name != right.Name {
|
||||||
return left.Name < right.Name
|
return left.Name < right.Name
|
||||||
}
|
}
|
||||||
if kindOrder(left.Kind) != kindOrder(right.Kind) {
|
if leftRank != rightRank {
|
||||||
return kindOrder(left.Kind) < kindOrder(right.Kind)
|
return leftRank < rightRank
|
||||||
}
|
}
|
||||||
if left.Kind != right.Kind {
|
if left.Kind != right.Kind {
|
||||||
return left.Kind < right.Kind
|
return left.Kind < right.Kind
|
||||||
|
|||||||
@@ -75,6 +75,29 @@ func TestNormalizeKeepsSameNamedIDsAndDistinctEvidence(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNormalizeOrdersTiedEvidenceAndRetainsInvalidOccurrences(t *testing.T) {
|
||||||
|
doc := &source.SourceDocument{ID: "session", Units: []source.SourceUnit{{ID: 50}, {ID: 10}, {ID: 90}, {ID: 30}, {ID: 70}, {ID: 20}, {ID: 60}, {ID: 40}}}
|
||||||
|
location := registryLocations("Inn").Locations[0]
|
||||||
|
ref := func(id int) source.SourceRef {
|
||||||
|
return source.SourceRef{SourceID: doc.ID, StartUnitID: id, EndUnitID: id}
|
||||||
|
}
|
||||||
|
makeOccurrence := func(refs ...source.SourceRef) dnd.LocationOccurrence {
|
||||||
|
return dnd.LocationOccurrence{LocationID: location.ID, Name: location.Name, Kind: dnd.LocationOccurrenceKindMentioned, SourceRefs: refs}
|
||||||
|
}
|
||||||
|
earlier, later, invalid := makeOccurrence(ref(50), ref(10), ref(90), ref(30), ref(70), ref(20), ref(60)), makeOccurrence(ref(50), ref(10), ref(90), ref(30), ref(70), ref(20), ref(40)), makeOccurrence(ref(999))
|
||||||
|
input := dnd.LocationOccurrenceList{Occurrences: []dnd.LocationOccurrence{later, invalid, earlier, later, invalid}}
|
||||||
|
result, err := runNormalize(newNormalizer(t, registryReferences(t, dnd.LocationRegistry{Locations: []dnd.Location{location}})), context.Background(), normalizeRequest(input, doc, contracts.ReferenceSet{}))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if want := []dnd.LocationOccurrence{earlier, later, invalid, invalid}; !reflect.DeepEqual(result.Value.Occurrences, want) {
|
||||||
|
t.Fatalf("ordered = %#v, want %#v", result.Value.Occurrences, want)
|
||||||
|
}
|
||||||
|
if !hasDiagnostic(result.Diagnostics, ReasonCodeOccurrencesReordered, contracts.DiagnosticDispositionObservation) || !hasDiagnostic(result.Diagnostics, ReasonCodeDuplicateCollapsed, contracts.DiagnosticDispositionObservation) {
|
||||||
|
t.Fatalf("diagnostics = %#v", result.Diagnostics)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestNormalizePreservesUnknownIDsAndMalformedOperationRegistry(t *testing.T) {
|
func TestNormalizePreservesUnknownIDsAndMalformedOperationRegistry(t *testing.T) {
|
||||||
doc := &source.SourceDocument{ID: "session", Units: []source.SourceUnit{{ID: 10}}}
|
doc := &source.SourceDocument{ID: "session", Units: []source.SourceUnit{{ID: 10}}}
|
||||||
locations := registryLocations("The Mill")
|
locations := registryLocations("The Mill")
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func TestCollapseDuplicatesPreservesIndependentEvidenceAndOriginalIndices(t *tes
|
|||||||
a := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(10))
|
a := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(10))
|
||||||
b := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(20))
|
b := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(20))
|
||||||
invalid := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(999))
|
invalid := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(999))
|
||||||
records := []normalizedRecord{{a, 10}, {b, 20}, {invalid, 30}, {b, 40}, {invalid, 50}, {a, 60}}
|
records := []normalizedRecord{{occurrence: a, inputIndex: 10}, {occurrence: b, inputIndex: 20}, {occurrence: invalid, inputIndex: 30}, {occurrence: b, inputIndex: 40}, {occurrence: invalid, inputIndex: 50}, {occurrence: a, inputIndex: 60}}
|
||||||
output, findings := collapseDuplicates(records, source.NewDocumentIndex(doc))
|
output, findings := collapseDuplicates(records, source.NewDocumentIndex(doc))
|
||||||
if want := []dnd.NPCOccurrence{a, b, invalid, invalid}; !reflect.DeepEqual(output, want) {
|
if want := []dnd.NPCOccurrence{a, b, invalid, invalid}; !reflect.DeepEqual(output, want) {
|
||||||
t.Fatalf("output = %#v, want %#v", output, want)
|
t.Fatalf("output = %#v, want %#v", output, want)
|
||||||
@@ -25,7 +25,7 @@ func TestCollapseDuplicatesPreservesIndependentEvidenceAndOriginalIndices(t *tes
|
|||||||
if len(findings) != 2 || !strings.Contains(findings[0].Message, "retained input index 10") || !strings.Contains(findings[0].Message, "removed input index 60") || !strings.Contains(findings[1].Message, "retained input index 20") || !strings.Contains(findings[1].Message, "removed input index 40") {
|
if len(findings) != 2 || !strings.Contains(findings[0].Message, "retained input index 10") || !strings.Contains(findings[0].Message, "removed input index 60") || !strings.Contains(findings[1].Message, "retained input index 20") || !strings.Contains(findings[1].Message, "removed input index 40") {
|
||||||
t.Fatalf("findings = %#v", findings)
|
t.Fatalf("findings = %#v", findings)
|
||||||
}
|
}
|
||||||
_, reversed := collapseDuplicates([]normalizedRecord{{b, 20}, {a, 10}, {a, 60}, {b, 40}}, source.NewDocumentIndex(doc))
|
_, reversed := collapseDuplicates([]normalizedRecord{{occurrence: b, inputIndex: 20}, {occurrence: a, inputIndex: 10}, {occurrence: a, inputIndex: 60}, {occurrence: b, inputIndex: 40}}, source.NewDocumentIndex(doc))
|
||||||
if len(reversed) != 2 || !strings.Contains(reversed[0].Message, "retained input index 20") || !strings.Contains(reversed[1].Message, "retained input index 10") {
|
if len(reversed) != 2 || !strings.Contains(reversed[0].Message, "retained input index 20") || !strings.Contains(reversed[1].Message, "retained input index 10") {
|
||||||
t.Fatalf("permuted findings = %#v", reversed)
|
t.Fatalf("permuted findings = %#v", reversed)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,8 +93,10 @@ func (n *Normalizer) PrepareNormalize(ctx context.Context, req contracts.Normali
|
|||||||
}
|
}
|
||||||
|
|
||||||
type normalizedRecord struct {
|
type normalizedRecord struct {
|
||||||
occurrence dnd.NPCOccurrence
|
occurrence dnd.NPCOccurrence
|
||||||
inputIndex int
|
inputIndex int
|
||||||
|
earliest int
|
||||||
|
hasEvidence bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeList(input dnd.NPCOccurrenceList, documentIndex source.DocumentIndex, order shared.SourceRefOrder, registry *npcregistry.Registry) (dnd.NPCOccurrenceList, []diagnostics.Finding, error) {
|
func normalizeList(input dnd.NPCOccurrenceList, documentIndex source.DocumentIndex, order shared.SourceRefOrder, registry *npcregistry.Registry) (dnd.NPCOccurrenceList, []diagnostics.Finding, error) {
|
||||||
@@ -109,7 +111,8 @@ func normalizeList(input dnd.NPCOccurrenceList, documentIndex source.DocumentInd
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return dnd.NPCOccurrenceList{}, nil, fmt.Errorf("occurrences[%d]: %w", index, err)
|
return dnd.NPCOccurrenceList{}, nil, fmt.Errorf("occurrences[%d]: %w", index, err)
|
||||||
}
|
}
|
||||||
records[index] = normalizedRecord{occurrence: occurrence, inputIndex: index}
|
earliest, hasEvidence := order.EarliestValid(occurrence.SourceRefs)
|
||||||
|
records[index] = normalizedRecord{occurrence: occurrence, inputIndex: index, earliest: earliest, hasEvidence: hasEvidence}
|
||||||
if refsChanged {
|
if refsChanged {
|
||||||
findings = append(findings, diagnostics.Finding{
|
findings = append(findings, diagnostics.Finding{
|
||||||
Scope: occurrenceScope(index),
|
Scope: occurrenceScope(index),
|
||||||
@@ -121,7 +124,14 @@ func normalizeList(input dnd.NPCOccurrenceList, documentIndex source.DocumentInd
|
|||||||
}
|
}
|
||||||
|
|
||||||
sort.SliceStable(records, func(left, right int) bool {
|
sort.SliceStable(records, func(left, right int) bool {
|
||||||
return occurrencemodel.Less(order, records[left].occurrence, records[right].occurrence)
|
l, r := records[left], records[right]
|
||||||
|
if l.hasEvidence != r.hasEvidence {
|
||||||
|
return l.hasEvidence
|
||||||
|
}
|
||||||
|
if l.hasEvidence && l.earliest != r.earliest {
|
||||||
|
return l.earliest < r.earliest
|
||||||
|
}
|
||||||
|
return occurrencemodel.LessAfterEvidence(order, l.occurrence, r.occurrence)
|
||||||
})
|
})
|
||||||
for position, record := range records {
|
for position, record := range records {
|
||||||
if position == record.inputIndex {
|
if position == record.inputIndex {
|
||||||
|
|||||||
@@ -117,6 +117,33 @@ func TestNormalizeOrdersAndCollapsesExactDuplicatesOnly(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNormalizeOrdersTiedEvidenceAndRetainsInvalidOccurrences(t *testing.T) {
|
||||||
|
doc := &source.SourceDocument{ID: "session", Units: []source.SourceUnit{{ID: 50}, {ID: 10}, {ID: 90}, {ID: 30}, {ID: 70}, {ID: 20}, {ID: 60}, {ID: 40}}}
|
||||||
|
ref := func(id int) source.SourceRef {
|
||||||
|
return source.SourceRef{SourceID: doc.ID, StartUnitID: id, EndUnitID: id}
|
||||||
|
}
|
||||||
|
earlier := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(50))
|
||||||
|
earlier.SourceRefs = append(earlier.SourceRefs, ref(10), ref(90), ref(30), ref(70), ref(20), ref(60))
|
||||||
|
later := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(50))
|
||||||
|
later.SourceRefs = append(later.SourceRefs, ref(10), ref(90), ref(30), ref(70), ref(20), ref(40))
|
||||||
|
invalid := occurrence("Ária", dnd.NPCOccurrenceKindDialogue, ref(999))
|
||||||
|
input := dnd.NPCOccurrenceList{Occurrences: []dnd.NPCOccurrence{later, invalid, earlier, later, invalid}}
|
||||||
|
normalizer, err := New(Options{}, npcReferences(t))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
result, err := runNormalize(normalizer, context.Background(), contracts.NormalizeInput[dnd.NPCOccurrenceList]{Source: doc, MergeOutput: contracts.MergeArtifact[dnd.NPCOccurrenceList]{Value: input}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if want := []dnd.NPCOccurrence{earlier, later, invalid, invalid}; !reflect.DeepEqual(result.Value.Occurrences, want) {
|
||||||
|
t.Fatalf("ordered = %#v, want %#v", result.Value.Occurrences, want)
|
||||||
|
}
|
||||||
|
if !hasDiagnostic(result.Diagnostics, ReasonCodeOccurrencesReordered) || !hasDiagnostic(result.Diagnostics, ReasonCodeDuplicateCollapsed) {
|
||||||
|
t.Fatalf("diagnostics = %#v", result.Diagnostics)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestNormalizerContract(t *testing.T) {
|
func TestNormalizerContract(t *testing.T) {
|
||||||
_, err := New(Options{}, npcReferences(t))
|
_, err := New(Options{}, npcReferences(t))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ func Less(order shared.SourceRefOrder, left, right dnd.NPCOccurrence) bool {
|
|||||||
if leftHasEvidence && leftPosition != rightPosition {
|
if leftHasEvidence && leftPosition != rightPosition {
|
||||||
return leftPosition < rightPosition
|
return leftPosition < rightPosition
|
||||||
}
|
}
|
||||||
|
return LessAfterEvidence(order, left, right)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LessAfterEvidence compares tie breakers after equal earliest-evidence keys.
|
||||||
|
// Callers must establish that premise; Less remains suitable for arbitrary input.
|
||||||
|
func LessAfterEvidence(order shared.SourceRefOrder, left, right dnd.NPCOccurrence) bool {
|
||||||
leftKey := left.NPCID
|
leftKey := left.NPCID
|
||||||
rightKey := right.NPCID
|
rightKey := right.NPCID
|
||||||
if leftKey != rightKey {
|
if leftKey != rightKey {
|
||||||
|
|||||||
Reference in New Issue
Block a user