Answer stability round 1: 0 🔴, 1 🟡 (0 misread); leave an item a person split to be closed by its team, and refuse a setting below the label table
This commit is contained in:
@@ -17,7 +17,7 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
||||
- `clone-folder` is the folder a missing repo is cloned into: a path that starts with / or ~/. `~/code` where left out.
|
||||
- `language` is the default language of Jira text, by its English name. English where left out.
|
||||
- `jira-finish-transition` and `jira-finish-status` name the workflow transition that moves a finished chunk's issue and closes a finished epic, such as "Mark as done", and the status it leads to, such as "Done". A project's config names a plan item's the same way. Set both or neither; without them do-epic moves no issue to done and closes no epic.
|
||||
- `[label-repos]` maps a label the team gives an issue to the repo it is worked in, such as `twu-4` to `tenant-web-ui-4`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself.
|
||||
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself.
|
||||
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
@@ -38,6 +38,7 @@ JIRA_URL = "jira-url"
|
||||
REPOLESS_MODEL = "repoless-model"
|
||||
CLONE_FOLDER = "clone-folder"
|
||||
SETTINGS = (JIRA_URL, ENV_FILE, REPOLESS_MODEL)
|
||||
# Three readers, seated as those who write and read this config, picked `label-repos` from four candidates, over `repo-aliases`, `repo-labels` and `team-labels`, 2-1. All three readers would misread `repo-labels` as mapping a repo to its label.
|
||||
LABEL_REPOS = "label-repos"
|
||||
OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH, LABEL_REPOS)
|
||||
LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTIONAL, 'and')}."
|
||||
@@ -55,17 +56,18 @@ class DoEpicConfig:
|
||||
repo_rule: str
|
||||
# How a finished epic closes; None where the config doesn't say.
|
||||
finish: Finish | None = None
|
||||
# The team's own label for a repo, mapped to the repo's name; empty where the config has no LABEL_REPOS table.
|
||||
# The LABEL_REPOS table; empty where the config has none.
|
||||
label_repos: LabelRepos = types.MappingProxyType({})
|
||||
|
||||
|
||||
def label_repo_faults(table: object) -> list[str]:
|
||||
"""What is wrong with the LABEL_REPOS table: an entry that is no label of a team's mapped to a repo's name."""
|
||||
"""What is wrong with the LABEL_REPOS table: each entry whose key isn't a team's label, or whose value isn't a repo's name."""
|
||||
if not isinstance(table, dict):
|
||||
return [f"`{LABEL_REPOS}` is {table!r}, not a table of labels, such as `twu-4 = \"tenant-web-ui-4\"` under `[{LABEL_REPOS}]`"]
|
||||
return [
|
||||
*(f"`{LABEL_REPOS}` maps {label!r}, a label do-epic gives a meaning of its own" for label in table if of_label(label, {}) is not None or label in (REVIEW_LABEL, SPLIT_LABEL)),
|
||||
*(f"`{LABEL_REPOS}` maps {label!r}, which Jira takes as no label" for label in table if not LABEL.fullmatch(label)),
|
||||
*(f"`{label}` stands below `[{LABEL_REPOS}]`, so it is read as a label; move it above the table" for label in table if label in (*SETTINGS, *OPTIONAL)),
|
||||
*(f"`{LABEL_REPOS}` maps {label!r}, which is no Jira label: a label holds no white space" for label in table if not LABEL.fullmatch(label)),
|
||||
*(f"`{LABEL_REPOS}` maps {label!r} to {repo!r}, not a repo's name in letters, digits, dots, hyphens and underscores" for label, repo in table.items() if not (isinstance(repo, str) and REPO_NAME.fullmatch(repo))),
|
||||
]
|
||||
|
||||
|
||||
+3
-2
@@ -46,8 +46,9 @@ HELP = f"""usage: do-epic <EPIC-KEY> [--status]
|
||||
Runs the chunks of one Jira epic, such as ABC-12, each in its own window of the tmux session epic-<EPIC-KEY>.
|
||||
Before it starts chunks, do-epic <EPIC-KEY> plans each open issue that has none of these labels:
|
||||
`repo:<name>` for its repo, `do-epic-claude` for work of Claude's that changes no repo, `do-epic-human` for a task of yours.
|
||||
A label that `[label-repos]` in config.toml maps to a repo counts as that repo's, and an issue with a sub-task a person filed is left as it is.
|
||||
A label that `[label-repos]` in config.toml maps to a repo counts as that repo's.
|
||||
Where such an issue changes several repos, it files a sub-task per repo. Otherwise it gives the issue its label, as repo-rule.md says.
|
||||
An issue under which a person filed a sub-task is not planned: its sub-tasks run, each needs a label of its own, and you close the issue in Jira.
|
||||
Where the rule leaves the label unclear, it asks you on the terminal. Answer with the label, or with Enter alone to leave the issue waiting.
|
||||
It then puts the scored issues that do-epic itself filed in order of score, by the `Score = ...` line under the epic's ## Scoring.
|
||||
An open issue labelled `repo:<name>` or `do-epic-claude` runs as a chunk once no issue blocks it.
|
||||
@@ -400,7 +401,7 @@ def handed_on(key: str, epic: EpicRun) -> Stop:
|
||||
def split_items_closed(epic: EpicRun, issues: list[EpicIssue]) -> list[EpicIssue] | Stop:
|
||||
"""The issues, with each item split by repo whose sub-tasks are all done moved to done in the tracker and read as done; the stop where one cannot move. Its last sub-task to finish closes it, and one an earlier run left open closes with it."""
|
||||
for item in issues:
|
||||
if split.is_split(item, issues) and not item.done and split.finished(issues, item.key):
|
||||
if split.SPLIT_LABEL in item.labels and not item.done and split.finished(issues, item.key):
|
||||
moved = epic.store.finish_issue(item.key)
|
||||
if isinstance(moved, Failure):
|
||||
return Stop(1, f"the chunk finished, but its split item {item.key} could not move to done: {moved.reason}; once it is done in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
|
||||
|
||||
@@ -9,8 +9,8 @@ from do_epic.epic_record import CAP
|
||||
from chunk_driver.claims import CHUNK_FLAG, epic_chunks, HANDED, loop_chunks, project_lock, starting
|
||||
from do_epic.backend.protocol import EpicIssue
|
||||
from failure import Failure
|
||||
from do_epic.split import finished, is_split
|
||||
from do_epic.repo_pick import HumanTask, LabelRepos, Pick, recorded, Repo
|
||||
from do_epic.split import is_split
|
||||
from project_config.settings import PARALLEL_CHUNKS
|
||||
from do_epic.parked import parked_chunks
|
||||
from chunk_pr.approval import PARKS
|
||||
@@ -97,13 +97,17 @@ def held_up(issues: list[EpicIssue]) -> dict[str, list[str]]:
|
||||
|
||||
|
||||
def chunks(issues: list[EpicIssue], team: LabelRepos) -> tuple[list[Chunk], list[Waits]]:
|
||||
"""The open issues to work as chunks, in the tracker's rank order, and those that wait. A split item is worked through its sub-tasks, and what blocks it blocks them. team maps the team's own labels to repos."""
|
||||
"""The open issues to work as chunks, in the tracker's rank order, and those that wait. A split item is worked through its sub-tasks, and what blocks it blocks them."""
|
||||
by_key = {issue.key: issue for issue in issues}
|
||||
holding = held_up(issues)
|
||||
found: list[Chunk] = []
|
||||
waits: list[Waits] = []
|
||||
for issue in issues:
|
||||
if issue.done or is_split(issue, issues):
|
||||
if issue.done:
|
||||
continue
|
||||
if is_split(issue, issues):
|
||||
if all(task.done for task in issues if task.parent == issue.key) and not finished(issues, issue.key):
|
||||
waits.append(Waits(issue.key, "its sub-tasks are done; close it in Jira"))
|
||||
continue
|
||||
turn = turn_of(issue, recorded(issue, team), open_blockers(issue, by_key), by_key, issue.key in holding)
|
||||
if isinstance(turn, Chunk):
|
||||
@@ -118,7 +122,7 @@ def turn_of(issue: EpicIssue, pick: Pick | None | Failure, blocking: list[str],
|
||||
if isinstance(pick, Failure):
|
||||
return Waits(issue.key, pick.reason)
|
||||
if pick is None:
|
||||
return Waits(issue.key, "no label names its repo")
|
||||
return Waits(issue.key, "no label names its repo" + ("; label it in Jira, since do-epic plans no sub-task" if issue.parent in by_key else ""))
|
||||
if isinstance(pick, HumanTask):
|
||||
return Chunk(issue.key, None, human=True) if holds and not blocking else Waits(issue.key, "it is a human's task")
|
||||
if blocking:
|
||||
|
||||
@@ -60,7 +60,7 @@ class Split:
|
||||
|
||||
|
||||
def is_split(item: EpicIssue, issues: list[EpicIssue]) -> bool:
|
||||
"""Whether the item is worked through its sub-tasks: it is marked SPLIT_LABEL, or a person filed a sub-task under it. A sub-task do-epic filed doesn't count without the mark, since a run that failed between the two leaves the next run to file the lacking ones."""
|
||||
"""Whether the item is worked through its sub-tasks: it is marked SPLIT_LABEL, or a person filed a sub-task under it. A sub-task do-epic filed doesn't count without the mark: a run that failed after filing some of an item's sub-tasks, before marking it, leaves the next run to file the rest."""
|
||||
return SPLIT_LABEL in item.labels or any(task.parent == item.key and not task.by_loop for task in issues)
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool,
|
||||
have = {pick.name for task in read if task.parent == issue.key for label in task.labels if isinstance(pick := of_label(label, team), Repo)}
|
||||
repos = tuple(dict.fromkeys([*sorted(have), *(part.repo for part in predicted.parts)]))
|
||||
if len(repos) < 2:
|
||||
# Left as it is even where an earlier, failed run filed one sub-task and this prediction names only that repo. The stray sub-task is labelled for its repo and harmless.
|
||||
# Left unmarked even where an earlier, failed run filed one sub-task and this prediction names only that repo: the item changes one repo, so it gets its pick as any issue does.
|
||||
return Split((), ())
|
||||
if by_person and not predicted.comment:
|
||||
return Failure("the repo split gave no comment for the team on a person's issue")
|
||||
@@ -111,12 +111,12 @@ def task_summary(repo: str, summary: str) -> str:
|
||||
|
||||
|
||||
def finished(issues: list[EpicIssue], key: str) -> bool:
|
||||
"""Whether the item named key is done. A split item (is_split) that has sub-tasks is done once each of them is, whatever its own status; any other item is done by its own status, and a key no issue has isn't done."""
|
||||
"""Whether the item named key is done. An item marked SPLIT_LABEL that has sub-tasks is done once each of them is, whatever its own status. Any other item is done by its own status, also one a person's sub-tasks split: do-epic filed those for every repo the item changes, and a person's may cover only a part of it. A key no issue has isn't done."""
|
||||
item = next((issue for issue in issues if issue.key == key), None)
|
||||
tasks = [issue for issue in issues if issue.parent == key]
|
||||
if item is None:
|
||||
return False
|
||||
return all(task.done for task in tasks) if is_split(item, issues) and tasks else item.done
|
||||
return all(task.done for task in tasks) if SPLIT_LABEL in item.labels and tasks else item.done
|
||||
|
||||
|
||||
def prediction(issue: EpicIssue, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Prediction | Failure | Limited:
|
||||
|
||||
@@ -45,14 +45,15 @@ class ConfigTest(unittest.TestCase):
|
||||
self.assertEqual(dict(found.label_repos), {"twu-4": "tenant-web-ui-4", "core-4": "core-4"})
|
||||
|
||||
def test_names_each_entry_that_is_no_label_mapped_to_a_repo(self) -> None:
|
||||
self.write(SETTINGS + '[label-repos]\n"repo:api" = "api"\ndo-epic-human = "api"\nsplit-by-repo = "api"\ndo-epic-release-review = "api"\n"two words" = "api"\nweb = "../web"\ncore = 4\n')
|
||||
self.write(SETTINGS + '[label-repos]\n"repo:api" = "api"\ndo-epic-human = "api"\nsplit-by-repo = "api"\ndo-epic-release-review = "api"\n"two words" = "api"\nweb = "../web"\ncore = 4\nlanguage = "Swedish"\n')
|
||||
reason = self.failure()
|
||||
for fault in (
|
||||
"`label-repos` maps 'repo:api', a label do-epic gives a meaning of its own",
|
||||
"`label-repos` maps 'do-epic-human', a label do-epic gives a meaning of its own",
|
||||
"`label-repos` maps 'split-by-repo', a label do-epic gives a meaning of its own",
|
||||
"`label-repos` maps 'do-epic-release-review', a label do-epic gives a meaning of its own",
|
||||
"`label-repos` maps 'two words', which Jira takes as no label",
|
||||
"`label-repos` maps 'two words', which is no Jira label: a label holds no white space",
|
||||
"`language` stands below `[label-repos]`, so it is read as a label; move it above the table",
|
||||
"`label-repos` maps 'web' to '../web', not a repo's name in letters, digits, dots, hyphens and underscores",
|
||||
"`label-repos` maps 'core' to 4, not a repo's name",
|
||||
):
|
||||
|
||||
@@ -73,6 +73,17 @@ class WhichIssuesAreChunks(unittest.TestCase):
|
||||
task = dataclasses.replace(issue("ABC-23", "repo:api", parent="ABC-20"), by_loop=True)
|
||||
self.assertEqual(chunks([issue("ABC-20"), task], {}), ([Chunk("ABC-23", "api")], [Waits("ABC-20", "no label names its repo")]))
|
||||
|
||||
def test_an_item_a_person_split_waits_to_be_closed_once_its_sub_tasks_are_done_and_blocks_until_then(self) -> None:
|
||||
found = chunks([issue("ABC-20", "repo:api"), issue("ABC-23", parent="ABC-20", done=True), issue("ABC-21", "repo:api", blockers=("ABC-20",))], {})
|
||||
self.assertEqual(found, ([], [Waits("ABC-20", "its sub-tasks are done; close it in Jira"), Waits("ABC-21", "ABC-20 blocks it")]))
|
||||
|
||||
def test_an_item_marked_split_whose_sub_tasks_are_done_waits_for_nobody(self) -> None:
|
||||
self.assertEqual(chunks([issue("ABC-20", "split-by-repo"), issue("ABC-23", "repo:api", parent="ABC-20", done=True)], {}), ([], []))
|
||||
|
||||
def test_a_persons_sub_task_without_a_label_waits_for_one_and_says_do_epic_plans_none(self) -> None:
|
||||
found = chunks([issue("ABC-20", "repo:api"), issue("ABC-23", parent="ABC-20")], {})
|
||||
self.assertEqual(found, ([], [Waits("ABC-23", "no label names its repo; label it in Jira, since do-epic plans no sub-task")]))
|
||||
|
||||
def test_names_each_blocker_outside_the_epic(self) -> None:
|
||||
self.assertEqual(chunks([issue("ABC-20", "repo:api", blockers=("XYZ-1", "XYZ-2"))], {})[1], [
|
||||
Waits("ABC-20", "XYZ-1 and XYZ-2 block it; do-epic cannot see XYZ-1 and XYZ-2, outside the epic, finish: remove such a link in Jira once its issue is done"),
|
||||
@@ -89,7 +100,7 @@ class WhichIssuesAreChunks(unittest.TestCase):
|
||||
self.assertEqual(found, ([], [
|
||||
Waits("ABC-20", "no label names its repo"),
|
||||
Waits("ABC-21", "it is a human's task"),
|
||||
Waits("ABC-22", "ABC-22 is labelled with 2 picks: repo:api, repo:web; remove all but the right one"),
|
||||
Waits("ABC-22", "ABC-22 is labelled with 2 picks: repo:api, repo:web; remove the labels of all but the right one"),
|
||||
Waits("ABC-23", "ABC-20 and XYZ-1 block it; do-epic cannot see XYZ-1, outside the epic, finish: remove such a link in Jira once its issue is done"),
|
||||
]))
|
||||
|
||||
|
||||
@@ -207,8 +207,8 @@ class Finished(unittest.TestCase):
|
||||
self.assertEqual([finished(self.issues((own, ()), ()), "ABC-1") for own in (True, False)], [True, False])
|
||||
self.assertEqual(finished(self.issues((True, ()), ()), "ABC-9"), False)
|
||||
|
||||
def test_an_item_with_a_persons_sub_tasks_is_split_without_the_mark_and_done_once_they_are(self) -> None:
|
||||
self.assertEqual([finished(self.issues((False, ()), tasks), "ABC-1") for tasks in ((True, True), (True, False))], [True, False])
|
||||
def test_an_item_with_a_persons_sub_tasks_is_split_without_the_mark_and_done_only_by_its_own_status(self) -> None:
|
||||
self.assertEqual([finished(self.issues((done, ()), (True, True)), "ABC-1") for done in (False, True)], [False, True])
|
||||
self.assertTrue(is_split(*self.issues((False, ()), (False,))[:1], self.issues((False, ()), (False,))))
|
||||
|
||||
def test_an_item_whose_only_sub_tasks_do_epic_filed_is_not_split_until_marked(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user