From 4ddb76f9ffbe231a06ee8f335e6c5cc29d72abc6 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Thu, 2 Jul 2026 02:24:36 +0700 Subject: [PATCH] test(editor): make content-integrity catch backslash-punct load loss MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generative oracle shipped green over the escape-tokenizer bug: its atoms held only backslash-before-letter (which survives), and both oracles are too weak for a first-load loss — survives/includes never ran on the missing class, and convergence passes because the drop happens once then stabilizes. Add backslash-before-punctuation atoms to the generative pool and a direct byte-exact source-fidelity assertion for the escape class (regex/glob/UNC/ line-leading star), which is strictly stronger than survives+converges. Fails on the pre-fix escape-active parser, passes on the neutralized one. Co-Authored-By: Claude Opus 4.8 --- .../editor-content-integrity.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/components/shared/markdown-editor/editor-content-integrity.test.ts b/frontend/src/components/shared/markdown-editor/editor-content-integrity.test.ts index 18ba0dae..3a487462 100644 --- a/frontend/src/components/shared/markdown-editor/editor-content-integrity.test.ts +++ b/frontend/src/components/shared/markdown-editor/editor-content-integrity.test.ts @@ -44,6 +44,9 @@ const ATOMS = [ '
', 'match \\d+ then \\w*', 'C:\\Users\\bob\\a.txt', + 'regex \\.php files', + 'glob \\* and \\?', + 'escaped \\[ \\| \\+ here', '<script>', 'AT&T', 'x & y', @@ -104,4 +107,17 @@ describe('generative content-integrity — atoms survive load↔serialize across } } }); + + // Source-fidelity is strictly stronger than the survives/converges oracles above: a backslash-escaped + // punctuation char is dropped on the FIRST load and then converges, so convergence passes while the byte + // is already gone. Assert byte-exact round-trip for the escape class directly. + it.each([ + 'regex \\.php and \\d+', + 'glob \\* \\? and range \\[a-z\\]', + 'table \\| pipe and plus \\+', + 'unc \\\\server\\\\share double \\\\', + '\\* line-leading star, not a bullet', + ])('round-trips %s byte-identical', (source) => { + expect(roundTrip(source)).toBe(source); + }); });