Read a team's own repo labels as do-epic's picks, and treat an item a person filed sub-tasks under as split
CI / tests (pull_request) Has been cancelled

This commit is contained in:
Lilleman
2026-11-19 15:33:51 +01:00
parent 017cf33611
commit 95535b4fb3
20 changed files with 278 additions and 119 deletions
+27 -2
View File
@@ -8,18 +8,26 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
clone-folder = "~/code"
language = "Swedish"
[label-repos]
twu-4 = "tenant-web-ui-4"
- `jira-url` is the Jira site's address: https, a host, and no path.
- `env-file` is the file of Jira credentials: a path that starts with / or ~/, outside every folder of `~/.claude-projects` and outside the clone folder, which hold git checkouts. `~/.claude-projects/<key>.env` is fine.
- `repoless-model` is the model that works an epic item with no repo: a model on the routing ladder, `model_routing/routing-ladder.json`.
- `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.
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
import dataclasses
import pathlib
import re
import types
from project_config.settings import anywhere, CONFIG, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINISH, LANGUAGE, language_fault, lies_in, parsed, PROJECTS, SITE
from do_epic.backend.protocol import LABEL
from do_epic.repo_pick import of_label, REPO_NAME, LabelRepos, REVIEW_LABEL
from do_epic.split import SPLIT_LABEL
from failure import Failure
from text_files.markdown_text import listed
from model_routing.ladder_file import read_ladder, SHIPPED
@@ -30,7 +38,8 @@ JIRA_URL = "jira-url"
REPOLESS_MODEL = "repoless-model"
CLONE_FOLDER = "clone-folder"
SETTINGS = (JIRA_URL, ENV_FILE, REPOLESS_MODEL)
OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH)
LABEL_REPOS = "label-repos"
OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH, LABEL_REPOS)
LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTIONAL, 'and')}."
@@ -46,6 +55,19 @@ 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.
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."""
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_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))),
]
def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
@@ -78,10 +100,13 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
*([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []),
*([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []),
*finish_faults(values),
*label_repo_faults(values.get(LABEL_REPOS, {})),
*([rule.reason] if isinstance(rule, Failure) else [f"`{REPO_RULE}` is blank"] if not rule.strip() else []),
]
if faults:
return Failure(f"{folder}: {'; '.join(faults)}. {LISTED}")
# Without a fault, each value above is present and of the type asserted here.
assert clone_folder and env_file and isinstance(url, str) and isinstance(model, str) and isinstance(language, str) and isinstance(rule, str)
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values))
labels = values.get(LABEL_REPOS, {})
assert isinstance(labels, dict)
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values), types.MappingProxyType(labels))