From ea225308782dc5a57e83d1effad211a87849c262 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 10:54:03 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20refuse=20a?= =?UTF-8?q?=20write=20that=20repeats=20a=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/record_store/jira_description.py | 5 ++++- bin/record_store/test_jira_description.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/record_store/jira_description.py b/bin/record_store/jira_description.py index bc657e7d..1c5608b1 100644 --- a/bin/record_store/jira_description.py +++ b/bin/record_store/jira_description.py @@ -92,7 +92,10 @@ class EpicDescription: sent = "" if document is None else self.markdown_of(document) if isinstance(sent, Failure): return sent - if unapproved := [name for name in APPROVED_SECTIONS if name not in self.approved and sections(sent).get(name) != sections(current.text).get(name)]: + before, after = sections(current.text), sections(sent) + if repeated := [name for name, bodies in after.items() if len(bodies) > max(1, len(before.get(name, [])))]: + return Failure(f"the write would repeat ## {repeated[0]} in {key}'s description, which locks that section for reads and writes: leave a heading out of the text, or edit the description in Jira") + if unapproved := [name for name in APPROVED_SECTIONS if name not in self.approved and after.get(name) != before.get(name)]: return Failure(f"the write changes ## {unapproved[0]} of {key}'s description without the human's approval: have the human approve it in an interrupt, or edit the section in Jira") authorization = basic_auth(self.env_file) if isinstance(authorization, Failure): diff --git a/bin/record_store/test_jira_description.py b/bin/record_store/test_jira_description.py index 4d497061..ee80ea47 100644 --- a/bin/record_store/test_jira_description.py +++ b/bin/record_store/test_jira_description.py @@ -175,6 +175,20 @@ class EpicDescriptionWriteTest(WriteCase): self.assertIn("## Goals", found.reason) self.assertEqual(self.jira.puts(), []) + def test_refuses_a_write_that_repeats_a_section_the_codec_reads_from_another_spelling_of_its_heading(self) -> None: + held = self.held("## Decisions\n- one\n") + as_atx = lambda documents: [fake_markdown(documents)[0].replace("Decisions\n=====", "## Decisions")] + store = EpicDescription(EPIC, self.env, self.jira.http, as_atx, fake_adf) + found = store.write("## Decisions\n- one\n\n## Scoring\nValue.\n\nDecisions\n=====\n- copied\n", held.version) + assert isinstance(found, Failure), found + self.assertIn("repeat ## Decisions", found.reason) + self.assertEqual(self.jira.puts(), []) + + def test_keeps_a_section_that_was_already_repeated_in_the_description(self) -> None: + held = self.held("## Decisions\n- one\n\n## Decisions\n- two\n") + written = self.new_store().write("## Decisions\n- one\n\n## Decisions\n- two\n\n## Scoring\nValue.\n", held.version) + self.assertIsInstance(written, Held) + def test_the_version_does_not_depend_on_the_order_of_the_documents_keys(self) -> None: held = self.held("## Scoring\nValue.\n") self.jira.description = dict(reversed(list(fake_adf("## Scoring\nValue.\n").items())))