uttrflow / uttrflow/uttrflow-swift
Layout number corroboration overflows on Int.max and crashes the rules transformer
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## Reproduced crash
On main `5c310667cd35c44abd8bbd26c19b0905471287b4`, passing this text through the production `RuleBasedTransformer` crashes the process:
```text
check number 9223372036854775807 again
```
The parser accepts the number as an `Int`, then overflows while looking for a neighboring item number. This is a transcript-string input, not a fabricated internal range or direct call with an invalid index.
## Evidence
An isolated Swift test calls:
```swift
try await RuleBasedTransformer().transform(
TransformationRequest(
transcription: .fixture(
text: "check number 9223372036854775807 again",
language: .english)))
```
The test process terminates with signal 5. Its macOS crash report identifies:
```text
Swift runtime failure: arithmetic overflow
LayoutWordsPass.isCorroborated(at:in:of:among:) LayoutWordsPass.swift:69
LayoutWordsPass.apply(_:) LayoutWordsPass.swift:28
CleaningPipeline.run(_:) CleaningPass.swift:48
RuleBasedTransformer.transform(_:) RuleBasedTransformer.swift:32
```
The neighboring value `9223372036854775806` completes and returns `Check number 9223372036854775806 again.`. All 34 existing layout, spoken-punctuation and quantity tests pass.
No speech recording was used; this proves the production text boundary crashes on a representable integer, not that a recognizer has been observed producing this particular value.
## Cause
[LayoutWordsPass.swift](https://github.com/uttrflow/uttrflow-swift/blob/5c310667cd35c44abd8bbd26c19b0905471287b4/Sources/UttrflowAI/Passes/LayoutWordsPass.swift#L69) checks:
```swift
numbered.contains(value - 1) || numbered.contains(value + 1)
```
`itemNumber` accepts any positive `Int`. With `Int.max` and no predecessor in `numbered`, the second operand evaluates and traps. The shared piece pipeline runs this pass before number formatting, including the deterministic fallback path. A Swift arithmetic trap cannot be recovered by the router's error fallback.
Priority P2: a rare numeric input causes process termination instead of being retained as ordinary text.
## Acceptance criteria
- Make neighboring-item checks safe at integer boundaries, or constrain list item values while preserving out-of-range designators as text.
- Add a full-rules-transformer regression for `Int.max`, alongside `Int.max - 1`, zero, and an integer too large to parse.
- Preserve normal adjacent spoken list numbering and lone-number restraint.
Related #238 introduced lone-designator restraint; this is an unchecked arithmetic boundary in corroboration. #396 is an unrelated Accessibility-range overflow. No duplicate issue or open fix was found in the refreshed tracker.
Contributor guide
Assessment
This issue has not been assessed yet.