diff --git a/CHANGELOG.md b/CHANGELOG.md index 0917fda6..f14ace06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- do-epic finishes an epic: once none of its issues is open, a finishing chunk files a release review of each repo the epic changed, as an issue labelled `do-epic-release-review`, and asks you to confirm each goal. `do-epic --close-epic` then posts the summary piped in as a comment on the epic and closes it in Jira, by the transition `jira-finish-transition` names, to the status `jira-finish-status` names. - do-epic parks a chunk whose pull request waits on its checks, an approval or a new review: the chunk frees its place for the next one, its tmux window says what it awaits, and its worker goes on when the gate opens or a reviewer comments, even after a reboot. `do-epic --status` prints what each open issue does. - A chunk that `do-epic` runs files a finding about an epic goal as an issue of the epic, with `do-epic --file`, and records a decision in the epic's description, with `--record-decision`; its judge reads the epic's Scoring and Decisions before the repo's records. - Added `do-epic `: it runs the chunks of one Jira epic, each in its own window of the tmux session `epic-`. As many run at once as the line `**Max parallel chunks:** 2` in the epic's description allows, one without it; a repo takes as many as its `parallel-chunks`, and none while loop-claude runs chunks in it. loop-claude in turn starts no chunk in a checkout where do-epic runs one. diff --git a/README.md b/README.md index cba7eaf1..f4c649e7 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `branch_chunks/` cuts a default branch into chunks and finds, for each, the items it shipped and the later chunks that fixed its code, for `score_outcomes` and `routing_figures`. It imports `reading_cost`'s record path. - `command_lines/` reads a shell command: its simple commands, and a docker call's subcommand and memory limits, for `command_patterns`, `reading_cost`, `routing_figures`, `rule_hook` and `run_heavy`. - `deploy_release` imports `release_plan`'s `release_standing`. -- `do_epic/` holds `do-epic`, the tool that drives one Jira epic. `main.py` starts the epic's chunks and runs one chunk's cycles in its window, through `agent_cycle`. `scheduler.py` says which issues run now: as many as the epic's cap and each repo's `parallel-chunks` allow, and none in a repo where loop-claude runs chunks. `gates.py` reads once whether a chunk's pull request waits on its checks, an approval or a new review, and `parked.py` keeps each chunk that does in a state file, so it takes no running slot while it waits and goes on waiting after a reboot. `chunk_prompt.py` words what a chunk's worker reads. Through `findings.py` that worker files a finding as an issue of the epic, with `--file`, and appends a decision to its description, with `--record-decision`. `config.py` reads its machine-wide settings, importing `project_config`'s settings and `model_routing`'s ladder file, and `epic_record.py` reads and writes an epic's description by section, language line and cap line, through `record_store`'s `EpicDescription`. `repos.py` finds a repo's checkout and project config by its name, and clones a missing checkout from the host and owner of the epic's other repos, through `forge`'s `url_beside`. `repo_pick.py` asks claude, by `repo-rule.md`, where an epic item is worked, and records the answer as a label on the issue. `split.py` has claude predict from the code which repos an item changes, and files a sub-task per repo under it where there are several. `ranking.py` orders an epic's items by score over one chain of goals, the epic's, then code health, then the item's repo's, through `plan`'s ranking, and re-ranks the tracker's backlog to that order through `backend/`. `backend/` reads, files and ranks the epic's issues, adds the labels `repo_pick.py` and `split.py` record, and posts comments. +- `do_epic/` holds `do-epic`, the tool that drives one Jira epic. `main.py` starts the epic's chunks and runs one chunk's cycles in its window, through `agent_cycle`. `scheduler.py` says which issues run now: as many as the epic's cap and each repo's `parallel-chunks` allow, and none in a repo where loop-claude runs chunks. `gates.py` reads once whether a chunk's pull request waits on its checks, an approval or a new review, and `parked.py` keeps each chunk that does in a state file, so it takes no running slot while it waits and goes on waiting after a reboot. `chunk_prompt.py` words what a chunk's worker reads. Through `findings.py` that worker files a finding as an issue of the epic, with `--file`, and appends a decision to its description, with `--record-decision`. `finish.py` ends an epic that holds no open issue: its finishing chunk files a release review of each repo the epic changed, has the human confirm each goal, and with `--close-epic` posts the summary on the epic and closes it. `config.py` reads its machine-wide settings, importing `project_config`'s settings and `model_routing`'s ladder file, and `epic_record.py` reads and writes an epic's description by section, language line and cap line, through `record_store`'s `EpicDescription`. `repos.py` finds a repo's checkout and project config by its name, and clones a missing checkout from the host and owner of the epic's other repos, through `forge`'s `url_beside`. `repo_pick.py` asks claude, by `repo-rule.md`, where an epic item is worked, and records the answer as a label on the issue. `split.py` has claude predict from the code which repos an item changes, and files a sub-task per repo under it where there are several. `ranking.py` orders an epic's items by score over one chain of goals, the epic's, then code health, then the item's repo's, through `plan`'s ranking, and re-ranks the tracker's backlog to that order through `backend/`. `backend/` reads, files and ranks the epic's issues, adds the labels `repo_pick.py` and `split.py` record, posts comments, and closes the epic. - `forge/` tells a GitHub origin from a Gitea one, names a repo beside an origin's and runs that forge's CLI (`commands.py`), and finds a pull request and reads its checks, once or until they settle (`pulls.py`), for `chunk_preflight`, `chunk_pr`, `deploy_release`, `do_epic` and `larv_review`. - `git_cli/` runs git for every tool (`git_repo.py`), and reads the git calls in a shell command (`git_command.py`). - `judge_replay` imports `agent_cycle`'s judge and verdicts, and `loop_claude`'s premises, records and `ANSWER_DESTINATIONS`. diff --git a/bin/do_epic/backend/contract.py b/bin/do_epic/backend/contract.py index 7101e63c..4b1c74b3 100644 --- a/bin/do_epic/backend/contract.py +++ b/bin/do_epic/backend/contract.py @@ -140,6 +140,14 @@ class EpicStoreContract: self.assertIsInstance(store.comment("ZZZ-1", "Hello."), Failure) self.assertEqual([self.comments_on(store, key) for key in (child, task)], [[], []]) + def test_closes_the_epic_once_its_summary_is_posted_and_refuses_a_blank_one(self) -> None: + store = self.new_store() + self.assertEqual(store.closed(), False) + self.assertIsInstance(store.close(" \n"), Failure) + self.assertEqual((store.closed(), self.comments_on(store, "ABC-12")), (False, [])) + self.assertEqual(store.close("## Shipped\n\nThe import.\n"), None) + self.assertEqual((store.closed(), self.comments_on(store, "ABC-12")), (True, ["## Shipped\n\nThe import."])) + 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.") diff --git a/bin/do_epic/backend/fake.py b/bin/do_epic/backend/fake.py index c6d766bb..ea404f51 100644 --- a/bin/do_epic/backend/fake.py +++ b/bin/do_epic/backend/fake.py @@ -7,11 +7,12 @@ 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 read, filing, label, comment and rank fails with it as the reason. comments holds each issue's comments, by key.""" + """An epic whose issues rank in the order filed, until one is ranked. Where fails is set, every read, filing, label, comment, rank and closing fails with it as the reason. comments holds each issue's comments, and the epic's, by key. done says whether the epic is closed.""" epic_key: str issues: list[EpicIssue] = dataclasses.field(default_factory=list) comments: dict[str, list[str]] = dataclasses.field(default_factory=dict) fails: str | None = None + done: bool = False def read(self) -> list[EpicIssue] | Failure: if self.fails: @@ -60,6 +61,18 @@ class MemoryEpic: self.comments.setdefault(key, []).append(text.strip()) return None + def closed(self) -> bool | Failure: + return Failure(self.fails) if self.fails else self.done + + def close(self, summary: str) -> None | Failure: + if self.fails: + return Failure(self.fails) + if refused := no_words(summary): + return refused + self.comments.setdefault(self.epic_key, []).append(summary.strip()) + self.done = True + return None + def change(self, key: str, **fields: object) -> None: """Changes the issue named key as a person would in the tracker, such as assignee="Ada Lovelace".""" self.issues = [dataclasses.replace(issue, **fields) if issue.key == key else issue for issue in self.issues] # type: ignore[arg-type] diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index 43813796..f9a6d1c3 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -5,8 +5,8 @@ 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, rank_refusal, scores, searched -from project_config.settings import Epic +from plan_store.jira_epic import blocked_by_links, FILED_BY, finishing_transition, ISSUE_KEY, ISSUE_TYPE, move_refusal, project_of, PROPERTY, rank_refusal, scores, searched +from project_config.settings import Epic, Finish, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION from do_epic.backend.protocol import EpicIssue, no_child, no_parent, no_words, unfit, unfit_label from failure import Failure @@ -25,12 +25,13 @@ class Found: @dataclasses.dataclass(frozen=True) class JiraEpic: - """The issues of a Jira epic, read and filed with the credentials env_file holds.""" + """The issues of a Jira epic, read and filed with the credentials env_file holds. finish says how the epic itself closes; None where the machine's settings don't say.""" epic: Epic env_file: pathlib.Path http: Http = jira_json to_markdown: ToMarkdown = adfs_to_markdown to_adf: ToAdf = markdown_to_adf + finish: Finish | None = None @property def epic_key(self) -> str: @@ -116,6 +117,40 @@ class JiraEpic: posted = self.http("POST", f"{self.epic.site}/rest/api/3/issue/{key}/comment", authorization, {"body": body}) return Failure(f"cannot comment on {key}: {posted.reason}") if isinstance(posted, Failure) else None + def closed(self) -> bool | Failure: + authorization = basic_auth(self.env_file) + if isinstance(authorization, Failure): + return authorization + answered = self.http("GET", f"{self.epic.site}/rest/api/3/issue/{self.epic_key}?fields=status", authorization, None) + if isinstance(answered, Failure): + return Failure(f"cannot read {self.epic_key}'s status: {answered.reason}") + try: + category = answered["fields"]["status"]["statusCategory"]["key"] # type: ignore[index] + except (KeyError, TypeError) as failure: + return Failure(f"{self.epic_key}'s status is not in the shape Jira Cloud's REST API version 3 documents: {failure!r}") + return bool(category == "done") + + def close(self, summary: str) -> None | Failure: + if self.finish is None: + return Failure(f"do-epic's settings name no transition to close an epic by: set `{JIRA_FINISH_TRANSITION}` and `{JIRA_FINISH_STATUS}` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\"") + authorization = basic_auth(self.env_file) + if isinstance(authorization, Failure): + return authorization + if refused := no_words(summary): + return refused + body = self.to_adf(summary) + if isinstance(body, Failure): + return Failure(f"cannot convert the summary to a Jira comment: {body.reason}") + # The transition is read before the comment is posted, so an epic that cannot move gets no summary. + transition = finishing_transition(self.epic.site, self.epic_key, self.finish, authorization, self.http) + if isinstance(transition, Failure): + return transition + posted = self.http("POST", f"{self.epic.site}/rest/api/3/issue/{self.epic_key}/comment", authorization, {"body": body}) + if isinstance(posted, Failure): + return Failure(f"cannot comment on {self.epic_key}: {posted.reason}") + refused_move = move_refusal(self.epic.site, self.epic_key, transition, self.finish, authorization, self.http) + return Failure(f"posted the summary on {self.epic_key}, but {refused_move}; close the epic in Jira rather than posting the summary again") if refused_move else None + def not_a_parent(self, parent: str, authorization: str) -> Failure | None: """Why nothing can be filed under parent; None where it is the epic or one of its child issues.""" if parent == self.epic_key: diff --git a/bin/do_epic/backend/protocol.py b/bin/do_epic/backend/protocol.py index b48b314c..94b4e7bc 100644 --- a/bin/do_epic/backend/protocol.py +++ b/bin/do_epic/backend/protocol.py @@ -64,6 +64,13 @@ class EpicStore(typing.Protocol): """Posts text, markdown, as a comment on the epic's child issue named key, for the people who work the epic to read. A sub-task, an issue outside the epic, or an empty or blank text is refused.""" + def closed(self) -> bool | Failure: + """Whether the epic itself is in a status the tracker counts as done.""" + + def close(self, summary: str) -> None | Failure: + """Posts summary, markdown, as a comment on the epic, then moves the epic to a status the tracker counts as done. Before anything is posted, it refuses a blank summary, and an epic the tracker cannot move to such a status. Where the move fails after the comment is posted, the Failure says so.""" + + def unfit(summary: str, labels: tuple[str, ...]) -> Failure | None: """Why no tracker can file an issue with this summary and these labels; None where a tracker can file it.""" if not summary.strip() or "\n" in summary: diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 3d3c7cac..af2db03d 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -9,7 +9,7 @@ import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2])) -from project_config.settings import Epic +from project_config.settings import Epic, Finish from do_epic.backend.contract import EpicStoreContract from failure import Failure from plan_store import jira_epic @@ -25,6 +25,10 @@ SEARCH = f"{SITE}/rest/api/3/search/jql" ISSUES = f"{SITE}/rest/api/3/issue" RANK = f"{SITE}/rest/agile/1.0/issue/rank" TO_DO = {"name": "To Do", "statusCategory": {"key": "new"}} +DONE = {"name": "Done", "statusCategory": {"key": "done"}} +TRANSITIONS = f"{ISSUES}/ABC-12/transitions" +EPIC_COMMENT = f"{ISSUES}/ABC-12/comment" +EPIC_STATUS = f"{ISSUES}/ABC-12?fields=status" TYPES = {"issueTypes": [{"id": "10001", "name": "Task", "subtask": False}, {"id": "10003", "name": "Subtask", "subtask": True}]} @@ -44,6 +48,8 @@ class FakeJira: answers: dict[tuple[str, str], object] = dataclasses.field(default_factory=dict) calls: list[tuple[str, str]] = dataclasses.field(default_factory=list) comments: dict[str, list[object]] = dataclasses.field(default_factory=dict) + # The epic's own status, which the transition "Mark as done" moves to DONE. + epic_status: dict[str, object] = dataclasses.field(default_factory=lambda: dict(TO_DO)) def __call__(self, method: str, url: str, authorization: str, body: object) -> object: self.calls.append((method, url)) @@ -53,6 +59,18 @@ class FakeJira: return self.answers[method, url] if method == "GET" and url == EPIC_URL: return {"key": "ABC-12"} + if method == "GET" and url == EPIC_STATUS: + return {"key": "ABC-12", "fields": {"status": self.epic_status}} + if method == "GET" and url == TRANSITIONS: + return {"transitions": [] if self.epic_status == DONE else [{"id": "31", "name": "Mark as done", "to": DONE}, {"id": "21", "name": "Start", "to": {"name": "In Progress", "statusCategory": {"key": "indeterminate"}}}]} + if method == "POST" and url == TRANSITIONS: + assert body == {"transition": {"id": "31"}}, body + self.epic_status = DONE + return None + if method == "POST" and url == EPIC_COMMENT: + assert isinstance(body, dict) + self.comments.setdefault("ABC-12", []).append(body["body"]) + return {"id": "1"} if method == "GET" and url == ISSUE_TYPES: return TYPES if method == "POST" and url == SEARCH: @@ -127,7 +145,7 @@ class Case(unittest.TestCase): self.jira = FakeJira() def new_store(self) -> JiraEpic: - return JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf) + return JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Mark as done", "Done")) class JiraEpicContract(Case, EpicStoreContract): @@ -153,6 +171,41 @@ class JiraEpicContract(Case, EpicStoreContract): class Jira(Case): + def test_closes_the_epic_by_the_transition_the_settings_name_after_the_summary(self) -> None: + self.assertEqual(self.new_store().close("Shipped."), None) + self.assertEqual(self.jira.calls[-3:], [("GET", TRANSITIONS), ("POST", EPIC_COMMENT), ("POST", TRANSITIONS)]) + + def test_posts_no_summary_on_an_epic_it_cannot_close(self) -> None: + unnamed = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf) + wrong_status = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Start", "Done")) + no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done")) + unconverted = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, lambda markdown: Failure("adf-codec refused it"), Finish("Mark as done", "Done")) + for store, reason in ( + (unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""), + (wrong_status, "ABC-12's transition 'Start' leads to the status 'In Progress', not to 'Done', which `jira-finish-status` names"), + (unconverted, "cannot convert the summary to a Jira comment: adf-codec refused it"), + ): + self.assertEqual(store.close("Shipped."), Failure(reason)) + refused = no_such.close("Shipped.") + assert isinstance(refused, Failure) + self.assertIn("ABC-12 has no transition 'Close' from its status", refused.reason) + self.jira.answers[("GET", TRANSITIONS)] = Failure("Jira answered 503") + self.assertEqual(self.new_store().close("Shipped."), Failure("cannot read ABC-12's transitions: Jira answered 503")) + self.assertEqual((self.jira.comments, self.jira.epic_status), ({}, TO_DO)) + + def test_says_what_was_posted_where_the_comment_or_the_move_fails(self) -> None: + self.jira.answers[("POST", EPIC_COMMENT)] = Failure("Jira answered 503") + self.assertEqual(self.new_store().close("Shipped."), Failure("cannot comment on ABC-12: Jira answered 503")) + self.assertEqual(self.jira.epic_status, TO_DO) + del self.jira.answers[("POST", EPIC_COMMENT)] + self.jira.answers[("POST", TRANSITIONS)] = Failure("Jira answered 503") + self.assertEqual(self.new_store().close("Shipped."), Failure("posted the summary on ABC-12, but cannot move ABC-12 by 'Mark as done': Jira answered 503; close the epic in Jira rather than posting the summary again")) + + def test_says_why_the_epics_status_cannot_be_read(self) -> None: + for answer, reason in ((Failure("Jira answered 503"), "cannot read ABC-12's status: Jira answered 503"), ({"fields": {}}, "ABC-12's status is not in the shape Jira Cloud's REST API version 3 documents: KeyError('status')"), (["ABC-12"], "ABC-12's status is not in the shape Jira Cloud's REST API version 3 documents: TypeError('list indices must be integers or slices, not str')")): + self.jira.answers[("GET", EPIC_STATUS)] = answer + self.assertEqual(self.new_store().closed(), Failure(reason)) + def test_reads_the_sub_tasks_of_more_children_than_one_search_names(self) -> None: store = self.new_store() children = [store.file("ABC-12", f"Item {n}.", "", ()) for n in range(60)] diff --git a/bin/do_epic/chunk_prompt.py b/bin/do_epic/chunk_prompt.py index f4d22fa4..2d1f08fa 100644 --- a/bin/do_epic/chunk_prompt.py +++ b/bin/do_epic/chunk_prompt.py @@ -1,4 +1,4 @@ -"""What a do-epic cycle's worker is told: its task, from the issue, and its first prompt. The resumed prompt and the rung sentences are the ones loop-claude's cycles use, naming do-epic; a chunk that was parked is first told why it resumes.""" +"""What a do-epic cycle's worker is told: its task, from the issue, and its first prompt. The resumed prompt and the rung sentences are the ones loop-claude's cycles use, naming do-epic; a chunk that was parked is first told why it resumes, and one whose task follows the epic's state is told that task as it resumes.""" import dataclasses from do_epic.backend.protocol import EpicIssue @@ -48,3 +48,8 @@ def unparked(news: str) -> WorkerPrompts: """The prompts of the first cycle after a parked chunk resumes: WORKER's, with each prompt that starts a worker opening with news, which says what the chunk waited on and what changed. The fresh prompt opens with it too, since a chunk the judge ruled finished before it parked has no session left to resume.""" opening = f"{news} {FEEDBACK}\n\n" return dataclasses.replace(WORKER, fresh=lambda *task: opening + WORKER.fresh(*task), resumed=lambda *evidence: opening + WORKER.resumed(*evidence)) + + +def restating(task: str) -> WorkerPrompts: + """WORKER for a chunk whose task follows the epic's state, as its finishing's does: the prompt that resumes its worker states task, which may not be the one its session began with.""" + return dataclasses.replace(WORKER, resumed=lambda *evidence: f"{WORKER.resumed(*evidence)}\n\nThe task follows the epic's state, so it may have changed since you began. It is now:\n\n{task}") diff --git a/bin/do_epic/config.py b/bin/do_epic/config.py index 81da5cff..f3852832 100644 --- a/bin/do_epic/config.py +++ b/bin/do_epic/config.py @@ -13,13 +13,15 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d - `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 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 closes no epic. - `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 -from project_config.settings import anywhere, CONFIG, DO_EPIC, ENV_FILE, LANGUAGE, language_fault, lies_in, parsed, PROJECTS, SITE +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 failure import Failure +from text_files.markdown_text import listed from model_routing.ladder_file import read_ladder, SHIPPED REPO_RULE = "repo-rule.md" @@ -28,8 +30,8 @@ JIRA_URL = "jira-url" REPOLESS_MODEL = "repoless-model" CLONE_FOLDER = "clone-folder" SETTINGS = (JIRA_URL, ENV_FILE, REPOLESS_MODEL) -OPTIONAL = (CLONE_FOLDER, LANGUAGE) -LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {' and '.join(OPTIONAL)}." +OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH) +LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTIONAL, 'and')}." @dataclasses.dataclass(frozen=True) @@ -42,6 +44,8 @@ class DoEpicConfig: language: str repoless_model: str repo_rule: str + # How a finished epic closes; None where the config doesn't say. + finish: Finish | None = None def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure: @@ -73,10 +77,11 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi *([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of ~/{PROJECTS} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []), *([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), *([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) + return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values)) diff --git a/bin/do_epic/findings.py b/bin/do_epic/findings.py index 9985adc9..92336512 100644 --- a/bin/do_epic/findings.py +++ b/bin/do_epic/findings.py @@ -6,10 +6,11 @@ import fcntl import pathlib import typing -from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, of_label, REPO_PREFIX +from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, of_label, REPO_PREFIX, REVIEW_LABEL from do_epic.epic_record import EpicRecord from do_epic.backend.protocol import EpicStore from failure import Failure +from text_files.markdown_text import listed from text_files.piped_text import piped # Three readers, seated as the human and as a chunk's worker, picked each spelling from four: ` --file` over `--file `, `add` and `--finding`, and `--record-decision` over `--decision` and `--decide`. @@ -20,10 +21,11 @@ RECORD_DECISION = "--record-decision" LABELS = f"`{REPO_PREFIX}` for the repo that works it, `{CLAUDE_LABEL}` for work of Claude's that changes no repo, or `{HUMAN_LABEL}` for a task of the human's" # Under the epic's folder, the file a do-epic holds locked while it appends a decision. DECISIONS_LOCK = "decisions.lock" -USAGE = f"""do-epic {FILE} [{LABEL}