Rename do-epic to build-epic, with no alias, and its config folder with it #802

Merged
lilleman merged 9 commits from item-575 into main 2026-12-03 23:33:09 +01:00
99 changed files with 862 additions and 957 deletions
+8 -8
View File
@@ -37,7 +37,15 @@
!bin/atlassian/*.py
!bin/branch_chunks/
!bin/branch_chunks/*.py
!bin/build-epic
!bin/build-epic-e2e
!bin/build-release
!bin/build_epic/
!bin/build_epic/*.py
!bin/build_epic/backend/
!bin/build_epic/backend/*.py
!bin/build_epic/e2e/
!bin/build_epic/e2e/*.py
!bin/build_release/
!bin/build_release/**/
!bin/build_release/**/*.py
@@ -64,14 +72,6 @@
!bin/deploy-release
!bin/deploy_release/
!bin/deploy_release/*.py
!bin/do-epic
!bin/do-epic-e2e
!bin/do_epic/
!bin/do_epic/*.py
!bin/do_epic/backend/
!bin/do_epic/backend/*.py
!bin/do_epic/e2e/
!bin/do_epic/e2e/*.py
!bin/failure.py
!bin/forge/
!bin/forge/*.py
+2 -1
View File
@@ -2,7 +2,8 @@
## Unreleased
- The setup's folders moved, and nothing reads or migrates the old ones. Before you update, stop every running `build-release` and `do-epic`. Then move `~/.claude-projects/` to `~/.config/build-release/` and `~/.claude/loop-claude-models.json` to `~/.config/build-release/models.json`; move `~/.claude/loop-claude-transcripts` to `~/.local/state/build-release/transcripts` and `~/.claude/do-epic-transcripts` to `~/.local/state/build-release/do-epic-transcripts`; move `larv-review`, `do-epic`, `project-record`, `run-heavy` and `deploy-release` from `~/.local/state/` into `~/.local/state/build-release/`; and delete `~/.local/state/loop-claude/`, which held only locks. Respell each setting that names `~/.claude-projects/`, such as `env-file`, and the log path in your crontab line. Where `XDG_CONFIG_HOME` or `XDG_STATE_HOME` holds an absolute path, the two folders are `build-release/` under it instead, and a chunk's tmux window is handed both variables.
- Renamed `do-epic` to `build-epic`, with no alias. Before you update, finish your open `do-epic` chunks, since a chunk left open starts a fresh session, and stop every running `do-epic`, since one that runs across the update can't reload. Then, in each Jira project, relabel every issue that carries `do-epic-claude`, `do-epic-human` or `do-epic-release-review`, done issues included, to `build-epic-claude`, `build-epic-human` or `build-epic-release-review`, since a finished release review that keeps the old label isn't counted and `build-epic` files another. Rename each `DO_EPIC_E2E_*` variable you set to `BUILD_EPIC_E2E_*`. Nothing reads the old names. The next bullet moves the folders.
- The setup's folders moved, and nothing reads or migrates the old ones. Before you update, stop every running `build-release` and `do-epic`. Then move `~/.claude-projects/` to `~/.config/build-release/` and `~/.config/build-release/do-epic/` to `~/.config/build-release/build-epic/`, and move `~/.claude/loop-claude-models.json` to `~/.config/build-release/models.json`; move `~/.claude/loop-claude-transcripts` to `~/.local/state/build-release/transcripts` and `~/.claude/do-epic-transcripts` to `~/.local/state/build-release/build-epic-transcripts`; move `larv-review`, `project-record`, `run-heavy` and `deploy-release` from `~/.local/state/` into `~/.local/state/build-release/`, and `~/.local/state/do-epic` to `~/.local/state/build-release/build-epic`; and delete `~/.local/state/loop-claude/`, which held only locks. Respell each setting that names `~/.claude-projects/`, such as `env-file`, and the log path in your crontab line. Where `XDG_CONFIG_HOME` or `XDG_STATE_HOME` holds an absolute path, the two folders are `build-release/` under it instead, and a chunk's tmux window is handed both variables.
- The stability reviewer traces every path that can reach a callback, handler or hook that a change guards, background and process-wide ones included, and reports each path the guard leaves open.
- Interactive sessions start with permissions bypassed (`defaultMode: bypassPermissions`) instead of in auto mode, so a session on the sandbox this checkout requires asks for permission only where Claude Code always does.
- Renamed `loop-claude` to `build-release`, with no alias. Before you update, finish your open chunks, since a chunk left open under `loop-claude` starts a fresh session, and stop every running `loop-claude`, since a loop that runs across the update can't reload and hands its workers variables the new rule-hook ignores. Then remove `~/.local/bin/loop-claude`, link the new name with `ln -s ~/.claude/bin/build-release ~/.local/bin/build-release`, and rename each `LOOP_CLAUDE_*` variable you set, in your shell profile and in your crontab, to `BUILD_RELEASE_*`, such as `BUILD_RELEASE_TRANSCRIPTS`.
+32 -32
View File
@@ -85,9 +85,9 @@ Link `build-release` onto `PATH`: `ln -s ~/.claude/bin/build-release ~/.local/bi
The setup keeps each project's config, and what you choose for a project, in the config folder, `~/.config/build-release/`. Its tools keep their own state, such as transcripts, review reports and locks, in the state folder, `~/.local/state/build-release/`. Where `XDG_CONFIG_HOME` holds an absolute path, the config folder is `build-release/` under that path instead, and likewise the state folder under `XDG_STATE_HOME`; this README spells the defaults. Set such a variable in the environment Claude Code starts in, since rule-hook reads it there. `settings.json` names only the default review folder, `~/.local/state/build-release/larv-review`, in `additionalDirectories`: where `XDG_STATE_HOME` moves that folder, add it there yourself, or an interactive session asks before a reviewer writes its report. Back up these four folders:
- `~/.config/build-release/`: each project's config, a client project's plan and records, and `models.json`, the model of each project, which build-release and do-epic write. A project's `env-file`, if you keep it here as below, puts credentials in the backup, so keep the backup private.
- `~/.config/build-release/`: each project's config, a client project's plan and records, and `models.json`, the model of each project, which build-release and build-epic write. A project's `env-file`, if you keep it here as below, puts credentials in the backup, so keep the backup private.
- `~/.local/state/build-release/transcripts`: every transcript build-release keeps. Where you set `BUILD_RELEASE_TRANSCRIPTS`, back up the folder it names instead.
- `~/.local/state/build-release/do-epic-transcripts`: the transcripts of do-epic's chunks.
- `~/.local/state/build-release/build-epic-transcripts`: the transcripts of build-epic's chunks.
- `~/.local/state/build-release/larv-review`: each chunk's review reports.
Leave out Claude Code's memory files in `~/.claude/projects/<folder>/memory/`: Claude Code writes them, so they aren't part of this setup.
@@ -140,9 +140,9 @@ A legacy project with no container setup sets `tooling-on-host = true`, so the l
A project whose pull requests need a human's approval sets `wait-for-approval = true` in its config. `chunk-pr merge` then waits, once the checks have passed, until GitHub reports the pull request approved as its branch protection requires, and merges it. It refuses on Gitea, where a reviewer requested changes and where the protection requires no review. While it waits, other chunks merge. It stops where a reviewer's comment waits for an answer, on an approved pull request too; answer it and run it again. It gives up after 90 minutes without an approval; run it again once the pull request is approved. Left out, the setting is false.
A project whose team merges its pull requests itself sets `merge = "human"`. `chunk-pr merge` then brings the branch level with origin's default branch, finishes the chunk's plan items, waits for the checks and marks the pull request ready, but leaves the merge to a person. A plan or changelog kept in the checkout is finished on the branch, so it lands with that merge; one kept in Jira, or in the config's folder, is finished at once; where you close the pull request unmerged, file the item again. A do-epic chunk parks until the pull request is merged, and its window's name says `awaits your merge`. The chunk resumes and brings the branch level again once the pull request conflicts with the default branch. It does so too once the branch is behind a default branch whose protection, on GitHub, requires an up-to-date branch. build-release doesn't start a chunk for an item that a ready pull request finishes. Once no item left in the release can start and one awaits a merge, build-release stops and names the pull requests to merge; run it again after you merge one. The first chunk after a merge runs `chunk-pr clean` in the worktree the merged pull request left, where nobody pushed to the pull request after the chunk did. Nobody works on a pull request that awaits your merge. To have a reviewer's comment answered, turn the pull request back into a draft: a chunk then takes its item up again. Left out, the setting is `"chunk"`: the chunk merges.
A project whose team merges its pull requests itself sets `merge = "human"`. `chunk-pr merge` then brings the branch level with origin's default branch, finishes the chunk's plan items, waits for the checks and marks the pull request ready, but leaves the merge to a person. A plan or changelog kept in the checkout is finished on the branch, so it lands with that merge; one kept in Jira, or in the config's folder, is finished at once; where you close the pull request unmerged, file the item again. A build-epic chunk parks until the pull request is merged, and its window's name says `awaits your merge`. The chunk resumes and brings the branch level again once the pull request conflicts with the default branch. It does so too once the branch is behind a default branch whose protection, on GitHub, requires an up-to-date branch. build-release doesn't start a chunk for an item that a ready pull request finishes. Once no item left in the release can start and one awaits a merge, build-release stops and names the pull requests to merge; run it again after you merge one. The first chunk after a merge runs `chunk-pr clean` in the worktree the merged pull request left, where nobody pushed to the pull request after the chunk did. Nobody works on a pull request that awaits your merge. To have a reviewer's comment answered, turn the pull request back into a draft: a chunk then takes its item up again. Left out, the setting is `"chunk"`: the chunk merges.
A project whose team wants an epic's work in one pull request sets `epic-branch`, a template with `{epic}` for the epic's key, such as `epic-branch = "{epic}"`. Under build-release the epic is the Jira epic the config's `plan` names, so a plan kept in a file gets no working branch. Under do-epic it is the epic do-epic drives. Each chunk then branches off the epic's working branch, here `ABC-123` for the epic ABC-123, and `chunk-pr` opens its pull request into that branch and merges it there without a person, also under `merge = "human"` and `wait-for-approval`: those two keep guarding the default branch. A pull request that was open into the default branch when you set `epic-branch` stays yours to settle: `chunk-pr ready` and `merge` fail on it, naming both branches, until you change its base on the forge to the working branch, or merge it yourself. `chunk-preflight`, and do-epic as a chunk starts, make the branch on origin off the default branch, or merge the default branch into it with a merge commit, which needs git 2.38 or later. Where that merge conflicts, they stop, and a person merges it. Once the epic's last issue has landed, do-epic's finishing chunk runs `chunk-pr open-epic <epic's key> <title>`, which brings the branch level once more and opens the pull request from it into the default branch. Under build-release, run it yourself. A person merges that pull request, and its checks and reviews are theirs to answer. An auto-reviewer that reviews only pull requests into the default branch is asked by a comment: set `review-request-comment` to the comment's text, such as `"@reviewbot review"`. `chunk-pr ready` then posts it on a pull request into the working branch, and `chunk-pr push` pushes later commits and posts it again.
A project whose team wants an epic's work in one pull request sets `epic-branch`, a template with `{epic}` for the epic's key, such as `epic-branch = "{epic}"`. Under build-release the epic is the Jira epic the config's `plan` names, so a plan kept in a file gets no working branch. Under build-epic it is the epic build-epic drives. Each chunk then branches off the epic's working branch, here `ABC-123` for the epic ABC-123, and `chunk-pr` opens its pull request into that branch and merges it there without a person, also under `merge = "human"` and `wait-for-approval`: those two keep guarding the default branch. A pull request that was open into the default branch when you set `epic-branch` stays yours to settle: `chunk-pr ready` and `merge` fail on it, naming both branches, until you change its base on the forge to the working branch, or merge it yourself. `chunk-preflight`, and build-epic as a chunk starts, make the branch on origin off the default branch, or merge the default branch into it with a merge commit, which needs git 2.38 or later. Where that merge conflicts, they stop, and a person merges it. Once the epic's last issue has landed, build-epic's finishing chunk runs `chunk-pr open-epic <epic's key> <title>`, which brings the branch level once more and opens the pull request from it into the default branch. Under build-release, run it yourself. A person merges that pull request, and its checks and reviews are theirs to answer. An auto-reviewer that reviews only pull requests into the default branch is asked by a comment: set `review-request-comment` to the comment's text, such as `"@reviewbot review"`. `chunk-pr ready` then posts it on a pull request into the working branch, and `chunk-pr push` pushes later commits and posts it again.
For a client's project, use one sandbox VM per client, so that one client's code, transcripts and credentials never share a machine with another's. What the client's repo should not hold lives in the config's folder, at paths written as `folder:<path>`, as `project-config --help` shows: the plan, the working rules in an `AGENTS.md` I write for the agents, the records, and the goals and audience, as `goals-and-audience = "folder:goals.md"`. Name that file `goals.md`, so the rules for goals and audience load when an agent writes it. A file outside the checkout has no commits in the checkout's history, so four things are not supported for it yet. `score-outcomes` and build-release's routing figures count a project's chunks only where `todo.md`, `docs/comprehension-history.md` and `docs/reading-cost.md` are at those paths in the checkout; otherwise each says so, and the loop goes on. For a plan or a comprehension history outside the checkout, `larv-review` says it cannot tell whether a scoring run is owed, and for such a history it cannot find a paired ruling's base. For a plan outside the checkout, chunk-preflight and build-release don't see a release whose last item has shipped, and say that its release review and its cut are yours to call. And rule-hook checks a plan outside the checkout on every call, not only when it changed.
@@ -175,23 +175,23 @@ cd ~/code/acme-billing && ~/.claude/bin/project-config
The last line prints each setting's path once the config is complete.
`do-epic` keeps its settings per machine, not per project, in `~/.config/build-release/do-epic/`, two files for every epic:
`build-epic` keeps its settings per machine, not per project, in `~/.config/build-release/build-epic/`, two files for every epic:
- `config.toml` sets `jira-url`, the site, such as `https://acme.atlassian.net`; `env-file`, the file holding `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, a path that starts with `/` or `~/`, outside the clone folder and every folder of `~/.config/build-release`; and `repoless-model`, the model that works an item with no repo. It may also set `clone-folder`, where a missing repo is cloned, `~/code` if left out; `language`, the language of Jira text, English if left out; and `jira-finish-transition` with `jira-finish-status`, which name the workflow transition that moves a finished chunk's issue, and closes a finished epic, and the status it leads to, such as `"Mark as done"` and `"Done"`. Set both or neither: without them do-epic moves no issue to done and closes no epic, and a chunk that finishes stops with that reason.
- `config.toml` fits do-epic to a team whose own automation moves issues, such as a CI job that moves an issue when its pull request merges. Two settings do:
- `jira-unblocking-statuses` lists the statuses at which an issue's work has landed though Jira doesn't count it done yet, such as `["Release Ready"]`, in upper or lower case. An issue in one of them takes no chunk and no longer blocks the issues it blocks, and `--status` names the statuses beside each blocker. A status Jira counts as done always does both. The release reviews, which are the epic's last chunk, still wait until Jira counts every issue done: run `do-epic <EPIC-KEY>` then, to start them.
- `jira-automation-moves-issues = true` keeps do-epic from moving the issue of a finished chunk in a repo: the automation moves it, and do-epic waits for that move before it starts what the issue blocks. An issue without a repo has no pull request, so do-epic still moves it, with `jira-finish-transition`. The setting needs `jira-unblocking-statuses`, which names the status the automation gives an issue whose pull request merged.
- `config.toml` names the statuses do-epic itself gives an issue whose chunk merges into an epic's working branch, in a repo whose config sets `epic-branch`. A team's automation moves an issue only for a pull request into the default branch, so there do-epic makes both moves, whatever `jira-automation-moves-issues` says. `jira-pull-request-open-status`, such as `"Code Review"`, is the status of an issue whose chunk parks with its pull request open; a pull request that opens and merges within one run of the worker skips it, unless the workflow leads to the merged status only through it. `jira-pull-request-merged-status`, such as `"Release Ready"`, is the status once the pull request has merged into the working branch. `jira-unblocking-statuses` must list it, and an issue that has it counts as done when the release reviews and the finishing chunk fall due, since both come before a person merges the working branch. Without it, do-epic moves a finished chunk's issue to done. Where `jira-automation-moves-issues` is set, it stops instead and asks you to move the issue.
- `config.toml` names how do-epic moves a parent issue whose sub-tasks a person filed. Once every sub-task is done, the parent moves to done by `jira-finish-transition`; without that setting it stays. Before that, once each sub-task is done or in one of `jira-unblocking-statuses`, the parent moves by the transition `jira-sub-tasks-landed-transition` names, such as `"Release Ready"`; without that setting it stays. The transition must lead to one of `jira-unblocking-statuses`, or do-epic doesn't make it. do-epic makes these moves as each run plans and as each chunk finishes, and `--dry-run` prints them. A parent that is done, or already in one of `jira-unblocking-statuses`, never moves back. A move that is not made is said, and the run goes on.
- `config.toml` also says how a starting chunk's issue shows on its team's board. A starting chunk always assigns its issue to the account do-epic works as, unless someone else holds it; that issue keeps its assignee, and moves and joins the sprint like any other. `jira-start-transition` names the workflow transition that then moves the issue, such as `"In Progress"`; an issue whose work has started already keeps its status. `jira-sprint-board` is the ID of the board whose active sprint the issue joins, such as `6`. Where a setting is left out, do-epic doesn't take its step.
- `config.toml` may set `jira-finding-type`, the issue type do-epic files a finding as, and `jira-review-type`, the one it files a repo's release review as, such as `"Feature"` and `"Chore"`. Both are Task where left out. do-epic doesn't file anything where the Jira project lacks the type, and says which types it has.
- `config.toml` may set `sub-task-summary`, which shapes the summary of each sub-task do-epic files for an issue that changes several repos, such as `sub-task-summary = "{label}: {Summary}"`. `{label}` is the team's label for the repo, else the repo's name, and `{Summary}` is the issue's summary with a capital first letter. It must hold `{Summary}`. Without it a summary is `[<repo>] <the issue's summary>`.
- `config.toml` may end with a `[label-repos]` table, for a team that already labels its issues by repo. Give it one line for each such label: the label, then the repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. Where the label is the repo's name, map the name to itself, as in `core-4 = "core-4"`. Where several lines name one repo, do-epic writes the label of the first. Write every other setting above the table.
- `repo-rule.md` is prose that says how to tell an item's repo, such as "a label that equals a repo's name names that repo". It may not be blank. `do-epic <EPIC-KEY>` uses it to pick where each open issue without such a label is worked, and records the pick as a label. For a repo that is the team's own label from `[label-repos]`, else `repo:<name>`; for work of Claude's that changes no repo, `do-epic-claude`; for a task of yours, `do-epic-human`. Where the rule leaves an issue unclear, do-epic asks you on the terminal. Answer with the label, or with Enter alone to leave the issue waiting. Change a pick by editing the label in Jira.
- `config.toml` sets `jira-url`, the site, such as `https://acme.atlassian.net`; `env-file`, the file holding `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, a path that starts with `/` or `~/`, outside the clone folder and every folder of `~/.config/build-release`; and `repoless-model`, the model that works an item with no repo. It may also set `clone-folder`, where a missing repo is cloned, `~/code` if left out; `language`, the language of Jira text, English if left out; and `jira-finish-transition` with `jira-finish-status`, which name the workflow transition that moves a finished chunk's issue, and closes a finished epic, and the status it leads to, such as `"Mark as done"` and `"Done"`. Set both or neither: without them build-epic moves no issue to done and closes no epic, and a chunk that finishes stops with that reason.
- `config.toml` fits build-epic to a team whose own automation moves issues, such as a CI job that moves an issue when its pull request merges. Two settings do:
- `jira-unblocking-statuses` lists the statuses at which an issue's work has landed though Jira doesn't count it done yet, such as `["Release Ready"]`, in upper or lower case. An issue in one of them takes no chunk and no longer blocks the issues it blocks, and `--status` names the statuses beside each blocker. A status Jira counts as done always does both. The release reviews, which are the epic's last chunk, still wait until Jira counts every issue done: run `build-epic <EPIC-KEY>` then, to start them.
- `jira-automation-moves-issues = true` keeps build-epic from moving the issue of a finished chunk in a repo: the automation moves it, and build-epic waits for that move before it starts what the issue blocks. An issue without a repo has no pull request, so build-epic still moves it, with `jira-finish-transition`. The setting needs `jira-unblocking-statuses`, which names the status the automation gives an issue whose pull request merged.
- `config.toml` names the statuses build-epic itself gives an issue whose chunk merges into an epic's working branch, in a repo whose config sets `epic-branch`. A team's automation moves an issue only for a pull request into the default branch, so there build-epic makes both moves, whatever `jira-automation-moves-issues` says. `jira-pull-request-open-status`, such as `"Code Review"`, is the status of an issue whose chunk parks with its pull request open; a pull request that opens and merges within one run of the worker skips it, unless the workflow leads to the merged status only through it. `jira-pull-request-merged-status`, such as `"Release Ready"`, is the status once the pull request has merged into the working branch. `jira-unblocking-statuses` must list it, and an issue that has it counts as done when the release reviews and the finishing chunk fall due, since both come before a person merges the working branch. Without it, build-epic moves a finished chunk's issue to done. Where `jira-automation-moves-issues` is set, it stops instead and asks you to move the issue.
- `config.toml` names how build-epic moves a parent issue whose sub-tasks a person filed. Once every sub-task is done, the parent moves to done by `jira-finish-transition`; without that setting it stays. Before that, once each sub-task is done or in one of `jira-unblocking-statuses`, the parent moves by the transition `jira-sub-tasks-landed-transition` names, such as `"Release Ready"`; without that setting it stays. The transition must lead to one of `jira-unblocking-statuses`, or build-epic doesn't make it. build-epic makes these moves as each run plans and as each chunk finishes, and `--dry-run` prints them. A parent that is done, or already in one of `jira-unblocking-statuses`, never moves back. A move that is not made is said, and the run goes on.
- `config.toml` also says how a starting chunk's issue shows on its team's board. A starting chunk always assigns its issue to the account build-epic works as, unless someone else holds it; that issue keeps its assignee, and moves and joins the sprint like any other. `jira-start-transition` names the workflow transition that then moves the issue, such as `"In Progress"`; an issue whose work has started already keeps its status. `jira-sprint-board` is the ID of the board whose active sprint the issue joins, such as `6`. Where a setting is left out, build-epic doesn't take its step.
- `config.toml` may set `jira-finding-type`, the issue type build-epic files a finding as, and `jira-review-type`, the one it files a repo's release review as, such as `"Feature"` and `"Chore"`. Both are Task where left out. build-epic doesn't file anything where the Jira project lacks the type, and says which types it has.
- `config.toml` may set `sub-task-summary`, which shapes the summary of each sub-task build-epic files for an issue that changes several repos, such as `sub-task-summary = "{label}: {Summary}"`. `{label}` is the team's label for the repo, else the repo's name, and `{Summary}` is the issue's summary with a capital first letter. It must hold `{Summary}`. Without it a summary is `[<repo>] <the issue's summary>`.
- `config.toml` may end with a `[label-repos]` table, for a team that already labels its issues by repo. Give it one line for each such label: the label, then the repo's name, such as `twu-4 = "tenant-web-ui-4"`. build-epic reads such a label as it reads its own `repo:<name>`. Where the label is the repo's name, map the name to itself, as in `core-4 = "core-4"`. Where several lines name one repo, build-epic writes the label of the first. Write every other setting above the table.
- `repo-rule.md` is prose that says how to tell an item's repo, such as "a label that equals a repo's name names that repo". It may not be blank. `build-epic <EPIC-KEY>` uses it to pick where each open issue without such a label is worked, and records the pick as a label. For a repo that is the team's own label from `[label-repos]`, else `repo:<name>`; for work of Claude's that changes no repo, `build-epic-claude`; for a task of yours, `build-epic-human`. Where the rule leaves an issue unclear, build-epic asks you on the terminal. Answer with the label, or with Enter alone to leave the issue waiting. Change a pick by editing the label in Jira.
An epic's description states the formula that puts its issues in order: once under `## Scoring`, on a line of its own and inside backticks, such as `` `Score = 100 * V / (2**S + 32)` ``. do-epic starts the epic's issues by that score, highest first, with each blocker before what it blocks, whatever their order on the board. Where two or more issues may start, it scores each of them that holds no scores, a person's included, against the epic's goals and the goals of the issue's repo, and tells the team the scores in a comment on the issue. It doesn't score a task of yours, and it keeps the scores an issue already holds. On the board it re-ranks only the issues it filed, so a person's issue keeps the rank the team gave it. Without that line do-epic says so, doesn't score anything and starts the issues in the backlog's order.
An epic's description states the formula that puts its issues in order: once under `## Scoring`, on a line of its own and inside backticks, such as `` `Score = 100 * V / (2**S + 32)` ``. build-epic starts the epic's issues by that score, highest first, with each blocker before what it blocks, whatever their order on the board. Where two or more issues may start, it scores each of them that holds no scores, a person's included, against the epic's goals and the goals of the issue's repo, and tells the team the scores in a comment on the issue. It doesn't score a task of yours, and it keeps the scores an issue already holds. On the board it re-ranks only the issues it filed, so a person's issue keeps the rank the team gave it. Without that line build-epic says so, doesn't score anything and starts the issues in the backlog's order.
Each repo an epic changes has a project config of its own, as in the rest of this section. `do-epic` fails and names each setting or file that is missing or invalid.
Each repo an epic changes has a project config of its own, as in the rest of this section. `build-epic` fails and names each setting or file that is missing or invalid.
A project runs on the routing ladder this setup ships, `bin/model_routing/routing-ladder.json`: the rungs, least competent first, each a model at an effort, that build-release routes workers, subagents and reviews to. To run one project on other rungs, as when an outage or a client's account leaves it fewer models, copy that file to `~/.config/build-release/<key>/routing-ladder.json` and cut or change its rungs. Keep one model for each family, such as opus: Claude Code launches a subagent by its family's name. The project's file replaces the shipped ladder whole. build-release reads it as each cycle starts, and `subagent-rung` and rule-hook each time they run. The loop never commits it, so commit it in the folder's repo yourself only where it should last. Set the project's models to ones its ladder holds, for example with `BUILD_RELEASE_WORKER_MODEL` and `BUILD_RELEASE_JUDGE_MODEL`. A model off the ladder is not routed: every worker runs on that model, at the effort Claude Code's `settings.json` gives. Each cycle of a project on a ladder of its own says so on stderr, naming the file, and says where the worker's model is off it. `build-release --help` shows the file's shape.
@@ -227,16 +227,16 @@ It applies only those commits on the newest tag, tests them with `ci.sh`, tags a
## Tools
build-release, do-epic and `task-bench gather` put the release's tools first on the `PATH` of every claude they start, so this README and the rules name each tool bare, as in `metric-bench`. Install puts only `build-release` on your shell's `PATH`: there, and in a claude you start from it yourself, call another by its path, `~/.claude/bin/<tool>`, from the project's checkout. The tools under `~/.claude` are the release's; test a change to one from `~/code/claude-config/bin`. The tools are listed in alphabetical order, and the packages under `bin/` follow under their own heading.
build-release, build-epic and `task-bench gather` put the release's tools first on the `PATH` of every claude they start, so this README and the rules name each tool bare, as in `metric-bench`. Install puts only `build-release` on your shell's `PATH`: there, and in a claude you start from it yourself, call another by its path, `~/.claude/bin/<tool>`, from the project's checkout. The tools under `~/.claude` are the release's; test a change to one from `~/code/claude-config/bin`. The tools are listed in alphabetical order, and the packages under `bin/` follow under their own heading.
- `build-epic <EPIC-KEY>` runs the chunks of one Jira epic whose items span repos, or have none, each in its own window of the tmux session `epic-<EPIC-KEY>`, on the same cycle, judge and interrupt as build-release. The epic's description is its record: goals, audience, scoring and decisions. Before it starts chunks, build-epic plans each open issue that no label places yet, as "Set up a project" says. It files a sub-task per repo where the issue changes several repos. Otherwise it labels the issue with where it is worked, and asks you where that is unclear. It plans no issue your team filed a sub-task under: those sub-tasks run instead, each under a label of its own, and your team closes the issue. Then, where two or more issues may start, it scores each of them that holds no scores, and moves the issues that build-epic itself filed into order of score on the board. An open issue runs once a label names its repo or marks it as Claude's, in order of score, as many at once as a line such as `**Max parallel chunks:** 2` in the epic's description allows, 1 without it, and as each repo's `parallel-chunks` allows. A chunk whose pull request waits on a gate parks. An open task of yours that blocks another issue gets a window that DMs you once and reads the epic every minute; once you close the task, the issues it blocked may start. `build-epic <EPIC-KEY> --dry-run` prints what `build-epic <EPIC-KEY>` would write to Jira and which chunks it would start, and does neither; run it before the first real run on a team's epic. `--help` lists what it prints and leaves out. build-epic closes the epic only once you confirm every goal. Install → "Set up a project" says how to set it up; `build-epic --help` states the flags and the contract.
- `build-epic-e2e` runs `build-epic` against a sandbox epic on a real Jira site, as Test says.
- `build-release <task>` runs a project's next chunks, each in its own tmux window, cycle after cycle; `build-release --help` states its contract.
- `chunk-pr open|sync|ready|push|merge|clean|open-epic` opens a chunk's pull request as a draft, brings its branch level with origin's default branch, marks it ready and merges it once its checks pass, with `gh` on a GitHub origin and `tea` elsewhere. Where the project's config sets `epic-branch`, the pull request goes into the epic's working branch instead, `push` pushes later commits and asks the auto-reviewer for a review, and `open-epic` opens the pull request from that branch into the default branch. The chunks of one project merge one at a time: in its turn, `merge` brings the branch level again, finishes the plan items its `--finish` flags name, and waits for the checks. Under `merge = "human"` it then marks the pull request ready and leaves the merge to a person. Once the pull request is merged, `clean` removes the chunk's worktree and branch and fast-forwards the main checkout. `chunk-pr --help` states the steps.
- `chunk-preflight` finds the mechanical facts a chunk starts from, and with `--worktree` makes its worktree; `build-release` runs it with `--worktree` before it routes each chunk, and `chunk-preflight --help` lists the facts.
- `command-patterns [<version>] [--calls <file>]` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release, and with `--calls <file>` saves each call as a JSON line; `command-patterns --help` states the columns and the line's keys.
- `compress-archives` gzips each transcript in build-release's archive and each file in the review folders 30 days after it last changed, keeping all of them; Install's crontab line runs it daily.
- `deploy-release [--cut | --cut-patch <commits>] [<checkout>]` moves `~/.claude`, or the checkout named, to the newest release, as Update says; with `--cut`, run in the development clone, it first cuts the next release, and with `--cut-patch`, a patch release of only the commits named, as Release says.
- `do-epic <EPIC-KEY>` runs the chunks of one Jira epic whose items span repos, or have none, each in its own window of the tmux session `epic-<EPIC-KEY>`, on the same cycle, judge and interrupt as build-release. The epic's description is its record: goals, audience, scoring and decisions. Before it starts chunks, do-epic plans each open issue that no label places yet, as "Set up a project" says. It files a sub-task per repo where the issue changes several repos. Otherwise it labels the issue with where it is worked, and asks you where that is unclear. It plans no issue your team filed a sub-task under: those sub-tasks run instead, each under a label of its own, and your team closes the issue. Then, where two or more issues may start, it scores each of them that holds no scores, and moves the issues that do-epic itself filed into order of score on the board. An open issue runs once a label names its repo or marks it as Claude's, in order of score, as many at once as a line such as `**Max parallel chunks:** 2` in the epic's description allows, 1 without it, and as each repo's `parallel-chunks` allows. A chunk whose pull request waits on a gate parks. An open task of yours that blocks another issue gets a window that DMs you once and reads the epic every minute; once you close the task, the issues it blocked may start. `do-epic <EPIC-KEY> --dry-run` prints what `do-epic <EPIC-KEY>` would write to Jira and which chunks it would start, and does neither; run it before the first real run on a team's epic. `--help` lists what it prints and leaves out. do-epic closes the epic only once you confirm every goal. Install → "Set up a project" says how to set it up; `do-epic --help` states the flags and the contract.
- `do-epic-e2e` runs `do-epic` against a sandbox epic on a real Jira site, as Test says.
- `judge-replay <model> [--offline]` replays build-release's judge on archived verdicts of the projects run on the model. It prints what each rung a review climbs to misses, and the lowest rung below those that returns every verdict, as each candidate above it does. With `--offline` it doesn't call a judge: it counts what a "?" rule, a decision table and a classifier trained on the archive decide of each verdict's kind from the worker's final message, and how many interrupts each misses. `judge-replay --help` states both replays.
- `larv-review <command>` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count and the opening of its round commit's title, the scoring run's trigger and setup; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts. A reviewer under `agents/` whose frontmatter has `omitClaudeMd: true` starts without `CLAUDE.md`, and the command hands it that file's "Shared goal", "Prose" and "Vocabulary" sections.
- `markdown-section <file> <fragment>` prints the section of a markdown file under the first heading that holds the fragment, to the next heading of its level or a higher one, instead of a `grep -n` and a guessed `sed -n` range; `markdown-section --help` says what it does where several headings match.
@@ -266,11 +266,9 @@ build-release, do-epic and `task-bench gather` put the release's tools first on
#### Driving chunks
- `agent_cycle/` runs one cycle (`run.py`): a headless claude worker, then the judge of its transcript. It also holds the interrupt, the tmux window and the routing of the worker's rung. The entry point that runs the cycles supplies the prompts and file names of its own workflow (`worker_prompts.py`), and reads which items a worker took in. `build_release` and `do_epic` drive it; `agent_cycle` doesn't import either.
- `build_release` runs `chunk-preflight` as a process of its own.
- `chunk_driver/` holds what the entry points share. An entry point is a tool that drives chunks through `agent_cycle`: `build_release` and `do_epic` are the two. They share how a cycle starts (`cycle_start.py`) and closes (`chunk_run.py`), the claim on a checkout before a chunk starts in it (`claims.py`), the prompts every worker gets (`prompts.py`), and a checkout's premises, records and saved models (`project/`). It imports neither entry point, and `repo_checks` fails any package that imports one of the two. `agent_cycle` is the layer below it, and `repo_checks` fails `agent_cycle` where it imports `chunk_driver`, tests included.
- `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`. `epic_run.py` holds what stays the same through one run of do-epic, such as its config, its Jira store and its paths, and starts the chunks that may start now.
- `agent_cycle/` runs one cycle (`run.py`): a headless claude worker, then the judge of its transcript. It also holds the interrupt, the tmux window and the routing of the worker's rung. The entry point that runs the cycles supplies the prompts and file names of its own workflow (`worker_prompts.py`), and reads which items a worker took in. `build_release` and `build_epic` drive it; `agent_cycle` doesn't import either.
- `build_epic/` holds `build-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`. `epic_run.py` holds what stays the same through one run of build-epic, such as its config, its Jira store and its paths, and starts the chunks that may start now.
- `planning.py` settles, before the chunks start, where each open issue is worked, its scores and the order the issues start in, through `split.py`, `repo_pick.py`, `issue_scores.py` and `ranking.py`.
- `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 build-release 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. `parking.py` parks such a chunk after a cycle and polls the gate until its worker has something to do, or until its pull request merged, when it removes the worktree with `chunk-pr clean` and finishes the chunk itself.
@@ -283,10 +281,12 @@ build-release, do-epic and `task-bench gather` put the release's tools first on
- `parent_moves.py` moves a parent whose sub-tasks a person filed, once those have landed or are done.
- `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, moves a finished chunk's issue to done, and closes the epic.
- `e2e/` holds `do-epic-e2e`.
- `loop_effects/` holds `Effects`: the processes, terminal, clock and git a tool reaches, injected so its tests can script them. build-release, do-epic, both replay tools and `reviewer-merge-trials`' driver use it.
- `e2e/` holds `build-epic-e2e`.
- `build_release` runs `chunk-preflight` as a process of its own.
- `chunk_driver/` holds what the entry points share. An entry point is a tool that drives chunks through `agent_cycle`: `build_epic` and `build_release` are the two. They share how a cycle starts (`cycle_start.py`) and closes (`chunk_run.py`), the claim on a checkout before a chunk starts in it (`claims.py`), the prompts every worker gets (`prompts.py`), and a checkout's premises, records and saved models (`project/`). It imports neither entry point, and `repo_checks` fails any package that imports one of the two. `agent_cycle` is the layer below it, and `repo_checks` fails `agent_cycle` where it imports `chunk_driver`, tests included.
- `loop_effects/` holds `Effects`: the processes, terminal, clock and git a tool reaches, injected so its tests can script them. build-release, build-epic, both replay tools and `reviewer-merge-trials`' driver use it.
- `loop_state/` holds `paths.py`, the one module under `bin/` that resolves the setup's folders: the release root, which is the folder the running code ships in, the Claude home, the config folder and the state folder. `repo_checks` fails another module under `bin/`, tests aside, that names one as a quoted path part, such as `".claude"`, or finds the release root from `__file__`.
- `model_routing/` holds the shipped routing ladder (`routing-ladder.json`) and its steps (`ladder.py`), and reads a ladder from that file or a project's own (`ladder_file.py`), for build-release, `rule_hook`, `do_epic`, both replay tools and `subagent-rung`. It finds a project's config folder through `project_config`. It also holds the list prices, which `routing_figures` and `transcript_archive` read.
- `model_routing/` holds the shipped routing ladder (`routing-ladder.json`) and its steps (`ladder.py`), and reads a ladder from that file or a project's own (`ladder_file.py`), for build-release, `build_epic`, `rule_hook`, both replay tools and `subagent-rung`. It finds a project's config folder through `project_config`. It also holds the list prices, which `routing_figures` and `transcript_archive` read.
- `notifier/` sends the human a DM through the notifier a project's config names, for `notify` and for build-release through `loop_effects`. Its backends are `mattermost.py` and `slack.py`.
- `transcript_archive/` stores build-release's transcripts. Its `project_key.py` names each project's archive folder, build-release session and models-file entry.
@@ -302,8 +302,8 @@ build-release, do-epic and `task-bench gather` put the release's tools first on
#### Git, forges and Atlassian
- `adf_codec/` converts markdown to ADF, the rich text of Jira Cloud and Confluence, and back, in a throwaway container running a pinned `@larvit/adf-codec`. It builds the container's image inside a heavy slot.
- `atlassian/` holds what the Jira and Confluence backends share (`client.py`): one Atlassian account's credentials, the request both backends send, and each service's error messages. `jira.py` holds what every reader of Jira shares: a search read page by page, the key, fields, links and property of each issue it finds, checked for their shape, and the transition that finishes an issue, for `plan_store` and `do_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`), finds a pull request, lists the ready ones and reads its checks, once or until they settle (`pulls.py`), and reads a pull request's review state (`reviews.py`), for `chunk_preflight`, `chunk_pr`, `deploy_release`, `do_epic` and `larv_review`.
- `atlassian/` holds what the Jira and Confluence backends share (`client.py`): one Atlassian account's credentials, the request both backends send, and each service's error messages. `jira.py` holds what every reader of Jira shares: a search read page by page, the key, fields, links and property of each issue it finds, checked for their shape, and the transition that finishes an issue, for `plan_store` and `build_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`), finds a pull request, lists the ready ones and reads its checks, once or until they settle (`pulls.py`), and reads a pull request's review state (`reviews.py`), for `build_epic`, `chunk_preflight`, `chunk_pr`, `deploy_release` and `larv_review`.
- `git_cli/` runs git for every tool (`git_repo.py`), reads the git calls in a shell command (`git_command.py`), and keeps an epic's working branch level with the default branch (`epic_branch.py`).
- `rest_client/` sends a JSON request to a REST API and reads its credentials from an env file, for `notifier`, `atlassian` and `record_store`.
@@ -331,7 +331,7 @@ build-release, do-epic and `task-bench gather` put the release's tools first on
Test on the host with `bin/run-tests`, which runs pytest through `uvx`, pinned in `bin/run_tests/main.py`. It prints each failing test with its error and pytest's summary line, and saves the whole output to a file whose path it prints. It passes on any test paths or pytest options it is given, such as `bin/run-tests bin/chunk_pr -x`. It needs `uv` on `PATH`, which fetches pytest, pytest-xdist and mypy, a Docker daemon, Linux, and a user other than root; a test that lacks one fails, naming it. pytest-xdist runs the tests in one worker per CPU of a heavy slot (`docs/decisions.md` → `bin/: the tools support only the latest stable Python, …`). `python3 -m unittest discover -s bin -p 'test_*.py'` runs the same tests one at a time, with the same needs. Test the bench's scripts with `python3 -m unittest discover -s workflow-bench -p 'test_*.py'`.
`bin/do-epic-e2e` checks `do-epic` against a real Jira site, which `run-tests` never reaches. It makes an epic with issues and sub-tasks in a sandbox project, runs `do-epic --file`, `--record-decision` and `--close-epic` against it in a home folder of its own, and deletes the epic and its issues when it ends. The sandbox project must be team-managed, with a `Done` transition, and its account must be able to create, edit, transition, comment on and delete issues there. Set `DO_EPIC_E2E_JIRA_URL` to the sandbox site's address, `DO_EPIC_E2E_ENV_FILE` to the absolute path of the file holding the account's `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, and `DO_EPIC_E2E_PROJECT` to the project's key. The command fails, naming each setting that is missing. It needs a Docker daemon, as `run-tests` does.
`bin/build-epic-e2e` checks `build-epic` against a real Jira site, which `run-tests` never reaches. It makes an epic with issues and sub-tasks in a sandbox project, runs `build-epic --file`, `--record-decision` and `--close-epic` against it in a home folder of its own, and deletes the epic and its issues when it ends. The sandbox project must be team-managed, with a `Done` transition, and its account must be able to create, edit, transition, comment on and delete issues there. Set `BUILD_EPIC_E2E_JIRA_URL` to the sandbox site's address, `BUILD_EPIC_E2E_ENV_FILE` to the absolute path of the file holding the account's `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, and `BUILD_EPIC_E2E_PROJECT` to the project's key. The command fails, naming each setting that is missing. It needs a Docker daemon, as `run-tests` does.
The commands in this section name their tools bare, as Tools says. CI runs `ci.sh` on every pull request, and `main` doesn't merge anything until it passes. The script runs the same tests on the committed HEAD in a pinned Python container. Run it under `run-heavy` to reproduce a CI failure, with Docker on `PATH` and its socket at `/var/run/docker.sock`, which the container shares.
+1 -1
View File
@@ -1,4 +1,4 @@
"""One cycle of a headless claude worker and the judge of its transcript, for every entry point that drives such cycles: build-release and do-epic (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""One cycle of a headless claude worker and the judge of its transcript, for every entry point that drives such cycles: build-release and build-epic (docs/decisions.md → `build-epic: drives one Jira epic …`).
run.py runs a cycle through the states in states.py: worker.py runs the worker, judge.py rules on its transcript, interrupt.py puts a question to the human in the tmux window tmux.py names, and routing.py picks the rung the worker runs on next. An entry point hands the cycle what is its own: its prompts and file names (worker_prompts.py) and how it reads the plan items a worker took in (run.py's Cycle.taken_in). What two entry points share beyond the cycle lives in bin/chunk_driver/. No module here imports an entry point's package, and bin/repo_checks/test_package_cycles.py fails on such an import. A reader finds a module by its name, so the modules stay at one level. docs/decisions.md → `principles: about seven things per level, …` allows that.
"""
+1 -1
View File
@@ -20,7 +20,7 @@ STEP_TAG = "[step]"
def asks_higher_rung(driver: str) -> str:
"""How a worker's run ends where it wants the rest of its chunk on a higher rung. The worker's prompt tells it to, and the judge's rules name the same words, so both take them from here. driver is the entry point that drives the cycle, such as `do-epic`."""
"""How a worker's run ends where it wants the rest of its chunk on a higher rung. The worker's prompt tells it to, and the judge's rules name the same words, so both take them from here. driver is the entry point that drives the cycle, such as `build-epic`."""
return f"asking {driver} for a higher rung"
+1 -1
View File
@@ -155,7 +155,7 @@ class Brief(typing.NamedTuple):
entries: list[Entry]
# How many of the entries the session held when an escalation last stepped the worker up a rung, 0 before any.
escalated_at: int
# The entry point's name, such as `do-epic`, as WorkerPrompts.driver has it.
# The entry point's name, such as `build-epic`, as WorkerPrompts.driver has it.
driver: str
+1 -1
View File
@@ -43,7 +43,7 @@ JUDGE_REPLAYED = ("claude-opus-5-5",)
class Scored(typing.Protocol):
"""What routes a chunk: a plan item under build-release, an epic's issue under do-epic."""
"""What routes a chunk: a plan item under build-release, an epic's issue under build-epic."""
@property
def id(self) -> int:
"""The number a Route keeps as its item."""
+1 -1
View File
@@ -14,7 +14,7 @@ def needs_human(need: str, blocker: str) -> Stop:
def needs_terminal(need: str, on_terminal: bool, driver: str) -> Stop | None:
"""driver is the entry point the human reruns, such as `do-epic`."""
"""driver is the entry point the human reruns, such as `build-epic`."""
if on_terminal:
return None
return needs_human(need, f"stdin or stdout is not a terminal; rerun {driver} on a terminal")
+5 -5
View File
@@ -1,4 +1,4 @@
"""The tmux commands an entry point runs: each chunk's loop runs in its own window of one tmux session, which build-release names for the project and do-epic for the epic (docs/decisions.md → `build-release: each chunk runs in its own tmux window`)."""
"""The tmux commands an entry point runs: each chunk's loop runs in its own window of one tmux session, which build-release names for the project and build-epic for the epic (docs/decisions.md → `build-release: each chunk runs in its own tmux window`)."""
import dataclasses
import re
import subprocess
@@ -14,14 +14,14 @@ NEEDED = (3, 2)
# What a window's name ends in while its chunk waits for the human. tmux's status bar shows the name, and `!` after it once the bell rang.
WAITS = " ?"
BELL = "\a"
# What follows a window's name while its chunk is parked, before what its pull request waits on, as in `ABC-34 awaits an approval`. A parked chunk takes no running slot (docs/decisions.md → `do-epic: drives one Jira epic …`, "Long gates").
# What follows a window's name while its chunk is parked, before what its pull request waits on, as in `ABC-34 awaits an approval`. A parked chunk takes no running slot (docs/decisions.md → `build-epic: drives one Jira epic …`, "Long gates").
PARKED = " awaits "
# What a session's name opens with: LOOP for a project's chunks under build-release, EPIC for an epic's chunks under do-epic.
# What a session's name opens with: LOOP for a project's chunks under build-release, EPIC for an epic's chunks under build-epic.
LOOP = "loop"
EPIC = "epic"
# The session option that names the checkout whose chunks the session runs, since two checkouts' keys may map to one session name.
OWNER = "@loop-root"
# The window option that names the folder a window's chunk works in, so that build-release and every do-epic see the chunks a do-epic runs in a checkout.
# The window option that names the folder a window's chunk works in, so that build-release and every build-epic see the chunks a build-epic runs in a checkout.
ROOT = "@chunk-root"
@@ -113,7 +113,7 @@ def start_window(window: Window, cwd: str, env: typing.Mapping[str, str], comman
return Failure(f"tmux could not start the window {window.target}: {done.stderr.strip() or f'it exited {done.returncode}'}")
# set-option and show-options read a target as a pane's, so `=session` alone names no session.
marked = run(["set-option", "-t", f"={window.session}:", OWNER, cwd]) if first and owned else None
# A failure leaves the window unseen by build-release and by another epic's do-epic, which then may start a chunk beside it; the window still runs.
# A failure leaves the window unseen by build-release and by another epic's build-epic, which then may start a chunk beside it; the window still runs.
run(["set-option", "-w", "-t", done.stdout.strip(), ROOT, cwd])
# By the ID, since a window of the same name may still be closing. A failed remain-on-exit doesn't matter: a loop that fails before it is set closes its window, and its stop is still sent as a DM.
run(["set-option", "-w", "-t", done.stdout.strip(), "remain-on-exit", "failed"])
+1 -1
View File
@@ -33,7 +33,7 @@ def typed_answer(prompt: str) -> Typed | None:
@dataclasses.dataclass(frozen=True)
class WorkerPrompts:
"""What an entry point supplies to the prompts of its cycles."""
# The entry point's name as the worker, the judge and the human read it, such as `do-epic`.
# The entry point's name as the worker, the judge and the human read it, such as `build-epic`.
driver: str
# The prompt that starts a worker, from its task, the premises, its route, the project's rung and the facts found before the cycle.
fresh: typing.Callable[[str, str, Route, ProjectRung | None, str], str]
+1 -1
View File
@@ -7,7 +7,7 @@ LAUNCHER = pathlib.Path(__file__).resolve()
sys.path.insert(0, str(LAUNCHER.parent))
from loop_effects import effects
from do_epic import main
from build_epic import main
from loop_state import paths
sys.exit(main.main(sys.argv[1:], os.environ, paths.paths_from(pathlib.Path.home(), os.environ), LAUNCHER, effects.system_effects(pathlib.Path.home(), os.environ)))
+2 -2
View File
@@ -6,6 +6,6 @@ import sys
LAUNCHER = pathlib.Path(__file__).resolve()
sys.path.insert(0, str(LAUNCHER.parent))
from do_epic.e2e import main, sandbox, scenario
from build_epic.e2e import main, sandbox, scenario
sys.exit(main.main(sys.argv[1:], os.environ, LAUNCHER.parent / "do-epic", sandbox.epic_made, scenario.run))
sys.exit(main.main(sys.argv[1:], os.environ, LAUNCHER.parent / "build-epic", sandbox.epic_made, scenario.run))
@@ -2,7 +2,7 @@
import re
import typing
from do_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
@@ -1,7 +1,7 @@
"""An epic held in memory, for do-epic's tests and its `--dry-run`, held to contract.py like every backend."""
"""An epic held in memory, for build-epic's tests and its `--dry-run`, held to contract.py like every backend."""
import dataclasses
from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, unfit, unfit_label
from build_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, unfit, unfit_label
from failure import Failure
@@ -15,7 +15,7 @@ class MemoryEpic:
done: bool = False
writes: list[str] = dataclasses.field(default_factory=list)
# The display name of the account the epic's issues are started as.
account: str = "do-epic"
account: str = "build-epic"
def read(self) -> list[EpicIssue] | Failure:
if self.fails:
@@ -8,16 +8,16 @@ from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
from plan_store.jira_epic import BLOCKS, FILED_BY, scores as held_scores, PROPERTY
from project_config.settings import DEFAULT_ISSUE_TYPE, Epic, Finish, JIRA_FINDING_TYPE, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION, JIRA_REVIEW_TYPE
from atlassian.jira import DONE, edit_issue, entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, issue_types_of, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, SHAPE, status_category, unshaped
from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, REVIEW_LABEL, unfit, unfit_label
from build_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, REVIEW_LABEL, unfit, unfit_label
from failure import Failure
from do_epic.backend.jira_status import moved_by, moved_to
from build_epic.backend.jira_status import moved_by, moved_to
from plan.todo_table import MOVES
from do_epic.backend.jira_start import Start, started
from build_epic.backend.jira_start import Start, started
FIELDS = ["summary", "description", "labels", "assignee", "status", "parent", "issuelinks"]
# How many child issues one search for sub-tasks names, which keeps its JQL well inside the length Jira takes.
PARENTS_PER_SEARCH = 50
NO_FINISH = "do-epic's settings name no transition to {to} by: set `{transition}` and `{status}` in do-epic's config.toml (`do-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""
NO_FINISH = "build-epic's settings name no transition to {to} by: set `{transition}` and `{status}` in build-epic's config.toml (`build-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""
@dataclasses.dataclass(frozen=True)
@@ -6,7 +6,7 @@ from failure import Failure
from atlassian.client import Http
from atlassian.jira import offers_of, unshaped
# Three readers, seated as those who write and read do-epic's config, picked both spellings from four candidates each, 3-0. `jira-start-transition` pairs with `jira-finish-transition`. `jira-board`, a candidate they turned down, reads as the board do-epic takes its issues from.
# Three readers, seated as those who write and read build-epic's config, picked both spellings from four candidates each, 3-0. `jira-start-transition` pairs with `jira-finish-transition`. `jira-board`, a candidate they turned down, reads as the board build-epic takes its issues from.
START_TRANSITION = "jira-start-transition"
SPRINT_BOARD = "jira-sprint-board"
# The key of the category Jira gives each status at which an issue's work hasn't started.
@@ -58,10 +58,10 @@ def assigned(site: str, key: str, held: Held, authorization: str, http: Http) ->
"""Assigns the issue named key to the account authorization names, unless someone holds it. The display name of someone else who holds it, else None."""
me = http("GET", f"{site}/rest/api/3/myself", authorization, None)
if isinstance(me, Failure):
return Failure(f"cannot read which account do-epic works as, to assign {key}: {me.reason}")
return Failure(f"cannot read which account build-epic works as, to assign {key}: {me.reason}")
account = me.get("accountId") if isinstance(me, dict) else None
if not isinstance(account, str):
return Failure(f"cannot assign {key}: Jira named no account ID for the account do-epic works as")
return Failure(f"cannot assign {key}: Jira named no account ID for the account build-epic works as")
if held.holder is not None:
return None if held.holder[0] == account else held.holder[1]
put = http("PUT", f"{site}/rest/api/3/issue/{key}/assignee", authorization, {"accountId": account})
@@ -1,6 +1,6 @@
"""What every backend of an epic's plan reads, files, labels, comments on and ranks: an EpicIssue, and the EpicStore protocol they all meet. do-epic reads an epic only through EpicStore, so another tracker can stand behind it; contract.py holds the tests every backend passes.
"""What every backend of an epic's plan reads, files, labels, comments on and ranks: an EpicIssue, and the EpicStore protocol they all meet. build-epic reads an epic only through EpicStore, so another tracker can stand behind it; contract.py holds the tests every backend passes.
EpicStore is not plan_store's PlanStore. A PlanStore item names a release, but an epic item has none (`docs/decisions.md` → `do-epic: drives one Jira epic …`), and it may be a sub-task."""
EpicStore is not plan_store's PlanStore. A PlanStore item names a release, but an epic item has none (`docs/decisions.md` → `build-epic: drives one Jira epic …`), and it may be a sub-task."""
import dataclasses
import re
import typing
@@ -10,7 +10,7 @@ from failure import Failure
from plan_store.jira_epic import SET_SCORES
# 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"
REVIEW_LABEL = "build-epic-release-review"
# What a tracker accepts as a label: Jira refuses a label holding white space.
LABEL = re.compile(r"\S+")
@@ -4,11 +4,11 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from do_epic.backend.protocol import EpicIssue, no_blocker
from do_epic.backend.contract import EpicStoreContract
from build_epic.backend.protocol import EpicIssue, no_blocker
from build_epic.backend.contract import EpicStoreContract
from failure import Failure
from plan_store import jira_epic
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
class MemoryEpicContract(EpicStoreContract, unittest.TestCase):
@@ -9,12 +9,12 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from project_config.settings import Epic, Finish
from do_epic.backend.contract import EpicStoreContract
from build_epic.backend.contract import EpicStoreContract
from failure import Failure
from do_epic.backend.jira import JiraEpic
from build_epic.backend.jira import JiraEpic
from adf_codec.convert import Refused
from do_epic.backend.protocol import REVIEW_LABEL
from do_epic.backend.jira_start import Start
from build_epic.backend.protocol import REVIEW_LABEL
from build_epic.backend.jira_start import Start
SITE = "https://acme.atlassian.net"
EPIC = Epic(SITE, "ABC-12")
@@ -28,7 +28,7 @@ TO_DO = {"name": "To Do", "statusCategory": {"key": "new"}}
DONE = {"name": "Done", "statusCategory": {"key": "done"}}
IN_PROGRESS = {"name": "In Progress", "statusCategory": {"key": "indeterminate"}}
MYSELF = f"{SITE}/rest/api/3/myself"
ME = {"accountId": "712020:do-epic", "displayName": "Do Epic"}
ME = {"accountId": "712020:build-epic", "displayName": "Build Epic"}
ACTIVE_SPRINTS = f"{SITE}/rest/agile/1.0/board/6/sprint?state=active"
SPRINT_ISSUES = f"{SITE}/rest/agile/1.0/sprint/77/issue"
TRANSITIONS = f"{ISSUES}/ABC-12/transitions"
@@ -228,7 +228,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` in do-epic's config.toml (`do-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""),
(unnamed, "build-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in build-epic's config.toml (`build-epic --help` says where), 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"),
):
@@ -349,9 +349,9 @@ class Jira(Case):
for answers, reason in (
({("GET", f"{ISSUES}/{key}?fields=assignee,status"): Failure("Jira answered 503")}, f"cannot read {key} to start it: Jira answered 503"),
({("GET", f"{ISSUES}/{key}?fields=assignee,status"): {"fields": {"assignee": None}}}, f"{key} is not in the shape Jira Cloud's REST API version 3 documents: KeyError('status')"),
({("GET", MYSELF): Failure("Jira answered 503")}, f"cannot read which account do-epic works as, to assign {key}: Jira answered 503"),
({("GET", MYSELF): {"displayName": "Do Epic"}}, f"cannot assign {key}: Jira named no account ID for the account do-epic works as"),
({("GET", MYSELF): ["Do Epic"]}, f"cannot assign {key}: Jira named no account ID for the account do-epic works as"),
({("GET", MYSELF): Failure("Jira answered 503")}, f"cannot read which account build-epic works as, to assign {key}: Jira answered 503"),
({("GET", MYSELF): {"displayName": "Build Epic"}}, f"cannot assign {key}: Jira named no account ID for the account build-epic works as"),
({("GET", MYSELF): ["Build Epic"]}, f"cannot assign {key}: Jira named no account ID for the account build-epic works as"),
({("PUT", assignee): Failure("Jira answered 403")}, f"cannot assign {key}: Jira answered 403"),
({("GET", transitions): Failure("Jira answered 503")}, f"cannot read {key}'s transitions: Jira answered 503"),
({("GET", transitions): {"transitions": [{"id": "21"}]}}, f"Jira answered {key}'s transitions in a shape other than the one it documents"),
@@ -383,7 +383,7 @@ class Jira(Case):
self.jira.answers = {("POST", f"{ISSUES}/{key}/transitions"): Failure("Jira answered 400"), ("POST", SPRINT_ISSUES): Failure("Jira answered 403")}
self.assertEqual(store.start_issue(key), Failure(f"cannot move {key} by 'Start': Jira answered 400; cannot add {key} to the active sprint of board 6: Jira answered 403; {key} stays assigned to Ada Berg"))
self.jira.answers = {("GET", MYSELF): Failure("Jira answered 503"), ("POST", SPRINT_ISSUES): Failure("Jira answered 403")}
self.assertEqual(store.start_issue(key), Failure(f"cannot read which account do-epic works as, to assign {key}: Jira answered 503; cannot add {key} to the active sprint of board 6: Jira answered 403"))
self.assertEqual(store.start_issue(key), Failure(f"cannot read which account build-epic works as, to assign {key}: Jira answered 503; cannot add {key} to the active sprint of board 6: Jira answered 403"))
self.jira.change(key, assignee=ME)
self.jira.answers = {("POST", SPRINT_ISSUES): Failure("Jira answered 403")}
self.assertEqual(store.start_issue(key), Failure(f"cannot add {key} to the active sprint of board 6: Jira answered 403"))
@@ -523,7 +523,7 @@ class Jira(Case):
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("Mark as done", "Closed"))
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
self.assertEqual(unnamed.finish_issue(key), Failure("do-epic's settings name no transition to finish an issue by: set `jira-finish-transition` and `jira-finish-status` in do-epic's config.toml (`do-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""))
self.assertEqual(unnamed.finish_issue(key), Failure("build-epic's settings name no transition to finish an issue by: set `jira-finish-transition` and `jira-finish-status` in build-epic's config.toml (`build-epic --help` says where), to the names Jira shows, such as \"Mark as done\" and \"Done\""))
self.assertEqual(wrong_status.finish_issue(key), Failure(f"{key}'s transition 'Mark as done' leads to the status 'Done', not to 'Closed', which `jira-finish-status` names"))
refused = no_such.finish_issue(key)
assert isinstance(refused, Failure)
@@ -1,11 +1,11 @@
"""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 build-release'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."""
"""What a build-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 build-release's cycles use, naming build-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 chunk_driver.drivers import DO_EPIC
from do_epic.backend.protocol import EpicIssue
from do_epic import findings
from chunk_driver.drivers import BUILD_EPIC
from build_epic.backend.protocol import EpicIssue
from build_epic import findings
from chunk_driver.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from do_epic.repo_pick import LabelRepos
from build_epic.repo_pick import LabelRepos
from text_files.markdown_text import listed
import pathlib
from project_config.settings import ProjectConfig
@@ -16,11 +16,11 @@ from project_config import templates
from agent_cycle.worker_prompts import WorkerPrompts
# The entry point's name as the worker, the judge and the human read it.
DRIVER = DO_EPIC
DRIVER = BUILD_EPIC
def shipping(config: ProjectConfig) -> str:
"""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"). Where the repo's config leaves the merge to a person, the worker ends its run on `chunk-pr merge`'s word, since do-epic parks the chunk until that merge ("Long gates")."""
"""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 → `build-epic: drives one Jira epic …`, "Releases"). Where the repo's config leaves the merge to a person, the worker ends its run on `chunk-pr merge`'s word, since build-epic parks the chunk until that merge ("Long gates")."""
opening = "The issue isn't an item of the repo's plan, so run `chunk-pr merge` without `--finish`."
if config.merge == "human" and config.epic_branch is None:
opening += " The repo's team merges its pull requests itself, so `chunk-pr merge` leaves the pull request ready for a person to merge: end your run when it says so."
@@ -40,7 +40,7 @@ def epic_branch_rule(config: ProjectConfig, epic: str) -> str:
def task(issue: EpicIssue, epic: str, team: LabelRepos, 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. team is the config's LABEL_REPOS table. 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."""
"""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. team is the config's LABEL_REPOS table. launcher is the build-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 = " ".join(filter(None, [shipping(config), epic_branch_rule(config, epic)])) 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}. {" ".join(filter(None, [findings.instructions(epic, launcher, language, team, issue), shipped]))} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
@@ -50,7 +50,7 @@ CODE_HEALTH = 'the setup\'s CLAUDE.md → "Shared goal"'
def fresh(task: str, premises: str, route: Route, project: ProjectRung | None, facts: str) -> str:
"""A chunk's first prompt. facts is empty: do-epic runs no preflight."""
"""A chunk's first prompt. facts is empty: build-epic runs no preflight."""
routed = f"{DRIVER} runs you on {route.rung}, routed by the issue's L of {route.likelihood}. Where a sentence below names item {route.item}, it means the issue." if route.item else ""
opening = " ".join(filter(None, [routed, *prompts.rung_sentences(DRIVER, route, project)]))
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one. {prompts.READING_RULE}\n\n{opening and f'{opening}{chr(10)}{chr(10)}'}The issue sets the chunk's scope. The goals below choose between ways to deliver that scope, and never widen it. The epic's goals rank first, then code health ({CODE_HEALTH}), then the repo's.\n\nFrom {premises}"
@@ -65,7 +65,7 @@ NAMES = prompts.RecordNames(
)
WORKER = prompts.worker_prompts(DRIVER, fresh, "", NAMES)
# What a worker that was parked does: with a reviewer's feedback, and with a pull request a person merged, as the decision asks (docs/decisions.md → `do-epic: drives one Jira epic …`, "Long gates").
# What a worker that was parked does: with a reviewer's feedback, and with a pull request a person merged, as the decision asks (docs/decisions.md → `build-epic: drives one Jira epic …`, "Long gates").
FEEDBACK = 'Where a reviewer left feedback, fix what is reasonable and push the fix, answer each other comment in its thread, and change the setup so our review would have caught the finding (the setup\'s CLAUDE.md → "Working loop", "Change the setup for each finding an outside reviewer raises on a PR, deterministic tools first"). Then merge the pull request as before. Where the pull request is merged already, run `chunk-pr clean` in its worktree instead, and finish the chunk; where it was closed without a merge, say so and end your run.'
@@ -1,6 +1,6 @@
"""do-epic's machine-wide settings: `do-epic/config.toml` in the config folder (`loop_state.paths.config_folder`), and `repo-rule.md` beside it.
"""build-epic's machine-wide settings: `build-epic/config.toml` in the config folder (`loop_state.paths.config_folder`), and `repo-rule.md` beside it.
One pair per machine, the same for every epic (docs/decisions.md → `do-epic: drives one Jira epic …`). The config is TOML:
One pair per machine, the same for every epic (docs/decisions.md → `build-epic: drives one Jira epic …`). The config is TOML:
jira-url = "https://acme.atlassian.net"
env-file = "~/.secrets/acme-jira.env"
@@ -16,15 +16,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 moves a finished chunk's issue and closes a finished epic, such as "Mark as done", and the status it leads to, such as "Done". A project's config names a plan item's the same way. Set both or neither; without them do-epic moves no issue to done and closes no epic.
- `jira-start-transition` names the workflow transition that moves an issue as its chunk starts, such as "In Progress". An issue whose work has started already, such as one in Code Review, keeps its status. Without it do-epic doesn't move a starting issue.
- `jira-sprint-board` is the ID of a Jira board, the number in the board's address, such as `6`. An issue whose chunk starts joins that board's active sprint; a sub-task's parent joins in its place. Without it do-epic doesn't add a starting issue to a sprint.
- `jira-finish-transition` and `jira-finish-status` name the workflow transition that moves a finished chunk's issue and closes a finished epic, such as "Mark as done", and the status it leads to, such as "Done". A project's config names a plan item's the same way. Set both or neither; without them build-epic moves no issue to done and closes no epic.
- `jira-start-transition` names the workflow transition that moves an issue as its chunk starts, such as "In Progress". An issue whose work has started already, such as one in Code Review, keeps its status. Without it build-epic doesn't move a starting issue.
- `jira-sprint-board` is the ID of a Jira board, the number in the board's address, such as `6`. An issue whose chunk starts joins that board's active sprint; a sub-task's parent joins in its place. Without it build-epic doesn't add a starting issue to a sprint.
- `jira-unblocking-statuses` lists the statuses at which an issue's work has landed though Jira doesn't count it done yet, such as `["Release Ready"]`, in upper or lower case. An issue in one of them takes no chunk and no longer blocks the issues it blocks. A status Jira counts as done always does both, listed or not.
- `jira-automation-moves-issues = true` says the team's own automation moves an issue when its pull request merges. do-epic then moves only the issue of a chunk without a repo, which has no pull request, and waits for the automation to move each other. It needs `jira-unblocking-statuses`, which then names the status the automation gives an issue whose pull request merged. false where left out.
- `jira-pull-request-open-status` and `jira-pull-request-merged-status` name the statuses do-epic itself gives an issue whose chunk merges into an epic's working branch, in a repo whose config sets `epic-branch` (`project-config --help`): the first once the chunk's pull request is open, such as `"Code Review"`, and the second once it has merged into that branch, such as `"Release Ready"`. A team's automation moves an issue only for a pull request into the default branch, so there do-epic makes both moves, whatever `jira-automation-moves-issues` says. `jira-unblocking-statuses` must list the second, and an issue that has it counts as done when the epic's release reviews and its finishing chunk fall due: both come before a person merges the working branch into the default branch. Without the first, do-epic doesn't move an issue as its pull request opens. Without the second, do-epic moves a finished chunk's issue to done. Where `jira-automation-moves-issues` is set, it stops instead and asks you to move the issue.
- `jira-finding-type` names the Jira issue type do-epic files a finding as, and `jira-review-type` the one it files a repo's release review as, such as `"Feature"` and `"Chore"`, for a Jira project that has no Task type. Task where left out. do-epic doesn't file anything where the project lacks the type, and says which types it has.
- `sub-task-summary` shapes the summary of each sub-task do-epic files for an issue that changes several repos, such as `"{label}: {Summary}"`. `{label}` is the team's label for the repo, else the repo's name, and `{Summary}` is the issue's summary with a capital first letter. It must hold `{Summary}`. Where left out, a summary is `[<repo>] <the issue's summary>`.
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself. Where several lines name one repo, do-epic writes the label of the first.
- `jira-automation-moves-issues = true` says the team's own automation moves an issue when its pull request merges. build-epic then moves only the issue of a chunk without a repo, which has no pull request, and waits for the automation to move each other. It needs `jira-unblocking-statuses`, which then names the status the automation gives an issue whose pull request merged. false where left out.
- `jira-pull-request-open-status` and `jira-pull-request-merged-status` name the statuses build-epic itself gives an issue whose chunk merges into an epic's working branch, in a repo whose config sets `epic-branch` (`project-config --help`): the first once the chunk's pull request is open, such as `"Code Review"`, and the second once it has merged into that branch, such as `"Release Ready"`. A team's automation moves an issue only for a pull request into the default branch, so there build-epic makes both moves, whatever `jira-automation-moves-issues` says. `jira-unblocking-statuses` must list the second, and an issue that has it counts as done when the epic's release reviews and its finishing chunk fall due: both come before a person merges the working branch into the default branch. Without the first, build-epic doesn't move an issue as its pull request opens. Without the second, build-epic moves a finished chunk's issue to done. Where `jira-automation-moves-issues` is set, it stops instead and asks you to move the issue.
- `jira-finding-type` names the Jira issue type build-epic files a finding as, and `jira-review-type` the one it files a repo's release review as, such as `"Feature"` and `"Chore"`, for a Jira project that has no Task type. Task where left out. build-epic doesn't file anything where the project lacks the type, and says which types it has.
- `sub-task-summary` shapes the summary of each sub-task build-epic files for an issue that changes several repos, such as `"{label}: {Summary}"`. `{label}` is the team's label for the repo, else the repo's name, and `{Summary}` is the issue's summary with a capital first letter. It must hold `{Summary}`. Where left out, a summary is `[<repo>] <the issue's summary>`.
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. build-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself. Where several lines name one repo, build-epic writes the label of the first.
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
import dataclasses
from collections.abc import Mapping
@@ -33,15 +33,15 @@ import re
import string
import types
from project_config.settings import anywhere, CONFIG, DEFAULT_ISSUE_TYPE, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINDING_TYPE, JIRA_FINISH, JIRA_REVIEW_TYPE, LANGUAGE, language_fault, lies_in, name_of, parsed, SITE, type_fault
from project_config.settings import anywhere, BUILD_EPIC, CONFIG, DEFAULT_ISSUE_TYPE, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINDING_TYPE, JIRA_FINISH, JIRA_REVIEW_TYPE, LANGUAGE, language_fault, lies_in, name_of, parsed, SITE, type_fault
from loop_state.paths import config_folder
from failure import Failure
from do_epic.backend.protocol import LABEL, REVIEW_LABEL
from do_epic.repo_pick import LabelRepos, of_label, REPO_NAME
from build_epic.backend.protocol import LABEL, REVIEW_LABEL
from build_epic.repo_pick import LabelRepos, of_label, REPO_NAME
from text_files.markdown_text import listed
from model_routing.ladder_file import read_ladder, SHIPPED
from do_epic.split import SPLIT_LABEL
from do_epic.backend.jira_start import SPRINT_BOARD, Start, START_TRANSITION
from build_epic.split import SPLIT_LABEL
from build_epic.backend.jira_start import SPRINT_BOARD, Start, START_TRANSITION
REPO_RULE = "repo-rule.md"
# Three readers, seated as the human who writes this config, picked these spellings from four candidates each, 3-0: `jira-url` over `site`, `clone-folder` over `repos-folder` (which reads as the folder of repos that already exist) and `repoless-model` over `no-repo-model`. `env-file` and `language` keep the names a project's config gives them.
@@ -51,10 +51,10 @@ CLONE_FOLDER = "clone-folder"
SETTINGS = (JIRA_URL, ENV_FILE, REPOLESS_MODEL)
# Three readers, seated as those who write and read this config, picked `label-repos` from four candidates, over `repo-aliases`, `repo-labels` and `team-labels`, 2-1. All three readers would misread `repo-labels` as mapping a repo to its label.
LABEL_REPOS = "label-repos"
# Three readers, seated as those who write and read this config, picked `jira-unblocking-statuses` from four candidates, 3-0, and `jira-automation-moves-issues` 2-1. `jira-unblock-statuses` reads as statuses do-epic moves an issue to, and `jira-finish-issues = false` as closing no epic either.
# Three readers, seated as those who write and read this config, picked `jira-unblocking-statuses` from four candidates, 3-0, and `jira-automation-moves-issues` 2-1. `jira-unblock-statuses` reads as statuses build-epic moves an issue to, and `jira-finish-issues = false` as closing no epic either.
UNBLOCKING_STATUSES = "jira-unblocking-statuses"
AUTOMATION_MOVES = "jira-automation-moves-issues"
# Three readers, seated as those who write and read this config, picked `jira-pull-request-open-status` from four candidates, 2-1, and the merged status's name was spelt to pair with it. Each names a status, not a transition as `jira-start-transition` does: do-epic takes whichever transition leads there.
# Three readers, seated as those who write and read this config, picked `jira-pull-request-open-status` from four candidates, 2-1, and the merged status's name was spelt to pair with it. Each names a status, not a transition as `jira-start-transition` does: build-epic takes whichever transition leads there.
PULL_OPEN_STATUS = "jira-pull-request-open-status"
PULL_MERGED_STATUS = "jira-pull-request-merged-status"
SUB_TASKS_LANDED_TRANSITION = "jira-sub-tasks-landed-transition"
@@ -65,8 +65,8 @@ LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTION
@dataclasses.dataclass(frozen=True)
class DoEpicConfig:
"""folder is `do-epic` in the config folder; repo_rule is `repo-rule.md`'s text."""
class BuildEpicConfig:
"""folder is `build-epic` in the config folder; repo_rule is `repo-rule.md`'s text."""
folder: pathlib.Path
jira_url: str
env_file: pathlib.Path
@@ -98,7 +98,7 @@ def label_repo_faults(table: object) -> list[str]:
if not isinstance(table, dict):
return [f"`{LABEL_REPOS}` is {table!r}, not a table of labels, such as `twu-4 = \"tenant-web-ui-4\"` under `[{LABEL_REPOS}]`"]
return [
*(f"`{LABEL_REPOS}` maps {label!r}, a label do-epic gives a meaning of its own" for label in table if of_label(label, {}) is not None or label in (REVIEW_LABEL, SPLIT_LABEL)),
*(f"`{LABEL_REPOS}` maps {label!r}, a label build-epic gives a meaning of its own" for label in table if of_label(label, {}) is not None or label in (REVIEW_LABEL, SPLIT_LABEL)),
*(f"`{label}` stands below `[{LABEL_REPOS}]`, so it is read as a label; move it above the table" for label in table if label in (*SETTINGS, *OPTIONAL)),
*(f"`{LABEL_REPOS}` maps {label!r}, which is no Jira label: a label holds no white space" for label in table if not LABEL.fullmatch(label)),
*(f"`{LABEL_REPOS}` maps {label!r} to {repo!r}, not a repo's name in letters, digits, dots, hyphens and underscores" for label, repo in table.items() if not (isinstance(repo, str) and REPO_NAME.fullmatch(repo))),
@@ -153,10 +153,10 @@ def workflow_faults(values: dict[str, object]) -> list[str]:
]
def load(home: pathlib.Path, env: Mapping[str, str], ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
"""The settings and the repo rule in the config folder; a Failure naming the file it can't read, else each missing or misspelt setting it finds, so that do-epic refuses to start."""
def load(home: pathlib.Path, env: Mapping[str, str], ladder_file: pathlib.Path = SHIPPED) -> BuildEpicConfig | Failure:
"""The settings and the repo rule in the config folder; a Failure naming the file it can't read, else each missing or misspelt setting it finds, so that build-epic refuses to start."""
configs = config_folder(env, home)
folder = configs / DO_EPIC
folder = configs / BUILD_EPIC
values = parsed(folder / CONFIG)
if isinstance(values, Failure):
return Failure(f"{values.reason}. {LISTED}")
@@ -205,4 +205,4 @@ def load(home: pathlib.Path, env: Mapping[str, str], ladder_file: pathlib.Path =
finding_type, review_type = (str(values.get(name, DEFAULT_ISSUE_TYPE)) for name in ISSUE_TYPES)
board = values.get(SPRINT_BOARD)
assert board is None or isinstance(board, int)
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values), types.MappingProxyType(labels), tuple(statuses), values.get(AUTOMATION_MOVES) is True, name_of(values.get(PULL_OPEN_STATUS)), name_of(values.get(PULL_MERGED_STATUS)), template, finding_type, review_type, Start(name_of(values.get(START_TRANSITION)), board), name_of(values.get(SUB_TASKS_LANDED_TRANSITION)))
return BuildEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values), types.MappingProxyType(labels), tuple(statuses), values.get(AUTOMATION_MOVES) is True, name_of(values.get(PULL_OPEN_STATUS)), name_of(values.get(PULL_MERGED_STATUS)), template, finding_type, review_type, Start(name_of(values.get(START_TRANSITION)), board), name_of(values.get(SUB_TASKS_LANDED_TRANSITION)))
@@ -1,11 +1,11 @@
"""What `do-epic <EPIC-KEY> --dry-run` runs planning and the scheduler on, in place of Jira, tmux and git: an in-memory copy of the epic that records each write, a tmux that starts no window and a git that clones no repo. The copy starts as the epic is in Jira, and tmux's windows are read as they are, so the run sees the epic and the chunks as they are now."""
"""What `build-epic <EPIC-KEY> --dry-run` runs planning and the scheduler on, in place of Jira, tmux and git: an in-memory copy of the epic that records each write, a tmux that starts no window and a git that clones no repo. The copy starts as the epic is in Jira, and tmux's windows are read as they are, so the run sees the epic and the chunks as they are now."""
import dataclasses
import subprocess
from do_epic.backend.protocol import EpicStore
from build_epic.backend.protocol import EpicStore
from failure import Failure
from git_cli.git_repo import Git
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
from agent_cycle.tmux import Tmux
# The tmux commands that only read. Each other command makes or changes a session or a window.
@@ -1,14 +1,14 @@
"""The do-epic-e2e command: runs do-epic's commands that need no tmux session and no worker against a sandbox epic on a real Jira site (docs/decisions.md → `do-epic: drives one Jira epic …`)."""
"""The build-epic-e2e command: runs build-epic's commands that need no tmux session and no worker against a sandbox epic on a real Jira site (docs/decisions.md → `build-epic: drives one Jira epic …`)."""
import pathlib
import sys
import typing
from failure import Failure
from do_epic.e2e import sandbox, scenario, settings
from build_epic.e2e import sandbox, scenario, settings
HELP = f"""usage: do-epic-e2e
HELP = f"""usage: build-epic-e2e
Makes an epic in the Jira sandbox, with issues and sub-tasks, drives do-epic against it and deletes it, whatever the outcome.
Makes an epic in the Jira sandbox, with issues and sub-tasks, drives build-epic against it and deletes it, whatever the outcome.
It reads three environment variables and fails, naming each that is missing:
{chr(10).join(f' {name}: {meaning}' for name, meaning in settings.MEANING.items())}
It prints a line per check, and exits 0 only where every check held."""
@@ -18,20 +18,20 @@ Run = typing.Callable[[settings.Sandbox, str, pathlib.Path, typing.Mapping[str,
def main(argv: list[str], env: typing.Mapping[str, str], launcher: pathlib.Path, epic_made: EpicMade, run: Run) -> int:
"""Runs do-epic-e2e: epic_made makes the sandbox epic, as sandbox.epic_made does, and run drives do-epic against it, as scenario.run does."""
"""Runs build-epic-e2e: epic_made makes the sandbox epic, as sandbox.epic_made does, and run drives build-epic against it, as scenario.run does."""
if argv:
print(HELP, file=sys.stdout if argv in (["-h"], ["--help"]) else sys.stderr)
return 0 if argv in (["-h"], ["--help"]) else 1
found = settings.read(env)
if isinstance(found, Failure):
print(f"do-epic-e2e cannot start: {found.reason}", file=sys.stderr)
print(f"build-epic-e2e cannot start: {found.reason}", file=sys.stderr)
return 1
report = scenario.Report()
left: sandbox.Leftover | None = None
try:
with epic_made(found, "do-epic e2e sandbox epic") as key:
with epic_made(found, "build-epic e2e sandbox epic") as key:
if isinstance(key, Failure):
print(f"do-epic-e2e: {key.reason}", file=sys.stderr)
print(f"build-epic-e2e: {key.reason}", file=sys.stderr)
return 1
print(f"Sandbox epic {key} in {found.jira_url}")
report = run(found, key, launcher, env)
@@ -44,5 +44,5 @@ def main(argv: list[str], env: typing.Mapping[str, str], launcher: pathlib.Path,
print(f"FAIL {line}")
print(f"{len(report.held)} held, {len(report.broke)} broke")
if left:
print(f"do-epic-e2e: {left}", file=sys.stderr)
print(f"build-epic-e2e: {left}", file=sys.stderr)
return 1 if report.broke or left else 0
@@ -5,22 +5,22 @@ import typing
from atlassian.client import basic_auth, Http, jira_json, ToAdf
from failure import Failure
from adf_codec.convert import markdown_to_adf
from do_epic.e2e.settings import Sandbox
from build_epic.e2e.settings import Sandbox
from atlassian.jira import searched
EPIC_TYPE = "Epic"
# How a team-managed project's workflow moves an issue to done, as do-epic's `jira-finish-transition` and `jira-finish-status` name it.
# How a team-managed project's workflow moves an issue to done, as build-epic's `jira-finish-transition` and `jira-finish-status` name it.
FINISH_TRANSITION = "Done"
FINISH_STATUS = "Done"
DESCRIPTION = """**Language:** English
## Goals
1. **Achieve:** Prove do-epic's commands against a real Jira site.
1. **Achieve:** Prove build-epic's commands against a real Jira site.
## Audience
The person who runs do-epic's e2e command.
The person who runs build-epic's e2e command.
"""
@@ -1,23 +1,23 @@
"""What the e2e command does to a sandbox epic: runs `do-epic --file`, `--record-decision` and `--close-epic`, each as a process of its own against the real Jira site, and checks what the site holds after each."""
"""What the e2e command does to a sandbox epic: runs `build-epic --file`, `--record-decision` and `--close-epic`, each as a process of its own against the real Jira site, and checks what the site holds after each."""
import dataclasses
import pathlib
import subprocess
import tempfile
import typing
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL
from build_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL
from loop_state.paths import config_folder, without_xdg_folders
from project_config.settings import Epic, Finish
from do_epic import epic_record, findings, finish
from build_epic import epic_record, findings, finish
from record_store.jira_description import EpicDescription
from do_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from do_epic.e2e.sandbox import FINISH_STATUS, FINISH_TRANSITION
from do_epic.backend.jira import JiraEpic
from build_epic.e2e.sandbox import FINISH_STATUS, FINISH_TRANSITION
from build_epic.backend.jira import JiraEpic
from model_routing.ladder_file import read_ladder, SHIPPED
from do_epic.e2e.settings import Sandbox
from build_epic.e2e.settings import Sandbox
# Seconds one do-epic command may take.
# Seconds one build-epic command may take.
TIMEOUT = 300
RULE = "A label that equals a repo's name names that repo.\n"
@@ -32,33 +32,33 @@ class Report:
(self.held if holds else self.broke).append(what)
class DoEpic(typing.Protocol):
"""What the steps run do-epic through: a Machine, or a stand-in in a test."""
class BuildEpic(typing.Protocol):
"""What the steps run build-epic through: a Machine, or a stand-in in a test."""
def do_epic(self, *args: str, stdin: str = "") -> subprocess.CompletedProcess[str]:
"""Runs `do-epic args`, feeding it stdin."""
def build_epic(self, *args: str, stdin: str = "") -> subprocess.CompletedProcess[str]:
"""Runs `build-epic args`, feeding it stdin."""
@dataclasses.dataclass(frozen=True)
class Machine:
"""A home folder of its own, holding the do-epic settings that point at the sandbox, so that do-epic writes its state there. The sandbox's env-file stays where it is. do-epic runs in env with HOME set to the home folder, and is stopped after timeout seconds."""
"""A home folder of its own, holding the build-epic settings that point at the sandbox, so that build-epic writes its state there. The sandbox's env-file stays where it is. build-epic runs in env with HOME set to the home folder, and is stopped after timeout seconds."""
home: pathlib.Path
launcher: pathlib.Path
env: typing.Mapping[str, str]
timeout: float = TIMEOUT
def do_epic(self, *args: str, stdin: str = "") -> subprocess.CompletedProcess[str]:
def build_epic(self, *args: str, stdin: str = "") -> subprocess.CompletedProcess[str]:
env = {**self.env, "HOME": str(self.home)}
try:
return subprocess.run([str(self.launcher), *args], input=stdin, env=env, capture_output=True, text=True, timeout=self.timeout, check=False)
except subprocess.TimeoutExpired:
return subprocess.CompletedProcess(args, 124, "", f"do-epic {' '.join(args)} ran over {self.timeout} seconds and was stopped")
return subprocess.CompletedProcess(args, 124, "", f"build-epic {' '.join(args)} ran over {self.timeout} seconds and was stopped")
def machine_made(home: pathlib.Path, sandbox: Sandbox, launcher: pathlib.Path, env: typing.Mapping[str, str]) -> Machine | Failure:
# So that do-epic keeps its config and state under home.
# So that build-epic keeps its config and state under home.
env = without_xdg_folders(env)
folder = config_folder(env, home) / "do-epic"
folder = config_folder(env, home) / "build-epic"
folder.mkdir(parents=True)
ladder = read_ladder(SHIPPED)
if isinstance(ladder, Failure):
@@ -71,7 +71,7 @@ def machine_made(home: pathlib.Path, sandbox: Sandbox, launcher: pathlib.Path, e
def run(sandbox: Sandbox, epic_key: str, launcher: pathlib.Path, env: typing.Mapping[str, str]) -> Report:
"""Drives do-epic against the epic epic_key in the sandbox, an epic with no issue yet."""
"""Drives build-epic against the epic epic_key in the sandbox, an epic with no issue yet."""
report = Report()
epic = Epic(sandbox.jira_url, epic_key)
store = JiraEpic(epic, sandbox.env_file, finish=Finish(FINISH_TRANSITION, FINISH_STATUS))
@@ -79,7 +79,7 @@ def run(sandbox: Sandbox, epic_key: str, launcher: pathlib.Path, env: typing.Map
with tempfile.TemporaryDirectory() as home:
machine = machine_made(pathlib.Path(home).resolve(), sandbox, launcher, env)
if isinstance(machine, Failure):
report.check(False, f"set up do-epic's settings: {machine.reason}")
report.check(False, f"set up build-epic's settings: {machine.reason}")
return report
items_filed(report, store, epic_key)
finding_filed(report, machine, store, epic_key)
@@ -108,40 +108,40 @@ def items_filed(report: Report, store: EpicStore, epic_key: str) -> None:
report.check([issue.summary for issue in issues] == ["Sandbox item with a sub-task", "Sandbox sub-task", "Sandbox second item"], f"read the filed issues back in order, the sub-task after its parent (found {[issue.summary for issue in issues]})")
def finding_filed(report: Report, machine: DoEpic, store: EpicStore, epic_key: str) -> None:
done = machine.do_epic(epic_key, findings.FILE, "Sandbox finding", findings.LABEL, CLAUDE_LABEL, stdin="Why the finding matters.\n")
report.check(done.returncode == 0 and " Filed " in done.stdout, f"`do-epic {findings.FILE}` files the finding and says so (exit {done.returncode}: {done.stdout.strip() or done.stderr.strip()})")
def finding_filed(report: Report, machine: BuildEpic, store: EpicStore, epic_key: str) -> None:
done = machine.build_epic(epic_key, findings.FILE, "Sandbox finding", findings.LABEL, CLAUDE_LABEL, stdin="Why the finding matters.\n")
report.check(done.returncode == 0 and " Filed " in done.stdout, f"`build-epic {findings.FILE}` files the finding and says so (exit {done.returncode}: {done.stdout.strip() or done.stderr.strip()})")
found = [issue for issue in read(report, store, "after the finding") if issue.summary == "Sandbox finding"]
report.check(len(found) == 1 and found[0].labels == (CLAUDE_LABEL,) and found[0].detail == "Why the finding matters." and found[0].by_loop, f"the finding is an issue of the epic with its label, its detail and the loop's mark (found {found})")
def follow_up_filed(report: Report, machine: DoEpic, store: EpicStore, epic_key: str) -> None:
def follow_up_filed(report: Report, machine: BuildEpic, store: EpicStore, epic_key: str) -> None:
"""Files a follow-up finding that waits for the first finding, and checks that Jira reads the link in that direction."""
first = next((issue.key for issue in read(report, store, "before the follow-up") if issue.summary == "Sandbox finding"), "")
done = machine.do_epic(epic_key, findings.FILE, "Sandbox follow-up finding", findings.LABEL, CLAUDE_LABEL, findings.BLOCKED_BY, first, stdin="Waits for the first finding.\n")
report.check(done.returncode == 0 and f"It is blocked by {first}." in done.stdout, f"`do-epic {findings.FILE} {findings.BLOCKED_BY}` files the follow-up and says it is blocked (exit {done.returncode}: {done.stdout.strip() or done.stderr.strip()})")
done = machine.build_epic(epic_key, findings.FILE, "Sandbox follow-up finding", findings.LABEL, CLAUDE_LABEL, findings.BLOCKED_BY, first, stdin="Waits for the first finding.\n")
report.check(done.returncode == 0 and f"It is blocked by {first}." in done.stdout, f"`build-epic {findings.FILE} {findings.BLOCKED_BY}` files the follow-up and says it is blocked (exit {done.returncode}: {done.stdout.strip() or done.stderr.strip()})")
issues = read(report, store, "after the follow-up")
waiting = [issue for issue in issues if issue.summary == "Sandbox follow-up finding"]
report.check(len(waiting) == 1 and waiting[0].blockers == (first,) and not any(issue.blockers for issue in issues if issue.key == first), f"the follow-up is blocked by the first finding, not the other way round (found {[(issue.key, issue.blockers) for issue in issues if issue.key == first or issue.summary == 'Sandbox follow-up finding']})")
def decision_recorded(report: Report, machine: DoEpic, section: typing.Callable[[str], str | Failure], epic_key: str) -> None:
done = machine.do_epic(epic_key, findings.RECORD_DECISION, "Sandbox decision", stdin="The text of the decision.\n")
report.check(done.returncode == 0 and "Recorded the decision" in done.stdout, f"`do-epic {findings.RECORD_DECISION}` records the decision and says so (exit {done.returncode}: {done.stdout.strip() or done.stderr.strip()})")
def decision_recorded(report: Report, machine: BuildEpic, section: typing.Callable[[str], str | Failure], epic_key: str) -> None:
done = machine.build_epic(epic_key, findings.RECORD_DECISION, "Sandbox decision", stdin="The text of the decision.\n")
report.check(done.returncode == 0 and "Recorded the decision" in done.stdout, f"`build-epic {findings.RECORD_DECISION}` records the decision and says so (exit {done.returncode}: {done.stdout.strip() or done.stderr.strip()})")
decisions = section("Decisions")
report.check(isinstance(decisions, str) and "Sandbox decision" in decisions and "The text of the decision." in decisions, f"the epic's description holds the decision under ## Decisions (found {decisions!r})")
goals = section("Goals")
report.check(isinstance(goals, str) and "Prove do-epic's commands" in goals, f"the decision leaves the description's ## Goals as it was (found {goals!r})")
report.check(isinstance(goals, str) and "Prove build-epic's commands" in goals, f"the decision leaves the description's ## Goals as it was (found {goals!r})")
def closed(report: Report, machine: DoEpic, store: EpicStore, epic_key: str) -> None:
early = machine.do_epic(epic_key, finish.CLOSE, stdin="Too early.\n")
def closed(report: Report, machine: BuildEpic, store: EpicStore, epic_key: str) -> None:
early = machine.build_epic(epic_key, finish.CLOSE, stdin="Too early.\n")
still = store.closed()
report.check(early.returncode == 1 and " open" in early.stderr and still is False, f"`do-epic {finish.CLOSE}` refuses while issues are open and leaves the epic open (exit {early.returncode}: {early.stderr.strip()}; epic closed: {still!r})")
report.check(early.returncode == 1 and " open" in early.stderr and still is False, f"`build-epic {finish.CLOSE}` refuses while issues are open and leaves the epic open (exit {early.returncode}: {early.stderr.strip()}; epic closed: {still!r})")
for issue in read(report, store, "before finishing them"):
done = store.finish_issue(issue.key)
report.check(done is None, f"finish {issue.key}" + (f": {done.reason}" if isinstance(done, Failure) else ""))
late = machine.do_epic(epic_key, finish.CLOSE, stdin="Everything the sandbox epic held is done.\n")
report.check(late.returncode == 0 and "closed it" in late.stdout, f"`do-epic {finish.CLOSE}` posts the summary and closes the epic (exit {late.returncode}: {late.stdout.strip() or late.stderr.strip()})")
late = machine.build_epic(epic_key, finish.CLOSE, stdin="Everything the sandbox epic held is done.\n")
report.check(late.returncode == 0 and "closed it" in late.stdout, f"`build-epic {finish.CLOSE}` posts the summary and closes the epic (exit {late.returncode}: {late.stdout.strip() or late.stderr.strip()})")
now = store.closed()
report.check(now is True, f"Jira counts the epic as done (found {now!r})")
@@ -8,9 +8,9 @@ from atlassian.client import basic_auth
from failure import Failure
from project_config.settings import SITE
JIRA_URL = "DO_EPIC_E2E_JIRA_URL"
ENV_FILE = "DO_EPIC_E2E_ENV_FILE"
PROJECT = "DO_EPIC_E2E_PROJECT"
JIRA_URL = "BUILD_EPIC_E2E_JIRA_URL"
ENV_FILE = "BUILD_EPIC_E2E_ENV_FILE"
PROJECT = "BUILD_EPIC_E2E_PROJECT"
PROJECT_KEY = r"[A-Z][A-Z0-9]+"
MEANING = {
JIRA_URL: "the sandbox Jira site's https address without a path, such as https://acme.atlassian.net",
@@ -8,16 +8,16 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from do_epic.e2e.settings import ENV_FILE, JIRA_URL, PROJECT
from build_epic.e2e.settings import ENV_FILE, JIRA_URL, PROJECT
from failure import Failure
from do_epic.e2e import main, sandbox, scenario, settings
from build_epic.e2e import main, sandbox, scenario, settings
class MainTest(unittest.TestCase):
def run_main(self, argv: list[str]) -> tuple[int, str, str]:
out, err = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
code = main.main(argv, {}, pathlib.Path("do-epic"), sandbox.epic_made, scenario.run)
code = main.main(argv, {}, pathlib.Path("build-epic"), sandbox.epic_made, scenario.run)
return code, out.getvalue(), err.getvalue()
def test_fails_naming_each_missing_setting_before_it_touches_anything(self) -> None:
@@ -62,7 +62,7 @@ class ReportedTest(unittest.TestCase):
return report
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
code = main.main([], self.env, pathlib.Path("do-epic"), epic_made, ran)
code = main.main([], self.env, pathlib.Path("build-epic"), epic_made, ran)
return code, out.getvalue(), err.getvalue()
def test_prints_each_check_and_fails_where_one_broke(self) -> None:
@@ -80,14 +80,14 @@ class ReportedTest(unittest.TestCase):
code, out, err = self.run_scenario(True, scenario.Report(["a check held"]))
sandbox_set = settings.read(self.env)
self.assertEqual((code, err), (0, ""))
self.assertEqual(self.made_with, (sandbox_set, "do-epic e2e sandbox epic"))
self.assertEqual(self.ran_with, (sandbox_set, "SBX-1", pathlib.Path("do-epic"), self.env))
self.assertEqual(self.made_with, (sandbox_set, "build-epic e2e sandbox epic"))
self.assertEqual(self.ran_with, (sandbox_set, "SBX-1", pathlib.Path("build-epic"), self.env))
self.assertEqual(out, "Sandbox epic SBX-1 in https://acme.atlassian.net\nok a check held\n1 held, 0 broke\n")
def test_fails_without_a_scenario_where_the_epic_cannot_be_made(self) -> None:
code, out, err = self.run_scenario(True, made=Failure("Jira said no"))
self.assertEqual((code, out, self.ran_with), (1, "", None))
self.assertEqual(err, "do-epic-e2e: Jira said no\n")
self.assertEqual(err, "build-epic-e2e: Jira said no\n")
def test_fails_where_every_check_held_but_the_epic_stays(self) -> None:
self.assertEqual(self.run_scenario(False, scenario.Report(["a check held"]))[0], 1)
@@ -6,9 +6,9 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from do_epic.e2e.sandbox import epic_made, Leftover
from build_epic.e2e.sandbox import epic_made, Leftover
from failure import Failure
from do_epic.e2e.settings import Sandbox
from build_epic.e2e.settings import Sandbox
class JiraStub:
@@ -8,13 +8,13 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from do_epic.repo_pick import CLAUDE_LABEL
from build_epic.repo_pick import CLAUDE_LABEL
from failure import Failure
from do_epic import findings, finish
from do_epic.config import load
from do_epic.backend.fake import MemoryEpic
from do_epic.e2e.settings import Sandbox
from do_epic.e2e import scenario
from build_epic import findings, finish
from build_epic.config import load
from build_epic.backend.fake import MemoryEpic
from build_epic.e2e.settings import Sandbox
from build_epic.e2e import scenario
EPIC = "SBX-1"
@@ -25,11 +25,11 @@ def done(code: int, out: str = "", err: str = "") -> subprocess.CompletedProcess
@dataclasses.dataclass
class Scripted:
"""A do-epic that answers each call with the next of its answers, each a function that may also change the epic as do-epic would, and notes the call."""
"""A build-epic that answers each call with the next of its answers, each a function that may also change the epic as build-epic would, and notes the call."""
answers: list[typing.Callable[[], subprocess.CompletedProcess[str]]]
calls: list[tuple[tuple[str, ...], str]] = dataclasses.field(default_factory=list)
def do_epic(self, *args: str, stdin: str = "") -> subprocess.CompletedProcess[str]:
def build_epic(self, *args: str, stdin: str = "") -> subprocess.CompletedProcess[str]:
self.calls.append((args, stdin))
return self.answers.pop(0)()
@@ -77,7 +77,7 @@ class FindingFiledTest(unittest.TestCase):
return done(code, out)
return answer
def test_holds_where_do_epic_files_the_finding_with_its_label_and_detail(self) -> None:
def test_holds_where_build_epic_files_the_finding_with_its_label_and_detail(self) -> None:
store = MemoryEpic(EPIC)
machine = Scripted([self.filing(store)])
report = scenario.Report()
@@ -85,7 +85,7 @@ class FindingFiledTest(unittest.TestCase):
self.assertEqual((report.broke, len(report.held)), ([], 2))
self.assertEqual(machine.calls, [((EPIC, findings.FILE, "Sandbox finding", findings.LABEL, CLAUDE_LABEL), "Why the finding matters.\n")])
def test_breaks_where_do_epic_fails_and_files_nothing(self) -> None:
def test_breaks_where_build_epic_fails_and_files_nothing(self) -> None:
report = scenario.Report()
scenario.finding_filed(report, Scripted([lambda: done(1, err="no")]), MemoryEpic(EPIC), EPIC)
self.assertEqual(report.held, [])
@@ -100,7 +100,7 @@ class FindingFiledTest(unittest.TestCase):
self.assertEqual(len(report.broke), 1)
self.assertIn("with its label", report.broke[0])
def test_breaks_where_do_epic_exits_cleanly_but_says_nothing_of_filing(self) -> None:
def test_breaks_where_build_epic_exits_cleanly_but_says_nothing_of_filing(self) -> None:
store = MemoryEpic(EPIC)
report = scenario.Report()
scenario.finding_filed(report, Scripted([self.filing(store, out="")]), store, EPIC)
@@ -137,14 +137,14 @@ class FollowUpFiledTest(unittest.TestCase):
self.assertEqual(len(report.broke), 1)
self.assertIn("not the other way round", report.broke[0])
def test_breaks_where_do_epic_exits_cleanly_but_says_nothing_of_the_blocker(self) -> None:
def test_breaks_where_build_epic_exits_cleanly_but_says_nothing_of_the_blocker(self) -> None:
store = self.store()
report = scenario.Report()
scenario.follow_up_filed(report, Scripted([lambda: (self.following(store)(), done(0, "Filed SBX-101 in the epic SBX-1."))[1]]), store, EPIC)
self.assertEqual(len(report.broke), 1)
self.assertIn("says it is blocked", report.broke[0])
def test_breaks_where_do_epic_fails_and_files_nothing(self) -> None:
def test_breaks_where_build_epic_fails_and_files_nothing(self) -> None:
report = scenario.Report()
scenario.follow_up_filed(report, Scripted([lambda: done(1, err="no")]), self.store(), EPIC)
self.assertEqual(len(report.broke), 2)
@@ -152,7 +152,7 @@ class FollowUpFiledTest(unittest.TestCase):
class DecisionRecordedTest(unittest.TestCase):
SECTIONS: typing.ClassVar[dict[str, str | Failure]] = {"Decisions": "### Sandbox decision\nThe text of the decision.", "Goals": "1. Prove do-epic's commands work."}
SECTIONS: typing.ClassVar[dict[str, str | Failure]] = {"Decisions": "### Sandbox decision\nThe text of the decision.", "Goals": "1. Prove build-epic's commands work."}
def recorded(self, answer: subprocess.CompletedProcess[str], **sections: str | Failure) -> tuple[scenario.Report, Scripted]:
machine = Scripted([lambda: answer])
@@ -198,7 +198,7 @@ class ClosedTest(unittest.TestCase):
scenario.closed(report, self.machine, store, EPIC)
return report
def test_holds_where_do_epic_refuses_while_an_issue_is_open_and_closes_the_epic_after(self) -> None:
def test_holds_where_build_epic_refuses_while_an_issue_is_open_and_closes_the_epic_after(self) -> None:
store = MemoryEpic(EPIC)
report = self.closing(store)
self.assertEqual((report.broke, len(report.held)), ([], 4))
@@ -249,27 +249,27 @@ class MachineTest(unittest.TestCase):
launcher.chmod(0o755)
return launcher
def test_writes_settings_that_do_epic_loads_and_that_point_at_the_sandbox(self) -> None:
def test_writes_settings_that_build_epic_loads_and_that_point_at_the_sandbox(self) -> None:
home = self.folder / "home"
machine = scenario.machine_made(home, self.sandbox, pathlib.Path("do-epic"), {"A": "b"})
machine = scenario.machine_made(home, self.sandbox, pathlib.Path("build-epic"), {"A": "b"})
assert not isinstance(machine, Failure), machine
self.assertEqual((machine.home, machine.launcher, machine.env), (home, pathlib.Path("do-epic"), {"A": "b"}))
self.assertEqual((machine.home, machine.launcher, machine.env), (home, pathlib.Path("build-epic"), {"A": "b"}))
config = load(home, {})
assert not isinstance(config, Failure), config
self.assertEqual((config.jira_url, config.env_file, config.repo_rule), ("https://acme.atlassian.net", self.env_file, scenario.RULE))
self.assertEqual((config.finish.transition, config.finish.status) if config.finish else None, ("Done", "Done"))
def test_runs_do_epic_in_the_given_environment_with_the_machines_home_and_the_words_and_stdin_given(self) -> None:
def test_runs_build_epic_in_the_given_environment_with_the_machines_home_and_the_words_and_stdin_given(self) -> None:
machine = scenario.Machine(self.folder, self.script('echo "$HOME $KEPT $*"; cat'), {"KEPT": "yes", "HOME": "/elsewhere"})
finished = machine.do_epic("ABC-1", "--file", stdin="detail")
finished = machine.build_epic("ABC-1", "--file", stdin="detail")
self.assertEqual((finished.returncode, finished.stdout), (0, f"{self.folder} yes ABC-1 --file\ndetail"))
def test_answers_a_failing_do_epic_with_its_exit_and_output(self) -> None:
finished = scenario.Machine(self.folder, self.script("echo out; echo err >&2; exit 3"), {}).do_epic("ABC-1")
def test_answers_a_failing_build_epic_with_its_exit_and_output(self) -> None:
finished = scenario.Machine(self.folder, self.script("echo out; echo err >&2; exit 3"), {}).build_epic("ABC-1")
self.assertEqual((finished.returncode, finished.stdout, finished.stderr), (3, "out\n", "err\n"))
def test_stops_a_do_epic_that_runs_over_its_time_and_says_so(self) -> None:
finished = scenario.Machine(self.folder, self.script("exec sleep 30"), {}, timeout=0.2).do_epic("ABC-1")
def test_stops_a_build_epic_that_runs_over_its_time_and_says_so(self) -> None:
finished = scenario.Machine(self.folder, self.script("exec sleep 30"), {}, timeout=0.2).build_epic("ABC-1")
self.assertEqual(finished.returncode, 124)
self.assertIn("ran over 0.2 seconds", finished.stderr)
self.assertIn("ABC-1", finished.stderr)
@@ -5,7 +5,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from do_epic.e2e.settings import ENV_FILE, JIRA_URL, PROJECT, read, Sandbox
from build_epic.e2e.settings import ENV_FILE, JIRA_URL, PROJECT, read, Sandbox
from failure import Failure
@@ -1,4 +1,4 @@
"""A Jira epic's description as the record of do-epic, the tool that drives one epic.
"""A Jira epic's description as the record of build-epic, the tool that drives one epic.
The description holds a language line, a line that caps the chunks running at once, and the sections Goals, Audience, Scoring (the formula and the bar) and Decisions. They are read and written one at a time through `EpicDescription`, and a write leaves every other line of the markdown as it was. Goals and Audience change only where the human approved in an interrupt, which `write_section` takes as `approved`; `EpicDescription` refuses the change otherwise."""
import dataclasses
@@ -73,7 +73,7 @@ def parallel_chunks_in(text: str) -> int | Failure:
return int(value)
return Failure(f"the epic's description caps its chunks with `{CAP} {value}`, which is not a whole number of 1 or more, such as `{CAP} 2`")
if not fenced and NEAR_CAP_LINE.match(line):
return Failure(f"the epic's description holds the line `{line.strip()}`, which do-epic doesn't read as the epic's cap: write it as a line of its own, spelt `{CAP} 2`")
return Failure(f"the epic's description holds the line `{line.strip()}`, which build-epic doesn't read as the epic's cap: write it as a line of its own, spelt `{CAP} 2`")
return 1
@@ -1,15 +1,15 @@
"""One run of do-epic on an epic (`EpicRun`), and how it starts the epic's chunks that may start now (`chunks_started`)."""
"""One run of build-epic on an epic (`EpicRun`), and how it starts the epic's chunks that may start now (`chunks_started`)."""
import dataclasses
import pathlib
import typing
from do_epic.config import DoEpicConfig
from build_epic.config import BuildEpicConfig
from loop_effects.effects import Effects, say
from do_epic.backend.protocol import EpicIssue, EpicStore
from do_epic.epic_record import EpicRecord
from build_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.epic_record import EpicRecord
from failure import Failure
from do_epic import finish, planning, scheduler
from do_epic.repos import locate
from build_epic import finish, planning, scheduler
from build_epic.repos import locate
from loop_state.paths import Paths
from forge.commands import Run, runner
from agent_cycle import tmux
@@ -20,9 +20,9 @@ POLL_SECONDS = 60
@dataclasses.dataclass(frozen=True)
class EpicRun:
"""What stays the same through one run of do-epic on an epic."""
"""What stays the same through one run of build-epic on an epic."""
key: str
config: DoEpicConfig
config: BuildEpicConfig
store: EpicStore
record: EpicRecord
paths: Paths
@@ -1,15 +1,15 @@
"""What a chunk's worker writes into its epic: a finding, filed as an issue, and a decision, appended to the description.
A finding about one of the epic's goals is filed in the epic, and one about a repo's goals by that repo's rules (docs/decisions.md → `do-epic: drives one Jira epic …` → "Findings"). A decision that governs the epic goes under the description's ## Decisions, where the judge of each later chunk reads it."""
A finding about one of the epic's goals is filed in the epic, and one about a repo's goals by that repo's rules (docs/decisions.md → `build-epic: drives one Jira epic …` → "Findings"). A decision that governs the epic goes under the description's ## Decisions, where the judge of each later chunk reads it."""
import contextlib
import dataclasses
import fcntl
import pathlib
import typing
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, label_of, LabelRepos, of_label, REPO_PREFIX, team_label
from do_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL
from do_epic.epic_record import EpicRecord
from build_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, label_of, LabelRepos, of_label, REPO_PREFIX, team_label
from build_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL
from build_epic.epic_record import EpicRecord
from failure import Failure
from text_files.markdown_text import listed
from text_files.piped_text import piped
@@ -23,19 +23,19 @@ RECORD_DECISION = "--record-decision"
def worked_by(team: LabelRepos) -> str:
"""The labels that say where an issue is worked, as do-epic's scheduler reads them: for each repo the team's table names, the label on its first line for that repo, and `repo:<name>` for any other repo."""
"""The labels that say where an issue is worked, as build-epic's scheduler reads them: for each repo the team's table names, the label on its first line for that repo, and `repo:<name>` for any other repo."""
named = [f"`{label}` for the repo {name}" for name in sorted(set(team.values())) if (label := team_label(name, team))]
repos = ", ".join([*named, f"`{REPO_PREFIX}<name>` for {'any other repo' if named else 'the repo'} that works it"])
return f"{repos}, `{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.
# Under the epic's folder, the file a build-epic holds locked while it appends a decision.
DECISIONS_LOCK = "decisions.lock"
USAGE = f"""do-epic <EPIC-KEY> {FILE} <summary> [{LABEL} <label>]... [{BLOCKED_BY} <KEY>] [{PARENT} <KEY>] [<<'EOF' detail EOF]
do-epic <EPIC-KEY> {RECORD_DECISION} <title> <<'EOF' entry EOF"""
USAGE = f"""build-epic <EPIC-KEY> {FILE} <summary> [{LABEL} <label>]... [{BLOCKED_BY} <KEY>] [{PARENT} <KEY>] [<<'EOF' detail EOF]
build-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.
A finding about a repo's own goals goes into that repo's plan instead.
{LABEL} is {worked_by({})}; without one, the next `do-epic <EPIC-KEY>` you run picks where the issue is worked.
{LABEL} is {worked_by({})}; without one, the next `build-epic <EPIC-KEY>` you run picks where the issue is worked.
A second {LABEL}, `{REVIEW_LABEL}`, marks the issue as a repo's release review, which the epic's finishing files.
{BLOCKED_BY} <KEY> makes the new issue wait for the issue <KEY>, which is a child issue of the epic or a sub-task of one.
{PARENT} <KEY> files the new issue as a sub-task of the child issue <KEY>.
@@ -44,7 +44,7 @@ Where a repo's rules ask for a change to ship as more than one pull request, fil
def instructions(epic: str, launcher: pathlib.Path, language: str, team: LabelRepos, issue: EpicIssue | None = None) -> str:
"""What a chunk's first prompt says about filing a finding and recording a decision in the epic with the key epic. launcher is the do-epic that runs the chunk, and language the one the epic's Jira text is in. Where issue is the chunk's own, it also says how to file the next pull request of a change as an issue that waits for it."""
"""What a chunk's first prompt says about filing a finding and recording a decision in the epic with the key epic. launcher is the build-epic that runs the chunk, and language the one the epic's Jira text is in. Where issue is the chunk's own, it also says how to file the next pull request of a change as an issue that waits for it."""
next_step = ""
if issue:
parent = f" {PARENT} {issue.parent}" if issue.parent != epic else ""
@@ -53,7 +53,7 @@ def instructions(epic: str, launcher: pathlib.Path, language: str, team: LabelRe
next_step = f"Where the repo's rules ask for a change to ship as more than one pull request, finish only this issue's pull request, and file only the next one as an issue that waits for it, with `{launcher} {epic} {FILE} \"<summary>\" {BLOCKED_BY} {issue.key}{parent}{label}` and its detail on stdin. "
return (
f"File a finding about one of the epic's goals in the epic, with `{launcher} {epic} {FILE} \"<summary>\" {LABEL} <label>` and its detail on stdin. "
f"The label is {worked_by(team)}; leave it out where you cannot tell, and the next `do-epic` the human runs picks it. "
f"The label is {worked_by(team)}; leave it out where you cannot tell, and the next `build-epic` the human runs picks it. "
"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. "
f"Record a decision that governs the epic, such as an answer the human typed, with `{launcher} {epic} {RECORD_DECISION} \"<title>\"` and its text on stdin. "
@@ -104,13 +104,13 @@ def written(epic: str, write: Write, store: EpicStore, team: LabelRepos, record:
flag, value, labels = write.flag, write.value, write.labels
if flag == FILE:
if unread := [label for label in labels if of_label(label, team) 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 {worked_by(team)}")
return Failure(f"cannot file the finding in the epic {epic}: build-epic doesn't read the label {unread[0]!r}; write {worked_by(team)}")
if len(picks := [label for label in labels if of_label(label, team)]) > 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(write.parent or epic, value, text, labels, write.blocked_by)
if isinstance(key, Failure):
return Failure(f"cannot file the finding in the epic {epic}: {key.reason}")
return f"Filed {key} {f'under {write.parent} in ' if write.parent else 'in '}the epic {epic}." + (f" It is blocked by {write.blocked_by}." if write.blocked_by else "") + ("" if any(of_label(label, team) for label in labels) else f" It has no label that says where it is worked, so the next `do-epic {epic}` picks one: {worked_by(team)}.")
return f"Filed {key} {f'under {write.parent} in ' if write.parent else 'in '}the epic {epic}." + (f" It is blocked by {write.blocked_by}." if write.blocked_by else "") + ("" if any(of_label(label, team) for label in labels) else f" It has no label that says where it is worked, so the next `build-epic {epic}` picks one: {worked_by(team)}.")
try:
with decisions_locked(folder):
added = record.append_decision(value, text)
@@ -1,29 +1,29 @@
"""How an epic ends (docs/decisions.md → `do-epic: drives one Jira epic …` → "Finishing").
"""How an epic ends (docs/decisions.md → `build-epic: drives one Jira epic …` → "Finishing").
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 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.
3. With every goal confirmed, `build-epic <EPIC-KEY> --close-epic` posts the summary on the epic and closes it.
The chunk starts again each time the epic holds no open issue, until the epic is closed. A repo is reviewed once per epic, as a release is: the issues filed after its review don't bring another."""
import dataclasses
import pathlib
import typing
from do_epic.chunk_prompt import DRIVER
from do_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL
from build_epic.chunk_prompt import DRIVER
from build_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL
from failure import Failure
from do_epic import findings
from do_epic.split import finished
from do_epic.repo_pick import label_of, LabelRepos, recorded, Repo
from build_epic import findings
from build_epic.split import finished
from build_epic.repo_pick import label_of, LabelRepos, recorded, Repo
from text_files.markdown_text import listed
from text_files.piped_text import piped
from plan.release import REVIEW_TITLE
# 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"
USAGE = f"build-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.
It files a release review of each repo the epic changed, as an issue labelled `{REVIEW_LABEL}`, then asks you to confirm each goal.
{CLOSE} posts the markdown piped in on the epic as its summary, then closes the epic. It refuses while an issue is open or a repo lacks its review.
@@ -31,7 +31,7 @@ It closes the epic by the transition `jira-finish-transition` names, to the stat
def landed(issues: list[EpicIssue], merged_status: str | None) -> list[EpicIssue]:
"""issues, each counted done where it has the status merged_status, which do-epic's `jira-pull-request-merged-status` names: its work has merged into the epic's working branch, and Jira counts it done only once a person has merged that branch into the default branch. The epic's release reviews and finishing come before that merge, so they can't wait for it (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`). None names no such status."""
"""issues, each counted done where it has the status merged_status, which build-epic's `jira-pull-request-merged-status` names: its work has merged into the epic's working branch, and Jira counts it done only once a person has merged that branch into the default branch. The epic's release reviews and finishing come before that merge, so they can't wait for it (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`). None names no such status."""
if merged_status is None:
return issues
return [dataclasses.replace(issue, done=True) if issue.status.casefold() == merged_status.casefold() else issue for issue in issues]
@@ -61,7 +61,7 @@ def unreviewed(issues: list[EpicIssue], team: LabelRepos) -> list[str]:
def task(epic: str, issues: list[EpicIssue], team: LabelRepos, launcher: pathlib.Path, language: str) -> str:
"""The finishing chunk's task, for the epic with the key epic as issues has it. launcher is the do-epic that runs the chunk, and language the one the epic's Jira text is in."""
"""The finishing chunk's task, for the epic with the key epic as issues has it. launcher is the build-epic that runs the chunk, and language the one the epic's Jira text is in."""
opening = f"Finish the epic {epic}, which holds no open issue, as one chunk that changes no repo: work in the folder you start in."
if lacking := unreviewed(issues, team):
return (
@@ -1,6 +1,6 @@
"""What the pull request of a do-epic chunk waits on, read once from its forge (docs/decisions.md → `do-epic: drives one Jira epic …`, "Long gates").
"""What the pull request of a build-epic chunk waits on, read once from its forge (docs/decisions.md → `build-epic: drives one Jira epic …`, "Long gates").
A gate is something only time or a person passes: checks that still run, an approval a reviewer has yet to give, the new review of a reviewer whose requested changes the worker answered, or the merge itself, where the project's config leaves it to a person. While a chunk's pull request waits on one, its worker doesn't have anything to do, so do-epic parks the chunk (`parked`). Anything else is news the worker acts on."""
A gate is something only time or a person passes: checks that still run, an approval a reviewer has yet to give, the new review of a reviewer whose requested changes the worker answered, or the merge itself, where the project's config leaves it to a person. While a chunk's pull request waits on one, its worker doesn't have anything to do, so build-epic parks the chunk (`parked`). Anything else is news the worker acts on."""
import dataclasses
import typing
@@ -70,7 +70,7 @@ def gate(branch: str, checkout: str, at: typing.Callable[[str], Run], by_human:
decision = review_decision(forge, pull, head, run)
if not isinstance(decision, str):
return decision or Open(f"pull request #{pull} is a draft")
# do-epic takes the base as saying who merges, so the forge must merge the pull request into it too.
# build-epic takes the base as saying who merges, so the forge must merge the pull request into it too.
required = other_base(forge, pull, base, run) or required_checks(forge, base, run)
checks = required if isinstance(required, Failure) else checks_now(forge, pull, head, required, run)
if isinstance(checks, CheckFailed):
@@ -1,4 +1,4 @@
"""A human's task that holds up other issues of an epic (docs/decisions.md → `do-epic: drives one Jira epic …`, "Human tasks").
"""A human's task that holds up other issues of an epic (docs/decisions.md → `build-epic: drives one Jira epic …`, "Human tasks").
A window that starts again, as after a reboot, DMs again, and so does one whose DM failed, on its next read."""
from collections.abc import Mapping
@@ -6,10 +6,10 @@ import pathlib
from project_config.settings import by_name, ProjectConfig
from loop_effects.effects import Effects, say
from do_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from do_epic.repo_pick import LabelRepos, recorded, Repo
from do_epic import scheduler
from build_epic.repo_pick import LabelRepos, recorded, Repo
from build_epic import scheduler
from agent_cycle.direct_message import tell
from agent_cycle import tmux
@@ -25,7 +25,7 @@ def holds_up(key: str, issues: list[EpicIssue], team: LabelRepos, unblocking: tu
def message(task: EpicIssue, epic: str, held: list[str]) -> str:
return f"do-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. do-epic goes on once you close {task.key} in Jira."
return f"build-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. build-epic goes on once you close {task.key} in Jira."
def notifier_checkout(issues: list[EpicIssue], team: LabelRepos, home: pathlib.Path, env: Mapping[str, str]) -> str | None:
@@ -1,11 +1,11 @@
"""The scores of an epic's issue that holds none, asked of claude, so that the epic's issues start in order of score (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""The scores of an epic's issue that holds none, asked of claude, so that the epic's issues start in order of score (docs/decisions.md → `build-epic: drives one Jira epic …`).
A headless claude call with a JSON schema, as repo_pick makes, reads the rule every plan item is scored by, the goals the issue may move and the issue. It answers L, E, I, S and Moves, and a comment that tells the issue's team the scores."""
import dataclasses
import json
from claude_code.reply import Claude, claude_reply, Limited
from do_epic.backend.protocol import EpicIssue
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from model_routing.ladder import Rung
from plan_store.jira_epic import SET_SCORES
+43 -43
View File
@@ -1,8 +1,8 @@
"""The do-epic command (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""The build-epic command (docs/decisions.md → `build-epic: drives one Jira epic …`).
`do-epic <EPIC-KEY>` first plans the epic's open issues (`planning`): each that no label places is split by repo or gets its pick, and the scored issues do-epic filed are re-ranked. Then it moves each parent whose sub-tasks a person filed, where those sub-tasks have landed or are done (`parent_moves`). Then it starts each of the epic's chunks that may start now, each in a window of the epic's tmux session, as `scheduler` picks them, and puts that session on the terminal. Each window runs `do-epic --chunk <ISSUE-KEY> <EPIC-KEY>`: the cycles of one issue's chunk, run by the code that runs build-release's (`agent_cycle`), until the judge rules it finished. Then it starts the chunks that may start now, and its window closes. The window of a human's task runs no cycle: it waits until the task no longer holds up an issue (`human_tasks`), then does the same.
`build-epic <EPIC-KEY>` first plans the epic's open issues (`planning`): each that no label places is split by repo or gets its pick, and the scored issues build-epic filed are re-ranked. Then it moves each parent whose sub-tasks a person filed, where those sub-tasks have landed or are done (`parent_moves`). Then it starts each of the epic's chunks that may start now, each in a window of the epic's tmux session, as `scheduler` picks them, and puts that session on the terminal. Each window runs `build-epic --chunk <ISSUE-KEY> <EPIC-KEY>`: the cycles of one issue's chunk, run by the code that runs build-release's (`agent_cycle`), until the judge rules it finished. Then it starts the chunks that may start now, and its window closes. The window of a human's task runs no cycle: it waits until the task no longer holds up an issue (`human_tasks`), then does the same.
After each cycle of a chunk in a repo, the window reads what the chunk's pull request waits on (`gates`). While that is a gate only time or a person passes, the chunk is parked (`parked`): the window frees its running slot and polls the forge, and the chunk's next cycle starts once the worker has something to do and a slot is free. `do-epic <EPIC-KEY> --status` prints what each open issue does."""
After each cycle of a chunk in a repo, the window reads what the chunk's pull request waits on (`gates`). While that is a gate only time or a person passes, the chunk is parked (`parked`): the window frees its running slot and polls the forge, and the chunk's next cycle starts once the worker has something to do and a slot is free. `build-epic <EPIC-KEY> --status` prints what each open issue does."""
import dataclasses
import enum
import pathlib
@@ -10,30 +10,30 @@ import sys
import typing
from chunk_driver.cycle_start import announced_route, cycle_of, project_routing, routing_on
from build_epic.config import BuildEpicConfig, load, PULL_MERGED_STATUS
from chunk_driver.claims import CHUNK_FLAG
from do_epic import chunk_prompt, dry_run, findings, finish, human_tasks, parent_moves, planning, scheduler, split, status
from build_epic import chunk_prompt, dry_run, findings, finish, human_tasks, parent_moves, planning, scheduler, split, status
from chunk_driver.chunk_run import ChunkRun, closed_cycle
from do_epic.epic_run import chunks_started, EpicRun, planned_epic, POLL_SECONDS, real
from do_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo
from build_epic.epic_run import chunks_started, EpicRun, planned_epic, POLL_SECONDS, real
from build_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo
from project_config.main import located as config_located
from chunk_driver.project.records import CONSEQUENCE, read_records
from agent_cycle.run import Cycle, run_cycle
from do_epic.config import DoEpicConfig, load, PULL_MERGED_STATUS
from loop_effects.effects import Effects, say
from project_config.settings import Epic
from git_cli import epic_branch
from record_store.jira_description import EpicDescription
from do_epic.backend.protocol import EpicIssue, EpicStore
from do_epic.epic_record import EpicRecord
from build_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.epic_record import EpicRecord
from failure import Failure
from agent_cycle.verdicts import Finished, TakenIn
from atlassian.jira import ISSUE_KEY
from do_epic.backend.jira import JiraEpic
from build_epic.backend.jira import JiraEpic
from claude_code.reply import Limited
from text_files.markdown_text import listed
from do_epic.repos import locate
from build_epic.repos import locate
from chunk_driver.this_loop import Loop
from do_epic.parking import Merged, parked_through
from build_epic.parking import Merged, parked_through
from chunk_driver.project.model_choice import Models, overridden
from loop_state.paths import Paths
from chunk_driver.project.premises import read_premises
@@ -46,38 +46,38 @@ from agent_cycle.direct_message import tell
from project_config import templates
from agent_cycle import tmux
HELP = f"""usage: do-epic <EPIC-KEY> [--status | --dry-run]
HELP = f"""usage: build-epic <EPIC-KEY> [--status | --dry-run]
{findings.USAGE}
{finish.USAGE}
Runs the chunks of one Jira epic, such as ABC-12, each in its own window of the tmux session epic-<EPIC-KEY>.
Before it starts chunks, do-epic <EPIC-KEY> plans each open issue that has none of these labels:
`repo:<name>` for its repo, `do-epic-claude` for work of Claude's that changes no repo, `do-epic-human` for a task of yours.
Before it starts chunks, build-epic <EPIC-KEY> plans each open issue that has none of these labels:
`repo:<name>` for its repo, `build-epic-claude` for work of Claude's that changes no repo, `build-epic-human` for a task of yours.
A label that `[label-repos]` in config.toml maps to a repo counts as that repo's.
Where such an issue changes several repos, it files a sub-task per repo. Otherwise it gives the issue its label, as repo-rule.md says.
An issue under which a person filed a sub-task is not planned: its sub-tasks run, each needs a label of its own, and do-epic moves the issue once they have landed or are done, as config.toml names how.
An issue under which a person filed a sub-task is not planned: its sub-tasks run, each needs a label of its own, and build-epic moves the issue once they have landed or are done, as config.toml names how.
Where the rule leaves the label unclear, it asks you on the terminal. Answer with the label, or with Enter alone to leave the issue waiting.
Where two or more issues may start, it then scores each of them that holds no scores, and tells the issue's team the scores in a comment on the issue. It scores by the `Score = ...` line under the epic's ## Scoring, and moves the issues do-epic itself filed into that order on the board.
An open issue labelled `repo:<name>` or `do-epic-claude` runs as a chunk once no issue blocks it.
The issues start in order of score, highest first, whatever their order on the board. An issue it could not score starts after the others. As its chunk starts, an issue is assigned in Jira to the account do-epic works as, unless someone else holds it. Where config.toml names a start transition or a sprint board, the issue is also moved by that transition and joins that board's active sprint.
A `do-epic-human` issue that blocks another gets a window too. The window DMs you once, then waits without taking a place until you close the issue in Jira.
Where two or more issues may start, it then scores each of them that holds no scores, and tells the issue's team the scores in a comment on the issue. It scores by the `Score = ...` line under the epic's ## Scoring, and moves the issues build-epic itself filed into that order on the board.
An open issue labelled `repo:<name>` or `build-epic-claude` runs as a chunk once no issue blocks it.
The issues start in order of score, highest first, whatever their order on the board. An issue it could not score starts after the others. As its chunk starts, an issue is assigned in Jira to the account build-epic works as, unless someone else holds it. Where config.toml names a start transition or a sprint board, the issue is also moved by that transition and joins that board's active sprint.
A `build-epic-human` issue that blocks another gets a window too. The window DMs you once, then waits without taking a place until you close the issue in Jira.
As many run at once as the epic's description allows with a line such as `**Max parallel chunks:** 2`, one where it has none.
A repo takes as many chunks as its `parallel-chunks`, and none while build-release runs chunks in it.
A chunk whose worker ends its run while its pull request waits on its checks, an approval or a new review
is parked: it frees its place for the next chunk, and its window's name says what it awaits. Its worker goes
on once the checks pass, the approval comes or a reviewer comments, and a place is free; until one is, the
name says `awaits a slot`. In a repo whose config sets `merge = "human"`, a chunk never merges: once its pull
request is ready, with nothing else to wait on, the window's name says `awaits your merge`. Once you merged it, do-epic removes the chunk's worktree with `chunk-pr clean` and finishes the chunk, without a worker or a place. Where it cannot, as for a pull request closed unmerged or a worktree with uncommitted or untracked files, the worker goes on once a place is free. A parked chunk survives a reboot: run do-epic <EPIC-KEY> again to go on polling.
request is ready, with nothing else to wait on, the window's name says `awaits your merge`. Once you merged it, build-epic removes the chunk's worktree with `chunk-pr clean` and finishes the chunk, without a worker or a place. Where it cannot, as for a pull request closed unmerged or a worktree with uncommitted or untracked files, the worker goes on once a place is free. A parked chunk survives a reboot: run build-epic <EPIC-KEY> again to go on polling.
--status doesn't start any chunk. It prints a line per open issue: that its chunk runs or asks you a question, or why it waits, such as the gate a parked chunk awaits and since when.
--dry-run runs the planning and the scheduling against the epic as Jira holds it. It doesn't write anything to Jira, start a window or ask a question, and it doesn't start any issue in Jira as a real run's chunk does. It prints each label, sub-task, comment, score and rank move that planning would write, each move of a parent issue whose sub-tasks a person filed, the order the issues would start in, each chunk that would start and why each other issue waits. A sub-task not yet filed shows a key such as ABC-new1. A question planning would ask is printed instead of asked. Planning's claude calls still run.
A repo that is missing isn't cloned. Planning then stops there, so its writes are only those made before it, and the issues of that repo wait, and a chunk of another repo may start in the place a real run gives them; a real run would clone it and go on.
{findings.HELP}
{finish.HELP}
The Jira site and its credentials are set in ~/.config/build-release/do-epic/config.toml.
The Jira site and its credentials are set in ~/.config/build-release/build-epic/config.toml.
Where XDG_CONFIG_HOME holds an absolute path, read ~/.config in this help as that path."""
# The folder in the state folder where a chunk's cycles are archived, in a folder per epic. It is not build-release's archive, since that archive's readers, such as judge-replay and the routing figures, read build-release's prompts.
ARCHIVE = "do-epic-transcripts"
ARCHIVE = "build-epic-transcripts"
# The flag that prints what each open issue does.
STATUS_FLAG = "--status"
# The flag that prints what planning and the scheduler would do, without doing it.
@@ -86,10 +86,10 @@ DRY_RUN_FLAG = "--dry-run"
LEVEL_SECONDS = 60
# The store of an epic's issues and its record, for the epic with this key.
Backend = typing.Callable[[DoEpicConfig, str], tuple[EpicStore, EpicRecord]]
Backend = typing.Callable[[BuildEpicConfig, str], tuple[EpicStore, EpicRecord]]
def jira_backend(config: DoEpicConfig, key: str) -> tuple[EpicStore, EpicRecord]:
def jira_backend(config: BuildEpicConfig, key: str) -> tuple[EpicStore, EpicRecord]:
epic = Epic(config.jira_url, key)
return JiraEpic(epic, config.env_file, finish=config.finish, finding_type=config.finding_type, review_type=config.review_type, start=config.start), EpicRecord(EpicDescription(epic, config.env_file))
@@ -100,13 +100,13 @@ def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
except KeyboardInterrupt:
stop = Stop(130, "")
except Exception as crash:
tell(f"do-epic {' '.join(argv)} crashed: {crash!r}", effects)
tell(f"build-epic {' '.join(argv)} crashed: {crash!r}", effects)
raise
if stop.reason:
say(stop.reason, effects, stdout=not stop.code)
# A chunk's stop is DMed, as build-release's is, so a chunk left overnight never ends unseen.
if stop.reason and argv[:1] == [CHUNK_FLAG]:
tell(f"do-epic {' '.join(argv)} stopped: {stop.reason}", effects)
tell(f"build-epic {' '.join(argv)} stopped: {stop.reason}", effects)
return stop.code
@@ -138,7 +138,7 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
def status_printed(epic: EpicRun) -> Stop:
"""What `do-epic <EPIC-KEY> --status` does: prints a line per open issue, and doesn't start anything."""
"""What `build-epic <EPIC-KEY> --status` does: prints a line per open issue, and doesn't start anything."""
issues = epic.store.read()
# Reading a repo's goals may clone it, which a status doesn't do.
reading = dataclasses.replace(epic, effects=dataclasses.replace(epic.effects, git=dry_run.without_clones(epic.effects.git)))
@@ -159,7 +159,7 @@ def epic_written(key: str, writes: findings.Write | None, paths: Paths, env: typ
def windows_opened(epic: EpicRun) -> Stop:
"""What the do-epic the human runs does: plans the open issues (`planning`), starts each chunk that may start now, says why each other open issue waits, then puts the epic's session on the terminal until the human detaches."""
"""What the build-epic the human runs does: plans the open issues (`planning`), starts each chunk that may start now, says why each other open issue waits, then puts the epic's session on the terminal until the human detaches."""
started = planned_and_started(epic)
if isinstance(started, Stop):
return started
@@ -200,7 +200,7 @@ def chunks_said(epic: EpicRun, started: scheduler.Started, verb: str, where: str
def dry_run_printed(epic: EpicRun) -> Stop:
"""What `do-epic <EPIC-KEY> --dry-run` does: plans and starts as `windows_opened` does, on a copy of the epic, a tmux that starts no window and a git that clones no repo, then prints each Jira write planning made on the copy, the scores among them, the order the scored issues would start in, each chunk that would start and why each other issue waits. It doesn't put the session on the terminal or ask a question."""
"""What `build-epic <EPIC-KEY> --dry-run` does: plans and starts as `windows_opened` does, on a copy of the epic, a tmux that starts no window and a git that clones no repo, then prints each Jira write planning made on the copy, the scores among them, the order the scored issues would start in, each chunk that would start and why each other issue waits. It doesn't put the session on the terminal or ask a question."""
dry = dry_run.seeded(epic.store)
if isinstance(dry, Failure):
return Stop(1, dry.reason)
@@ -239,7 +239,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
"""Runs the cycles of the chunk of the issue called key until one stops the loop, or the judge rules the chunk finished. For a human's task it runs no cycle: it waits until the task no longer holds up an issue (`human_tasks.awaited`), then starts the next chunks. A chunk in a repo parks after each cycle that leaves its pull request waiting on a gate, and before its first where it was parked when its window last ended, as at a reboot."""
pane = epic.env.get("TMUX_PANE")
if not pane:
return Stop(1, f"{CHUNK_FLAG} is how do-epic starts itself in a tmux window; run do-epic <EPIC-KEY>")
return Stop(1, f"{CHUNK_FLAG} is how build-epic starts itself in a tmux window; run build-epic <EPIC-KEY>")
# None for the epic's finishing, which is no issue.
issue = None if key == epic.key else issue_read(key, epic)
if isinstance(issue, Stop):
@@ -259,7 +259,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
return based
if issue:
issue_started(key, epic)
session = session_named(f"A {epic.key} do-epic {key}", epic.paths.claude_code_transcripts)
session = session_named(f"A {epic.key} build-epic {key}", epic.paths.claude_code_transcripts)
loop = Loop(root=root, session=session, window=tmux.Window(epic.session, key, pane), paths=epic.paths, env=epic.env, launcher=epic.launcher, effects=epic.effects)
run = ChunkRun()
# What a chunk that was parked is told as it resumes; empty for a chunk that wasn't.
@@ -301,7 +301,7 @@ def epic_based(key: str, root: str, epic: EpicRun) -> str | None | Stop:
level = default if isinstance(default, Failure) else epic_branch.levelled(branch, default.strip(), cwd=root, timeout=LEVEL_SECONDS, run=epic.effects.git)
readied = level if isinstance(level, Failure) else record_chunk_base(key, branch, cwd=root, run=epic.effects.git)
if isinstance(readied, Failure):
return Stop(1, f"cannot ready the epic's working branch {branch} in {root} for {key}: {readied.reason}; once that is settled, run `do-epic {epic.key}` to start the chunk again")
return Stop(1, f"cannot ready the epic's working branch {branch} in {root} for {key}: {readied.reason}; once that is settled, run `build-epic {epic.key}` to start the chunk again")
say(f"{str(level).rstrip('.')}; {key}'s pull request goes into {branch}", epic.effects, stdout=True)
return branch
@@ -363,19 +363,19 @@ def landed_in(repo: str | None, based: str | None) -> Landed:
class How(enum.Enum):
"""How a finished chunk's issue moves when it doesn't move to a status the config names."""
# do-epic neither moves nor awaits it.
# build-epic neither moves nor awaits it.
LEFT = enum.auto()
# Nobody would move it, so the loop stops.
STUCK = enum.auto()
# The team's automation moves it, and do-epic waits for that.
# The team's automation moves it, and build-epic waits for that.
AWAITED = enum.auto()
# do-epic moves it to done.
# build-epic moves it to done.
TO_DONE = enum.auto()
@dataclasses.dataclass(frozen=True)
class ToStatus:
"""do-epic moves a finished chunk's issue to status. Where that move fails, it moves the issue to through first and tries again; through is None where the config names no open status."""
"""build-epic moves a finished chunk's issue to status. Where that move fails, it moves the issue to through first and tries again; through is None where the config names no open status."""
status: str
through: str | None
@@ -409,7 +409,7 @@ def issue_move(landed: Landed, automated: bool, merged: str | None, opened: str
def handed_on(key: str, epic: EpicRun, landed: Landed = Landed.NOWHERE) -> Stop:
"""The stop of a do-epic whose chunk finished. It first moves the chunk's issue as `issue_move` says, and the issue's parent too where the parent's sub-tasks now let it move (`parents_settled`), so that no finished chunk starts again and what they block may start. Then it starts each chunk that may start now. Where the team's automation moves the issue, the stop waits for that move (`moved_by_automation`). do-epic's window closes as it exits."""
"""The stop of a build-epic whose chunk finished. It first moves the chunk's issue as `issue_move` says, and the issue's parent too where the parent's sub-tasks now let it move (`parents_settled`), so that no finished chunk starts again and what they block may start. Then it starts each chunk that may start now. Where the team's automation moves the issue, the stop waits for that move (`moved_by_automation`). build-epic's window closes as it exits."""
move = issue_move(landed, epic.config.automation_moves, epic.config.pull_merged_status, epic.config.pull_open_status, finishing=key == epic.key)
issues: list[EpicIssue] | Failure
match move:
@@ -420,18 +420,18 @@ def handed_on(key: str, epic: EpicRun, landed: Landed = Landed.NOWHERE) -> Stop:
if isinstance(moved, Failure) and through and not isinstance(epic.store.move_issue(key, through), Failure):
moved = epic.store.move_issue(key, status)
if isinstance(moved, Failure):
return Stop(1, f"the chunk finished, but its issue could not move to {status!r}: {moved.reason}; once it has that status in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
return Stop(1, f"the chunk finished, but its issue could not move to {status!r}: {moved.reason}; once it has that status in Jira, run `build-epic {epic.key}` to start the chunks it blocks")
issues = epic.store.read()
# A search may not show the move yet, so the issue counts as moved here whatever the read says.
issues = issues if isinstance(issues, Failure) else [dataclasses.replace(each, status=status) if each.key == key else each for each in issues]
case How.STUCK:
return Stop(1, f"the chunk finished, but its issue stays as it is: its pull request merged into the epic's working branch, where the team's automation moves no issue, and do-epic's config names no `{PULL_MERGED_STATUS}` to move it to. Move {key} in Jira, then run `do-epic {epic.key}` to start the chunks it blocks")
return Stop(1, f"the chunk finished, but its issue stays as it is: its pull request merged into the epic's working branch, where the team's automation moves no issue, and build-epic's config names no `{PULL_MERGED_STATUS}` to move it to. Move {key} in Jira, then run `build-epic {epic.key}` to start the chunks it blocks")
case How.AWAITED:
issues = moved_by_automation(key, epic)
case How.TO_DONE:
moved = epic.store.finish_issue(key)
if isinstance(moved, Failure):
return Stop(1, f"the chunk finished, but its issue could not move to done: {moved.reason}; once it is done in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
return Stop(1, f"the chunk finished, but its issue could not move to done: {moved.reason}; once it is done in Jira, run `build-epic {epic.key}` to start the chunks it blocks")
issues = epic.store.read()
# A search may not show the move yet, so the issue counts as done here whatever the read says.
issues = issues if isinstance(issues, Failure) else [dataclasses.replace(each, done=True) if each.key == key else each for each in issues]
@@ -476,7 +476,7 @@ def parents_moved(epic: EpicRun, issues: list[EpicIssue]) -> list[EpicIssue]:
def parents_settled(epic: EpicRun, issues: list[EpicIssue]) -> list[EpicIssue] | Stop:
"""The issues once each parent has moved as its sub-tasks let it: one whose sub-tasks a person filed (`parents_moved`), then one do-epic split (`split_items_closed`); the stop where a split item cannot move."""
"""The issues once each parent has moved as its sub-tasks let it: one whose sub-tasks a person filed (`parents_moved`), then one build-epic split (`split_items_closed`); the stop where a split item cannot move."""
return split_items_closed(epic, parents_moved(epic, issues))
@@ -486,7 +486,7 @@ def split_items_closed(epic: EpicRun, issues: list[EpicIssue]) -> list[EpicIssue
if split.SPLIT_LABEL in item.labels and not item.done and split.finished(issues, item.key):
moved = epic.store.finish_issue(item.key)
if isinstance(moved, Failure):
return Stop(1, f"the chunk finished, but its split item {item.key} could not move to done: {moved.reason}; once it is done in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
return Stop(1, f"the chunk finished, but its split item {item.key} could not move to done: {moved.reason}; once it is done in Jira, run `build-epic {epic.key}` to start the chunks it blocks")
issues = [dataclasses.replace(each, done=True) if each.key == item.key else each for each in issues]
return issues
@@ -1,11 +1,11 @@
"""Moves a parent issue whose sub-tasks a person filed, once those sub-tasks have landed or are done. Until the parent moves, every issue it blocks waits, and nobody else moves it: the team's automation sees a pull request only on the sub-task that carries it. `main.split_items_closed` closes an item that do-epic split itself."""
"""Moves a parent issue whose sub-tasks a person filed, once those sub-tasks have landed or are done. Until the parent moves, every issue it blocks waits, and nobody else moves it: the team's automation sees a pull request only on the sub-task that carries it. `main.split_items_closed` closes an item that build-epic split itself."""
import dataclasses
from do_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from do_epic.split import SPLIT_LABEL
from do_epic.config import SUB_TASKS_LANDED_TRANSITION
from do_epic.scheduler import unblocks
from build_epic.split import SPLIT_LABEL
from build_epic.config import SUB_TASKS_LANDED_TRANSITION
from build_epic.scheduler import unblocks
def moved(store: EpicStore, issues: list[EpicIssue], unblocking: tuple[str, ...], landed_by: str | None, finishes: bool) -> tuple[list[EpicIssue], list[str]]:
@@ -15,7 +15,7 @@ def moved(store: EpicStore, issues: list[EpicIssue], unblocking: tuple[str, ...]
refused: list[str] = []
for parent in issues:
tasks = [task for task in issues if task.parent == parent.key]
# A sub-task do-epic filed under an item it didn't mark is a split that failed halfway, which the next run completes.
# A sub-task build-epic filed under an item it didn't mark is a split that failed halfway, which the next run completes.
if parent.done or SPLIT_LABEL in parent.labels or all(task.by_loop for task in tasks):
continue
if all(task.done for task in tasks):
@@ -1,4 +1,4 @@
"""The parked chunks of an epic: each keeps its worktree, pull request and session while that pull request waits on a long gate, in a file that survives a reboot (docs/decisions.md → `do-epic: drives one Jira epic …`, "Long gates").
"""The parked chunks of an epic: each keeps its worktree, pull request and session while that pull request waits on a long gate, in a file that survives a reboot (docs/decisions.md → `build-epic: drives one Jira epic …`, "Long gates").
A chunk is parked from the moment its file is written until the file is removed, whatever its window does: `scheduler` starts a window again for a parked chunk that has none, and that window goes on polling."""
import dataclasses
@@ -1,9 +1,9 @@
"""A chunk parked while its pull request waits on a gate (docs/decisions.md → `do-epic: drives one Jira epic …`): `parked_through` keeps it parked from the end of a cycle until its worker has something to do, and `news_after` says what a chunk that isn't parked tells its worker."""
"""A chunk parked while its pull request waits on a gate (docs/decisions.md → `build-epic: drives one Jira epic …`): `parked_through` keeps it parked from the end of a cycle until its worker has something to do, and `news_after` says what a chunk that isn't parked tells its worker."""
import dataclasses
import pathlib
from do_epic import chunk_prompt, gates, parked, scheduler
from do_epic.epic_run import chunks_started, EpicRun, POLL_SECONDS, scheduled_epic
from build_epic import chunk_prompt, gates, parked, scheduler
from build_epic.epic_run import chunks_started, EpicRun, POLL_SECONDS, scheduled_epic
from project_config.main import located as config_located
from failure import Failure
from chunk_driver.this_loop import Loop
@@ -14,19 +14,19 @@ from agent_cycle import tmux
# How the news for a chunk that was parked opens.
DRIVER_PARKED = f"{chunk_prompt.DRIVER} parked the chunk while"
# do-epic's PATH holds only what its user linked there, so chunk-pr is run by its path.
# build-epic's PATH holds only what its user linked there, so chunk-pr is run by its path.
CHUNK_PR = str(RELEASE_ROOT / "bin" / "chunk-pr")
@dataclasses.dataclass(frozen=True)
class Merged:
"""What `parked_through` returns for a chunk whose pull request merged and whose worktree do-epic removed itself: the chunk is finished."""
"""What `parked_through` returns for a chunk whose pull request merged and whose worktree build-epic removed itself: the chunk is finished."""
def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finished: bool, based: str | None) -> str | Stop | Merged:
"""Keeps the chunk in loop's window parked. Its work is in the repo called repo. It stays parked for as long as its pull request waits on a gate, and returns once its worker has something to do: what to tell that worker, or empty where the chunk was never parked. Or Merged, where the chunk's pull request merged and `merged_and_cleaned` removed its worktree: the chunk then needs no worker and no running slot. told is the news its last cycle's worker got, None where the window just started, and finished says the judge ruled the chunk finished. based is the epic's working branch that `epic_based` recorded as the chunk's base when the window started, None where it recorded none. A window that just started parks the chunk only if its file says so: the forge isn't read for a chunk that starts afresh.
Where a person merges, a worker ends its run with the pull request open, so the judge may rule the chunk finished before it is. For such a finished chunk, a gate that cannot be read is read again until it can (`Poll.first_gate`), and what the worker must still do is news (`news_after`), unless the pull request merged already and do-epic removes the worktree itself.
Where a person merges, a worker ends its run with the pull request open, so the judge may rule the chunk finished before it is. For such a finished chunk, a gate that cannot be read is read again until it can (`Poll.first_gate`), and what the worker must still do is news (`news_after`), unless the pull request merged already and build-epic removes the worktree itself.
A chunk parks in three steps: its file is written, its window is shown as parked, and the epic's next chunks start in the slot it frees. It resumes in the reverse order: `scheduler.resume` gives it a running slot, then its file is removed. So a window that ends in between finds the chunk parked when it starts again.
"""
@@ -1,29 +1,29 @@
"""What `do-epic <EPIC-KEY>` settles before it starts chunks: where each open issue is worked, and the order the loop's issues come in (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""What `build-epic <EPIC-KEY>` settles before it starts chunks: where each open issue is worked, and the order the loop's issues come in (docs/decisions.md → `build-epic: drives one Jira epic …`).
An open child issue that no label places is first split by repo (`split`), and where it changes one repo or none, its repo is picked (`repo_pick`). Each is a headless claude call on `repoless-model`'s rung of the shipped ladder. Where the repo rule leaves a pick unclear, the human answers on the terminal. Then, where two or more issues may start, each of them that holds no scores is scored (`issue_scores`), a person's too. The issues start in order of score (`start_order`). The issues do-epic filed are re-ranked in Jira's backlog to match (`ranking`), and the rank of a person's issue stays as the team set it.
An open child issue that no label places is first split by repo (`split`), and where it changes one repo or none, its repo is picked (`repo_pick`). Each is a headless claude call on `repoless-model`'s rung of the shipped ladder. Where the repo rule leaves a pick unclear, the human answers on the terminal. Then, where two or more issues may start, each of them that holds no scores is scored (`issue_scores`), a person's too. The issues start in order of score (`start_order`). The issues build-epic filed are re-ranked in Jira's backlog to match (`ranking`), and the rank of a person's issue stays as the team set it.
Planning runs only in the `do-epic <EPIC-KEY>` the human starts. A chunk that finishes starts the next chunks from the labels and the scores it finds, so no window waits on a question.
Planning runs only in the `build-epic <EPIC-KEY>` the human starts. A chunk that finishes starts the next chunks from the labels and the scores it finds, so no window waits on a question.
Planning holds no lock: one `do-epic <EPIC-KEY>` at a time is assumed. A second one started meanwhile finds the sub-tasks the first filed, since `split` reads them before it files, unless Jira's search lags."""
Planning holds no lock: one `build-epic <EPIC-KEY>` at a time is assumed. A second one started meanwhile finds the sub-tasks the first filed, since `split` reads them before it files, unless Jira's search lags."""
import dataclasses
from collections.abc import Mapping
import pathlib
import re
from build_epic.config import BuildEpicConfig
from loop_state.paths import CLAUDE_HOME
from do_epic.config import DoEpicConfig
from loop_effects.effects import Effects, say
from do_epic.backend.protocol import EpicIssue, EpicStore, no_scores
from do_epic.epic_record import EpicRecord
from build_epic.backend.protocol import EpicIssue, EpicStore, no_scores
from build_epic.epic_record import EpicRecord
from failure import Failure
from record_store.stores import goals_store, store as record_store
from do_epic import issue_scores, ranking, repo_pick, repos, split
from build_epic import issue_scores, ranking, repo_pick, repos, split
from plan.todo_table import Item
from claude_code.reply import Limited
from plan_store.jira_epic import number
from model_routing.ladder_file import read_ladder, SHIPPED
from model_routing.ladder import Rung
from do_epic.scheduler import unblocks
from build_epic.scheduler import unblocks
from plan_store.scoring import weighing_texts
# The epic's formula, stated under its `## Scoring` as a todo.md states its own.
@@ -38,7 +38,7 @@ RULE = f"{CLAUDE_HOME}/rules/todo-items.md"
class Planned:
"""The epic whose open issues are planned."""
key: str
config: DoEpicConfig
config: BuildEpicConfig
store: EpicStore
record: EpicRecord
home: pathlib.Path
@@ -51,7 +51,7 @@ class Planned:
def planned(epic: Planned, issues: list[EpicIssue]) -> tuple[list[EpicIssue], Failure | Limited | None]:
"""The epic's issues as far as they are planned, and why the planning stopped early, None where it didn't. issues are the epic's, as just read.
Each open child issue that no label places, and that isn't split already, is split or gets its pick. Then each issue that holds no scores is scored, and the issues do-epic filed are re-ranked. What was labelled, filed, scored or ranked before a Failure or a Limited stays, and the issues returned show it."""
Each open child issue that no label places, and that isn't split already, is split or gets its pick. Then each issue that holds no scores is scored, and the issues build-epic filed are re-ranked. What was labelled, filed, scored or ranked before a Failure or a Limited stays, and the issues returned show it."""
unplaced = [issue for issue in issues if issue.parent == epic.key and not issue.done and not split.is_split(issue, issues) and repo_pick.recorded(issue, epic.config.label_repos) is None]
added: dict[str, str] = {}
stopped = placed(epic, issues, unplaced, added) if unplaced else None
@@ -68,12 +68,12 @@ def planned(epic: Planned, issues: list[EpicIssue]) -> tuple[list[EpicIssue], Fa
starts = start_order(epic, issues)
if isinstance(starts, Failure):
return issues, starts
# The board's rank of a person's issue is the team's, so only the child issues do-epic filed are re-ranked, among themselves.
# The board's rank of a person's issue is the team's, so only the child issues build-epic filed are re-ranked, among themselves.
ours = {issue.key for issue in issues if issue.by_loop and issue.parent == epic.key}
order = [key for key in starts if key in ours]
if [issue.key for issue in issues if issue.key in order] == order:
return issues, None
say(f"re-ranking the issues do-epic filed in {epic.key}'s backlog", epic.effects, stdout=True)
say(f"re-ranking the issues build-epic filed in {epic.key}'s backlog", epic.effects, stdout=True)
refused = ranking.reranked(epic.store, order)
if refused:
return issues, refused
@@ -130,9 +130,9 @@ def planning_rung(model: str) -> Rung | Failure:
def answered(epic: Planned, issue: EpicIssue, question: str) -> repo_pick.Pick | None | Failure:
"""The pick the human types for an issue the repo rule leaves unclear, once it is recorded; None where nobody is at a terminal to answer, or the human answers with Enter alone, so the issue waits for the next run. The answer is the label to give the issue, so that it is spelt as a person would spell it in Jira.
A repo's name is not checked against the repos do-epic knows: an epic's first issue in a repo names one it has not seen."""
A repo's name is not checked against the repos build-epic knows: an epic's first issue in a repo names one it has not seen."""
if not epic.effects.on_terminal():
say(f"{issue.key} waits for your answer: {question} Run `do-epic {epic.key}` on a terminal to answer, or label the issue in Jira.", epic.effects, stdout=True)
say(f"{issue.key} waits for your answer: {question} Run `build-epic {epic.key}` on a terminal to answer, or label the issue in Jira.", epic.effects, stdout=True)
return None
say(f"\n{issue.key}, {issue.summary}: {question}", epic.effects)
while True:
@@ -1,4 +1,4 @@
"""The order do-epic works an epic's items in: by score, then each blocker above what it blocks (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""The order build-epic works an epic's items in: by score, then each blocker above what it blocks (docs/decisions.md → `build-epic: drives one Jira epic …`).
An item scores by the epic's formula over one chain of goals: the epic's goals, then code health, then the goals of the item's repo. An item without a repo has only the epic's goals. Each achieve goal weighs 0.97 of the one above it in the chain, and the epic's achieve goals weigh the same in every repo, so an achieve goal of the epic outweighs every achieve goal of a repo, whichever repos the two items are in. chain_scoring says what code health and a maintain goal weigh.
@@ -9,7 +9,7 @@ import decimal
from plan.blockers import blockers_first, blocking_loop
from plan.todo_table import CODE_HEALTH, EPIC_GOAL, Item, REPO_GOAL, SHAPE
from do_epic.backend.protocol import EpicStore
from build_epic.backend.protocol import EpicStore
from failure import Failure
from plan.goals_file import GOAL_STEP, goal_weights, goals_section, Mark, numbered, ranked_goals
from review_rules.comprehension_history import latest_overall
@@ -1,4 +1,4 @@
"""Where an epic item is worked, picked by `repo-rule.md` and recorded on the issue (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""Where an epic item is worked, picked by `repo-rule.md` and recorded on the issue (docs/decisions.md → `build-epic: drives one Jira epic …`).
An item is worked in a repo, or has no repo and is either Claude's work, done without a PR, or a human task. A headless claude call with a JSON schema, as the judge makes, reads the repo rule and the item. It picks one of those three, or asks a question where the rule leaves the item unclear. `picked` records the pick as a label on the issue and reads it back later without a claude call; `record` stores the human's answer to a question. A person changes a pick by editing the label."""
import dataclasses
@@ -7,19 +7,19 @@ import re
import typing
from claude_code.reply import Claude, claude_reply, Limited
from do_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from model_routing.ladder import Rung
from claude_code.entries import structured_output
# Three readers, seated as a client's team, picked these spellings from four candidates for each label group, 2-1 each time: `repo:<name>` over `<name>`, `repo-<name>` and `do-epic-repo:<name>`; `do-epic-claude` and `do-epic-human` over `claude-work`, `no-repo:claude` and `done-by-ai`. A team's own `repo:<name>` label reads as a pick, as `repo-rule.md` reads a label that names a repo.
# Three readers, seated as a client's team, picked these spellings from four candidates for each label group, 2-1 each time: `repo:<name>` over `<name>`, `repo-<name>` and `build-epic-repo:<name>`; `build-epic-claude` and `build-epic-human` over `claude-work`, `no-repo:claude` and `done-by-ai`. A team's own `repo:<name>` label reads as a pick, as `repo-rule.md` reads a label that names a repo.
REPO_PREFIX = "repo:"
CLAUDE_LABEL = "do-epic-claude"
HUMAN_LABEL = "do-epic-human"
CLAUDE_LABEL = "build-epic-claude"
HUMAN_LABEL = "build-epic-human"
# 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.-]*")
# A team's own label for a repo, mapped to the repo's name: the LABEL_REPOS table of do-epic's config (config.py).
# A team's own label for a repo, mapped to the repo's name: the LABEL_REPOS table of build-epic's config (config.py).
LabelRepos = typing.Mapping[str, str]
PICK_SCHEMA = {
@@ -80,12 +80,12 @@ def recorded(issue: EpicIssue, team: LabelRepos) -> Pick | None | Failure:
def also(team: LabelRepos) -> str:
"""The team's own labels, to end a list of do-epic's in a prompt or a refusal; empty where the team has none."""
"""The team's own labels, to end a list of build-epic's in a prompt or a refusal; empty where the team has none."""
return f" (or the team's {', '.join(f'`{label}`' for label in sorted(team))})" if team else ""
def of_label(label: str, team: LabelRepos) -> Pick | None:
"""The pick the label records: one of do-epic's own, or one the team's table maps to a repo."""
"""The pick the label records: one of build-epic's own, or one the team's table maps to a repo."""
if label in team:
return Repo(team[label])
if label == CLAUDE_LABEL:
@@ -1,15 +1,15 @@
"""Where an epic's repo is on this machine: its checkout and its project config, found by the repo's name.
A missing checkout is cloned from the host and owner of the epic's other repos (docs/decisions.md → `do-epic: drives one Jira epic …`). Where that is unclear, the answer is an Unsure."""
A missing checkout is cloned from the host and owner of the epic's other repos (docs/decisions.md → `build-epic: drives one Jira epic …`). Where that is unclear, the answer is an Unsure."""
import dataclasses
from collections.abc import Mapping
import pathlib
import re
import shutil
from build_epic.config import BuildEpicConfig
from project_config.settings import by_name, CONFIG, ProjectConfig
from loop_state.paths import config_folder
from do_epic.config import DoEpicConfig
from failure import Failure
from git_cli.git_repo import Git
from forge.commands import url_beside
@@ -36,7 +36,7 @@ class Unsure(Failure):
"""reason is a question for the human."""
def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pathlib.Path, env: Mapping[str, str], git: Git) -> Located | Failure:
def locate(name: str, others: list[pathlib.Path], config: BuildEpicConfig, home: pathlib.Path, env: Mapping[str, str], git: Git) -> Located | Failure:
"""The checkout and project config of the repo called name; others are the checkouts of the epic's other repos.
A project config names the repo's checkout, and it is cloned where missing. Where no config names the repo, it is cloned into the clone folder, if it isn't there, and the human is asked to write the config, since the repo's plan, goals and records are theirs to place.
@@ -51,7 +51,7 @@ def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pa
if isinstance(cloned, Failure):
return cloned
if found is None:
return Unsure(f"{checkout} {'was cloned' if cloned else 'holds the repo'}, but no project config names it. Write {config_folder(env, home)}/<key>/{CONFIG} with `checkout = \"{checkout}\"`, as `project-config --help` shows, and run do-epic again.")
return Unsure(f"{checkout} {'was cloned' if cloned else 'holds the repo'}, but no project config names it. Write {config_folder(env, home)}/<key>/{CONFIG} with `checkout = \"{checkout}\"`, as `project-config --help` shows, and run build-epic again.")
return Located(checkout, found)
@@ -1,27 +1,27 @@
"""Which of an epic's issues run as chunks now, each in its own window of the epic's tmux session (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""Which of an epic's issues run as chunks now, each in its own window of the epic's tmux session (docs/decisions.md → `build-epic: drives one Jira epic …`).
Three limits hold a chunk back: the epic's cap of chunks at once, its repo's `parallel-chunks`, counted across every epic, and a build-release that runs chunks in its repo. A parked chunk (`parked`) counts toward none of them: its window only polls the forge, and `resume` gives it a running slot under the same limits once its worker has something to do. do-epic checks a repo and starts a chunk in it while holding the lock build-release holds when it starts one (`chunk_driver.claims.starting`), so the two never start chunks in one checkout together."""
Three limits hold a chunk back: the epic's cap of chunks at once, its repo's `parallel-chunks`, counted across every epic, and a build-release that runs chunks in its repo. A parked chunk (`parked`) counts toward none of them: its window only polls the forge, and `resume` gives it a running slot under the same limits once its worker has something to do. build-epic checks a repo and starts a chunk in it while holding the lock build-release holds when it starts one (`chunk_driver.claims.starting`), so the two never start chunks in one checkout together."""
import dataclasses
import pathlib
import typing
from do_epic.epic_record import CAP
from build_epic.epic_record import CAP
from chunk_driver.claims import CHUNK_FLAG, epic_chunks, handed, loop_chunks, project_lock, starting
from do_epic.backend.protocol import EpicIssue
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from do_epic.split import finished, is_split, SPLIT_LABEL
from do_epic.repo_pick import HumanTask, LabelRepos, Pick, recorded, Repo
from build_epic.split import finished, is_split, SPLIT_LABEL
from build_epic.repo_pick import HumanTask, LabelRepos, Pick, recorded, Repo
from text_files.markdown_text import listed
from project_config.settings import PARALLEL_CHUNKS
from do_epic.parked import parked_chunks
from build_epic.parked import parked_chunks
from chunk_pr.approval import PARKS
from loop_state.paths import Paths
from agent_cycle import tmux
# The folder in the state folder where a folder per epic key holds the epic's lock file, which `claims.LOCK` names. A chunk without a repo works there.
STATE = "do-epic"
STATE = "build-epic"
# Why a human's task with a live window waits, as the epic's status says.
HUMAN_WAIT = "it is a human's task; do-epic polls Jira until you close it"
HUMAN_WAIT = "it is a human's task; build-epic polls Jira until you close it"
def epic_folder(state: pathlib.Path, key: str) -> pathlib.Path:
@@ -75,7 +75,7 @@ class Epic:
# The checkout of the repo with this name and its `parallel-chunks`, or why the repo cannot be used.
locate: typing.Callable[[str], tuple[pathlib.Path, int] | Failure]
paths: Paths
# The do-epic script each window runs.
# The build-epic script each window runs.
launcher: pathlib.Path
env: typing.Mapping[str, str]
# The team's own labels for its repos.
@@ -153,12 +153,12 @@ def turn_of(issue: EpicIssue, pick: Pick | None | Failure, blocking: list[str],
if isinstance(pick, Failure):
return Waits(issue.key, pick.reason)
if pick is None:
return Waits(issue.key, "no label names its repo" + ("; label it in Jira, since do-epic plans no sub-task" if issue.parent in by_key else ""))
return Waits(issue.key, "no label names its repo" + ("; label it in Jira, since build-epic plans no sub-task" if issue.parent in by_key else ""))
if isinstance(pick, HumanTask):
return Chunk(issue.key, None, human=True) if holds and not blocking else Waits(issue.key, "it is a human's task")
if blocking:
outside = [key for key in blocking if key not in by_key]
unseen = f"; do-epic cannot see {' and '.join(outside)}, outside the epic, finish: remove such a link in Jira once its issue is done" if outside else ""
unseen = f"; build-epic cannot see {' and '.join(outside)}, outside the epic, finish: remove such a link in Jira once its issue is done" if outside else ""
inside = [key for key in blocking if key in by_key]
whom = ("it is" if len(blocking) == 1 else "each is") if not outside else f"{' and '.join(inside)} {'is' if len(inside) == 1 else 'are'}"
until = f", until {whom} {listed((*unblocking, 'done'), 'or')}" if unblocking and inside else ""
@@ -176,7 +176,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, in the epic's start order, so the issue with the highest score takes the first free slot. 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 or parked: 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 parked chunk waits in its window; one without a live window, as after a reboot, starts again as a stopped chunk does, whatever the limits, since it goes on parked. A Failure says why a window could not start; those before it run."""
"""Starts a build-epic in a new window for each of the epic's chunks that may start now, in the epic's start order, so the issue with the highest score takes the first free slot. 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 or parked: it counts as running nowhere, and no stopped chunk starts again. Where own is None, the human's `build-epic <EPIC-KEY>` asks, and each stopped chunk starts again. A parked chunk waits in its window; one without a live window, as after a reboot, starts again as a stopped chunk does, whatever the limits, since it goes on parked. 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, epic.team, epic.unblocking)
found = in_start_order(found, epic.order)
@@ -204,7 +204,7 @@ def start_chunks(epic: Epic, issues: list[EpicIssue], finishing: bool, own: str
elif chunk.issue in parked and chunk.issue in live:
waits.append(Waits(chunk.issue, parked[chunk.issue].waits(live[chunk.issue].awaits)))
elif own and (chunk.issue in stopped or chunk.issue in parked):
waits.append(Waits(chunk.issue, f"its window stopped; run `do-epic {epic.key}` to start it again"))
waits.append(Waits(chunk.issue, f"its window stopped; run `build-epic {epic.key}` to start it again"))
elif slot and len(running) + taken >= epic.cap:
waits.append(Waits(chunk.issue, f"the epic runs as many chunks as its `{CAP}` line allows: {epic.cap}"))
else:
@@ -1,18 +1,18 @@
"""Splits an epic item that changes several repos into one sub-task per repo (docs/decisions.md → `do-epic: drives one Jira epic …`).
"""Splits an epic item that changes several repos into one sub-task per repo (docs/decisions.md → `build-epic: drives one Jira epic …`).
A headless claude call with a JSON schema, as repo_pick makes, predicts from the code which repos the item changes and what changes in each. Where that is more than one repo, `split` files a sub-task under the item for each, labelled for its repo as repo_pick labels an item, and then labels the item SPLIT_LABEL. The item stays the issue that tracks the whole change: `finished` says it is done once every sub-task is. An item a person filed, as against one do-epic filed, gets a comment for the team, in the epic's language, once its sub-tasks are filed."""
A headless claude call with a JSON schema, as repo_pick makes, predicts from the code which repos the item changes and what changes in each. Where that is more than one repo, `split` files a sub-task under the item for each, labelled for its repo as repo_pick labels an item, and then labels the item SPLIT_LABEL. The item stays the issue that tracks the whole change: `finished` says it is done once every sub-task is. An item a person filed, as against one build-epic filed, gets a comment for the team, in the epic's language, once its sub-tasks are filed."""
import dataclasses
import json
from claude_code.reply import Claude, claude_reply, Limited
from do_epic.backend.protocol import EpicIssue, EpicStore
from build_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from do_epic.repo_pick import label_of, LabelRepos, of_label, Repo, REPO_NAME, team_label
from build_epic.repo_pick import label_of, LabelRepos, of_label, Repo, REPO_NAME, team_label
from model_routing.ladder import Rung
from claude_code.entries import structured_output
# Marks an item whose sub-tasks are all filed, so a later run doesn't predict again; a partly split item lacks it.
# Three readers, seated as a client's team, picked this spelling from four candidates, `split-by-repo` over `do-epic-split`, `repo:split` and `has-sub-tasks`, 2-1.
# Three readers, seated as a client's team, picked this spelling from four candidates, `split-by-repo` over `build-epic-split`, `repo:split` and `has-sub-tasks`, 2-1.
SPLIT_LABEL = "split-by-repo"
SPLIT_SCHEMA = {
@@ -60,7 +60,7 @@ class Split:
def is_split(item: EpicIssue, issues: list[EpicIssue]) -> bool:
"""Whether the item is worked through its sub-tasks: it is marked SPLIT_LABEL, or a person filed a sub-task under it. A sub-task do-epic filed doesn't count without the mark: a run that failed after filing some of an item's sub-tasks, before marking it, leaves the next run to file the rest."""
"""Whether the item is worked through its sub-tasks: it is marked SPLIT_LABEL, or a person filed a sub-task under it. A sub-task build-epic filed doesn't count without the mark: a run that failed after filing some of an item's sub-tasks, before marking it, leaves the next run to file the rest."""
return SPLIT_LABEL in item.labels or any(task.parent == item.key and not task.by_loop for task in issues)
@@ -89,14 +89,14 @@ def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool,
continue
key = store.file(issue.key, task_summary(part.repo, issue.summary, team, summary_template), part.change, (label_of(Repo(part.repo), team),))
if isinstance(key, Failure):
return Failure(f"cannot file the sub-task for {part.repo} under {issue.key}: {key.reason}; {sub_tasks_filed(filed)}; run do-epic again to file the rest")
return Failure(f"cannot file the sub-task for {part.repo} under {issue.key}: {key.reason}; {sub_tasks_filed(filed)}; run build-epic again to file the rest")
filed.append(key)
posted = store.comment(issue.key, predicted.comment) if by_person else None
if isinstance(posted, Failure):
return Failure(f"cannot comment on {issue.key}: {posted.reason}; {sub_tasks_filed(filed)}; run do-epic again to post it")
return Failure(f"cannot comment on {issue.key}: {posted.reason}; {sub_tasks_filed(filed)}; run build-epic again to post it")
marked = store.add_label(issue.key, SPLIT_LABEL)
if isinstance(marked, Failure):
return Failure(f"cannot mark {issue.key} as split: {marked.reason}; {sub_tasks_filed(filed)}; run do-epic again to mark it")
return Failure(f"cannot mark {issue.key} as split: {marked.reason}; {sub_tasks_filed(filed)}; run build-epic again to mark it")
return Split(repos, tuple(filed))
@@ -1,12 +1,12 @@
"""What `do-epic <EPIC-KEY> --status` prints: a line per open issue of the epic (docs/decisions.md → `do-epic: drives one Jira epic …`)."""
"""What `build-epic <EPIC-KEY> --status` prints: a line per open issue of the epic (docs/decisions.md → `build-epic: drives one Jira epic …`)."""
import datetime
import pathlib
from do_epic.scheduler import chunks, HUMAN_WAIT
from do_epic.backend.protocol import EpicIssue
from build_epic.scheduler import chunks, HUMAN_WAIT
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from do_epic.parked import file_of, Parked, parked_chunks, SLOT
from do_epic.repo_pick import LabelRepos
from build_epic.parked import file_of, Parked, parked_chunks, SLOT
from build_epic.repo_pick import LabelRepos
from agent_cycle import tmux
UNSCORED = ", after each issue that holds every score, since it doesn't"
@@ -29,7 +29,7 @@ def lines(key: str, folder: pathlib.Path, issues: list[EpicIssue], team: LabelRe
session = tmux.session_name(tmux.EPIC, key)
windows = tmux.listed(session, run)
live = {window.name: window for window in windows if not window.dead}
again = f"run `do-epic {key}` to start it again"
again = f"run `build-epic {key}` to start it again"
reasons = {wait.issue: wait.reason for wait in waits}
# Where no issue starts by score, each starts in the tracker's rank order, which needs no reason.
bare = {chunk.issue for chunk in found if chunk.issue not in order} if order else set()
@@ -43,7 +43,7 @@ def lines(key: str, folder: pathlib.Path, issues: list[EpicIssue], team: LabelRe
elif chunk.human and chunk.issue in live:
reasons[chunk.issue] = HUMAN_WAIT
elif chunk.issue not in live:
reasons[chunk.issue] = f"its window stopped; {again}" if chunk.issue in {window.name for window in windows} else f"it has not started; `do-epic {key}` starts it" + ("" if chunk.human else " once the epic and its repo have room") + ("" if chunk.human or chunk.issue not in bare else UNSCORED)
reasons[chunk.issue] = f"its window stopped; {again}" if chunk.issue in {window.name for window in windows} else f"it has not started; `build-epic {key}` starts it" + ("" if chunk.human else " once the epic and its repo have room") + ("" if chunk.human or chunk.issue not in bare else UNSCORED)
return [line(issue.key, reasons, live, session) for issue in issues if issue.key in reasons or issue.key in live]
@@ -5,10 +5,10 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.config import DoEpicConfig, load
from build_epic.config import BuildEpicConfig, load
from failure import Failure
from project_config.settings import Finish
from do_epic.backend.jira_start import Start
from build_epic.backend.jira_start import Start
SETTINGS = """jira-url = "https://acme.atlassian.net"
env-file = "~/jira.env"
@@ -21,7 +21,7 @@ class ConfigTest(unittest.TestCase):
made = tempfile.TemporaryDirectory()
self.addCleanup(made.cleanup)
self.home = pathlib.Path(made.name).resolve()
self.folder = self.home / ".config/build-release" / "do-epic"
self.folder = self.home / ".config/build-release" / "build-epic"
self.folder.mkdir(parents=True)
def write(self, settings: str | None = SETTINGS, rule: str | None = "A label that equals a repo's name names that repo.\n") -> None:
@@ -37,22 +37,22 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_settings_and_the_rule_and_defaults_the_clone_folder_and_language(self) -> None:
self.write()
self.assertEqual(load(self.home, {}), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
self.assertEqual(load(self.home, {}), BuildEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
def test_reads_the_teams_labels_for_its_repos(self) -> None:
self.write(SETTINGS + '[label-repos]\ntwu-4 = "tenant-web-ui-4"\n"core-4" = "core-4"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(dict(found.label_repos), {"twu-4": "tenant-web-ui-4", "core-4": "core-4"})
def test_names_each_entry_that_is_no_label_mapped_to_a_repo(self) -> None:
self.write(SETTINGS + '[label-repos]\n"repo:api" = "api"\ndo-epic-human = "api"\nsplit-by-repo = "api"\ndo-epic-release-review = "api"\n"two words" = "api"\nweb = "../web"\ncore = 4\nlanguage = "Swedish"\n')
self.write(SETTINGS + '[label-repos]\n"repo:api" = "api"\nbuild-epic-human = "api"\nsplit-by-repo = "api"\nbuild-epic-release-review = "api"\n"two words" = "api"\nweb = "../web"\ncore = 4\nlanguage = "Swedish"\n')
reason = self.failure()
for fault in (
"`label-repos` maps 'repo:api', a label do-epic gives a meaning of its own",
"`label-repos` maps 'do-epic-human', a label do-epic gives a meaning of its own",
"`label-repos` maps 'split-by-repo', a label do-epic gives a meaning of its own",
"`label-repos` maps 'do-epic-release-review', a label do-epic gives a meaning of its own",
"`label-repos` maps 'repo:api', a label build-epic gives a meaning of its own",
"`label-repos` maps 'build-epic-human', a label build-epic gives a meaning of its own",
"`label-repos` maps 'split-by-repo', a label build-epic gives a meaning of its own",
"`label-repos` maps 'build-epic-release-review', a label build-epic gives a meaning of its own",
"`label-repos` maps 'two words', which is no Jira label: a label holds no white space",
"`language` stands below `[label-repos]`, so it is read as a label; move it above the table",
"`label-repos` maps 'web' to '../web', not a repo's name in letters, digits, dots, hyphens and underscores",
@@ -64,13 +64,13 @@ class ConfigTest(unittest.TestCase):
def test_reads_a_template_for_a_sub_tasks_summary(self) -> None:
self.write(SETTINGS + 'sub-task-summary = "{label}: {Summary}"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.sub_task_summary, "{label}: {Summary}")
def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None:
self.write()
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertIsNone(found.sub_task_summary)
def test_refuses_a_template_that_is_no_one_line_with_summary_and_only_known_fields(self) -> None:
@@ -93,7 +93,7 @@ class ConfigTest(unittest.TestCase):
with self.subTest(template=template):
self.write(SETTINGS + f'sub-task-summary = "{template}"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.sub_task_summary, template)
def test_refuses_a_label_repos_that_is_no_table(self) -> None:
@@ -103,13 +103,13 @@ class ConfigTest(unittest.TestCase):
def test_reads_a_clone_folder_and_language_the_config_sets(self) -> None:
self.write(SETTINGS + 'clone-folder = "/srv/repos"\nlanguage = "Brazilian Portuguese"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.clone_folder, found.language), (pathlib.Path("/srv/repos"), "Brazilian Portuguese"))
def test_reads_how_a_finished_epic_closes_and_wants_both_names_or_neither(self) -> None:
self.write(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.finish, Finish("Mark as done", "Done"))
self.write(SETTINGS + 'jira-finish-status = " "\n')
self.assertIn('`jira-finish-status` is \' \', not the name Jira shows, such as "Done"; `jira-finish-status` is set, so `jira-finish-transition` must be too', self.failure())
@@ -117,11 +117,11 @@ class ConfigTest(unittest.TestCase):
def test_reads_how_a_starting_issue_moves_and_which_boards_sprint_it_joins(self) -> None:
self.write(SETTINGS)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.start, Start(None, None))
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 1\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.start, Start("In Progress", 1))
for board, read in (('"6"', "'6'"), ("0", "0"), ("true", "True"), ("6.0", "6.0")):
with self.subTest(board=board):
@@ -131,11 +131,11 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_transition_that_moves_a_parent_whose_sub_tasks_have_all_landed(self) -> None:
self.write(SETTINGS)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertIsNone(found.sub_tasks_landed_transition)
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = "Release Ready"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.sub_tasks_landed_transition, "Release Ready")
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = 5\n')
self.assertIn("`jira-sub-tasks-landed-transition` is 5, not the name Jira shows, such as \"Release Ready\"", self.failure())
@@ -143,23 +143,23 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_unblocking_statuses_and_that_the_teams_automation_moves_issues(self) -> None:
self.write(SETTINGS)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.unblocking, found.automation_moves), ((), False))
self.write(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Done"]\njira-automation-moves-issues = true\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.unblocking, found.automation_moves), (("Release Ready", "Done"), True))
def test_the_issue_types_of_a_finding_and_a_release_review_are_task_where_left_out(self) -> None:
self.write()
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.finding_type, found.review_type), ("Task", "Task"))
def test_reads_the_issue_types_of_a_finding_and_a_release_review(self) -> None:
self.write(SETTINGS + 'jira-finding-type = "Feature"\njira-review-type = "Chore"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.finding_type, found.review_type), ("Feature", "Chore"))
def test_refuses_an_issue_type_that_is_no_name(self) -> None:
@@ -172,11 +172,11 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_statuses_of_an_issue_whose_pull_request_into_an_epic_branch_opened_and_merged(self) -> None:
self.write(SETTINGS)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.pull_open_status, found.pull_merged_status), (None, None))
self.write(SETTINGS + 'jira-unblocking-statuses = ["release ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual((found.pull_open_status, found.pull_merged_status), ("Code Review", "Release Ready"))
def test_refuses_a_pull_request_status_that_is_no_name_and_a_merged_one_that_does_not_unblock(self) -> None:
@@ -244,7 +244,7 @@ class ConfigTest(unittest.TestCase):
def test_keeps_the_credentials_outside_every_config_folder_and_the_clone_folder(self) -> None:
(self.home / ".config/build-release" / "acme").mkdir()
for env_file in ("~/.config/build-release/do-epic/jira.env", "~/.config/build-release/acme/jira.env", "~/code/acme/jira.env"):
for env_file in ("~/.config/build-release/build-epic/jira.env", "~/.config/build-release/acme/jira.env", "~/code/acme/jira.env"):
with self.subTest(env_file):
self.write(SETTINGS.replace("~/jira.env", env_file))
self.assertIn("`env-file` is", self.failure())
@@ -254,10 +254,10 @@ class ConfigTest(unittest.TestCase):
self.assertIn("`env-file` is", self.failure())
def test_accepts_credentials_beside_the_config_folders(self) -> None:
self.write(SETTINGS.replace("~/jira.env", "~/.config/build-release/do-epic.env"))
self.write(SETTINGS.replace("~/jira.env", "~/.config/build-release/build-epic.env"))
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.env_file, self.home / ".config/build-release" / "do-epic.env")
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.env_file, self.home / ".config/build-release" / "build-epic.env")
def test_refuses_while_the_routing_ladder_cannot_be_read(self) -> None:
self.write()
@@ -283,5 +283,5 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_rule_and_the_settings_as_utf8(self) -> None:
self.write(SETTINGS + 'language = "Svenska"\n', rule="Etiketten är repots namn.\n")
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
assert isinstance(found, BuildEpicConfig), found
self.assertEqual(found.repo_rule, "Etiketten är repots namn.\n")
@@ -5,13 +5,13 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic import dry_run
from build_epic import dry_run
from failure import Failure
from do_epic.test_scheduler import issue
from do_epic.backend.fake import MemoryEpic
from build_epic.test_scheduler import issue
from build_epic.backend.fake import MemoryEpic
LISTED = "-t", "=epic-ABC-12", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"
START = ["new-window", "-d", "-t", "=epic-ABC-12:", "-n", "ABC-21", "-c", "/code/api", "-P", "-F", "#{window_id}", "--", "do-epic"]
START = ["new-window", "-d", "-t", "=epic-ABC-12:", "-n", "ABC-21", "-c", "/code/api", "-P", "-F", "#{window_id}", "--", "build-epic"]
def tmux(calls: list[list[str]], shown: str = "ABC-20\t0\t@1\n"):
@@ -102,13 +102,13 @@ class TheEpicItCopies(unittest.TestCase):
def test_notes_each_kind_of_write_in_order(self) -> None:
epic = MemoryEpic("ABC-12", [issue("ABC-20"), issue("ABC-21")])
epic.file("ABC-20", "Sub", "d", ("repo:api", "do-epic-claude"), "ABC-21")
epic.add_label("ABC-21", "do-epic-claude")
epic.file("ABC-20", "Sub", "d", ("repo:api", "build-epic-claude"), "ABC-21")
epic.add_label("ABC-21", "build-epic-claude")
epic.rank("ABC-21", "ABC-20")
epic.comment("ABC-20", " Why. ")
epic.finish_issue("ABC-21")
epic.close("All done")
self.assertEqual(epic.writes, ["file ABC-102 under ABC-20: Sub, labelled do-epic-claude, repo:api, blocked by ABC-21", "label ABC-21 with do-epic-claude", "rank ABC-21 before ABC-20", "comment on ABC-20: Why.", "finish ABC-21", "close the epic: All done"])
self.assertEqual(epic.writes, ["file ABC-102 under ABC-20: Sub, labelled build-epic-claude, repo:api, blocked by ABC-21", "label ABC-21 with build-epic-claude", "rank ABC-21 before ABC-20", "comment on ABC-20: Why.", "finish ABC-21", "close the epic: All done"])
def test_notes_no_write_that_fails(self) -> None:
epic = MemoryEpic("ABC-12", [issue("ABC-20")])
@@ -8,7 +8,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from project_config.settings import Epic
from record_store.jira_description import EpicDescription
from do_epic.epic_record import EpicRecord, language_in, read_section, with_language, with_section
from build_epic.epic_record import EpicRecord, language_in, read_section, with_language, with_section
from failure import Failure
from record_store.fakes import fake_adf, fake_markdown, FakeJira
from record_store.held import Held
@@ -8,13 +8,13 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.test_main import DESCRIPTION, DoEpicTest
from do_epic.epic_record import EpicRecord
from build_epic.test_main import BuildEpicTest, DESCRIPTION
from build_epic.epic_record import EpicRecord
from failure import Failure
from loop_effects.doubles import FakeEffects
from do_epic import findings, main
from build_epic import findings, main
from record_store.held import Held
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
from loop_state.paths import paths_from
@@ -49,11 +49,11 @@ class WrittenDescription:
return Held(text)
class FindingsTest(DoEpicTest):
class FindingsTest(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
self.store = MemoryEpic("ABC-12", list(self.issues))
self.written = WrittenDescription([DESCRIPTION], self.home / ".local/state/build-release/do-epic/ABC-12/decisions.lock")
self.written = WrittenDescription([DESCRIPTION], self.home / ".local/state/build-release/build-epic/ABC-12/decisions.lock")
self.keys: list[str] = []
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
@@ -63,29 +63,29 @@ class FindingsTest(DoEpicTest):
def run_with(self, argv: list[str], stdin: str = "") -> tuple[int, str, str, FakeEffects]:
out, err, fake = io.StringIO(), io.StringIO(), FakeEffects()
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
code = main.main(argv, {}, paths_from(self.home, {}), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, io.StringIO(stdin))
# Without the time each line of do-epic opens with.
code = main.main(argv, {}, paths_from(self.home, {}), pathlib.Path("/b/build-epic"), fake.effects(), self.backend, io.StringIO(stdin))
# Without the time each line of build-epic opens with.
return code, out.getvalue().replace("<1790000000> ", ""), err.getvalue().replace("<1790000000> ", ""), fake
class FilingAFinding(FindingsTest):
def test_files_an_issue_under_the_epic_with_the_detail_piped_in_and_doesnt_start_anything(self) -> None:
code, out, err, fake = self.run_with(["ABC-12", "--file", "Retry the import on a 503"], "The client times out.\n")
self.assertEqual((code, out, err), (0, "Filed ABC-102 in the epic ABC-12. It has no label that says where it is worked, so the next `do-epic ABC-12` picks one: `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", ""))
self.assertEqual((code, out, err), (0, "Filed ABC-102 in the epic ABC-12. It has no label that says where it is worked, so the next `build-epic ABC-12` picks one: `repo:<name>` for the repo that works it, `build-epic-claude` for work of Claude's that changes no repo, or `build-epic-human` for a task of the human's.\n", ""))
self.assertEqual(self.keys, ["ABC-12"])
filed = self.store.issues[-1]
self.assertEqual((filed.key, filed.summary, filed.detail, filed.labels, filed.parent, filed.by_loop), ("ABC-102", "Retry the import on a 503", "The client times out.", (), "ABC-12", True))
self.assertEqual(fake.calls, [], "filing needs no tmux, clone or claude")
def test_a_label_says_where_the_issue_is_worked(self) -> None:
for argv, label in ((["ABC-12", "--file", "Retry", "--label", "repo:api"], "repo:api"), (["ABC-12", "--file", "--label", "do-epic-claude", "Retry"], "do-epic-claude"), (["ABC-12", "--file", "Retry", "--label", "do-epic-human"], "do-epic-human")):
for argv, label in ((["ABC-12", "--file", "Retry", "--label", "repo:api"], "repo:api"), (["ABC-12", "--file", "--label", "build-epic-claude", "Retry"], "build-epic-claude"), (["ABC-12", "--file", "Retry", "--label", "build-epic-human"], "build-epic-human")):
with self.subTest(argv=argv):
code, out, _, _ = self.run_with(argv)
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_label_of_the_teams_says_where_the_issue_is_worked(self) -> None:
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
with (self.home / ".config/build-release/build-epic/config.toml").open("a", encoding="utf-8") as config:
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\n')
code, out, _, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu-4"])
filed = self.store.issues[-1]
@@ -98,11 +98,11 @@ class FilingAFinding(FindingsTest):
self.assertTrue(out.endswith(f"picks one: {findings.worked_by({'twu-4': 'tenant-web-ui-4'})}.\n"), out)
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"])
code, out, _, _ = self.run_with(["ABC-12", "--file", "Review api", "--label", "repo:api", "--label", "build-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")))
code, out, _, _ = self.run_with(["ABC-12", "--file", "Review api", "--label", "do-epic-release-review"])
self.assertEqual((code, out), (0, f"Filed {self.store.issues[-1].key} in the epic ABC-12. It has no label that says where it is worked, so the next `do-epic ABC-12` picks one: `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"))
self.assertEqual((code, out, filed.labels), (0, f"Filed {filed.key} in the epic ABC-12.\n", ("build-epic-release-review", "repo:api")))
code, out, _, _ = self.run_with(["ABC-12", "--file", "Review api", "--label", "build-epic-release-review"])
self.assertEqual((code, out), (0, f"Filed {self.store.issues[-1].key} in the epic ABC-12. It has no label that says where it is worked, so the next `build-epic ABC-12` picks one: `repo:<name>` for the repo that works it, `build-epic-claude` for work of Claude's that changes no repo, or `build-epic-human` for a task of the human's.\n"))
def test_files_the_next_step_of_a_change_blocked_by_the_issue_before_it(self) -> None:
code, out, err, _ = self.run_with(["ABC-12", "--file", "Change it", "--label", "repo:api", "--blocked-by", "ABC-20"], "Detail.\n")
@@ -126,7 +126,7 @@ class FilingAFinding(FindingsTest):
with self.subTest(label=label):
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", label])
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")
self.assertEqual(err, f"cannot file the finding in the epic ABC-12: build-epic doesn't read the label {label!r}; write `repo:<name>` for the repo that works it, `build-epic-claude` for work of Claude's that changes no repo, or `build-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"])
@@ -139,7 +139,7 @@ class FilingAFinding(FindingsTest):
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: Jira answered 401\n"))
def test_stops_where_the_machines_settings_cannot_be_read(self) -> None:
(self.home / ".config/build-release/do-epic/config.toml").unlink()
(self.home / ".config/build-release/build-epic/config.toml").unlink()
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry"])
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
self.assertIn("config.toml", err)
@@ -153,22 +153,22 @@ class FilingAFinding(FindingsTest):
class Instructions(unittest.TestCase):
def test_say_nothing_of_a_next_pull_request_without_the_chunks_issue(self) -> None:
told = findings.instructions("ABC-12", pathlib.Path("/b/do-epic"), "Swedish", {})
told = findings.instructions("ABC-12", pathlib.Path("/b/build-epic"), "Swedish", {})
self.assertTrue(told.endswith("its text on stdin. Write the issue and the decision in Swedish, the epic's language."), told)
self.assertNotIn("--blocked-by", told)
def test_name_the_labels_the_team_has_for_its_repos(self) -> None:
team = {"core": "core-4", "twu-4": "tenant-web-ui-4"}
self.assertIn(f"The label is {findings.worked_by(team)};", findings.instructions("ABC-12", pathlib.Path("/b/do-epic"), "Swedish", team))
self.assertIn(f"The label is {findings.worked_by(team)};", findings.instructions("ABC-12", pathlib.Path("/b/build-epic"), "Swedish", team))
class WorkedBy(unittest.TestCase):
def test_lists_repo_colon_name_alone_for_a_team_without_a_table(self) -> None:
self.assertEqual(findings.worked_by({}), "`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")
self.assertEqual(findings.worked_by({}), "`repo:<name>` for the repo that works it, `build-epic-claude` for work of Claude's that changes no repo, or `build-epic-human` for a task of the human's")
def test_lists_each_repo_the_table_names_once_by_the_first_label_for_it_in_the_order_of_the_repos(self) -> None:
named = findings.worked_by({"twu-4": "tenant-web-ui-4", "core": "core-4", "c4": "core-4"})
self.assertTrue(named.startswith("`core` for the repo core-4, `twu-4` for the repo tenant-web-ui-4, `repo:<name>` for any other repo that works it, `do-epic-claude`"), named)
self.assertTrue(named.startswith("`core` for the repo core-4, `twu-4` for the repo tenant-web-ui-4, `repo:<name>` for any other repo that works it, `build-epic-claude`"), named)
self.assertNotIn("`c4`", named)
@@ -5,25 +5,25 @@ import sys
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
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 build_epic.config import BuildEpicConfig, load
from build_epic.test_main import BuildEpicTest, Description, DESCRIPTION, MODELS, UNREAD
from build_epic.epic_record import EpicRecord
from failure import Failure
from loop_effects.doubles import FakeEffects, judged, Worker
from do_epic import findings, finish, main
from build_epic import findings, finish, main
from project_config.settings import Finish
from do_epic.test_scheduler import issue
from build_epic.test_scheduler import issue
from chunk_driver.claims import LOCK
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
from loop_state.paths import paths_from
from claude_code.session import session_named
from do_epic.test_do_epic import SETTINGS
from build_epic.test_build_epic import SETTINGS
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)]
LAUNCHER = pathlib.Path("/b/build-epic")
REVIEWED = [issue("ABC-20", "repo:api", done=True), issue("ABC-21", "build-epic-claude", done=True), issue("ABC-30", "repo:api", "build-epic-release-review", done=True)]
class WhenTheFinishingIsDue(DoEpicTest):
class WhenTheFinishingIsDue(BuildEpicTest):
def test_is_due_once_the_epic_holds_issues_and_none_is_open(self) -> None:
self.assertIs(finish.due([]), False)
self.assertIs(finish.due([issue("ABC-20", done=True), issue("ABC-21")]), False)
@@ -43,26 +43,26 @@ class WhenTheFinishingIsDue(DoEpicTest):
self.assertEqual(finish.unreviewed(finish.landed(issues[:1], "Release Ready"), {}), ["api"])
def test_a_repo_lacks_its_review_while_a_done_issue_names_it_and_no_review_does(self) -> None:
done = [issue("ABC-20", "repo:web", done=True), issue("ABC-21", "repo:api", done=True), issue("ABC-22", "do-epic-claude", done=True), issue("ABC-23", "repo:docs")]
done = [issue("ABC-20", "repo:web", done=True), issue("ABC-21", "repo:api", done=True), issue("ABC-22", "build-epic-claude", done=True), issue("ABC-23", "repo:docs")]
self.assertEqual(finish.unreviewed(done, {}), ["api", "web"])
self.assertEqual(finish.unreviewed([*done, issue("ABC-30", "repo:api", "do-epic-release-review")], {}), ["web"])
self.assertEqual(finish.unreviewed([issue("ABC-30", "repo:api", "do-epic-release-review", done=True)], {}), [], "a review alone changes no repo")
self.assertEqual(finish.unreviewed([*done, issue("ABC-30", "repo:api", "build-epic-release-review")], {}), ["web"])
self.assertEqual(finish.unreviewed([issue("ABC-30", "repo:api", "build-epic-release-review", done=True)], {}), [], "a review alone changes no repo")
def test_a_label_of_the_teams_names_the_repo_a_done_issue_changed_and_a_review_covers(self) -> None:
team = {"twu-4": "tenant-web-ui-4"}
done = [issue("ABC-20", "twu-4", done=True)]
self.assertEqual(finish.unreviewed(done, team), ["tenant-web-ui-4"])
self.assertEqual(finish.unreviewed([*done, issue("ABC-30", "repo:tenant-web-ui-4", "do-epic-release-review")], team), [])
self.assertIn("- ABC-20 (tenant-web-ui-4): ", finish.task("ABC-12", [*done, issue("ABC-30", "repo:tenant-web-ui-4", "do-epic-release-review", done=True)], team, LAUNCHER, "Swedish"))
self.assertEqual(finish.unreviewed([*done, issue("ABC-30", "repo:tenant-web-ui-4", "build-epic-release-review")], team), [])
self.assertIn("- ABC-20 (tenant-web-ui-4): ", finish.task("ABC-12", [*done, issue("ABC-30", "repo:tenant-web-ui-4", "build-epic-release-review", done=True)], team, LAUNCHER, "Swedish"))
class TheFinishingChunksTask(DoEpicTest):
class TheFinishingChunksTask(BuildEpicTest):
def test_first_asks_for_one_review_issue_per_repo_that_lacks_one(self) -> None:
task = finish.task("ABC-12", [issue("ABC-20", "repo:api", done=True), issue("ABC-21", "repo:web", done=True)], {}, LAUNCHER, "Swedish")
self.assertIn("Finish the epic ABC-12", task)
self.assertIn("first, and api and web have none. ", task)
self.assertIn("first, and api has none. ", finish.task("ABC-12", [issue("ABC-20", "repo:api", done=True)], {}, LAUNCHER, "Swedish"))
self.assertIn('`/b/do-epic ABC-12 --file "<summary>" --label <label> --label do-epic-release-review`', task)
self.assertIn('`/b/build-epic ABC-12 --file "<summary>" --label <label> --label build-epic-release-review`', task)
self.assertIn("`Release review of ABC-12`", task)
self.assertIn("in Swedish", task)
self.assertNotIn("--close-epic", task)
@@ -78,24 +78,24 @@ class TheFinishingChunksTask(DoEpicTest):
self.assertIn("Finish the epic ABC-12", task)
self.assertIn("A goal is met only where the human confirms it", task)
self.assertIn("ask the human to approve the set", task)
self.assertIn("`/b/do-epic ABC-12 --close-epic`", task)
self.assertIn("`/b/build-epic ABC-12 --close-epic`", task)
self.assertIn("in Swedish", task)
self.assertIn("3. Once the human has confirmed every goal, run `project-config epic-branch` in the checkout of each repo the epic changed. Where it fails, the repo keeps no working branch for the epic: skip it. Where it prints a template, run `chunk-pr open-epic ABC-12 \"<title>\"` in that checkout", task)
self.assertIn("Never merge that pull request: a person does.\n4. Then write a summary", task)
self.assertIn("what shipped in each repo, each pull request step 3 opened, and each goal's evidence.", task)
self.assertIn(findings.instructions("ABC-12", LAUNCHER, "Swedish", {}), task)
self.assertIn("The epic's issues, each done:\n\n- ABC-20 (api): Do ABC-20\n- ABC-21: Do ABC-21\n- ABC-30 (api): Do ABC-30", task)
self.assertNotIn("do-epic-release-review`", task)
self.assertNotIn("build-epic-release-review`", task)
class ClosingTheEpic(DoEpicTest):
class ClosingTheEpic(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
self.issues = list(REVIEWED)
self.store = MemoryEpic("ABC-12", self.issues)
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
self.assertIsInstance(config, DoEpicConfig)
self.assertIsInstance(config, BuildEpicConfig)
self.store.issues = list(self.issues)
return self.store, EpicRecord(Description(self.description)) # type: ignore[arg-type]
@@ -127,15 +127,15 @@ class ClosingTheEpic(DoEpicTest):
self.assertEqual(finish.closed("ABC-12", Unreadable("ABC-12", list(REVIEWED)), {}, io.StringIO("Shipped.")), Failure("cannot close the epic ABC-12: Jira answered 503"))
def test_the_jira_backend_closes_an_epic_by_the_transition_the_settings_name(self) -> None:
with open(self.home / ".config/build-release/do-epic/config.toml", "a", encoding="utf-8") as settings:
with open(self.home / ".config/build-release/build-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
assert isinstance(config, BuildEpicConfig), config
store, _ = main.jira_backend(config, "ABC-12")
self.assertEqual(store.finish, Finish("Mark as done", "Done")) # type: ignore[attr-defined]
def test_closes_an_epic_whose_open_issues_all_have_the_merged_status(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
self.issues.append(issue("ABC-31", "repo:api", status="Release Ready"))
code, out, err = self.close()
self.assertEqual(code, 0, err)
@@ -154,7 +154,7 @@ class ClosingTheEpic(DoEpicTest):
self.issues.append(issue("ABC-31", "repo:web", done=True))
code, _, err = self.close()
self.assertEqual(code, 1)
self.assertIn("cannot close the epic ABC-12: no issue labelled do-epic-release-review reviews web\n", err)
self.assertIn("cannot close the epic ABC-12: no issue labelled build-epic-release-review reviews web\n", err)
self.assertEqual((self.store.comments, self.store.done), ({}, False))
self.issues.append(issue("ABC-32", "repo:docs", done=True))
self.assertIn("reviews docs or web\n", self.close()[2])
@@ -174,11 +174,11 @@ class ClosingTheEpic(DoEpicTest):
for argv in (["ABC-12", "--close-epic", "now"], ["--close-epic", "ABC-12"], ["--close-epic"]):
code, out, err = self.run_main(argv, FakeEffects())
self.assertEqual((code, out), (1, ""), argv)
self.assertIn("usage: do-epic <EPIC-KEY> [--status | --dry-run]\n", err)
self.assertIn("do-epic <EPIC-KEY> --close-epic <<'EOF' summary EOF", err)
self.assertIn("usage: build-epic <EPIC-KEY> [--status | --dry-run]\n", err)
self.assertIn("build-epic <EPIC-KEY> --close-epic <<'EOF' summary EOF", err)
class TheFinishingChunk(DoEpicTest):
class TheFinishingChunk(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
self.store = MemoryEpic("ABC-12", [])
@@ -188,28 +188,28 @@ class TheFinishingChunk(DoEpicTest):
return self.store, EpicRecord(Description(self.description)) # type: ignore[arg-type]
def started(self, fake: FakeEffects) -> list[str]:
"""The name of each window do-epic started."""
"""The name of each window build-epic started."""
return [args[args.index("-n") + 1] for args in fake.tmux_calls if args[0] in ("new-session", "new-window")]
def test_starts_in_a_window_named_for_the_epic_once_no_issue_is_open(self) -> None:
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
self.issues = [issue("ABC-20", "build-epic-claude", done=True)]
fake = FakeEffects(on_terminal=False)
code, out, err = self.run_main(["ABC-12"], fake)
self.assertEqual(code, 0, err)
self.assertIn("started ABC-12 in the tmux session epic-ABC-12\n", out)
self.assertEqual(self.started(fake), ["ABC-12"])
self.assertIn(["/b/do-epic", "--chunk", "ABC-12", "ABC-12"], [args[-4:] for args in fake.tmux_calls])
self.assertIn(["/b/build-epic", "--chunk", "ABC-12", "ABC-12"], [args[-4:] for args in fake.tmux_calls])
def test_starts_once_each_open_issue_has_the_merged_status(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
self.issues = [issue("ABC-20", "do-epic-claude", status="Release Ready"), issue("ABC-21", "do-epic-claude", done=True)]
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
self.issues = [issue("ABC-20", "build-epic-claude", status="Release Ready"), issue("ABC-21", "build-epic-claude", done=True)]
fake = FakeEffects(on_terminal=False)
code, out, err = self.run_main(["ABC-12"], fake)
self.assertEqual(code, 0, err)
self.assertEqual(self.started(fake), ["ABC-12"])
def test_doesnt_start_while_an_issue_is_open_or_in_an_epic_without_issues(self) -> None:
for issues in ([issue("ABC-20", "do-epic-claude", done=True), issue("ABC-21", "do-epic-human")], []):
for issues in ([issue("ABC-20", "build-epic-claude", done=True), issue("ABC-21", "build-epic-human")], []):
self.issues = issues
fake = FakeEffects(on_terminal=False)
code, out, _ = self.run_main(["ABC-12"], fake)
@@ -217,7 +217,7 @@ class TheFinishingChunk(DoEpicTest):
self.assertIn("started no chunk\n", out)
def test_doesnt_start_in_an_epic_that_is_closed(self) -> None:
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
self.issues = [issue("ABC-20", "build-epic-claude", done=True)]
self.store.done = True
fake = FakeEffects(on_terminal=False)
code, out, _ = self.run_main(["ABC-12"], fake)
@@ -234,16 +234,16 @@ class TheFinishingChunk(DoEpicTest):
self.assertIn("the chunk finished; started no other\n", out)
streamed = " ".join([what for seam, what in fake.calls if seam == "stream_claude"][0])
self.assertIn("Finish the epic ABC-12", streamed)
self.assertIn("`/b/do-epic ABC-12 --close-epic`", streamed)
self.assertIn("`/b/build-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/build-release/do-epic/ABC-12").is_dir())
self.assertTrue((self.home / ".local/state/build-release/build-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)
session = session_named("A ABC-12 build-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")
@@ -252,11 +252,11 @@ class TheFinishingChunk(DoEpicTest):
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))
self.assertIn("`/b/build-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/build-release/do-epic/ABC-12" / LOCK).mkdir(parents=True)
self.issues = [issue("ABC-20", "build-epic-claude", done=True)]
(self.home / ".local/state/build-release/build-epic/ABC-12" / LOCK).mkdir(parents=True)
code, _, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False))
self.assertEqual(code, 1)
self.assertIn("cannot lock ", err)
@@ -266,7 +266,7 @@ class TheFinishingChunk(DoEpicTest):
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.issues = [*REVIEWED, issue("ABC-31", "build-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)
@@ -276,7 +276,7 @@ class TheFinishingChunk(DoEpicTest):
self.assertEqual([seam for seam, _ in fake.calls if seam == "stream_claude"], [])
def test_asking_for_the_finishing_chunks_work_names_a_reopened_epic_and_doesnt_start_any_window(self) -> None:
self.issues = [*REVIEWED, issue("ABC-31", "do-epic-claude")]
self.issues = [*REVIEWED, issue("ABC-31", "build-epic-claude")]
fake = FakeEffects(windows="ABC-12\t0\t@9\n")
out = io.StringIO()
with contextlib.redirect_stdout(out):
@@ -5,8 +5,8 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.gates import APPROVAL, CHECKS, gate, Gate, MERGE, NEW_REVIEW, Open, Unmergeable, Unopened
from do_epic.parking import CHUNK_PR
from build_epic.gates import APPROVAL, CHECKS, gate, Gate, MERGE, NEW_REVIEW, Open, Unmergeable, Unopened
from build_epic.parking import CHUNK_PR
from failure import Failure
WORKTREES = "worktree /code/billing\nHEAD aaa\nbranch refs/heads/main\n\nworktree /code/billing-ABC-21\nHEAD abc\nbranch refs/heads/ABC-21\n"
@@ -6,24 +6,24 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from build_epic.test_main import BuildEpicTest, DESCRIPTION, Description, MODELS, UNREAD
from project_config.doubles import configured
from do_epic.test_main import DESCRIPTION, Description, DoEpicTest, MODELS, UNREAD
from do_epic.epic_record import EpicRecord
from build_epic.epic_record import EpicRecord
from failure import Failure
from loop_effects.doubles import FakeEffects
from do_epic.human_tasks import holds_up
from do_epic.scheduler import HUMAN_WAIT
from do_epic.test_scheduler import issue
from do_epic.backend.fake import MemoryEpic
from build_epic.human_tasks import holds_up
from build_epic.scheduler import HUMAN_WAIT
from build_epic.test_scheduler import issue
from build_epic.backend.fake import MemoryEpic
# The window of ABC-19, a human's task that blocks ABC-21.
WINDOW = "ABC-19\t0\t@9\n"
class AHumanTaskThatBlocksAnIssue(DoEpicTest):
class AHumanTaskThatBlocksAnIssue(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
self.issues = [issue("ABC-19", "do-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-19",))]
self.issues = [issue("ABC-19", "build-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-19",))]
self.issues[0] = dataclasses.replace(self.issues[0], summary="Order the test certificate")
self.epic = MemoryEpic("ABC-12", self.issues)
self.backend = lambda config, key: (self.epic, EpicRecord(Description(self.description))) # type: ignore[method-assign, arg-type]
@@ -52,7 +52,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
def moved_to_an_unblocking_status(self, switch: str, frees: tuple[str, dict[str, object]] = ("ABC-19", {"status": "Release Ready"}), starts: str = "ABC-21") -> bool:
"""Whether Jira counts the task done after its window's run, where the config ends with switch. frees is the change in Jira that ends the wait: by default the human moves the task to an unblocking status. starts is what the window then starts."""
with (self.home / ".config/build-release" / "do-epic" / "config.toml").open("a") as config:
with (self.home / ".config/build-release" / "build-epic" / "config.toml").open("a") as config:
config.write('jira-unblocking-statuses = ["Release Ready"]\n' + switch)
fake = FakeEffects(git=UNREAD, windows=WINDOW)
slept: list[int] = []
@@ -78,7 +78,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
self.assertFalse(self.moved_to_an_unblocking_status("jira-automation-moves-issues = true\n", ("ABC-21", {"done": True}), starts="no other"))
def test_a_task_holds_up_only_the_issues_no_unblocking_status_settles(self) -> None:
issues = [issue("ABC-19", "do-epic-human"), issue("ABC-20", "do-epic-claude", blockers=("ABC-19",), status="Release Ready"), issue("ABC-21", "do-epic-claude", blockers=("ABC-19",))]
issues = [issue("ABC-19", "build-epic-human"), issue("ABC-20", "build-epic-claude", blockers=("ABC-19",), status="Release Ready"), issue("ABC-21", "build-epic-claude", blockers=("ABC-19",))]
self.assertEqual(holds_up("ABC-19", issues, {}, ("Release Ready",)), ["ABC-21"])
def test_dms_the_human_once_parks_its_window_and_polls_until_the_issue_closes_then_starts_the_next(self) -> None:
@@ -108,7 +108,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
self.assertEqual(fake.dm_directories, [str(self.api)])
def test_the_dm_goes_through_the_notifier_of_another_open_issues_repo_where_the_held_up_issue_has_none(self) -> None:
self.epic.change("ABC-21", labels=("do-epic-claude",))
self.epic.change("ABC-21", labels=("build-epic-claude",))
self.epic.issues.append(issue("ABC-40", "repo:api"))
fake = FakeEffects(git=UNREAD, windows=WINDOW)
self.awaited(fake, closes_after=1)
@@ -124,7 +124,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
self.assertEqual(out.count("<1790000000> no DM went out"), 1, out)
def test_the_window_of_a_closed_task_goes_on_while_another_human_task_still_holds_an_issue_up(self) -> None:
self.epic.issues.extend([issue("ABC-30", "do-epic-human"), issue("ABC-31", "do-epic-claude", blockers=("ABC-30",))])
self.epic.issues.extend([issue("ABC-30", "build-epic-human"), issue("ABC-31", "build-epic-claude", blockers=("ABC-30",))])
fake = FakeEffects(git=UNREAD, windows=WINDOW)
code, out, err = self.awaited(fake, closes_after=1)
self.assertEqual((code, err), (0, ""))
@@ -142,10 +142,10 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
fake = FakeEffects(windows="")
code, out, err = self.run_main(["ABC-12", "--status"], fake)
self.assertEqual((code, err), (0, ""))
self.assertEqual(out.replace("<1790000000> ", "").splitlines()[0], "ABC-19 waits: it has not started; `do-epic ABC-12` starts it")
self.assertEqual(out.replace("<1790000000> ", "").splitlines()[0], "ABC-19 waits: it has not started; `build-epic ABC-12` starts it")
def test_a_task_that_blocks_two_issues_names_both(self) -> None:
self.epic.issues.append(issue("ABC-22", "do-epic-claude", blockers=("ABC-19",)))
self.epic.issues.append(issue("ABC-22", "build-epic-claude", blockers=("ABC-19",)))
fake = FakeEffects(git=UNREAD, windows=WINDOW)
self.awaited(fake, closes_after=1)
self.assertIn("blocks ABC-21 and ABC-22. ", fake.dms[0])
@@ -5,9 +5,9 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.issue_scores import answer_of, asked, prompt, SCHEMA, Scores
from do_epic.test_repo_pick import Claude, says
from do_epic.backend.protocol import EpicIssue
from build_epic.issue_scores import answer_of, asked, prompt, SCHEMA, Scores
from build_epic.test_repo_pick import Claude, says
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from model_routing.ladder import Rung
@@ -4,7 +4,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.main import Landed, landed_in
from build_epic.main import Landed, landed_in
class WhereTheWorkOfAFinishedChunkLanded(unittest.TestCase):
@@ -12,27 +12,27 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.parking import CHUNK_PR
from do_epic import chunk_prompt, epic_run, main, planning
from build_epic.config import BuildEpicConfig
from build_epic.parking import CHUNK_PR
from build_epic import chunk_prompt, epic_run, main, planning
from chunk_driver.chunk_run import ChunkRun
from project_config.doubles import configured
from do_epic.config import DoEpicConfig
from project_config.settings import Epic, Finish
from do_epic.epic_record import EpicRecord
from build_epic.epic_record import EpicRecord
from agent_cycle import escalation_mark, judge, tmux
from failure import Failure
from loop_effects.doubles import FakeEffects, judged, Worker
from do_epic.test_gates import Forge
from do_epic.test_scheduler import issue
from build_epic.test_gates import Forge
from build_epic.test_scheduler import issue
from chunk_driver.this_loop import Loop
from do_epic.backend.fake import MemoryEpic
from do_epic import parked
from build_epic.backend.fake import MemoryEpic
from build_epic import parked
from loop_state.paths import paths_from
from text_files.file_writes import replace_file
from model_routing.route import Route
from model_routing.ladder import Rung
from do_epic.test_do_epic import SETTINGS
from do_epic.backend.jira_start import Start
from build_epic.test_build_epic import SETTINGS
from build_epic.backend.jira_start import Start
DESCRIPTION = "**Max parallel chunks:** 2\n\n## Goals\nShip the import.\n\n## Audience\nThe client's team.\n"
@@ -51,16 +51,16 @@ class Description:
return self.text
class DoEpicTest(unittest.TestCase):
class BuildEpicTest(unittest.TestCase):
def setUp(self) -> None:
made = tempfile.TemporaryDirectory()
self.addCleanup(made.cleanup)
self.home = pathlib.Path(made.name).resolve()
folder = self.home / ".config/build-release" / "do-epic"
folder = self.home / ".config/build-release" / "build-epic"
folder.mkdir(parents=True)
(folder / "config.toml").write_text(SETTINGS, encoding="utf-8")
(folder / "repo-rule.md").write_text("A label that equals a repo's name names that repo.\n", encoding="utf-8")
self.issues = [issue("ABC-20", "do-epic-human"), dataclasses.replace(issue("ABC-21", "do-epic-claude"), detail="Tidy the docs.", scores={"L": 3, "E": 2, "I": 3})]
self.issues = [issue("ABC-20", "build-epic-human"), dataclasses.replace(issue("ABC-21", "build-epic-claude"), detail="Tidy the docs.", scores={"L": 3, "E": 2, "I": 3})]
self.description: str | Failure = DESCRIPTION
# What the forge answers each read of a chunk's gate, in turn; the last answers every later read. No worktree has the chunk's branch, so no chunk parks.
self.forges = [Forge(worktrees="worktree /code/api\nbranch refs/heads/main\n")]
@@ -91,53 +91,53 @@ class DoEpicTest(unittest.TestCase):
config = main.load(self.home, {})
assert not isinstance(config, Failure)
store, record = self.backend(config, "ABC-12")
return epic_run.EpicRun("ABC-12", config, store, record, paths_from(self.home, env or {}), env or {}, pathlib.Path("/b/do-epic"), fake.effects())
return epic_run.EpicRun("ABC-12", config, store, record, paths_from(self.home, env or {}), env or {}, pathlib.Path("/b/build-epic"), fake.effects())
def run_main(self, argv: list[str], fake: FakeEffects, env: dict[str, str] | None = None) -> tuple[int, str, str]:
out, err = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
code = main.main(argv, env or {}, paths_from(self.home, env or {}), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, forge_at=self.forge_at)
code = main.main(argv, env or {}, paths_from(self.home, env or {}), pathlib.Path("/b/build-epic"), fake.effects(), self.backend, forge_at=self.forge_at)
return code, out.getvalue(), err.getvalue()
class TheJiraBackend(unittest.TestCase):
def test_reads_the_epic_with_the_credentials_and_the_finish_the_config_names(self) -> None:
config = DoEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", Finish("Mark as done", "Done"))
config = BuildEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", Finish("Mark as done", "Done"))
store, record = main.jira_backend(config, "ABC-12")
self.assertEqual((store.epic, store.env_file, store.finish), (Epic("https://acme.atlassian.net", "ABC-12"), pathlib.Path("/h/jira.env"), Finish("Mark as done", "Done"))) # type: ignore[attr-defined]
self.assertEqual((record.description.epic, record.description.env_file), (store.epic, store.env_file)) # type: ignore[attr-defined]
def test_starts_an_issue_as_the_config_says(self) -> None:
config = DoEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", start=Start("In Progress", 6))
config = BuildEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", start=Start("In Progress", 6))
store, _ = main.jira_backend(config, "ABC-12")
self.assertEqual(store.start, Start("In Progress", 6)) # type: ignore[attr-defined]
def test_files_the_issue_types_the_config_names(self) -> None:
config = DoEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", finding_type="Feature", review_type="Chore")
config = BuildEpicConfig(pathlib.Path("/c"), "https://acme.atlassian.net", pathlib.Path("/h/jira.env"), pathlib.Path("/h/code"), "English", "claude-opus-5-5", "rule", finding_type="Feature", review_type="Chore")
store, _ = main.jira_backend(config, "ABC-12")
self.assertEqual((store.finding_type, store.review_type), ("Feature", "Chore")) # type: ignore[attr-defined]
class TheLauncher(unittest.TestCase):
def test_the_repo_ships_a_do_epic_that_prints_its_help(self) -> None:
launcher = pathlib.Path(__file__).resolve().parents[1] / "do-epic"
def test_the_repo_ships_a_build_epic_that_prints_its_help(self) -> None:
launcher = pathlib.Path(__file__).resolve().parents[1] / "build-epic"
ran = subprocess.run([str(launcher), "--help"], capture_output=True, text=True, timeout=60)
self.assertEqual((ran.returncode, ran.stdout.split(" ", 2)[2]), (0, main.HELP + "\n"))
tracked = subprocess.run(["git", "ls-files", "--error-unmatch", launcher.name], capture_output=True, cwd=launcher.parent)
self.assertEqual(tracked.returncode, 0, "bin/do-epic is not in the repo; .gitignore lists what it keeps")
self.assertEqual(tracked.returncode, 0, "bin/build-epic is not in the repo; .gitignore lists what it keeps")
class TheCommand(DoEpicTest):
class TheCommand(BuildEpicTest):
def test_prints_the_help_for_anything_but_one_epic_key(self) -> None:
for argv, code in ((["--help"], 0), (["-h"], 0), ([], 1), (["abc"], 1), (["ABC-12", "ABC-13"], 1), (["--chunk", "x", "ABC-12"], 1), (["--chunk", "ABC-12"], 1)):
with self.subTest(argv=argv):
ran_code, out, err = self.run_main(argv, FakeEffects())
self.assertEqual((ran_code, (err if code else out).split(" ", 1)[1]), (code, main.HELP + "\n"))
def test_refuses_a_tmux_too_old_naming_do_epic(self) -> None:
def test_refuses_a_tmux_too_old_naming_build_epic(self) -> None:
code, _, err = self.run_main(["ABC-12"], FakeEffects(tmux_version="tmux 3.1"))
self.assertEqual(code, 1)
self.assertIn("do-epic runs each chunk in a tmux window, and needs tmux 3.2 or later; it found tmux 3.1", err)
self.assertIn("build-epic runs each chunk in a tmux window, and needs tmux 3.2 or later; it found tmux 3.1", err)
def test_starts_the_chunks_and_says_why_each_other_issue_waits(self) -> None:
fake = FakeEffects(on_terminal=False)
@@ -146,7 +146,7 @@ class TheCommand(DoEpicTest):
self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out)
self.assertIn("ABC-20 waits: it is a human's task\n", out)
started = [args for args in fake.tmux_calls if args[0] == "new-session"]
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]])
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/build-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/build-epic", "--chunk", "ABC-21", "ABC-12"]])
# The session is no checkout's, so nothing marks it as one's.
self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"])
@@ -155,7 +155,7 @@ class TheCommand(DoEpicTest):
fake = FakeEffects(on_terminal=False, claude=[structured({"parts": []}), structured({"pick": "claude"})])
code, out, err = self.run_main(["ABC-12"], fake)
self.assertEqual(code, 0, err)
self.assertLess(out.index("ABC-20 is labelled do-epic-claude\n"), out.index("started ABC-20 in the tmux session epic-ABC-12\n"))
self.assertLess(out.index("ABC-20 is labelled build-epic-claude\n"), out.index("started ABC-20 in the tmux session epic-ABC-12\n"))
def test_starts_no_chunk_where_a_usage_limit_ends_the_planning(self) -> None:
self.issues.append(issue("ABC-22"))
@@ -167,7 +167,7 @@ class TheCommand(DoEpicTest):
self.assertEqual([args for args in fake.tmux_calls if args[0] == "new-session"], [])
def test_says_why_the_epic_is_not_planned_in_full_and_starts_the_chunks_that_may_start(self) -> None:
self.issues = [dataclasses.replace(issue(key, "do-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1}, by_loop=True) for key in ("ABC-20", "ABC-21")]
self.issues = [dataclasses.replace(issue(key, "build-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1}, by_loop=True) for key in ("ABC-20", "ABC-21")]
code, out, err = self.run_main(["ABC-12"], FakeEffects())
self.assertEqual(code, 0, err)
self.assertIn("the epic ABC-12 is not planned in full: the epic ABC-12's description states `Score = ...` 0 times under ## Scoring", err)
@@ -180,12 +180,12 @@ class TheCommand(DoEpicTest):
self.assertEqual(code, 1)
self.assertIn("Jira answered 401\n", err)
def test_a_chunk_outside_a_tmux_window_says_how_to_run_do_epic(self) -> None:
def test_a_chunk_outside_a_tmux_window_says_how_to_run_build_epic(self) -> None:
fake = FakeEffects()
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake)
self.assertEqual(code, 1)
self.assertIn("--chunk is how do-epic starts itself in a tmux window; run do-epic <EPIC-KEY>\n", err)
self.assertEqual(fake.dms, ["do-epic --chunk ABC-21 ABC-12 stopped: --chunk is how do-epic starts itself in a tmux window; run do-epic <EPIC-KEY>"])
self.assertIn("--chunk is how build-epic starts itself in a tmux window; run build-epic <EPIC-KEY>\n", err)
self.assertEqual(fake.dms, ["build-epic --chunk ABC-21 ABC-12 stopped: --chunk is how build-epic starts itself in a tmux window; run build-epic <EPIC-KEY>"])
def test_a_chunk_of_an_issue_the_epic_lacks_stops(self) -> None:
code, _, err = self.run_main(["--chunk", "ABC-99", "ABC-12"], FakeEffects(), {"TMUX_PANE": "%1"})
@@ -193,9 +193,9 @@ class TheCommand(DoEpicTest):
self.assertIn("ABC-99 is no issue of the epic ABC-12\n", err)
class ACycleOfAChunkWithoutARepo(DoEpicTest):
class ACycleOfAChunkWithoutARepo(BuildEpicTest):
def test_naming_the_chunks_folder_doesnt_make_it(self) -> None:
folder = self.home / ".local/state/build-release/do-epic/ABC-12"
folder = self.home / ".local/state/build-release/build-epic/ABC-12"
self.assertEqual(main.chunk_root("ABC-21", self.issues[1], self.epic_run(FakeEffects())), (str(folder), None))
self.assertFalse(folder.exists())
self.assertIsNone(main.folder_made(str(folder)))
@@ -203,10 +203,10 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
def test_a_chunk_whose_folder_cannot_be_made_stops_with_the_reason(self) -> None:
(self.home / ".local/state/build-release").mkdir(parents=True, exist_ok=True)
(self.home / ".local/state/build-release/do-epic").write_text("", encoding="utf-8")
(self.home / ".local/state/build-release/build-epic").write_text("", encoding="utf-8")
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], FakeEffects(), {"TMUX_PANE": "%1"})
self.assertEqual(code, 1)
self.assertRegex(err, f"could not make the chunk's folder {self.home}/.local/state/build-release/do-epic/ABC-12: \\w")
self.assertRegex(err, f"could not make the chunk's folder {self.home}/.local/state/build-release/build-epic/ABC-12: \\w")
def cycle(self, env: dict[str, str] | None = None, run: ChunkRun = ChunkRun(1)) -> main.Cycle:
fake = FakeEffects(git=[Failure("no git"), Failure("no git")])
@@ -216,7 +216,7 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
assert isinstance(place, tuple)
root, repo = place
self.assertIsNone(main.folder_made(root))
loop = Loop(root=root, session=main.session_named("A ABC-12 do-epic ABC-21", paths.claude_code_transcripts), window=tmux.Window("epic-ABC-12", "ABC-21", "%1"), paths=paths, env=env or {}, launcher=pathlib.Path("/b/do-epic"), effects=fake.effects())
loop = Loop(root=root, session=main.session_named("A ABC-12 build-epic ABC-21", paths.claude_code_transcripts), window=tmux.Window("epic-ABC-12", "ABC-21", "%1"), paths=paths, env=env or {}, launcher=pathlib.Path("/b/build-epic"), effects=fake.effects())
with contextlib.redirect_stdout(io.StringIO()):
found = main.next_cycle(run, loop, repo is not None, epic)
assert isinstance(found, main.Cycle), found
@@ -243,7 +243,7 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
def test_works_in_the_epics_folder_and_archives_apart_from_build_release(self) -> None:
cycle = self.cycle()
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/build-release/do-epic/ABC-12"), self.home / ".local/state/build-release/do-epic-transcripts/ABC-12", ""))
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/build-release/build-epic/ABC-12"), self.home / ".local/state/build-release/build-epic-transcripts/ABC-12", ""))
def test_the_records_are_the_epics_scoring_and_decisions_then_the_humans_rules(self) -> None:
self.description = DESCRIPTION + "\n## Scoring\nE + I, bar 4.\n\n## Decisions\n### Merges squash\nAlways.\n"
@@ -263,7 +263,7 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
def test_the_task_is_the_issue(self) -> None:
task = self.cycle().task
self.assertTrue(task.startswith("Work the Jira issue ABC-21 of the epic ABC-12 as one chunk, which changes no repo: work in the folder you start in. File a finding"), task)
self.assertIn('with `/b/do-epic ABC-12 --file "<summary>" --label <label>` and its detail on stdin', task)
self.assertIn('with `/b/build-epic ABC-12 --file "<summary>" --label <label>` and its detail on stdin', task)
self.assertIn("Write the issue and the decision in English, the epic's language.", task)
self.assertTrue(task.endswith(" Its summary: Do ABC-21\n\nIts description:\n\nTidy the docs."), task)
@@ -278,7 +278,7 @@ UNREAD = [Failure("no git")] * 20
MODELS = {"BUILD_RELEASE_JUDGE_MODEL": "claude-opus-5-5", "BUILD_RELEASE_WORKER_MODEL": "claude-opus-5-5", "TMUX_PANE": "%1"}
class TheHumansRun(DoEpicTest):
class TheHumansRun(BuildEpicTest):
def test_shows_the_session_on_a_terminal_and_says_when_tmux_cannot(self) -> None:
fake = FakeEffects(windows="ABC-21\t0\t@9\n")
code, out, err = self.run_main(["ABC-12"], fake)
@@ -315,7 +315,7 @@ class TheHumansRun(DoEpicTest):
code, _, err = self.run_main(["ABC-12"], FakeEffects())
self.assertEqual(code, 1)
self.assertIn("`**Max parallel chunks:** many`, which is not a whole number of 1 or more", err)
(self.home / ".config/build-release/do-epic/config.toml").unlink()
(self.home / ".config/build-release/build-epic/config.toml").unlink()
code, out, err = self.run_main(["ABC-12"], FakeEffects())
self.assertEqual((code, out), (1, ""))
self.assertIn("config.toml", err)
@@ -327,7 +327,7 @@ class TheHumansRun(DoEpicTest):
fake.tmux = lambda args: (_ for _ in ()).throw(ValueError("boom")) # type: ignore[method-assign]
with self.assertRaises(ValueError):
self.run_main(["ABC-12"], fake)
self.assertEqual(fake.dms, ["do-epic ABC-12 crashed: ValueError('boom')"])
self.assertEqual(fake.dms, ["build-epic ABC-12 crashed: ValueError('boom')"])
def test_starts_each_chunk_in_its_repos_checkout(self) -> None:
for name in ("api", "web"):
@@ -365,7 +365,7 @@ class TheHumansRun(DoEpicTest):
self.assertEqual([args[-2:] for args in fake.tmux_calls if "@chunk-root" in args], [["@chunk-root", str(real)]])
class AChunksRun(DoEpicTest):
class AChunksRun(BuildEpicTest):
def test_a_finished_chunk_starts_the_next_without_planning_again(self) -> None:
self.issues.append(issue("ABC-22"))
@@ -373,7 +373,7 @@ class AChunksRun(DoEpicTest):
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
self.assertIn("the chunk finished; started no other\n", out)
# The one claude call is the judge's: ABC-22, which no label places, waits for the human's do-epic.
# The one claude call is the judge's: ABC-22, which no label places, waits for the human's build-epic.
self.assertEqual(len(fake.made("claude")), 1)
def started(self, store: MemoryEpic) -> str:
@@ -386,7 +386,7 @@ class AChunksRun(DoEpicTest):
def test_a_starting_chunk_starts_its_issue_in_the_tracker_before_its_first_cycle(self) -> None:
store = MemoryEpic("ABC-12", list(self.issues))
out = self.started(store)
self.assertEqual((store.writes[0], store.issues[1].assignee), ("start ABC-21", "do-epic"))
self.assertEqual((store.writes[0], store.issues[1].assignee), ("start ABC-21", "build-epic"))
self.assertNotIn("assigned", out.partition("=== cycle 1")[0])
def test_a_starting_chunk_says_who_else_holds_its_issue_and_leaves_it_theirs(self) -> None:
@@ -403,7 +403,7 @@ class AChunksRun(DoEpicTest):
self.assertIn("the chunk finished", out)
def test_runs_cycles_until_the_judge_rules_it_finished_then_starts_the_next_chunk(self) -> None:
self.issues.append(issue("ABC-22", "do-epic-claude"))
self.issues.append(issue("ABC-22", "build-epic-claude"))
self.description = DESCRIPTION.replace("2", "1")
fake = FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD, windows="ABC-21\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
@@ -413,14 +413,14 @@ class AChunksRun(DoEpicTest):
self.assertNotIn("=== cycle 3", out)
self.assertIn("the chunk finished; started ABC-22\n", out)
self.assertEqual(fake.dms, [])
archive = self.home / ".local/state/build-release/do-epic-transcripts/ABC-12"
archive = self.home / ".local/state/build-release/build-epic-transcripts/ABC-12"
self.assertTrue(any(archive.iterdir()))
self.assertFalse((self.home / ".local/state/build-release/transcripts").exists())
streamed = [what for seam, what in fake.calls if seam == "stream_claude"]
self.assertIn("Work the Jira issue ABC-21 of the epic ABC-12 as one chunk", " ".join(streamed[0]))
self.assertNotIn("Work the Jira issue", " ".join(streamed[1]))
def test_every_text_of_a_run_names_do_epic_as_what_drives_it(self) -> None:
def test_every_text_of_a_run_names_build_epic_as_what_drives_it(self) -> None:
fake = FakeEffects(streams=[self.worker()] * 3, claude=[judged("unfinished", escalation="working"), judged("interrupt"), judged("finished")], inputs=["Use B."], git=UNREAD)
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
@@ -430,26 +430,26 @@ class AChunksRun(DoEpicTest):
for text in (*prompts, *judged_with, *fake.dms, *[str(what) for seam, what in fake.calls if seam == "input"]):
self.assertNotIn("build-release", text.replace(str(self.home / ".local/state/build-release"), "<state>"), "but for the state folder's name")
self.assertNotIn("None", text)
self.assertIn(" do-epic runs you on claude-", prompts[1])
self.assertIn("The human answered your question at do-epic's terminal:\nUse B.", prompts[2])
self.assertIn(" build-epic runs you on claude-", prompts[1])
self.assertIn("The human answered your question at build-epic's terminal:\nUse B.", prompts[2])
for text in judged_with:
self.assertIn("what do-epic told it on [loop] lines, latest last:\n", text)
self.assertIn("asking do-epic for a higher rung", text)
self.assertIn("do-epic in ", fake.dms[0])
self.assertIn("what build-epic told it on [loop] lines, latest last:\n", text)
self.assertIn("asking build-epic for a higher rung", text)
self.assertIn("build-epic in ", fake.dms[0])
self.assertNotIn("\n\n[step] ", judged_with[0])
self.assertIn("\n\n[step] do-epic stepped the worker up a rung here", judged_with[1])
self.assertIn("\n\n[step] build-epic stepped the worker up a rung here", judged_with[1])
def test_stops_for_the_human_after_six_unfinished_cycles_naming_do_epic(self) -> None:
def test_stops_for_the_human_after_six_unfinished_cycles_naming_build_epic(self) -> None:
fake = FakeEffects(streams=[self.worker()] * 6, claude=[judged("unfinished")] * 6, git=UNREAD)
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 2, out)
self.assertIn("the judge ruled it unfinished 6 cycles running; finish the chunk yourself, or rerun do-epic to give it 6 more cycles", err + out)
self.assertIn("the judge ruled it unfinished 6 cycles running; finish the chunk yourself, or rerun build-epic to give it 6 more cycles", err + out)
def test_every_archived_transcript_opens_with_the_chunks_task_through_step_ups_and_the_stop_for_the_human(self) -> None:
fake = FakeEffects(streams=[self.worker()] * 6, claude=[judged("unfinished", escalation="working")] + [judged("unfinished")] * 5, git=UNREAD)
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 2, out)
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/build-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
@@ -468,12 +468,12 @@ class AChunksRun(DoEpicTest):
fake.replace_file = grown_after_each_copy
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 2, out)
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/build-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
def test_a_finished_chunk_moves_its_issue_to_done_before_the_chunk_it_blocks_starts(self) -> None:
store = MemoryEpic("ABC-12", [self.issues[0], self.issues[1], issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))])
store = MemoryEpic("ABC-12", [self.issues[0], self.issues[1], issue("ABC-22", "build-epic-claude", blockers=("ABC-21",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-21\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
@@ -482,7 +482,7 @@ class AChunksRun(DoEpicTest):
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_a_finished_chunk_counts_as_done_though_the_search_still_shows_its_issue_open(self) -> None:
issues = [self.issues[0], self.issues[1], issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))]
issues = [self.issues[0], self.issues[1], issue("ABC-22", "build-epic-claude", blockers=("ABC-21",))]
store = MemoryEpic("ABC-12", issues)
store.read = lambda: list(issues) # type: ignore[method-assign]
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
@@ -492,21 +492,21 @@ class AChunksRun(DoEpicTest):
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_where_the_teams_automation_moves_issues_a_finished_chunk_without_a_repo_still_moves_its_own(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
parent = issue("ABC-23", "split-by-repo")
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-21", "do-epic-claude", parent="ABC-23"), issue("ABC-22", "do-epic-claude", blockers=("ABC-23",))])
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-21", "build-epic-claude", parent="ABC-23"), issue("ABC-22", "build-epic-claude", blockers=("ABC-23",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-21\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
# No pull request carries ABC-21, so do-epic moves it; its split item, then all done, closes as ever.
# No pull request carries ABC-21, so build-epic moves it; its split item, then all done, closes as ever.
self.assertEqual({each.key: each.done for each in store.issues}, {"ABC-20": False, "ABC-23": True, "ABC-21": True, "ABC-22": False})
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_the_last_sub_task_of_a_split_item_to_finish_moves_the_item_to_done_and_starts_what_it_blocks(self) -> None:
parent = issue("ABC-21", "split-by-repo")
tasks = [issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-24", "do-epic-claude", parent="ABC-21", done=True)]
store = MemoryEpic("ABC-12", [self.issues[0], parent, *tasks, issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))])
tasks = [issue("ABC-23", "build-epic-claude", parent="ABC-21"), issue("ABC-24", "build-epic-claude", parent="ABC-21", done=True)]
store = MemoryEpic("ABC-12", [self.issues[0], parent, *tasks, issue("ABC-22", "build-epic-claude", blockers=("ABC-21",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-23\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-23", "ABC-12"], fake, MODELS)
@@ -515,9 +515,9 @@ class AChunksRun(DoEpicTest):
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_the_last_sub_task_a_person_filed_to_finish_moves_its_parent_to_done_and_starts_what_it_blocks(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
tasks = [issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-24", "do-epic-claude", parent="ABC-21", done=True)]
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), *tasks, issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))])
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
tasks = [issue("ABC-23", "build-epic-claude", parent="ABC-21"), issue("ABC-24", "build-epic-claude", parent="ABC-21", done=True)]
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), *tasks, issue("ABC-22", "build-epic-claude", blockers=("ABC-21",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-23\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-23", "ABC-12"], fake, MODELS)
@@ -526,8 +526,8 @@ class AChunksRun(DoEpicTest):
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_a_parent_jira_will_not_move_is_said_and_the_next_chunk_still_starts(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-22", "do-epic-claude")])
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), issue("ABC-23", "build-epic-claude", parent="ABC-21"), issue("ABC-22", "build-epic-claude")])
finish = store.finish_issue
store.finish_issue = lambda key: Failure("no way to done") if key == "ABC-21" else finish(key) # type: ignore[method-assign]
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
@@ -539,7 +539,7 @@ class AChunksRun(DoEpicTest):
def test_a_sub_task_that_leaves_another_open_leaves_its_split_item_open(self) -> None:
parent = issue("ABC-21", "split-by-repo")
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-24", "do-epic-claude", parent="ABC-21")])
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-23", "build-epic-claude", parent="ABC-21"), issue("ABC-24", "build-epic-claude", parent="ABC-21")])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-23\t0\t@9\n")
code, _, err = self.run_main(["--chunk", "ABC-23", "ABC-12"], fake, MODELS)
@@ -548,14 +548,14 @@ class AChunksRun(DoEpicTest):
def test_a_split_item_that_jira_will_not_move_to_done_stops_with_the_reason(self) -> None:
parent = issue("ABC-21", "split-by-repo")
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-23", "do-epic-claude", parent="ABC-21")])
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-23", "build-epic-claude", parent="ABC-21")])
finish = store.finish_issue
store.finish_issue = lambda key: Failure("no way to done") if key == "ABC-21" else finish(key) # type: ignore[method-assign]
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-23\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-23", "ABC-12"], fake, MODELS)
self.assertEqual(code, 1)
self.assertIn("the chunk finished, but its split item ABC-21 could not move to done: no way to done; once it is done in Jira, run `do-epic ABC-12` to start the chunks it blocks\n", err)
self.assertIn("the chunk finished, but its split item ABC-21 could not move to done: no way to done; once it is done in Jira, run `build-epic ABC-12` to start the chunks it blocks\n", err)
self.assertNotIn("started", out)
def test_a_chunk_whose_issue_jira_will_not_move_to_done_stops_with_the_reason_and_starts_no_other(self) -> None:
@@ -565,7 +565,7 @@ class AChunksRun(DoEpicTest):
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD)
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 1)
self.assertIn("the chunk finished, but its issue could not move to done: ABC-21's status has no transition to a done status; once it is done in Jira, run `do-epic ABC-12` to start the chunks it blocks\n", err)
self.assertIn("the chunk finished, but its issue could not move to done: ABC-21's status has no transition to a done status; once it is done in Jira, run `build-epic ABC-12` to start the chunks it blocks\n", err)
self.assertNotIn("started", out)
def test_a_finished_chunk_says_why_the_next_could_not_start(self) -> None:
@@ -622,12 +622,12 @@ class AChunksRun(DoEpicTest):
self.assertEqual(code, 0, err)
self.assertIn("=== cycle 1, worker on claude-fable-5-2 at low effort ===\n", out)
def test_a_chunk_in_a_repo_without_a_saved_model_stops_off_a_terminal_naming_do_epic_as_what_to_rerun(self) -> None:
def test_a_chunk_in_a_repo_without_a_saved_model_stops_off_a_terminal_naming_build_epic_as_what_to_rerun(self) -> None:
self.repo_chunk()
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], FakeEffects(git=UNREAD, on_terminal=False), {"TMUX_PANE": "%1"})
self.assertEqual((code, out), (2, ""))
self.assertIn("pick api's model", err)
self.assertIn("rerun do-epic on a terminal", err)
self.assertIn("rerun build-epic on a terminal", err)
def test_a_chunk_in_a_repo_stops_where_the_repos_ladder_or_records_cannot_be_read(self) -> None:
folder = self.repo_chunk()
@@ -658,7 +658,7 @@ class AChunksRun(DoEpicTest):
class Relabelling(Worker):
def __call__(inner, *args: object, **kwargs: object) -> object:
store.issues[:] = [issue("ABC-20", "do-epic-claude")]
store.issues[:] = [issue("ABC-20", "build-epic-claude")]
return super().__call__(*args, **kwargs)
worker = Relabelling(paths_from(self.home, {}).claude_code_transcripts.parent)
@@ -691,15 +691,15 @@ class AChunksRun(DoEpicTest):
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], FakeEffects(git=UNREAD), MODELS)
self.assertEqual(code, 1)
self.assertIn("api", err)
self.issues = [issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-21", "build-epic-claude")]
self.description = "## Goals\nShip.\n"
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], FakeEffects(git=UNREAD), MODELS)
self.assertEqual(code, 1)
self.assertIn("the epic ABC-12's description has no text under a `## Audience` heading - no premises.\n", err)
class WhatAWorkerJudgeAndHumanRead(DoEpicTest):
def test_every_prompt_names_do_epic_and_never_build_release(self) -> None:
class WhatAWorkerJudgeAndHumanRead(BuildEpicTest):
def test_every_prompt_names_build_epic_and_never_build_release(self) -> None:
cycle = ACycleOfAChunkWithoutARepo.cycle(self) # type: ignore[arg-type]
prompts = cycle.prompts
texts = [
@@ -711,13 +711,13 @@ class WhatAWorkerJudgeAndHumanRead(DoEpicTest):
]
for text in texts:
self.assertNotIn("build-release", text.replace(str(self.home / ".local/state/build-release"), "<state>"), "but for the state folder's name")
self.assertIn(f"do-epic runs you on {cycle.route.rung}, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue.", texts[0])
self.assertIn(f"build-epic runs you on {cycle.route.rung}, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue.", texts[0])
self.assertRegex(texts[0], r"it means the issue\.( \S|\n\n)")
self.assertNotIn("Chunk items:", texts[1])
# The worker's prompt and the judge's rules word the request for a higher rung alike, from one place.
for text in (texts[0], texts[3]):
self.assertIn("asking do-epic for a higher rung", text)
self.assertEqual(escalation_mark.asks_higher_rung(chunk_prompt.DRIVER), "asking do-epic for a higher rung")
self.assertIn("asking build-epic for a higher rung", text)
self.assertEqual(escalation_mark.asks_higher_rung(chunk_prompt.DRIVER), "asking build-epic for a higher rung")
WORKTREE = "worktree /code/api\nbranch refs/heads/main\n\nworktree /code/api-ABC-20\nbranch refs/heads/ABC-20\n"
@@ -733,13 +733,13 @@ def awaiting(**answers: object) -> Forge:
CLEANED = Forge(worktrees="worktree /code/api\nHEAD aaa\nbranch refs/heads/main\n")
class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
class AChunkWhosePullRequestWaitsOnAGate(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
self.repo_config = self.repo_chunk() / "config.toml"
self.issues.append(issue("ABC-22", "do-epic-claude"))
self.file = parked.file_of(self.home / ".local/state/build-release/do-epic/ABC-12", "ABC-20")
self.session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
self.issues.append(issue("ABC-22", "build-epic-claude"))
self.file = parked.file_of(self.home / ".local/state/build-release/build-epic/ABC-12", "ABC-20")
self.session = main.session_named("A ABC-12 build-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
def parked_run(self, fake: FakeEffects) -> tuple[int, str, str, list[str]]:
"""The chunk's run, as its exit code, what it printed, and each prompt its workers got."""
@@ -761,7 +761,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertEqual(len(prompts), 2)
self.assertTrue(prompts[0].startswith("Work the Jira issue ABC-20 "), prompts[0])
self.assertEqual(set(self.forges[0].ran[:1] + self.forges[1].ran[:1]), {checkout})
self.assertTrue(prompts[1].startswith(f"do-epic parked the chunk while its pull request awaited an approval. It resumes now: pull request #7 passed its checks and is approved. {chunk_prompt.FEEDBACK}\n\nWork the Jira issue ABC-20 "), prompts[1])
self.assertTrue(prompts[1].startswith(f"build-epic parked the chunk while its pull request awaited an approval. It resumes now: pull request #7 passed its checks and is approved. {chunk_prompt.FEEDBACK}\n\nWork the Jira issue ABC-20 "), prompts[1])
self.assertIn("the chunk finished; ", out)
shown = [args for args in fake.tmux_calls if args[0] == "rename-window" or tmux.ROOT in args and "%1" in args]
self.assertEqual(shown, [["rename-window", "-t", "%1", "ABC-20 awaits an approval"], ["rename-window", "-t", "%1", "ABC-20"], ["set-option", "-w", "-t", "%1", tmux.ROOT, checkout]])
@@ -855,8 +855,8 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertEqual((code, len(prompts)), (0, 1), err)
def test_where_the_teams_automation_moves_issues_a_finished_chunk_in_a_repo_moves_none_and_waits_for_the_move(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "build-epic-claude", blockers=("ABC-20",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
self.forges = [awaiting(pulls="")]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
@@ -901,7 +901,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertNotIn("parked: ", out)
self.assertEqual([args[3] for args in fake.tmux_calls if args[0] == "rename-window"], ["ABC-20 awaits an approval", "ABC-20"])
self.assertEqual(len(prompts), 1)
self.assertTrue(prompts[0].startswith("do-epic parked the chunk while its pull request awaited an approval. It resumes now: a reviewer requested changes on pull request #7. "), prompts[0])
self.assertTrue(prompts[0].startswith("build-epic parked the chunk while its pull request awaited an approval. It resumes now: a reviewer requested changes on pull request #7. "), prompts[0])
self.assertFalse(self.file.exists())
def test_a_chunk_with_work_again_stays_parked_until_a_slot_is_free(self) -> None:
@@ -922,7 +922,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertEqual([args[3] for args in fake.tmux_calls if args[0] == "rename-window"], ["ABC-20 awaits an approval", "ABC-20 awaits a slot", "ABC-20"])
self.assertEqual(len(prompts), 2)
def test_a_parked_chunk_whose_pull_request_merged_is_cleaned_and_finished_by_do_epic_though_no_slot_is_free(self) -> None:
def test_a_parked_chunk_whose_pull_request_merged_is_cleaned_and_finished_by_build_epic_though_no_slot_is_free(self) -> None:
self.description = DESCRIPTION.replace("2", "1")
self.forges = [awaiting(), awaiting(pulls="", merged=True)]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW + "ABC-22\t0\t@10\n")
@@ -953,8 +953,8 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertFalse(self.file.exists())
def test_where_the_teams_automation_moves_issues_a_merged_parked_chunk_waits_for_the_move_as_a_finished_one_does(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "build-epic-claude", blockers=("ABC-20",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
self.forges = [awaiting(), awaiting(pulls="", merged=True)]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
@@ -979,7 +979,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertEqual(self.forges[1].commands.count([CHUNK_PR, "clean"]), 1)
self.assertIn("no pull request from origin's ABC-20 is open", prompts[1].split("\n\n")[0])
def test_where_a_person_merged_before_the_cycle_closed_a_finished_chunk_is_cleaned_by_do_epic(self) -> None:
def test_where_a_person_merged_before_the_cycle_closed_a_finished_chunk_is_cleaned_by_build_epic(self) -> None:
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8") + 'merge = "human"\n', encoding="utf-8")
self.forges = [awaiting(pulls="", merged=True)]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
@@ -1103,7 +1103,7 @@ class LaggingStore:
return self.answer
class AnEpicsWorkingBranch(DoEpicTest):
class AnEpicsWorkingBranch(BuildEpicTest):
"""A chunk in a repo whose config sets `epic-branch`, so its pull request goes into the branch ABC-12."""
def setUp(self) -> None:
@@ -1111,13 +1111,13 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.repo_config = self.repo_chunk() / "config.toml"
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8") + 'epic-branch = "{epic}"\nmerge = "human"\n', encoding="utf-8")
self.checkout = str(self.home / "code/api")
self.store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
self.store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-22", "build-epic-claude", blockers=("ABC-20",))])
self.backend = lambda config, key: (self.store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
self.git_calls: list[tuple[tuple[str, ...], str | None]] = []
self.git_timeouts: list[tuple[str, object]] = []
def settings(self, more: str) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
def with_git(self, fake: FakeEffects, **answers: str | Failure) -> FakeEffects:
"""fake, whose git answers each command by its first word: as answers has it, else as a checkout whose origin has the branch ABC-12, which holds origin/main."""
@@ -1168,7 +1168,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
def test_a_default_branch_that_conflicts_stops_the_loop_for_a_person_and_records_no_base(self) -> None:
stop = main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("git merge-tree --write-tree origin/ABC-12 origin/main: "))))
self.assertEqual(stop, main.Stop(1, f"cannot ready the epic's working branch ABC-12 in {self.checkout} for ABC-20: origin/main doesn't merge into origin/ABC-12 cleanly, so a person merges it: check ABC-12 out, run `git merge origin/main`, resolve the conflicts and push; once that is settled, run `do-epic ABC-12` to start the chunk again"))
self.assertEqual(stop, main.Stop(1, f"cannot ready the epic's working branch ABC-12 in {self.checkout} for ABC-20: origin/main doesn't merge into origin/ABC-12 cleanly, so a person merges it: check ABC-12 out, run `git merge origin/main`, resolve the conflicts and push; once that is settled, run `build-epic ABC-12` to start the chunk again"))
self.assertNotIn("config", [args[0] for args, _ in self.git_calls])
def test_a_checkout_that_names_no_default_branch_stops_before_the_branch_is_touched(self) -> None:
@@ -1199,7 +1199,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertIn("The chunk's pull request goes into the epic's working branch `ABC-12`", prompts[0])
self.assertIn(("config", "branch.ABC-20.chunk-base", "ABC-12"), [args for args, _ in self.git_calls])
def test_a_parked_chunk_whose_pull_request_merged_into_the_branch_gets_its_issue_moved_by_do_epic_as_no_automation_does_it(self) -> None:
def test_a_parked_chunk_whose_pull_request_merged_into_the_branch_gets_its_issue_moved_by_build_epic_as_no_automation_does_it(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
self.forges = [self.recorded(base="ABC-12"), self.recorded(base="ABC-12", pulls="", merged=True)]
fake = self.with_git(FakeEffects(streams=[self.worker()], claude=[judged("finished")], windows=PARKED_WINDOW))
@@ -1210,8 +1210,8 @@ class AnEpicsWorkingBranch(DoEpicTest):
def test_a_chunk_parked_on_a_persons_merge_into_the_default_branch_stays_parked_until_its_pull_request_goes_into_the_branch(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
parked.park(self.home / ".local/state/build-release/do-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
session = main.session_named("A ABC-12 build-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
parked.park(self.home / ".local/state/build-release/build-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
self.worker()(["--session-id", str(session.id)])
# The pull request was opened into main before the setting was on; a person then changes its base to ABC-12.
self.forges = [self.recorded(decision="APPROVED"), self.recorded(decision="APPROVED"), self.recorded(base="ABC-12", decision="APPROVED")]
@@ -1221,7 +1221,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertEqual(code, 0, err)
self.assertEqual(out.count("cannot read the gate: pull request #7 merges into main on the forge, but this checkout takes ABC-12 as the base of its branch; a person settles which holds, and changes the pull request's base on the forge or the branch's `chunk-base` in git's config; trying again every 60 seconds\n"), 1)
self.assertEqual(len(prompts), 1)
self.assertTrue(prompts[0].startswith("do-epic parked the chunk while its pull request awaited a person's merge. It resumes now: pull request #7 passed its checks and is approved. "), prompts[0])
self.assertTrue(prompts[0].startswith("build-epic parked the chunk while its pull request awaited a person's merge. It resumes now: pull request #7 passed its checks and is approved. "), prompts[0])
def test_a_chunk_that_started_before_the_setting_was_on_keeps_its_merge_for_a_person(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
@@ -1283,7 +1283,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
def test_without_a_merged_status_a_finished_chunk_stops_where_automation_moves_issues_and_is_done_where_it_doesnt(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n')
stop = main.handed_on("ABC-20", self.epic_run(FakeEffects()), main.Landed.ON_EPIC_BRANCH)
self.assertEqual(stop, main.Stop(1, "the chunk finished, but its issue stays as it is: its pull request merged into the epic's working branch, where the team's automation moves no issue, and do-epic's config names no `jira-pull-request-merged-status` to move it to. Move ABC-20 in Jira, then run `do-epic ABC-12` to start the chunks it blocks"))
self.assertEqual(stop, main.Stop(1, "the chunk finished, but its issue stays as it is: its pull request merged into the epic's working branch, where the team's automation moves no issue, and build-epic's config names no `jira-pull-request-merged-status` to move it to. Move ABC-20 in Jira, then run `build-epic ABC-12` to start the chunks it blocks"))
self.assertEqual(self.store.writes, [])
self.settings("")
out = io.StringIO()
@@ -1310,7 +1310,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
stop = main.handed_on("ABC-20", self.epic_run(FakeEffects()), main.Landed.ON_EPIC_BRANCH)
self.assertEqual(stop.code, 1)
self.assertTrue(stop.reason.startswith("the chunk finished, but its issue could not move to 'Release Ready': "), stop.reason)
self.assertTrue(stop.reason.endswith("once it has that status in Jira, run `do-epic ABC-12` to start the chunks it blocks"), stop.reason)
self.assertTrue(stop.reason.endswith("once it has that status in Jira, run `build-epic ABC-12` to start the chunks it blocks"), stop.reason)
class TheMoveOfAFinishedChunksIssue(unittest.TestCase):
@@ -1347,7 +1347,7 @@ class TheMoveOfAFinishedChunksIssue(unittest.TestCase):
self.assertEqual(self.move(main.Landed.ON_EPIC_BRANCH, False, None, "In Review"), main.How.TO_DONE)
class TheStatus(DoEpicTest):
class TheStatus(BuildEpicTest):
def test_prints_what_each_open_issue_does_and_starts_nothing(self) -> None:
self.issues = [issue("ABC-21", "repo:api"), issue("ABC-24", "repo:api"), issue("ABC-27")]
fake = FakeEffects(windows="ABC-21 ?\t0\t@2\n")
@@ -1355,15 +1355,15 @@ class TheStatus(DoEpicTest):
self.assertEqual((code, err), (0, ""))
self.assertEqual(out.replace("<1790000000> ", "").splitlines(), [
"ABC-21 asks you: answer its question in the tmux window epic-ABC-12:ABC-21",
"ABC-24 waits: it has not started; `do-epic ABC-12` starts it once the epic and its repo have room",
"ABC-24 waits: it has not started; `build-epic ABC-12` starts it once the epic and its repo have room",
"ABC-27 waits: no label names its repo",
])
self.assertEqual({args[0] for args in fake.tmux_calls}, {"-V", "list-windows"})
self.assertTrue(all("epic-ABC-12" in " ".join(args) for args in fake.tmux_calls if args[0] == "list-windows"), fake.tmux_calls)
def test_says_which_issue_starts_after_those_that_start_by_score(self) -> None:
self.issues = [issue("ABC-21", "do-epic-claude"), dataclasses.replace(issue("ABC-24", "do-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1})]
room = "it has not started; `do-epic ABC-12` starts it once the epic and its repo have room"
self.issues = [issue("ABC-21", "build-epic-claude"), dataclasses.replace(issue("ABC-24", "build-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1})]
room = "it has not started; `build-epic ABC-12` starts it once the epic and its repo have room"
out = self.run_main(["ABC-12", "--status"], FakeEffects())[1]
self.assertEqual(out.replace("<1790000000> ", "").splitlines(), [f"ABC-21 waits: {room}, after each issue that holds every score, since it doesn't", f"ABC-24 waits: {room}"])
@@ -1394,7 +1394,7 @@ class TheStatus(DoEpicTest):
BANNER = "dry run: nothing is written to Jira and no window starts, so a line below that says an issue is labelled, split or scored shows what a real run would do. A real run would also start in Jira the issue of each chunk it starts: assign it and, where config.toml says so, move it and add it to a sprint"
class TheDryRun(DoEpicTest):
class TheDryRun(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
for repo in ("api", "web"):
@@ -1405,7 +1405,7 @@ class TheDryRun(DoEpicTest):
self.backend = lambda config, key: (self.stores.append(made(config, key)[0]) or self.stores[-1], EpicRecord(Description(self.description))) # type: ignore[method-assign,assignment]
def test_prints_each_write_and_each_chunk_it_would_start_and_makes_none_of_them(self) -> None:
self.issues = [issue("ABC-20"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20"), issue("ABC-21", "build-epic-claude")]
parts = structured({"parts": [{"repo": "api", "change": "Add the endpoint."}, {"repo": "web", "change": "Call it."}], "comment": "Split by repo: api and web."})
fake = FakeEffects(on_terminal=True, claude=[parts])
code, out, err = self.run_main(["ABC-12", "--dry-run"], fake)
@@ -1419,8 +1419,8 @@ class TheDryRun(DoEpicTest):
self.assertEqual([args for args in fake.tmux_calls if args[0] in changing], [])
def test_prints_each_move_of_a_parent_whose_sub_tasks_a_person_filed(self) -> None:
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-sub-tasks-landed-transition = "Release Ready"\njira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
self.issues = [issue("ABC-20", status="In Progress"), issue("ABC-30", "do-epic-claude", parent="ABC-20", status="Release Ready"), issue("ABC-21"), issue("ABC-31", "do-epic-claude", parent="ABC-21", done=True), issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))]
(self.home / ".config/build-release" / "build-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-sub-tasks-landed-transition = "Release Ready"\njira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
self.issues = [issue("ABC-20", status="In Progress"), issue("ABC-30", "build-epic-claude", parent="ABC-20", status="Release Ready"), issue("ABC-21"), issue("ABC-31", "build-epic-claude", parent="ABC-21", done=True), issue("ABC-22", "build-epic-claude", blockers=("ABC-20",))]
code, out, err = self.run_main(["ABC-12", "--dry-run"], FakeEffects())
self.assertEqual((code, err), (0, ""))
self.assertIn("planning would write to Jira:\n- move ABC-20 by Release Ready\n- finish ABC-21\nwould start ABC-22\n", out.replace("<1790000000> ", ""))
@@ -1430,10 +1430,10 @@ class TheDryRun(DoEpicTest):
self.issues = [issue("ABC-20")]
code, out, _ = self.run_main(["ABC-12", "--dry-run"], FakeEffects(claude=[structured({"parts": []}), structured({"pick": "claude"})]))
self.assertEqual(code, 0)
self.assertIn("planning would write to Jira:\n- label ABC-20 with do-epic-claude\nwould start ABC-20\n", out.replace("<1790000000> ", ""))
self.assertIn("planning would write to Jira:\n- label ABC-20 with build-epic-claude\nwould start ABC-20\n", out.replace("<1790000000> ", ""))
def test_counts_the_chunks_it_would_start_against_the_epics_cap_and_a_repos_limit(self) -> None:
self.issues = [issue("ABC-21", "do-epic-claude"), issue("ABC-22", "do-epic-claude"), issue("ABC-23", "do-epic-claude")]
self.issues = [issue("ABC-21", "build-epic-claude"), issue("ABC-22", "build-epic-claude"), issue("ABC-23", "build-epic-claude")]
self.description = DESCRIPTION.replace("2", "1")
code, out, _ = self.run_main(["ABC-12", "--dry-run"], FakeEffects(on_terminal=True))
self.assertEqual(code, 0)
@@ -1452,7 +1452,7 @@ class TheDryRun(DoEpicTest):
self.assertIn("planning wouldn't write anything to Jira\n", out)
def test_works_without_tmux_and_a_chunk_in_a_missing_repo_waits(self) -> None:
self.issues = [issue("ABC-20", "repo:missing"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20", "repo:missing"), issue("ABC-21", "build-epic-claude")]
fake = FakeEffects(on_terminal=False, tmux_version="")
code, out, _ = self.run_main(["ABC-12", "--dry-run"], fake)
self.assertEqual(code, 0)
@@ -1464,7 +1464,7 @@ class TheDryRun(DoEpicTest):
(self.home / planning.RULE).parent.mkdir(parents=True, exist_ok=True)
(self.home / planning.RULE).write_text("L is how much the item changes.\n", encoding="utf-8")
self.description = DESCRIPTION.replace("Ship the import.", "1. **Achieve:** Ship the import.") + "\n## Scoring\n`Score = V`\n"
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
answer = {"L": 2, "E": 1, "I": 2, "S": 3, "comment": "Scored to decide what starts first."}
fake = FakeEffects(on_terminal=False, claude=[structured(answer | {"moves": "epic 1 by 2"}), structured(answer | {"moves": "epic 1 by 9"})])
code, out, err = self.run_main(["ABC-12", "--dry-run"], fake)
@@ -1476,7 +1476,7 @@ class TheDryRun(DoEpicTest):
self.assertEqual(self.stores[0].writes, [])
def test_says_why_the_issues_start_in_backlog_order_and_names_no_order_of_one_issue(self) -> None:
self.issues = [dataclasses.replace(issue(key, "do-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1}) for key in ("ABC-20", "ABC-21")]
self.issues = [dataclasses.replace(issue(key, "build-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1}) for key in ("ABC-20", "ABC-21")]
out = io.StringIO()
with contextlib.redirect_stdout(out):
epic_run.chunks_started(self.epic_run(FakeEffects(on_terminal=False)), self.issues, None)
@@ -5,11 +5,11 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.backend.protocol import EpicIssue
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from do_epic.test_scheduler import issue
from do_epic.backend.fake import MemoryEpic
from do_epic.parent_moves import moved
from build_epic.test_scheduler import issue
from build_epic.backend.fake import MemoryEpic
from build_epic.parent_moves import moved
UNBLOCKING = ("Release Ready", "Teach & Learn")
@@ -59,12 +59,12 @@ class MovingAParentWhoseSubTasksAPersonFiled(unittest.TestCase):
self.assertEqual(self.moves(done, landed_by=None)[0], ["finish ABC-20"])
self.assertEqual(self.moves(done, finishes=False), ([], {"ABC-20": ("In Progress", False), "ABC-30": ("Done", True)}, []))
def test_an_item_do_epic_split_or_half_split_is_left_to_its_own_closing(self) -> None:
def test_an_item_build_epic_split_or_half_split_is_left_to_its_own_closing(self) -> None:
done = dataclasses.replace(issue("ABC-30", done=True), by_loop=True)
self.assertEqual(self.moves(family(done, parent=issue("ABC-20", "split-by-repo")))[0], [])
self.assertEqual(self.moves(family(done))[0], [])
def test_a_parent_with_a_sub_task_a_person_filed_beside_one_do_epic_filed_moves(self) -> None:
def test_a_parent_with_a_sub_task_a_person_filed_beside_one_build_epic_filed_moves(self) -> None:
ours = dataclasses.replace(issue("ABC-31", done=True), by_loop=True)
self.assertEqual(self.moves(family(issue("ABC-30", status="Release Ready"), ours))[0], ["move ABC-20 by Release Ready"])
self.assertEqual(self.moves(family(issue("ABC-30", done=True), ours))[0], ["finish ABC-20"])
@@ -6,7 +6,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from failure import Failure
from do_epic.parked import file_of, park, Parked, parked_chunks, unpark
from build_epic.parked import file_of, park, Parked, parked_chunks, unpark
CHUNK = Parked("ABC-21", "/code/billing-ABC-21", "7", "0c0f", "an approval")
@@ -9,12 +9,12 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.parking import CHUNK_PR
from do_epic import chunk_prompt, parked
from build_epic.parking import CHUNK_PR
from build_epic import chunk_prompt, parked
from failure import Failure
from loop_effects.doubles import FakeEffects
from do_epic.parking import Merged, merged_and_cleaned, news_after, Poll
from do_epic.gates import Open, Unmergeable, Unopened
from build_epic.parking import Merged, merged_and_cleaned, news_after, Poll
from build_epic.gates import Open, Unmergeable, Unopened
from agent_cycle.stop import Stop
UNOPENED = Unopened("no pull request is open", "/code/api-ABC-20")
@@ -72,7 +72,7 @@ class TheCleanupOfAChunkWhosePullRequestIsNoLongerOpen(unittest.TestCase):
with contextlib.redirect_stdout(out):
return merged_and_cleaned(self.poll, UNOPENED), out.getvalue()
def test_chunk_pr_is_run_by_a_path_that_exists_since_do_epics_path_does_not_hold_it(self) -> None:
def test_chunk_pr_is_run_by_a_path_that_exists_since_build_epics_path_does_not_hold_it(self) -> None:
path = pathlib.Path(CHUNK_PR)
self.assertTrue(path.is_absolute() and path.is_file() and os.access(path, os.X_OK), CHUNK_PR)
@@ -9,18 +9,18 @@ import sys
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from build_epic.test_main import BuildEpicTest, Description, structured as says
from project_config.doubles import configured
from do_epic.test_main import Description, DoEpicTest, structured as says
from do_epic.backend.protocol import EpicIssue
from do_epic.epic_record import EpicRecord
from build_epic.backend.protocol import EpicIssue
from build_epic.epic_record import EpicRecord
from failure import Failure
from loop_effects.doubles import FakeEffects
from do_epic.test_scheduler import issue
from build_epic.test_scheduler import issue
from claude_code.reply import Limited
from do_epic.config import load
from do_epic.backend.fake import MemoryEpic
from build_epic.config import load
from build_epic.backend.fake import MemoryEpic
from plan.todo_table import parse_moves
from do_epic import planning
from build_epic import planning
RANKED = "## Goals\n1. **Achieve:** Ship the import.\n\n## Audience\nThe client's team.\n\n## Scoring\n`Score = V`\n"
GOALS = "## Goals\n\n**Void:** code health, since it is a one-off script.\n\n1. **Achieve:** Serve the API.\n\n## Audience\nIts callers.\n"
@@ -35,10 +35,10 @@ def scored(key: str, moves: str, *labels: str, blockers: tuple[str, ...] = (), b
return dataclasses.replace(issue(key, *labels, blockers=blockers, parent=parent), scores={"L": 1, "E": 1, "I": 1, "S": 1}, moves=parsed, by_loop=by_loop)
class Planning(DoEpicTest):
class Planning(BuildEpicTest):
def setUp(self) -> None:
super().setUp()
self.folder = self.home / ".local/state/build-release/do-epic/ABC-12"
self.folder = self.home / ".local/state/build-release/build-epic/ABC-12"
def plan(self, fake: FakeEffects) -> tuple[list[EpicIssue] | Failure | Limited, MemoryEpic, str]:
"""What planning answers for self.issues, the store it changed and what it printed on stdout. self.asked holds what it asked the human, on stderr."""
@@ -71,13 +71,13 @@ class Planning(DoEpicTest):
def test_an_issue_a_label_places_is_planned_without_claude(self) -> None:
self.description = RANKED
self.repo("api")
self.issues = [scored("ABC-20", "epic 1 by 9", "repo:api"), scored("ABC-21", "epic 1 by 2", "do-epic-claude"), issue("ABC-22", "split-by-repo"), issue("ABC-23", done=True)]
self.issues = [scored("ABC-20", "epic 1 by 9", "repo:api"), scored("ABC-21", "epic 1 by 2", "build-epic-claude"), issue("ABC-22", "split-by-repo"), issue("ABC-23", done=True)]
fake = FakeEffects()
found, _, out = self.plan(fake)
self.assertEqual((found, out, fake.made("claude")), (self.issues, "", []))
def test_an_epic_shaped_as_a_teams_is_planned_without_claude_and_without_a_write(self) -> None:
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
with (self.home / ".config/build-release/build-epic/config.toml").open("a", encoding="utf-8") as config:
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\ncore-4 = "core-4"\n')
self.description = RANKED
self.repo("tenant-web-ui-4")
@@ -107,7 +107,7 @@ class Planning(DoEpicTest):
self.assertIn("A label that equals a repo's name names that repo.", fake.made("claude")[1][1])
def test_labels_work_without_a_repo_as_claudes_or_a_humans(self) -> None:
for pick, label in (("claude", "do-epic-claude"), ("human", "do-epic-human")):
for pick, label in (("claude", "build-epic-claude"), ("human", "build-epic-human")):
with self.subTest(pick=pick):
self.issues = [issue("ABC-20")]
_, store, _ = self.plan(FakeEffects(claude=[says({"parts": []}), says({"pick": pick})]))
@@ -124,7 +124,7 @@ class Planning(DoEpicTest):
self.assertIn("in English, that tells the team why it is split by repo", fake.made("claude")[0][1])
def test_a_failed_runs_sub_task_under_the_teams_label_is_not_filed_again_and_another_label_is_no_pick(self) -> None:
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
with (self.home / ".config/build-release/build-epic/config.toml").open("a", encoding="utf-8") as config:
config.write('\n[label-repos]\nbackend = "api"\n')
configured(self, self.home / "code" / "api", home=self.home)
self.issues = [issue("ABC-20", "urgent"), dataclasses.replace(issue("ABC-23", "backend", parent="ABC-20"), by_loop=True), issue("ABC-21", "urgent")]
@@ -132,13 +132,13 @@ class Planning(DoEpicTest):
_, store, _ = self.plan(FakeEffects(claude=[parts, says({"parts": []}), says({"pick": "human"})]))
read = store.read()
assert not isinstance(read, Failure)
self.assertEqual(([task.labels for task in read if task.parent == "ABC-20"], self.labels(store)["ABC-21"]), ([("backend",), ("repo:web",)], ("do-epic-human", "urgent")))
self.assertEqual(([task.labels for task in read if task.parent == "ABC-20"], self.labels(store)["ABC-21"]), ([("backend",), ("repo:web",)], ("build-epic-human", "urgent")))
def test_plans_the_issue_after_one_that_is_split(self) -> None:
self.issues = [issue("ABC-20"), issue("ABC-21")]
parts = says({"parts": [{"repo": "api", "change": "Add the endpoint."}, {"repo": "web", "change": "Call it."}], "comment": "Split by repo: api and web."})
_, store, _ = self.plan(FakeEffects(claude=[parts, says({"parts": []}), says({"pick": "human"})]))
self.assertEqual(self.labels(store)["ABC-21"], ("do-epic-human",))
self.assertEqual(self.labels(store)["ABC-21"], ("build-epic-human",))
def test_writes_to_the_team_in_the_epics_language(self) -> None:
self.description = "**Language:** Swedish\n"
@@ -184,16 +184,16 @@ class Planning(DoEpicTest):
self.assertEqual(args[args.index("--add-dir") + 1], str(checkout))
def test_asks_for_one_of_the_teams_labels_too_and_takes_it(self) -> None:
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
with (self.home / ".config/build-release/build-epic/config.toml").open("a", encoding="utf-8") as config:
config.write('\n[label-repos]\nbackend = "api"\n')
self.issues = [issue("ABC-20")]
fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "Is the importer in api or in web?"})], inputs=["backend"])
found, _, _ = self.plan(fake)
self.assertEqual((found, fake.made("input")), ([issue("ABC-20", "backend")], ["The label that says where ABC-20 is worked, `repo:<name>`, `do-epic-claude` or `do-epic-human` (or the team's `backend`), or Enter alone to leave it waiting: "]))
self.assertEqual((found, fake.made("input")), ([issue("ABC-20", "backend")], ["The label that says where ABC-20 is worked, `repo:<name>`, `build-epic-claude` or `build-epic-human` (or the team's `backend`), or Enter alone to leave it waiting: "]))
def configure_team(self, *above: str) -> None:
"""Gives the config the team's label `backend` for api, and the settings in above."""
path = self.home / ".config/build-release/do-epic/config.toml"
path = self.home / ".config/build-release/build-epic/config.toml"
path.write_text("".join(f"{line}\n" for line in above) + path.read_text(encoding="utf-8") + '\n[label-repos]\nbackend = "api"\n', encoding="utf-8")
def test_files_sub_tasks_under_the_teams_label_and_summary_template(self) -> None:
@@ -219,7 +219,7 @@ class Planning(DoEpicTest):
self.assertIn("ABC-20, Do ABC-20: Is the importer in api or in web?\n", self.asked.getvalue())
self.assertIn("`api` is none of those labels; the repo api's label is `repo:api`\n", self.asked.getvalue())
self.assertIn("`a b` is none of those labels\n", self.asked.getvalue())
self.assertEqual(fake.made("input"), ["The label that says where ABC-20 is worked, `repo:<name>`, `do-epic-claude` or `do-epic-human`, or Enter alone to leave it waiting: "] * 3)
self.assertEqual(fake.made("input"), ["The label that says where ABC-20 is worked, `repo:<name>`, `build-epic-claude` or `build-epic-human`, or Enter alone to leave it waiting: "] * 3)
def unclear_then_claudes(self, **fake: object) -> tuple[dict[str, tuple[str, ...]], str]:
"""The labels and the output after planning ABC-20, which the rule leaves unclear, and ABC-21, which is Claude's, on a FakeEffects made with fake."""
@@ -230,17 +230,17 @@ class Planning(DoEpicTest):
def test_an_unclear_issue_waits_off_a_terminal_and_the_next_is_planned(self) -> None:
labels, out = self.unclear_then_claudes(on_terminal=False)
self.assertEqual(labels, {"ABC-20": (), "ABC-21": ("do-epic-claude",)})
self.assertEqual(labels, {"ABC-20": (), "ABC-21": ("build-epic-claude",)})
self.assertNotIn("ABC-20 is labelled", out)
self.assertIn("ABC-20 waits for your answer: Is the importer in api or in web? Run `do-epic ABC-12` on a terminal to answer, or label the issue in Jira.\n", out)
self.assertIn("ABC-20 waits for your answer: Is the importer in api or in web? Run `build-epic ABC-12` on a terminal to answer, or label the issue in Jira.\n", out)
def test_an_unclear_issue_waits_where_the_human_answers_with_enter_alone(self) -> None:
labels, out = self.unclear_then_claudes(inputs=[" "])
self.assertEqual((labels, "ABC-20 is labelled" in out), ({"ABC-20": (), "ABC-21": ("do-epic-claude",)}, False))
self.assertEqual((labels, "ABC-20 is labelled" in out), ({"ABC-20": (), "ABC-21": ("build-epic-claude",)}, False))
def test_an_unclear_issue_waits_where_the_terminals_input_ends(self) -> None:
labels, out = self.unclear_then_claudes(inputs=[EOFError()])
self.assertEqual((labels, "ABC-20 is labelled" in out), ({"ABC-20": (), "ABC-21": ("do-epic-claude",)}, False))
self.assertEqual((labels, "ABC-20 is labelled" in out), ({"ABC-20": (), "ABC-21": ("build-epic-claude",)}, False))
def test_clones_a_labelled_repo_without_a_checkout_beside_the_origin_of_the_others(self) -> None:
configured(self, self.home / "code" / "api", home=self.home)
@@ -262,7 +262,7 @@ class Planning(DoEpicTest):
(checkout / "docs").mkdir()
(checkout / "docs" / "comprehension-history.md").write_text("# Comprehension history\n\n## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\n| Seat | Overall |\n|---|---|\n| Mid A | 6 |\n| Mean | 7.5 |\n", encoding="utf-8")
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 9", "do-epic-claude"), scored("ABC-21", "code health by 3", "repo:api")]
self.issues = [scored("ABC-20", "epic 1 by 9", "build-epic-claude"), scored("ABC-21", "code health by 3", "repo:api")]
found = self.plan(FakeEffects())[0]
assert not isinstance(found, Failure | Limited), found
return [each.key for each in found]
@@ -279,7 +279,7 @@ class Planning(DoEpicTest):
self.issues = [issue("ABC-20"), issue("ABC-21")]
fake = FakeEffects(claude=[subprocess.CompletedProcess([], 1, "", ""), says({"parts": []}), says({"pick": "claude"})])
_, store, out = self.plan(fake)
self.assertEqual(self.labels(store), {"ABC-20": (), "ABC-21": ("do-epic-claude",)})
self.assertEqual(self.labels(store), {"ABC-20": (), "ABC-21": ("build-epic-claude",)})
self.assertIn("ABC-20 is not planned: the repo split exited 1\n", out)
def test_a_usage_limit_ends_the_planning(self) -> None:
@@ -291,60 +291,60 @@ class Planning(DoEpicTest):
def test_re_ranks_the_loops_scored_issues_by_score_with_a_blocker_first_and_leaves_every_other_issue_in_place(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9", "do-epic-claude", by_loop=False), scored("ABC-22", "epic 1 by 5", "do-epic-claude", blockers=("ABC-24",)), dataclasses.replace(issue("ABC-23", "do-epic-human"), by_loop=True), scored("ABC-24", "epic 1 by 3", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "epic 1 by 9", "build-epic-claude", by_loop=False), scored("ABC-22", "epic 1 by 5", "build-epic-claude", blockers=("ABC-24",)), dataclasses.replace(issue("ABC-23", "build-epic-human"), by_loop=True), scored("ABC-24", "epic 1 by 3", "build-epic-claude")]
found, store, out = self.plan(FakeEffects())
assert not isinstance(found, Failure | Limited), found
# ABC-22 scores highest, and ABC-24 blocks it. ABC-21 is a person's, and ABC-23 is a human's task, which holds no scores.
self.assertEqual([each.key for each in found], ["ABC-24", "ABC-21", "ABC-22", "ABC-23", "ABC-20"])
self.assertIn("re-ranking the issues do-epic filed in ABC-12's backlog\n", out)
self.assertIn("re-ranking the issues build-epic filed in ABC-12's backlog\n", out)
def test_ranks_an_issue_in_a_repo_by_that_repos_goals_after_the_epics(self) -> None:
self.repo("api")
self.description = RANKED
self.issues = [scored("ABC-20", "repo 1 by 9", "repo:api"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "repo 1 by 9", "repo:api"), scored("ABC-21", "epic 1 by 9", "build-epic-claude")]
found, _, _ = self.plan(FakeEffects())
assert not isinstance(found, Failure | Limited), found
self.assertEqual([each.key for each in found], ["ABC-21", "ABC-20"])
def test_issues_already_in_their_order_are_not_ranked_again(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 9", "do-epic-claude"), scored("ABC-21", "epic 1 by 2", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 9", "build-epic-claude"), scored("ABC-21", "epic 1 by 2", "build-epic-claude")]
found, _, out = self.plan(FakeEffects())
self.assertEqual((found, out), (self.issues, ""))
def test_fails_where_the_epic_states_no_formula_to_rank_two_scored_issues_by(self) -> None:
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "epic 1 by 9", "build-epic-claude")]
found, store, _ = self.plan(FakeEffects())
self.assertEqual(found, Failure("the epic ABC-12's description states `Score = ...` 0 times under ## Scoring; state the formula that ranks its issues once, on a line of its own and inside backticks, such as `Score = 100 * V / (2**S + 32)`"))
self.assertEqual([each.key for each in store.issues], ["ABC-20", "ABC-21"])
def test_fails_where_the_formula_names_a_score_no_issue_holds(self) -> None:
self.description = RANKED.replace("Score = V", "Score = Q")
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "epic 1 by 9", "build-epic-claude")]
self.assertIsInstance(self.plan(FakeEffects())[0], Failure)
def test_orders_issues_of_two_jira_projects_that_share_a_number(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("XYZ-20", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("XYZ-20", "epic 1 by 9", "build-epic-claude")]
found = self.plan(FakeEffects())[0]
assert not isinstance(found, Failure | Limited), found
self.assertEqual(planning.start_order(self.epic, found), ["XYZ-20", "ABC-20"])
def test_issues_that_score_the_same_start_in_the_trackers_order(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-30", "epic 1 by 5", "do-epic-claude", by_loop=False), scored("ABC-20", "epic 1 by 5", "do-epic-claude", by_loop=False)]
self.issues = [scored("ABC-30", "epic 1 by 5", "build-epic-claude", by_loop=False), scored("ABC-20", "epic 1 by 5", "build-epic-claude", by_loop=False)]
self.plan(FakeEffects())
self.assertEqual(planning.start_order(self.epic, self.issues), ["ABC-30", "ABC-20"])
def test_names_the_issue_by_its_key_where_the_order_of_score_fails(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-30", "epic 1 by 5", "do-epic-claude", by_loop=False), scored("ABC-20", "epic 7 by 5", "do-epic-claude", by_loop=False)]
self.issues = [scored("ABC-30", "epic 1 by 5", "build-epic-claude", by_loop=False), scored("ABC-20", "epic 7 by 5", "build-epic-claude", by_loop=False)]
self.plan(FakeEffects())
self.assertEqual(planning.start_order(self.epic, self.issues), Failure("ABC-20 names epic 7, which the epic's ## Goals does not number"))
def test_quotes_a_formula_that_names_an_item_as_the_epic_states_it(self) -> None:
self.description = RANKED.replace("Score = V", "Score = item 1")
self.issues = [scored("ABC-30", "epic 1 by 5", "do-epic-claude", by_loop=False), scored("ABC-20", "epic 1 by 5", "do-epic-claude", by_loop=False)]
self.issues = [scored("ABC-30", "epic 1 by 5", "build-epic-claude", by_loop=False), scored("ABC-20", "epic 1 by 5", "build-epic-claude", by_loop=False)]
self.plan(FakeEffects())
failed = planning.start_order(self.epic, self.issues)
assert isinstance(failed, Failure), failed
@@ -353,7 +353,7 @@ class Planning(DoEpicTest):
def test_fails_where_the_description_cannot_be_read_to_rank_by(self) -> None:
self.description = Failure("Jira answered 503")
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "epic 1 by 9", "build-epic-claude")]
self.assertEqual(self.plan(FakeEffects())[0], Failure("the epic ABC-12's description: Jira answered 503"))
def test_fails_naming_the_repo_whose_goals_cannot_be_read(self) -> None:
@@ -361,26 +361,26 @@ class Planning(DoEpicTest):
configured(self, checkout, home=self.home)
(checkout / "README.md").unlink(missing_ok=True)
self.description = RANKED
self.issues = [scored("ABC-20", "repo 1 by 9", "repo:api"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "repo 1 by 9", "repo:api"), scored("ABC-21", "epic 1 by 9", "build-epic-claude")]
found = self.plan(FakeEffects())[0]
assert isinstance(found, Failure), found
self.assertRegex(found.reason, r"^api: .*missing or empty")
def test_ranks_a_security_issue_first(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 9", "do-epic-claude"), dataclasses.replace(scored("ABC-21", "epic 1 by 2", "do-epic-claude"), exempt="security")]
self.issues = [scored("ABC-20", "epic 1 by 9", "build-epic-claude"), dataclasses.replace(scored("ABC-21", "epic 1 by 2", "build-epic-claude"), exempt="security")]
found = self.plan(FakeEffects())[0]
assert not isinstance(found, Failure | Limited), found
self.assertEqual([each.key for each in found], ["ABC-21", "ABC-20"])
def test_one_scored_issue_needs_no_formula(self) -> None:
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), issue("ABC-21", "do-epic-human")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), issue("ABC-21", "build-epic-human")]
self.assertEqual(self.plan(FakeEffects())[0], self.issues)
def test_scores_each_bare_issue_whoever_filed_it_and_tells_its_team_without_ranking_a_persons(self) -> None:
self.rule()
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude", by_loop=False), issue("ABC-21", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude", by_loop=False), issue("ABC-21", "build-epic-claude")]
# An earlier run made the folder the scoring runs in.
self.folder.mkdir(parents=True, exist_ok=True)
fake = FakeEffects(claude=[says(ANSWER)])
@@ -392,24 +392,24 @@ class Planning(DoEpicTest):
self.assertEqual(out, "<1790000000> scoring ABC-21\n<1790000000> ABC-21 is scored L 2, E 1, I 2, S 3, Moves epic 1 by 9\n")
self.assertEqual(planning.start_order(self.epic, found), ["ABC-21", "ABC-20"])
(asked,) = fake.made("claude")
for part in ("L is how much the item changes.", "Write the comment in English", "An item moves only these: `epic 1`.", "## Item ABC-21: Do ABC-21", "Labels: do-epic-claude"):
for part in ("L is how much the item changes.", "Write the comment in English", "An item moves only these: `epic 1`.", "## Item ABC-21: Do ABC-21", "Labels: build-epic-claude"):
self.assertIn(part, asked[1])
self.assertIn("--json-schema", asked[0])
def test_scores_no_human_task_and_no_issue_that_is_the_only_one_to_start(self) -> None:
self.rule()
self.description = RANKED
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-human")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-human")]
fake = FakeEffects()
found, store, out = self.plan(fake)
self.assertEqual((found, store.writes, out, fake.made("claude")), (self.issues, [], "", []))
def test_scores_no_issue_whose_work_has_landed(self) -> None:
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
with (self.home / ".config/build-release/build-epic/config.toml").open("a", encoding="utf-8") as config:
config.write('\njira-unblocking-statuses = ["Release Ready"]\n')
self.rule()
self.description = RANKED
self.issues = [issue("ABC-20", "do-epic-claude", status="release ready"), issue("ABC-21", "do-epic-claude"), scored("ABC-22", "epic 1 by 2", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude", status="release ready"), issue("ABC-21", "build-epic-claude"), scored("ABC-22", "epic 1 by 2", "build-epic-claude")]
fake = FakeEffects(claude=[says(ANSWER)])
found, store, _ = self.plan(fake)
assert not isinstance(found, Failure | Limited), found
@@ -419,7 +419,7 @@ class Planning(DoEpicTest):
def test_names_an_issue_whose_scoring_fails_and_scores_the_next(self) -> None:
self.rule()
self.description = RANKED
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "do-epic-claude"), issue("ABC-23", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude"), issue("ABC-22", "build-epic-claude"), issue("ABC-23", "build-epic-claude")]
fake = FakeEffects(claude=[says({"L": "big"}), says(ANSWER | {"moves": "epic 7 by 5"}), says(ANSWER | {"L": 99}), says(ANSWER)])
found, store, out = self.plan(fake)
assert not isinstance(found, Failure | Limited), found
@@ -434,7 +434,7 @@ class Planning(DoEpicTest):
def test_names_each_issue_whose_goals_cannot_be_read_and_asks_claude_about_none(self) -> None:
self.rule()
self.description = RANKED.replace("1. **Achieve:** ", "")
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
fake = FakeEffects()
out = self.plan(fake)[2]
self.assertIn("ABC-20 is not scored: the epic's ## Goals has no numbered goal\n", out)
@@ -443,7 +443,7 @@ class Planning(DoEpicTest):
def test_the_scoring_call_runs_in_the_epics_state_folder(self) -> None:
self.rule()
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
effects, folders = FakeEffects(claude=[says(ANSWER), says(ANSWER)]).effects(), []
def claude(args: object, cwd: str, stdin: object) -> object:
@@ -457,7 +457,7 @@ class Planning(DoEpicTest):
self.rule()
self.description = RANKED
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
fake = FakeEffects(claude=[subprocess.CompletedProcess([], 0, json.dumps(LIMIT), "")])
found, store, _ = self.plan(fake)
self.assertIsInstance(found, Limited)
@@ -466,7 +466,7 @@ class Planning(DoEpicTest):
def test_names_a_score_the_tracker_refuses(self) -> None:
self.rule()
self.description = RANKED
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-human"), scored("ABC-22", "epic 1 by 2", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-human"), scored("ABC-22", "epic 1 by 2", "build-epic-claude")]
store = MemoryEpic("ABC-12", list(self.issues))
store.fails = "Jira answered 503"
out = io.StringIO()
@@ -478,7 +478,7 @@ class Planning(DoEpicTest):
self.assertEqual((found, stopped, out.getvalue()), (self.issues, None, "<1790000000> scoring ABC-20\n<1790000000> ABC-20 is not scored: Jira answered 503\n"))
def test_scores_no_issue_without_the_scoring_rule_or_the_epics_formula(self) -> None:
self.issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude")]
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
self.description = RANKED
fake = FakeEffects()
found, _, _ = self.plan(fake)
@@ -495,7 +495,7 @@ class Planning(DoEpicTest):
self.rule()
self.repo("api")
self.description = RANKED + "\n**Language:** Swedish\n"
self.issues = [issue("ABC-20", "split-by-repo"), issue("ABC-30", "repo:api", parent="ABC-20"), scored("ABC-21", "epic 1 by 2", "do-epic-claude")]
self.issues = [issue("ABC-20", "split-by-repo"), issue("ABC-30", "repo:api", parent="ABC-20"), scored("ABC-21", "epic 1 by 2", "build-epic-claude")]
fake = FakeEffects(claude=[says(ANSWER | {"moves": "repo 1 by 4"})])
found, store, _ = self.plan(fake)
assert not isinstance(found, Failure | Limited), found
@@ -509,10 +509,10 @@ class Planning(DoEpicTest):
self.repo("api")
self.description = RANKED
self.issues = [
scored("ABC-20", "epic 1 by 9", "do-epic-claude", blockers=("ABC-21",)),
scored("ABC-20", "epic 1 by 9", "build-epic-claude", blockers=("ABC-21",)),
dataclasses.replace(issue("ABC-21", "split-by-repo"), blockers=("ABC-22",)),
scored("ABC-30", "epic 1 by 5", "repo:api", parent="ABC-21"),
scored("ABC-22", "epic 1 by 1", "do-epic-claude"),
scored("ABC-22", "epic 1 by 1", "build-epic-claude"),
]
found, _, _ = self.plan(FakeEffects())
assert not isinstance(found, Failure | Limited), found
@@ -530,18 +530,18 @@ class Planning(DoEpicTest):
def test_a_label_it_added_counts_where_the_tracker_cannot_be_read_afterwards(self) -> None:
self.issues = [issue("ABC-20")]
found = self.planned_on(Unreadable("ABC-12", list(self.issues)), FakeEffects(claude=[says({"parts": []}), says({"pick": "claude"})]))
self.assertEqual(found, ([issue("ABC-20", "do-epic-claude")], Failure("Jira answered 503")))
self.assertEqual(found, ([issue("ABC-20", "build-epic-claude")], Failure("Jira answered 503")))
def test_a_label_and_an_order_it_wrote_count_where_the_trackers_search_lags(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9"), issue("ABC-22")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "epic 1 by 9"), issue("ABC-22")]
parts = says({"parts": [{"repo": "api", "change": "Add the endpoint."}, {"repo": "web", "change": "Call it."}], "comment": "Split by repo: api and web."})
found, stopped = self.planned_on(Lagging("ABC-12", list(self.issues)), FakeEffects(claude=[says({"parts": []}), says({"pick": "claude"}), parts]))
self.assertEqual(([(each.key, each.labels) for each in found], stopped), ([("ABC-21", ("do-epic-claude",)), ("ABC-20", ("do-epic-claude",)), ("ABC-22", ("split-by-repo",))], None))
self.assertEqual(([(each.key, each.labels) for each in found], stopped), ([("ABC-21", ("build-epic-claude",)), ("ABC-20", ("build-epic-claude",)), ("ABC-22", ("split-by-repo",))], None))
def test_keeps_the_order_and_says_why_where_the_tracker_refuses_the_ranking(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "epic 1 by 9", "build-epic-claude")]
store = MemoryEpic("ABC-12", list(self.issues))
store.fails = "Jira answered 503"
found, stopped = self.planned_on(store, FakeEffects())
@@ -550,7 +550,7 @@ class Planning(DoEpicTest):
def test_an_issue_without_a_pick_is_not_ranked(self) -> None:
self.description = RANKED
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "code health by 9")]
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude"), scored("ABC-21", "code health by 9")]
found, _, out = self.plan(FakeEffects(claude=[subprocess.CompletedProcess([], 1, "", "")]))
self.assertEqual((found, "re-ranking" in out), (self.issues, False))
@@ -7,10 +7,10 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.ranking import chain, EpicItem, goals_named, rank_moves, ranked, RepoRanking, reranked
from build_epic.ranking import chain, EpicItem, goals_named, rank_moves, ranked, RepoRanking, reranked
from failure import Failure
from plan.todo_table import Item, parse_moves
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
EPIC_GOALS = "1. **Achieve:** Ship invoices.\n2. **Achieve:** Cut support mail.\n3. **Maintain:** Leak no customer data.\n"
VOIDED = RepoRanking("## Goals\n\n**Void:** code health, since it is a one-off script.\n\n1. **Achieve:** Fast builds.\n", "", "", decimal.Decimal("7.0"))
@@ -6,11 +6,11 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.repo_pick import also, CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, PICK_SCHEMA, picked, record, recorded, Repo, REPO_PREFIX, Unclear
from do_epic.backend.protocol import EpicIssue
from build_epic.repo_pick import also, CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, PICK_SCHEMA, picked, record, recorded, Repo, REPO_PREFIX, Unclear
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from claude_code.reply import Limited
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
from model_routing.ladder import Rung
RULE = "A label equal to a repo's name names that repo. Cleaning up docs has no repo."
@@ -99,7 +99,7 @@ class RepoPick(unittest.TestCase):
self.store.add_label(self.key, "repo:log")
self.store.add_label(self.key, HUMAN_LABEL)
claude = says({"pick": "claude"})
self.assertEqual(self.pick(claude), Failure(f"{self.key} is labelled with 2 picks: do-epic-human, repo:log; remove the labels of all but the right one"))
self.assertEqual(self.pick(claude), Failure(f"{self.key} is labelled with 2 picks: build-epic-human, repo:log; remove the labels of all but the right one"))
self.assertEqual(claude.calls, [])
def test_an_unclear_pick_returns_the_question_and_records_nothing_until_the_human_answers(self) -> None:
@@ -145,12 +145,12 @@ class RepoPick(unittest.TestCase):
self.assertEqual((picked(self.store, self.issue(), TEAM, RULE, RUNG, claude, "/rules"), claude.calls), (Repo("tenant-web-ui-4"), []))
self.assertIsNone(recorded(self.issue(), {}), "the label means nothing without the table")
def test_the_teams_label_and_do_epics_own_for_one_repo_record_one_pick(self) -> None:
def test_the_teams_label_and_build_epics_own_for_one_repo_record_one_pick(self) -> None:
self.store.add_label(self.key, "twu-4")
self.store.add_label(self.key, "repo:tenant-web-ui-4")
self.assertEqual(recorded(self.issue(), TEAM), Repo("tenant-web-ui-4"))
def test_the_teams_labels_end_a_list_of_do_epics_only_where_it_has_some(self) -> None:
def test_the_teams_labels_end_a_list_of_build_epics_only_where_it_has_some(self) -> None:
self.assertEqual((also(TEAM), also({})), (" (or the team's `core-4`, `twu-4`)", ""))
def test_two_of_the_teams_labels_for_different_repos_fail_and_name_both(self) -> None:
@@ -6,9 +6,9 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from test_env import assert_not_root
from do_epic.config import DoEpicConfig
from build_epic.config import BuildEpicConfig
from failure import Failure
from do_epic.repos import locate, Located, Unsure
from build_epic.repos import locate, Located, Unsure
from project_config.settings import ProjectConfig
from project_config.doubles import write_config
@@ -44,7 +44,7 @@ class LocateTest(unittest.TestCase):
self.addCleanup(made.cleanup)
self.home = pathlib.Path(made.name).resolve()
self.projects = self.home / ".config/build-release"
self.config = DoEpicConfig(self.projects / "do-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "clones", "English", "claude-opus-5-5", "rule")
self.config = BuildEpicConfig(self.projects / "build-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "clones", "English", "claude-opus-5-5", "rule")
self.billing, self.payments = self.home / "elsewhere" / "billing", self.home / "elsewhere" / "payments"
self.origins: dict[str, str | Failure] = {str(self.billing): "git@github.com:acme/billing.git", str(self.payments): "git@github.com:acme/payments"}
@@ -7,13 +7,13 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.scheduler import Chunk, chunks, Epic, held_up, HUMAN_WAIT, refusal, RepoRoom, resume, start_chunks, Started, Waits
from build_epic.scheduler import Chunk, chunks, Epic, held_up, HUMAN_WAIT, refusal, RepoRoom, resume, start_chunks, Started, Waits
from chunk_driver.claims import CHUNK_FLAG
from do_epic import chunk_prompt
from do_epic.backend.protocol import EpicIssue
from build_epic import chunk_prompt
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from do_epic.parked import file_of, park, Parked
from do_epic.epic_record import parallel_chunks_in
from build_epic.parked import file_of, park, Parked
from build_epic.epic_record import parallel_chunks_in
from loop_state.paths import paths_from
from chunk_driver import prompts
from model_routing.route import Route
@@ -38,7 +38,7 @@ class TheCapLine(unittest.TestCase):
for line in ("**Max parallel chunks**: 2", "Max parallel chunks: 2", "**max parallel chunks:** 2", "- **Max parallel chunks:** 2"):
found = parallel_chunks_in(f"## Goals\nShip.\n{line}\n")
assert isinstance(found, Failure), line
self.assertEqual(found.reason, f"the epic's description holds the line `{line}`, which do-epic doesn't read as the epic's cap: write it as a line of its own, spelt `**Max parallel chunks:** 2`")
self.assertEqual(found.reason, f"the epic's description holds the line `{line}`, which build-epic doesn't read as the epic's cap: write it as a line of its own, spelt `**Max parallel chunks:** 2`")
self.assertEqual(parallel_chunks_in("We raise the max parallel chunks later.\n```\nMax parallel chunks: 2\n```\n"), 1)
def test_refuses_a_cap_that_is_no_whole_number_of_1_or_more(self) -> None:
@@ -50,7 +50,7 @@ class TheCapLine(unittest.TestCase):
class WhichIssuesAreChunks(unittest.TestCase):
def test_an_open_issue_with_a_repo_or_claude_work_is_a_chunk_in_rank_order(self) -> None:
found = chunks([issue("ABC-20", "repo:api"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "repo:web", done=True)], {})
found = chunks([issue("ABC-20", "repo:api"), issue("ABC-21", "build-epic-claude"), issue("ABC-22", "repo:web", done=True)], {})
self.assertEqual(found, ([Chunk("ABC-20", "api"), Chunk("ABC-21", None)], []))
def test_a_split_item_is_no_chunk_but_its_sub_tasks_are(self) -> None:
@@ -70,7 +70,7 @@ class WhichIssuesAreChunks(unittest.TestCase):
self.assertEqual(chunks(issues, team), ([Chunk("ABC-19", "tenant-web-ui-4"), Chunk("ABC-25", "core-4")], [Waits("ABC-23", "ABC-19 blocks it")]))
self.assertEqual(chunks(issues[:1], {}), ([], [Waits("ABC-19", "no label names its repo")]))
def test_an_item_whose_only_sub_task_do_epic_filed_is_not_split_until_marked(self) -> None:
def test_an_item_whose_only_sub_task_build_epic_filed_is_not_split_until_marked(self) -> None:
task = dataclasses.replace(issue("ABC-23", "repo:api", parent="ABC-20"), by_loop=True)
self.assertEqual(chunks([issue("ABC-20"), task], {}), ([Chunk("ABC-23", "api")], [Waits("ABC-20", "no label names its repo")]))
@@ -81,19 +81,19 @@ class WhichIssuesAreChunks(unittest.TestCase):
def test_an_item_marked_split_whose_sub_tasks_are_done_waits_for_nobody(self) -> None:
self.assertEqual(chunks([issue("ABC-20", "split-by-repo"), issue("ABC-23", "repo:api", parent="ABC-20", done=True)], {}), ([], []))
def test_a_persons_sub_task_without_a_label_waits_for_one_and_says_do_epic_plans_none(self) -> None:
def test_a_persons_sub_task_without_a_label_waits_for_one_and_says_build_epic_plans_none(self) -> None:
found = chunks([issue("ABC-20", "repo:api"), issue("ABC-23", parent="ABC-20")], {})
self.assertEqual(found, ([], [Waits("ABC-23", "no label names its repo; label it in Jira, since do-epic plans no sub-task")]))
self.assertEqual(found, ([], [Waits("ABC-23", "no label names its repo; label it in Jira, since build-epic plans no sub-task")]))
def test_names_each_blocker_outside_the_epic(self) -> None:
self.assertEqual(chunks([issue("ABC-20", "repo:api", blockers=("XYZ-1", "XYZ-2"))], {})[1], [
Waits("ABC-20", "XYZ-1 and XYZ-2 block it; do-epic cannot see XYZ-1 and XYZ-2, outside the epic, finish: remove such a link in Jira once its issue is done"),
Waits("ABC-20", "XYZ-1 and XYZ-2 block it; build-epic cannot see XYZ-1 and XYZ-2, outside the epic, finish: remove such a link in Jira once its issue is done"),
])
def test_an_issue_waits_for_its_pick_its_human_and_its_blockers(self) -> None:
found = chunks([
issue("ABC-20"),
issue("ABC-21", "do-epic-human"),
issue("ABC-21", "build-epic-human"),
issue("ABC-22", "repo:api", "repo:web"),
issue("ABC-23", "repo:api", blockers=("ABC-20", "ABC-30", "XYZ-1")),
issue("ABC-30", "repo:api", done=True),
@@ -102,19 +102,19 @@ class WhichIssuesAreChunks(unittest.TestCase):
Waits("ABC-20", "no label names its repo"),
Waits("ABC-21", "it is a human's task"),
Waits("ABC-22", "ABC-22 is labelled with 2 picks: repo:api, repo:web; remove the labels of all but the right one"),
Waits("ABC-23", "ABC-20 and XYZ-1 block it; do-epic cannot see XYZ-1, outside the epic, finish: remove such a link in Jira once its issue is done"),
Waits("ABC-23", "ABC-20 and XYZ-1 block it; build-epic cannot see XYZ-1, outside the epic, finish: remove such a link in Jira once its issue is done"),
]))
def test_a_human_task_that_blocks_an_open_issue_is_a_chunk_to_await_and_one_that_blocks_none_waits(self) -> None:
found = chunks([issue("ABC-20", "do-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "do-epic-human")], {})
found = chunks([issue("ABC-20", "build-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "build-epic-human")], {})
self.assertEqual(found, ([Chunk("ABC-20", None, human=True)], [Waits("ABC-21", "ABC-20 blocks it"), Waits("ABC-22", "it is a human's task")]))
def test_a_human_task_is_awaited_while_it_blocks_a_sub_task_through_its_split_parent(self) -> None:
found = chunks([issue("ABC-19", "do-epic-human"), issue("ABC-20", "split-by-repo", blockers=("ABC-19",)), issue("ABC-23", "repo:api", parent="ABC-20")], {})
found = chunks([issue("ABC-19", "build-epic-human"), issue("ABC-20", "split-by-repo", blockers=("ABC-19",)), issue("ABC-23", "repo:api", parent="ABC-20")], {})
self.assertEqual(found, ([Chunk("ABC-19", None, human=True)], [Waits("ABC-23", "ABC-19 blocks it")]))
def test_a_human_task_that_is_blocked_itself_or_blocks_only_done_issues_waits(self) -> None:
found = chunks([issue("ABC-19", "repo:api"), issue("ABC-20", "do-epic-human", blockers=("ABC-19",)), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "do-epic-human"), issue("ABC-23", "repo:api", done=True, blockers=("ABC-22",))], {})
found = chunks([issue("ABC-19", "repo:api"), issue("ABC-20", "build-epic-human", blockers=("ABC-19",)), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "build-epic-human"), issue("ABC-23", "repo:api", done=True, blockers=("ABC-22",))], {})
self.assertEqual(found, ([Chunk("ABC-19", "api")], [Waits("ABC-20", "it is a human's task"), Waits("ABC-21", "ABC-20 blocks it"), Waits("ABC-22", "it is a human's task")]))
def test_what_blocks_a_split_item_blocks_its_sub_tasks(self) -> None:
@@ -132,7 +132,7 @@ class WhichIssuesAreChunks(unittest.TestCase):
self.assertEqual(held_up(issues, ("Release Ready", "Shipped")), {"ABC-21": ["ABC-22", "ABC-24"], "ABC-22": ["ABC-24"]})
def test_a_humans_task_gets_no_window_for_an_issue_it_blocks_that_is_in_an_unblocking_status(self) -> None:
issues = [issue("ABC-19", "do-epic-human"), issue("ABC-20", "repo:api", blockers=("ABC-19",), status="Release Ready")]
issues = [issue("ABC-19", "build-epic-human"), issue("ABC-20", "repo:api", blockers=("ABC-19",), status="Release Ready")]
self.assertEqual(chunks(issues, {}, ("Release Ready",))[0], [])
def test_an_unblocking_status_matches_whatever_its_case(self) -> None:
@@ -143,9 +143,9 @@ class WhichIssuesAreChunks(unittest.TestCase):
unseen = "outside the epic, finish: remove such a link in Jira once its issue is done"
issues = [issue("ABC-19", "repo:api"), issue("ABC-20", "repo:api", blockers=("XYZ-1",)), issue("ABC-21", "repo:api", blockers=("ABC-19", "XYZ-1")), issue("ABC-22", "repo:api", blockers=("ABC-19", "ABC-20", "XYZ-1"))]
self.assertEqual(chunks(issues, {}, ("Release Ready",))[1], [
Waits("ABC-20", f"XYZ-1 blocks it; do-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-21", f"ABC-19 and XYZ-1 block it, until ABC-19 is Release Ready or done; do-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-22", f"ABC-19 and ABC-20 and XYZ-1 block it, until ABC-19 and ABC-20 are Release Ready or done; do-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-20", f"XYZ-1 blocks it; build-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-21", f"ABC-19 and XYZ-1 block it, until ABC-19 is Release Ready or done; build-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-22", f"ABC-19 and ABC-20 and XYZ-1 block it, until ABC-19 and ABC-20 are Release Ready or done; build-epic cannot see XYZ-1, {unseen}"),
])
def test_a_split_item_unblocks_what_it_blocks_once_each_sub_task_is_in_an_unblocking_status(self) -> None:
@@ -211,7 +211,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
"""An epic whose repos are checked out under the home folder, each with its `parallel-chunks`."""
def locate(name: str) -> tuple[pathlib.Path, int] | Failure:
return (self.home / "code" / name, limits[name]) if name in limits else Failure(f"no project config names {name}")
return Epic("ABC-12", cap, locate, paths_from(self.home, {}), pathlib.Path("/bin/do-epic"), {"BUILD_RELEASE_X": "1", "OTHER": "2"}, {}, self.order)
return Epic("ABC-12", cap, locate, paths_from(self.home, {}), pathlib.Path("/bin/build-epic"), {"BUILD_RELEASE_X": "1", "OTHER": "2"}, {}, self.order)
def start(self, epic: Epic, issues: list[EpicIssue], run: Tmux, own: str | None = None) -> Started:
found = start_chunks(epic, issues, False, own, run)
@@ -220,26 +220,26 @@ class StartingAnEpicsChunks(unittest.TestCase):
def test_starts_a_window_per_chunk_up_to_the_epics_cap(self) -> None:
run = Tmux()
found = self.start(self.epic(2, api=1, web=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "repo:web")], run)
found = self.start(self.epic(2, api=1, web=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "build-epic-claude"), issue("ABC-22", "repo:web")], run)
self.assertEqual(found, Started(["ABC-20", "ABC-21"], [Waits("ABC-22", "the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 2")]))
self.assertEqual(run.started(), [("epic-ABC-12", "ABC-20", f"{CHUNK_FLAG} ABC-20 ABC-12"), ("epic-ABC-12", "ABC-21", f"{CHUNK_FLAG} ABC-21 ABC-12")])
self.assertEqual([args[args.index("-c") + 1] for args in run.calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / ".local/state/build-release/do-epic/ABC-12")])
self.assertEqual([args[args.index("-c") + 1] for args in run.calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / ".local/state/build-release/build-epic/ABC-12")])
self.assertIn("BUILD_RELEASE_X=1", run.calls[[args[0] for args in run.calls].index("new-session")])
self.assertNotIn("OTHER=2", run.calls[[args[0] for args in run.calls].index("new-session")])
def parked(self, issue_key: str, on: str = "an approval") -> None:
self.assertIsNone(park(self.home / ".local/state/build-release/do-epic/ABC-12", Parked(issue_key, f"/code/api-{issue_key}", "7", "0c0f", on)))
self.assertIsNone(park(self.home / ".local/state/build-release/build-epic/ABC-12", Parked(issue_key, f"/code/api-{issue_key}", "7", "0c0f", on)))
def test_starts_the_chunks_in_the_epics_start_order_and_those_it_leaves_out_last_in_backlog_order(self) -> None:
self.order = ("ABC-23", "ABC-21")
run = Tmux()
issues = [issue("ABC-20", "do-epic-claude"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "do-epic-claude"), issue("ABC-23", "do-epic-claude")]
issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude"), issue("ABC-22", "build-epic-claude"), issue("ABC-23", "build-epic-claude")]
found = self.start(self.epic(3), issues, run)
self.assertEqual(found, Started(["ABC-23", "ABC-21", "ABC-20"], [Waits("ABC-22", "the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 3")]))
def test_the_epics_finishing_starts_whatever_the_start_order_names(self) -> None:
self.order = ("ABC-20",)
found = start_chunks(self.epic(1), [issue("ABC-20", "do-epic-claude", done=True)], True, None, Tmux())
found = start_chunks(self.epic(1), [issue("ABC-20", "build-epic-claude", done=True)], True, None, Tmux())
self.assertEqual(found, Started(["ABC-12"], []))
def test_a_parked_chunk_waits_in_its_window_and_takes_no_slot_of_the_epic_or_its_repo(self) -> None:
@@ -261,17 +261,17 @@ class StartingAnEpicsChunks(unittest.TestCase):
run = Tmux(*windows, ("epic-ABC-12", "ABC-21", False, str(self.home / "code/api")))
found = self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], run)
self.assertEqual(found, Started(["ABC-20"], []))
self.assertEqual(run.windows[-1], ("epic-ABC-12", "ABC-20", False, str(self.home / ".local/state/build-release/do-epic/ABC-12")))
self.assertEqual(run.windows[-1], ("epic-ABC-12", "ABC-20", False, str(self.home / ".local/state/build-release/build-epic/ABC-12")))
self.assertEqual([name for _, name, dead, _ in run.windows if dead], [""] * len(windows))
def test_a_human_task_that_blocks_an_issue_gets_a_window_that_takes_no_slot_of_the_epics_cap(self) -> None:
run = Tmux()
found = self.start(self.epic(1, api=1), [issue("ABC-19", "do-epic-human"), issue("ABC-20", "do-epic-claude"), issue("ABC-21", "repo:api", blockers=("ABC-19",))], run)
found = self.start(self.epic(1, api=1), [issue("ABC-19", "build-epic-human"), issue("ABC-20", "build-epic-claude"), issue("ABC-21", "repo:api", blockers=("ABC-19",))], run)
self.assertEqual(found, Started(["ABC-19", "ABC-20"], [Waits("ABC-21", "ABC-19 blocks it")]))
def test_a_human_task_with_a_window_that_awaits_it_starts_no_second_window(self) -> None:
run = Tmux(("epic-ABC-12", "ABC-19 awaits a human's task", False, ""))
found = self.start(self.epic(1, api=1), [issue("ABC-19", "do-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-19",))], run)
found = self.start(self.epic(1, api=1), [issue("ABC-19", "build-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-19",))], run)
self.assertEqual(found, Started([], [Waits("ABC-19", HUMAN_WAIT), Waits("ABC-21", "ABC-19 blocks it")]))
self.assertEqual(run.started(), [])
@@ -283,7 +283,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
def test_a_chunk_that_hands_on_starts_no_parked_chunk_whose_window_stopped(self) -> None:
self.parked("ABC-20")
found = self.start(self.epic(2, api=2), [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], Tmux(), own="ABC-21")
self.assertEqual(found, Started([], [Waits("ABC-20", "its window stopped; run `do-epic ABC-12` to start it again")]))
self.assertEqual(found, Started([], [Waits("ABC-20", "its window stopped; run `build-epic ABC-12` to start it again")]))
def test_a_chunk_that_parks_frees_its_slot_for_the_next(self) -> None:
self.parked("ABC-20")
@@ -293,7 +293,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
def test_stops_on_a_parked_chunk_it_cannot_read_and_starts_none(self) -> None:
self.parked("ABC-20")
file_of(self.home / ".local/state/build-release/do-epic/ABC-12", "ABC-20").write_text("{")
file_of(self.home / ".local/state/build-release/build-epic/ABC-12", "ABC-20").write_text("{")
run = Tmux()
found = start_chunks(self.epic(2, api=2), [issue("ABC-21", "repo:api")], False, None, run)
assert isinstance(found, Failure)
@@ -315,7 +315,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
self.assertEqual(run.windows[0], ("epic-ABC-12", "ABC-20", False, str(self.home / "code/api")))
def test_a_parked_chunk_whose_window_started_again_doesnt_count_itself_as_running(self) -> None:
for root in (str(self.home / ".local/state/build-release/do-epic/ABC-12"), str(self.home / "code/api")):
for root in (str(self.home / ".local/state/build-release/build-epic/ABC-12"), str(self.home / "code/api")):
with self.subTest(root=root):
run = Tmux(("epic-ABC-12", "ABC-20", False, root))
self.assertIsNone(self.resumed(self.epic(1, api=1), run))
@@ -370,12 +370,12 @@ class StartingAnEpicsChunks(unittest.TestCase):
def test_a_finished_chunk_leaves_its_room_and_restarts_no_stopped_chunk(self) -> None:
run = Tmux(("epic-ABC-12", "ABC-20", False, str(self.home / "code/api")), ("epic-ABC-12", "ABC-21", True, str(self.home / "code/api")))
found = self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api"), issue("ABC-22", "repo:api")], run, own="ABC-20")
self.assertEqual(found, Started(["ABC-22"], [Waits("ABC-21", "its window stopped; run `do-epic ABC-12` to start it again")]))
self.assertEqual(found, Started(["ABC-22"], [Waits("ABC-21", "its window stopped; run `build-epic ABC-12` to start it again")]))
def test_holds_each_repos_starting_lock_that_build_release_holds(self) -> None:
self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api")], Tmux())
self.assertTrue((self.home / ".local/state/build-release/claims/api/starting").is_file())
self.assertTrue((self.home / ".local/state/build-release/do-epic/ABC-12/starting").is_file())
self.assertTrue((self.home / ".local/state/build-release/build-epic/ABC-12/starting").is_file())
def test_a_parked_chunk_resumes_under_the_starting_lock_of_its_repos_checkout(self) -> None:
self.assertIsNone(self.resumed(self.epic(1, api=1), Tmux(("epic-ABC-12", "ABC-20 awaits an approval", False, ""))))
@@ -388,17 +388,17 @@ class StartingAnEpicsChunks(unittest.TestCase):
def test_a_chunks_window_never_marks_the_session_as_a_checkouts(self) -> None:
run = Tmux()
self.start(self.epic(2, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "do-epic-claude")], run)
self.start(self.epic(2, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "build-epic-claude")], run)
options = [args[-2] for args in run.calls if args[0] == "set-option"]
self.assertIn(tmux.ROOT, options)
self.assertNotIn(tmux.OWNER, options)
def test_says_which_lock_it_could_not_take(self) -> None:
(self.home / ".local/state/build-release/do-epic").mkdir(parents=True)
(self.home / ".local/state/build-release/do-epic/ABC-12").write_text("", encoding="utf-8")
(self.home / ".local/state/build-release/build-epic").mkdir(parents=True)
(self.home / ".local/state/build-release/build-epic/ABC-12").write_text("", encoding="utf-8")
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
assert isinstance(found, Failure)
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/build-release/do-epic/ABC-12: \\w")
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/build-release/build-epic/ABC-12: \\w")
def test_says_which_repos_lock_it_could_not_take(self) -> None:
(self.home / ".local/state/build-release").mkdir(parents=True)
@@ -422,29 +422,29 @@ CONFIG = settings.ProjectConfig("api", pathlib.Path("/c/api"), pathlib.Path("/co
class TheFirstPrompt(unittest.TestCase):
def test_the_task_names_the_checkout_and_branch_and_quotes_a_description_only_where_there_is_one(self) -> None:
labels = "`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"
labels = "`repo:<name>` for the repo that works it, `build-epic-claude` for work of Claude's that changes no repo, or `build-epic-human` for a task of the human's"
told = (
f"File a finding about one of the epic's goals in the epic, with `/b/do-epic ABC-12 --file \"<summary>\" --label <label>` and its detail on stdin. The label is {labels}; leave it out where you cannot tell, and the next `do-epic` the human runs picks it. "
f"File a finding about one of the epic's goals in the epic, with `/b/build-epic ABC-12 --file \"<summary>\" --label <label>` and its detail on stdin. The label is {labels}; leave it out where you cannot tell, and the next `build-epic` the human runs picks it. "
"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. "
"Record a decision that governs the epic, such as an answer the human typed, with `/b/build-epic ABC-12 --record-decision \"<title>\"` and its text on stdin. "
"Write the issue and the decision in Swedish, the epic's language."
)
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/build-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.removesuffix('Write the issue and the decision in Swedish, the epic\'s language.')}"))
self.assertIn("`/b/do-epic ABC-12 --file \"<summary>\" --blocked-by ABC-20`", task)
self.assertIn("`/b/build-epic ABC-12 --file \"<summary>\" --blocked-by ABC-20`", task)
self.assertIn(" Write the issue and the decision in Swedish, the epic's language. ", task)
self.assertTrue(task.endswith(" Its summary: Do ABC-20"))
def test_a_sub_task_is_told_to_file_the_next_pull_request_under_its_parent_in_its_repo(self) -> None:
task = chunk_prompt.task(issue("ABC-23", "repo:api", parent="ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
task = chunk_prompt.task(issue("ABC-23", "repo:api", parent="ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/build-epic"), "Swedish", CONFIG)
self.assertIn("--file \"<summary>\" --blocked-by ABC-23 --parent ABC-20 --label repo:api` and its detail on stdin.", task)
task = chunk_prompt.task(issue("ABC-20", "twu-4", "urgent"), "ABC-12", {"twu-4": "tenant-web-ui-4"}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
task = chunk_prompt.task(issue("ABC-20", "twu-4", "urgent"), "ABC-12", {"twu-4": "tenant-web-ui-4"}, "/code/api", pathlib.Path("/b/build-epic"), "Swedish", CONFIG)
self.assertIn("--file \"<summary>\" --blocked-by ABC-20 --label twu-4` and its detail on stdin.", task)
task = chunk_prompt.task(issue("ABC-20", "repo:tenant-web-ui-4"), "ABC-12", {"twu-4": "tenant-web-ui-4"}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
task = chunk_prompt.task(issue("ABC-20", "repo:tenant-web-ui-4"), "ABC-12", {"twu-4": "tenant-web-ui-4"}, "/code/api", pathlib.Path("/b/build-epic"), "Swedish", CONFIG)
self.assertIn("--file \"<summary>\" --blocked-by ABC-20 --label twu-4` and its detail on stdin.", task)
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)
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, None, pathlib.Path("/b/build-epic"), "Swedish", None)
self.assertTrue(task.endswith("Swedish, the epic's language. Its summary: Do ABC-20"))
self.assertNotIn("--finish", task)
@@ -468,7 +468,7 @@ class TheFirstPrompt(unittest.TestCase):
def test_a_repo_with_an_epic_branch_is_told_to_branch_off_it_and_that_the_merge_needs_no_person(self) -> None:
config = dataclasses.replace(CONFIG, epic_branch="epic/{epic}", merge="human")
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/build-epic"), "Swedish", config)
self.assertIn("The chunk's pull request goes into the epic's working branch `epic/ABC-12`, not into the default branch", task)
self.assertIn("make the chunk's worktree and branch off `origin/epic/ABC-12`", task)
self.assertIn("`chunk-pr merge` merges into `epic/ABC-12` without waiting for a person. Where the chunk's tests run", task)
@@ -479,12 +479,12 @@ class TheFirstPrompt(unittest.TestCase):
def test_a_repo_whose_reviewer_is_asked_by_a_comment_is_told_to_push_with_chunk_pr(self) -> None:
config = dataclasses.replace(CONFIG, epic_branch="{epic}", review_request_comment="@reviewbot review")
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/build-epic"), "Swedish", config)
self.assertIn("`chunk-pr merge` merges into `ABC-12` without waiting for a person. After `chunk-pr ready`, push each commit with `chunk-pr push`, which asks the repo's auto-reviewer to review the new head, and wait for that review. Where the chunk's tests run", task)
def test_a_repo_without_an_epic_branch_is_told_nothing_of_one(self) -> None:
config = dataclasses.replace(CONFIG, merge="human")
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/build-epic"), "Swedish", config)
self.assertEqual(chunk_prompt.epic_branch_rule(config, "ABC-12"), "")
self.assertNotIn("working branch", task)
self.assertIn("leaves the pull request ready for a person to merge", task)
@@ -497,7 +497,7 @@ class TheFirstPrompt(unittest.TestCase):
start = f"T\n\nContinue any open draft PR or worktree for the chunk before creating a new one. {prompts.READING_RULE}\n\n"
self.assertEqual(chunk_prompt.fresh("T", "P", Route(Rung("off-the-ladder")), None, ""), start + rest)
routed = chunk_prompt.fresh("T", "P", Route(Rung("off-the-ladder"), 21, 3, 5), None, "")
self.assertTrue(routed.startswith(start + "do-epic runs you on off-the-ladder, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue."), routed)
self.assertTrue(routed.startswith(start + "build-epic runs you on off-the-ladder, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue."), routed)
self.assertTrue(routed.endswith("\n\n" + rest), routed)
@@ -511,7 +511,7 @@ class WindowsAcrossSessions(unittest.TestCase):
self.assertEqual(tmux.everywhere(lambda args: subprocess.CompletedProcess(args, 1, "epic-ABC-12\tABC-20\t0\t@0\t/code/api\n", "")), [])
def test_a_started_chunk_joins_the_sessions_windows_as_running(self) -> None:
found = tmux.start_chunk(tmux.Window("epic-ABC-12", "ABC-20", ""), "/code/api", {}, ["do-epic"], [tmux.Listed("ABC-20", "@0", True), tmux.Listed("ABC-21", "@1", False)], False, Tmux(("epic-ABC-12", "ABC-20", True, "/code/api"), ("epic-ABC-12", "ABC-21", False, "/code/api")))
found = tmux.start_chunk(tmux.Window("epic-ABC-12", "ABC-20", ""), "/code/api", {}, ["build-epic"], [tmux.Listed("ABC-20", "@0", True), tmux.Listed("ABC-21", "@1", False)], False, Tmux(("epic-ABC-12", "ABC-20", True, "/code/api"), ("epic-ABC-12", "ABC-21", False, "/code/api")))
self.assertEqual(found, [tmux.Listed("ABC-21", "@1", False), tmux.Listed("ABC-20", "", False)])
@@ -6,12 +6,12 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.test_repo_pick import Claude, says
from do_epic.backend.protocol import EpicIssue
from build_epic.test_repo_pick import Claude, says
from build_epic.backend.protocol import EpicIssue
from failure import Failure
from do_epic.split import finished, is_split, Split, split, SPLIT_LABEL, SPLIT_SCHEMA, task_summary
from build_epic.split import finished, is_split, Split, split, SPLIT_LABEL, SPLIT_SCHEMA, task_summary
from claude_code.reply import Limited
from do_epic.backend.fake import MemoryEpic
from build_epic.backend.fake import MemoryEpic
from model_routing.ladder import Rung
RULE = "A label equal to a repo's name names that repo."
@@ -100,13 +100,13 @@ class Split_(unittest.TestCase):
def test_a_first_filing_that_fails_says_the_run_filed_no_sub_task(self) -> None:
self.store.fails_files = True
self.assertEqual(self.run_split(says(TWO)), Failure(f"cannot file the sub-task for api under {self.key}: Jira answered 500; this run filed no sub-task; run do-epic again to file the rest"))
self.assertEqual(self.run_split(says(TWO)), Failure(f"cannot file the sub-task for api under {self.key}: Jira answered 500; this run filed no sub-task; run build-epic again to file the rest"))
def test_a_comment_that_fails_leaves_the_item_unmarked_and_the_next_run_files_nothing_again(self) -> None:
self.store.fails_comments = True
failed = self.run_split(says(TWO), by_person=True)
first, second = (task.key for task in self.tasks())
self.assertEqual(failed, Failure(f"cannot comment on {self.key}: Jira answered 500; this run filed {first}, {second}; run do-epic again to post it"))
self.assertEqual(failed, Failure(f"cannot comment on {self.key}: Jira answered 500; this run filed {first}, {second}; run build-epic again to post it"))
self.assertEqual(self.issue().labels, ("api",))
self.store.fails_comments = False
done = self.run_split(says(TWO), by_person=True)
@@ -144,7 +144,7 @@ class Split_(unittest.TestCase):
self.store.jammed = True
failed = self.run_split(says(TWO), by_person=True)
first = self.tasks()[0].key
self.assertEqual(failed, Failure(f"cannot file the sub-task for web under {self.key}: Jira answered 500; this run filed {first}; run do-epic again to file the rest"))
self.assertEqual(failed, Failure(f"cannot file the sub-task for web under {self.key}: Jira answered 500; this run filed {first}; run build-epic again to file the rest"))
self.assertEqual(self.issue().labels, ("api",))
self.store.jammed = False
done = self.run_split(says(TWO), by_person=True)
@@ -204,7 +204,7 @@ class Split_(unittest.TestCase):
self.store.add_label = lambda key, label: Failure("Jira answered 500") if label == SPLIT_LABEL else None # type: ignore[method-assign]
failed = self.run_split(says(TWO))
first, second = (task.key for task in self.tasks())
self.assertEqual(failed, Failure(f"cannot mark {self.key} as split: Jira answered 500; this run filed {first}, {second}; run do-epic again to mark it"))
self.assertEqual(failed, Failure(f"cannot mark {self.key} as split: Jira answered 500; this run filed {first}, {second}; run build-epic again to mark it"))
def test_passes_on_a_failed_or_limited_claude(self) -> None:
self.assertEqual(self.run_split(Claude("", 1)), Failure("the repo split exited 1"))
@@ -228,7 +228,7 @@ class Finished(unittest.TestCase):
self.assertEqual([finished(self.issues((done, ()), (True, True)), "ABC-1") for done in (False, True)], [False, True])
self.assertTrue(is_split(*self.issues((False, ()), (False,))[:1], self.issues((False, ()), (False,))))
def test_an_item_whose_only_sub_tasks_do_epic_filed_is_not_split_until_marked(self) -> None:
def test_an_item_whose_only_sub_tasks_build_epic_filed_is_not_split_until_marked(self) -> None:
parent, task = self.issues((False, ()), (True,))
ours = [parent, dataclasses.replace(task, by_loop=True)]
self.assertEqual((is_split(parent, ours), finished(ours, "ABC-1")), (False, False))
@@ -5,8 +5,8 @@ import tempfile
import unittest
from failure import Failure
from do_epic.test_scheduler import issue, Tmux
from do_epic import parked, status
from build_epic.test_scheduler import issue, Tmux
from build_epic import parked, status
SINCE = 1_700_000_000
# SINCE as the status prints it.
@@ -47,11 +47,11 @@ class TheStatusLines(unittest.TestCase):
def test_a_parked_chunk_without_a_window_says_since_when_and_how_to_start_it_again(self) -> None:
self.park("ABC-20", "an approval")
self.assertEqual(self.lines([issue("ABC-20", "repo:api")]), [f"ABC-20 waits: it is parked: its pull request #7 awaits an approval, since {SINCE_ON}, and its window stopped; run `do-epic ABC-12` to start it again"])
self.assertEqual(self.lines([issue("ABC-20", "repo:api")]), [f"ABC-20 waits: it is parked: its pull request #7 awaits an approval, since {SINCE_ON}, and its window stopped; run `build-epic ABC-12` to start it again"])
def test_an_issue_without_scores_says_that_it_starts_after_each_that_holds_them(self) -> None:
held = dataclasses.replace(issue("ABC-21", "repo:api"), scores={"L": 1, "E": 1, "I": 1, "S": 1})
room = "it has not started; `do-epic ABC-12` starts it once the epic and its repo have room"
room = "it has not started; `build-epic ABC-12` starts it once the epic and its repo have room"
found = status.lines("ABC-12", self.folder, [issue("ABC-20", "repo:api"), held], {}, (), Tmux(), ("ABC-21",))
self.assertEqual(found, [f"ABC-20 waits: {room}, after each issue that holds every score, since it doesn't", f"ABC-21 waits: {room}"])
# Where no issue starts by score, each starts in the tracker's rank order.
@@ -59,10 +59,10 @@ class TheStatusLines(unittest.TestCase):
def test_a_stopped_chunk_and_one_not_started_say_so(self) -> None:
found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], (EPIC, "ABC-20", True, ""))
self.assertEqual(found, ["ABC-20 waits: its window stopped; run `do-epic ABC-12` to start it again", "ABC-21 waits: it has not started; `do-epic ABC-12` starts it once the epic and its repo have room"])
self.assertEqual(found, ["ABC-20 waits: its window stopped; run `build-epic ABC-12` to start it again", "ABC-21 waits: it has not started; `build-epic ABC-12` starts it once the epic and its repo have room"])
def test_a_human_task_and_a_blocked_issue_say_why_they_wait(self) -> None:
found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "do-epic-human")], (EPIC, "ABC-20", False, ""))
found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "build-epic-human")], (EPIC, "ABC-20", False, ""))
self.assertEqual(found, ["ABC-20 runs", "ABC-21 waits: ABC-20 blocks it", "ABC-22 waits: it is a human's task"])
def test_a_parked_chunk_that_cannot_be_read_is_a_failure(self) -> None:
+1 -1
View File
@@ -1,4 +1,4 @@
"""build-release: headless claude cycles, judged, that interrupt the human only for a decision that is theirs (loop/usage.py's help).
Its packages hold one concern each: chunk/ words a fresh chunk's first prompt and reads the items a worker names, and loop/ runs the cycles. What it shares with do-epic lives in bin/chunk_driver/. build-release's paths live in bin/loop_state/, and its effects in bin/loop_effects/. The cycle itself, its judge, interrupts and routing live in bin/agent_cycle/, which doesn't import this package, so that a second entry point can drive it. routed_item.py, at this level, reads the plan for the item a chunk starts on.
Its packages hold one concern each: chunk/ words a fresh chunk's first prompt and reads the items a worker names, and loop/ runs the cycles. What it shares with build-epic lives in bin/chunk_driver/. build-release's paths live in bin/loop_state/, and its effects in bin/loop_effects/. The cycle itself, its judge, interrupts and routing live in bin/agent_cycle/, which doesn't import this package, so that a second entry point can drive it. routed_item.py, at this level, reads the plan for the item a chunk starts on.
"""
+2 -2
View File
@@ -1,4 +1,4 @@
"""What build-release alone says to its worker: the first prompt of a chunk, with what chunk-preflight found. The resumed prompt and the rung sentences are chunk_driver.prompts', which do-epic's cycles use too."""
"""What build-release alone says to its worker: the first prompt of a chunk, with what chunk-preflight found. The resumed prompt and the rung sentences are chunk_driver.prompts', which build-epic's cycles use too."""
import functools
from chunk_driver.drivers import BUILD_RELEASE
@@ -7,7 +7,7 @@ from model_routing.ladder import ProjectRung
from chunk_driver.prompts import READING_RULE, rung_sentences, worker_prompts
from model_routing.route import Route
# build-release's name as its workers, its judge and the human read it. A function below that takes a driver words a sentence for any entry point, such as do-epic.
# build-release's name as its workers, its judge and the human read it. A function below that takes a driver words a sentence for any entry point, such as build-epic.
DRIVER = BUILD_RELEASE
# chunk_items reads the latest such line; three fresh readers picked the label (docs/decisions.md → `routing: build-release reads the items a chunk takes`).
NAME_THE_ITEMS = f"Name every plan item this chunk takes on one line, as in `{CHUNK_ITEMS} 297 (L 3, E + I 5), 298 (L 3, E + I 7)`, and write the whole line again whenever the set changes."
+2 -2
View File
@@ -136,11 +136,11 @@ def start_chunks(loop_run: LoopRun, leaving: bool, paths: Paths, env: typing.Map
def refusal(session: str, windows: list[tmux.Listed], root: str, run: tmux.Tmux) -> Failure | None:
"""Why no chunk of the checkout root may start in session, whose windows are windows: another checkout's chunks run in the session, or do-epic runs chunks in root."""
"""Why no chunk of the checkout root may start in session, whose windows are windows: another checkout's chunks run in the session, or build-epic runs chunks in root."""
if windows and (owned := tmux.owner(session, run)) != root:
return Failure(f"the tmux session {session} runs the chunks of {owned or 'another checkout'}, whose key maps to the same session name; rename one of the two checkouts' folders")
if theirs := epic_chunks(root, run):
return Failure(f"do-epic runs chunks in {root}: {', '.join(f'{placed.window.name} of {placed.session}' for placed in theirs)}; build-release doesn't start a chunk there until those chunks finish")
return Failure(f"build-epic runs chunks in {root}: {', '.join(f'{placed.window.name} of {placed.session}' for placed in theirs)}; build-release doesn't start a chunk there until those chunks finish")
return None
+2 -2
View File
@@ -181,9 +181,9 @@ class StartChunks(unittest.TestCase):
self.assertEqual(self.starts(fake), [])
self.assertIn(["show-options", "-qv", "-t", f"={self.session}:", "@loop-root"], fake.tmux_calls)
def test_refuses_a_checkout_do_epic_runs_chunks_in(self):
def test_refuses_a_checkout_build_epic_runs_chunks_in(self):
fake = FakeEffects(windows=f"epic-ABC-12\tABC-34 ?\t0\t@4\t{self.root}\nepic-ABC-12\tABC-35\t0\t@5\t/c/other\nepic-ABC-12\tABC-36\t1\t@6\t{self.root}\nloop-x\titem-1\t0\t@7\t{self.root}\n")
self.assertEqual(self.start(fake), Failure(f"do-epic runs chunks in {self.root}: ABC-34 of epic-ABC-12; build-release doesn't start a chunk there until those chunks finish"))
self.assertEqual(self.start(fake), Failure(f"build-epic runs chunks in {self.root}: ABC-34 of epic-ABC-12; build-release doesn't start a chunk there until those chunks finish"))
self.assertEqual(self.starts(fake), [])
def test_leaves_out_the_items_a_running_chunk_names_on_its_chunk_items_line(self):
+1 -1
View File
@@ -1,4 +1,4 @@
"""What the entry points that drive chunks share: build-release and do-epic.
"""What the entry points that drive chunks share: build-release and build-epic.
Each runs a chunk as cycles of bin/agent_cycle/. cycle_start.py starts a cycle and chunk_run.py closes it, on the Loop this_loop.py holds, once claims.py has claimed the checkout. prompts.py words what every worker is told, project/ reads a checkout's premises, records and saved models, and drivers.py names the entry points. No module here imports an entry point's package, and bin/repo_checks/test_package_cycles.py fails on such an import.
"""
+1 -1
View File
@@ -31,7 +31,7 @@ class Run(typing.Protocol):
@dataclasses.dataclass(frozen=True)
class ChunkRun:
"""The run of one chunk, for an entry point that never hands it to another process, such as do-epic."""
"""The run of one chunk, for an entry point that never hands it to another process, such as build-epic."""
cycle_number: int = 0
# The evidence of the latest unfinished verdict; empty before the chunk's first one, and once it finishes.
unfinished_evidence: str = ""
+5 -5
View File
@@ -1,4 +1,4 @@
"""How entry points claim a checkout before they start a chunk in it, so that two never start the same chunk and do-epic never starts one where build-release runs.
"""How entry points claim a checkout before they start a chunk in it, so that two never start the same chunk and build-epic never starts one where build-release runs.
An entry point holds `starting` on `project_lock` while it lists the windows of the checkout's chunks and starts new ones. Where the lock cannot be taken, `starting` yields a Failure, and the entry point doesn't start any chunk. It starts each chunk in a tmux window with CHUNK_FLAG, and hands that window the variables `handed` picks.
"""
@@ -12,9 +12,9 @@ from loop_state.paths import Paths, XDG_CONFIG_HOME, XDG_STATE_HOME
from transcript_archive.project_key import project_key
from agent_cycle import tmux
# The file an entry point keeps locked with flock while it lists the windows of a project's chunks and starts new ones. Two loops whose chunks finish together then don't start a chunk twice, and do-epic, which holds the same lock, never starts a chunk in a checkout while build-release does.
# The file an entry point keeps locked with flock while it lists the windows of a project's chunks and starts new ones. Two loops whose chunks finish together then don't start a chunk twice, and build-epic, which holds the same lock, never starts a chunk in a checkout while build-release does.
LOCK = "starting"
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for build-release and `--chunk ABC-34 ABC-12` for do-epic. Nobody types it, so no panel picked it.
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for build-release and `--chunk ABC-34 ABC-12` for build-epic. Nobody types it, so no panel picked it.
CHUNK_FLAG = "--chunk"
# The prefix of the variables both entry points read.
OWN = "BUILD_RELEASE_"
@@ -29,7 +29,7 @@ def handed(env: typing.Mapping[str, str]) -> dict[str, str]:
@contextlib.contextmanager
def starting(folder: pathlib.Path) -> typing.Iterator[Failure | None]:
"""Holds the LOCK in folder: project_lock's for a project, or do-epic's for an epic. It yields a Failure, and doesn't hold any lock, where the file cannot be opened or locked."""
"""Holds the LOCK in folder: project_lock's for a project, or build-epic's for an epic. It yields a Failure, and doesn't hold any lock, where the file cannot be opened or locked."""
with locked(folder / LOCK) as failure:
yield failure
@@ -75,5 +75,5 @@ def loop_chunks(root: str, home: pathlib.Path, run: tmux.Tmux) -> list[tmux.List
def epic_chunks(root: str, run: tmux.Tmux) -> list[tmux.Placed]:
"""The windows of do-epic's sessions whose chunks run in the checkout root. A parked chunk doesn't run."""
"""The windows of build-epic's sessions whose chunks run in the checkout root. A parked chunk doesn't run."""
return [placed for placed in tmux.everywhere(run) if placed.session.startswith(f"{tmux.EPIC}-") and placed.root == root and not placed.window.dead and not placed.window.parked]
+1 -1
View File
@@ -1,3 +1,3 @@
"""The entry points that drive chunks, each by its name as its workers, its judge and the human read it. A prompt function that takes a driver takes one of these."""
BUILD_RELEASE = "build-release"
DO_EPIC = "do-epic"
BUILD_EPIC = "build-epic"
+1 -1
View File
@@ -72,7 +72,7 @@ def save_model(project_key: str, chosen: str, paths: Paths, replace: typing.Call
def read_models_file(saved: pathlib.Path) -> dict[str, str] | Failure:
"""Each project's model, as the models file at saved maps them; none where there is no such file. The entry points, build-release and do-epic, and the replay tools read it."""
"""Each project's model, as the models file at saved maps them; none where there is no such file. The entry points, build-release and build-epic, and the replay tools read it."""
try:
with open(saved, encoding="utf-8") as handle:
models = json.load(handle)
+1 -1
View File
@@ -154,5 +154,5 @@ class RecordNames(typing.NamedTuple):
def worker_prompts(driver: str, fresh: typing.Callable[[str, str, Route, ProjectRung | None, str], str], naming: str, names: RecordNames = RecordNames()) -> WorkerPrompts:
"""The prompts of an entry point's cycles: its own fresh prompt, and the resumed prompt and rung sentences every entry point shares, each naming driver. resumed says what naming is. names is build-release's unless the entry point keeps records elsewhere, as do-epic does."""
"""The prompts of an entry point's cycles: its own fresh prompt, and the resumed prompt and rung sentences every entry point shares, each naming driver. resumed says what naming is. names is build-release's unless the entry point keeps records elsewhere, as build-epic does."""
return WorkerPrompts(driver, fresh, functools.partial(resumed, driver, naming), functools.partial(rungs_held, driver), *names)
+1 -1
View File
@@ -10,7 +10,7 @@ from agent_cycle.tmux import Window
@dataclasses.dataclass(frozen=True)
class Loop:
"""What stays the same while an entry point drives one chunk in one process. build-release builds it once per process, so a reload builds it afresh; do-epic builds one per chunk."""
"""What stays the same while an entry point drives one chunk in one process. build-release builds it once per process, so a reload builds it afresh; build-epic builds one per chunk."""
# The checkout the loop runs in. build-release's LoopRun.root names it too, since a reload hands it on there.
root: str
# The worker's session.
+4 -4
View File
@@ -8,7 +8,7 @@ from forge.commands import Forge, Run
# A human answers in hours, so merge polls once a minute and gives up after 90 minutes. That leaves half an hour for the queue and the checks inside the 2 hours a background command may run; a run that needs more is killed before the give-up message prints, and its next run goes on from what it pushed.
POLL_SECONDS = 60
WAIT_SECONDS = 90 * 60
# The environment variable do-epic sets to 1 for its chunks' workers. With it, merge doesn't wait for an approval: do-epic parks the chunk and polls the forge itself, so the chunk holds no running slot meanwhile (docs/decisions.md → `do-epic: drives one Jira epic …`, "Long gates").
# The environment variable build-epic sets to 1 for its chunks' workers. With it, merge doesn't wait for an approval: build-epic parks the chunk and polls the forge itself, so the chunk holds no running slot meanwhile (docs/decisions.md → `build-epic: drives one Jira epic …`, "Long gates").
PARKS = "CHUNK_PR_PARKS"
@@ -50,13 +50,13 @@ def approved(number: str, run: Run, sleep: typing.Callable[[float], None]) -> Fa
def left_to_park(number: str, run: Run) -> Failure:
"""Why a merge under PARKS ends at once where pull request number passed its checks and awaits an approval, in place of waiting as `approved` does: a reviewer's comment waits for an answer, which the worker gives first, or else do-epic parks the chunk, so the worker ends its run."""
return unanswered(number, run) or Failure(f"pull request {number} passed its checks and awaits an approval; end your run now, since do-epic parks the chunk and resumes this session once it is approved or a reviewer comments")
"""Why a merge under PARKS ends at once where pull request number passed its checks and awaits an approval, in place of waiting as `approved` does: a reviewer's comment waits for an answer, which the worker gives first, or else build-epic parks the chunk, so the worker ends its run."""
return unanswered(number, run) or Failure(f"pull request {number} passed its checks and awaits an approval; end your run now, since build-epic parks the chunk and resumes this session once it is approved or a reviewer comments")
def left_to_a_person(number: str, parks: bool) -> str:
"""What merge prints where the project's config leaves the merge of pull request number to a person (`merge = "human"`): what the worker does now, which under PARKS is to end its run, as in `left_to_park`."""
now = "end your run now, since do-epic parks the chunk and resumes this session once it is merged or a reviewer comments." if parks else "leave the merge to them, and report the chunk as ready to merge. Once it is merged, run chunk-pr clean in this worktree."
now = "end your run now, since build-epic parks the chunk and resumes this session once it is merged or a reviewer comments." if parks else "leave the merge to them, and report the chunk as ready to merge. Once it is merged, run chunk-pr clean in this worktree."
return f"Marked pull request #{number} ready. It passed its checks and awaits a person's merge, since the project's config sets `merge = \"human\"`: {now}"
+3 -3
View File
@@ -12,7 +12,7 @@ Run it in the chunk's worktree, on the chunk's branch. ready and merge act on th
pull request only while its head is the commit checked out, so push before you run them.
Where the project's config sets `epic-branch` (`project-config --help`), a chunk's pull request
goes into its epic's working branch, which chunk-preflight or do-epic recorded for the chunk's
goes into its epic's working branch, which chunk-preflight or build-epic recorded for the chunk's
branch as it started or continued the chunk. There, each step below reads "origin's default
branch" as that branch, with these differences:
- merge merges the pull request itself, whatever `merge` and `wait-for-approval` say: those
@@ -66,8 +66,8 @@ merge merges the pull request in its turn: the chunks of one project on this
Where the project's config sets `wait-for-approval = true` (`project-config --help`), it
merges only once GitHub reports the pull request approved as its branch protection
requires. It waits for that outside its turn, so other chunks merge meanwhile, and takes
a new turn once approved. In a chunk do-epic runs, which sets CHUNK_PR_PARKS=1, it
fails at once instead of waiting: do-epic parks the chunk until the approval comes.
a new turn once approved. In a chunk build-epic runs, which sets CHUNK_PR_PARKS=1, it
fails at once instead of waiting: build-epic parks the chunk until the approval comes.
Where the project's config sets `merge = "human"` (`project-config --help`), it does
steps 1 to 4, marks the pull request ready in place of step 5, and prints that the pull
request awaits a person's merge, exit 0. A plan or changelog in the checkout that step 2
+1 -1
View File
@@ -466,7 +466,7 @@ class Merge(unittest.TestCase):
def test_a_merge_that_parks_returns_at_once_while_the_branch_protection_still_wants_a_review(self):
checkout = self.requiring_approval(GITHUB, "REVIEW_REQUIRED")
failed = merged(checkout, checkout.config, self.fail, parks=True)
self.assertEqual(failed.reason, "pull request 12 passed its checks and awaits an approval; end your run now, since do-epic parks the chunk and resumes this session once it is approved or a reviewer comments")
self.assertEqual(failed.reason, "pull request 12 passed its checks and awaits an approval; end your run now, since build-epic parks the chunk and resumes this session once it is approved or a reviewer comments")
self.assertEqual(checkout.ran.count(GH_DECISION), 1)
self.assertEqual(step(["merge"], self.requiring_approval(GITHUB, "REVIEW_REQUIRED"), checkout.config, parks=True), failed)
+1 -1
View File
@@ -1,4 +1,4 @@
"""A pull request's review state, read once from its forge: the review decision, whether it is a draft, whether the worker answered the changes a reviewer requested, and the review threads that wait for an answer. chunk-pr and do-epic decide on what this reads, and run no review query of their own."""
"""A pull request's review state, read once from its forge: the review decision, whether it is a draft, whether the worker answered the changes a reviewer requested, and the review threads that wait for an answer. chunk-pr and build-epic decide on what this reads, and run no review query of their own."""
import dataclasses
import json
+1 -1
View File
@@ -33,7 +33,7 @@ def with_release_tools(env: Mapping[str, str]) -> dict[str, str]:
def config_folder(env: Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
"""The config folder, which a person writes and backs up: one folder per project, do-epic's, and the model of each project."""
"""The config folder, which a person writes and backs up: one folder per project, build-epic's, and the model of each project."""
# The models file is here though the tools write it: it holds a person's choice per project, and is backed up with the configs.
return xdg_folder(env.get(XDG_CONFIG_HOME), home / CONFIG_HOME) / SETUP
+1 -1
View File
@@ -12,7 +12,7 @@ DATED = re.compile(rf"({VERSION}) - " + "-".join(f"[0-9]{{{digits}}}" for digits
TAG = re.compile(rf"v({VERSION})")
# The title of CHANGELOG.md's section for news not yet released: Unreleased, or a title that says unreleased, such as `0.6.0 (unreleased)`, as a project's own changelog may head it; and its ## heading.
UNRELEASED_TITLE = r"(?i:.*unreleased.*)"
# What opens the title of a release review's first commit, before the release it reviews, or the epic's key in do-epic's finishing chunk. release_standing counts a review by it.
# What opens the title of a release review's first commit, before the release it reviews, or the epic's key in build-epic's finishing chunk. release_standing counts a review by it.
REVIEW_TITLE = "Release review of "
UNRELEASED_HEADING = re.compile(rf"^## {UNRELEASED_TITLE}$", re.M)
+3 -3
View File
@@ -6,8 +6,8 @@ Run inside a checkout, or a worktree of one. It finds the config that names the
~/.config/build-release/<key>/config.toml, and prints each setting and its absolute path, as in
`plan: /home/me/code/acme/todo.md`. Given a setting, it prints only that setting's path.
`~/.config/build-release/do-epic/` holds do-epic's machine-wide settings, not a project's. It needs no `checkout`,
and project-config doesn't read anything from it, so no project may use `do-epic` as its key.
`~/.config/build-release/build-epic/` holds build-epic's machine-wide settings, not a project's. It needs no `checkout`,
and project-config doesn't read anything from it, so no project may use `build-epic` as its key.
The config is TOML. `checkout` names the project's main checkout, and every setting in the example below is a path:
"checkout:<path>" inside the checkout, "folder:<path>" inside the config's own folder, or one that
@@ -111,7 +111,7 @@ prints chunk or human; the full listing shows the setting only where it is human
`epic-branch` is an optional setting: a template that names an epic's working branch, with {epic} for the
epic's key, such as `epic-branch = "{epic}"` or "epic/{epic}". The epic is the Jira epic `plan` names, or
under do-epic the epic it drives. Each chunk then
under build-epic the epic it drives. Each chunk then
branches off that branch, and `chunk-pr` opens its pull request into it and merges it there without a
person, whatever `merge` and `wait-for-approval` say: those guard the default branch. `chunk-preflight`
makes the branch on origin off the default branch, or merges the default branch into it, and stops where
+10 -7
View File
@@ -18,8 +18,8 @@ from project_config import templates
from plan.ranking import variables
CONFIG = "config.toml"
# The key of do-epic's machine-wide settings: the folder's config.toml has no `checkout`, so no project may use the key.
DO_EPIC = "do-epic"
# The key of build-epic's machine-wide settings: the folder's config.toml has no `checkout`, so no project may use the key.
BUILD_EPIC = "build-epic"
# A Jira Cloud or Confluence Cloud site's address: only https, so the credentials are never sent in the clear.
SITE = r"https://[A-Za-z0-9.-]+(?::[0-9]+)?"
# Every path a project sets, by its role. Three readers, seated as the human who writes the config, picked the spelling from four candidates. They picked role names over file names, which a client's project doesn't share.
@@ -70,7 +70,7 @@ JIRA_FINISH = (JIRA_FINISH_TRANSITION, JIRA_FINISH_STATUS)
JIRA_SCORE_FORMULA = "jira-score-formula"
JIRA_SCORE_BAR = "jira-score-bar"
JIRA_SCORE = (JIRA_SCORE_FORMULA, JIRA_SCORE_BAR)
# The issue types that `todo-item add` files an item as and do-epic files a finding as, and do-epic files a release review as; only do-epic's config reads the review type.
# The issue types that `todo-item add` files an item as and build-epic files a finding as, and build-epic files a release review as; only build-epic's config reads the review type.
JIRA_FINDING_TYPE = "jira-finding-type"
JIRA_REVIEW_TYPE = "jira-review-type"
# Jira Software's project templates ship Task, but a project such as TW may lack it.
@@ -438,13 +438,16 @@ def by_name(name: str, home: pathlib.Path, env: Mapping[str, str]) -> ProjectCon
def configs(home: pathlib.Path, env: Mapping[str, str]) -> list[pathlib.Path]:
"""Every project's config file in the config folder, in key order. do-epic's machine-wide config is not a project's."""
return sorted(file for file in config_folder(env, home).glob(f"*/{CONFIG}") if file.parent.name != DO_EPIC)
"""Every project's config file in the config folder, in key order. build-epic's machine-wide config is not a project's.
A `do-epic/` folder left from before the rename is read as a project's config and fails, naming its file. The changelog says to move it, and nothing forwards from the old name (docs/decisions.md → `names`).
"""
return sorted(file for file in config_folder(env, home).glob(f"*/{CONFIG}") if file.parent.name != BUILD_EPIC)
def env_files(home: pathlib.Path, env: Mapping[str, str]) -> list[pathlib.Path]:
"""Every config's env-file, do-epic's included. Each is read without the checks load makes, so a config that fails them still keeps its credentials guarded. A config that can't be read doesn't name one."""
values = [parsed(file) for file in (*configs(home, env), config_folder(env, home) / DO_EPIC / CONFIG)]
"""Every config's env-file, build-epic's included. Each is read without the checks load makes, so a config that fails them still keeps its credentials guarded. A config that can't be read doesn't name one."""
values = [parsed(file) for file in (*configs(home, env), config_folder(env, home) / BUILD_EPIC / CONFIG)]
return [path for found in values if not isinstance(found, Failure) and (path := anywhere(found.get(ENV_FILE), home))]
+7 -7
View File
@@ -54,8 +54,8 @@ class LoadTest(ConfigCase):
self.assertEqual(found.paths["standards"], self.home / ".claude" / "skills" / "larv-review" / "standards")
self.assertEqual(tuple(found.paths), SETTINGS)
def test_the_do_epic_folder_is_no_projects_config_so_it_needs_no_checkout(self) -> None:
self.write("do-epic", 'jira-url = "https://acme.atlassian.net"\n')
def test_the_build_epic_folder_is_no_projects_config_so_it_needs_no_checkout(self) -> None:
self.write("build-epic", 'jira-url = "https://acme.atlassian.net"\n')
self.write("acme", CLIENT)
found = load(self.checkout, self.checkout, self.home, {})
assert isinstance(found, ProjectConfig), found
@@ -639,8 +639,8 @@ class HeldTest(ConfigCase):
(elsewhere / "config.toml").write_text(CLIENT, encoding="utf-8")
self.assertIsNone(held(elsewhere, self.home, {}), "a config.toml outside ~/.config/build-release/")
def test_the_do_epic_folder_holds_no_projects_config(self) -> None:
folder = self.write("do-epic", CLIENT)
def test_the_build_epic_folder_holds_no_projects_config(self) -> None:
folder = self.write("build-epic", CLIENT)
self.assertIsNone(held(folder, self.home, {}))
def test_a_configs_folder_reached_through_a_symlink_holds_its_config(self) -> None:
@@ -663,7 +663,7 @@ class ByNameTest(ConfigCase):
self.write("acme", CLIENT)
self.assertIsNone(by_name("billing", self.home, {}), "a part of a name is not the name")
self.assertIsNone(by_name("acme", self.home, {}), "a config's key is not a repo's name")
self.assertIsNone(by_name("do-epic", self.home, {}))
self.assertIsNone(by_name("build-epic", self.home, {}))
def test_fails_where_two_configs_name_a_checkout_of_that_name(self) -> None:
self.write("acme", CLIENT)
@@ -686,8 +686,8 @@ class EnvFilesTest(ConfigCase):
self.write("none", CLIENT)
self.assertEqual(env_files(self.home, {}), [self.home / "acme.env", pathlib.Path("/srv/other.env")])
def test_lists_do_epics_env_file_though_its_config_names_no_checkout(self) -> None:
self.write("do-epic", 'env-file = "~/jira.env"\n')
def test_lists_build_epics_env_file_though_its_config_names_no_checkout(self) -> None:
self.write("build-epic", 'env-file = "~/jira.env"\n')
self.assertEqual(env_files(self.home, {}), [self.home / "jira.env"])
+1 -1
View File
@@ -136,7 +136,7 @@ def heading_commit(release: Release, ref: str, changelog: stores.RecordStore, cw
def reviewed_releases(tag: str | None, ref: str, cwd: str, titles: templates.Titles, after: Release | None = None, run: Git = git) -> frozenset[Release] | Failure:
"""LastCut.reviews: each release that a commit on ref names in its title, as a release review opens, `Release review of <release>`. The commits read are those after tag, or all of them where tag is None. A title that names no version, such as an epic's `Release review of ABC-12` (do_epic/finish.py), reviews no release.
"""LastCut.reviews: each release that a commit on ref names in its title, as a release review opens, `Release review of <release>`. The commits read are those after tag, or all of them where tag is None. A title that names no version, such as an epic's `Release review of ABC-12` (build_epic/finish.py), reviews no release.
titles holds the project's title templates, and each commit title is read as the summary they give. after is the version a branch with no tag counts as cut, or None. A release counts only where it is later than after, or than tag's version where after is None. A patch release cut beside the default branch and merged back leaves on ref, after its tag, the review of that patch, which reviews no later release. pick_from needs that where the next release has no name.
"""
+1 -1
View File
@@ -62,7 +62,7 @@ def part_cycles(bin_folder: pathlib.Path) -> dict[str, list[str]]:
# The entry points that drive chunks. What two of them need lives in bin/chunk_driver/, so no other package imports one, its tests included.
DRIVERS = ("do_epic", "build_release")
DRIVERS = ("build_epic", "build_release")
def driver_imports(bin_folder: pathlib.Path, drivers: tuple[str, ...]) -> list[str]:
+1 -1
View File
@@ -1,6 +1,6 @@
"""Whether a Read or a Grep reads a credentials file, or a Bash command names it or searches a folder holding it, for the `env-file-read` rule.
The files are `~/.claude/.env` and every config's `env-file`, do-epic's included, not only the calling project's: a worker in one client's project must not read another client's credentials either, and listing every config's file needs no git call, as finding the calling project's would.
The files are `~/.claude/.env` and every config's `env-file`, build-epic's included, not only the calling project's: a worker in one client's project must not read another client's credentials either, and listing every config's file needs no git call, as finding the calling project's would.
A Bash command names one where its text spells the file's path, or one of its words, a redirect's target included, leads to the file from the directory `cd` left the command in. Whether the command reads the file is not judged, so one that only mentions the path is refused too.
It searches a folder holding one where `folder_search.searches` finds that an `ag`, `grep -r` or `rg` reaches the file.
This guards against an agent reading the file in passing, not against one that hides the path, such as behind a glob, a variable of its own, `xargs` or `find -exec`."""
+32 -32
View File
@@ -4,7 +4,7 @@ Each project principle states one rule that the decisions below apply; their ent
1. **Cut cost only where a measurement of archived chunks shows quality holds.** Chunk bundling, the round cap, which fixes rerun a pass, a reviewer of its own for each pass, the review a branch changing only Markdown no agent follows gets, the passes kept for the release review, review opt-outs, the security pass, compaction and the routing ladder all apply it.
2. **A measurement files or ranks work, and never blocks a merge.** The comprehension floor and check, and a reading-cost rise, apply it. A merge waits on a scoring run the plan calls for only until the run is recorded, whatever it scores.
3. **Each file has one writer.** `~/.config/build-release/models.json` is written only by `save_model`, which the entry points, build-release and do-epic, both call. `~/.claude.json` is Claude Code's, and `~/.claude` moves only through `deploy-release`. The exception is `~/.claude/settings.json`, which Claude Code writes from any session. Git's clean filter `bin/settings_filter.py` keeps each machine's model and Claude Code's key order out of every commit, and `README.md` → "Update" carries its other changes into this repo.
3. **Each file has one writer.** `~/.config/build-release/models.json` is written only by `save_model`, which the entry points, build-release and build-epic, both call. `~/.claude.json` is Claude Code's, and `~/.claude` moves only through `deploy-release`. The exception is `~/.claude/settings.json`, which Claude Code writes from any session. Git's clean filter `bin/settings_filter.py` keeps each machine's model and Claude Code's key order out of every commit, and `README.md` → "Update" carries its other changes into this repo.
4. **A rule a program can check is enforced by a program, and reviewers rule on the rest.** rule-hook and its overrides, `docker-run-memory`, the refused writes of reviewers under `agents/`, and CI with `main`'s branch protection apply it.
5. **A chunk can't vouch for itself.** What a chunk writes is approved by a review pass, by the human, or by a precedent the repo held before the chunk began. So an unanswered ask leaves the PR unmerged, the human approves the premises chunk and runs `deploy-release --cut`, and the judge holds a chunk open while an answer the human typed isn't recorded anywhere.
6. **An unattended run never waits on a prompt, and a lasting failure stops it.** Every claude build-release starts bypasses permissions inside its sandbox, each claude it opens on a terminal has `CLAUDE_CODE_SANDBOXED` set, and interactive sessions bypass permissions with the dangerous-mode prompt skipped. A failed archive stops the loop, while a `claude` that cannot start, as during an update, is retried.
@@ -17,15 +17,15 @@ Each project principle states one rule that the decisions below apply; their ent
- bin/: the tools run on the host's Python, with no container, and so do their tests outside CI
- bin/: the tools send no OTLP traces, logs or metrics, and build-release's archive holds the trace of each cycle
- bin/: the tools support only the latest stable Python, and the tests, written in plain unittest, run on it in four pytest-xdist workers
- build-epic: drives one Jira epic whose items span repos, or have none, ranked by the epic's goals, then code health, then each repo's goals, and closes the epic only once the human confirms every goal
- build-release: each verdict records the claude-config release and commit that ran it, the raw tokens each thread spent by model and kind since the previous outcome that recorded a spend, and the human's typed answer the judge quotes as reversing a choice the worker took on its own recommendation
- build-release: each chunk runs in its own tmux window, of one tmux session per project, up to `parallel-chunks` at once, and needs tmux 3.2; its claude session is named after its window, its id derived from that name; a chunk's commit in the config's folder takes only the file it changed
- chunk-pr: the chunks of a project merge one at a time on a machine, each finishing its plan items in its turn, and a pull request that waits for an approval leaves the queue while it waits
- Claude Code in a home of its own: a `CLAUDE_CONFIG_DIR` home loads `CLAUDE.md`, rules, agents, skills, hooks and plugins, and `CLAUDE_CODE_OAUTH_TOKEN` signs in there, but never under `--bare`
- deploy: this repo keeps no `AGENTS.md`, since `~/.claude` is its checkout; its principles and decision titles head `docs/decisions.md`, its working rules follow them there, and its `.claude/settings.json` excludes every `.claude/CLAUDE.md`, so a session in the clone loads only the clone's `CLAUDE.md`
- do-epic: drives one Jira epic whose items span repos, or have none, ranked by the epic's goals, then code health, then each repo's goals, and closes the epic only once the human confirms every goal
- epic-branch: an epic's chunks branch off and merge into a working branch its project's config names, without a person, and a person merges that branch into the default branch in one pull request
- machine load: a heavy command waits for one of the machine's heavy slots, one for every 4 CPUs, which every session shares, and build-release starts a worker only while at least a quarter of the machine's memory is available
- names: the plan calls the project and its repo `dev-factory` and do-epic `build-epic`, as it called loop-claude `build-release` until the rename shipped, and the code keeps today's other names until their planned items ship
- names: the plan calls the project and its repo `dev-factory`, its commands are `build-release` and `build-epic` with no old name kept as an alias, and the code keeps its other names until their planned items ship
- principles: about seven things per level, four or five where they act on each other, more where a reader finds them by name; crossing a limit asks for a grouping or a recorded reason
- project config: a record may name a Confluence Cloud page as `confluence:` and its address, the loop reads and writes it as markdown, and a write never overwrites a save made since the loop's read
- project config: a tool that reads a file's commits says where it does not support that file, and the work goes on
@@ -160,37 +160,18 @@ Valid while `~/.claude` is a checkout of this repo.
2026-11-27, lilleman, the release review of 0.16.0. A release review on `main` counts only for the release its title names, which must be exactly the next release, as `chunk-preflight --help` states. So the patch's own review, which the merge leaves on `main` after the tag, doesn't review any later release, and neither does a review opened under a release name todo.md has since changed. Where todo.md names no next release, a review of any release after the last cut counts.
## do-epic: drives one Jira epic whose items span repos, or have none, ranked by the epic's goals, then code health, then each repo's goals, and closes the epic only once the human confirms every goal
2026-11-18, lilleman's answers to claude's questions while planning release 0.12.0. Serves goal 1, so development scales past one repo, and goal 1.6, since the epic stays in the client's Jira. Valid while Jira is the only backend; another backend goes behind the same interface.
- **What it is.** `do-epic <EPIC-KEY>` is a sibling of build-release, built on the same cycle, judge, interrupt, tmux and routing packages, not a copy (goal 1.3). It runs one tmux session per epic.
- **Machine settings.** `~/.config/build-release/do-epic/` holds `config.toml` (the Jira site, env-file, the folder repos are cloned into, the default language, and the model for a no-repo item) and `repo-rule.md`. `repo-rule.md` is a prose instruction that says how to tell an item's repo. It is the same for every epic on the machine. On the first machine, an item's label that equals a repo's name names that repo. A `[label-repos]` table in `config.toml` maps a team's own label to a repo, so do-epic reads that label as a pick without a claude call.
- **The epic's description is its record.** It holds `## Goals`, `## Audience`, `## Scoring` (formula and bar), `## Decisions` and a language line. do-epic writes all of it, but it changes Goals or Audience only after the human approves in an interrupt.
- **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. An item a person filed a sub-task under counts as split already: do-epic works it through the team's own sub-tasks and doesn't file any of its own. It plans no such sub-task, so one without a label waits for the team's. It moves such an item itself (lilleman's call of 2026-11-20), since every issue the item blocks waits until the item moves, and the team's automation sees a pull request only on the sub-task that carries it. Once every sub-task is done, the item moves to done. Once every sub-task has landed, each done or in one of `jira-unblocking-statuses`, the item moves by the transition `jira-sub-tasks-landed-transition` names, which must lead to one of those statuses. A move that is not made is said, and the run goes on.
- **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 the issues it filed in Jira's backlog to match. A person's issue keeps its rank there: goal 1.6 has the loop plug in without changing what the owners keep. On 2026-11-20 the human chose that the order the issues start in is do-epic's, while the board's order stays the team's: do-epic starts the open issues by score. Where two or more may start, it scores each of them that holds no scores, a person's included but not a human's task, and tells the team the scores in a comment. It never overwrites scores an issue holds. An issue that cannot be scored starts after those that can, in the backlog's order; where no order of score can be made at all, such as without the epic's formula, every issue starts in the backlog's order and do-epic says why.
- **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 build-release 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 build-release sees do-epic's chunks in a checkout. do-epic and build-release 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/build-release/do-epic/<EPIC-KEY>/`. do-epic archives its cycles under `~/.local/state/build-release/do-epic-transcripts/`, not in build-release's archive, whose readers parse build-release'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. In a repo whose config sets `merge = "human"`, the merge itself is a gate: `chunk-pr merge` leaves the pull request ready, the chunk parks on `your merge` once nothing else holds the pull request, and it gets its gate read again when the forge no longer reports the pull request open, so that its worktree is removed and the chunk finishes. It resumes too once the pull request conflicts with its base branch, or is behind it where GitHub's branch protection requires an up-to-date branch, so the person finds a pull request they can merge. The worker then runs `chunk-pr merge` again, which levels the branch, waits for the checks and leaves the pull request ready. A chunk whose cycle ends on such a pull request is not handed on: its worker is told after each cycle until the pull request merges into its base. While GitHub still computes whether the pull request merges, the chunk stays parked until the next read. Gitea also reports a pull request as not mergeable for the seconds it checks for conflicts. A read in those seconds resumes the chunk for a run that doesn't change anything, which costs less than reading every gate twice to tell the two apart. The judge may rule such a chunk finished while its pull request is open, since its worker ends each run there. So do-epic reads a gate it could not read again before it hands the chunk on, and does the removal itself where it can. For a chunk whose pull request is no longer open, do-epic runs `chunk-pr clean` in the chunk's worktree. That command acts only on a pull request the forge reports merged at the worktree's head, and refuses a worktree with uncommitted or untracked files. Where it removed the worktree, the chunk finishes without a worker and, where it was parked, without a running slot, even if the command then failed on the main checkout, whose reason do-epic says. Where it left the worktree, as for a pull request closed unmerged, do-epic tells the worker once to remove it, and a parked chunk waits for a slot as for any other news.
- **Human tasks.** do-epic leaves a human task's issue as the team filed it. The task gets a window of its own while it is open, no issue blocks it, and it blocks another open issue. The window DMs the human once, through the notifier of the first repo whose project config names one (the repos of the issues it holds up come first, then those of the epic's other issues; where none does, the window says so), shows as parked (`awaits a human's task`) so that it doesn't take a running slot, and polls the epic every minute until the task no longer holds up an open issue. Then the issues it held up may start. A window that starts again, as after a reboot, DMs again.
- **Findings.** A finding about the epic's goals is filed in the epic. A finding about a repo's goals follows that repo's rules. Where unsure which, do-epic asks. A set of new items toward an epic goal needs the human's approval before work starts; a finding filed during a chunk doesn't.
- **Finishing.** When the epic holds no open item: release-review passes on each repo the epic changed, then the items they file, then the human confirms each achieve goal and that no maintain goal has a defect. For a goal that isn't met, do-epic proposes items for approval. Then a summary comment on the epic, and closing the epic in Jira, as the very last step.
- **Tests.** Black-box tests run against a fake Jira backend. An opt-in e2e test runs as its own command against a sandbox epic on a real Jira site.
## epic-branch: an epic's chunks branch off and merge into a working branch its project's config names, without a person, and a person merges that branch into the default branch in one pull request
2026-11-20, lilleman's call. Serves goals 1 and 1.6: a team may rule that only a person merges into its default branch. Such a team was asked to merge once per chunk, and reviewed an epic as many small pull requests. With `epic-branch` set, the loop asks once per epic, and the team keeps its rule. Valid while that rule covers only a team's default and protected branches.
- **The setting.** `epic-branch` in a project's config is a template with `{epic}` for the epic's key, such as `"{epic}"`. Left out, everything works as before. Under chunk-preflight the key is that of the Jira epic `plan` names, so a plan kept in a file has no working branch. Under do-epic it is the key of the epic do-epic drives.
- **The setting.** `epic-branch` in a project's config is a template with `{epic}` for the epic's key, such as `"{epic}"`. Left out, everything works as before. Under chunk-preflight the key is that of the Jira epic `plan` names, so a plan kept in a file has no working branch. Under build-epic it is the key of the epic build-epic drives.
- **A chunk's base is recorded in git.** `git config branch.<chunk's branch>.chunk-base <epic's working branch>`, in the checkout's shared config (`git_repo.CHUNK_BASE`). `git_repo.default_ref` answers `origin/<epic's working branch>` on such a branch, so each tool that measures a chunk against its base reads the chunk's own commits. Deleting the branch removes the record.
- **The branch stays level by a merge commit, made without a checkout.** `epic_branch.levelled` makes the branch on origin off the default branch, or merges the default branch into it with `git merge-tree --write-tree`, which needs git 2.38 or later, and `git commit-tree`, and pushes without force. It asks origin itself whether it has the branch, with `git ls-remote`, since a fetch keeps a checkout's `origin/<branch>` after origin deleted the branch. So a chunk that starts after the epic's branch merged and was deleted gets a fresh branch off the default branch, never the commits the deleted one held. chunk-preflight runs it before it makes a chunk's worktree, do-epic as a chunk's window starts, and `chunk-pr open-epic` before it opens the epic's pull request. `open-epic` refuses where origin has no such branch, since a branch made there would be a stray one. A conflict stops the chunk and asks a person to merge by hand: a resolution picks between two teams' changes, which is theirs to pick.
- **The chunk merges without a person.** `chunk-pr merge` into an epic's working branch ignores `merge = "human"` and `wait-for-approval`, and do-epic parks no such chunk on a person's merge. lilleman's call: the team's rule against merging without a go-ahead covers the default branch and protected branches. The pull request from the epic's working branch into the default branch is opened ready and never merged by the loop. do-epic's finishing chunk opens it with `chunk-pr open-epic`; under build-release the human runs that command.
- **The forge's base must agree with the recorded one.** The record says whether a person merges, and the forge says where the pull request lands, so the two must not differ. `chunk-pr ready` and `merge`, and do-epic's gate, read the pull request's base from the forge (`forge.pulls.other_base`). They fail, naming both branches, where it differs from the recorded base, or from the default branch where the checkout records none. A person then changes the pull request's base on the forge, or the record. chunk-preflight and do-epic record the base for a chunk they continue too, since the setting sends every chunk of the epic into the working branch. So a pull request that was open into the default branch when the setting was turned on fails this check until a person changes its base or merges it. do-epic parks a chunk, and moves its issue, by the base it recorded as the chunk's window started, never by the config alone.
- **The branch stays level by a merge commit, made without a checkout.** `epic_branch.levelled` makes the branch on origin off the default branch, or merges the default branch into it with `git merge-tree --write-tree`, which needs git 2.38 or later, and `git commit-tree`, and pushes without force. It asks origin itself whether it has the branch, with `git ls-remote`, since a fetch keeps a checkout's `origin/<branch>` after origin deleted the branch. So a chunk that starts after the epic's branch merged and was deleted gets a fresh branch off the default branch, never the commits the deleted one held. chunk-preflight runs it before it makes a chunk's worktree, build-epic as a chunk's window starts, and `chunk-pr open-epic` before it opens the epic's pull request. `open-epic` refuses where origin has no such branch, since a branch made there would be a stray one. A conflict stops the chunk and asks a person to merge by hand: a resolution picks between two teams' changes, which is theirs to pick.
- **The chunk merges without a person.** `chunk-pr merge` into an epic's working branch ignores `merge = "human"` and `wait-for-approval`, and build-epic parks no such chunk on a person's merge. lilleman's call: the team's rule against merging without a go-ahead covers the default branch and protected branches. The pull request from the epic's working branch into the default branch is opened ready and never merged by the loop. build-epic's finishing chunk opens it with `chunk-pr open-epic`; under build-release the human runs that command.
- **The forge's base must agree with the recorded one.** The record says whether a person merges, and the forge says where the pull request lands, so the two must not differ. `chunk-pr ready` and `merge`, and build-epic's gate, read the pull request's base from the forge (`forge.pulls.other_base`). They fail, naming both branches, where it differs from the recorded base, or from the default branch where the checkout records none. A person then changes the pull request's base on the forge, or the record. chunk-preflight and build-epic record the base for a chunk they continue too, since the setting sends every chunk of the epic into the working branch. So a pull request that was open into the default branch when the setting was turned on fails this check until a person changes its base or merges it. build-epic parks a chunk, and moves its issue, by the base it recorded as the chunk's window started, never by the config alone.
- **A review is asked for by a comment.** An auto-reviewer may review on its own only pull requests into the default branch. `review-request-comment` holds the comment that asks it, which `chunk-pr ready` and `chunk-pr push` post on a pull request into an epic's working branch. The worker waits for the review as for any auto-reviewer.
- **do-epic moves the issue itself.** A team's automation fires only for pull requests into the default branch. `jira-pull-request-open-status` names the status of an issue whose chunk parks with its pull request open, and `jira-pull-request-merged-status` the one once it has merged. The first move is made as the chunk parks, since that is where do-epic learns of the pull request; one that opens and merges within a single run of the worker skips it. Where the workflow then offers no way straight to the merged status, do-epic moves the issue through the open status first. Each setting names a status, and do-epic takes whichever transition leads there.
- **An issue at the merged status counts as done for the epic's end.** The release reviews and the finishing chunk come before a person merges the epic's working branch, and Jira counts the issues done only after. So `finish.landed` reads such an issue as done, wherever do-epic's config names the status. Without the setting, the finishing waits for Jira as before.
- **build-epic moves the issue itself.** A team's automation fires only for pull requests into the default branch. `jira-pull-request-open-status` names the status of an issue whose chunk parks with its pull request open, and `jira-pull-request-merged-status` the one once it has merged. The first move is made as the chunk parks, since that is where build-epic learns of the pull request; one that opens and merges within a single run of the worker skips it. Where the workflow then offers no way straight to the merged status, build-epic moves the issue through the open status first. Each setting names a status, and build-epic takes whichever transition leads there.
- **An issue at the merged status counts as done for the epic's end.** The release reviews and the finishing chunk come before a person merges the epic's working branch, and Jira counts the issues done only after. So `finish.landed` reads such an issue as done, wherever build-epic's config names the status. Without the setting, the finishing waits for Jira as before.
- **The epic's other repos.** Where a chunk's tests run other repos of the epic, its worker runs each at its branch of the same name where it has one, else at its default branch, and its summary names each repo that ran at the default branch. A team's shared test harness needs an option to pick the branch; that is the team's change.
## larv-review: within a chunk lifting a project towards the comprehension floor, work on the project's lowest-scoring dimension comes first, and the floor doesn't block anything
@@ -201,6 +182,25 @@ Valid while `~/.claude` is a checkout of this repo.
2026-11-08, claude, item 230: the floor item that larv-review files (`skills/larv-review/SKILL.md` → "Floor item") keeps the move by 9 and competes like any item, though its R, likely above 5, makes it ship alone.
## build-epic: drives one Jira epic whose items span repos, or have none, ranked by the epic's goals, then code health, then each repo's goals, and closes the epic only once the human confirms every goal
2026-11-18, lilleman's answers to claude's questions while planning release 0.12.0. Serves goal 1, so development scales past one repo, and goal 1.6, since the epic stays in the client's Jira. Valid while Jira is the only backend; another backend goes behind the same interface.
- **What it is.** `build-epic <EPIC-KEY>` is a sibling of build-release, built on the same cycle, judge, interrupt, tmux and routing packages, not a copy (goal 1.3). It runs one tmux session per epic.
- **Machine settings.** `~/.config/build-release/build-epic/` holds `config.toml` (the Jira site, env-file, the folder repos are cloned into, the default language, and the model for a no-repo item) and `repo-rule.md`. `repo-rule.md` is a prose instruction that says how to tell an item's repo. It is the same for every epic on the machine. On the first machine, an item's label that equals a repo's name names that repo. A `[label-repos]` table in `config.toml` maps a team's own label to a repo, so build-epic reads that label as a pick without a claude call.
- **The epic's description is its record.** It holds `## Goals`, `## Audience`, `## Scoring` (formula and bar), `## Decisions` and a language line. build-epic writes all of it, but it changes Goals or Audience only after the human approves in an interrupt.
- **Items live only in the epic.** A repo's own plan never mirrors them. Where `repo-rule.md` leaves an item's repo unclear, build-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, build-epic asks.
- **One item, several repos.** build-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. An item a person filed a sub-task under counts as split already: build-epic works it through the team's own sub-tasks and doesn't file any of its own. It plans no such sub-task, so one without a label waits for the team's. It moves such an item itself (lilleman's call of 2026-11-20), since every issue the item blocks waits until the item moves, and the team's automation sees a pull request only on the sub-task that carries it. Once every sub-task is done, the item moves to done. Once every sub-task has landed, each done or in one of `jira-unblocking-statuses`, the item moves by the transition `jira-sub-tasks-landed-transition` names, which must lead to one of those statuses. A move that is not made is said, and the run goes on.
- **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. build-epic re-ranks the issues it filed in Jira's backlog to match. A person's issue keeps its rank there: goal 1.6 has the loop plug in without changing what the owners keep. On 2026-11-20 the human chose that the order the issues start in is build-epic's, while the board's order stays the team's: build-epic starts the open issues by score. Where two or more may start, it scores each of them that holds no scores, a person's included but not a human's task, and tells the team the scores in a comment. It never overwrites scores an issue holds. An issue that cannot be scored starts after those that can, in the backlog's order; where no order of score can be made at all, such as without the epic's formula, every issue starts in the backlog's order and build-epic says why.
- **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, build-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. build-epic and build-release 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 build-release sees build-epic's chunks in a checkout. build-epic and build-release 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/build-release/build-epic/<EPIC-KEY>/`. build-epic archives its cycles under `~/.local/state/build-release/build-epic-transcripts/`, not in build-release's archive, whose readers parse build-release's prompts. An open issue runs once a label records its repo; until build-epic picks repos itself, an issue without one waits, and `build-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. build-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. `build-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. `build-epic <key>` starts a parked chunk's window again whatever the limits, since the chunk stays parked. build-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. In a repo whose config sets `merge = "human"`, the merge itself is a gate: `chunk-pr merge` leaves the pull request ready, the chunk parks on `your merge` once nothing else holds the pull request, and it gets its gate read again when the forge no longer reports the pull request open, so that its worktree is removed and the chunk finishes. It resumes too once the pull request conflicts with its base branch, or is behind it where GitHub's branch protection requires an up-to-date branch, so the person finds a pull request they can merge. The worker then runs `chunk-pr merge` again, which levels the branch, waits for the checks and leaves the pull request ready. A chunk whose cycle ends on such a pull request is not handed on: its worker is told after each cycle until the pull request merges into its base. While GitHub still computes whether the pull request merges, the chunk stays parked until the next read. Gitea also reports a pull request as not mergeable for the seconds it checks for conflicts. A read in those seconds resumes the chunk for a run that doesn't change anything, which costs less than reading every gate twice to tell the two apart. The judge may rule such a chunk finished while its pull request is open, since its worker ends each run there. So build-epic reads a gate it could not read again before it hands the chunk on, and does the removal itself where it can. For a chunk whose pull request is no longer open, build-epic runs `chunk-pr clean` in the chunk's worktree. That command acts only on a pull request the forge reports merged at the worktree's head, and refuses a worktree with uncommitted or untracked files. Where it removed the worktree, the chunk finishes without a worker and, where it was parked, without a running slot, even if the command then failed on the main checkout, whose reason build-epic says. Where it left the worktree, as for a pull request closed unmerged, build-epic tells the worker once to remove it, and a parked chunk waits for a slot as for any other news.
- **Human tasks.** build-epic leaves a human task's issue as the team filed it. The task gets a window of its own while it is open, no issue blocks it, and it blocks another open issue. The window DMs the human once, through the notifier of the first repo whose project config names one (the repos of the issues it holds up come first, then those of the epic's other issues; where none does, the window says so), shows as parked (`awaits a human's task`) so that it doesn't take a running slot, and polls the epic every minute until the task no longer holds up an open issue. Then the issues it held up may start. A window that starts again, as after a reboot, DMs again.
- **Findings.** A finding about the epic's goals is filed in the epic. A finding about a repo's goals follows that repo's rules. Where unsure which, build-epic asks. A set of new items toward an epic goal needs the human's approval before work starts; a finding filed during a chunk doesn't.
- **Finishing.** When the epic holds no open item: release-review passes on each repo the epic changed, then the items they file, then the human confirms each achieve goal and that no maintain goal has a defect. For a goal that isn't met, build-epic proposes items for approval. Then a summary comment on the epic, and closing the epic in Jira, as the very last step.
- **Tests.** Black-box tests run against a fake Jira backend. An opt-in e2e test runs as its own command against a sandbox epic on a real Jira site.
## build-release: a `claude` that cannot start is a failed worker run, retried
2026-09-28, larv-review, declining a product-owner nit to exit at once when `claude` is missing. Serves goal 1. Claude Code's updater repoints `~/.local/bin/claude` at each new version under running loops, and a start that meets it mid-update fails with the same error as a broken install; the retry costs two minutes on the second and saves an unattended loop on the first. Valid while Claude Code updates by repointing its link.
@@ -225,9 +225,9 @@ Valid while `~/.claude` is a checkout of this repo.
2026-10-30, lilleman, todo item 6. Serves goal 1. Until then build-release marked each worktree trusted in `~/.claude.json`, reading the file, changing it and writing it back. Claude Code owns and writes that file, so a write it made in between could be lost. Claude Code 2.1.314 treats every folder as trusted while `CLAUDE_CODE_SANDBOXED` is set, and doesn't persist that trust. A claude started in a new folder with the variable set showed no dialog, and Claude Code recorded the folder untrusted. `hand_over` sets the variable for every claude it opens on a terminal: for `/talk`, a release ready to cut and the routing calls. The variable tells Claude Code it runs inside a sandbox, which holds here: build-release runs only in the sandbox README → Install names (`build-release: every claude it starts bypasses permissions inside its sandbox`). Claude Code doesn't document the variable. Where a later version drops it, the trust dialog comes back on those claudes, and nothing is lost. Valid while Claude Code honours `CLAUDE_CODE_SANDBOXED`.
## build-release: each project's model lives in `~/.config/build-release/models.json`, which only build-release and do-epic write, through one locked function
## build-release: each project's model lives in `~/.config/build-release/models.json`, which only build-release and build-epic write, through one locked function
2026-09-26, lilleman. Serves goal 1. Claude Code rewrites the user settings' `model` whenever one is picked inside a session, so a loop reading settings runs whatever was picked last. `~/.config/build-release/models.json` has one writer: `save_model` in `bin/chunk_driver/project/model_choice.py`. The entry points, build-release and do-epic, both call it, and it holds a lock from its read to its write. Every claude they start gets that model as `--model`. The file is per machine, outside the synced allowlist, since a tracked file the loop writes would dirty the checkout. 2026-10-02, lilleman: goal 2 has others run the setup on their own machines, and a project's model is each machine's own choice, so a new machine asks once per project, which is not asking the same thing twice (goal 1.2). Valid while Claude Code keeps rewriting the settings' model from inside a session.
2026-09-26, lilleman. Serves goal 1. Claude Code rewrites the user settings' `model` whenever one is picked inside a session, so a loop reading settings runs whatever was picked last. `~/.config/build-release/models.json` has one writer: `save_model` in `bin/chunk_driver/project/model_choice.py`. The entry points, build-release and build-epic, both call it, and it holds a lock from its read to its write. Every claude they start gets that model as `--model`. The file is per machine, outside the synced allowlist, since a tracked file the loop writes would dirty the checkout. 2026-10-02, lilleman: goal 2 has others run the setup on their own machines, and a project's model is each machine's own choice, so a new machine asks once per project, which is not asking the same thing twice (goal 1.2). Valid while Claude Code keeps rewriting the settings' model from inside a session.
## build-release: every claude it starts bypasses permissions inside its sandbox
@@ -334,9 +334,9 @@ The heavy command in that hang started its container from the project's own scri
A daemon-wide cap would see every container: dockerd's `cgroup-parent`, given a memory limit. lilleman turned it down, since it is host config and would cap a project's heavy work too. Valid while sessions start their work in containers on a machine they share.
## names: the plan calls the project and its repo `dev-factory` and do-epic `build-epic`, as it called loop-claude `build-release` until the rename shipped, and the code keeps today's other names until their planned items ship
## names: the plan calls the project and its repo `dev-factory`, its commands are `build-release` and `build-epic` with no old name kept as an alias, and the code keeps its other names until their planned items ship
2026-11-28, lilleman, part of the standalone-install plan approved on 2026-11-20. Serves goal 2: a person who clones a release meets commands named for what they make. The names set the install folders, such as `~/.config/build-release/`. lilleman chose `build-release` over the proposed `do-release` because "do" reads as if the command cuts the release, which stays the human's. "Build" says it makes what the release holds, and `build-epic` follows it for an epic. Neither name has "claude" in it, which fits goal 6, a setup that doesn't depend on Claude Code. `loop-claude` has been renamed `build-release`; the code keeps today's other names until items 575 and 576 ship, both in 0.18.0. On 2026-12-03 lilleman chose a hard break for those three renames: no old name stays as an alias. Renaming the repo on the forge is the human's. Valid while the install folders are named for `build-release`.
2026-11-28, lilleman, part of the standalone-install plan approved on 2026-11-20. Serves goal 2: a person who clones a release meets commands named for what they make. The names set the install folders, such as `~/.config/build-release/`. lilleman chose `build-release` over the proposed `do-release` because "do" reads as if the command cuts the release, which stays the human's. "Build" says it makes what the release holds, and `build-epic` follows it for an epic. Neither name has "claude" in it, which fits goal 6, a setup that doesn't depend on Claude Code. `loop-claude` has been renamed `build-release`, and `do-epic` has been renamed `build-epic`; the code keeps its other names until item 576 ships, in 0.18.0. On 2026-12-03 lilleman chose a hard break for the renames to `build-release`, `build-epic` and `dev-factory`: no old name stays as an alias. The `build-epic` rename applied it to the tool's own names too, so no name of the old tool lingers: its issue labels, which sit in a client's Jira, its config, state and transcripts folders and its `BUILD_EPIC_E2E_*` variables take the new name. Renaming the repo on the forge is the human's. Valid while the install folders are named for `build-release`.
## principles: about seven things per level, four or five where they act on each other, more where a reader finds them by name; crossing a limit asks for a grouping or a recorded reason
+8
View File
@@ -4036,3 +4036,11 @@ Read most (opens and searches):
Read most (opens and searches):
- `agents/stability-reviewer.md` 2
## Reading cost, chunk 2bedb32c176a, finished 2026-12-03T21:25:39Z
43758 new input tokens before the first commit.
Read most (opens and searches):
- `README.md` 1
+1 -1
View File
@@ -149,7 +149,7 @@ A round's fixes re-enter together: run every pass the table names for any of the
**Findings.** A reviewer rates each finding 🔴 must fix, 🟡 should fix, 🟢 nit, ❓ question, or 🔀 escalation naming the reviewer whose concern it is.
- **Outside the chunk.** A finding outside the chunk's change, whatever its pass or severity, is scored and filed in `todo.md` per `~/.claude/rules/todo-items.md`. A 🔴 is marked `defect`. A 🟡 against a file in the config's principles folder is marked `principle`, its detail naming the principle, where no other reason fits. One under the bar and not exempt is named in the summary with its score. A verified security HIGH is handled per "Security". In the release review the whole project is the chunk's change, so nothing lies outside it; "Release review" → "Findings" says which of its findings are filed.
- **Under do-epic.** A chunk do-epic runs files a finding about one of the epic's goals in the epic, as its prompt says, in place of `todo.md`. Where unsure whether a finding is about the epic's goals or a repo's, ask the human.
- **Under build-epic.** A chunk build-epic runs files a finding about one of the epic's goals in the epic, as its prompt says, in place of `todo.md`. Where unsure whether a finding is about the epic's goals or a repo's, ask the human.
- **Goal or decision.** A fix that would change a goal, or a `docs/decisions.md` entry the repo held before the chunk began, is asked; no user reachable → filed, marked `question`, the goal or decision left as is.
- **New decision.** Each decision a fix or an answer records in `docs/decisions.md` is checked against the project principles per `~/.claude/rules/decisions.md` → "Decisions: one home, each linked to a goal or a technical principle", "Check each new decision against the project's principles", before the commit that records it.
- **🔴.** A 🔴 is fixed, or shown factually wrong, and what disproved it recorded per the review standards' `comments.md` → "Where a choice goes": in a comment at the code the finding concerns, or in `docs/decisions.md` when it concerns more than one place. Never declined.
+20 -127
View File
@@ -12,12 +12,11 @@
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 575 | 0.18.0 | | owner | **Rename `do-epic` to `build-epic`, with no alias, and its config folder with it.** | 2 | 2 | 2 | 4 | 4 | 2 by 2, 6 by 1 | 0.6 |
| 482 | 0.18.0 | | owner | **Run the setup from a clone of a release by the path of its `bin/`, with no install step, and replace `deploy-release` with a command that moves that clone to the newest tag.** | 3 | 2 | 3 | 6 | 7 | 2 by 6 | 0.4 |
| 483 | 0.18.0 | 482 | owner | **Run every claude the loop starts in a Claude home that the commands generate under `~/.local/share/build-release/` and refresh when the clone's tag changes, with the enabled plugins installed there and the person signed in by `/login` in that home.** | 4 | 2 | 3 | 7 | 7 | 2 by 8 | 0.5 |
| 486 | 0.18.0 | 483 | owner | **Open an interactive claude with the setup loaded through one wrapper command, which sets the generated home and `PATH` and passes every argument on to claude.** | 2 | 1 | 1 | 2 | 3 | 2 by 2 | 0.5 |
| 577 | 0.18.0 | 483, 486, 575 | owner | **Test in the gate that a container holding only a stock Claude Code runs a chunk from a clone, against a mock Messages API, and that the run leaves the container's own `~/.claude` as it was.** | 3 | 1 | 2 | 4 | 6 | 3 by 9, 2 by 5 | 5.2 |
| 576 | 0.18.0 | 575 | owner | **Name the project `dev-factory` in the README, the prose and the tools, and say in the changelog that the repo moved.** | 2 | 2 | 2 | 4 | 4 | 2 by 1, 6 by 1 | 0.4 |
| 577 | 0.18.0 | 483, 486 | owner | **Test in the gate that a container holding only a stock Claude Code runs a chunk from a clone, against a mock Messages API, and that the run leaves the container's own `~/.claude` as it was.** | 3 | 1 | 2 | 4 | 6 | 3 by 9, 2 by 5 | 5.2 |
| 576 | 0.18.0 | | owner | **Name the project `dev-factory` in the README, the prose and the tools, and say in the changelog that the repo moved.** | 2 | 2 | 2 | 4 | 4 | 2 by 1, 6 by 1 | 0.4 |
| 578 | 0.18.0 | 576, 577 | owner | **Ship one chunk of this repo, to a merged pull request, from a clone of `main` that runs in the generated home, beside the untouched `~/.claude`.** | 1 | 2 | 1 | 2 | 1 | 2 by 4 | 1.2 |
| 580 | 0.19.0 | | | **Call no scoring run for a release already cut whose last item the chunk moved to a later release.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3, 1.5 by 3 | 1.6 |
| 487 | 0.20.0 | 483 | owner | **Run larv-review's passes from a program that picks them from the diff and the item, counts rounds against the cap and decides each rerun, with each reviewer returning its findings as JSON against a schema.** | 4 | 2 | 3 | 7 | 8 | 1.1 by 5, 1.4 by 5 | 0.4 |
@@ -48,7 +47,7 @@
| 264 | 0.23.0 | | | **Report the comprehension seats and the escalated subagents as subagent types of their own in `routing-figures.md`, with their dollars.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 5 | 1.4 |
| 323 | 0.23.0 | | | **Count a release review as landed once its pull request has merged, whatever its commits are titled.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 1.4 |
| 342 | 0.23.0 | | | **Research the tooling agents read, search and run commands with once more, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 1.4 |
| 471 | 0.23.0 | | | **Ship `jira-rest METHOD PATH [BODY]`, which makes one Jira Cloud REST call with the credentials of the project's config, or do-epic's, reading the env file itself, so an agent calls Jira without naming a file rule-hook guards.** | 2 | 2 | 4 | 6 | 3 | 1.6 by 3, 1.4 by 2 | 1.3 |
| 471 | 0.23.0 | | | **Ship `jira-rest METHOD PATH [BODY]`, which makes one Jira Cloud REST call with the credentials of the project's config, or build-epic's, reading the env file itself, so an agent calls Jira without naming a file rule-hook guards.** | 2 | 2 | 4 | 6 | 3 | 1.6 by 3, 1.4 by 2 | 1.3 |
| 149 | 0.23.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 1.3 |
| 165 | 0.23.0 | | | **Make this repo's tests assert the facts a prompt or help text carries in place of its sentences, and drop the tests that scan source or assert a constant.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4, 1.4 by 3 | 1.3 |
| 392 | 0.23.0 | | owner | **Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, ship and host), so a newcomer finds a tool's neighbours in one place.** | 3 | 1 | 3 | 5 | 7 | code health by 4 | 1.3 |
@@ -105,112 +104,6 @@
## Details
### 575. Rename `do-epic` to `build-epic`, with no alias, and its config folder with it.
Part of the standalone-install plan lilleman approved on 2026-11-20, as reshaped on 2026-12-03 when 0.18.0 was planned. The decision "names" set `build-epic` beside `build-release`. Its machine settings move from `~/.claude-projects/do-epic/` to a folder named for `build-epic` under `~/.config/build-release/`. The changelog names the successor, and nothing forwards from the old name.
Which mentions of `do-epic` in prose change is not predictable, so the list holds every file that names it. The new name of the `do_epic` package is not predictable either, so the list names its old files whole and leaves out the new ones beside the new launchers. Item 485 renamed `bin/loop_claude/` to `bin/build_release/`, so the list names those files by their new paths.
Touches:
- `bin/build-epic`
- `bin/build-epic-e2e`
- `bin/do-epic`
- `bin/do-epic-e2e`
- `bin/do_epic/__init__.py`
- `bin/do_epic/backend/__init__.py`
- `bin/do_epic/backend/contract.py`
- `bin/do_epic/backend/fake.py`
- `bin/do_epic/backend/jira.py`
- `bin/do_epic/backend/jira_start.py`
- `bin/do_epic/backend/jira_status.py`
- `bin/do_epic/backend/protocol.py`
- `bin/do_epic/backend/test_fake.py`
- `bin/do_epic/backend/test_jira.py`
- `bin/do_epic/chunk_prompt.py`
- `bin/do_epic/config.py`
- `bin/do_epic/dry_run.py`
- `bin/do_epic/e2e/__init__.py`
- `bin/do_epic/e2e/main.py`
- `bin/do_epic/e2e/sandbox.py`
- `bin/do_epic/e2e/scenario.py`
- `bin/do_epic/e2e/settings.py`
- `bin/do_epic/e2e/test_main.py`
- `bin/do_epic/e2e/test_sandbox.py`
- `bin/do_epic/e2e/test_scenario.py`
- `bin/do_epic/e2e/test_settings.py`
- `bin/do_epic/epic_record.py`
- `bin/do_epic/epic_run.py`
- `bin/do_epic/findings.py`
- `bin/do_epic/finish.py`
- `bin/do_epic/gates.py`
- `bin/do_epic/human_tasks.py`
- `bin/do_epic/issue_scores.py`
- `bin/do_epic/main.py`
- `bin/do_epic/parent_moves.py`
- `bin/do_epic/parked.py`
- `bin/do_epic/parking.py`
- `bin/do_epic/planning.py`
- `bin/do_epic/ranking.py`
- `bin/do_epic/repo_pick.py`
- `bin/do_epic/repos.py`
- `bin/do_epic/scheduler.py`
- `bin/do_epic/split.py`
- `bin/do_epic/status.py`
- `bin/do_epic/test_do_epic.py`
- `bin/do_epic/test_dry_run.py`
- `bin/do_epic/test_epic_record.py`
- `bin/do_epic/test_findings.py`
- `bin/do_epic/test_finish.py`
- `bin/do_epic/test_gates.py`
- `bin/do_epic/test_human_tasks.py`
- `bin/do_epic/test_issue_scores.py`
- `bin/do_epic/test_main.py`
- `bin/do_epic/test_parent_moves.py`
- `bin/do_epic/test_parked.py`
- `bin/do_epic/test_parking.py`
- `bin/do_epic/test_planning.py`
- `bin/do_epic/test_ranking.py`
- `bin/do_epic/test_repo_pick.py`
- `bin/do_epic/test_repos.py`
- `bin/do_epic/test_scheduler.py`
- `bin/do_epic/test_split.py`
- `bin/do_epic/test_status.py`
- `.gitignore`: lines 63-70
- `README.md`: `## Install`, `### Set up a project`, `## Tools`, `#### Driving chunks`, `#### Git, forges and Atlassian`, `## Test`
- `bin/agent_cycle/__init__.py`: `(module)`
- `bin/agent_cycle/escalation_mark.py`: `asks_higher_rung`
- `bin/agent_cycle/judge.py`: `Brief`
- `bin/agent_cycle/routing.py`: `Scored`
- `bin/agent_cycle/stop.py`: `needs_terminal`
- `bin/agent_cycle/tmux.py`: `(module)`, `start_window`
- `bin/agent_cycle/worker_prompts.py`: `WorkerPrompts`
- `bin/chunk_driver/__init__.py`: `(module)`
- `bin/chunk_driver/chunk_run.py`: `ChunkRun`
- `bin/chunk_driver/claims.py`: `(module)`, `starting`, `epic_chunks`
- `bin/chunk_driver/drivers.py`: `DO_EPIC`
- `bin/chunk_driver/project/model_choice.py`: `read_models_file`
- `bin/chunk_driver/prompts.py`: `worker_prompts`
- `bin/chunk_driver/this_loop.py`: `Loop`
- `bin/chunk_pr/approval.py`: `(module)`, `left_to_park`, `left_to_a_person`
- `bin/chunk_pr/main.py`: `(module)`
- `bin/chunk_pr/test_chunk_pr.py`: `Merge`
- `bin/forge/reviews.py`: `(module)`
- `bin/build_release/__init__.py`: `(module)`
- `bin/build_release/chunk/fresh_prompt.py`: `(module)`
- `bin/build_release/loop/chunk_windows.py`: `refusal`
- `bin/build_release/loop/test_chunk_windows.py`: `StartChunks`
- `bin/plan/release.py`: `(module)`
- `bin/project_config/main.py`: `(module)`
- `bin/project_config/settings.py`: `(module)`, `DO_EPIC`, `configs`, `env_files`
- `bin/project_config/test_project_config.py`: `LoadTest`, `HeldTest`, `ByNameTest`, `EnvFilesTest`
- `bin/release_plan/release_standing.py`: `reviewed_releases`
- `bin/repo_checks/test_gitignore.py`: `PRIVATE`
- `bin/repo_checks/test_package_cycles.py`: `DRIVERS`
- `bin/rule_hook/env_file.py`: `(module)`
- `bin/todo_item/doubles.py`: `UNREADABLE_BULLETS`
- `skills/larv-review/SKILL.md`: `## 3. Passes`
### 482. Run the setup from a clone of a release by the path of its `bin/`, with no install step, and replace `deploy-release` with a command that moves that clone to the newest tag.
Part of the standalone-install plan lilleman approved on 2026-11-20, as reshaped on 2026-12-03 when 0.18.0 was planned. lilleman chose a clone run by path over `uv tool install`: a person clones a release anywhere, and each machine keeps two clones, one at a release tag that people run and one for developing. The update command keeps what `deploy-release` checks and prints today, such as the changelog sections it moved past. A panel seated as the audience picks its spelling; `build-release self-update` was the proposal. No alias for `deploy-release` stays. Its `--cut` and `--cut-patch` cut a release, which is another job than updating: keep them as a command of their own, run in the development clone.
@@ -250,7 +143,7 @@ Touches:
- `bin/chunk_driver/cycle_start.py`: `setup_version` (small)
- `bin/build_release/loop/main.py`: `main` (small), `run_loop` (small)
- `bin/build_release/test_black_box.py`: `Checkout`
- `bin/do_epic/main.py`: `main` (small), `run` (small)
- `bin/build_epic/main.py`: `main` (small), `run` (small)
- `bin/rule_hook/transcript_read.py`: `(module)` (small), `transcript_breaches` (small)
- `bin/repo_checks/test_install.py`: `Install`
- `bin/repo_checks/test_settings.py`: `Settings`
@@ -488,11 +381,11 @@ Raised by the goals audit of PR #296. `bin/routing_figures/calls.py` groups a ch
### 300. Reach the comprehension floor: restructure the places the comprehension seats found hardest to follow, so the project reads at 7.0 or above on every dimension, Locality, Shape and Self-sufficiency first; today the second scoring run at 0aff7d39 scored Navigation 7.00, Locality 5.88, Shape 5.88, Self-sufficiency 6.00 and Overall 6.00.
Filed by the comprehension check of PR #473 at 13d1550 (`larv-review record-scoring`), which printed `Floor:` and `Next:`, refreshed from the two runs of item 525's chunk at 68611733, and then from the two runs of item 565's chunk at 98c49021. The lowest mean of the second run at 98c49021 is Self-sufficiency at 5.75, with Locality at 5.88 and Shape at 6.13; the first run put Self-sufficiency lowest at 5.63, with Locality and Shape at 5.75. Self-sufficiency: the why behind code sits in `docs/decisions.md`, cited by title from about 120 places, and the review loop's rules live in `skills/larv-review/SKILL.md`, not beside the unit that enforces them; `bin/agent_cycle/routing.py:115` `unfinished_route` keeps its reasons in the decision log too. Locality: do-epic and chunk-pr run order-dependent steps and keep state in tmux window names and between loop passes (`start_chunks`, `resumed_news`, `merged`, `merge_turn`), and no code enforces the order; `bin/do_epic/main.py:236` `chunk_run` and `bin/do_epic/scheduler.py:172` `start_chunks` are the hardest do-epic places, and the round cap is counted three ways (`bin/rule_hook/round_cap.py:28` `earlier_titles`, `bin/larv_review/reviewer_header.py:83` `branch_summaries`, `bin/review_rules/round_titles.py:39` `named_counts`). Shape: `bin/` stays flat at about 86 entries at one level, long functions carry several flags at once, and the OLD_SHAPE fork in `bin/plan/ranking.py` doubles the paths through ranking. Refresh this item's places and aim from the newest run before the chunk starts; do not file a second floor item.
Filed by the comprehension check of PR #473 at 13d1550 (`larv-review record-scoring`), which printed `Floor:` and `Next:`, refreshed from the two runs of item 525's chunk at 68611733, and then from the two runs of item 565's chunk at 98c49021. The lowest mean of the second run at 98c49021 is Self-sufficiency at 5.75, with Locality at 5.88 and Shape at 6.13; the first run put Self-sufficiency lowest at 5.63, with Locality and Shape at 5.75. Self-sufficiency: the why behind code sits in `docs/decisions.md`, cited by title from about 120 places, and the review loop's rules live in `skills/larv-review/SKILL.md`, not beside the unit that enforces them; `bin/agent_cycle/routing.py:115` `unfinished_route` keeps its reasons in the decision log too. Locality: build-epic and chunk-pr run order-dependent steps and keep state in tmux window names and between loop passes (`start_chunks`, `resumed_news`, `merged`, `merge_turn`), and no code enforces the order; `bin/build_epic/main.py:236` `chunk_run` and `bin/build_epic/scheduler.py:172` `start_chunks` are the hardest build-epic places, and the round cap is counted three ways (`bin/rule_hook/round_cap.py:28` `earlier_titles`, `bin/larv_review/reviewer_header.py:83` `branch_summaries`, `bin/review_rules/round_titles.py:39` `named_counts`). Shape: `bin/` stays flat at about 86 entries at one level, long functions carry several flags at once, and the OLD_SHAPE fork in `bin/plan/ranking.py` doubles the paths through ranking. Refresh this item's places and aim from the newest run before the chunk starts; do not file a second floor item.
Newest run, two runs of item 569's chunk at add7c09d: Locality is lowest at 5.63. It adds these places to the list below: `bin/rule_hook/reviewer_rung.py:28` `reviewer_breaches` refuses a launch for its rung and never for its round count, so the round cap has a launch-time gap beside the three counters; `bin/build_release/loop/chunk_windows.py:150` `chunks_to_start` is a near-twin of `bin/do_epic/scheduler.py:172` `start_chunks` with different rules and no stated reason for two; `bin/agent_cycle/tmux.py:92` `as_listed` keeps chunk state in window-name suffixes that other code matches on; `bin/plan/ranking.py:144` `weigh` checks the old table shape in every function; `bin/do_epic/__init__.py:1` has no map of its 25 modules.
Newest run, two runs of item 569's chunk at add7c09d: Locality is lowest at 5.63. It adds these places to the list below: `bin/rule_hook/reviewer_rung.py:28` `reviewer_breaches` refuses a launch for its rung and never for its round count, so the round cap has a launch-time gap beside the three counters; `bin/build_release/loop/chunk_windows.py:150` `chunks_to_start` is a near-twin of `bin/build_epic/scheduler.py:172` `start_chunks` with different rules and no stated reason for two; `bin/agent_cycle/tmux.py:92` `as_listed` keeps chunk state in window-name suffixes that other code matches on; `bin/plan/ranking.py:144` `weigh` checks the old table shape in every function; `bin/build_epic/__init__.py:1` has no map of its 25 modules.
Newest run, two runs of item 579's chunk at 0aff7d39: Locality and Shape are lowest, both at 5.88, with Self-sufficiency at 6.00 and Navigation at 7.00. It adds these places to the list below: `bin/chunk_pr/main.py:601` `levelled_and_finished` is an order-dependent chain of git changes and a scoring-run check, with no statement of what holds after it returns; `bin/agent_cycle/run.py:160` `rule` decides the figures written by the order of its archive calls, and only a comment says so; `bin/larv_review/main.py:33` "needs-scoring-run" holds the whole rule for when a run is due and owed only in a long docstring; `bin/plan_store/jira_epic.py:200` `edit` hides the loop-filed against person-filed rule among about 45 lines of early returns; `bin/transcript_archive/outcomes.py:11` `outcomes` is a line format that four readers parse by regex; `bin/do_epic/main.py:236` `chunk_run` sits in a 520-line main that also holds help text and the issue-move policy.
Newest run, two runs of item 579's chunk at 0aff7d39: Locality and Shape are lowest, both at 5.88, with Self-sufficiency at 6.00 and Navigation at 7.00. It adds these places to the list below: `bin/chunk_pr/main.py:601` `levelled_and_finished` is an order-dependent chain of git changes and a scoring-run check, with no statement of what holds after it returns; `bin/agent_cycle/run.py:160` `rule` decides the figures written by the order of its archive calls, and only a comment says so; `bin/larv_review/main.py:33` "needs-scoring-run" holds the whole rule for when a run is due and owed only in a long docstring; `bin/plan_store/jira_epic.py:200` `edit` hides the loop-filed against person-filed rule among about 45 lines of early returns; `bin/transcript_archive/outcomes.py:11` `outcomes` is a line format that four readers parse by regex; `bin/build_epic/main.py:236` `chunk_run` sits in a 520-line main that also holds help text and the issue-move policy.
Aim: one ambitious refactor of the areas below, sized so every mean reaches 7.0 on the chunk's own scoring run. Where a place is already easier to read when the chunk starts, drop it.
@@ -500,24 +393,24 @@ Places the seats named in the two runs at 98c49021, hardest first (`larv-review
- Self-sufficiency, Locality: `bin/agent_cycle/routing.py:115` `unfinished_route`: five rungs interact, and the reasons sit in the decision log or the module's table. Three seats named it.
- Self-sufficiency, Locality: `skills/larv-review/SKILL.md:104` "Re-entry", with `:96` "Round cap": Re-entry depends on "Round cap" and "Mechanical answers" and is read twice to know which pass a fix reruns, and the cap's contract spans the skill, three modules and `bin/rule_hook/rules.py:85`. Two seats named it.
- Self-sufficiency: `bin/do_epic/main.py:485` `next_cycle`: a tmux window name doubles as the Jira issue key, written down nowhere.
- Self-sufficiency: `bin/build_epic/main.py:485` `next_cycle`: a tmux window name doubles as the Jira issue key, written down nowhere.
- Self-sufficiency, Shape: `bin/release_plan/release_standing.py:206` `next_release`: one boolean packs three inputs.
- Locality, Self-sufficiency, Shape: `bin/do_epic/parking.py:18` `parked_through`: a crash-ordering protocol of three ordered steps and a polling loop, with state in a file, tmux attributes, Jira and scheduler slots, and the order only in the docstring. Three seats named it.
- Locality, Shape, Navigation: `bin/do_epic/scheduler.py:172` `start_chunks`: window sets and a parked map in a five-way branch under two nested locks, and the cap on running chunks lives here, in `resume` and in `bin/build_release/loop/chunk_windows.py:117` `start_chunks`. Three seats named it.
- Locality, Self-sufficiency, Shape: `bin/build_epic/parking.py:18` `parked_through`: a crash-ordering protocol of three ordered steps and a polling loop, with state in a file, tmux attributes, Jira and scheduler slots, and the order only in the docstring. Three seats named it.
- Locality, Shape, Navigation: `bin/build_epic/scheduler.py:172` `start_chunks`: window sets and a parked map in a five-way branch under two nested locks, and the cap on running chunks lives here, in `resume` and in `bin/build_release/loop/chunk_windows.py:117` `start_chunks`. Three seats named it.
- Locality: `bin/rule_hook/round_cap.py:28` `earlier_titles`, with `bin/larv_review/reviewer_header.py:83` `branch_summaries` and `bin/review_rules/round_titles.py:39` `named_counts`: three round counters, and `earlier_titles` fails open where the others don't. Two seats named it.
- Locality, Shape: `bin/do_epic/main.py:402` `handed_on`: reads like a getter and writes Jira, the store and tmux.
- Locality, Shape: `bin/build_epic/main.py:402` `handed_on`: reads like a getter and writes Jira, the store and tmux.
- Locality: `bin/chunk_pr/main.py:624` `levelled_and_finished`: the order of the scoring-run check and the remeasure isn't explained.
- Locality: `bin/agent_cycle/judge.py:88` `Reply`: the prompt's wording is coupled to `judge_replay.archived_prompt`.
- Locality: `bin/chunk_driver/chunk_run.py:44` `closed_cycle`: `Route.unfinished` and `Run.unfinished_run` have near-identical names and different meanings.
- Locality: `bin/build_release/loop/reload.py:97` `exec_if_edited`: a new `LoopRun` field breaks running loops.
- Shape, Locality, Self-sufficiency: `bin/chunk_pr/main.py:485` `merged`: a merge-queue loop interleaving approval, parking and a flock, with chained Failure ternaries, four flags whose combinations aren't all visibly handled, about eight functions to follow one merge, and git, forge and plan effects in an unexplained order. Five seats named it.
- Shape, Locality: `bin/do_epic/main.py:236` `chunk_run`: a long loop mixing parking and reopening, with flags threaded through and a nested ternary at line 285. Three seats named it.
- Shape, Locality: `bin/build_epic/main.py:236` `chunk_run`: a long loop mixing parking and reopening, with flags threaded through and a nested ternary at line 285. Three seats named it.
- Shape: `bin/task_bench/main.py:241` `Planner`: three layers of curried callables. Two seats named it.
- Shape: `bin/agent_cycle/run.py:33` `Cycle`, with `:160` `rule`: the dataclass has 17 fields, and `rule` has four near-identical archive names and one very long expression at line 255.
- Shape, Navigation: `bin/rule_hook/rules.py:27` `RULES`: a prose table and the check functions share one file.
- Shape: `bin/rule_hook/env_file.py:34` `reaching`: `and` over `or` without parentheses at line 41.
- Navigation, Shape: `bin/agent_cycle/__init__.py:1` `agent_cycle`: 17 flat modules against its own "about seven" citation.
- Navigation: `README.md:269` "do_epic": the only map of a 22-module package with an empty `__init__.py`.
- Navigation: `README.md:269` "build_epic": the only map of a 22-module package with an empty `__init__.py`.
- Navigation: `bin/chunk_driver/this_loop.py:12` `Loop`: the name doesn't say it holds a chunk's run context.
### 264. Report the comprehension seats and the escalated subagents as subagent types of their own in `routing-figures.md`, with their dollars.
@@ -545,13 +438,13 @@ Dropped in 312's round, and why; look again only where the reason has changed:
- LSP, repo maps and outline scripts: item 231's trial lost findings and agents didn't call them; the only figures found since are a vendor's and a blog's.
- Compact test reporters and output filters such as rtk: this archive's test output is a few thousand tokens per release, and the filters' figures are their own; trimming read output is item 311's ceiling.
### 471. Ship `jira-rest METHOD PATH [BODY]`, which makes one Jira Cloud REST call with the credentials of the project's config, or do-epic's, reading the env file itself, so an agent calls Jira without naming a file rule-hook guards.
### 471. Ship `jira-rest METHOD PATH [BODY]`, which makes one Jira Cloud REST call with the credentials of the project's config, or build-epic's, reading the env file itself, so an agent calls Jira without naming a file rule-hook guards.
Once a Jira credentials file is a config's `env-file`, rule-hook's `env-file-read` refuses every Bash command that names it. A machine's own rules that tell agents to `source` it and `curl` Jira then stop working. On 2026-11-20 this happened on a machine whose rules call Jira that way, and a machine-only script, `~/.local/bin/jira-rest`, took their place. The human asked for it as a claude-config tool, so every machine has it.
- `jira-rest METHOD PATH [BODY.json | -]` sends one call to a path under `/rest/`, with the body from the file or stdin, and prints Jira's JSON answer, or `null` for an empty one. A refused call exits non-zero with the message `atlassian.client.jira_errors` gives. No output, error or log line holds a credential.
- The site and the env file come from the project's config where the checkout has one whose `plan` or `goals-and-audience` is a Jira epic: the epic's site and the config's `env-file`. Otherwise they come from do-epic's config: `jira-url` and `env-file`. Where neither holds them, it fails, naming both places.
- It sends through `atlassian.client`, as `plan_store` and `do_epic` do, so it gains their error messages and timeouts.
- The site and the env file come from the project's config where the checkout has one whose `plan` or `goals-and-audience` is a Jira epic: the epic's site and the config's `env-file`. Otherwise they come from build-epic's config: `jira-url` and `env-file`. Where neither holds them, it fails, naming both places.
- It sends through `atlassian.client`, as `plan_store` and `build_epic` do, so it gains their error messages and timeouts.
- `--help` states the contract, and README → `## Tools` lists the tool.
After it ships, the machine's `~/.local/bin/jira-rest` is removed, and its rules call the shipped tool.
@@ -697,13 +590,13 @@ The change touches `skills/larv-review/SKILL.md` "Re-entry", which the comprehen
### 444. Rank an epic item that is split by repo, by the goals of each repo its sub-tasks name.
Today `bin/do_epic/planning.py` → `ranked_keys` leaves an item marked `split-by-repo` at its position in the backlog, as it leaves a person's issue: `ranking.ranked` scores an item in one repo's chain of goals, and a split item has several repos. Its sub-tasks follow it, so the whole change keeps whatever rank the item had when it was filed.
Today `bin/build_epic/planning.py` → `ranked_keys` leaves an item marked `split-by-repo` at its position in the backlog, as it leaves a person's issue: `ranking.ranked` scores an item in one repo's chain of goals, and a split item has several repos. Its sub-tasks follow it, so the whole change keeps whatever rank the item had when it was filed.
Touches:
- `bin/do_epic/planning.py`: `ranked_keys`
- `bin/do_epic/ranking.py`: `ranked`
- `bin/do_epic/test_planning.py`
- `bin/build_epic/planning.py`: `ranked_keys`
- `bin/build_epic/ranking.py`: `ranked`
- `bin/build_epic/test_planning.py`
### 366. Count the chunks of a project whose plan sits outside the checkout in the routing figures, from the project repo's history or from Jira.