Answer stability round 1: 0 🔴, 1 🟡 (0 misread); refuse a blocker loop and link a blocker named twice once
CI / tests (pull_request) Failing after 3m48s

This commit is contained in:
2026-11-17 06:28:17 +01:00
parent c988bd61b4
commit 89fb819fbe
4 changed files with 35 additions and 4 deletions
+15 -1
View File
@@ -244,6 +244,8 @@ class JiraPlan:
open_keys = keys_of(answered)
if revision.blockers is not None and (missing := missing_blocker(revision.blockers, open_keys, self.label)):
return missing
if revision.blockers is not None and (looped := blocking_loop(answered, issue, revision.blockers, self.label)):
return looped
body = revision.body
if detail is not None and not self.shows(issue, detail):
description = self.description_of(detail)
@@ -403,7 +405,7 @@ def revision_of(issue: Issue, named: dict[str, str], detail: str | None, comment
body["properties"] = [{"key": PROPERTY, "value": value}]
if own and (scored.exempt == SECURITY) != (held.get("Exempt") == SECURITY):
body["update"] = {"labels": [{"add" if scored.exempt == SECURITY else "remove": SECURITY}]}
return Revision(body, release, tuple(f"{project_of(issue.key)}-{blocker}" for blocker in checked.blocked_by) if BLOCKED_BY in named else None)
return Revision(body, release, tuple(dict.fromkeys(f"{project_of(issue.key)}-{blocker}" for blocker in checked.blocked_by)) if BLOCKED_BY in named else None)
def offer_of(raw: object) -> tuple[str, str, str, str] | None:
@@ -498,6 +500,18 @@ def missing_blocker(blockers: tuple[str, ...], held: set[object], label: str) ->
return None if missing is None else Failure(f"{label} holds no item {number(missing)} to be blocked by")
def blocking_loop(answered: list[object], issue: Issue, blockers: tuple[str, ...], label: str) -> Failure | None:
"""A Failure where issue, once blocked by blockers, would block itself through the items its blockers wait for, and none of them could be taken; None otherwise. A loop the plan already holds without issue isn't this edit's."""
issues = {found.key: found for raw in answered if isinstance(found := issue_of(raw), Issue)}
waits_for = {found.key: found.blockers for found in issues.values()} | {issue.key: blockers}
reached: set[str] = set()
frontier = set(blockers)
while frontier:
reached |= frontier
frontier = {blocker for key in frontier for blocker in waits_for.get(key, ()) if blocker in issues} - reached
return Failure(f"{label}: item {issue.number} would be blocked by itself through {', '.join(str(number(key)) for key in sorted(reached - {issue.key}, key=number))}; drop one of the blockers") if issue.key in reached else None
def plan_of(issues: list[Issue], epic: Epic, to_markdown: ToMarkdown) -> Plan | Failure:
"""The plan the issues hold, in their order."""
project = project_of(epic.key)
+18 -1
View File
@@ -614,6 +614,10 @@ class Editing(unittest.TestCase):
self.assertEqual(self.edit(34, {"Blocked by": "35, 36"}), Written(34))
self.assertEqual(self.writes(), [("POST", LINKS, {"type": {"name": "Blocks"}, "inwardIssue": {"key": f"ABC-{blocker}"}, "outwardIssue": {"key": "ABC-34"}}) for blocker in (35, 36)])
def test_links_a_blocker_named_twice_once(self):
self.edit(34, {"Blocked by": "35, 35"})
self.assertEqual([body["inwardIssue"]["key"] for _, _, body in self.writes()], ["ABC-35"]) # type: ignore[index]
def test_deletes_the_link_of_each_blocker_the_edit_drops_and_makes_none_for_one_it_keeps(self):
self.open[0] = issue("ABC-34", scores=PROPERTY, blocked_by=("ABC-35", "ABC-36"))
self.assertEqual(self.edit(34, {"Blocked by": "35"}), Written(34))
@@ -669,6 +673,18 @@ class Editing(unittest.TestCase):
self.assertEqual(self.edit(34, {"L": "2", "Blocked by": "35, 40"}), Failure("jira:https://acme.atlassian.net/browse/ABC-12 holds no item 40 to be blocked by"))
self.assertEqual(self.writes(), [])
def test_a_blocker_that_makes_the_issue_wait_for_itself_fails_before_any_write(self):
self.open[1] = issue("ABC-35", scores=PROPERTY, blocked_by=("ABC-34",))
self.open[2] = issue("ABC-36", scores=PROPERTY, blocked_by=("ABC-35",))
self.assertEqual(self.edit(34, {"L": "2", "Blocked by": "36"}), Failure("jira:https://acme.atlassian.net/browse/ABC-12: item 34 would be blocked by itself through 35, 36; drop one of the blockers"))
self.assertEqual(self.writes(), [])
def test_a_loop_the_plan_holds_without_the_issue_does_not_stop_its_edit(self):
self.open[1] = issue("ABC-35", scores=PROPERTY, blocked_by=("ABC-36",))
self.open[2] = issue("ABC-36", scores=PROPERTY, blocked_by=("ABC-35",))
self.assertEqual(self.edit(34, {"Blocked by": "35"}), Written(34))
self.assertEqual([method for method, _, _ in self.writes()], ["POST"])
def test_a_blocked_by_out_of_format_or_naming_the_issue_itself_fails_before_any_write(self):
for cell in ("ABC-35", "35,36", "34"):
with self.subTest(cell=cell):
@@ -677,7 +693,8 @@ class Editing(unittest.TestCase):
def test_the_links_of_an_issue_a_person_filed_are_never_changed(self):
for id_ in (35, 36):
self.assertEqual(self.edit(id_, {"Blocked by": "34"}, None, COMMENT), Failure(f"a person filed ABC-{id_}, so the loop sets only its scores: change its summary, description, links and Fix Version in Jira"))
with self.subTest(id_=id_):
self.assertEqual(self.edit(id_, {"Blocked by": "34"}, None, COMMENT), Failure(f"a person filed ABC-{id_}, so the loop sets only its scores: change its summary, description, links and Fix Version in Jira"))
self.assertEqual(self.writes(), [])
def test_an_issue_that_is_no_open_child_of_the_epic_is_not_edited(self):
+1 -1
View File
@@ -45,7 +45,7 @@ ranking fails or scores the item under the bar.
In a Jira epic, edit changes an issue the loop filed: its summary, description and scores, the label
`security` with --exempt, and its "is blocked by" links with --blocked-by: it makes a link for each
blocker added and deletes the link of each blocker dropped. Each blocker must be an open child of the
epic, and a link to any other issue stays.
epic that doesn't wait for the issue itself, directly or through others. A link to any other issue stays.
Of an issue a person filed it sets only the scores, --moves and --exempt, and only with --comment;
--blocked-by fails there, since its links are the team's.
The four scores are set together where the issue holds none yet.