Answer stability round 1: 0 🔴, 6 🟡 (0 misread); share the finish settings' checks with the project config, and test the finishing chunk's language, unread issues, cap, lock and backend

This commit is contained in:
2026-11-19 00:44:07 +01:00
parent 9b47b76f52
commit d99345fb8a
14 changed files with 106 additions and 29 deletions
+2 -2
View File
@@ -132,7 +132,7 @@ class JiraEpic:
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")
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
@@ -141,7 +141,7 @@ class JiraEpic:
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.
# 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
+1 -1
View File
@@ -68,7 +68,7 @@ class EpicStore(typing.Protocol):
"""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."""
"""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:
+1 -1
View File
@@ -181,7 +181,7 @@ class Jira(Case):
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"),
(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"),
):
+7
View File
@@ -1,4 +1,6 @@
"""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."""
import dataclasses
from do_epic.backend.protocol import EpicIssue
from do_epic import findings
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
@@ -36,3 +38,8 @@ NAMES = prompts.RecordNames(
records_named="the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project",
)
WORKER = prompts.worker_prompts(DRIVER, fresh, "", NAMES)
def restating(task: str) -> prompts.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, route, project: f"{WORKER.resumed(evidence, route, project)}\n\nThe task follows the epic's state, so it may have changed since you began. It is now:\n\n{task}")
+4 -6
View File
@@ -13,13 +13,13 @@ 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.
- `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, Finish, JIRA_FINISH, LANGUAGE, language_fault, lies_in, name_of, 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
@@ -77,13 +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 []),
*(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),
*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)
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)
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values))
+4
View File
@@ -10,6 +10,7 @@ from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, of_label, REPO_PREFIX,
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: `<EPIC-KEY> --file` over `--file <EPIC-KEY>`, `add` and `--finding`, and `--record-decision` over `--decision` and `--decide`.
@@ -24,6 +25,7 @@ USAGE = f"""do-epic <EPIC-KEY> {FILE} <summary> [{LABEL} <label>]... [<<'EOF' de
do-epic <EPIC-KEY> {RECORD_DECISION} <title> <<'EOF' entry EOF"""
HELP = f"""{FILE} files a finding about one of the epic's goals as an open issue of the epic, with the markdown piped in as its description.
{LABEL} is {LABELS}; without one the issue waits until someone labels it.
A second {LABEL}, `{REVIEW_LABEL}`, marks the issue as a repo's release review, which the epic's finishing files.
A finding about a repo's own goals goes into that repo's plan instead.
{RECORD_DECISION} appends a decision that governs the epic to its description's ## Decisions, under the title, with the markdown piped in as its text."""
@@ -72,6 +74,8 @@ def written(epic: str, flag: str, value: str, labels: tuple[str, ...], store: Ep
if flag == FILE:
if unread := [label for label in labels if of_label(label) is None and label != REVIEW_LABEL]:
return Failure(f"cannot file the finding in the epic {epic}: do-epic doesn't read the label {unread[0]!r}; write {LABELS}")
if len(picks := [label for label in labels if of_label(label)]) > 1:
return Failure(f"cannot file the finding in the epic {epic}: {listed(picks, 'and')} each say who works it; write one of them")
key = store.file(epic, value, text, labels)
if isinstance(key, Failure):
return Failure(f"cannot file the finding in the epic {epic}: {key.reason}")
+8 -4
View File
@@ -2,7 +2,7 @@
Once the epic holds issues and none is open, its finishing chunk runs, in a window named for the epic's key. It has no issue: `task` is its task, which follows the epic's state.
1. While a repo the epic changed lacks a release review, the chunk files one issue per such repo, labelled REVIEW_LABEL, and ends. Each runs as any issue's chunk does, and so do the issues it files.
1. While a repo the epic changed lacks a release review, the chunk files one issue per such repo, labelled REVIEW_LABEL, and ends. Each such issue runs as any issue's chunk does, and so does each issue its review files.
2. With each repo reviewed, the human confirms each goal. For a goal they don't confirm, the chunk files the set of items they approve, and ends.
3. With every goal confirmed, `do-epic <EPIC-KEY> --close-epic` posts the summary on the epic and closes it.
@@ -19,7 +19,7 @@ from text_files.markdown_text import listed
from text_files.piped_text import piped
from do_epic.repo_pick import recorded, Repo, REPO_PREFIX, REVIEW_LABEL
# Three readers, seated as the human, as a chunk's worker and as one of the client's team, picked it from four, 2-1 over `--close`, which reads as closing the run or one issue.
# Not `--close`, which reads as closing the run or one issue: three readers, seated as the human, as a chunk's worker and as one of the client's team, picked this one from four, 2-1 over it.
CLOSE = "--close-epic"
USAGE = f"do-epic <EPIC-KEY> {CLOSE} <<'EOF' summary EOF"
HELP = f"""Once every issue is done, the epic's finishing chunk runs, in a window named for the epic.
@@ -58,13 +58,13 @@ def task(epic: str, issues: list[EpicIssue], launcher: pathlib.Path, language: s
return (
f"{opening} Each repo the epic changed takes a release review first, and {listed(lacking, 'and')} {'has' if len(lacking) == 1 else 'have'} none. "
f"File one issue per such repo, with `{launcher} {epic} {findings.FILE} \"<summary>\" {findings.LABEL} {REPO_PREFIX}<name> {findings.LABEL} {REVIEW_LABEL}` and its detail on stdin, both in {language}, the epic's language. "
f"The detail asks for the release review of `~/.claude/skills/larv-review/SKILL.md` → \"Release review\" over the whole repo, as the epic's issues left it, with the epic's key in place of the release: its first commit is empty and titled `Release review of {epic}`. "
f"The detail asks for a release review of the whole repo, as the epic's issues left it: the one `~/.claude/skills/larv-review/SKILL.md` → \"Release review\" describes. The epic's key stands in place of the release there, so the review's branch opens with an empty commit titled `Release review of {epic}`. "
"Where filing fails and says the issue may exist, ask the human to look before you file it again. "
f"The chunk is finished once each issue is filed: {DRIVER} works them, and starts this chunk again once the epic holds no open issue."
)
return (
f"{opening} Each repo it changed has had its release review. Three steps remain, in this order.\n\n"
"1. Ask the human to confirm each goal under the description's ## Goals, one goal per question, each with the evidence of what shipped: that an achieve goal is achieved, and that no defect stands against a maintain goal. "
"1. Ask the human to confirm each goal under the description's ## Goals: that an achieve goal is achieved, and that no defect stands against a maintain goal. Ask one goal per question, each with the evidence of what shipped. "
"A goal is met only where the human confirms it: never take one as met from the evidence alone. Don't ask again about a goal a decision in the description records as confirmed.\n"
"2. For a goal the human doesn't confirm, propose a set of items that would meet it, and ask the human to approve the set. File each item they approve. "
f"Then the chunk is finished: {DRIVER} works the items, and starts this chunk again once the epic holds no open issue.\n"
@@ -77,9 +77,13 @@ def task(epic: str, issues: list[EpicIssue], launcher: pathlib.Path, language: s
def closed(epic: str, store: EpicStore, stdin: typing.TextIO) -> str | Failure:
"""Posts the summary piped in on the epic with the key epic and closes it, and answers the line to print; a Failure, with nothing posted, while the epic isn't ready to close."""
# Whether the human confirmed each goal isn't checked here: a decision that records it is the worker's own text, so only the task and the judge, who reads the human's answers, can hold the worker to it.
issues = store.read()
if isinstance(issues, Failure):
return Failure(f"cannot close the epic {epic}: {issues.reason}")
already = store.closed()
if already:
return Failure(f"cannot close the epic {epic}: {already.reason if isinstance(already, Failure) else 'it is closed already, so its summary is posted'}")
if waiting := still_open(issues):
return Failure(f"cannot close the epic {epic}: {listed(waiting, 'and')} {'is' if len(waiting) == 1 else 'are'} open")
if lacking := unreviewed(issues):
+3 -3
View File
@@ -285,11 +285,11 @@ def next_cycle(loop_run: LoopRun, loop: Loop, in_repo: bool, epic: EpicRun) -> C
project = ladder.project_rung(models.worker)
route = routed(loop_run.route, project, models.worker, lambda: archived_route(archive_folder, loop), lambda: routing)
say(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", epic.effects, stdout=True)
return Cycle(config=setup_version(epic.paths.claude_dir, epic.effects.git), effects=epic.effects, facts="", judge=judge_rung(ladder, models.judge), premises=premises, project=project, project_archive=archive_folder, records=records, root=loop.root, route=route, session=loop.session, task=task, prompts=chunk_prompt.WORKER, taken_in=lambda entries: TakenIn(), unfinished_evidence=loop_run.unfinished_evidence, window=loop.window)
return Cycle(config=setup_version(epic.paths.claude_dir, epic.effects.git), effects=epic.effects, facts="", judge=judge_rung(ladder, models.judge), premises=premises, project=project, project_archive=archive_folder, records=records, root=loop.root, route=route, session=loop.session, task=task, prompts=chunk_prompt.restating(task) if loop_run.chunk == epic.key else chunk_prompt.WORKER, taken_in=lambda entries: TakenIn(), unfinished_evidence=loop_run.unfinished_evidence, window=loop.window)
def chunk_work(key: str, checkout: str | None, language: str, epic: EpicRun) -> tuple[str, RoutingIssue | None] | Stop:
"""The task of the chunk called key, and the issue that routes it, None where none has scores: both from the epic's issues, read afresh. The epic's finishing has no issue, and it ends here once the epic holds an open issue again, since working that issue comes first."""
"""The task of the chunk called key, and the issue that routes it, or None where that issue has no scores: both from the epic's issues, read afresh. The epic's finishing has no issue, and it ends here once the epic holds an open issue again, since working that issue comes first."""
if key != epic.key:
issue = issue_read(key, epic)
if isinstance(issue, Stop):
@@ -299,7 +299,7 @@ def chunk_work(key: str, checkout: str | None, language: str, epic: EpicRun) ->
if isinstance(issues, Failure):
return Stop(1, issues.reason)
if not finish.due(issues):
say(f"the epic {epic.key} holds an open issue again, so its finishing waits", epic.effects, stdout=True)
say(f"the epic {epic.key} holds an open issue again, so its finishing chunk ends until none is open", epic.effects, stdout=True)
return handed_on(key, epic)
return finish.task(epic.key, issues, epic.launcher, language), None
+1 -1
View File
@@ -15,7 +15,7 @@ from claude_code.entries import structured_output
REPO_PREFIX = "repo:"
CLAUDE_LABEL = "do-epic-claude"
HUMAN_LABEL = "do-epic-human"
# Marks the issue that asks for a repo's release review, beside the label that names the repo (finish.py). Three readers, seated as the human, as a chunk's worker and as one of the client's team, picked it 3-0 from four: `release-review` could pass for the team's own release process.
# Marks the issue that asks for a repo's release review, beside the label that names the repo (finish.py). Not `release-review`, which could pass for the team's own release process: three readers, seated as the human, as a chunk's worker and as one of the client's team, picked this one 3-0 from four.
REVIEW_LABEL = "do-epic-release-review"
# A repo's name is a folder name and part of a clone address, so claude's answer or a label a person typed must not hold a slash, a colon or a leading dot.
REPO_NAME = re.compile(r"\w[\w.-]*")
+2 -2
View File
@@ -109,7 +109,7 @@ def refusal(repo: str, room: RepoRoom) -> str | None:
def start_chunks(epic: Epic, issues: list[EpicIssue], finishing: bool, own: str | None, run: tmux.Tmux) -> Started | Failure:
"""Starts a do-epic in a new window for each of the epic's chunks that may start now. Where finishing is set, no issue is open, and the chunk is the epic's finishing (finish.py), in a window named for the epic's key. own is the issue of the chunk that asks, which has finished: it counts as running nowhere, and no stopped chunk starts again. Where own is None, the human's `do-epic <EPIC-KEY>` asks, and each stopped chunk starts again. A Failure says why a window could not start; those before it run."""
"""Starts a do-epic in a new window for each of the epic's chunks that may start now. Where finishing is set, no issue is open, and the one chunk to start is the epic's finishing (finish.py), in a window named for the epic's key. own is the key of the chunk that asks, which has finished: it counts as running nowhere, and no stopped chunk starts again. Where own is None, the human's `do-epic <EPIC-KEY>` asks, and each stopped chunk starts again. A Failure says why a window could not start; those before it run."""
session = tmux.session_name(tmux.EPIC, epic.key)
found, waits = chunks(issues)
if finishing:
@@ -138,7 +138,7 @@ def start_chunks(epic: Epic, issues: list[EpicIssue], finishing: bool, own: str
started.append(chunk.issue)
except OSError as failure:
return Failure(f"cannot lock {failure.filename or epic.folder / LOCK}: {failure.strerror}")
# The epic's finishing is no issue, and waits last.
# The epic's finishing is no issue: its wait is listed after every issue's.
order = [*(issue.key for issue in issues), epic.key]
return Started(started, sorted(waits, key=lambda wait: order.index(wait.issue)))
+6 -1
View File
@@ -83,7 +83,7 @@ class FilingAFinding(FindingsTest):
filed = self.store.issues[-1]
self.assertEqual((code, out, filed.labels, filed.detail), (0, f"Filed {filed.key} in the epic ABC-12.\n", (label,), ""))
def test_a_release_review_takes_its_label_beside_its_repos(self) -> None:
def test_a_release_review_takes_its_label_beside_its_repo(self) -> None:
code, out, _, _ = self.run_with(["ABC-12", "--file", "Review api", "--label", "repo:api", "--label", "do-epic-release-review"])
filed = self.store.issues[-1]
self.assertEqual((code, out, filed.labels), (0, f"Filed {filed.key} in the epic ABC-12.\n", ("do-epic-release-review", "repo:api")))
@@ -97,6 +97,11 @@ class FilingAFinding(FindingsTest):
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
self.assertEqual(err, f"cannot file the finding in the epic ABC-12: do-epic doesn't read the label {label!r}; write `repo:<name>` for the repo that works it, `do-epic-claude` for work of Claude's that changes no repo, or `do-epic-human` for a task of the human's\n")
def test_refuses_two_labels_that_each_say_who_works_the_issue(self) -> None:
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "repo:api", "--label", "repo:web"])
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
self.assertEqual(err, "cannot file the finding in the epic ABC-12: repo:api and repo:web each say who works it; write one of them\n")
def test_says_why_an_issue_was_not_filed(self) -> None:
self.store.fails = "Jira answered 401"
code, _, err, _ = self.run_with(["ABC-12", "--file", "Retry"])
+50 -3
View File
@@ -5,14 +5,17 @@ import sys
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.test_main import Description, DoEpicTest, MODELS, UNREAD
from do_epic.test_main import Description, DESCRIPTION, DoEpicTest, MODELS, UNREAD
from do_epic.config import DoEpicConfig, load
from do_epic.epic_record import EpicRecord
from failure import Failure
from loop_claude.test_loop_claude import FakeEffects, judged, Worker
from do_epic import findings, finish, main
from do_epic import findings, finish, main, scheduler
from project_config.settings import Finish
from do_epic.test_scheduler import issue
from do_epic.backend.fake import MemoryEpic
from loop_state.paths import paths_from
from claude_code.session import session_named
LAUNCHER = pathlib.Path("/b/do-epic")
REVIEWED = [issue("ABC-20", "repo:api", done=True), issue("ABC-21", "do-epic-claude", done=True), issue("ABC-30", "repo:api", "do-epic-release-review", done=True)]
@@ -66,6 +69,7 @@ class ClosingTheEpic(DoEpicTest):
self.store = MemoryEpic("ABC-12", self.issues)
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
self.assertIsInstance(config, DoEpicConfig)
self.store.issues = list(self.issues)
return self.store, EpicRecord(Description(self.description)) # type: ignore[arg-type]
@@ -82,6 +86,21 @@ class ClosingTheEpic(DoEpicTest):
self.assertEqual(self.store.comments, {"ABC-12": ["## Shipped\n\napi: the import."]})
self.assertIs(self.store.done, True)
def test_refuses_an_epic_that_is_closed_already(self) -> None:
self.store.done = True
code, _, err = self.close()
self.assertEqual(code, 1)
self.assertIn("cannot close the epic ABC-12: it is closed already, so its summary is posted\n", err)
self.assertEqual(self.store.comments, {})
def test_the_jira_backend_closes_an_epic_by_the_transition_the_settings_name(self) -> None:
with open(self.home / ".claude-projects/do-epic/config.toml", "a", encoding="utf-8") as settings:
settings.write('jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
config = load(self.home)
assert isinstance(config, DoEpicConfig), config
store, _ = main.jira_backend(config, "ABC-12")
self.assertEqual(store.finish, Finish("Mark as done", "Done")) # type: ignore[attr-defined]
def test_refuses_while_an_issue_is_open(self) -> None:
self.issues.append(issue("ABC-31", "repo:api"))
code, _, err = self.close()
@@ -169,13 +188,41 @@ class TheFinishingChunk(DoEpicTest):
self.assertIn("Finish the epic ABC-12", streamed)
self.assertIn("`/b/do-epic ABC-12 --close-epic`", streamed)
self.assertIn("From the epic ABC-12's description:\n## Goals\nShip the import.", streamed)
self.assertIn("write a summary in English, the epic's language", streamed)
self.assertTrue((self.home / ".local/state/do-epic/ABC-12").is_dir())
def test_a_worker_that_resumes_is_told_the_task_as_the_epic_now_stands(self) -> None:
self.issues = list(REVIEWED)
transcripts = paths_from(self.home).claude_code_transcripts
worker = Worker(transcripts.parent)
session = session_named("A ABC-12 do-epic ABC-12", transcripts)
(transcripts / "-fake").mkdir(parents=True)
(transcripts / "-fake" / f"{session.id}.jsonl").write_text("{}\n", encoding="utf-8")
fake = FakeEffects(streams=[worker], claude=[judged("finished")], git=UNREAD, windows="ABC-12\t0\t@9\n")
code, _, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
args = [what for seam, what in fake.calls if seam == "stream_claude"][0]
self.assertIn("--resume", args)
self.assertIn("so it may have changed since you began. It is now:\n\nFinish the epic ABC-12", " ".join(args))
self.assertIn("`/b/do-epic ABC-12 --close-epic`", " ".join(args))
def test_stops_where_the_epics_issues_cannot_be_read_or_its_lock_cannot_be_taken(self) -> None:
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
(self.home / ".local/state/do-epic/ABC-12" / scheduler.LOCK).mkdir(parents=True)
code, _, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False))
self.assertEqual(code, 1)
self.assertIn("cannot lock ", err)
self.store.fails = "Jira answered 503"
code, _, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], FakeEffects(windows="ABC-12\t0\t@9\n"), MODELS)
self.assertEqual(code, 1)
self.assertIn("Jira answered 503\n", err)
def test_ends_before_a_cycle_where_the_epic_holds_an_open_issue_again_and_starts_its_chunk(self) -> None:
self.issues = [*REVIEWED, issue("ABC-31", "do-epic-claude")]
self.description = DESCRIPTION.replace("chunks:** 2", "chunks:** 1")
fake = FakeEffects(windows="ABC-12\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
self.assertIn("the epic ABC-12 holds an open issue again, so its finishing waits\n", out)
self.assertIn("the epic ABC-12 holds an open issue again, so its finishing chunk ends until none is open\n", out)
self.assertIn("the chunk finished; started ABC-31\n", out)
self.assertEqual([seam for seam, _ in fake.calls if seam == "stream_claude"], [])
+1 -1
View File
@@ -406,7 +406,7 @@ def offer_of(raw: object) -> tuple[str, str, str, str] | None:
def finishing_transition(site: str, key: str, finish: Finish, authorization: str, http: Http) -> str | Failure:
"""The ID of the transition finish names, as Jira offers it now for the issue named key, an item's or an epic's; or why none of those offered finishes it."""
"""The ID of the transition finish names, as Jira offers it now for the issue named key, which is a plan item or an epic; or why none of those offered finishes it."""
offered = http("GET", f"{site}/rest/api/3/issue/{key}/transitions", authorization, None)
if isinstance(offered, Failure):
return Failure(f"cannot read {key}'s transitions: {offered.reason}")
+16 -4
View File
@@ -204,7 +204,6 @@ def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectCo
env_file = anywhere(values.get(ENV_FILE), home)
misplaced = ENV_FILE in values and (env_file is None or lies_in(env_file, top, main, file.parent))
scalars = {scalar: scalar.read(values[scalar.name]) for scalar in SCALARS if scalar.name in values}
finish = [name for setting in JIRA_FINISH if (name := name_of(values.get(setting)))]
formula, bar = values.get(JIRA_SCORE_FORMULA), values.get(JIRA_SCORE_BAR)
scoring = JiraScoring(formula, bar_value) if isinstance(formula, str) and (bar_value := bar_of(bar)) is not None else None
faults = [
@@ -225,8 +224,7 @@ def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectCo
*(f"`{name}` names a Confluence page, so `plan` must name a Jira epic" for name in RANKED if name in pages and not epics["plan"]),
*(f"`{name}` is set, so `plan` must name a Jira epic" for name in JIRA_PLAN_ONLY if name in values and not epics["plan"]),
*(f"`plan` names a Jira epic, so `{name}` must be set, as `project-config --help` shows" for name in JIRA_SCORE if epics["plan"] and name not in values),
*(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),
*finish_faults(values),
*([f"`{JIRA_SCORE_FORMULA}` is {formula!r}: {fault}"] if JIRA_SCORE_FORMULA in values and (fault := formula_fault(formula)) else []),
*([f"`{JIRA_SCORE_BAR}` is {bar!r}, not a bare number, such as `{JIRA_SCORE_BAR} = 1`"] if JIRA_SCORE_BAR in values and bar_of(bar) is None else []),
]
@@ -234,7 +232,7 @@ def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectCo
return Failure(f"{file}: {'; '.join(faults)}. The settings are {', '.join(SETTINGS)}, and optionally {', '.join(OPTIONAL[:-1])} and {OPTIONAL[-1]}.")
# faults names a formula or bar a plan in Jira lacks or misspells.
assert scoring is not None or not epics["plan"]
defaulted = ProjectConfig(file.parent.name, file.parent, top, {name: path for name, path in paths.items() if path}, env_file, epic=epics["plan"], goals_epic=epics["goals-and-audience"], jira_finish=Finish(*finish) if finish else None, jira_scoring=scoring, pages=pages, coding_conventions=conventions or ())
defaulted = ProjectConfig(file.parent.name, file.parent, top, {name: path for name, path in paths.items() if path}, env_file, epic=epics["plan"], goals_epic=epics["goals-and-audience"], jira_finish=finish_of(values), jira_scoring=scoring, pages=pages, coding_conventions=conventions or ())
return dataclasses.replace(defaulted, **{scalar.field: read for scalar, read in scalars.items()})
@@ -294,6 +292,20 @@ def bar_of(value: object) -> float | None:
return float(value)
def finish_faults(values: dict[str, object]) -> list[str]:
"""What is wrong with the two JIRA_FINISH settings in values, which are set together or not at all."""
return [
*(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),
]
def finish_of(values: dict[str, object]) -> Finish | None:
"""The Finish the two JIRA_FINISH settings in values name; None where they don't name both."""
names = [name for setting in JIRA_FINISH if (name := name_of(values.get(setting)))]
return Finish(*names) if len(names) == 2 else None
def name_of(value: object) -> str | None:
"""The name value holds, of a Jira transition or status; None where it holds none."""
return value if isinstance(value, str) and value.strip() else None