Select protected spelling findings without sorting
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
**Updated:** 2026-11-11
|
**Updated:** 2026-11-11
|
||||||
|
|
||||||
**Status:** 7 of nine findings resolved. Findings refer to implementation revision
|
**Status:** 8 of nine findings resolved. Findings refer to implementation revision
|
||||||
`aa8073c`. See the [implementation plan](implementation.md).
|
`aa8073c`. See the [implementation plan](implementation.md).
|
||||||
|
|
||||||
## Review Result
|
## Review Result
|
||||||
@@ -275,6 +275,8 @@ and available artifact paths on success and interruption.
|
|||||||
|
|
||||||
### R8 — Select a Protected-Spelling Finding in One Pass (P3)
|
### R8 — Select a Protected-Spelling Finding in One Pass (P3)
|
||||||
|
|
||||||
|
**Completed.** Protection checks select a deterministic spelling in one pass without sorting. Validator and runner tests pass.
|
||||||
|
|
||||||
**Affected plan:** Stage 5, item 4.
|
**Affected plan:** Stage 5, item 4.
|
||||||
|
|
||||||
**Evidence:** The [protection checks](../../internal/framework/validators/protected_terms.go#L98)
|
**Evidence:** The [protection checks](../../internal/framework/validators/protected_terms.go#L98)
|
||||||
|
|||||||
@@ -96,35 +96,40 @@ func (v ProtectedVocabulary) occurrences(text string) []protectedOccurrence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validateIdentityPreservation(beforeByID, afterByID map[glossary.Identity][]protectedOccurrence) string {
|
func validateIdentityPreservation(beforeByID, afterByID map[glossary.Identity][]protectedOccurrence) string {
|
||||||
var spellings []string
|
var selected string
|
||||||
|
found := false
|
||||||
for identity, beforeItems := range beforeByID {
|
for identity, beforeItems := range beforeByID {
|
||||||
if len(afterByID[identity]) < len(beforeItems) && len(beforeItems) > 0 {
|
if len(afterByID[identity]) < len(beforeItems) && len(beforeItems) > 0 {
|
||||||
spellings = append(spellings, beforeItems[0].canonical)
|
if spelling := beforeItems[0].canonical; !found || spelling < selected {
|
||||||
|
selected, found = spelling, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return protectedSpellingMessage(spellings)
|
return protectedSpellingMessage(selected, found)
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateCapitalizationTransitions(beforeByID, afterByID map[glossary.Identity][]protectedOccurrence) string {
|
func validateCapitalizationTransitions(beforeByID, afterByID map[glossary.Identity][]protectedOccurrence) string {
|
||||||
var spellings []string
|
var selected string
|
||||||
|
found := false
|
||||||
for identity, afterItems := range afterByID {
|
for identity, afterItems := range afterByID {
|
||||||
beforeItems := beforeByID[identity]
|
beforeItems := beforeByID[identity]
|
||||||
for i, afterItem := range afterItems {
|
for i, afterItem := range afterItems {
|
||||||
if i >= len(beforeItems) || afterItem.text == beforeItems[i].text || afterItem.text == afterItem.canonical {
|
if i >= len(beforeItems) || afterItem.text == beforeItems[i].text || afterItem.text == afterItem.canonical {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
spellings = append(spellings, afterItem.canonical)
|
if !found || afterItem.canonical < selected {
|
||||||
|
selected, found = afterItem.canonical, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return protectedSpellingMessage(spellings)
|
return protectedSpellingMessage(selected, found)
|
||||||
}
|
}
|
||||||
|
|
||||||
func protectedSpellingMessage(spellings []string) string {
|
func protectedSpellingMessage(spelling string, found bool) string {
|
||||||
if len(spellings) == 0 {
|
if !found {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
sort.Strings(spellings)
|
return fmt.Sprintf("proposal may alter protected glossary spelling %q", spelling)
|
||||||
return fmt.Sprintf("proposal may alter protected glossary spelling %q", spellings[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// preservesRepeatedIdentities permits a spoken-word proposal to reduce repeated
|
// preservesRepeatedIdentities permits a spoken-word proposal to reduce repeated
|
||||||
|
|||||||
Reference in New Issue
Block a user