medlab / case

medlab

what got hurt, and what now fails loudly

↑ sublayer

2026-10-24 · fixed: yes

Cutting between words preserves a sentence's meaning

InvariantsTest EffectivenessRuntime InvariantsMutation Testing

now fails loudly Regression tests require the full selected context and its governing modal to survive cloze construction.

What broke

A vocabulary-learning service turns text and photographs supplied by a learner into Anki flashcards. Each card hides one German word or expression inside its original context. The answer includes an English translation of that context. The learner expected useful vocabulary presented as a clear, readable card.

The implementation treated a cut between words as a safe context boundary. Normalization split long contexts at clause boundaries. A later cloze builder also restricted its output to a 25-word window around the target. Neither rule established that the remaining text retained the grammar needed by that target. The translation could still describe the complete original context.

How it showed

An audit of 75 stored vocabulary notes found a request excerpt ending at its target verb. The retained source continued with a coordinated verb and the modal governing both. Other excerpts began with a dependent continuation after normalization had divided a coordinated sentence.

A separate parcel-delivery card combined multiple lines around a word obscured in the source photograph. Shortening alone could not repair that source damage. The learner's complaint about bad cards led to an examination of the stored notes, original captures and installed template.

What was watching

Schema validation checked required fields. Source validation checked that the selected text was a verbatim substring. Cloze validation checked that removing the markup recovered a substring of the original sentence. These checks accepted a grammatical dependency removed at a word boundary.

A unit test explicitly required a 60-word synthetic input to produce 25 words. It verified the imposed limit rather than preservation of the learning context. Formatting and test checks could therefore pass while accepting the defect. Collection-safety tests protected synchronization and scheduling, which were separate from the meaning of the displayed text.

The learner was the detecting sensor. The interval is not exact but it has a lower bound: the published tree dates the shortening rule from 2026-10-16 and the learner reported the cards on 2026-10-24, so eight days passed with them in the deck. The malformed excerpts reached the study deck.

Where it sits

Runtime invariants were present but checked source fidelity rather than context completeness. A substring can preserve every printed character while losing a governing verb. This is an invariants failure with a test-effectiveness gap: the old test encoded the shortening rule as the expected result.

Mutation testing was absent from that path. During repair, the previous cloze builder was executed against the new preservation condition. It failed that condition; the replacement passed. This was a targeted sensitivity check, not a project-wide mutation run.

What we did

The deployed change removes the cloze builder's word-window cropping and uses normalization guidance that preserves coherent authentic contexts. Labels remain valid vocabulary sources. A subject, finite verb and minimum context-word count are not prerequisites for retaining a useful unfamiliar word.

The card template gives the answer visual priority and displays the full English translation in secondary text. Existing notes were revised in place from retained captures. The post-sync verification found no changes to any card or review row. A damaged occurrence was reduced to its readable label without inventing missing source characters. Its original capture remains archived.

The source change is commit b1d0c0d8b713587ca57fc2bf45de9145002e33ec in the vocabulary service. The runtime reports that commit as its build, and the source pull request merged as f59a921.

What now fails loudly

test_cloze_builder_preserves_selected_context_even_over_25_words requires removing cloze markup to recover the complete selected source. test_long_request_keeps_modal_and_full_translation_context also requires the request's final governing modal to remain present. Restoring the previous word-window builder violates those assertions.

An additional label test requires a usable English hint for a whole-label cloze, and the existing separable-verb test still requires both printed parts in place. An incremental-sync test verifies that replacing the old template preserves card IDs, scheduling and reviews while displaying the translation on the answer side. The source pull request passed CI.

These are inline unit tests over fixed strings, not recorded model output: no fixture or golden file changed in the source pull request. The apology sentence has no test; it is a prompt instruction to preserve it whole, and its wording was checked by hand against the captured source.