Answer stability round 1: 0 🔴, 1 🟡 (0 misread); split the re-rank into the pure rank_moves, rank only just before, as the item says, and name ranking in the README and the protocol

This commit is contained in:
2026-11-18 19:56:29 +01:00
parent 7bd192735a
commit ddce0f2cb0
10 changed files with 93 additions and 57 deletions
+5 -5
View File
@@ -7,7 +7,7 @@ from failure import Failure
@dataclasses.dataclass
class MemoryEpic:
"""An epic whose issues rank in the order filed, until one is ranked. Where fails is set, every call fails with it as the reason."""
"""An epic whose issues rank in the order filed, until one is ranked. Where fails is set, every call but change fails with it as the reason."""
epic_key: str
issues: list[EpicIssue] = dataclasses.field(default_factory=list)
fails: str | None = None
@@ -39,14 +39,14 @@ class MemoryEpic:
self.change(key, labels=tuple(sorted({*child.labels, label})))
return None
def rank(self, key: str, other: str, after: bool = False) -> None | Failure:
def rank(self, key: str, before: str) -> None | Failure:
if self.fails:
return Failure(self.fails)
children = {issue.key: issue for issue in self.issues if issue.parent == self.epic_key}
if stray := next((each for each in (key, other) if each not in children), None):
return Failure(f"{stray} is not one of the child issues of the epic {self.epic_key}, so it cannot be ranked")
if stray := next((each for each in (key, before) if each not in children), None):
return Failure(f"{stray} is not one of the child issues of the epic {self.epic_key}, so {key} is not ranked")
self.issues.remove(children[key])
self.issues.insert(self.issues.index(children[other]) + after, children[key])
self.issues.insert(self.issues.index(children[before]), children[key])
return None
def change(self, key: str, **fields: object) -> None: