Select protected spelling findings without sorting
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
**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).
|
||||
|
||||
## Review Result
|
||||
@@ -275,6 +275,8 @@ and available artifact paths on success and interruption.
|
||||
|
||||
### 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.
|
||||
|
||||
**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 {
|
||||
var spellings []string
|
||||
var selected string
|
||||
found := false
|
||||
for identity, beforeItems := range beforeByID {
|
||||
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 {
|
||||
var spellings []string
|
||||
var selected string
|
||||
found := false
|
||||
for identity, afterItems := range afterByID {
|
||||
beforeItems := beforeByID[identity]
|
||||
for i, afterItem := range afterItems {
|
||||
if i >= len(beforeItems) || afterItem.text == beforeItems[i].text || afterItem.text == afterItem.canonical {
|
||||
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 {
|
||||
if len(spellings) == 0 {
|
||||
func protectedSpellingMessage(spelling string, found bool) string {
|
||||
if !found {
|
||||
return ""
|
||||
}
|
||||
sort.Strings(spellings)
|
||||
return fmt.Sprintf("proposal may alter protected glossary spelling %q", spellings[0])
|
||||
return fmt.Sprintf("proposal may alter protected glossary spelling %q", spelling)
|
||||
}
|
||||
|
||||
// preservesRepeatedIdentities permits a spoken-word proposal to reduce repeated
|
||||
|
||||
Reference in New Issue
Block a user