From d92a0781b3f7f5eec60f2b5fe18e454a39a695a8 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 28 Sep 2026 13:31:54 +1300 Subject: [PATCH] qet-mcp: test the text-field uuid guard on each side of a diff A field with a uuid on a symbol with none cannot be keyed by (symbol, field); the mutation audit showed either side's guard could be dropped unnoticed. Now tested with the symbol uuid missing on one side, then the other. Co-Authored-By: Claude Opus 5.5 --- misc/qet-mcp/test_qet_mcp.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/misc/qet-mcp/test_qet_mcp.py b/misc/qet-mcp/test_qet_mcp.py index 2677d7450..fa7e9808e 100644 --- a/misc/qet-mcp/test_qet_mcp.py +++ b/misc/qet-mcp/test_qet_mcp.py @@ -1189,6 +1189,20 @@ class DiffContracts(unittest.TestCase): self.assertEqual([(c["item"]["element"], c["item"]["uuid"], c["changed"]) for c in d["changed"]], [(which, "{same}", {"x": ["1", "5"]})]) + def test_a_field_on_a_symbol_without_a_uuid_is_matched_by_position(self): + """The field has a uuid but its symbol has none (an older file): with no + symbol to pair it with, the whole kind falls back to position.""" + field = lambda x: ('t') + on = lambda sym, x: self.qet(self.folio(self.el(sym, 0, 0, texts=field(x)))) + d = m.tool_diff(on("", 1), on("", 2))["element_texts"] + self.assertEqual(d["keyed_by"], "position") + self.assertEqual([c["changed"] for c in d["changed"]], [{"x": ["1", "2"]}]) + # the symbol has a uuid on one side only: each side is checked on its own + for before, after in ((on("", 1), on(self.A, 1)), (on(self.A, 1), on("", 1))): + with self.subTest(before=before, after=after): + self.assertEqual(m.tool_diff(before, after)["element_texts"]["keyed_by"], "position") + def test_repeated_uuids_fall_back_rather_than_merge(self): # the same field uuid twice inside one symbol twice = lambda x: self.qet(self.folio(self.el(self.A, 0, 0, texts="".join(