uttrflow / uttrflow/uttrflow-swift
Correction evidence joins across uncertain words and counts a phrase that was never said clearly
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## Reproduced behavior
On main `5c310667cd35c44abd8bbd26c19b0905471287b4`, `CorrectionEvidence` removes every uncertain word before constructing its `saidClearly` sequence. This makes separated certain words adjacent. A multiword dictionary spelling can then earn `saidClearlyElsewhere` even though the speaker never said that phrase consecutively.
The extra signal can change the actual `WordCorrectionEngine.proposals` result, not merely its diagnostics.
## Controlled reproduction
Use a dictionary containing `New York`, selected text `New York`, and the following synthetic scored utterance (`?` means confidence 0.2; the other words are 0.95):
```text
new jersey york is different from ?new ?yourk and the others are waiting outside
```
The engine returns no proposals: a screen sighting alone does not clear the two-signal margin.
Change only `jersey` to `?jersey`, keeping every word and the screen unchanged:
```text
new ?jersey york is different from ?new ?yourk and the others are waiting outside
```
The engine now proposes replacing words `6..<8`, `new yourk`, with `New York`, reason `seenOnScreen`, heard confidence 0.2. Removing `jersey` from the corroboration sequence fabricated a second occurrence of `new york`. Lower confidence in an unrelated intervening word made the correction eligible.
This was reproduced with the actual engine, evidence implementation and phonetic index, using the repository's scored-utterance fixture helper. It is a synthetic confidence-boundary test, not a captured recognition or an observed insertion. All 112 existing candidate/correction tests passed; the paired regression's no-proposal expectation fails only with the uncertain gap.
## Location and impact
[CorrectionEvidence.swift](https://github.com/uttrflow/uttrflow-swift/blob/5c310667cd35c44abd8bbd26c19b0905471287b4/Sources/UttrflowAI/CorrectionEvidence.swift#L31-L35) filters uncertain words and flattens the remainder. Its `Haystack.contains` checks adjacency only after this loss of boundaries.
The native app's `DictionaryCorrections.corrections` supplies real scored words to this engine and maps proposals to pipeline corrections. This weakens the evidence margin protecting automatic dictionary replacements. Priority P2.
## Acceptance criteria
- Preserve gaps between certain runs when testing multiword corroboration. A phrase should count only when its words are consecutive in the original utterance and all are certain.
- Keep single-word evidence and genuinely consecutive certain phrases working.
- Add engine-level controls for a certain intervening word, an uncertain intervening word, and a genuinely consecutive phrase. Keep the dictionary, screen and proposed target fixed across the controls.
- Run the restraint corpus to verify the correction margin still protects ordinary speech.
Related #190 concerns insufficient restraint-corpus coverage and multiword replacement permissiveness. This reproduction uses the current longer-utterance code and demonstrates a separate fabricated-adjacency signal; #217 concerns screen phonetic candidates rather than this deterministic evidence path.
Contributor guide
Assessment
This issue has not been assessed yet.