Skip to main content
SS. M. Siam
November 4, 2026·8 min read·
#AI#Testing#Rust#Unicode

Where an AI coding tool was wrong, and how I caught it

A concrete case study showing subtle bugs introduced by AI code generators in boundary conditions, and the property-based tests that exposed them.

Contents

4 sections

The Setup

While working on phoneme candidate ranking in lekhani-ai, I asked an AI model to optimize the scoring loop for n-gram frequency lookups across transliterated strings with complex conjuncts.

The initial code looked convincing:

rust· 3 lines
1// AI drafted ranking fallback
2- let best = candidates.first();
3+ let best = rank(&candidates, &context); // illustrative diff

What It Produced

On standard ASCII input, the function returned 0 errors. But when tested against Unicode character sequences containing zero-width joiners (U+200D ZWJ) and vowel diacritics, the heuristic completely scrambled the syllable cluster boundaries.

How I Caught It

I run proptest property tests against a corpus of 100,000 real Bengali editorial sentences. The property test asserted that:

reconstruct(transliterate(s)) \equiv s

The test instantly panicked on words like "স্মৃতি" (smriti) and "বিজ্ঞান" (bijnan).

WHAT I CHECKED: Never trust an AI model with grapheme cluster segmentation without an invariant property test verifying Unicode normal forms (NFC/NFD) across dialectal edges.

What I Would Do Differently

Write the acceptance criteria and test corpus before asking the model for any code.

Sintaul Mahdi Siam
Sintaul Mahdi Siam
Systems developer · Rust · Linux · Android
all writing

Discussion & Peer Review

Questions, empirical pushbacks, and architecture discussions.

0 THREADS & REPLIES
Leave a comment
Reviewed before publishing

No published discussion threads yet.

Be the first to challenge a premise or start an inquiry.