From 382ac99c4184b04b96de7be420ae85ef32fcb026 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 23:52:15 +0100 Subject: [PATCH 01/11] Re-score item 415 at L 4 and S 6 after reading the code --- docs/reading-cost.md | 17 +++++++++++++++++ todo.md | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 2438e973..18b6b9c3 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -2910,3 +2910,20 @@ Read most (opens and searches): - `docs/decisions.md` 2 - `bin/agent_cycle/tmux.py` 1 - `bin/loop-claude` 1 + +## Reading cost, chunk 43ac6d329242, finished 2026-11-18T22:50:16Z + +104341 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/agent_cycle/judge.py` 3 +- `rules/todo-items.md` 3 +- `bin/do_epic/main.py` 2 +- `bin/loop_claude/cycle/prompts.py` 2 +- `bin/agent_cycle/run.py` 1 +- `bin/agent_cycle/worker_prompts.py` 1 +- `bin/do_epic/chunk_prompt.py` 1 +- `bin/do_epic/epic_record.py` 1 +- `bin/loop_claude/project/premises.py` 1 +- `bin/loop_claude/project/records.py` 1 diff --git a/todo.md b/todo.md index 647fd824..dd54de6e 100644 --- a/todo.md +++ b/todo.md @@ -14,7 +14,7 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 441 | 0.12.0 | | | **Move an epic's issue to done in Jira when its chunk finishes, so no finished chunk starts again and what it blocks starts.** | 2 | 2 | 2 | 4 | 3 | 1 by 6 | 2.3 | | 416 | 0.12.0 | | | **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 | -| 415 | 0.12.0 | | | **Finish an epic: run release-review passes on each repo it changed, work what they file, have the human confirm each goal, post a summary comment, and close the epic in Jira last.** | 3 | 2 | 3 | 6 | 5 | 1 by 5 | 1.2 | +| 415 | 0.12.0 | | | **Finish an epic: run release-review passes on each repo it changed, work what they file, have the human confirm each goal, post a summary comment, and close the epic in Jira last.** | 4 | 2 | 3 | 7 | 6 | 1 by 5 | 0.8 | | 418 | 0.12.0 | 415 | | **Describe do-epic in `README.md`'s tools and setup, with its machine settings and `repo-rule.md`.** | 1 | 2 | 1 | 2 | 2 | 1 by 5 | 2.1 | | 420 | 0.12.0 | | | **End a worker that printed its final result and lingers, by killing the background shells it left, after a few minutes, and print each kill with its evidence on loop-claude's terminal.** | 2 | 2 | 2 | 4 | 3 | 1.5 by 6 | 2.0 | | 411 | 0.12.0 | | | **Park a chunk whose PR waits on a long gate, keeping its worktree, PR and session in a state file that survives a reboot, and resume its session when the gate passes or a reviewer comments.** | 3 | 2 | 3 | 6 | 5 | 1 by 5 | 1.2 | -- 2.52.0 From fdb942472d0cdfe3758c32f052ddca77bf0364ee Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 23:59:53 +0100 Subject: [PATCH 02/11] Finish an epic: a finishing chunk files each repo's release review, has the human confirm each goal, and closes the epic with its summary --- README.md | 2 +- bin/do_epic/backend/contract.py | 8 + bin/do_epic/backend/fake.py | 15 +- bin/do_epic/backend/jira.py | 41 ++++- bin/do_epic/backend/protocol.py | 7 + bin/do_epic/backend/test_jira.py | 57 ++++++- bin/do_epic/config.py | 15 +- bin/do_epic/findings.py | 29 ++-- bin/do_epic/finish.py | 88 +++++++++++ bin/do_epic/main.py | 71 ++++++--- bin/do_epic/repo_pick.py | 2 + bin/do_epic/scheduler.py | 14 +- bin/do_epic/test_do_epic.py | 9 ++ bin/do_epic/test_findings.py | 7 + bin/do_epic/test_finish.py | 174 ++++++++++++++++++++++ bin/do_epic/test_main.py | 2 +- bin/do_epic/test_scheduler.py | 4 +- bin/plan_store/jira_epic.py | 24 ++- bin/release_plan/release_standing.py | 4 +- bin/release_plan/test_release_standing.py | 4 + 20 files changed, 514 insertions(+), 63 deletions(-) create mode 100644 bin/do_epic/finish.py create mode 100644 bin/do_epic/test_finish.py diff --git a/README.md b/README.md index d0205e4c..89c8ed21 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. Beside it, `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. Beside it, `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 waits for its checks (`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..3cfdaa31 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}`, as config.py's docstring shows") + 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}") + # Read before the comment is posted, so that an epic that cannot move gets no summary, and a second try posts no second one. + 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..ab50bdba 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. A blank summary is refused, and so is an epic the tracker cannot move so, before anything is posted. 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..9253a4b4 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`, as config.py's docstring shows"), + (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/config.py b/bin/do_epic/config.py index 81da5cff..53b77fbb 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` say how a finished epic closes, as a project's config says it of a plan item: the name of the workflow transition, such as "Mark as done", and of the status it leads to, such as "Done". 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, JIRA_FINISH, LANGUAGE, language_fault, lies_in, name_of, 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,13 @@ 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 []), + *(f"`{name}` is {values[name]!r}, not the name Jira shows, such as \"{example}\"" for name, example in zip(JIRA_FINISH, ("Mark as done", "Done")) if name in values and not name_of(values[name])), + *(f"`{name}` is set, so `{other}` must be too" for name, other in (JIRA_FINISH, JIRA_FINISH[::-1]) if name in values and other not in 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) + finish = [name for setting in JIRA_FINISH if (name := name_of(values.get(setting)))] + return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, Finish(*finish) if len(finish) == 2 else None) diff --git a/bin/do_epic/findings.py b/bin/do_epic/findings.py index 9985adc9..d2eefb9d 100644 --- a/bin/do_epic/findings.py +++ b/bin/do_epic/findings.py @@ -6,7 +6,7 @@ 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 @@ -20,7 +20,7 @@ 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}