Answer stability round 1: 0 🔴, 2 🟡 (0 misread); name the changelog as the repo spells it, test facts not sentences
This commit is contained in:
@@ -17,18 +17,19 @@ DRIVER = "do-epic"
|
||||
|
||||
|
||||
def shipping(config: ProjectConfig) -> str:
|
||||
"""How a chunk in the repo that config names ships its change. An epic's issue is no item of the repo's plan, so the worker finishes none: its bullet, where the repo has a changelog to put one in, is its own to write (docs/decisions.md → `do-epic: drives one Jira epic …`, "Releases")."""
|
||||
opening = "The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`."
|
||||
"""How a chunk in the repo that config names ships its change. An epic's issue isn't an item of the repo's plan, so `chunk-pr merge --finish`, which adds a finished item's changelog bullet, doesn't apply: the worker writes the bullet itself, where the repo publishes something others consume (docs/decisions.md → `do-epic: drives one Jira epic …`, "Releases")."""
|
||||
opening = "The issue isn't an item of the repo's plan, so run `chunk-pr merge` without `--finish`."
|
||||
if config.epic:
|
||||
return f"{opening} The repo's plan is a Jira epic, whose issues' history is its changelog, so write no changelog bullet."
|
||||
return f"{opening} Where the repo publishes something others consume, ship the change with one bullet for its users under `## Unreleased` in {config.places['changelog']}, added in the branch; otherwise write none."
|
||||
return f"{opening} The repo's plan is a Jira epic, and the history of its issues serves as the changelog, so leave the changelog as it is."
|
||||
changelog = config.paths["changelog"].relative_to(config.top) if "changelog" in config.paths and config.paths["changelog"].is_relative_to(config.top) else config.places["changelog"]
|
||||
return f"{opening} Where the repo publishes something others consume, add one bullet to `## Unreleased` in `{changelog}` that tells the repo's consumers what changed; otherwise leave the changelog as it is."
|
||||
|
||||
|
||||
def task(issue: EpicIssue, epic: str, checkout: str | None, launcher: pathlib.Path, language: str, config: ProjectConfig | None) -> str:
|
||||
"""The task of the chunk that works issue, of the epic with the key epic: in checkout, or without a repo where it is None. launcher is the do-epic that runs the chunk, language the one the epic's Jira text is in, and config the project config of the repo's checkout, None without a repo."""
|
||||
shipped = shipping(config) if config else ""
|
||||
where = f"in the checkout {checkout}, on the branch {issue.key}" if checkout else "which changes no repo: work in the folder you start in"
|
||||
return f"Work the Jira issue {issue.key} of the epic {epic} as one chunk, {where}. {findings.instructions(epic, launcher, language)}{f' {shipped}' if shipped else ''} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
|
||||
return f"Work the Jira issue {issue.key} of the epic {epic} as one chunk, {where}. {" ".join(filter(None, [findings.instructions(epic, launcher, language), shipped]))} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
|
||||
|
||||
|
||||
CODE_HEALTH = '~/.claude/CLAUDE.md → "Shared goal"'
|
||||
|
||||
@@ -152,12 +152,6 @@ class TheCommand(DoEpicTest):
|
||||
|
||||
|
||||
class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
||||
def test_a_chunk_in_a_folder_no_project_config_names_stops_with_the_reason(self) -> None:
|
||||
stopped = main.chunk_work("ABC-21", str(self.home), "English", self.epic_run(FakeEffects()))
|
||||
assert isinstance(stopped, main.Stop)
|
||||
self.assertEqual(stopped.code, 1)
|
||||
self.assertIn("rev-parse", stopped.reason)
|
||||
|
||||
def cycle(self, env: dict[str, str] | None = None) -> main.Cycle:
|
||||
fake = FakeEffects(git=[Failure("no git"), Failure("no git")])
|
||||
paths = paths_from(self.home)
|
||||
@@ -418,6 +412,12 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("the chunk finished, but the next could not start: Jira answered 503\n", err)
|
||||
|
||||
def test_a_chunk_in_a_folder_no_project_config_names_stops_with_gits_reason(self) -> None:
|
||||
stopped = main.chunk_work("ABC-21", str(self.home), "English", self.epic_run(FakeEffects()))
|
||||
assert isinstance(stopped, main.Stop)
|
||||
self.assertEqual(stopped.code, 1)
|
||||
self.assertIn("rev-parse", stopped.reason) # git's reason, since no project config can be found without a checkout
|
||||
|
||||
def test_a_chunk_in_a_repo_works_in_its_checkout_on_the_repos_premises_and_records(self) -> None:
|
||||
checkout = self.home / "code" / "api"
|
||||
configured(self, checkout, home=self.home)
|
||||
@@ -433,7 +433,8 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("Ship the import.", prompt)
|
||||
self.assertIn("The repo's goals, which rank after the epic's and after code health, are from", prompt)
|
||||
self.assertIn("Serve the API.", prompt)
|
||||
self.assertIn(f"give `chunk-pr merge` no `--finish`. Where the repo publishes something others consume, ship the change with one bullet for its users under `## Unreleased` in {checkout}/CHANGELOG.md", prompt)
|
||||
self.assertIn("without `--finish`", prompt)
|
||||
self.assertIn("add one bullet to `## Unreleased` in `CHANGELOG.md`", prompt)
|
||||
self.assertIn("the chunk finished; started ABC-12\n", out)
|
||||
judge_prompt = [what[1] for seam, what in fake.calls if seam == "claude"][0]
|
||||
self.assertIn("The records: the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project:\nFrom the epic ABC-12's description, ## Decisions:\nKeep the v1 endpoints.\n\nFrom AGENTS.md:\nSquash every merge.", judge_prompt)
|
||||
|
||||
@@ -303,18 +303,32 @@ class TheFirstPrompt(unittest.TestCase):
|
||||
"Where filing fails and says the issue may exist, ask the human to look before you file it again. File a finding about a repo's goals by that repo's rules. Where unsure which, ask the human. "
|
||||
"Record a decision that governs the epic, such as an answer the human typed, with `/b/do-epic ABC-12 --record-decision \"<title>\"` and its text on stdin. Write the issue and the decision in Swedish, the epic's language."
|
||||
)
|
||||
self.assertEqual(chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG), f"Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout /code/api, on the branch ABC-20. {told} The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`. The repo's plan is a Jira epic, whose issues' history is its changelog, so write no changelog bullet. Its summary: Do ABC-20")
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
|
||||
self.assertTrue(task.startswith(f"Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout /code/api, on the branch ABC-20. {told} "))
|
||||
self.assertTrue(task.endswith(" Its summary: Do ABC-20"))
|
||||
|
||||
def test_a_chunk_without_a_repo_has_no_shipping_sentence(self) -> None:
|
||||
self.assertEqual(chunk_prompt.task(issue("ABC-20"), "ABC-12", None, pathlib.Path("/b/do-epic"), "Swedish", None).count(" "), 0)
|
||||
self.assertTrue(chunk_prompt.task(issue("ABC-20"), "ABC-12", None, pathlib.Path("/b/do-epic"), "Swedish", None).endswith("Swedish, the epic's language. Its summary: Do ABC-20"))
|
||||
def test_a_chunk_without_a_repo_is_told_nothing_of_shipping(self) -> None:
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", None, pathlib.Path("/b/do-epic"), "Swedish", None)
|
||||
self.assertTrue(task.endswith("Swedish, the epic's language. Its summary: Do ABC-20"))
|
||||
self.assertNotIn("--finish", task)
|
||||
|
||||
def test_a_repo_with_a_plan_file_ships_the_chunk_with_a_bullet_in_its_changelog(self) -> None:
|
||||
def test_a_repo_with_a_plan_file_is_told_to_add_a_bullet_to_its_changelog_where_it_publishes(self) -> None:
|
||||
config = settings.ProjectConfig("api", pathlib.Path("/c/api"), pathlib.Path("/code/api"), {"changelog": pathlib.Path("/code/api/CHANGELOG.md")})
|
||||
self.assertEqual(chunk_prompt.shipping(config), "The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`. Where the repo publishes something others consume, ship the change with one bullet for its users under `## Unreleased` in /code/api/CHANGELOG.md, added in the branch; otherwise write none.")
|
||||
told = chunk_prompt.shipping(config)
|
||||
self.assertIn("without `--finish`", told)
|
||||
self.assertIn("Where the repo publishes something others consume, add one bullet to `## Unreleased` in `CHANGELOG.md`", told)
|
||||
|
||||
def test_a_repo_with_its_plan_in_jira_ships_the_chunk_with_no_bullet(self) -> None:
|
||||
self.assertEqual(chunk_prompt.shipping(CONFIG), "The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`. The repo's plan is a Jira epic, whose issues' history is its changelog, so write no changelog bullet.")
|
||||
def test_a_changelog_outside_the_checkout_or_on_a_page_is_named_as_the_config_spells_it(self) -> None:
|
||||
config = settings.ProjectConfig("api", pathlib.Path("/c/api"), pathlib.Path("/code/api"), {"changelog": pathlib.Path("/c/api/CHANGELOG.md")})
|
||||
self.assertIn("in `/c/api/CHANGELOG.md`", chunk_prompt.shipping(config))
|
||||
paged = settings.ProjectConfig("api", pathlib.Path("/c/api"), pathlib.Path("/code/api"), {}, pages={"changelog": settings.Page("https://acme.atlassian.net", "7", "confluence:https://acme.atlassian.net/wiki/pages/7")})
|
||||
self.assertIn("in `confluence:https://acme.atlassian.net/wiki/pages/7`", chunk_prompt.shipping(paged))
|
||||
|
||||
def test_a_repo_with_its_plan_in_jira_is_told_to_leave_the_changelog_as_it_is(self) -> None:
|
||||
told = chunk_prompt.shipping(CONFIG)
|
||||
self.assertIn("without `--finish`", told)
|
||||
self.assertIn("leave the changelog as it is", told)
|
||||
self.assertNotIn("## Unreleased", told)
|
||||
|
||||
def test_an_answer_the_judge_quoted_names_the_epics_description_first(self) -> None:
|
||||
self.assertTrue(chunk_prompt.WORKER.answered("Q", "A", Route(Rung("off-the-ladder")), None, False).startswith("Your question: Q\n\nthe epic's description, "))
|
||||
|
||||
@@ -220,7 +220,7 @@ class ToolProcess(unittest.TestCase):
|
||||
|
||||
def test_an_interrupt_reaches_the_tool_before_the_run_kills_it(self):
|
||||
# A container's CLI, such as docker compose, stops its container on the SIGINT it is passed, and can't once killed.
|
||||
# The loop ends by itself after about 40 seconds: under mutmut, the interrupt doesn't reach this shell, and an endless one hung the run.
|
||||
# The loop ends by itself after about 40 seconds: under mutmut, the interrupt doesn't reach this shell, and a shell that looped for ever hung the run.
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
self.interrupted(folder, "trap 'echo > stopped; exit 130' INT; echo $$ > started; n=0; while [ $n -lt 400 ]; do sleep 0.1; n=$((n+1)); done;")
|
||||
self.assertTrue(pathlib.Path(folder, "stopped").is_file())
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ Valid while `~/.claude` is a checkout of this repo.
|
||||
- **Items live only in the epic.** A repo's own plan never mirrors them. Where `repo-rule.md` leaves an item's repo unclear, do-epic asks. An item without a repo is either Claude's work, done without a PR, or a human task; where the item doesn't say which, do-epic asks.
|
||||
- **One item, several repos.** do-epic splits such an item when it plans it, into one Jira sub-task per repo, each labelled for its repo. The parent tracks the whole change. A person's issue is split too, with a comment for the team.
|
||||
- **Ranking.** Score, then Blocked by, in one weight chain: the epic's achieve goals, then code health, then the repo's goals. Where the epic and a repo disagree, the epic wins. do-epic re-ranks Jira's backlog to match, and people's issues keep their rank.
|
||||
- **Releases.** An epic item has no release. It ships into its repo's unreleased work: a bullet under `CHANGELOG.md` → `## Unreleased`, or nothing where the repo's plan is in Jira.
|
||||
- **Releases.** An epic item has no release. It ships into its repo's unreleased work: where the repo publishes something others consume, a bullet under `CHANGELOG.md` → `## Unreleased`, or nothing where the repo's plan is in Jira. The issue is no item of the repo's plan, so the chunk's worker writes the bullet in its branch and runs `chunk-pr merge` without `--finish`.
|
||||
- **Repos.** A repo's name is its main checkout's folder name, and a project config names that checkout. A missing checkout is cloned from the host of the epic's other repos; where unsure, do-epic asks. Unsure means the other repos don't all sit under one host and owner (the same host spelt as https and as ssh counts as two), an origin can't be read or isn't an https, ssh or scp-style address, the folder to clone into holds something else, or the clone fails. A repo no config names is cloned into the clone folder, and the human is asked to write its config. Each chunk uses its repo's model, routing, and language for commits and PRs. Jira text is in the epic's language, or else the machine's default.
|
||||
- **Running.** The epic caps the chunks running at once, and each repo's `parallel-chunks` still applies. do-epic and loop-claude never run chunks in the same repo at once. The cap is a line of the epic's description, `**Max parallel chunks:** 2`, and 1 without it, as `parallel-chunks` is. A repo's `parallel-chunks` counts the chunks of every epic in its checkout. Each window is named for its issue's key, and a tmux window option, `@chunk-root`, names the folder its chunk works in, which is how loop-claude sees do-epic's chunks in a checkout. do-epic and loop-claude each hold the checkout's `starting` lock from checking the checkout's chunks to starting a window there. A chunk without a repo works in `~/.local/state/do-epic/<EPIC-KEY>/`. do-epic archives its cycles under `~/.claude/do-epic-transcripts/`, not in loop-claude's archive, whose readers parse loop-claude's prompts. An open issue runs once a label records its repo; until do-epic picks repos itself, an issue without one waits, and `do-epic <EPIC-KEY>` says so.
|
||||
- **Long gates.** A chunk whose PR waits on a gate, such as a human approval, parks. It keeps its worktree, PR and session, and its state is in a file that survives a reboot. A parked chunk takes no running slot, and the items it blocks wait. do-epic polls the forge and resumes the chunk's session when the gate passes or a reviewer comments. It fixes reasonable feedback, replies to the rest, and changes the setup so review would have caught it. `do-epic <key> --status` and the tmux window names show what each chunk waits on. A gate is a pull request's pending checks or, on GitHub, the approval its branch protection requires; a draft waits on neither, since its worker has yet to mark it ready. On Gitea a draft is a pull request whose title opens with `WIP:` or `[WIP]`, Gitea's default `WORK_IN_PROGRESS_PREFIXES`. Changes a reviewer requested resume the chunk only while that review was made on the pull request's head commit and the pull request's author has not commented or replied after it; once the worker pushed or replied, the chunk parks on a new review, since GitHub keeps the decision until the reviewer reviews again. The chunk's window reads the forge once a minute, which no forge's rate limit notices. A chunk resumes only into a free slot, under the limits a starting chunk meets, and stays parked until then. `do-epic <key>` starts a parked chunk's window again whatever the limits, since the chunk stays parked. do-epic sets `CHUNK_PR_PARKS=1` for each worker, so `chunk-pr merge` fails at once where the pull request awaits an approval, and the worker's run doesn't hold a slot while the pull request waits.
|
||||
|
||||
Reference in New Issue
Block a user