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)