uttrflow / uttrflow/uttrflow-swift

Caret echo removal deletes a matching prefix that the user actually dictated, and the guard accepts it

Open
#818 0 comments 0 reactions 1 assignee Claimed by @naveen-bhatt View on GitHub
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## Reproduction on current main

Reviewed `5c310667cd35c44abd8bbd26c19b0905471287b4`. With `They know ` already before a mid-sentence caret, dictate:

```text
they know the password
```

A faithful model response is `They know the password.`. The actual `GenerativeTextTransformer` instead returns:

```text
the password.
```

Combined with the existing field, that becomes `They know the password.` instead of the requested `They know they know the password.`. The latter states that they know about their own knowledge; the former deletes that clause. Here the model did not invent an echo: every word in its response was spoken.

## Verification

An isolated test used the production transformer and cleanup passes with an English `TransformationRequest`, an email `Situation` built from the real `AppContext.insertionPoint`, and `FakeCleanupModel` returning the faithful response above. Observed:

```text
spoken=they know the password
returned=the password.
combined=They know the password.
```

The preservation assertion fails; the transformer returns successfully. The combined text is concatenated in the test, not inserted into another app. This is a controlled model response, not an observed model hallucination. All 46 existing caret-echo, first-word, spacing and terminal-stop tests passed, including the controls that remove genuine unspoken echoes.

## Cause

- [CaretEchoPass.swift](https://github.com/uttrflow/uttrflow-swift/blob/5c310667cd35c44abd8bbd26c19b0905471287b4/Sources/UttrflowAI/Passes/CaretEchoPass.swift) compares the model's prefix with preceding field text and strips any whole match of at least two words. It receives no spoken draft with which to distinguish an extra echo from a faithfully repeated phrase.
- [GenerativeTextTransformer.swift](https://github.com/uttrflow/uttrflow-swift/blob/5c310667cd35c44abd8bbd26c19b0905471287b4/Sources/UttrflowAI/GenerativeTextTransformer.swift#L77-L79) passes the removed phrase to the meaning guard as `echoed`. That lets the removed spoken words count as survivors, so the guard accepts the shortened answer.

Priority P1: a faithful model answer loses dictated content inside deterministic finishing and the preservation guard endorses it.

## Acceptance criteria

- Distinguish an additional model echo from an occurrence present in the dictated text. Preserve the speaker's occurrence when the same phrase also precedes the caret.
- Cover a faithful repeated prefix, a genuinely extra echo before that repeated prefix, and the existing ordinary echo-removal cases through the full transformer.
- Exercise both message and piece finishing, which share this pass.
- Ensure `echoed` cannot excuse removal of a required spoken occurrence. Validate against the cleanup corpus so legitimate echo suppression remains effective.

Closed #239 concerns pre-model removals and their authorization; this is a post-model deletion that is explicitly passed back as an echo. #817 concerns unchecked rules fallback after a rejection; this reproduction is accepted as a model result without fallback. No matching open issue or PR was found in the refreshed tracker.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.