From 2c1a84518fab53646fe42a9f9a4b5f2c11bdca40 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 17:16:37 +0100 Subject: [PATCH 1/5] Read each epic issue's scores, blockers and whether the loop filed it, from both backends --- bin/do_epic/backend/contract.py | 47 ++++++++++++++++++++++++++++++-- bin/do_epic/backend/fake.py | 2 +- bin/do_epic/backend/jira.py | 25 +++++++++++------ bin/do_epic/backend/protocol.py | 9 +++++- bin/do_epic/backend/test_fake.py | 12 ++++++++ bin/do_epic/backend/test_jira.py | 35 ++++++++++++++++++++---- bin/plan_store/jira_epic.py | 7 ++++- docs/reading-cost.md | 17 ++++++++++++ 8 files changed, 136 insertions(+), 18 deletions(-) diff --git a/bin/do_epic/backend/contract.py b/bin/do_epic/backend/contract.py index e0b33b86..11d38cef 100644 --- a/bin/do_epic/backend/contract.py +++ b/bin/do_epic/backend/contract.py @@ -1,9 +1,10 @@ -"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign and close change an issue as a person would in the tracker.""" +"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign, close, person_files, score and block change the tracker as a person, or the plan store, would.""" import re import typing from do_epic.backend.protocol import EpicIssue, EpicStore from failure import Failure +from plan.todo_table import ItemFields class EpicStoreContract: @@ -22,6 +23,18 @@ class EpicStoreContract: """Moves the issue named key to the done status named status.""" raise NotImplementedError + def person_files(self, store: EpicStore, summary: str) -> str: + """Files a child issue of the epic as a person does in the tracker, not through the store, and answers its key.""" + raise NotImplementedError + + def score(self, store: EpicStore, key: str, scores: dict[str, str]) -> None: + """Sets the scores of the issue named key, as `plan_store` writes them: each column's name with its value as text, such as {"L": "2", "Moves": "1 by 5"}.""" + raise NotImplementedError + + def block(self, store: EpicStore, key: str, blocker: str) -> None: + """Makes the issue named key blocked by the issue named blocker, as a person would link them in the tracker.""" + raise NotImplementedError + def filed(self, store: EpicStore, parent: str, summary: str, detail: str = "", labels: tuple[str, ...] = ()) -> str: key = store.file(parent, summary, detail, labels) assert isinstance(key, str), key @@ -38,7 +51,7 @@ class EpicStoreContract: def test_reads_back_a_child_issue_it_filed(self) -> None: store = self.new_store() key = self.filed(store, store.epic_key, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("security", "api")) - self.assertEqual(self.issues(store), [EpicIssue(key, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("api", "security"), None, "To Do", False, store.epic_key)]) + self.assertEqual(self.issues(store), [EpicIssue(key, "Count the runs.", "Why it counts.\n\nA second paragraph.", ("api", "security"), None, "To Do", False, store.epic_key, by_loop=True)]) def test_reads_back_a_sub_task_it_filed_after_its_parent(self) -> None: store = self.new_store() @@ -107,3 +120,33 @@ class EpicStoreContract: self.assertEqual(store.add_label(key, label), Failure(reason)) self.assertIsInstance(store.add_label("ZZZ-1", "repo:log"), Failure) self.assertEqual([issue.labels for issue in self.issues(store)], [(), ()]) + + def test_reads_an_issue_without_scores_or_blockers_as_one_with_none(self) -> None: + store = self.new_store() + key = self.filed(store, store.epic_key, "Count the runs.") + [issue] = self.issues(store) + self.assertEqual((issue.key, issue.scores, issue.blockers), (key, ItemFields(), ())) + + def test_reads_the_scores_a_person_or_the_plan_store_set(self) -> None: + store = self.new_store() + key = self.filed(store, store.epic_key, "Count the runs.") + self.score(store, key, {"L": "2", "E": "3", "I": "4", "S": "3", "Moves": "1 by 5", "Exempt": "security"}) + [issue] = self.issues(store) + self.assertEqual((issue.scores.scores, issue.scores.moves, issue.scores.exempt), ({"L": 2, "E": 3, "I": 4, "S": 3}, (("1", 5),), "security")) + self.assertEqual((issue.scores.release, issue.scores.blocked_by), (None, ())) + + def test_reads_each_blocker_of_an_issue_and_none_for_a_blocker_of_another(self) -> None: + store = self.new_store() + first, second, third = (self.filed(store, store.epic_key, f"Item {n}.") for n in range(3)) + self.block(store, third, first) + self.block(store, third, second) + read = {issue.key: issue for issue in self.issues(store)} + self.assertEqual([read[key].blockers for key in (first, second, third)], [(), (), (first, second)]) + + def test_reads_whether_the_loop_filed_an_issue(self) -> None: + store = self.new_store() + ours = self.filed(store, store.epic_key, "Count the runs.") + theirs = self.person_files(store, "A person's issue.") + task = self.filed(store, ours, "Count them in the api.") + read = {issue.key: issue for issue in self.issues(store)} + self.assertEqual([read[key].by_loop for key in (ours, theirs, task)], [True, False, True]) diff --git a/bin/do_epic/backend/fake.py b/bin/do_epic/backend/fake.py index 04f87397..217ef991 100644 --- a/bin/do_epic/backend/fake.py +++ b/bin/do_epic/backend/fake.py @@ -25,7 +25,7 @@ class MemoryEpic: if parent != self.epic_key and parent not in {issue.key for issue in self.issues if issue.parent == self.epic_key}: return no_parent(self.epic_key, parent) key = f"{self.epic_key.rpartition('-')[0]}-{len(self.issues) + 100}" - self.issues.append(EpicIssue(key, summary, detail.strip(), tuple(sorted(labels)), None, "To Do", False, parent)) + self.issues.append(EpicIssue(key, summary, detail.strip(), tuple(sorted(labels)), None, "To Do", False, parent, by_loop=True)) return key def add_label(self, key: str, label: str) -> None | Failure: diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index 05d10536..730f885f 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -5,12 +5,12 @@ import typing from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown +from plan_store.jira_epic import blocked_by_links, FILED_BY, ISSUE_KEY, ISSUE_TYPE, project_of, PROPERTY, scores, searched from project_config.settings import Epic from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit, unfit_label from failure import Failure -from plan_store.jira_epic import ISSUE_KEY, ISSUE_TYPE, project_of, searched -FIELDS = ["summary", "description", "labels", "assignee", "status", "parent"] +FIELDS = ["summary", "description", "labels", "assignee", "status", "parent", "issuelinks"] # How many child issues one search for sub-tasks names, which keeps its JQL well inside the length Jira takes. PARENTS_PER_SEARCH = 50 PERHAPS_FILED = "unless Jira refused the request, the issue may exist: look under {parent} before filing it again" @@ -60,6 +60,8 @@ class JiraEpic: if refused := unfit(summary, labels) or self.not_a_parent(parent, authorization): return refused fields: dict[str, typing.Any] = {"project": {"key": project_of(parent)}, "parent": {"key": parent}, "summary": summary, "labels": list(labels)} + # The mark that tells the loop's issues from a person's, as plan_store marks the items it files. + properties = [{"key": PROPERTY, "value": {FILED_BY[0]: FILED_BY[1]}}] kind = {"name": ISSUE_TYPE} if parent == self.epic_key else self.sub_task_type(project_of(parent), authorization) if isinstance(kind, Failure): return kind @@ -68,7 +70,7 @@ class JiraEpic: if isinstance(description, Failure): return Failure(f"cannot convert the detail to a Jira description: {description.reason}") fields["description"] = description - created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, {"fields": fields | {"issuetype": kind}}) + created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, {"fields": fields | {"issuetype": kind}, "properties": properties}) if isinstance(created, Failure): return Failure(f"cannot file the issue under {parent}: {created.reason}; {PERHAPS_FILED.format(parent=parent)}") key = created.get("key") if isinstance(created, dict) else None @@ -130,7 +132,7 @@ class JiraEpic: def searched(self, what: str, parents: tuple[str, ...], authorization: str) -> list[Found] | Failure: """The issues whose parent is one of parents, in rank order.""" named = ", ".join(f'"{key}"' for key in parents) - answered = searched(self.epic.site, what, f"parent in ({named}) ORDER BY Rank ASC", {"fields": FIELDS}, authorization, self.http) + answered = searched(self.epic.site, what, f"parent in ({named}) ORDER BY Rank ASC", {"fields": FIELDS, "properties": [PROPERTY]}, authorization, self.http) if isinstance(answered, Failure): return answered found = [found_of(raw) for raw in answered] @@ -159,9 +161,16 @@ def found_of(raw: object) -> Found | Failure: summary, labels, assignee, status, parent, description = fields["summary"], fields["labels"], fields["assignee"], fields["status"], fields["parent"]["key"], fields["description"] name = assignee["displayName"] if assignee is not None else None state, done = status["name"], status["statusCategory"]["key"] == "done" + blockers = tuple(link.blocker for link in blocked_by_links(fields)) + held = raw.get("properties", {}).get(PROPERTY, {}) except (AttributeError, KeyError, TypeError) as failure: return Failure(f"{key} is not in the shape Jira Cloud's REST API version 3 documents: {failure!r}") - texts = (summary, *labels, state, parent) if isinstance(labels, list) else () - if not texts or not all(isinstance(text, str) for text in texts) or not isinstance(name, str | None) or not ISSUE_KEY.fullmatch(parent) or not isinstance(description, dict | None): - return Failure(f"{key} is not in the shape Jira Cloud's REST API version 3 documents: its summary, labels, assignee, status, parent or description holds another kind of value") - return Found(EpicIssue(key, summary.strip(), "", tuple(sorted(labels)), name, state, done, parent), description) + texts = (summary, *labels, state, parent, *blockers) if isinstance(labels, list) else () + if not texts or not all(isinstance(text, str) for text in texts) or not isinstance(name, str | None) or not all(ISSUE_KEY.fullmatch(each) for each in (parent, *blockers)) or not isinstance(description, dict | None): + return Failure(f"{key} is not in the shape Jira Cloud's REST API version 3 documents: its summary, labels, assignee, status, parent, description or a linked issue's key holds another kind of value") + if not isinstance(held, dict): + return Failure(f"{key}'s issue property {PROPERTY} is not a JSON object") + read = scores(key, held) + if isinstance(read, Failure): + return read + return Found(EpicIssue(key, summary.strip(), "", tuple(sorted(labels)), name, state, done, parent, read, blockers, held.get(FILED_BY[0]) == FILED_BY[1]), description) diff --git a/bin/do_epic/backend/protocol.py b/bin/do_epic/backend/protocol.py index 0a9b0f23..78b30cb6 100644 --- a/bin/do_epic/backend/protocol.py +++ b/bin/do_epic/backend/protocol.py @@ -6,6 +6,7 @@ import re import typing from failure import Failure +from plan.todo_table import ItemFields # What a tracker accepts as a label: Jira refuses a label holding white space. LABEL = re.compile(r"\S+") @@ -28,6 +29,12 @@ class EpicIssue: done: bool # The epic's key for a child issue, the child's key for a sub-task. parent: str + # The scores, Moves and Exempt a plan-item issue property holds, as `plan_store` reads them; its release and blocked_by stay unset, since an epic's items have no release and `blockers` holds theirs. Empty where the issue holds none, as a person's issue does. + scores: ItemFields = dataclasses.field(default_factory=ItemFields) + # The key of each issue this one is blocked by, in the tracker's order. + blockers: tuple[str, ...] = () + # Whether the loop filed the issue, through EpicStore.file, rather than a person. + by_loop: bool = False class EpicStore(typing.Protocol): @@ -41,7 +48,7 @@ class EpicStore(typing.Protocol): """Each child issue, open or done, in the tracker's rank order, each followed by its sub-tasks in theirs.""" def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...]) -> str | Failure: - """Files an open issue under parent and answers its key: a child issue where parent is the epic, a sub-task where parent is one of its child issues. detail is markdown, and may be empty.""" + """Files an open issue under parent, marked as filed by the loop, and answers its key: a child issue where parent is the epic, a sub-task where parent is one of its child issues. detail is markdown, and may be empty.""" def add_label(self, key: str, label: str) -> None | Failure: """Adds label to the epic's child issue named key, leaving its other labels as they are; adding one it already has leaves the labels as they are. A sub-task, or an issue outside the epic, is refused.""" diff --git a/bin/do_epic/backend/test_fake.py b/bin/do_epic/backend/test_fake.py index a2d804a8..40632ba8 100644 --- a/bin/do_epic/backend/test_fake.py +++ b/bin/do_epic/backend/test_fake.py @@ -6,6 +6,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2])) from do_epic.backend.contract import EpicStoreContract from failure import Failure +from plan_store import jira_epic from do_epic.backend.fake import MemoryEpic @@ -19,6 +20,17 @@ class MemoryEpicContract(EpicStoreContract, unittest.TestCase): def close(self, store: MemoryEpic, key: str, status: str) -> None: # type: ignore[override] store.change(key, status=status, done=True) + def person_files(self, store: MemoryEpic, summary: str) -> str: # type: ignore[override] + key = self.filed(store, store.epic_key, summary) + store.change(key, by_loop=False) + return key + + def score(self, store: MemoryEpic, key: str, scores: dict[str, str]) -> None: # type: ignore[override] + store.change(key, scores=jira_epic.scores(key, scores)) + + def block(self, store: MemoryEpic, key: str, blocker: str) -> None: # type: ignore[override] + store.change(key, blockers=(*next(issue for issue in store.issues if issue.key == key).blockers, blocker)) + class Failing(unittest.TestCase): def test_every_read_and_filing_fails_with_the_reason_given(self) -> None: diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index e7287c74..18ac3f23 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -72,7 +72,7 @@ class FakeJira: if matched is None: return Failure("Jira answered 400: the JQL is not valid") parents = re.findall(r'"([A-Z]+-[0-9]+)"', matched[1]) - found = [{"key": issue["key"], "fields": {name: value for name, value in issue["fields"].items() if name in body.get("fields", [])}} for issue in self.issues if issue["fields"]["parent"]["key"] in parents] # type: ignore[index, attr-defined] + found = [{"key": issue["key"], "fields": {name: value for name, value in issue["fields"].items() if name in body.get("fields", [])}, "properties": {name: value for name, value in issue.get("properties", {}).items() if name in body.get("properties", [])}} for issue in self.issues if issue["fields"]["parent"]["key"] in parents] # type: ignore[index, attr-defined] start = int(body.get("nextPageToken", 0)) return {"issues": found[start:start + 2]} | ({"nextPageToken": str(start + 2)} if start + 2 < len(found) else {}) @@ -84,12 +84,21 @@ class FakeJira: if fields["project"] != {"key": "ABC"} or kind is None or fields["issuetype"] != kind: return Failure("Jira answered 400: the project, parent or issue type is not valid") key = f"ABC-{len(self.issues) + 100}" - self.issues.append({"key": key, "fields": {"summary": fields["summary"], "description": fields.get("description"), "labels": fields["labels"], "assignee": None, "status": TO_DO, "parent": {"key": parent}}}) + self.issues.append({"key": key, "fields": {"summary": fields["summary"], "description": fields.get("description"), "labels": fields["labels"], "assignee": None, "status": TO_DO, "parent": {"key": parent}, "issuelinks": []}, "properties": {entry["key"]: entry["value"] for entry in body["properties"]}}) return {"id": "1", "key": key} def change(self, key: str, **fields: object) -> None: next(issue for issue in self.issues if issue["key"] == key)["fields"].update(fields) # type: ignore[union-attr] + def person_files(self, summary: str) -> str: + """Files a child issue as the Jira website does: with no issue property.""" + key = f"ABC-{len(self.issues) + 100}" + self.issues.append({"key": key, "fields": {"summary": summary, "description": None, "labels": [], "assignee": None, "status": TO_DO, "parent": {"key": "ABC-12"}, "issuelinks": []}}) + return key + + def set_property(self, key: str, value: dict[str, object]) -> None: + next(issue for issue in self.issues if issue["key"] == key).setdefault("properties", {})["plan-item"] = value # type: ignore[attr-defined, union-attr] + class Case(unittest.TestCase): def setUp(self) -> None: @@ -111,6 +120,17 @@ class JiraEpicContract(Case, EpicStoreContract): def close(self, store: JiraEpic, key: str, status: str) -> None: # type: ignore[override] self.jira.change(key, status={"name": status, "statusCategory": {"key": "done"}}) + def person_files(self, store: JiraEpic, summary: str) -> str: # type: ignore[override] + return self.jira.person_files(summary) + + def score(self, store: JiraEpic, key: str, scores: dict[str, str]) -> None: # type: ignore[override] + held = next(issue for issue in self.jira.issues if issue["key"] == key).get("properties", {}).get("plan-item", {}) # type: ignore[attr-defined, union-attr] + self.jira.set_property(key, held | scores) + + def block(self, store: JiraEpic, key: str, blocker: str) -> None: # type: ignore[override] + links = next(issue for issue in self.jira.issues if issue["key"] == key)["fields"]["issuelinks"] # type: ignore[index] + links.append({"id": str(len(links) + 1), "type": {"inward": "is blocked by", "outward": "blocks"}, "inwardIssue": {"key": blocker}}) + class Jira(Case): def test_reads_the_sub_tasks_of_more_children_than_one_search_names(self) -> None: @@ -146,16 +166,21 @@ class Jira(Case): self.assertEqual(len(self.jira.issues), 1) def test_an_issue_in_another_shape_fails_the_read(self) -> None: - valid = {"summary": "Count the runs.", "description": None, "labels": [], "assignee": None, "status": TO_DO, "parent": {"key": "ABC-12"}} + valid = {"summary": "Count the runs.", "description": None, "labels": [], "assignee": None, "status": TO_DO, "parent": {"key": "ABC-12"}, "issuelinks": []} + linked = {"id": "1", "type": {"inward": "is blocked by"}, "inwardIssue": {"key": "ABC-2"}} shape = "ABC-34 is not in the shape Jira Cloud's REST API version 3 documents" for raw, reason in ( ("ABC-34", "the search answered an issue without an issue key"), ({"fields": valid}, "the search answered an issue without an issue key"), ({"key": "abc-34", "fields": valid}, "the search answered an issue without an issue key"), ({"key": "ABC-34", "fields": {"summary": "Count the runs.", "parent": {"key": "ABC-12"}}}, shape + ": KeyError('labels')"), - *((({"key": "ABC-34", "fields": valid | changed}, shape + ": its summary, labels, assignee, status, parent or description holds another kind of value") for changed in ( - {"summary": 3}, {"labels": "api"}, {"labels": [3]}, {"assignee": {"displayName": 0}}, {"status": {"name": 0, "statusCategory": {"key": "new"}}}, {"parent": {"key": "ABC"}}, {"parent": {"key": 12}}, {"description": "text"}, + *((({"key": "ABC-34", "fields": valid | changed}, shape + ": its summary, labels, assignee, status, parent, description or a linked issue's key holds another kind of value") for changed in ( + {"summary": 3}, {"labels": "api"}, {"labels": [3]}, {"assignee": {"displayName": 0}}, {"status": {"name": 0, "statusCategory": {"key": "new"}}}, {"parent": {"key": "ABC"}}, {"parent": {"key": 12}}, {"description": "text"}, {"issuelinks": [linked | {"inwardIssue": {"key": 7}}]}, {"issuelinks": [linked | {"inwardIssue": {"key": "ABC-x"}}]}, ))), + ({"key": "ABC-34", "fields": {key: value for key, value in valid.items() if key != "issuelinks"}}, shape + ": KeyError('issuelinks')"), + ({"key": "ABC-34", "fields": valid, "properties": {"plan-item": "L 2"}}, "ABC-34's issue property plan-item is not a JSON object"), + ({"key": "ABC-34", "fields": valid, "properties": {"plan-item": {"L": "many"}}}, "item ABC-34's L 'many' is not a whole number from 1 to 4; ABC-34 holds it in its issue property plan-item"), + ({"key": "ABC-34", "fields": valid, "properties": None}, shape + ": AttributeError(\"'NoneType' object has no attribute 'get'\")"), ): with self.subTest(raw=raw): self.jira.answers[("POST", SEARCH)] = {"issues": [raw]} diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 69104cf4..9ffa60ef 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -476,7 +476,7 @@ def issue_of(raw: object) -> Issue | Failure: # The answer's nested fields are read as Jira documents them; one missing or of another type ends the read here, as a Failure, so no later step meets it. try: fields = raw["fields"] - links = tuple(Link(link["inwardIssue"]["key"], link["id"]) for link in fields["issuelinks"] if "inwardIssue" in link and link["type"]["inward"] == "is blocked by") + links = blocked_by_links(fields) held = raw.get("properties", {}).get(PROPERTY, {}) summary, description, versions = fields["summary"].strip(), fields["description"], tuple(version["name"] for version in fields["fixVersions"]) except (AttributeError, KeyError, TypeError) as failure: @@ -489,6 +489,11 @@ def issue_of(raw: object) -> Issue | Failure: return issue +def blocked_by_links(fields: dict[str, typing.Any]) -> tuple[Link, ...]: + """The "is blocked by" links among an issue's `issuelinks` field; a KeyError, TypeError or AttributeError where it isn't in the shape Jira documents.""" + return tuple(Link(link["inwardIssue"]["key"], link["id"]) for link in fields["issuelinks"] if "inwardIssue" in link and link["type"]["inward"] == "is blocked by") + + def keys_of(answered: list[object]) -> set[object]: """The key of each issue in the search's answer.""" return {raw.get("key") for raw in answered if isinstance(raw, dict)} diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 1c136508..110d0c05 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -2725,3 +2725,20 @@ Read most (opens and searches): - `bin/loop_claude/test_loop_claude.py` 2 - `bin/review_replay/main.py` 2 - `bin/rule_hook/main.py` 2 + +## Reading cost, chunk 755c22e12ace, finished 2026-11-18T16:10:53Z + +114613 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/plan/ranking.py` 6 +- `bin/plan_store/jira_epic.py` 5 +- `rules/todo-items.md` 4 +- `bin/plan/goals_file.py` 2 +- `bin/do_epic/backend/jira.py` 1 +- `bin/do_epic/backend/protocol.py` 1 +- `bin/do_epic/config.py` 1 +- `bin/plan/blockers.py` 1 +- `bin/plan/todo_table.py` 1 +- `docs/decisions.md` 1 -- 2.52.0 From f0d99c8141ac44d96a2ec8c5b5949d01073341c2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 17:21:16 +0100 Subject: [PATCH 2/5] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20no=20findin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From e8255be53412e58681cb2f5206136bc3cdf3f540 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 18:32:38 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20score=20the?= =?UTF-8?q?=20person's=20issue=20in=20the=20contract=20test,=20and=20hold?= =?UTF-8?q?=20scores,=20moves=20and=20exempt=20apart=20from=20blockers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/do_epic/backend/contract.py | 16 ++++++++-------- bin/do_epic/backend/jira.py | 4 ++-- bin/do_epic/backend/protocol.py | 14 +++++++++----- bin/do_epic/backend/test_fake.py | 6 ++++-- bin/do_epic/backend/test_jira.py | 2 +- bin/plan_store/jira_epic.py | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/bin/do_epic/backend/contract.py b/bin/do_epic/backend/contract.py index 11d38cef..c865bb0f 100644 --- a/bin/do_epic/backend/contract.py +++ b/bin/do_epic/backend/contract.py @@ -1,10 +1,9 @@ -"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign, close, person_files, score and block change the tracker as a person, or the plan store, would.""" +"""What every backend of an epic's plan must hold, as tests. A backend's test case inherits EpicStoreContract and unittest.TestCase, and builds an epic with no issues in new_store. Its assign, close, person_files, score and block change the tracker as a person or the plan store would.""" import re import typing from do_epic.backend.protocol import EpicIssue, EpicStore from failure import Failure -from plan.todo_table import ItemFields class EpicStoreContract: @@ -27,8 +26,8 @@ class EpicStoreContract: """Files a child issue of the epic as a person does in the tracker, not through the store, and answers its key.""" raise NotImplementedError - def score(self, store: EpicStore, key: str, scores: dict[str, str]) -> None: - """Sets the scores of the issue named key, as `plan_store` writes them: each column's name with its value as text, such as {"L": "2", "Moves": "1 by 5"}.""" + def score(self, store: EpicStore, key: str, scores: dict[str, object]) -> None: + """Sets the scores of the issue named key as `plan_store` writes them: each column's name with its value, a whole number for a score and text for Moves and Exempt, such as {"L": 2, "Moves": "1 by 5"}.""" raise NotImplementedError def block(self, store: EpicStore, key: str, blocker: str) -> None: @@ -125,15 +124,14 @@ class EpicStoreContract: store = self.new_store() key = self.filed(store, store.epic_key, "Count the runs.") [issue] = self.issues(store) - self.assertEqual((issue.key, issue.scores, issue.blockers), (key, ItemFields(), ())) + self.assertEqual((issue.key, issue.scores, issue.moves, issue.exempt, issue.blockers), (key, {}, (), "", ())) def test_reads_the_scores_a_person_or_the_plan_store_set(self) -> None: store = self.new_store() key = self.filed(store, store.epic_key, "Count the runs.") - self.score(store, key, {"L": "2", "E": "3", "I": "4", "S": "3", "Moves": "1 by 5", "Exempt": "security"}) + self.score(store, key, {"L": 2, "E": 3, "I": 4, "S": 3, "Moves": "1 by 5", "Exempt": "security"}) [issue] = self.issues(store) - self.assertEqual((issue.scores.scores, issue.scores.moves, issue.scores.exempt), ({"L": 2, "E": 3, "I": 4, "S": 3}, (("1", 5),), "security")) - self.assertEqual((issue.scores.release, issue.scores.blocked_by), (None, ())) + self.assertEqual((issue.scores, issue.moves, issue.exempt), ({"L": 2, "E": 3, "I": 4, "S": 3}, (("1", 5),), "security")) def test_reads_each_blocker_of_an_issue_and_none_for_a_blocker_of_another(self) -> None: store = self.new_store() @@ -147,6 +145,8 @@ class EpicStoreContract: store = self.new_store() ours = self.filed(store, store.epic_key, "Count the runs.") theirs = self.person_files(store, "A person's issue.") + # The plan store scores an issue a person filed without making it the loop's. + self.score(store, theirs, {"L": 2, "E": 3, "I": 4, "S": 3, "Moves": "1 by 5"}) task = self.filed(store, ours, "Count them in the api.") read = {issue.key: issue for issue in self.issues(store)} self.assertEqual([read[key].by_loop for key in (ours, theirs, task)], [True, False, True]) diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index 730f885f..d31f570b 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -60,7 +60,7 @@ class JiraEpic: if refused := unfit(summary, labels) or self.not_a_parent(parent, authorization): return refused fields: dict[str, typing.Any] = {"project": {"key": project_of(parent)}, "parent": {"key": parent}, "summary": summary, "labels": list(labels)} - # The mark that tells the loop's issues from a person's, as plan_store marks the items it files. + # Marks the issue as the loop's, as plan_store marks the items it files. properties = [{"key": PROPERTY, "value": {FILED_BY[0]: FILED_BY[1]}}] kind = {"name": ISSUE_TYPE} if parent == self.epic_key else self.sub_task_type(project_of(parent), authorization) if isinstance(kind, Failure): @@ -173,4 +173,4 @@ def found_of(raw: object) -> Found | Failure: read = scores(key, held) if isinstance(read, Failure): return read - return Found(EpicIssue(key, summary.strip(), "", tuple(sorted(labels)), name, state, done, parent, read, blockers, held.get(FILED_BY[0]) == FILED_BY[1]), description) + return Found(EpicIssue(key, summary.strip(), "", tuple(sorted(labels)), name, state, done, parent, read.scores, read.moves, read.exempt, blockers, held.get(FILED_BY[0]) == FILED_BY[1]), description) diff --git a/bin/do_epic/backend/protocol.py b/bin/do_epic/backend/protocol.py index 78b30cb6..3da13e8e 100644 --- a/bin/do_epic/backend/protocol.py +++ b/bin/do_epic/backend/protocol.py @@ -5,8 +5,8 @@ import dataclasses import re import typing +from plan.todo_table import Exempt, Moves from failure import Failure -from plan.todo_table import ItemFields # What a tracker accepts as a label: Jira refuses a label holding white space. LABEL = re.compile(r"\S+") @@ -29,11 +29,15 @@ class EpicIssue: done: bool # The epic's key for a child issue, the child's key for a sub-task. parent: str - # The scores, Moves and Exempt a plan-item issue property holds, as `plan_store` reads them; its release and blocked_by stay unset, since an epic's items have no release and `blockers` holds theirs. Empty where the issue holds none, as a person's issue does. - scores: ItemFields = dataclasses.field(default_factory=ItemFields) - # The key of each issue this one is blocked by, in the tracker's order. + # The score of each column the issue has one for, such as {"L": 2}, as `plan_store` reads them from the issue's `plan-item` property. Empty where the issue has no scores. + scores: dict[str, int] = dataclasses.field(default_factory=dict) + # The goals the issue moves, and how far (the plan's Moves cell); empty where it names none. + moves: Moves = () + # Why the issue is exempt from the plan's score bar, as the plan's Exempt cell names it; empty where it isn't. + exempt: Exempt = "" + # The key of each issue that blocks this one, in the tracker's order. blockers: tuple[str, ...] = () - # Whether the loop filed the issue, through EpicStore.file, rather than a person. + # True where the loop filed the issue through EpicStore.file; False for an issue a person filed. by_loop: bool = False diff --git a/bin/do_epic/backend/test_fake.py b/bin/do_epic/backend/test_fake.py index 40632ba8..24db7161 100644 --- a/bin/do_epic/backend/test_fake.py +++ b/bin/do_epic/backend/test_fake.py @@ -25,8 +25,10 @@ class MemoryEpicContract(EpicStoreContract, unittest.TestCase): store.change(key, by_loop=False) return key - def score(self, store: MemoryEpic, key: str, scores: dict[str, str]) -> None: # type: ignore[override] - store.change(key, scores=jira_epic.scores(key, scores)) + def score(self, store: MemoryEpic, key: str, scores: dict[str, object]) -> None: # type: ignore[override] + read = jira_epic.scores(key, scores) + assert not isinstance(read, Failure), read + store.change(key, scores=read.scores, moves=read.moves, exempt=read.exempt) def block(self, store: MemoryEpic, key: str, blocker: str) -> None: # type: ignore[override] store.change(key, blockers=(*next(issue for issue in store.issues if issue.key == key).blockers, blocker)) diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 18ac3f23..015d5514 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -123,7 +123,7 @@ class JiraEpicContract(Case, EpicStoreContract): def person_files(self, store: JiraEpic, summary: str) -> str: # type: ignore[override] return self.jira.person_files(summary) - def score(self, store: JiraEpic, key: str, scores: dict[str, str]) -> None: # type: ignore[override] + def score(self, store: JiraEpic, key: str, scores: dict[str, object]) -> None: # type: ignore[override] held = next(issue for issue in self.jira.issues if issue["key"] == key).get("properties", {}).get("plan-item", {}) # type: ignore[attr-defined, union-attr] self.jira.set_property(key, held | scores) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 9ffa60ef..2bf47644 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -490,7 +490,7 @@ def issue_of(raw: object) -> Issue | Failure: def blocked_by_links(fields: dict[str, typing.Any]) -> tuple[Link, ...]: - """The "is blocked by" links among an issue's `issuelinks` field; a KeyError, TypeError or AttributeError where it isn't in the shape Jira documents.""" + """The "is blocked by" links among an issue's `issuelinks` field. A field not in the shape Jira documents raises a KeyError or TypeError, which the caller turns into a Failure.""" return tuple(Link(link["inwardIssue"]["key"], link["id"]) for link in fields["issuelinks"] if "inwardIssue" in link and link["type"]["inward"] == "is blocked by") -- 2.52.0 From df1a4f9ca3e10a5c99b32ff42f2e2c50ae080a8d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 18:32:38 +0100 Subject: [PATCH 4/5] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20reword=20th?= =?UTF-8?q?e=20EpicIssue=20comments=20and=20the=20contract's=20score=20hoo?= =?UTF-8?q?k,=20in=20the=20stability=20round's=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 92bc84ba806a66f137f517d07b2ade4189ba08b3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 18:37:26 +0100 Subject: [PATCH 5/5] Finish item 426 in the plan --- CHANGELOG.md | 1 + todo.md | 15 +-------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 954f1364..4291972f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- do-epic's epic backends read each issue's scores, its blockers and whether the loop filed it, in the Jira backend and the in-memory one; the Jira backend marks each issue it files as the loop's. Nothing calls it yet. - The technical principles now forbid a test that decides at run time whether to check anything, by a conditional skip, early return or catch around its assertions, and stability-reviewer flags one. - do-epic's scorer orders an epic's items by score, then by Blocked by: an item's Moves names a goal as `epic 1.1`, `code health` or `repo 2`, and the epic's achieve goals outweigh the achieve goals of every repo. Nothing calls it yet. - `todo-item add` and `todo-item edit --detail` refuse a detail whose `Touches:` list touch-predictions cannot read, and `rank_todo.py --check` fails on each item holding one, so rule-hook refuses a commit of such a plan: after updating, run `~/.claude/bin/rank_todo.py --check` in each project and fix each list it names. diff --git a/todo.md b/todo.md index 1d48eaca..9fb303c1 100644 --- a/todo.md +++ b/todo.md @@ -12,8 +12,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 426 | 0.12.0 | | | **Read each epic issue's scores, its blockers and whether the loop filed it through `EpicStore`, from both backends.** | 2 | 2 | 2 | 4 | 3 | 1 by 5 | 1.9 | -| 427 | 0.12.0 | 426 | | **Re-rank Jira's backlog to match an epic's ranking, moving only the issues the loop filed, so people's issues keep their rank.** | 3 | 2 | 3 | 6 | 3 | 1 by 5 | 1.9 | +| 427 | 0.12.0 | | | **Re-rank Jira's backlog to match an epic's ranking, moving only the issues the loop filed, so people's issues keep their rank.** | 3 | 2 | 3 | 6 | 3 | 1 by 5 | 1.9 | | 410 | 0.12.0 | 427 | | **Run `do-epic `: one tmux session per epic, a window per chunk, up to the epic's cap of running chunks and each repo's `parallel-chunks`, and never in a repo a loop-claude is running chunks in.** | 3 | 2 | 3 | 6 | 6 | 1 by 5 | 0.8 | | 416 | 0.12.0 | 410 | | **Finish an epic's repo item with a bullet under its repo's `CHANGELOG.md` → `## Unreleased`, or with none where the repo's plan is in Jira.** | 1 | 1 | 1 | 1 | 2 | 1 by 5 | 2.1 | | 413 | 0.12.0 | 410 | | **File a finding about an epic goal in the epic and one about a repo goal by that repo's rules, ask the human where unsure which, and give the judge the epic's records beside the repo's.** | 3 | 2 | 3 | 6 | 4 | 1 by 5 | 1.6 | @@ -82,18 +81,6 @@ ## Details -### 426. Read each epic issue's scores, its blockers and whether the loop filed it through `EpicStore`, from both backends. - -Today `EpicIssue` holds none of the three, so do-epic cannot score or order an epic's items (item 408) or tell a person's issue from its own (item 427). The Jira backend reads them as `plan_store/jira_epic.py` does: the `plan-item` issue property, its `Filed by` key, and the "is blocked by" links. The contract tests in `contract.py` cover both backends. - -Touches: - -- `bin/do_epic/backend/protocol.py`: `EpicIssue` (small) -- `bin/do_epic/backend/fake.py` -- `bin/do_epic/backend/jira.py`: `FIELDS`, `JiraEpic.found` -- `bin/do_epic/backend/contract.py` -- `bin/do_epic/backend/test_jira.py` - ### 427. Re-rank Jira's backlog to match an epic's ranking, moving only the issues the loop filed, so people's issues keep their rank. Split from item 408 (`docs/decisions.md` → `do-epic: drives one Jira epic …`). `EpicStore` gains a rank call, in both backends and the contract tests. Lift `JiraPlan.rank_refusal` to a module function both stores call. Walk the target order: where the issue at a position isn't the target's, rank the target's just before it; the slots people's issues hold stay theirs. A rank Jira refuses stops the walk and is reported, since a wrongly ranked team backlog takes hours to restore. -- 2.52.0