Answer product-owner round 1: 1 🔴, 0 🟡 (0 misread); delete only the links to open items, and leave other links as they are

This commit is contained in:
2026-11-17 05:12:53 +01:00
parent 72b8dd3263
commit 5a757bae1f
3 changed files with 20 additions and 13 deletions
+11 -10
View File
@@ -2,7 +2,7 @@
An item is an open child issue. Its ID is the issue's number, so every child must be in the epic's own Jira project: ABC-34 is item 34 of the plan under ABC-12. The summary is the tagline, the description the detail, the earliest Fix Version the release, and an "is blocked by" link a blocker. L, E, I, S, Moves and Exempt sit in one issue property, PROPERTY, which needs no Jira admin to set up; an issue a person filed holds none, and reads as an item without scores.
`add` files an item as a new child issue, marked with FILED_BY, and ranks it among the issues the loop filed, by the score the config's formula gives, as `placing` says. `finish` moves an item's issue to a done status. `edit` changes an issue the loop filed, but never its links. Of an issue a person filed it sets only the scores, with a comment that tells the team why."""
`add` files an item as a new child issue, marked with FILED_BY, and ranks it among the issues the loop filed, by the score the config's formula gives, as `placing` says. `finish` moves an item's issue to a done status. `edit` changes an issue the loop filed, and its links to the epic's other open items. Of an issue a person filed it sets only the scores, with a comment that tells the team why."""
import dataclasses
import pathlib
import re
@@ -165,17 +165,17 @@ class JiraPlan:
# Jira names the two ends by the link type's sides: the inward issue blocks the outward one, which then reads "is blocked by" it.
return self.http("POST", f"{self.epic.site}/rest/api/3/issueLink", authorization, {"type": {"name": BLOCKS}, "inwardIssue": {"key": blocker}, "outwardIssue": {"key": key}})
def relinked(self, issue: Issue, wanted: tuple[str, ...] | None, authorization: str) -> tuple[str, ...]:
"""Makes issue blocked by exactly the issues named in wanted: a link for each blocker it lacks, and a deletion of each link to one it no longer has. None leaves its links as they are. A note for each request Jira refuses."""
def relinked(self, issue: Issue, wanted: tuple[str, ...] | None, open_keys: set[object], authorization: str) -> tuple[str, ...]:
"""Makes issue blocked by exactly the open children named in wanted: a link for each that it lacks, and a deletion of each link to an open child that wanted drops. A link to any other issue stays, since the team may have made it. None for wanted leaves every link as it is. A note for each request Jira refuses."""
if wanted is None:
return ()
notes = []
for blocker in (blocker for blocker in wanted if blocker not in issue.blockers):
if isinstance(linked := self.link(issue.key, blocker, authorization), Failure):
notes.append(f"edited {issue.key}, but cannot link it as blocked by {blocker}: {linked.reason}; link it in Jira")
for link in (link for link in issue.links if link.blocker not in wanted):
for link in (link for link in issue.links if link.blocker in open_keys and link.blocker not in wanted):
if isinstance(deleted := self.http("DELETE", f"{self.epic.site}/rest/api/3/issueLink/{link.id}", authorization, None), Failure):
notes.append(f"edited {issue.key}, but cannot delete its link as blocked by {link.blocker}: {deleted.reason}; delete it in Jira")
notes.append(f"edited {issue.key}, but cannot delete the link that makes it blocked by {link.blocker}: {deleted.reason}; delete it in Jira")
return tuple(notes)
def rank_refusal(self, key: str, before: str, authorization: str) -> str | None:
@@ -222,7 +222,7 @@ class JiraPlan:
return isinstance(texts, list) and texts[0].strip() == detail.strip()
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
"""Sets the fields and the detail in one request, so Jira takes all of the edit or none, then changes the issue's links, and then posts comment on the issue. `revision_of` says what an edit may set.
"""Sets the fields and the detail in one request, so Jira takes all of those or none, then changes the issue's links one request at a time, and then posts comment on the issue. `revision_of` says what an edit may set.
A link change or a comment Jira refuses leaves the edit made, so the write counts as landed, and a note says what to do by hand."""
authorization = basic_auth(self.env_file)
@@ -241,7 +241,8 @@ class JiraPlan:
revision = revision_of(issue, cells(fields), detail, comment)
if isinstance(revision, Failure):
return revision
if revision.blockers is not None and (missing := missing_blocker(revision.blockers, keys_of(answered), self.label)):
open_keys = keys_of(answered)
if revision.blockers is not None and (missing := missing_blocker(revision.blockers, open_keys, self.label)):
return missing
body = revision.body
if detail is not None and not self.shows(issue, detail):
@@ -261,7 +262,7 @@ class JiraPlan:
edited = self.http("PUT", url, authorization, body) if body else None
if isinstance(edited, Failure):
return Failure(f"cannot edit {key}: {edited.reason}; {PERHAPS_EDITED.format(key=key)}")
notes = self.relinked(issue, revision.blockers, authorization)
notes = self.relinked(issue, revision.blockers, open_keys, authorization)
if said is None:
return Written(id_, notes)
posted = self.http("POST", f"{url}/comment", authorization, {"body": said})
@@ -373,7 +374,7 @@ class Revision:
def revision_of(issue: Issue, named: dict[str, str], detail: str | None, comment: str | None) -> Revision | Failure:
"""The edit of issue that sets the cells in named, and the detail unless None, or why it cannot be made.
The summary, description and Fix Version of an issue a person filed are the team's, so there an edit may set only SCORED. Jira's screens don't show PROPERTY, so such an edit needs a comment, which tells the team. L, E, I and S are set together, so no issue is left partly scored. An issue the loop filed also keeps the label SECURITY in step with its Exempt. Only there may an edit name the blockers, whose links `JiraPlan.relinked` changes; each must be an open child, which the caller checks."""
The summary, description, Fix Version and links of an issue a person filed are the team's, so of such an issue an edit may set only SCORED. Jira's screens don't show PROPERTY, so such an edit needs a comment, which tells the team. L, E, I and S are set together, so no issue is left partly scored. An issue the loop filed also keeps the label SECURITY in step with its Exempt. Only an edit of an issue the loop filed may name the blockers, whose links `JiraPlan.relinked` changes; each must be an open child, which the caller checks."""
held = issue.scores
own = held.get(FILED_BY[0]) == FILED_BY[1]
if not own and ("Item" in named or "Release" in named or BLOCKED_BY in named or detail is not None):
@@ -492,7 +493,7 @@ def keys_of(answered: list[object]) -> set[object]:
def missing_blocker(blockers: tuple[str, ...], held: set[object], label: str) -> Failure | None:
"""A Failure naming the first of blockers that is not among the keys held, the plan's open children, or None. `item` reads only an open child as a blocker, so a link to any other issue would be lost on the next read."""
"""None where each of blockers is among the keys held, the plan's open children, else a Failure naming the first that isn't. `item` reads only an open child as a blocker, so a link to any other issue would be lost on the next read."""
missing = next((blocker for blocker in blockers if blocker not in held), None)
return None if missing is None else Failure(f"{label} holds no item {number(missing)} to be blocked by")
+6 -1
View File
@@ -624,6 +624,11 @@ class Editing(unittest.TestCase):
self.assertEqual(self.edit(34, {"Blocked by": ""}), Written(34))
self.assertEqual(self.writes(), [("DELETE", f"{LINKS}/{link_id('ABC-34', blocker)}", None) for blocker in ("ABC-35", "ABC-36")])
def test_a_link_to_an_issue_that_is_no_open_child_is_never_deleted(self):
self.open[0] = issue("ABC-34", scores=PROPERTY, blocked_by=("ABC-35", "OPS-9", "ABC-99"))
self.assertEqual(self.edit(34, {"Blocked by": "36"}), Written(34))
self.assertEqual([(method, url) for method, url, _ in self.writes()], [("POST", LINKS), ("DELETE", f"{LINKS}/{link_id('ABC-34', 'ABC-35')}")])
def test_a_blocked_by_the_issue_already_holds_writes_nothing(self):
self.open[0] = issue("ABC-34", scores=PROPERTY, blocked_by=("ABC-35", "ABC-36"))
self.assertEqual(self.edit(34, {"Blocked by": "36, 35"}), Written(34))
@@ -652,7 +657,7 @@ class Editing(unittest.TestCase):
def test_a_link_jira_refuses_to_delete_leaves_a_note_and_the_comment_posted(self):
self.open[0] = issue("ABC-34", scores=PROPERTY, blocked_by=("ABC-35", "ABC-36"))
self.unlinked = Failure("HTTP 404")
self.assertEqual(self.edit(34, {"Blocked by": ""}, None, COMMENT), Written(34, ("edited ABC-34, but cannot delete its link as blocked by ABC-35: HTTP 404; delete it in Jira", "edited ABC-34, but cannot delete its link as blocked by ABC-36: HTTP 404; delete it in Jira")))
self.assertEqual(self.edit(34, {"Blocked by": ""}, None, COMMENT), Written(34, ("edited ABC-34, but cannot delete the link that makes it blocked by ABC-35: HTTP 404; delete it in Jira", "edited ABC-34, but cannot delete the link that makes it blocked by ABC-36: HTTP 404; delete it in Jira")))
self.assertEqual(self.writes()[-1][1], f"{ISSUES}/ABC-34/comment")
def test_a_blocker_that_is_no_open_child_fails_before_any_write(self):
+3 -2
View File
@@ -44,14 +44,15 @@ dropped or wiped by mistake. It prints `Edited item <ID> in <plan>.` It doesn't
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.
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.
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.
--comment is posted as a comment on the Jira issue, for the client's team, in the project's
language. Jira doesn't show the team the scores, so say that the issue is scored, and why.
A todo.md keeps no comment, so there the flag doesn't do anything.
Where Jira takes the edit and then refuses a link or the comment, edit still prints `Edited item <ID> …`,
Where Jira takes the edit and then refuses a link, a deletion or the comment, edit still prints `Edited item <ID> …`,
and says on stderr what to do in Jira.
move sets the item's release, as edit sets a cell. It prints `Moved item <ID> to release <version> in <plan>.`