Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 005a23f431 | |||
| 26a0a2845d | |||
| 65491d1b55 | |||
| 14123912d9 | |||
| b9afedfd80 | |||
| 07902aa7f4 | |||
| 0a18503054 | |||
| 38f4274c85 | |||
| dae767b085 | |||
| 7e141eaa1e | |||
| 22654a5e05 | |||
| 24bd382d48 | |||
| 2e0ceef6ae | |||
| f49d176103 | |||
| e6f7d50943 | |||
| 50dd61c039 | |||
| 402b0690c8 | |||
| 5013fbdf1f | |||
| f8cabf78bf | |||
| 846d9cd197 | |||
| 62b4825cea | |||
| b7d7a1f1ea | |||
| b383a89c5b | |||
| b832c1e669 | |||
| 90352d74c4 | |||
| ff3961ca77 | |||
| 84a0f1d1be | |||
| 26cadbb79e | |||
| adae921cd6 | |||
| bfe32bc1fa | |||
| 144986e671 | |||
| 68ed7ac95a | |||
| dae6f586ab | |||
| 5d9d880f44 | |||
| 90dd09e566 | |||
| ecd8a99335 | |||
| b2630b8148 | |||
| e2f5661760 | |||
| b09d30b48e | |||
| b26256ce44 | |||
| 95535b4fb3 | |||
| 017cf33611 | |||
| e37430a8a2 |
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## 0.13.0
|
||||
|
||||
- Fix loop-claude stopping after a finished chunk: its judge may now quote the worker's task as evidence, so the loop starts the next chunks instead of exiting.
|
||||
- Add the project setting `merge = "human"`, for a team that merges its own pull requests: `chunk-pr merge` then marks the pull request ready and leaves the merge to a person, and a do-epic chunk parks, shown as `awaits your merge`, until the pull request is merged.
|
||||
- do-epic reads a team's own repo labels: a `[label-repos]` table in `~/.claude-projects/do-epic/config.toml` maps each such label to its repo, such as `twu-4 = "tenant-web-ui-4"`, and do-epic reads a mapped label as it reads `repo:<name>`. An issue a person filed a sub-task under is no longer split by repo: its sub-tasks run instead, each under a label of its own, and the team closes the issue.
|
||||
- do-epic --file takes --blocked-by <KEY> and --parent <KEY>, so a chunk files the next pull request of a change as an issue that waits for the one before it; a chunk's first prompt says when to use them.
|
||||
|
||||
## 0.12.0
|
||||
|
||||
- loop-claude asks a headless claude whether a worker that went quiet before its result is stuck, and prints the verdict and appends it to stuck-workers.md, without killing anything.
|
||||
|
||||
@@ -119,6 +119,8 @@ 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. A do-epic chunk parks until the pull request is merged, and its window's name says `awaits your merge`. Left out, the setting is `"chunk"`: the chunk merges.
|
||||
|
||||
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 loop-claude'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 loop-claude 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.
|
||||
|
||||
A client that plans in Jira Cloud names an epic as its project's plan: `plan = "jira:https://acme.atlassian.net/browse/ABC-12"`, which is `jira:` and the epic's address as the browser shows it. The plan is then the epic's open child issues, in Jira's backlog order, which the team sets, apart from the rank `todo-item add` gives an issue it files. An issue in a done status is a finished item. Each part of an item comes from one part of its issue:
|
||||
@@ -153,6 +155,7 @@ The last line prints each setting's path once the config is complete.
|
||||
`do-epic` keeps its settings per machine, not per project, in `~/.claude-projects/do-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 `~/.claude-projects`; 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` 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"`. 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: `repo:<name>` for its repo, `do-epic-claude` for work of Claude's that changes no repo, and `do-epic-human` for a task of yours. 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.
|
||||
|
||||
An epic's description states the formula that ranks the issues do-epic files in it: once under `## Scoring`, on a line of its own and inside backticks, such as `` `Score = 100 * V / (2**S + 32)` ``. Without that line do-epic says so and leaves the backlog's order as it is.
|
||||
@@ -187,12 +190,12 @@ It renames `## Unreleased` in `CHANGELOG.md` to the version and merges that thro
|
||||
|
||||
Install puts only `loop-claude` on `PATH`; call the others by their path, such as `~/.claude/bin/metric-bench`, from the project's checkout. Those 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.
|
||||
|
||||
- `chunk-pr open|sync|ready|merge|clean` 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. 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; 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-pr open|sync|ready|merge|clean` 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. 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; `loop-claude` 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 loop-claude'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] [<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, 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 loop-claude. 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. Then it puts the scored issues that do-epic itself filed in order of score. An open issue runs once a label names its repo or marks it as Claude's, in Jira's backlog order, 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 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 <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 loop-claude. 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 it puts the scored issues that do-epic itself filed in order of score. An open issue runs once a label names its repo or marks it as Claude's, in Jira's backlog order, 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 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 loop-claude'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.
|
||||
|
||||
@@ -134,6 +134,8 @@ class Grounds(typing.NamedTuple):
|
||||
quotable: str
|
||||
# Each answer the human typed, whole, latest last (transcript.human_answers).
|
||||
typed: tuple[str, ...] = ()
|
||||
# The worker's task, which the judge reads above shown and may quote as the evidence: the worker's first prompt holds it, but the tail in shown cuts that off once the session grows.
|
||||
task: str = ""
|
||||
|
||||
|
||||
class Brief(typing.NamedTuple):
|
||||
@@ -237,7 +239,7 @@ def quotes_checked(verdict: Verdict, grounds: Grounds) -> Verdict | Failure:
|
||||
|
||||
| Quote | Must be in | Where it isn't | Checked by |
|
||||
|---|---|---|---|
|
||||
| the evidence | grounds.shown, the evidence's fragments in order | a Failure: run_judge rejects the reply, and judge retries it | grounded |
|
||||
| the evidence | grounds.task then grounds.shown, the evidence's fragments in order | a Failure: run_judge rejects the reply, and judge retries it | grounded |
|
||||
| an interrupt's answered_before | grounds.shown | the interrupt stands, as if no earlier answer was found | re_ask_checked |
|
||||
| its left_open | answered_before and the question | the interrupt becomes an Unfinished that quotes answered_before back to the worker | re_ask_checked |
|
||||
| a quoted answer | grounds.quotable | the question goes to the human as an interrupt, which keeps the escalation the answer carried | answer_checked |
|
||||
@@ -246,7 +248,7 @@ def quotes_checked(verdict: Verdict, grounds: Grounds) -> Verdict | Failure:
|
||||
|
||||
Only a misquoted evidence fails. A Failure for any other would exit an unattended loop, so each changes the verdict instead.
|
||||
"""
|
||||
if not grounded(verdict.evidence, grounds.shown):
|
||||
if not grounded(verdict.evidence, f"{grounds.task}\n\n{grounds.shown}"):
|
||||
return misquoted_evidence(verdict)
|
||||
verdict = re_ask_checked(verdict, grounds.shown)
|
||||
verdict = answer_checked(verdict, grounds.quotable)
|
||||
@@ -306,5 +308,6 @@ def judge_prompt(brief: Brief) -> tuple[str, Grounds]:
|
||||
after_mark=escalation_mark.after_mark(brief.entries, brief.escalated_at),
|
||||
quotable=f"{brief.premises}\n\n{brief.records}",
|
||||
typed=tuple(human_answers(brief.entries, typed_answer)),
|
||||
task=brief.task,
|
||||
)
|
||||
return f"{head}{shown}\n\n{rules}", grounds
|
||||
@@ -124,6 +124,14 @@ class Verdict(unittest.TestCase):
|
||||
verdict = judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", "the project's decisions", "the plan or a comment", kinds(*entries), 1, "loop-claude"), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", evidence="round 2: 🔴")]).effects())
|
||||
self.assertEqual(verdict, Unfinished("round 2: 🔴", entries_read=2))
|
||||
|
||||
def test_takes_the_task_as_evidence_where_the_tail_it_shows_cuts_off_the_workers_first_prompt(self):
|
||||
entries = [human("Do the next chunk. " + "x" * judge.JUDGE_PROMPT_CHARS), assistant({"type": "text", "text": "Merged."})]
|
||||
def judged_on(evidence):
|
||||
return judge.judge_once("/r", judge.Brief("Do the next chunk.", "## Goals", "", "the project's decisions", "the plan or a comment", kinds(*entries), 0, "loop-claude"), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", evidence=evidence)] * 3).effects())
|
||||
self.assertEqual(judged_on("Do the next chunk."), Unfinished("Do the next chunk.", entries_read=2))
|
||||
self.assertEqual(judged_on("Do the next chunk. ... Merged."), Unfinished("Do the next chunk. ... Merged.", entries_read=2))
|
||||
self.assertIsInstance(judged_on("Do the next release."), Failure)
|
||||
|
||||
|
||||
class JudgePrompt(unittest.TestCase):
|
||||
def brief(self, entries, escalated_at, answer_destinations="the plan or a comment"):
|
||||
|
||||
@@ -12,8 +12,10 @@ WAIT_SECONDS = 90 * 60
|
||||
PARKS = "CHUNK_PR_PARKS"
|
||||
|
||||
|
||||
def awaited(forge: Forge, wait_for_approval: bool) -> bool | Failure:
|
||||
"""Whether merge waits for an approval: the project config's `wait-for-approval`. chunk-pr reads approvals on GitHub only, so a Gitea project that sets it fails, and merge never skips an approval the config requires."""
|
||||
def awaited(forge: Forge, wait_for_approval: bool, by_human: bool) -> bool | Failure:
|
||||
"""Whether merge waits for an approval. Never where a person merges the pull request (by_human): that person reads its approvals. Otherwise as the project config's `wait-for-approval` says; chunk-pr reads approvals on GitHub only, so a Gitea project that sets it fails, and the chunk never merges past an approval the config requires."""
|
||||
if by_human:
|
||||
return False
|
||||
if wait_for_approval and forge != "gh":
|
||||
return Failure("the project's config sets wait-for-approval, but chunk-pr reads approvals on GitHub only, so it cannot merge this pull request; ask the human to merge it")
|
||||
return wait_for_approval
|
||||
@@ -52,6 +54,12 @@ def left_to_park(number: str, run: Run) -> Failure:
|
||||
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")
|
||||
|
||||
|
||||
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."
|
||||
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}"
|
||||
|
||||
|
||||
def unanswered(number: str, run: Run) -> Failure | None:
|
||||
"""A Failure naming the files where a reviewer's comment waits for an answer on pull request number, as `waiting_threads` finds them, or saying why they cannot be read. None where no thread waits."""
|
||||
waiting = waiting_threads(number, run)
|
||||
|
||||
+25
-7
@@ -47,6 +47,12 @@ merge merges the pull request in its turn: the chunks of one project on this
|
||||
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.
|
||||
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
|
||||
finished is a commit on the branch, so it lands with that merge; one in Jira, or in
|
||||
the config's folder, is finished at once. It reads no approval then, whatever
|
||||
`wait-for-approval` says. Once a person merged it, run clean.
|
||||
It stops, without merging, and says what to do before running it again:
|
||||
- on a merge conflict in step 1, naming the conflicted files, with the merge in progress;
|
||||
- where `larv-review scoring-run-owed` exits 1 after step 3, because the chunk owes a
|
||||
@@ -86,7 +92,7 @@ import sys
|
||||
import time
|
||||
import typing
|
||||
|
||||
from chunk_pr.approval import approval, approved, awaited, left_to_park, PARKS, unanswered
|
||||
from chunk_pr.approval import approval, approved, awaited, left_to_a_person, left_to_park, PARKS, unanswered
|
||||
from forge.pulls import checks_passed, merged_pull, open_pull, required_checks
|
||||
from failure import Failure
|
||||
from forge.commands import Forge, forge_of, gitea, Run, runner
|
||||
@@ -306,7 +312,7 @@ def finishes_of(given: list[str]) -> list[list[str]] | None:
|
||||
|
||||
|
||||
def merged(run: Run, config: Config, sleep: typing.Callable[[float], None], finishes: typing.Sequence[list[str]] = (), parks: bool = False) -> str | Failure:
|
||||
"""Merge the branch's pull request in the project's merge queue. Each pass of the loop is one turn in the queue; a pull request that still wants its approval leaves the queue while it waits, so the next chunk merges meanwhile, and takes a new turn once approved. Where parks, it doesn't wait for the approval: it fails at once, as `left_to_park` says."""
|
||||
"""Merge the branch's pull request in the project's merge queue. Each pass of the loop is one turn in the queue; a pull request that still wants its approval leaves the queue while it waits, so the next chunk merges meanwhile, and takes a new turn once approved. Where parks, it doesn't wait for the approval: it fails at once, as `left_to_park` says. Where the project's config leaves the merge to a person, the turn ends with the pull request ready, as `left_to_a_person` says."""
|
||||
found = pull(run)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
@@ -314,7 +320,8 @@ def merged(run: Run, config: Config, sleep: typing.Callable[[float], None], fini
|
||||
loaded = config()
|
||||
if isinstance(loaded, Failure):
|
||||
return loaded
|
||||
waits = awaited(forge, loaded.wait_for_approval)
|
||||
by_human = loaded.merge == "human"
|
||||
waits = awaited(forge, loaded.wait_for_approval, by_human)
|
||||
if isinstance(waits, Failure):
|
||||
return waits
|
||||
method = merge_method(forge, run)
|
||||
@@ -331,10 +338,12 @@ def merged(run: Run, config: Config, sleep: typing.Callable[[float], None], fini
|
||||
if isinstance(absent, Failure):
|
||||
return absent
|
||||
file = pathlib.Path(queue[0]) / QUEUE
|
||||
pull_request = Merging(forge, number, method, str(base), required, waits)
|
||||
pull_request = Merging(forge, number, method, str(base), required, waits, by_human)
|
||||
while True:
|
||||
with turn(file, number, sleep) as untaken:
|
||||
taken = untaken or merge_turn(pull_request, finishes, loaded, run, sleep)
|
||||
if isinstance(taken, AwaitsMerge):
|
||||
return left_to_a_person(number, parks) + absent
|
||||
if not isinstance(taken, AwaitsApproval):
|
||||
return taken if isinstance(taken, Failure) else taken + absent
|
||||
if parks:
|
||||
@@ -347,13 +356,14 @@ def merged(run: Run, config: Config, sleep: typing.Callable[[float], None], fini
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Merging:
|
||||
"""A pull request that merge takes turns for: its forge and number, the merge method, the default branch it merges into with the checks that branch requires, and whether it waits for an approval."""
|
||||
"""A pull request that merge takes turns for: its forge and number, the merge method, the default branch it merges into with the checks that branch requires, whether it waits for an approval, and whether a person merges it."""
|
||||
forge: Forge
|
||||
number: str
|
||||
method: str
|
||||
base: str
|
||||
required: set[str]
|
||||
waits: bool
|
||||
by_human: bool
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -361,12 +371,20 @@ class AwaitsApproval:
|
||||
"""The pull request passed its checks but awaits a human's approval, so merge leaves the queue until it has one."""
|
||||
|
||||
|
||||
def merge_turn(pull_request: Merging, finishes: typing.Sequence[list[str]], config: ProjectConfig, run: Run, sleep: typing.Callable[[float], None]) -> str | AwaitsApproval | Failure:
|
||||
"""One turn in the queue: level the branch and finish its items, wait for its checks, and merge it where nothing still waits. What merged it, or why it waits or fails."""
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class AwaitsMerge:
|
||||
"""The pull request passed its checks and is marked ready, and the project's config leaves its merge to a person."""
|
||||
|
||||
|
||||
def merge_turn(pull_request: Merging, finishes: typing.Sequence[list[str]], config: ProjectConfig, run: Run, sleep: typing.Callable[[float], None]) -> str | AwaitsApproval | AwaitsMerge | Failure:
|
||||
"""One turn in the queue: level the branch and finish its items, wait for its checks, and merge it where nothing still waits. What merged it, or why it waits or fails. A pull request a person merges is marked ready instead: its finished items are commits on its branch, so they reach the default branch with that person's merge."""
|
||||
head = levelled_and_finished(run, pull_request.base, finishes, config)
|
||||
checked = head if isinstance(head, Failure) else checks_passed(pull_request.forge, pull_request.number, head, pull_request.required, run, sleep, NO_CHECKS_SECONDS)
|
||||
if isinstance(checked, Failure):
|
||||
return checked
|
||||
if pull_request.by_human:
|
||||
marked = marked_ready(run, None)
|
||||
return marked if isinstance(marked, Failure) else AwaitsMerge()
|
||||
ready = approval(pull_request.number, run) if pull_request.waits else True
|
||||
if isinstance(ready, Failure):
|
||||
return ready
|
||||
|
||||
@@ -11,6 +11,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from chunk_pr.approval import awaited
|
||||
from chunk_pr.main import cleaned, merged, QUEUE, step, turn, USAGE
|
||||
from failure import Failure
|
||||
from test_env import isolated_env
|
||||
@@ -81,7 +82,7 @@ class Checkout:
|
||||
return failed
|
||||
texts = {name: str(answer).strip() for name, answer in named.items()}
|
||||
paths = {name: pathlib.Path(texts[name]) for name in ("plan", "changelog", "comprehension-history") if texts.get(name, "").startswith("/")}
|
||||
return ProjectConfig("proj", pathlib.Path("/config"), pathlib.Path("/checkout"), paths, wait_for_approval=texts.get("wait-for-approval") == "true", commit_title=texts.get("commit-title", "{summary}"), pull_request_title=texts.get("pull-request-title", "{summary}"), branch=texts.get("branch", "item-{id}"))
|
||||
return ProjectConfig("proj", pathlib.Path("/config"), pathlib.Path("/checkout"), paths, wait_for_approval=texts.get("wait-for-approval") == "true", merge=texts.get("merge", "chunk"), commit_title=texts.get("commit-title", "{summary}"), pull_request_title=texts.get("pull-request-title", "{summary}"), branch=texts.get("branch", "item-{id}"))
|
||||
|
||||
def __call__(self, command: list[str]) -> str | Failure:
|
||||
self.ran.append(command)
|
||||
@@ -360,6 +361,60 @@ class Merge(unittest.TestCase):
|
||||
checkout.decisions = list(decisions) or ["APPROVED"]
|
||||
return checkout
|
||||
|
||||
def merged_by_a_human(self, origin: str = GITHUB) -> Checkout:
|
||||
"""A Checkout whose project config sets `merge = "human"`."""
|
||||
checkout = Checkout(origin, open=True)
|
||||
checkout.answers[(PROJECT_CONFIG, "merge")] = "human\n"
|
||||
return checkout
|
||||
|
||||
def test_under_a_humans_merge_it_waits_for_the_checks_marks_the_pull_request_ready_and_leaves_it_unmerged(self):
|
||||
for origin, ready in ((GITHUB, ["gh", "pr", "ready", "12"]), (GITEA, ["tea", "pulls", "edit", "12", "--ready"])):
|
||||
with self.subTest(origin):
|
||||
checkout = self.merged_by_a_human(origin)
|
||||
done = step(["merge"], checkout, checkout.config)
|
||||
for fact in ("pull request #12", "awaits a person's merge", "chunk-pr clean"):
|
||||
self.assertIn(fact, str(done))
|
||||
self.assertNotIn("end your run", str(done))
|
||||
self.assertEqual(checkout.acted()[-1], ready)
|
||||
self.assertFalse(any("merge" in command[1:4] for command in checkout.acted() if command[0] != "git"), checkout.acted())
|
||||
|
||||
def test_under_a_humans_merge_a_chunk_that_parks_is_told_to_end_its_run(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
done = merged(checkout, checkout.config, self.fail, parks=True)
|
||||
for fact in ("pull request #12", "awaits a person's merge", "end your run"):
|
||||
self.assertIn(fact, str(done))
|
||||
self.assertNotIn("chunk-pr clean", str(done))
|
||||
|
||||
def test_under_a_humans_merge_a_failed_check_leaves_the_pull_request_as_it_was(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
checkout.answers[tuple(GH_CHECKS)] = Failure("gh pr checks 12: CI / tests\tfail")
|
||||
self.assertEqual(step(["merge"], checkout, checkout.config), Failure("gh pr checks 12: CI / tests\tfail"))
|
||||
self.assertEqual(changes(checkout), [])
|
||||
|
||||
def test_under_a_humans_merge_it_never_reads_the_approval_also_on_gitea(self):
|
||||
for origin in (GITHUB, GITEA):
|
||||
with self.subTest(origin):
|
||||
checkout = self.merged_by_a_human(origin)
|
||||
checkout.answers[tuple(WAITS)] = "true\n"
|
||||
checkout.decisions = ["REVIEW_REQUIRED"]
|
||||
self.assertIn("awaits a person's merge", str(step(["merge"], checkout, checkout.config)))
|
||||
self.assertNotIn(GH_DECISION, checkout.ran)
|
||||
|
||||
def test_merge_waits_for_no_approval_where_a_person_merges_and_for_the_configs_otherwise(self):
|
||||
self.assertEqual([awaited("gh", True, True), awaited("tea", True, True), awaited("gh", True, False), awaited("gh", False, False)], [False, False, True, False])
|
||||
self.assertIsInstance(awaited("tea", True, False), Failure)
|
||||
|
||||
def test_under_a_humans_merge_a_pull_request_that_cannot_be_marked_ready_fails_saying_why(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
checkout.answers[("gh", "pr", "ready", "12")] = Failure("gh pr ready failed")
|
||||
self.assertEqual(step(["merge"], checkout, checkout.config), Failure("gh pr ready failed"))
|
||||
|
||||
def test_under_a_humans_merge_the_plan_items_are_finished_on_the_branch_so_they_land_with_the_merge(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
done = step(["merge", "--finish", "7", "--no-changelog"], checkout, checkout.config)
|
||||
self.assertIn("awaits a person's merge", str(done))
|
||||
self.assertIn([MergeQueue.TODO_ITEM, "finish", "7", "--no-changelog"], checkout.ran)
|
||||
|
||||
def test_a_project_without_wait_for_approval_never_reads_the_review_decision(self):
|
||||
checkout = Checkout(GITHUB, open=True)
|
||||
checkout.decisions = ["REVIEW_REQUIRED"]
|
||||
|
||||
@@ -91,6 +91,28 @@ class EpicStoreContract:
|
||||
self.assertEqual(store.file(task, "Count more.", "", ()), Failure(f"{task} is neither the epic {store.epic_key} nor one of its child issues, so nothing can be filed under it"))
|
||||
self.assertEqual(len(self.issues(store)), 2)
|
||||
|
||||
def test_files_an_issue_blocked_by_a_child_issue_or_a_sub_task_of_the_epic(self) -> None:
|
||||
store = self.new_store()
|
||||
child = self.filed(store, store.epic_key, "Pin the behaviour.")
|
||||
task = self.filed(store, child, "Pin it in the api.")
|
||||
second = store.file(store.epic_key, "Change the behaviour.", "", (), child)
|
||||
third = store.file(child, "Change it in the api.", "", (), task)
|
||||
assert isinstance(second, str) and isinstance(third, str), (second, third)
|
||||
read = {issue.key: issue for issue in self.issues(store)}
|
||||
self.assertEqual((read[second].blockers, read[third].blockers, read[third].parent), ((child,), (task,), child))
|
||||
|
||||
def test_refuses_to_file_blocked_by_an_issue_outside_the_epic(self) -> None:
|
||||
store = self.new_store()
|
||||
for blocker in ("ZZZ-1", "not a key"):
|
||||
with self.subTest(blocker=blocker):
|
||||
self.assertIsInstance(store.file(store.epic_key, "Count more.", "", (), blocker), Failure)
|
||||
self.assertEqual(self.issues(store), [])
|
||||
|
||||
def test_refuses_to_file_blocked_by_the_epic_itself(self) -> None:
|
||||
store = self.new_store()
|
||||
self.assertIsInstance(store.file(store.epic_key, "Count more.", "", (), store.epic_key), Failure)
|
||||
self.assertEqual(self.issues(store), [])
|
||||
|
||||
def test_refuses_to_file_under_an_issue_outside_the_epic(self) -> None:
|
||||
store = self.new_store()
|
||||
for parent in ("ZZZ-1", "not a key"):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""An epic held in memory, for do-epic's tests, held to contract.py like every backend."""
|
||||
import dataclasses
|
||||
|
||||
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, no_words, unfit, unfit_label
|
||||
from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_words, unfit, unfit_label
|
||||
from failure import Failure
|
||||
|
||||
|
||||
@@ -19,15 +19,18 @@ class MemoryEpic:
|
||||
return Failure(self.fails)
|
||||
return [issue for child in self.issues if child.parent == self.epic_key for issue in (child, *(task for task in self.issues if task.parent == child.key))]
|
||||
|
||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...]) -> str | Failure:
|
||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...], blocked_by: str | None = None) -> str | Failure:
|
||||
if self.fails:
|
||||
return Failure(self.fails)
|
||||
if refused := unfit(summary, labels):
|
||||
return refused
|
||||
if parent != self.epic_key and parent not in {issue.key for issue in self.issues if issue.parent == self.epic_key}:
|
||||
children = {issue.key for issue in self.issues if issue.parent == self.epic_key}
|
||||
if parent != self.epic_key and parent not in children:
|
||||
return no_parent(self.epic_key, parent)
|
||||
if blocked_by is not None and blocked_by not in {issue.key for issue in self.issues if issue.parent == self.epic_key or issue.parent in children}:
|
||||
return no_blocker(self.epic_key, blocked_by)
|
||||
key = f"{self.epic_key.rpartition('-')[0]}-{len(self.issues) + 100}"
|
||||
self.issues.append(EpicIssue(key, summary, detail.strip(), tuple(sorted(labels)), None, "To Do", False, parent, by_loop=True))
|
||||
self.issues.append(EpicIssue(key, summary, detail.strip(), tuple(sorted(labels)), None, "To Do", False, parent, blockers=(blocked_by,) if blocked_by else (), by_loop=True))
|
||||
return key
|
||||
|
||||
def add_label(self, key: str, label: str) -> None | Failure:
|
||||
|
||||
@@ -5,11 +5,11 @@ import typing
|
||||
|
||||
from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused
|
||||
from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
|
||||
from plan_store.jira_epic import BLOCKS, FILED_BY, ISSUE_TYPE, PROPERTY, scores
|
||||
from atlassian.jira import DONE, entry_of, finishing_transition, ISSUE_KEY, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, SHAPE, status_category, unshaped
|
||||
from project_config.settings import Epic, Finish, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION
|
||||
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, no_words, unfit, unfit_label
|
||||
from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_words, unfit, unfit_label
|
||||
from failure import Failure
|
||||
from plan_store.jira_epic import FILED_BY, ISSUE_TYPE, PROPERTY, scores
|
||||
|
||||
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.
|
||||
@@ -57,11 +57,11 @@ class JiraEpic:
|
||||
details = {each.issue.key: text.strip() for each, text in zip(described, texts)}
|
||||
return [dataclasses.replace(each.issue, detail=details.get(each.issue.key, "")) for each in found]
|
||||
|
||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...]) -> str | Failure:
|
||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...], blocked_by: str | None = None) -> str | Failure:
|
||||
authorization = basic_auth(self.env_file)
|
||||
if isinstance(authorization, Failure):
|
||||
return authorization
|
||||
if refused := unfit(summary, labels) or self.not_a_parent(parent, authorization):
|
||||
if refused := unfit(summary, labels) or self.not_a_parent(parent, authorization) or (self.not_a_blocker(blocked_by, authorization) if blocked_by is not None else None):
|
||||
return refused
|
||||
fields: dict[str, typing.Any] = {"project": {"key": project_of(parent)}, "parent": {"key": parent}, "summary": summary, "labels": list(labels)}
|
||||
# Marks the issue as the loop's, as plan_store marks the items it files.
|
||||
@@ -74,7 +74,11 @@ class JiraEpic:
|
||||
if isinstance(description, Failure):
|
||||
return Failure(f"cannot convert the detail to a Jira description: {description.reason}")
|
||||
fields["description"] = description
|
||||
created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, {"fields": fields | {"issuetype": kind}, "properties": properties})
|
||||
body: dict[str, typing.Any] = {"fields": fields | {"issuetype": kind}, "properties": properties}
|
||||
if blocked_by is not None:
|
||||
# Linked as it is created, so no issue is left filed and unblocked. The inward issue blocks the new one.
|
||||
body["update"] = {"issuelinks": [{"add": {"type": {"name": BLOCKS}, "inwardIssue": {"key": blocked_by}}}]}
|
||||
created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, body)
|
||||
if isinstance(created, Failure):
|
||||
return Failure(f"cannot file the issue under {parent}: {created.reason}; {PERHAPS_FILED.format(under=parent)}")
|
||||
key = created.get("key") if isinstance(created, dict) else None
|
||||
@@ -184,6 +188,16 @@ class JiraEpic:
|
||||
above = self.parent_of(parent, authorization, "to file under it")
|
||||
return above if isinstance(above, Failure) else None if above == self.epic_key else no_parent(self.epic_key, parent)
|
||||
|
||||
def not_a_blocker(self, blocker: str, authorization: str) -> Failure | None:
|
||||
"""Why nothing can be filed blocked by blocker; None where it is a child issue of the epic or a sub-task of one."""
|
||||
above = self.parent_of(blocker, authorization, "to file blocked by it")
|
||||
if isinstance(above, Failure):
|
||||
return above
|
||||
if above == self.epic_key:
|
||||
return None
|
||||
grand = None if above is None else self.parent_of(above, authorization, "to file blocked by it")
|
||||
return grand if isinstance(grand, Failure) else None if grand == self.epic_key else no_blocker(self.epic_key, blocker)
|
||||
|
||||
def parent_of(self, key: str, authorization: str, why: str) -> str | None | Failure:
|
||||
"""The key of key's parent issue; None where key isn't an issue key or has no parent. A failed read says "cannot read <key> <why>"."""
|
||||
placed = self.placed(key, authorization, why)
|
||||
|
||||
@@ -51,8 +51,8 @@ class EpicStore(typing.Protocol):
|
||||
def read(self) -> list[EpicIssue] | Failure:
|
||||
"""Each child issue, open or done, in the tracker's rank order, each followed by its sub-tasks in theirs."""
|
||||
|
||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...]) -> str | Failure:
|
||||
"""Files an open issue under parent, marked as filed by the loop, and answers its key: a child issue where parent is the epic, a sub-task where parent is one of its child issues. detail is markdown, and may be empty."""
|
||||
def file(self, parent: str, summary: str, detail: str, labels: tuple[str, ...], blocked_by: str | None = None) -> str | Failure:
|
||||
"""Files an open issue under parent, marked as filed by the loop, and answers its key: a child issue where parent is the epic, a sub-task where parent is one of its child issues. detail is markdown, and may be empty. Where blocked_by names an issue, a child issue of the epic or a sub-task of one, the new issue is blocked by it; any other issue is refused before anything is filed."""
|
||||
|
||||
def add_label(self, key: str, label: str) -> None | Failure:
|
||||
"""Adds label to the epic's child issue named key, leaving its other labels as they are; adding one it already has leaves the labels as they are. A sub-task, or an issue outside the epic, is refused."""
|
||||
@@ -93,6 +93,11 @@ def no_parent(epic_key: str, parent: str) -> Failure:
|
||||
return Failure(f"{parent} is neither the epic {epic_key} nor one of its child issues, so nothing can be filed under it")
|
||||
|
||||
|
||||
def no_blocker(epic_key: str, blocker: str) -> Failure:
|
||||
"""What every backend says when asked to file an issue blocked by blocker, which is neither a child issue of the epic nor a sub-task of one."""
|
||||
return Failure(f"{blocker} is neither a child issue of the epic {epic_key} nor a sub-task of one, so it cannot block a new issue")
|
||||
|
||||
|
||||
def no_child(epic_key: str, key: str, done_to_it: str) -> Failure:
|
||||
"""What every backend says when asked to change key, which is not one of the epic's child issues; done_to_it is the past participle of what was asked, such as "labelled"."""
|
||||
return Failure(f"{key} is not one of the child issues of the epic {epic_key}, so it cannot be {done_to_it}")
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 failure import Failure
|
||||
from plan_store import jira_epic
|
||||
@@ -44,6 +45,14 @@ class Failing(unittest.TestCase):
|
||||
self.assertEqual((store.read(), store.file("ABC-12", "Count the runs.", "", ()), store.add_label("ABC-100", "api"), store.comment("ABC-100", "Hello."), store.rank("ABC-100", "ABC-101")), (down,) * 5)
|
||||
|
||||
|
||||
class Blocking(unittest.TestCase):
|
||||
def test_refuses_a_blocker_that_is_an_issue_of_another_epic(self) -> None:
|
||||
store = MemoryEpic("ABC-12")
|
||||
store.issues.append(EpicIssue("ABC-50", "Elsewhere", "", (), None, "To Do", False, "ABC-99"))
|
||||
self.assertEqual(store.file("ABC-12", "Count more.", "", (), "ABC-50"), no_blocker("ABC-12", "ABC-50"))
|
||||
self.assertEqual(len(store.issues), 1)
|
||||
|
||||
|
||||
class Ranking(unittest.TestCase):
|
||||
def test_refuses_to_rank_beside_an_issue_that_isnt_a_child_of_the_epic(self) -> None:
|
||||
store = MemoryEpic("ABC-12")
|
||||
|
||||
@@ -120,7 +120,9 @@ class FakeJira:
|
||||
if fields["project"] != {"key": "ABC"} or kind is None or fields["issuetype"] != kind:
|
||||
return Failure("Jira answered 400: the project, parent or issue type is not valid")
|
||||
key = f"ABC-{len(self.issues) + 100}"
|
||||
self.issues.append({"key": key, "fields": {"summary": fields["summary"], "description": fields.get("description"), "labels": fields["labels"], "assignee": None, "status": TO_DO, "parent": {"key": parent}, "issuelinks": []}, "properties": {entry["key"]: entry["value"] for entry in body["properties"]}})
|
||||
# The links Jira makes as it creates the issue: the inward issue blocks the new one, which then reads "is blocked by" it.
|
||||
links = [{"id": "1", "type": {"inward": "is blocked by", "outward": "blocks"}, "inwardIssue": add["add"]["inwardIssue"]} for add in body.get("update", {}).get("issuelinks", []) if add["add"]["type"] == {"name": "Blocks"}]
|
||||
self.issues.append({"key": key, "fields": {"summary": fields["summary"], "description": fields.get("description"), "labels": fields["labels"], "assignee": None, "status": TO_DO, "parent": {"key": parent}, "issuelinks": links}, "properties": {entry["key"]: entry["value"] for entry in body["properties"]}})
|
||||
return {"id": "1", "key": key}
|
||||
|
||||
def ranked(self, body: object) -> object:
|
||||
@@ -364,6 +366,15 @@ class Jira(Case):
|
||||
self.assertEqual(store.file("ABC-78", "Count more.", "", ()), Failure("ABC-78 is neither the epic ABC-12 nor one of its child issues, so nothing can be filed under it"))
|
||||
self.assertEqual([call for call in self.jira.calls if call[0] == "POST" and call[1] == ISSUES], [])
|
||||
|
||||
def test_refuses_to_file_blocked_by_a_sub_task_of_another_epics_child_or_an_issue_it_cannot_read(self) -> None:
|
||||
self.jira.issues.extend([{"key": "ABC-6", "fields": {"parent": {"key": "ABC-7"}, "status": TO_DO}}, {"key": "ABC-5", "fields": {"parent": {"key": "ABC-6"}, "status": TO_DO}}])
|
||||
store = self.new_store()
|
||||
self.assertEqual(store.file("ABC-12", "Count more.", "", (), "ABC-5"), Failure("ABC-5 is neither a child issue of the epic ABC-12 nor a sub-task of one, so it cannot block a new issue"))
|
||||
self.assertEqual(store.file("ABC-12", "Count more.", "", (), "ABC-77"), Failure(f"cannot read ABC-77 to file blocked by it: Jira answered 404 for GET {ISSUES}/ABC-77?fields=parent,status"))
|
||||
self.jira.answers[("GET", f"{ISSUES}/ABC-6?fields=parent,status")] = Failure("Jira answered 503")
|
||||
self.assertEqual(store.file("ABC-12", "Count more.", "", (), "ABC-5"), Failure("cannot read ABC-6 to file blocked by it: Jira answered 503"))
|
||||
self.assertEqual([call for call in self.jira.calls if call[0] == "POST" and call[1] == ISSUES], [])
|
||||
|
||||
def test_a_label_jira_refuses_is_not_added(self) -> None:
|
||||
store = self.new_store()
|
||||
key = store.file("ABC-12", "Count the runs.", "", ())
|
||||
|
||||
@@ -5,6 +5,7 @@ from chunk_driver.drivers import DO_EPIC
|
||||
from do_epic.backend.protocol import EpicIssue
|
||||
from do_epic import findings
|
||||
from chunk_driver.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
||||
from do_epic.repo_pick import LabelRepos
|
||||
from text_files.markdown_text import listed
|
||||
import pathlib
|
||||
from project_config.settings import ProjectConfig
|
||||
@@ -18,19 +19,21 @@ DRIVER = DO_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")."""
|
||||
"""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")."""
|
||||
opening = "The issue isn't an item of the repo's plan, so run `chunk-pr merge` without `--finish`."
|
||||
if config.merge == "human":
|
||||
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."
|
||||
if config.epic:
|
||||
return f"{opening} The repo's plan is a Jira epic, and the history of its issues serves as the changelog, so leave the changelog as it is."
|
||||
changelog = config.paths["changelog"].relative_to(config.top) if "changelog" in config.paths and config.paths["changelog"].is_relative_to(config.top) else config.places["changelog"]
|
||||
return f"{opening} Where the repo publishes something others consume, add one bullet to `## Unreleased` in `{changelog}` that tells the repo's consumers what changed; otherwise leave the changelog as it is."
|
||||
|
||||
|
||||
def task(issue: EpicIssue, epic: str, checkout: str | None, launcher: pathlib.Path, language: str, config: ProjectConfig | None) -> str:
|
||||
"""The task of the chunk that works issue, of the epic with the key epic: in checkout, or without a repo where it is None. launcher is the do-epic that runs the chunk, language the one the epic's Jira text is in, and config the project config of the repo's checkout, None without a repo."""
|
||||
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."""
|
||||
shipped = shipping(config) if config else ""
|
||||
where = f"in the checkout {checkout}, on the branch {issue.key}" if checkout else "which changes no repo: work in the folder you start in"
|
||||
return f"Work the Jira issue {issue.key} of the epic {epic} as one chunk, {where}. {" ".join(filter(None, [findings.instructions(epic, launcher, language), shipped]))} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
|
||||
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 "")
|
||||
|
||||
|
||||
CODE_HEALTH = '~/.claude/CLAUDE.md → "Shared goal"'
|
||||
@@ -52,8 +55,8 @@ NAMES = prompts.RecordNames(
|
||||
)
|
||||
WORKER = prompts.worker_prompts(DRIVER, fresh, "", NAMES)
|
||||
|
||||
# What a worker does with a reviewer's feedback, as the decision asks (docs/decisions.md → `do-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 (~/.claude/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.'
|
||||
# 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").
|
||||
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 (~/.claude/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.'
|
||||
|
||||
|
||||
def unparked(news: str) -> WorkerPrompts:
|
||||
|
||||
+29
-2
@@ -8,21 +8,29 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
||||
clone-folder = "~/code"
|
||||
language = "Swedish"
|
||||
|
||||
[label-repos]
|
||||
twu-4 = "tenant-web-ui-4"
|
||||
|
||||
- `jira-url` is the Jira site's address: https, a host, and no path.
|
||||
- `env-file` is the file of Jira credentials: a path that starts with / or ~/, outside every folder of `~/.claude-projects` and outside the clone folder, which hold git checkouts. `~/.claude-projects/<key>.env` is fine.
|
||||
- `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.
|
||||
- `[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.
|
||||
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import re
|
||||
import types
|
||||
|
||||
from project_config.settings import anywhere, CONFIG, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINISH, LANGUAGE, language_fault, lies_in, parsed, PROJECTS, SITE
|
||||
from failure import Failure
|
||||
from do_epic.backend.protocol import LABEL
|
||||
from do_epic.repo_pick import LabelRepos, of_label, REPO_NAME, REVIEW_LABEL
|
||||
from text_files.markdown_text import listed
|
||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||
from do_epic.split import SPLIT_LABEL
|
||||
|
||||
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.
|
||||
@@ -30,7 +38,9 @@ JIRA_URL = "jira-url"
|
||||
REPOLESS_MODEL = "repoless-model"
|
||||
CLONE_FOLDER = "clone-folder"
|
||||
SETTINGS = (JIRA_URL, ENV_FILE, REPOLESS_MODEL)
|
||||
OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH)
|
||||
# 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"
|
||||
OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH, LABEL_REPOS)
|
||||
LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTIONAL, 'and')}."
|
||||
|
||||
|
||||
@@ -46,6 +56,20 @@ class DoEpicConfig:
|
||||
repo_rule: str
|
||||
# How a finished epic closes; None where the config doesn't say.
|
||||
finish: Finish | None = None
|
||||
# The LABEL_REPOS table; empty where the config has none.
|
||||
label_repos: LabelRepos = types.MappingProxyType({})
|
||||
|
||||
|
||||
def label_repo_faults(table: object) -> list[str]:
|
||||
"""What is wrong with the LABEL_REPOS table: each entry whose key isn't a team's label, or whose value isn't a repo's name."""
|
||||
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}` 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))),
|
||||
]
|
||||
|
||||
|
||||
def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
|
||||
@@ -78,10 +102,13 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
||||
*([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []),
|
||||
*([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []),
|
||||
*finish_faults(values),
|
||||
*label_repo_faults(values.get(LABEL_REPOS, {})),
|
||||
*([rule.reason] if isinstance(rule, Failure) else [f"`{REPO_RULE}` is blank"] if not rule.strip() else []),
|
||||
]
|
||||
if faults:
|
||||
return Failure(f"{folder}: {'; '.join(faults)}. {LISTED}")
|
||||
# Without a fault, each value above is present and of the type asserted here.
|
||||
assert clone_folder and env_file and isinstance(url, str) and isinstance(model, str) and isinstance(language, str) and isinstance(rule, str)
|
||||
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values))
|
||||
labels = values.get(LABEL_REPOS, {})
|
||||
assert isinstance(labels, dict)
|
||||
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values), types.MappingProxyType(labels))
|
||||
|
||||
@@ -80,6 +80,7 @@ def run(sandbox: Sandbox, epic_key: str, launcher: pathlib.Path, env: typing.Map
|
||||
return report
|
||||
items_filed(report, store, epic_key)
|
||||
finding_filed(report, machine, store, epic_key)
|
||||
follow_up_filed(report, machine, store, epic_key)
|
||||
decision_recorded(report, machine, record.section, epic_key)
|
||||
closed(report, machine, store, epic_key)
|
||||
return report
|
||||
@@ -111,6 +112,16 @@ def finding_filed(report: Report, machine: DoEpic, store: EpicStore, epic_key: s
|
||||
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:
|
||||
"""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()})")
|
||||
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()})")
|
||||
|
||||
@@ -108,6 +108,49 @@ class FindingFiledTest(unittest.TestCase):
|
||||
self.assertIn("files the finding and says so", report.broke[0])
|
||||
|
||||
|
||||
class FollowUpFiledTest(unittest.TestCase):
|
||||
def store(self) -> MemoryEpic:
|
||||
store = MemoryEpic(EPIC)
|
||||
store.file(EPIC, "Sandbox finding", "", (CLAUDE_LABEL,))
|
||||
return store
|
||||
|
||||
def following(self, store: MemoryEpic, flipped: bool = False) -> typing.Callable[[], subprocess.CompletedProcess[str]]:
|
||||
def answer() -> subprocess.CompletedProcess[str]:
|
||||
key = store.file(EPIC, "Sandbox follow-up finding", "", (CLAUDE_LABEL,), None if flipped else "SBX-100")
|
||||
if flipped:
|
||||
store.change("SBX-100", blockers=(str(key),))
|
||||
return done(0, "Filed SBX-101 in the epic SBX-1. It is blocked by SBX-100.")
|
||||
return answer
|
||||
|
||||
def test_holds_where_the_follow_up_is_blocked_by_the_first_finding(self) -> None:
|
||||
store = self.store()
|
||||
machine = Scripted([self.following(store)])
|
||||
report = scenario.Report()
|
||||
scenario.follow_up_filed(report, machine, store, EPIC)
|
||||
self.assertEqual((report.broke, len(report.held)), ([], 2))
|
||||
self.assertEqual(machine.calls, [((EPIC, findings.FILE, "Sandbox follow-up finding", findings.LABEL, CLAUDE_LABEL, findings.BLOCKED_BY, "SBX-100"), "Waits for the first finding.\n")])
|
||||
|
||||
def test_breaks_where_the_link_points_the_wrong_way(self) -> None:
|
||||
store = self.store()
|
||||
report = scenario.Report()
|
||||
scenario.follow_up_filed(report, Scripted([self.following(store, flipped=True)]), store, EPIC)
|
||||
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:
|
||||
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:
|
||||
report = scenario.Report()
|
||||
scenario.follow_up_filed(report, Scripted([lambda: done(1, err="no")]), self.store(), EPIC)
|
||||
self.assertEqual(len(report.broke), 2)
|
||||
self.assertIn("exit 1: no", report.broke[0])
|
||||
|
||||
|
||||
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."}
|
||||
|
||||
|
||||
+48
-25
@@ -2,13 +2,14 @@
|
||||
|
||||
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."""
|
||||
import contextlib
|
||||
import dataclasses
|
||||
import fcntl
|
||||
import pathlib
|
||||
import typing
|
||||
|
||||
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, of_label, REPO_PREFIX, REVIEW_LABEL
|
||||
from do_epic.repo_pick import also, CLAUDE_LABEL, HUMAN_LABEL, LabelRepos, of_label, REPO_PREFIX, REVIEW_LABEL
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
from do_epic.epic_record import EpicRecord
|
||||
from do_epic.backend.protocol import EpicStore
|
||||
from failure import Failure
|
||||
from text_files.markdown_text import listed
|
||||
from text_files.piped_text import piped
|
||||
@@ -16,29 +17,39 @@ from text_files.piped_text import piped
|
||||
# Three readers, seated as the human and as a chunk's worker, picked each spelling from four: `<EPIC-KEY> --file` over `--file <EPIC-KEY>`, `add` and `--finding`, and `--record-decision` over `--decision` and `--decide`.
|
||||
FILE = "--file"
|
||||
LABEL = "--label"
|
||||
BLOCKED_BY = "--blocked-by"
|
||||
PARENT = "--parent"
|
||||
RECORD_DECISION = "--record-decision"
|
||||
# The labels that say where an issue is worked, as do-epic's scheduler reads them.
|
||||
LABELS = f"`{REPO_PREFIX}<name>` for the repo that works it, `{CLAUDE_LABEL}` for work of Claude's that changes no repo, or `{HUMAN_LABEL}` for a task of the human's"
|
||||
# Under the epic's folder, the file a do-epic holds locked while it appends a decision.
|
||||
DECISIONS_LOCK = "decisions.lock"
|
||||
USAGE = f"""do-epic <EPIC-KEY> {FILE} <summary> [{LABEL} <label>]... [<<'EOF' detail EOF]
|
||||
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"""
|
||||
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 {LABELS}; without one, the next `do-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.
|
||||
A finding about a repo's own goals goes into that repo's plan instead.
|
||||
{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>.
|
||||
Where a repo's rules ask for a change to ship as more than one pull request, file each step after the first with {BLOCKED_BY} set to the step before it.
|
||||
{RECORD_DECISION} appends a decision that governs the epic to its description's ## Decisions, under the title, with the markdown piped in as its text."""
|
||||
|
||||
|
||||
def instructions(epic: str, launcher: pathlib.Path, language: str) -> 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."""
|
||||
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."""
|
||||
next_step = ""
|
||||
if issue:
|
||||
parent = f" {PARENT} {issue.parent}" if issue.parent != epic else ""
|
||||
label = next((f" {LABEL} {each}" for each in issue.labels if of_label(each, team)), "")
|
||||
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 {LABELS}; leave it out where you cannot tell, and the next `do-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. "
|
||||
f"Write the issue and the decision in {language}, the epic's language."
|
||||
f"{next_step}Write the issue and the decision in {language}, the epic's language."
|
||||
)
|
||||
|
||||
|
||||
@@ -51,35 +62,47 @@ def decisions_locked(folder: pathlib.Path) -> typing.Iterator[None]:
|
||||
yield
|
||||
|
||||
|
||||
def parsed(words: list[str]) -> tuple[str, str, tuple[str, ...]] | None:
|
||||
"""What the words after the epic's key ask for: the flag, the summary or title, and each label. None where they aren't spelt as USAGE has them. A word that opens with `--` is no summary, title or label."""
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Write:
|
||||
"""What the words after the epic's key ask for: the flag, and its summary or title. A finding may also carry labels, the issue that blocks it and the child issue it is a sub-task of."""
|
||||
flag: str
|
||||
value: str
|
||||
labels: tuple[str, ...] = ()
|
||||
blocked_by: str | None = None
|
||||
parent: str | None = None
|
||||
|
||||
|
||||
def parsed(words: list[str]) -> Write | None:
|
||||
"""The Write the words after the epic's key ask for. None where they aren't spelt as USAGE has them. A word that opens with `--` is no summary, title, label or key."""
|
||||
if not words or words[0] not in (FILE, RECORD_DECISION):
|
||||
return None
|
||||
labels: list[str] = []
|
||||
taken: dict[str, list[str]] = {LABEL: [], BLOCKED_BY: [], PARENT: []}
|
||||
rest = words[1:]
|
||||
while words[0] == FILE and LABEL in rest:
|
||||
at = rest.index(LABEL)
|
||||
if at + 1 >= len(rest):
|
||||
return None
|
||||
labels.append(rest[at + 1])
|
||||
rest = rest[:at] + rest[at + 2:]
|
||||
if len(rest) != 1 or any(word.startswith("--") for word in (*rest, *labels)):
|
||||
for option in taken if words[0] == FILE else ():
|
||||
while option in rest:
|
||||
at = rest.index(option)
|
||||
if at + 1 >= len(rest):
|
||||
return None
|
||||
taken[option].append(rest[at + 1])
|
||||
rest = rest[:at] + rest[at + 2:]
|
||||
if len(rest) != 1 or len(taken[BLOCKED_BY]) > 1 or len(taken[PARENT]) > 1 or any(word.startswith("--") for word in (*rest, *sum(taken.values(), []))) or any(not word.strip() for option in (BLOCKED_BY, PARENT) for word in taken[option]):
|
||||
return None
|
||||
return words[0], rest[0], tuple(labels)
|
||||
return Write(words[0], rest[0], tuple(taken[LABEL]), *(taken[option][0] if taken[option] else None for option in (BLOCKED_BY, PARENT)))
|
||||
|
||||
|
||||
def written(epic: str, flag: str, value: str, labels: tuple[str, ...], store: EpicStore, record: EpicRecord, stdin: typing.TextIO, folder: pathlib.Path) -> str | Failure:
|
||||
"""Files the finding or records the decision, as flag says, and answers the line to print. folder is the epic's, where the lock for its decisions lies."""
|
||||
def written(epic: str, write: Write, store: EpicStore, team: LabelRepos, record: EpicRecord, stdin: typing.TextIO, folder: pathlib.Path) -> str | Failure:
|
||||
"""Files the finding or records the decision, as write says, and answers the line to print. folder is the epic's, where the lock for its decisions lies."""
|
||||
text = piped(stdin)
|
||||
flag, value, labels = write.flag, write.value, write.labels
|
||||
if flag == FILE:
|
||||
if unread := [label for label in labels if of_label(label) is None and label != REVIEW_LABEL]:
|
||||
return Failure(f"cannot file the finding in the epic {epic}: do-epic doesn't read the label {unread[0]!r}; write {LABELS}")
|
||||
if len(picks := [label for label in labels if of_label(label)]) > 1:
|
||||
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 {LABELS}{also(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(epic, value, text, labels)
|
||||
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} in the epic {epic}." + ("" if any(of_label(label) for label in labels) else f" It has no label that says where it is worked, so the next `do-epic {epic}` picks one: {LABELS}.")
|
||||
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: {LABELS}.")
|
||||
try:
|
||||
with decisions_locked(folder):
|
||||
added = record.append_decision(value, text)
|
||||
|
||||
+12
-12
@@ -15,9 +15,9 @@ from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
from failure import Failure
|
||||
from do_epic import findings
|
||||
from do_epic.split import finished
|
||||
from do_epic.repo_pick import LabelRepos, recorded, Repo, REPO_PREFIX, REVIEW_LABEL
|
||||
from text_files.markdown_text import listed
|
||||
from text_files.piped_text import piped
|
||||
from do_epic.repo_pick import recorded, Repo, REPO_PREFIX, REVIEW_LABEL
|
||||
|
||||
# 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"
|
||||
@@ -38,23 +38,23 @@ def still_open(issues: list[EpicIssue]) -> list[str]:
|
||||
return [issue.key for issue in issues if not finished(issues, issue.key)]
|
||||
|
||||
|
||||
def repo_of(issue: EpicIssue) -> str | None:
|
||||
def repo_of(issue: EpicIssue, team: LabelRepos) -> str | None:
|
||||
"""The name of the repo the issue's labels record; None where they record none."""
|
||||
pick = recorded(issue)
|
||||
pick = recorded(issue, team)
|
||||
return pick.name if isinstance(pick, Repo) else None
|
||||
|
||||
|
||||
def unreviewed(issues: list[EpicIssue]) -> list[str]:
|
||||
def unreviewed(issues: list[EpicIssue], team: LabelRepos) -> list[str]:
|
||||
"""The repos the epic changed that have no release review, sorted. The epic changed a repo where a done issue names it, and a repo has its review once an issue labelled REVIEW_LABEL names it, open or done."""
|
||||
reviewed = {repo_of(issue) for issue in issues if REVIEW_LABEL in issue.labels}
|
||||
changed = {repo_of(issue) for issue in issues if issue.done and REVIEW_LABEL not in issue.labels}
|
||||
reviewed = {repo_of(issue, team) for issue in issues if REVIEW_LABEL in issue.labels}
|
||||
changed = {repo_of(issue, team) for issue in issues if issue.done and REVIEW_LABEL not in issue.labels}
|
||||
return sorted(repo for repo in changed - reviewed if repo is not None)
|
||||
|
||||
|
||||
def task(epic: str, issues: list[EpicIssue], launcher: pathlib.Path, language: str) -> 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."""
|
||||
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):
|
||||
if lacking := unreviewed(issues, team):
|
||||
return (
|
||||
f"{opening} Each repo the epic changed takes a release review first, and {listed(lacking, 'and')} {'has' if len(lacking) == 1 else 'have'} none. "
|
||||
f"File one issue per such repo, with `{launcher} {epic} {findings.FILE} \"<summary>\" {findings.LABEL} {REPO_PREFIX}<name> {findings.LABEL} {REVIEW_LABEL}` and its detail on stdin, both in {language}, the epic's language. "
|
||||
@@ -70,12 +70,12 @@ def task(epic: str, issues: list[EpicIssue], launcher: pathlib.Path, language: s
|
||||
f"Then the chunk is finished: {DRIVER} works the items, and starts this chunk again once the epic holds no open issue.\n"
|
||||
f"3. Once the human has confirmed every goal, write a summary in {language}, the epic's language, for the people who work the epic: what shipped in each repo, and each goal's evidence. "
|
||||
f"Post it and close the epic with `{launcher} {epic} {CLOSE}`, the summary on stdin. That is the chunk's very last step, and the chunk is finished once it succeeds.\n\n"
|
||||
f"{findings.instructions(epic, launcher, language)} Record each goal's confirmation as such a decision.\n\n"
|
||||
"The epic's issues, each done:\n\n" + "\n".join(f"- {issue.key}{f' ({repo})' if (repo := repo_of(issue)) else ''}: {issue.summary}" for issue in issues)
|
||||
f"{findings.instructions(epic, launcher, language, team)} Record each goal's confirmation as such a decision.\n\n"
|
||||
"The epic's issues, each done:\n\n" + "\n".join(f"- {issue.key}{f' ({repo})' if (repo := repo_of(issue, team)) else ''}: {issue.summary}" for issue in issues)
|
||||
)
|
||||
|
||||
|
||||
def closed(epic: str, store: EpicStore, stdin: typing.TextIO) -> str | Failure:
|
||||
def closed(epic: str, store: EpicStore, team: LabelRepos, stdin: typing.TextIO) -> str | Failure:
|
||||
"""Posts the summary piped in on the epic with the key epic and closes it, and answers the line to print; a Failure, with nothing posted, while the epic isn't ready to close."""
|
||||
# Whether the human confirmed each goal isn't checked here: a decision that records it is the worker's own text, so only the task and the judge, who reads the human's answers, can hold the worker to it.
|
||||
issues = store.read()
|
||||
@@ -86,7 +86,7 @@ def closed(epic: str, store: EpicStore, stdin: typing.TextIO) -> str | Failure:
|
||||
return Failure(f"cannot close the epic {epic}: {already.reason if isinstance(already, Failure) else 'it is closed already'}")
|
||||
if waiting := still_open(issues):
|
||||
return Failure(f"cannot close the epic {epic}: {listed(waiting, 'and')} {'is' if len(waiting) == 1 else 'are'} open")
|
||||
if lacking := unreviewed(issues):
|
||||
if lacking := unreviewed(issues, team):
|
||||
return Failure(f"cannot close the epic {epic}: no issue labelled {REVIEW_LABEL} reviews {listed(lacking, 'or')}")
|
||||
done = store.close(piped(stdin))
|
||||
return Failure(f"cannot close the epic {epic}: {done.reason}") if isinstance(done, Failure) else f"Posted the summary on the epic {epic} and closed it."
|
||||
|
||||
+14
-6
@@ -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").
|
||||
|
||||
A gate is something only time or a person passes: checks that still run, an approval a reviewer has yet to give, or the new review of a reviewer whose requested changes the worker answered. 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 do-epic parks the chunk (`parked`). Anything else is news the worker acts on."""
|
||||
import dataclasses
|
||||
import typing
|
||||
|
||||
@@ -13,6 +13,7 @@ from forge.commands import forge_of, Run
|
||||
CHECKS = "its checks"
|
||||
APPROVAL = "an approval"
|
||||
NEW_REVIEW = "a new review"
|
||||
MERGE = "your merge"
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -22,7 +23,7 @@ class Gate:
|
||||
worktree: str
|
||||
# The pull request's number.
|
||||
pull: str
|
||||
# CHECKS, APPROVAL or NEW_REVIEW.
|
||||
# CHECKS, APPROVAL, NEW_REVIEW or MERGE.
|
||||
on: str
|
||||
|
||||
|
||||
@@ -33,10 +34,15 @@ class Open:
|
||||
news: str
|
||||
|
||||
|
||||
def gate(branch: str, checkout: str, at: typing.Callable[[str], Run]) -> Gate | Open | Failure:
|
||||
"""What the chunk on branch waits on, in a worktree of checkout; at gives the runner of commands in a folder. A Failure where git or the forge cannot be read, which doesn't say anything about the gate.
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Unopened(Open):
|
||||
"""An Open whose worktree stands though no pull request is open at its head: one that was merged or closed, whose chunk still has its worktree to remove."""
|
||||
|
||||
A draft never waits on a gate: its worker still works on it. On Gitea only the checks are a gate, since chunk-pr reads approvals on GitHub only (`chunk_pr.approval.awaited`). Changes a reviewer requested are news until the worker answered them (`forge.reviews.answered`); from then on the pull request awaits a new review.
|
||||
|
||||
def gate(branch: str, checkout: str, at: typing.Callable[[str], Run], by_human: bool) -> Gate | Open | Failure:
|
||||
"""What the chunk on branch waits on, in a worktree of checkout; at gives the runner of commands in a folder, and by_human says the project's config leaves the merge to a person (`merge = "human"`). A Failure where git or the forge cannot be read, which doesn't say anything about the gate.
|
||||
|
||||
A draft never waits on a gate: its worker still works on it. On Gitea only the checks are a gate, since chunk-pr reads approvals on GitHub only (`chunk_pr.approval.awaited`). Changes a reviewer requested are news until the worker answered them (`forge.reviews.answered`); from then on the pull request awaits a new review. Where a person merges, a pull request with nothing else to wait on awaits that merge, and the chunk has news again once the pull request is no longer open.
|
||||
"""
|
||||
worktree = worktree_of(branch, at(checkout))
|
||||
if not isinstance(worktree, str):
|
||||
@@ -50,7 +56,7 @@ def gate(branch: str, checkout: str, at: typing.Callable[[str], Run]) -> Gate |
|
||||
forge = forge_of(origin)
|
||||
pull = open_pull(forge, branch, head, run)
|
||||
if not isinstance(pull, str):
|
||||
return pull or Open(f"no pull request from origin's {branch} is open at {head[:12]}; it may be merged or closed already")
|
||||
return pull or Unopened(f"no pull request from origin's {branch} is open at {head[:12]}; it may be merged or closed already")
|
||||
decision = review_decision(forge, pull, head, run)
|
||||
if not isinstance(decision, str):
|
||||
return decision or Open(f"pull request #{pull} is a draft")
|
||||
@@ -71,6 +77,8 @@ def gate(branch: str, checkout: str, at: typing.Callable[[str], Run]) -> Gate |
|
||||
return Open(f"a reviewer's comment on pull request #{pull} waits for an answer, in {', '.join(waiting)}")
|
||||
if decision in (ANSWERED, REVIEW_REQUIRED):
|
||||
return Gate(worktree, pull, NEW_REVIEW if decision == ANSWERED else APPROVAL)
|
||||
if by_human:
|
||||
return Gate(worktree, pull, MERGE)
|
||||
return Open(f"pull request #{pull} passed its checks" + (" and is approved" if decision == APPROVED else ""))
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from project_config.settings import by_name, ProjectConfig
|
||||
from loop_effects.effects import Effects, say
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
from failure import Failure
|
||||
from do_epic.repo_pick import recorded, Repo
|
||||
from do_epic.repo_pick import LabelRepos, recorded, Repo
|
||||
from do_epic import scheduler
|
||||
from agent_cycle.direct_message import tell
|
||||
from agent_cycle import tmux
|
||||
@@ -16,9 +16,9 @@ from agent_cycle import tmux
|
||||
AWAITS = "a human's task"
|
||||
|
||||
|
||||
def holds_up(key: str, issues: list[EpicIssue]) -> list[str]:
|
||||
def holds_up(key: str, issues: list[EpicIssue], team: LabelRepos) -> list[str]:
|
||||
"""The keys of the open issues that the human's task called key holds up; none where it is no such task, is closed, or an issue blocks it."""
|
||||
if not any(chunk.human and chunk.issue == key for chunk in scheduler.chunks(issues)[0]):
|
||||
if not any(chunk.human and chunk.issue == key for chunk in scheduler.chunks(issues, team)[0]):
|
||||
return []
|
||||
return scheduler.held_up(issues)[key]
|
||||
|
||||
@@ -27,17 +27,17 @@ 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."
|
||||
|
||||
|
||||
def notifier_checkout(issues: list[EpicIssue], home: pathlib.Path) -> str | None:
|
||||
def notifier_checkout(issues: list[EpicIssue], team: LabelRepos, home: pathlib.Path) -> str | None:
|
||||
"""The checkout of the first of issues whose repo has a git checkout and a project config that names a notifier: where the DM finds that notifier, since the window runs in no checkout. None where there is none."""
|
||||
for issue in issues:
|
||||
pick = recorded(issue)
|
||||
pick = recorded(issue, team)
|
||||
found = by_name(pick.name, home) if isinstance(pick, Repo) else None
|
||||
if isinstance(found, ProjectConfig) and found.notifier and (found.top / ".git").exists():
|
||||
return str(found.top)
|
||||
return None
|
||||
|
||||
|
||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, window: tmux.Window, poll: int, home: pathlib.Path, effects: Effects) -> None:
|
||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, window: tmux.Window, poll: int, home: pathlib.Path, effects: Effects) -> None:
|
||||
"""Waits in window for the human to close the human's task `task` of the epic called epic, and returns once it no longer holds up any issue. A read of the epic that fails is said once and tried again."""
|
||||
tmux.park(window, AWAITS, effects.tmux)
|
||||
told, said = False, None
|
||||
@@ -47,13 +47,13 @@ def awaited(task: EpicIssue, epic: str, store: EpicStore, window: tmux.Window, p
|
||||
if issues.reason != said:
|
||||
say(f"cannot read the epic, so cannot tell whether {task.key} is closed; trying again every {poll} seconds: {issues.reason}", effects, stdout=True)
|
||||
said = issues.reason
|
||||
elif not (held := holds_up(task.key, issues)):
|
||||
elif not (held := holds_up(task.key, issues, team)):
|
||||
return
|
||||
elif not told:
|
||||
text = message(task, epic, held)
|
||||
say(text, effects, stdout=True)
|
||||
# The issues it holds up come first; any other issue of the epic may do where they have no repo with a notifier.
|
||||
where = notifier_checkout(sorted(issues, key=lambda issue: issue.key not in held), home)
|
||||
where = notifier_checkout(sorted(issues, key=lambda issue: issue.key not in held), team, home)
|
||||
if where is None:
|
||||
say("no DM went out: no issue of the epic has a repo whose project config names a notifier and whose checkout exists", effects, stdout=True)
|
||||
told = where is None or tell(text, effects, where)
|
||||
|
||||
+95
-47
@@ -46,7 +46,9 @@ HELP = f"""usage: do-epic <EPIC-KEY> [--status]
|
||||
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.
|
||||
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 you close the issue in Jira.
|
||||
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.
|
||||
It then puts the scored issues that do-epic itself filed in order of score, by the `Score = ...` line under the epic's ## Scoring.
|
||||
An open issue labelled `repo:<name>` or `do-epic-claude` runs as a chunk once no issue blocks it.
|
||||
@@ -56,7 +58,8 @@ A repo takes as many chunks as its `parallel-chunks`, and none while loop-claude
|
||||
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`. A parked chunk survives a reboot: run do-epic <EPIC-KEY> again to go on polling.
|
||||
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`, and its worker goes on once you merged it. A parked chunk survives a reboot: run do-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.
|
||||
{findings.HELP}
|
||||
{finish.HELP}
|
||||
@@ -139,17 +142,17 @@ 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."""
|
||||
issues = epic.store.read()
|
||||
lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.effects.tmux)
|
||||
lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.config.label_repos, epic.effects.tmux)
|
||||
return Stop(1, lines.reason) if isinstance(lines, Failure) else Stop(0, "\n".join(lines) or f"the epic {epic.key} has no open issue")
|
||||
|
||||
|
||||
def epic_written(key: str, writes: tuple[str, str, tuple[str, ...]] | None, paths: Paths, backend: Backend, stdin: typing.TextIO) -> Stop:
|
||||
def epic_written(key: str, writes: findings.Write | None, paths: Paths, backend: Backend, stdin: typing.TextIO) -> Stop:
|
||||
"""Files a finding in the epic or records a decision in its description, as writes says; closes the epic where writes is None. It needs no tmux, so a chunk's worker may run it anywhere."""
|
||||
config = load(paths.home)
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
store, record = backend(config, key)
|
||||
done = findings.written(key, *writes, store, record, stdin, paths.home / scheduler.STATE / key) if writes else finish.closed(key, store, stdin)
|
||||
done = findings.written(key, writes, store, config.label_repos, record, stdin, paths.home / scheduler.STATE / key) if writes else finish.closed(key, store, config.label_repos, stdin)
|
||||
return Stop(1, done.reason) if isinstance(done, Failure) else Stop(0, done)
|
||||
|
||||
|
||||
@@ -208,7 +211,7 @@ def scheduled_epic(epic: EpicRun) -> scheduler.Epic | Failure:
|
||||
seen.append(found.checkout)
|
||||
return real(found.checkout), found.config.parallel_chunks
|
||||
|
||||
return scheduler.Epic(epic.key, cap, located, epic.paths.home, epic.launcher, epic.env)
|
||||
return scheduler.Epic(epic.key, cap, located, epic.paths.home, epic.launcher, epic.env, epic.config.label_repos)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -244,8 +247,8 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
||||
issue = None if key == epic.key else issue_read(key, epic)
|
||||
if isinstance(issue, Stop):
|
||||
return issue
|
||||
if issue and isinstance(recorded(issue), HumanTask):
|
||||
human_tasks.awaited(issue, epic.key, epic.store, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.effects)
|
||||
if issue and isinstance(recorded(issue, epic.config.label_repos), HumanTask):
|
||||
human_tasks.awaited(issue, epic.key, epic.store, epic.config.label_repos, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.effects)
|
||||
return handed_on(key, epic)
|
||||
place = chunk_root(key, issue, epic)
|
||||
if isinstance(place, Stop):
|
||||
@@ -257,7 +260,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
||||
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.
|
||||
news = parked_through(repo, loop, epic, starts=True) if repo is not None else ""
|
||||
news = parked_through(repo, loop, epic, told=None, finished=False) if repo is not None else ""
|
||||
while True:
|
||||
if isinstance(news, Stop):
|
||||
return news
|
||||
@@ -275,14 +278,16 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
||||
if isinstance(closed, Stop):
|
||||
return closed
|
||||
run = closed
|
||||
news = parked_through(repo, loop, epic, starts=False) if repo is not None else ""
|
||||
news = parked_through(repo, loop, epic, told=news, finished=isinstance(concluded.verdict, Finished)) if repo is not None else ""
|
||||
# A chunk that was parked has work again, whatever the judge ruled before its pull request passed the gate.
|
||||
if isinstance(concluded.verdict, Finished) and news == "":
|
||||
return handed_on(key, epic)
|
||||
|
||||
|
||||
def parked_through(repo: str, loop: Loop, epic: EpicRun, starts: bool) -> str | Stop:
|
||||
"""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. starts says the window just started, where the chunk is parked only if its file says so: the forge isn't read for a chunk that starts afresh.
|
||||
def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finished: bool) -> str | Stop:
|
||||
"""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. 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. 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, and a pull request no longer open, in a worktree that still stands, is news the worker hasn't been told: the worker removes the worktree.
|
||||
|
||||
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.
|
||||
"""
|
||||
@@ -290,46 +295,89 @@ def parked_through(repo: str, loop: Loop, epic: EpicRun, starts: bool) -> str |
|
||||
recorded_as = parked.parked_chunks(folder)
|
||||
if isinstance(recorded_as, Failure):
|
||||
return Stop(1, recorded_as.reason)
|
||||
if starts and key not in recorded_as:
|
||||
return ""
|
||||
# What the chunk is parked on; None while it isn't parked.
|
||||
on = recorded_as[key].on if key in recorded_as else None
|
||||
# What the window's name says the chunk awaits, and the last reason said for staying parked.
|
||||
shown = said = None
|
||||
config = config_located(loop.root, epic.paths.home)
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
poll = Poll(key, repo, config.merge == "human", folder, loop, epic)
|
||||
if key in recorded_as:
|
||||
return resumed_news(poll, recorded_as[key].on, shown=None)
|
||||
entered = None if told is None else poll.first_gate(again=finished)
|
||||
if not isinstance(entered, gates.Gate):
|
||||
if isinstance(entered, Failure):
|
||||
say(f"cannot tell whether the chunk's pull request waits on a gate, so the chunk isn't parked: {entered.reason}", epic.effects, stdout=True)
|
||||
uncleaned = f"{chunk_prompt.DRIVER} keeps the chunk open while its worktree stands: {entered.news}." if finished and poll.by_human and isinstance(entered, gates.Unopened) else ""
|
||||
return "" if uncleaned in (told or "") else uncleaned
|
||||
if failed := poll.record(entered):
|
||||
return Stop(1, failed.reason)
|
||||
tmux.park(loop.window, entered.on, epic.effects.tmux)
|
||||
# Once the window shows as parked, so the chunks that start count it as running nowhere.
|
||||
issues = epic.store.read()
|
||||
started = issues if isinstance(issues, Failure) else chunks_started(epic, issues, key)
|
||||
say(f"could not start the next chunk: {started.reason}" if isinstance(started, Failure) else f"started {', '.join(started.started) or 'no other'}", epic.effects, stdout=True)
|
||||
epic.effects.sleep(POLL_SECONDS)
|
||||
return resumed_news(poll, entered.on, shown=entered.on)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Poll:
|
||||
"""What each read of a parked chunk's gate needs: the chunk's key, the repo its work is in, whether a person merges its pull request, the folder of the epic's parked chunks, and the chunk's loop and epic."""
|
||||
key: str
|
||||
repo: str
|
||||
by_human: bool
|
||||
folder: pathlib.Path
|
||||
loop: Loop
|
||||
epic: EpicRun
|
||||
|
||||
def gate(self) -> gates.Gate | gates.Open | Failure:
|
||||
return gates.gate(self.key, self.loop.root, self.epic.forge_at, self.by_human)
|
||||
|
||||
def first_gate(self, again: bool) -> gates.Gate | gates.Open | Failure:
|
||||
"""The gate as a cycle ends. Where again holds and a person merges, one that cannot be read is read again every POLL_SECONDS until it can."""
|
||||
now = self.gate()
|
||||
if not again:
|
||||
return now
|
||||
if self.by_human and isinstance(now, Failure):
|
||||
say(f"cannot read the gate of a pull request a person merges: {now.reason}; trying again every {POLL_SECONDS} seconds", self.epic.effects, stdout=True)
|
||||
while self.by_human and isinstance(now, Failure):
|
||||
self.epic.effects.sleep(POLL_SECONDS)
|
||||
now = self.gate()
|
||||
return now
|
||||
|
||||
def record(self, gate: gates.Gate) -> Failure | None:
|
||||
"""Writes the chunk's file as parked on gate, and says so."""
|
||||
failed = parked.park(self.folder, parked.Parked(self.key, gate.worktree, gate.pull, str(self.loop.session.id), gate.on))
|
||||
if failed is None:
|
||||
say(f"parked: pull request #{gate.pull} awaits {gate.on}", self.epic.effects, stdout=True)
|
||||
return failed
|
||||
|
||||
|
||||
def resumed_news(poll: Poll, on: str, shown: str | None) -> str | Stop:
|
||||
"""Reads the gate of the parked chunk every POLL_SECONDS until its worker has something to do and a running slot is free, then removes its file: what to tell that worker. on is the gate the chunk's file says it is parked on, and shown what its window's name says it awaits, None where nothing yet. A gate that cannot be read leaves the chunk parked as it was."""
|
||||
# The last reason said for staying parked.
|
||||
said = None
|
||||
while True:
|
||||
now = gates.gate(key, loop.root, epic.forge_at)
|
||||
if on is None and not isinstance(now, gates.Gate):
|
||||
if isinstance(now, Failure):
|
||||
say(f"cannot tell whether the chunk's pull request waits on a gate, so the chunk isn't parked: {now.reason}", epic.effects, stdout=True)
|
||||
return ""
|
||||
stays = None
|
||||
if isinstance(now, gates.Gate) and now.on != on:
|
||||
failed = parked.park(folder, parked.Parked(key, now.worktree, now.pull, str(loop.session.id), now.on))
|
||||
if failed is not None:
|
||||
return Stop(1, failed.reason)
|
||||
say(f"parked: pull request #{now.pull} awaits {now.on}", epic.effects, stdout=True)
|
||||
now = poll.gate()
|
||||
if isinstance(now, gates.Gate):
|
||||
awaits, stays = now.on, None
|
||||
if now.on != on:
|
||||
if failed := poll.record(now):
|
||||
return Stop(1, failed.reason)
|
||||
on = now.on
|
||||
elif isinstance(now, Failure):
|
||||
stays = f"cannot read the gate: {now.reason}"
|
||||
elif isinstance(now, gates.Open):
|
||||
full = resumed(repo, loop, epic)
|
||||
awaits, stays = shown or on, f"cannot read the gate: {now.reason}"
|
||||
else:
|
||||
full = resumed(poll.repo, poll.loop, poll.epic)
|
||||
if full is None:
|
||||
failed = parked.unpark(folder, key)
|
||||
return Stop(1, failed.reason) if failed is not None else f"{DRIVER_PARKED} its pull request awaited {on}. It resumes now: {now.news}."
|
||||
stays = f"{now.news}, but the chunk stays parked: {full}"
|
||||
awaits = parked.SLOT if isinstance(now, gates.Open) else now.on if isinstance(now, gates.Gate) else shown or on
|
||||
failed = parked.unpark(poll.folder, poll.key)
|
||||
return Stop(1, failed.reason) if failed is not None else f"{DRIVER_PARKED} its pull request awaited {"a person's merge" if on == gates.MERGE else on}. It resumes now: {now.news}."
|
||||
awaits, stays = parked.SLOT, f"{now.news}, but the chunk stays parked: {full}"
|
||||
if awaits != shown:
|
||||
tmux.park(loop.window, str(awaits), epic.effects.tmux)
|
||||
tmux.park(poll.loop.window, awaits, poll.epic.effects.tmux)
|
||||
shown = awaits
|
||||
if on is None:
|
||||
# Once the window shows as parked, so the chunks that start count it as running nowhere.
|
||||
issues = epic.store.read()
|
||||
started = issues if isinstance(issues, Failure) else chunks_started(epic, issues, key)
|
||||
say(f"could not start the next chunk: {started.reason}" if isinstance(started, Failure) else f"started {', '.join(started.started) or 'no other'}", epic.effects, stdout=True)
|
||||
on = now.on if isinstance(now, gates.Gate) else on
|
||||
if stays is not None and stays != said:
|
||||
say(f"{stays}; trying again every {POLL_SECONDS} seconds", epic.effects, stdout=True)
|
||||
say(f"{stays}; trying again every {POLL_SECONDS} seconds", poll.epic.effects, stdout=True)
|
||||
said = stays
|
||||
epic.effects.sleep(POLL_SECONDS)
|
||||
poll.epic.effects.sleep(POLL_SECONDS)
|
||||
|
||||
|
||||
# How the news for a chunk that was parked opens.
|
||||
@@ -355,7 +403,7 @@ def issue_read(key: str, epic: EpicRun) -> EpicIssue | Stop:
|
||||
|
||||
def chunk_root(key: str, issue: EpicIssue | None, epic: EpicRun) -> tuple[str, str | None] | Stop:
|
||||
"""The folder the chunk called key works in, and the name of the repo whose checkout it is: None for the epic's folder, which holds work without a repo, as the epic's finishing is. issue is None for the epic's finishing. The chunk keeps both to its end, whatever its issue's labels become. The stop where the labels make the issue no chunk."""
|
||||
pick = recorded(issue) if issue else ClaudeWork()
|
||||
pick = recorded(issue, epic.config.label_repos) if issue else ClaudeWork()
|
||||
if isinstance(pick, Failure):
|
||||
return Stop(1, pick.reason)
|
||||
if isinstance(pick, ClaudeWork):
|
||||
@@ -445,13 +493,13 @@ def chunk_work(key: str, checkout: str | None, language: str, epic: EpicRun) ->
|
||||
config = config_located(checkout, epic.paths.home) if checkout else None
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
return chunk_prompt.task(issue, epic.key, checkout, epic.launcher, language, config), RoutingIssue(issue) if "L" in issue.scores else None
|
||||
return chunk_prompt.task(issue, epic.key, epic.config.label_repos, checkout, epic.launcher, language, config), RoutingIssue(issue) if "L" in issue.scores else None
|
||||
issues = epic.store.read()
|
||||
if isinstance(issues, Failure):
|
||||
return Stop(1, issues.reason)
|
||||
if not finish.due(issues):
|
||||
return EpicReopened()
|
||||
return finish.task(epic.key, issues, epic.launcher, language), None
|
||||
return finish.task(epic.key, issues, epic.config.label_repos, epic.launcher, language), None
|
||||
|
||||
|
||||
def repoless_models(epic: EpicRun) -> Models:
|
||||
|
||||
@@ -24,7 +24,7 @@ class Parked:
|
||||
pull: str
|
||||
# The ID of its worker's claude session, which `claude --resume` takes.
|
||||
session: str
|
||||
# What its pull request waits on, as the words after "awaits" (`gates.CHECKS`, `gates.APPROVAL`, `gates.NEW_REVIEW`).
|
||||
# What its pull request waits on, as the words after "awaits" (`gates.CHECKS`, `gates.APPROVAL`, `gates.NEW_REVIEW`, `gates.MERGE`).
|
||||
on: str
|
||||
|
||||
def waits(self, shown: str) -> str:
|
||||
|
||||
+10
-10
@@ -44,8 +44,8 @@ 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 is split or gets its pick. Then the issues do-epic filed are re-ranked. What was labelled, filed 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 split.SPLIT_LABEL not in issue.labels and repo_pick.recorded(issue) is None]
|
||||
Each open child issue that no label places, and that isn't split already, is split or gets its pick. Then the issues do-epic filed are re-ranked. What was labelled, filed 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
|
||||
if added:
|
||||
@@ -79,7 +79,7 @@ def placed(epic: Planned, issues: list[EpicIssue], unplaced: list[EpicIssue], ad
|
||||
rung = planning_rung(epic.config.repoless_model)
|
||||
language = epic.record.language()
|
||||
# Claude reads every repo a label of the epic names, a finished issue's too, to predict which of them an issue changes.
|
||||
places = located(epic, [repo for issue in issues if isinstance(repo := repo_pick.recorded(issue), repo_pick.Repo)])
|
||||
places = located(epic, [repo for issue in issues if isinstance(repo := repo_pick.recorded(issue, epic.config.label_repos), repo_pick.Repo)])
|
||||
if failed := next((each for each in (rung, language, places) if isinstance(each, Failure)), None):
|
||||
return failed
|
||||
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(places, dict)
|
||||
@@ -88,12 +88,12 @@ def placed(epic: Planned, issues: list[EpicIssue], unplaced: list[EpicIssue], ad
|
||||
checkouts = tuple(str(place.checkout) for place in places.values())
|
||||
for issue in unplaced:
|
||||
say(f"planning {issue.key}", epic.effects, stdout=True)
|
||||
parts = split.split(epic.store, issue, not issue.by_loop, epic.config.repo_rule, language or epic.config.language, checkouts, rung, epic.effects.claude, str(folder))
|
||||
parts = split.split(epic.store, issue, epic.config.label_repos, not issue.by_loop, epic.config.repo_rule, language or epic.config.language, checkouts, rung, epic.effects.claude, str(folder))
|
||||
if isinstance(parts, split.Split) and parts.repos:
|
||||
added[issue.key] = split.SPLIT_LABEL
|
||||
say(f"{issue.key} is split into a sub-task for each of {', '.join(parts.repos)}", epic.effects, stdout=True)
|
||||
continue
|
||||
pick: repo_pick.Pick | repo_pick.Unclear | Failure | Limited | None = parts if not isinstance(parts, split.Split) else repo_pick.picked(epic.store, issue, epic.config.repo_rule, rung, epic.effects.claude, str(folder))
|
||||
pick: repo_pick.Pick | repo_pick.Unclear | Failure | Limited | None = parts if not isinstance(parts, split.Split) else repo_pick.picked(epic.store, issue, epic.config.label_repos, epic.config.repo_rule, rung, epic.effects.claude, str(folder))
|
||||
if isinstance(pick, repo_pick.Unclear):
|
||||
pick = answered(epic, issue, pick.question)
|
||||
if isinstance(pick, Limited):
|
||||
@@ -125,16 +125,16 @@ def answered(epic: Planned, issue: EpicIssue, question: str) -> repo_pick.Pick |
|
||||
say(f"\n{issue.key}, {issue.summary}: {question}", epic.effects)
|
||||
while True:
|
||||
try:
|
||||
typed = epic.effects.input(f"The label that says where {issue.key} is worked, `{repo_pick.REPO_PREFIX}<name>`, `{repo_pick.CLAUDE_LABEL}` or `{repo_pick.HUMAN_LABEL}`, or Enter alone to leave it waiting: ")
|
||||
typed = epic.effects.input(f"The label that says where {issue.key} is worked, `{repo_pick.REPO_PREFIX}<name>`, `{repo_pick.CLAUDE_LABEL}` or `{repo_pick.HUMAN_LABEL}`{repo_pick.also(epic.config.label_repos)}, or Enter alone to leave it waiting: ")
|
||||
except EOFError:
|
||||
return None
|
||||
label = typed.strip()
|
||||
if not label:
|
||||
return None
|
||||
pick = repo_pick.of_label(label)
|
||||
pick = repo_pick.of_label(label, epic.config.label_repos)
|
||||
if pick is not None:
|
||||
return repo_pick.record(epic.store, issue, pick)
|
||||
named = f"; the repo {label}'s label is `{repo_pick.REPO_PREFIX}{label}`" if repo_pick.of_label(repo_pick.REPO_PREFIX + label) else ""
|
||||
named = f"; the repo {label}'s label is `{repo_pick.REPO_PREFIX}{label}`" if repo_pick.of_label(repo_pick.REPO_PREFIX + label, {}) else ""
|
||||
say(f"`{label}` is none of those labels{named}", epic.effects)
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ def ranked_keys(epic: Planned, issues: list[EpicIssue]) -> list[str] | Failure:
|
||||
"""The keys of the open child issues do-epic filed that hold scores and one pick, in the order ranking gives them; empty where fewer than two do, since one issue has no order.
|
||||
|
||||
Every other issue keeps its position: a person's issue, one nobody scored, one with no pick yet or with two, and an item split by repo, since several repos' goals would score it."""
|
||||
ours = [issue for issue in issues if issue.parent == epic.key and issue.by_loop and not issue.done and split.SPLIT_LABEL not in issue.labels and (pick := repo_pick.recorded(issue)) is not None and not isinstance(pick, Failure) and not ranking.unscored(item_of(issue, {}), issue.key)]
|
||||
ours = [issue for issue in issues if issue.parent == epic.key and issue.by_loop and not issue.done and not split.is_split(issue, issues) and (pick := repo_pick.recorded(issue, epic.config.label_repos)) is not None and not isinstance(pick, Failure) and not ranking.unscored(item_of(issue, {}), issue.key)]
|
||||
if len(ours) < 2:
|
||||
return []
|
||||
numbers = {issue.key: number(issue.key) for issue in ours}
|
||||
@@ -167,7 +167,7 @@ def ranked_keys(epic: Planned, issues: list[EpicIssue]) -> list[str] | Failure:
|
||||
formulas = FORMULA.findall(scoring)
|
||||
if len(formulas) != 1:
|
||||
return Failure(f"the epic {epic.key}'s description states `Score = ...` {len(formulas)} 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)`")
|
||||
picks = {issue.key: repo_pick.recorded(issue) for issue in ours}
|
||||
picks = {issue.key: repo_pick.recorded(issue, epic.config.label_repos) for issue in ours}
|
||||
places = located(epic, [pick for pick in picks.values() if isinstance(pick, repo_pick.Repo)])
|
||||
if isinstance(places, Failure):
|
||||
return places
|
||||
|
||||
@@ -4,6 +4,7 @@ An item is worked in a repo, or has no repo and is either Claude's work, done wi
|
||||
import dataclasses
|
||||
import json
|
||||
import re
|
||||
import typing
|
||||
|
||||
from claude_code.reply import Claude, claude_reply, Limited
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
@@ -20,6 +21,9 @@ REVIEW_LABEL = "do-epic-release-review"
|
||||
# A repo's name is a folder name and part of a clone address, so claude's answer or a label a person typed must not hold a slash, a colon or a leading dot.
|
||||
REPO_NAME = re.compile(r"\w[\w.-]*")
|
||||
|
||||
# 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).
|
||||
LabelRepos = typing.Mapping[str, str]
|
||||
|
||||
PICK_SCHEMA = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -61,15 +65,23 @@ def label_of(pick: Pick) -> str:
|
||||
return f"{REPO_PREFIX}{pick.name}" if isinstance(pick, Repo) else CLAUDE_LABEL if isinstance(pick, ClaudeWork) else HUMAN_LABEL
|
||||
|
||||
|
||||
def recorded(issue: EpicIssue) -> Pick | None | Failure:
|
||||
"""The pick the issue's labels record; None where they record no pick, a Failure where they record more than one."""
|
||||
picks = [pick for label in issue.labels if (pick := of_label(label)) is not None]
|
||||
if len(picks) > 1:
|
||||
return Failure(f"{issue.key} is labelled with {len(picks)} picks: {', '.join(label_of(pick) for pick in picks)}; remove all but the right one")
|
||||
return picks[0] if picks else None
|
||||
def recorded(issue: EpicIssue, team: LabelRepos) -> Pick | None | Failure:
|
||||
"""The pick the issue's labels record; None where they record no pick, a Failure where they record more than one. Two labels that name one repo, such as the team's and `repo:<name>`, record one pick."""
|
||||
picks = {label: pick for label in issue.labels if (pick := of_label(label, team)) is not None}
|
||||
if len(set(picks.values())) > 1:
|
||||
return Failure(f"{issue.key} is labelled with {len(set(picks.values()))} picks: {', '.join(picks)}; remove the labels of all but the right one")
|
||||
return next(iter(picks.values()), None)
|
||||
|
||||
|
||||
def of_label(label: str) -> Pick | None:
|
||||
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."""
|
||||
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."""
|
||||
if label in team:
|
||||
return Repo(team[label])
|
||||
if label == CLAUDE_LABEL:
|
||||
return ClaudeWork()
|
||||
if label == HUMAN_LABEL:
|
||||
@@ -77,9 +89,9 @@ def of_label(label: str) -> Pick | None:
|
||||
return Repo(label[len(REPO_PREFIX):]) if label.startswith(REPO_PREFIX) and REPO_NAME.fullmatch(label[len(REPO_PREFIX):]) else None
|
||||
|
||||
|
||||
def picked(store: EpicStore, issue: EpicIssue, rule: str, rung: Rung, claude: Claude, cwd: str) -> Pick | Unclear | Failure | Limited:
|
||||
def picked(store: EpicStore, issue: EpicIssue, team: LabelRepos, rule: str, rung: Rung, claude: Claude, cwd: str) -> Pick | Unclear | Failure | Limited:
|
||||
"""The pick for a child issue of the epic: the one its labels record, else claude's by rule, recorded on the issue. An unclear pick is not recorded; the human's answer is, with record."""
|
||||
known = recorded(issue)
|
||||
known = recorded(issue, team)
|
||||
if known is not None:
|
||||
return known
|
||||
reply = claude_reply(claude, ["--json-schema", json.dumps(PICK_SCHEMA), *rung.flags(), "--tools", ""], cwd, prompt(rule, issue), "the repo pick")
|
||||
|
||||
+32
-21
@@ -9,11 +9,11 @@ from do_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 failure import Failure
|
||||
from do_epic.repo_pick import HumanTask, recorded, Repo
|
||||
from do_epic.split import finished, is_split
|
||||
from do_epic.repo_pick import HumanTask, LabelRepos, Pick, recorded, Repo
|
||||
from project_config.settings import PARALLEL_CHUNKS
|
||||
from do_epic.parked import parked_chunks
|
||||
from chunk_pr.approval import PARKS
|
||||
from do_epic.split import SPLIT_LABEL
|
||||
from agent_cycle import tmux
|
||||
|
||||
# Under the home folder, a folder per epic key holds the epic's lock file, which `claims.LOCK` names. A chunk without a repo works there.
|
||||
@@ -71,6 +71,8 @@ class Epic:
|
||||
# The do-epic script each window runs.
|
||||
launcher: pathlib.Path
|
||||
env: typing.Mapping[str, str]
|
||||
# The team's own labels for its repos.
|
||||
team: LabelRepos
|
||||
|
||||
@property
|
||||
def folder(self) -> pathlib.Path:
|
||||
@@ -88,39 +90,48 @@ def held_up(issues: list[EpicIssue]) -> dict[str, list[str]]:
|
||||
by_key = {issue.key: issue for issue in issues}
|
||||
held: dict[str, list[str]] = {}
|
||||
for issue in issues:
|
||||
if not issue.done and SPLIT_LABEL not in issue.labels:
|
||||
if not issue.done and not is_split(issue, issues):
|
||||
for key in open_blockers(issue, by_key):
|
||||
held.setdefault(key, []).append(issue.key)
|
||||
return held
|
||||
|
||||
|
||||
def chunks(issues: list[EpicIssue]) -> tuple[list[Chunk], list[Waits]]:
|
||||
"""The open issues to work as chunks, in the tracker's rank order, and those that wait. An item split by repo is worked through its sub-tasks, and what blocks it blocks them. A blocker outside the epic blocks until the human removes the link, since its state is unknown. A human's task gets a window only while it holds up another issue and nothing holds it up; that window waits for the human."""
|
||||
def chunks(issues: list[EpicIssue], team: LabelRepos) -> tuple[list[Chunk], list[Waits]]:
|
||||
"""The open issues to work as chunks, in the tracker's rank order, and those that wait. A split item is worked through its sub-tasks, and what blocks it blocks them."""
|
||||
by_key = {issue.key: issue for issue in issues}
|
||||
holding = held_up(issues)
|
||||
found: list[Chunk] = []
|
||||
waits: list[Waits] = []
|
||||
for issue in issues:
|
||||
if issue.done or SPLIT_LABEL in issue.labels:
|
||||
if issue.done:
|
||||
continue
|
||||
pick = recorded(issue)
|
||||
blocking = open_blockers(issue, by_key)
|
||||
outside = [key for key in blocking if key not in by_key]
|
||||
if isinstance(pick, Failure):
|
||||
waits.append(Waits(issue.key, pick.reason))
|
||||
elif pick is None:
|
||||
waits.append(Waits(issue.key, "no label names its repo"))
|
||||
elif isinstance(pick, HumanTask) and not blocking and issue.key in holding:
|
||||
found.append(Chunk(issue.key, None, human=True))
|
||||
elif isinstance(pick, HumanTask):
|
||||
waits.append(Waits(issue.key, "it is a human's task"))
|
||||
elif blocking:
|
||||
waits.append(Waits(issue.key, f"{' and '.join(blocking)} block{'s' if len(blocking) == 1 else ''} it" + (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 "")))
|
||||
if is_split(issue, issues):
|
||||
if all(task.done for task in issues if task.parent == issue.key) and not finished(issues, issue.key):
|
||||
waits.append(Waits(issue.key, "its sub-tasks are done; close it in Jira"))
|
||||
continue
|
||||
turn = turn_of(issue, recorded(issue, team), open_blockers(issue, by_key), by_key, issue.key in holding)
|
||||
if isinstance(turn, Chunk):
|
||||
found.append(turn)
|
||||
else:
|
||||
found.append(Chunk(issue.key, pick.name if isinstance(pick, Repo) else None))
|
||||
waits.append(turn)
|
||||
return found, waits
|
||||
|
||||
|
||||
def turn_of(issue: EpicIssue, pick: Pick | None | Failure, blocking: list[str], by_key: dict[str, EpicIssue], holds: bool) -> Chunk | Waits:
|
||||
"""The open issue's chunk, or why it waits. blocking are its open blockers, and holds says it holds up another open issue. A human's task gets a window only while it holds up another issue and nothing holds it up; that window waits for the human. A blocker outside the epic blocks until the human removes the link, since its state is unknown."""
|
||||
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 ""))
|
||||
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 ""
|
||||
return Waits(issue.key, f"{' and '.join(blocking)} block{'s' if len(blocking) == 1 else ''} it{unseen}")
|
||||
return Chunk(issue.key, pick.name if isinstance(pick, Repo) else None)
|
||||
|
||||
|
||||
def refusal(repo: str, room: RepoRoom) -> str | None:
|
||||
"""Why the repo takes no further chunk; None where it takes one."""
|
||||
if room.loop_claude:
|
||||
@@ -133,7 +144,7 @@ def refusal(repo: str, room: RepoRoom) -> str | None:
|
||||
def start_chunks(epic: Epic, issues: list[EpicIssue], finishing: bool, own: str | None, run: tmux.Tmux) -> Started | Failure:
|
||||
"""Starts a do-epic in a new window for each of the epic's chunks that may start now. Where finishing is set, no issue is open, and the 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."""
|
||||
session = tmux.session_name(tmux.EPIC, epic.key)
|
||||
found, waits = chunks(issues)
|
||||
found, waits = chunks(issues, epic.team)
|
||||
if finishing:
|
||||
found.append(Chunk(epic.key, None))
|
||||
started: list[str] = []
|
||||
|
||||
+16
-11
@@ -7,7 +7,7 @@ import json
|
||||
from claude_code.reply import Claude, claude_reply, Limited
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
from failure import Failure
|
||||
from do_epic.repo_pick import label_of, of_label, Repo, REPO_NAME
|
||||
from do_epic.repo_pick import label_of, LabelRepos, of_label, Repo, REPO_NAME
|
||||
from model_routing.ladder import Rung
|
||||
from claude_code.entries import structured_output
|
||||
|
||||
@@ -59,22 +59,27 @@ class Split:
|
||||
tasks: tuple[str, ...]
|
||||
|
||||
|
||||
def split(store: EpicStore, issue: EpicIssue, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Split | Failure | Limited:
|
||||
"""Splits the epic's child issue into a sub-task per repo it changes, where that is more than one. by_person says a person filed the issue, and checkouts are the epic's repos that claude may read. An item that changes one repo or none is left as it is, for repo_pick, and one already marked SPLIT_LABEL is left alone.
|
||||
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."""
|
||||
return SPLIT_LABEL in item.labels or any(task.parent == item.key and not task.by_loop for task in issues)
|
||||
|
||||
A sub-task of the item already labelled for a repo counts as that repo's, so a run that failed after filing some sub-tasks, or a person's own sub-task, leaves the next run to file only the lacking ones. The comment on a person's issue is posted once its sub-tasks are filed, just before the item is marked. A failure after the comment but before the mark posts it again on the next run."""
|
||||
if SPLIT_LABEL in issue.labels:
|
||||
|
||||
def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Split | Failure | Limited:
|
||||
"""Splits the epic's child issue into a sub-task per repo it changes, where that is more than one. by_person says a person filed the issue, and checkouts are the epic's repos that claude may read. An item that changes one repo or none is left as it is, for repo_pick, and one already split (is_split) is left alone.
|
||||
|
||||
A sub-task of the item already labelled for a repo counts as that repo's, so a run that failed after filing some sub-tasks leaves the next run to file only the lacking ones. The comment on a person's issue is posted once its sub-tasks are filed, just before the item is marked. A failure after the comment but before the mark posts it again on the next run."""
|
||||
read = store.read()
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
if is_split(issue, read):
|
||||
return Split((), ())
|
||||
predicted = prediction(issue, by_person, rule, language, checkouts, rung, claude, cwd)
|
||||
if isinstance(predicted, Failure | Limited):
|
||||
return predicted
|
||||
read = store.read()
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
have = {pick.name for task in read if task.parent == issue.key for label in task.labels if isinstance(pick := of_label(label), Repo)}
|
||||
have = {pick.name for task in read if task.parent == issue.key for label in task.labels if isinstance(pick := of_label(label, team), Repo)}
|
||||
repos = tuple(dict.fromkeys([*sorted(have), *(part.repo for part in predicted.parts)]))
|
||||
if len(repos) < 2:
|
||||
# Left as it is even where an earlier, failed run filed one sub-task and this prediction names only that repo: marking the item split would make a person's own sub-task for one repo turn their ordinary issue into a tracking parent. The stray sub-task is labelled for its repo and harmless.
|
||||
# Left unmarked even where an earlier, failed run filed one sub-task and this prediction names only that repo: the item changes one repo, so it gets its pick as any issue does.
|
||||
return Split((), ())
|
||||
if by_person and not predicted.comment:
|
||||
return Failure("the repo split gave no comment for the team on a person's issue")
|
||||
@@ -106,7 +111,7 @@ def task_summary(repo: str, summary: str) -> str:
|
||||
|
||||
|
||||
def finished(issues: list[EpicIssue], key: str) -> bool:
|
||||
"""Whether the item named key is done. An item marked SPLIT_LABEL that has sub-tasks is done once each of them is, whatever its own status; any other item is done by its own status, and a key no issue has isn't done."""
|
||||
"""Whether the item named key is done. An item marked SPLIT_LABEL that has sub-tasks is done once each of them is, whatever its own status. Any other item is done by its own status, also one a person's sub-tasks split: do-epic filed those for every repo the item changes, and a person's may cover only a part of it. A key no issue has isn't done."""
|
||||
item = next((issue for issue in issues if issue.key == key), None)
|
||||
tasks = [issue for issue in issues if issue.parent == key]
|
||||
if item is None:
|
||||
|
||||
@@ -6,6 +6,7 @@ from do_epic.scheduler import chunks, HUMAN_WAIT, STATE
|
||||
from do_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 agent_cycle import tmux
|
||||
|
||||
|
||||
@@ -17,9 +18,9 @@ def since(folder: pathlib.Path, chunk: Parked) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], run: tmux.Tmux) -> list[str] | Failure:
|
||||
def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, run: tmux.Tmux) -> list[str] | Failure:
|
||||
"""A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back."""
|
||||
found, waits = chunks(issues)
|
||||
found, waits = chunks(issues, team)
|
||||
folder = home / STATE / key
|
||||
parked = parked_chunks(folder)
|
||||
if isinstance(parked, Failure):
|
||||
|
||||
@@ -38,6 +38,32 @@ class ConfigTest(unittest.TestCase):
|
||||
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"))
|
||||
|
||||
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
|
||||
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')
|
||||
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 '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",
|
||||
"`label-repos` maps 'core' to 4, not a repo's name",
|
||||
):
|
||||
self.assertIn(fault, reason)
|
||||
self.assertEqual(reason.count("`label-repos` maps"), 7)
|
||||
|
||||
def test_refuses_a_label_repos_that_is_no_table(self) -> None:
|
||||
self.write('label-repos = "twu-4"\n' + SETTINGS)
|
||||
self.assertIn("`label-repos` is 'twu-4', not a table of labels, such as `twu-4 = \"tenant-web-ui-4\"` under `[label-repos]`", self.failure())
|
||||
|
||||
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)
|
||||
|
||||
@@ -4,6 +4,7 @@ import fcntl
|
||||
import io
|
||||
import pathlib
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
@@ -11,8 +12,8 @@ from do_epic.test_main import DESCRIPTION, DoEpicTest
|
||||
from do_epic.epic_record import EpicRecord
|
||||
from failure import Failure
|
||||
from loop_effects.doubles import FakeEffects
|
||||
from do_epic import findings, main
|
||||
from record_store.held import Held
|
||||
from do_epic import main
|
||||
from do_epic.backend.fake import MemoryEpic
|
||||
from loop_state.paths import paths_from
|
||||
|
||||
@@ -83,6 +84,17 @@ class FilingAFinding(FindingsTest):
|
||||
filed = self.store.issues[-1]
|
||||
self.assertEqual((code, out, filed.labels, filed.detail), (0, f"Filed {filed.key} in the epic ABC-12.\n", (label,), ""))
|
||||
|
||||
def test_a_label_of_the_teams_says_where_the_issue_is_worked(self) -> None:
|
||||
with (self.home / ".claude-projects/do-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]
|
||||
self.assertEqual((code, out, filed.labels), (0, f"Filed {filed.key} in the epic ABC-12.\n", ("twu-4",)))
|
||||
code, _, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu-4", "--label", "repo:api"])
|
||||
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: twu-4 and repo:api each say who works it; write one of them\n"))
|
||||
_, _, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu"])
|
||||
self.assertTrue(err.endswith("or `do-epic-human` for a task of the human's (or the team's `twu-4`)\n"), err)
|
||||
|
||||
def test_a_release_review_takes_its_label_beside_its_repo(self) -> None:
|
||||
code, out, _, _ = self.run_with(["ABC-12", "--file", "Review api", "--label", "repo:api", "--label", "do-epic-release-review"])
|
||||
filed = self.store.issues[-1]
|
||||
@@ -90,6 +102,23 @@ class FilingAFinding(FindingsTest):
|
||||
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"))
|
||||
|
||||
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")
|
||||
filed = self.store.issues[-1]
|
||||
self.assertEqual((code, out, err), (0, f"Filed {filed.key} in the epic ABC-12. It is blocked by ABC-20.\n", ""))
|
||||
self.assertEqual((filed.parent, filed.blockers, filed.labels), ("ABC-12", ("ABC-20",), ("repo:api",)))
|
||||
|
||||
def test_files_a_sub_task_under_a_child_issue_of_the_epic(self) -> None:
|
||||
code, out, _, _ = self.run_with(["ABC-12", "--file", "--parent", "ABC-20", "Change it", "--label", "repo:api", "--blocked-by", "ABC-21"])
|
||||
filed = self.store.issues[-1]
|
||||
self.assertEqual((code, out, filed.parent, filed.blockers), (0, f"Filed {filed.key} under ABC-20 in the epic ABC-12. It is blocked by ABC-21.\n", "ABC-20", ("ABC-21",)))
|
||||
|
||||
def test_refuses_a_blocker_or_parent_outside_the_epic(self) -> None:
|
||||
for argv, reason in ((["--blocked-by", "ZZZ-1"], "ZZZ-1 is neither a child issue of the epic ABC-12 nor a sub-task of one, so it cannot block a new issue"), (["--parent", "ZZZ-1"], "ZZZ-1 is neither the epic ABC-12 nor one of its child issues, so nothing can be filed under it")):
|
||||
with self.subTest(argv=argv):
|
||||
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "repo:api", *argv])
|
||||
self.assertEqual((code, out, err, len(self.store.issues)), (1, "", f"cannot file the finding in the epic ABC-12: {reason}\n", 2))
|
||||
|
||||
def test_refuses_a_label_the_scheduler_doesnt_read(self) -> None:
|
||||
for label in ("api", "repo:", "repo:a b"):
|
||||
with self.subTest(label=label):
|
||||
@@ -114,12 +143,19 @@ class FilingAFinding(FindingsTest):
|
||||
self.assertIn("config.toml", err)
|
||||
|
||||
def test_prints_the_help_for_a_filing_spelt_wrong(self) -> None:
|
||||
for argv in (["ABC-12", "--file"], ["ABC-12", "--file", "a", "b"], ["ABC-12", "--file", "a", "--label"], ["ABC-12", "--file", "a", "--labels", "x"], ["--file", "ABC-12", "a"], ["ABC-12", "--file", "--label", "x"], ["ABC-12", "--file", "--lable"], ["ABC-12", "--file", "a", "--label", "--x"], ["--chunk", "ABC-20", "ABC-12", "--file", "a"]):
|
||||
for argv in (["ABC-12", "--file", "a", "--blocked-by", ""], ["ABC-12", "--file", "a", "--parent", " "], ["ABC-12", "--file"], ["ABC-12", "--file", "a", "b"], ["ABC-12", "--file", "a", "--label"], ["ABC-12", "--file", "a", "--labels", "x"], ["--file", "ABC-12", "a"], ["ABC-12", "--file", "--label", "x"], ["ABC-12", "--file", "--lable"], ["ABC-12", "--file", "a", "--blocked-by"], ["ABC-12", "--file", "a", "--blocked-by", "ABC-100", "--blocked-by", "ABC-101"], ["ABC-12", "--file", "a", "--parent", "ABC-100", "--parent", "ABC-101"], ["ABC-12", "--file", "a", "--parent", "--label", "x"], ["ABC-12", "--record-decision", "a", "--blocked-by", "ABC-100"], ["ABC-12", "--file", "a", "--label", "--x"], ["--chunk", "ABC-20", "ABC-12", "--file", "a"]):
|
||||
with self.subTest(argv=argv):
|
||||
code, out, err, _ = self.run_with(argv)
|
||||
self.assertEqual((code, out, err, len(self.store.issues)), (1, "", main.HELP + "\n", 2))
|
||||
|
||||
|
||||
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", {})
|
||||
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)
|
||||
|
||||
|
||||
class RecordingADecision(FindingsTest):
|
||||
def test_appends_the_entry_to_the_descriptions_decisions(self) -> None:
|
||||
code, out, err, fake = self.run_with(["ABC-12", "--record-decision", "Imports retry three times"], "2026-11-18, the human's answer. Valid while the client's API rate-limits.\n")
|
||||
|
||||
@@ -35,31 +35,38 @@ class WhenTheFinishingIsDue(DoEpicTest):
|
||||
|
||||
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")]
|
||||
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, {}), ["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")
|
||||
|
||||
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"))
|
||||
|
||||
|
||||
class TheFinishingChunksTask(DoEpicTest):
|
||||
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")
|
||||
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("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 repo:<name> --label do-epic-release-review`', task)
|
||||
self.assertIn("`Release review of ABC-12`", task)
|
||||
self.assertIn("in Swedish", task)
|
||||
self.assertNotIn("--close-epic", task)
|
||||
|
||||
def test_then_has_the_human_confirm_each_goal_before_the_summary_and_the_closing(self) -> None:
|
||||
task = finish.task("ABC-12", REVIEWED, LAUNCHER, "Swedish")
|
||||
task = finish.task("ABC-12", REVIEWED, {}, LAUNCHER, "Swedish")
|
||||
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("in Swedish", task)
|
||||
self.assertIn(findings.instructions("ABC-12", LAUNCHER, "Swedish"), task)
|
||||
self.assertIn("- ABC-20 (api): Do ABC-20\n- ABC-21: Do ABC-21\n- ABC-30 (api): Do ABC-30", 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)
|
||||
|
||||
|
||||
@@ -99,7 +106,7 @@ class ClosingTheEpic(DoEpicTest):
|
||||
def closed(self) -> Failure:
|
||||
return Failure("Jira answered 503")
|
||||
|
||||
self.assertEqual(finish.closed("ABC-12", Unreadable("ABC-12", list(REVIEWED)), io.StringIO("Shipped.")), Failure("cannot close the epic ABC-12: Jira answered 503"))
|
||||
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 / ".claude-projects/do-epic/config.toml", "a", encoding="utf-8") as settings:
|
||||
|
||||
@@ -5,7 +5,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from do_epic.gates import APPROVAL, CHECKS, gate, Gate, NEW_REVIEW, Open
|
||||
from do_epic.gates import APPROVAL, CHECKS, gate, Gate, MERGE, NEW_REVIEW, Open, Unopened
|
||||
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"
|
||||
@@ -58,8 +58,8 @@ class Forge:
|
||||
return Failure(f"{key} failed") if self.fails and key.startswith(self.fails) else self.answers[key]
|
||||
return run
|
||||
|
||||
def gate(self) -> Gate | Open | Failure:
|
||||
return gate("ABC-21", "/code/billing", self.at)
|
||||
def gate(self, by_human: bool = False) -> Gate | Open | Failure:
|
||||
return gate("ABC-21", "/code/billing", self.at, by_human)
|
||||
|
||||
|
||||
class GateOfAChunk(unittest.TestCase):
|
||||
@@ -72,6 +72,19 @@ class GateOfAChunk(unittest.TestCase):
|
||||
self.assertIn(["gh", "pr", "checks", "7", "--json", "bucket"], forge.commands)
|
||||
self.assertTrue(any(command[:3] == ["gh", "api", "graphql"] and "number=7" in command for command in forge.commands), forge.commands)
|
||||
|
||||
def test_where_a_person_merges_a_pull_request_with_nothing_else_to_wait_on_awaits_that_merge(self):
|
||||
gitea = "https://gitea.larvit.se/o/billing.git"
|
||||
for forge in (Forge(decision="APPROVED"), Forge(decision=""), Forge(gitea)):
|
||||
with self.subTest(forge.answers["git remote"]):
|
||||
self.assertEqual(forge.gate(by_human=True), Gate("/code/billing-ABC-21", "7", MERGE))
|
||||
self.assertEqual(Forge(decision="APPROVED").gate(by_human=False), Open("pull request #7 passed its checks and is approved"))
|
||||
|
||||
def test_where_a_person_merges_every_other_gate_and_all_news_stay_as_they_are(self):
|
||||
same = (Forge(), Forge(buckets=("pending",)), Forge(draft=True), Forge(decision="CHANGES_REQUESTED"), Forge(threads=(thread(False, "reviewer"),)), Forge(buckets=("fail",)), Forge(pulls=""))
|
||||
for forge in same:
|
||||
with self.subTest(forge.answers):
|
||||
self.assertEqual(forge.gate(by_human=True), forge.gate())
|
||||
|
||||
def test_a_review_decision_gh_prints_in_no_known_shape_is_a_failure(self):
|
||||
forge = Forge()
|
||||
forge.answers["gh pr view"] = "[1]"
|
||||
@@ -128,12 +141,12 @@ class GateOfAChunk(unittest.TestCase):
|
||||
"a check on pull request 7 failed; fix it and push": Forge(buckets=("fail",)),
|
||||
"a reviewer requested changes on pull request #7": Forge(decision="CHANGES_REQUESTED"),
|
||||
"a reviewer's comment on pull request #7 waits for an answer, in a.py, b.py": Forge(threads=(thread(False, "reviewer", "b.py"), thread(False, "reviewer"), thread(True, "reviewer", "c.py"), thread(False, "worker", "d.py"))),
|
||||
"no pull request from origin's ABC-21 is open at abcabcabcabc; it may be merged or closed already": Forge(pulls=""),
|
||||
"no worktree of /code/billing has the branch ABC-21 checked out": Forge(worktrees="worktree /code/billing\nHEAD aaa\nbranch refs/heads/main\n"),
|
||||
}
|
||||
for news, forge in cases.items():
|
||||
with self.subTest(news=news):
|
||||
self.assertEqual(forge.gate(), Open(news))
|
||||
self.assertEqual(Forge(pulls="").gate(), Unopened("no pull request from origin's ABC-21 is open at abcabcabcabc; it may be merged or closed already"))
|
||||
|
||||
def test_a_read_that_fails_is_a_failure_and_says_nothing_of_the_gate(self):
|
||||
for command in ("git worktree", "git remote", "gh pr list", "gh pr view", "gh pr checks", "gh api graphql"):
|
||||
|
||||
@@ -652,10 +652,14 @@ def awaiting(**answers: object) -> Forge:
|
||||
return Forge(worktrees=WORKTREE, **answers) # type: ignore[arg-type]
|
||||
|
||||
|
||||
# A forge whose checkout no longer has ABC-20's worktree, as after `chunk-pr clean`.
|
||||
CLEANED = Forge(worktrees="worktree /code/api\nHEAD aaa\nbranch refs/heads/main\n")
|
||||
|
||||
|
||||
class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
self.repo_chunk()
|
||||
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/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)
|
||||
@@ -676,6 +680,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
self.assertEqual(states, [(60, {"ABC-20": parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(self.session.id), "an approval")})] * 2)
|
||||
self.assertFalse(self.file.exists())
|
||||
self.assertIn("parked: pull request #7 awaits an approval\nstarted ABC-22\n", out)
|
||||
self.assertEqual(out.count("parked: "), 1)
|
||||
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})
|
||||
@@ -684,6 +689,87 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
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]])
|
||||
|
||||
def test_where_a_person_merges_it_parks_on_that_merge_and_works_again_once_merged(self) -> None:
|
||||
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8") + 'merge = "human"\n', encoding="utf-8")
|
||||
self.forges = [awaiting(), awaiting(decision="APPROVED"), awaiting(pulls=""), CLEANED]
|
||||
fake = FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("parked: pull request #7 awaits an approval\nstarted ABC-22\nparked: pull request #7 awaits your merge\n", out)
|
||||
self.assertEqual(out.count("parked: "), 2)
|
||||
for fact in ("run `chunk-pr merge` without `--finish`", "leaves the pull request ready for a person to merge"):
|
||||
self.assertIn(fact, prompts[0])
|
||||
for fact in ("awaited a person's merge", "no pull request from origin's ABC-20 is open", "chunk-pr clean"):
|
||||
self.assertIn(fact, prompts[1].split("\n\n")[0])
|
||||
self.assertEqual([args[3] for args in fake.tmux_calls if args[0] == "rename-window"], ["ABC-20 awaits an approval", "ABC-20 awaits your merge", "ABC-20"])
|
||||
self.assertFalse(self.file.exists())
|
||||
|
||||
def test_stops_where_the_repos_config_cannot_be_read_as_the_cycle_ends(self) -> None:
|
||||
self.forges = [awaiting()]
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("unfinished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
broken = self.repo_config.read_text(encoding="utf-8") + 'merge = "nobody"\n'
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, stream_claude=lambda *args, **kwargs: (self.repo_config.write_text(broken, encoding="utf-8"), made.stream_claude(*args, **kwargs))[1]) # type: ignore[method-assign]
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts)), (1, 1))
|
||||
self.assertIn('`merge` is \'nobody\', not "chunk" or "human"', err)
|
||||
self.assertNotIn("parked: ", out)
|
||||
|
||||
def test_stops_where_the_gate_a_parked_chunk_moved_to_cannot_be_recorded(self) -> None:
|
||||
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8") + 'merge = "human"\n', encoding="utf-8")
|
||||
self.forges = [awaiting(), awaiting(decision="APPROVED")]
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("unfinished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, sleep=lambda seconds: self.file.parent.chmod(0o555)) # type: ignore[method-assign]
|
||||
self.addCleanup(lambda: self.file.parent.chmod(0o755))
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts), out.count("parked: ")), (1, 1, 1))
|
||||
self.assertIn("Permission denied", err)
|
||||
|
||||
def test_where_a_person_merges_a_finished_chunk_waits_for_a_gate_it_cannot_read(self) -> None:
|
||||
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8") + 'merge = "human"\n', encoding="utf-8")
|
||||
self.forges = [awaiting(decision="APPROVED", fails="gh pr checks"), awaiting(decision="APPROVED"), CLEANED]
|
||||
fake = FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("finished"), judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
slept: list[object] = []
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, sleep=slept.append) # type: ignore[method-assign]
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts)), (0, 2), err)
|
||||
self.assertEqual(slept, [60, 60])
|
||||
self.assertIn("cannot read the gate of a pull request a person merges: gh pr checks failed", out)
|
||||
self.assertIn("parked: pull request #7 awaits your merge", out)
|
||||
|
||||
def test_where_a_person_merged_before_the_cycle_closed_the_worker_is_told_once_to_remove_its_worktree(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=""), awaiting(pulls="")]
|
||||
fake = FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("finished"), judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts)), (0, 2), err)
|
||||
for fact in ("keeps the chunk open while its worktree stands", "no pull request from origin's ABC-20 is open", "chunk-pr clean"):
|
||||
self.assertIn(fact, prompts[1].split("\n\n")[0])
|
||||
self.assertNotIn("parked: ", out)
|
||||
|
||||
def test_where_a_person_merges_an_unfinished_chunk_goes_on_without_news_or_a_wait(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=""), awaiting(decision="APPROVED", fails="gh pr checks"), CLEANED]
|
||||
fake = FakeEffects(streams=[self.worker(), self.worker(), self.worker()], claude=[judged("unfinished"), judged("unfinished"), judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
slept: list[object] = []
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, sleep=slept.append) # type: ignore[method-assign]
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts), slept), (0, 3, []), err)
|
||||
self.assertNotIn("keeps the chunk open", "".join(prompts))
|
||||
self.assertIn("so the chunk isn't parked: gh pr checks failed", out)
|
||||
|
||||
def test_where_the_chunk_merges_a_finished_chunk_whose_pull_request_is_no_longer_open_is_handed_on(self) -> None:
|
||||
self.forges = [awaiting(pulls="")]
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
code, _, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts)), (0, 1), err)
|
||||
|
||||
def test_where_the_chunk_merges_an_approved_pull_request_parks_no_chunk(self) -> None:
|
||||
self.forges = [awaiting(decision="APPROVED")]
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertNotIn("parked: ", out)
|
||||
|
||||
def test_an_unfinished_chunk_parks_too_and_a_reviewers_comment_resumes_it(self) -> None:
|
||||
self.forges = [awaiting(buckets=("pending",)), awaiting(), awaiting(threads=({"isResolved": False, "path": "a.py", "comments": {"nodes": [{"author": {"login": "reviewer"}}]}},))]
|
||||
fake = FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD, windows=PARKED_WINDOW + "ABC-22\t1\t@10\n")
|
||||
|
||||
@@ -56,6 +56,21 @@ class Planning(DoEpicTest):
|
||||
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 / ".claude-projects/do-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.issues = [
|
||||
issue("ABC-19", "twu-4"),
|
||||
issue("ABC-20"),
|
||||
issue("ABC-23", "core-4", parent="ABC-20"),
|
||||
issue("ABC-24", "twu-4", parent="ABC-20"),
|
||||
issue("ABC-21", "urgent"),
|
||||
issue("ABC-25", "core-4", parent="ABC-21"),
|
||||
]
|
||||
fake = FakeEffects()
|
||||
found, store, out = self.plan(fake)
|
||||
self.assertEqual((found, store.issues, out, fake.made("claude")), (self.issues, self.issues, "", []))
|
||||
|
||||
def test_labels_an_unplaced_issue_with_the_repo_claude_picks_on_the_repoless_models_rung(self) -> None:
|
||||
self.issues = [issue("ABC-20")]
|
||||
fake = FakeEffects(claude=[says({"parts": [{"repo": "api", "change": "Add the endpoint."}]}), says({"pick": "repo", "repo": "api"})])
|
||||
@@ -86,6 +101,17 @@ class Planning(DoEpicTest):
|
||||
self.assertIn("ABC-20 is split into a sub-task for each of api, web\n", out)
|
||||
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 / ".claude-projects/do-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")]
|
||||
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"})]))
|
||||
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")))
|
||||
|
||||
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."})
|
||||
@@ -136,6 +162,14 @@ class Planning(DoEpicTest):
|
||||
args = fake.made("claude")[0][0]
|
||||
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 / ".claude-projects/do-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", "repo:api")], ["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: "]))
|
||||
|
||||
def test_asks_the_human_for_the_label_of_an_issue_the_rule_leaves_unclear_until_one_is_typed(self) -> None:
|
||||
self.issues = [issue("ABC-20")]
|
||||
fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "Is the importer in api or in web?"})], inputs=["api", "a b", " repo:web "])
|
||||
|
||||
@@ -6,7 +6,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from do_epic.repo_pick import CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, PICK_SCHEMA, picked, recorded, Repo, REPO_PREFIX, Unclear
|
||||
from do_epic.repo_pick import also, CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, PICK_SCHEMA, picked, recorded, Repo, REPO_PREFIX, Unclear
|
||||
from do_epic.backend.protocol import EpicIssue
|
||||
from failure import Failure
|
||||
from claude_code.reply import Limited
|
||||
@@ -31,6 +31,9 @@ def says(output: object) -> Claude:
|
||||
return Claude(json.dumps({"type": "result", "structured_output": output}))
|
||||
|
||||
|
||||
TEAM = {"twu-4": "tenant-web-ui-4", "core-4": "core-4"}
|
||||
|
||||
|
||||
class RepoPick(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.store = MemoryEpic("ABC-12")
|
||||
@@ -43,7 +46,7 @@ class RepoPick(unittest.TestCase):
|
||||
return read[0]
|
||||
|
||||
def pick(self, claude: Claude): # type: ignore[no-untyped-def]
|
||||
return picked(self.store, self.issue(), RULE, RUNG, claude, "/rules")
|
||||
return picked(self.store, self.issue(), {}, RULE, RUNG, claude, "/rules")
|
||||
|
||||
def test_records_the_claude_pick_as_a_label_on_the_issue(self) -> None:
|
||||
self.assertEqual(self.pick(says({"pick": "repo", "repo": "payments-api"})), Repo("payments-api"))
|
||||
@@ -73,7 +76,7 @@ class RepoPick(unittest.TestCase):
|
||||
store = MemoryEpic("ABC-12")
|
||||
store.file("ABC-12", "Clean up the docs.", "", ())
|
||||
claude = says({"pick": "claude"})
|
||||
picked(store, store.read()[0], RULE, RUNG, claude, "/rules") # type: ignore[index]
|
||||
picked(store, store.read()[0], {}, RULE, RUNG, claude, "/rules") # type: ignore[index]
|
||||
self.assertIn("Labels: none\n\n(no description)\n", claude.calls[0][2])
|
||||
|
||||
def test_records_a_pick_without_a_repo_as_claudes_work_or_a_human_task(self) -> None:
|
||||
@@ -82,9 +85,9 @@ class RepoPick(unittest.TestCase):
|
||||
store = MemoryEpic("ABC-12")
|
||||
key = store.file("ABC-12", "Clean up the docs.", "", ())
|
||||
issue = store.read()[0] # type: ignore[index]
|
||||
self.assertEqual(picked(store, issue, RULE, RUNG, says(output), "/rules"), pick)
|
||||
self.assertEqual(picked(store, issue, {}, RULE, RUNG, says(output), "/rules"), pick)
|
||||
self.assertEqual(store.read()[0].labels, (label,)) # type: ignore[index]
|
||||
self.assertEqual(recorded(store.read()[0]), pick) # type: ignore[index]
|
||||
self.assertEqual(recorded(store.read()[0], {}), pick) # type: ignore[index]
|
||||
|
||||
def test_reads_a_recorded_pick_back_without_asking_claude(self) -> None:
|
||||
self.store.add_label(self.key, "repo:log")
|
||||
@@ -96,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 all but the right one"))
|
||||
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(claude.calls, [])
|
||||
|
||||
def test_an_unclear_pick_returns_the_question_and_records_nothing_until_the_human_answers(self) -> None:
|
||||
@@ -113,7 +116,7 @@ class RepoPick(unittest.TestCase):
|
||||
for name in ("../../.ssh", "a/b", ".hidden", "-flag", "https://host/x.git", "host:repo"):
|
||||
with self.subTest(name=name):
|
||||
self.assertIsInstance(self.pick(says({"pick": "repo", "repo": name})), Failure)
|
||||
self.assertIsNone(recorded(EpicIssue(self.key, "s", "", (REPO_PREFIX + name,), None, "To Do", False, "ABC-12")))
|
||||
self.assertIsNone(recorded(EpicIssue(self.key, "s", "", (REPO_PREFIX + name,), None, "To Do", False, "ABC-12"), {}))
|
||||
|
||||
def test_a_reply_that_is_no_pick_says_what_it_got_in_its_first_200_characters(self) -> None:
|
||||
output = {"pick": "repo", "repo": "two words" * 40}
|
||||
@@ -129,16 +132,36 @@ class RepoPick(unittest.TestCase):
|
||||
def test_a_label_the_tracker_refuses_comes_back_as_it_is(self) -> None:
|
||||
issue = self.issue()
|
||||
self.store.fails = "Jira answered 503"
|
||||
self.assertEqual(picked(self.store, issue, RULE, RUNG, says({"pick": "claude"}), "/rules"), Failure("Jira answered 503"))
|
||||
self.assertEqual(picked(self.store, issue, {}, RULE, RUNG, says({"pick": "claude"}), "/rules"), Failure("Jira answered 503"))
|
||||
|
||||
def test_the_label_of_a_pick_reads_back_as_that_pick(self) -> None:
|
||||
for pick in (Repo("payments-api"), ClaudeWork(), HumanTask()):
|
||||
with self.subTest(pick=pick):
|
||||
self.assertEqual(recorded(EpicIssue(self.key, "s", "", (label_of(pick),), None, "To Do", False, "ABC-12")), pick)
|
||||
self.assertEqual(recorded(EpicIssue(self.key, "s", "", (label_of(pick),), None, "To Do", False, "ABC-12"), {}), pick)
|
||||
|
||||
def test_a_label_the_teams_table_maps_records_its_repo_without_asking_claude(self) -> None:
|
||||
self.store.add_label(self.key, "twu-4")
|
||||
claude = says({"pick": "claude"})
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
self.store.add_label(self.key, "twu-4")
|
||||
self.store.add_label(self.key, "core-4")
|
||||
self.store.add_label(self.key, "repo:core-4")
|
||||
self.assertEqual(recorded(self.issue(), TEAM), Failure(f"{self.key} is labelled with 2 picks: core-4, repo:core-4, twu-4; remove the labels of all but the right one"))
|
||||
|
||||
def test_a_label_with_the_prefix_alone_is_no_pick(self) -> None:
|
||||
self.store.add_label(self.key, "repo:")
|
||||
self.assertIsNone(recorded(self.issue()))
|
||||
self.assertIsNone(recorded(self.issue(), {}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -48,13 +49,46 @@ 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", "do-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:
|
||||
found = chunks([issue("ABC-20", "split-by-repo"), issue("ABC-23", "repo:api", parent="ABC-20"), issue("ABC-24", "repo:web", parent="ABC-20")])
|
||||
found = chunks([issue("ABC-20", "split-by-repo"), issue("ABC-23", "repo:api", parent="ABC-20"), issue("ABC-24", "repo:web", parent="ABC-20")], {})
|
||||
self.assertEqual(found, ([Chunk("ABC-23", "api"), Chunk("ABC-24", "web")], []))
|
||||
|
||||
def test_an_epic_shaped_as_a_teams_is_worked_through_its_own_sub_tasks_and_labels(self) -> None:
|
||||
team = {"twu-4": "tenant-web-ui-4", "core-4": "core-4"}
|
||||
issues = [
|
||||
issue("ABC-19", "twu-4"),
|
||||
issue("ABC-20", blockers=("ABC-19",)),
|
||||
issue("ABC-23", "core-4", parent="ABC-20"),
|
||||
issue("ABC-24", "twu-4", parent="ABC-20", done=True),
|
||||
issue("ABC-21"),
|
||||
issue("ABC-25", "core-4", parent="ABC-21"),
|
||||
]
|
||||
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:
|
||||
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")]))
|
||||
|
||||
def test_an_item_a_person_split_waits_to_be_closed_once_its_sub_tasks_are_done_and_blocks_until_then(self) -> None:
|
||||
found = chunks([issue("ABC-20", "repo:api"), issue("ABC-23", parent="ABC-20", done=True), issue("ABC-21", "repo:api", blockers=("ABC-20",))], {})
|
||||
self.assertEqual(found, ([], [Waits("ABC-20", "its sub-tasks are done; close it in Jira"), Waits("ABC-21", "ABC-20 blocks it")]))
|
||||
|
||||
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:
|
||||
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")]))
|
||||
|
||||
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"),
|
||||
])
|
||||
|
||||
def test_an_issue_waits_for_its_pick_its_human_and_its_blockers(self) -> None:
|
||||
found = chunks([
|
||||
issue("ABC-20"),
|
||||
@@ -62,28 +96,28 @@ class WhichIssuesAreChunks(unittest.TestCase):
|
||||
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),
|
||||
])
|
||||
], {})
|
||||
self.assertEqual(found, ([], [
|
||||
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 all but the right one"),
|
||||
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"),
|
||||
]))
|
||||
|
||||
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", "do-epic-human"), issue("ABC-21", "repo:api", blockers=("ABC-20",)), issue("ABC-22", "do-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", "do-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", "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",))], {})
|
||||
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:
|
||||
found = chunks([issue("ABC-19", "repo:api"), issue("ABC-20", "split-by-repo", blockers=("ABC-19",)), issue("ABC-23", "repo:api", parent="ABC-20")])
|
||||
found = chunks([issue("ABC-19", "repo:api"), issue("ABC-20", "split-by-repo", blockers=("ABC-19",)), issue("ABC-23", "repo:api", parent="ABC-20")], {})
|
||||
self.assertEqual(found, ([Chunk("ABC-19", "api")], [Waits("ABC-23", "ABC-19 blocks it")]))
|
||||
|
||||
|
||||
@@ -142,7 +176,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, self.home, pathlib.Path("/bin/do-epic"), {"LOOP_CLAUDE_X": "1", "OTHER": "2"})
|
||||
return Epic("ABC-12", cap, locate, self.home, pathlib.Path("/bin/do-epic"), {"LOOP_CLAUDE_X": "1", "OTHER": "2"}, {})
|
||||
|
||||
def start(self, epic: Epic, issues: list[EpicIssue], run: Tmux, own: str | None = None) -> Started:
|
||||
found = start_chunks(epic, issues, False, own, run)
|
||||
@@ -345,14 +379,23 @@ class TheFirstPrompt(unittest.TestCase):
|
||||
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. "
|
||||
"Where filing fails and says the issue may exist, ask the human to look before you file it again. File a finding about a repo's goals by that repo's rules. Where unsure which, ask the human. "
|
||||
"Record a decision that governs the epic, such as an answer the human typed, with `/b/do-epic ABC-12 --record-decision \"<title>\"` and its text on stdin. Write the issue and the decision in Swedish, the epic's language."
|
||||
"Record a decision that governs the epic, such as an answer the human typed, with `/b/do-epic ABC-12 --record-decision \"<title>\"` and its text on stdin. "
|
||||
"Write the issue and the decision in Swedish, the epic's language."
|
||||
)
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
|
||||
self.assertTrue(task.startswith(f"Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout /code/api, on the branch ABC-20. {told} "))
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", CONFIG)
|
||||
self.assertTrue(task.startswith(f"Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout /code/api, on the branch ABC-20. {told.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(" 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)
|
||||
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)
|
||||
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/do-epic"), "Swedish", None)
|
||||
self.assertTrue(task.endswith("Swedish, the epic's language. Its summary: Do ABC-20"))
|
||||
self.assertNotIn("--finish", task)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import dataclasses
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
@@ -8,7 +9,7 @@ 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 failure import Failure
|
||||
from do_epic.split import finished, Split, split, SPLIT_LABEL, SPLIT_SCHEMA
|
||||
from do_epic.split import finished, is_split, Split, split, SPLIT_LABEL, SPLIT_SCHEMA
|
||||
from claude_code.reply import Limited
|
||||
from do_epic.backend.fake import MemoryEpic
|
||||
from model_routing.ladder import Rung
|
||||
@@ -50,7 +51,7 @@ class Split_(unittest.TestCase):
|
||||
return [issue for issue in self.issues() if issue.parent == self.key]
|
||||
|
||||
def run_split(self, claude: Claude, by_person: bool = False): # type: ignore[no-untyped-def]
|
||||
return split(self.store, self.issue(), by_person, RULE, "Swedish", ("/repos/api", "/repos/web"), RUNG, claude, "/rules")
|
||||
return split(self.store, self.issue(), {}, by_person, RULE, "Swedish", ("/repos/api", "/repos/web"), RUNG, claude, "/rules")
|
||||
|
||||
def test_files_a_sub_task_per_repo_labelled_for_it_and_marks_the_parent(self) -> None:
|
||||
done = self.run_split(says(TWO))
|
||||
@@ -60,6 +61,16 @@ class Split_(unittest.TestCase):
|
||||
self.assertEqual(self.issue().labels, ("api", SPLIT_LABEL))
|
||||
self.assertEqual(self.store.comments, {})
|
||||
|
||||
def test_an_item_a_person_filed_a_sub_task_under_is_left_alone_without_asking_claude(self) -> None:
|
||||
self.store.issues.append(EpicIssue("ABC-90", "twu-4: Count them.", "", ("twu-4",), None, "To Do", False, self.key))
|
||||
claude = says(TWO)
|
||||
self.assertEqual((self.run_split(claude), claude.calls, len(self.tasks())), (Split((), ()), [], 1))
|
||||
|
||||
def test_a_sub_task_with_the_teams_label_counts_as_its_repos_when_a_failed_run_is_taken_up(self) -> None:
|
||||
self.store.issues.append(EpicIssue("ABC-90", "Serve it.", "", ("backend",), None, "To Do", False, self.key, by_loop=True))
|
||||
done = split(self.store, self.issue(), {"backend": "api"}, False, RULE, "Swedish", (), RUNG, says(TWO), "/rules")
|
||||
self.assertEqual((done, [task.labels for task in self.tasks()]), (Split(("api", "web"), (self.tasks()[1].key,)), [("backend",), ("repo:web",)]))
|
||||
|
||||
def test_comments_on_a_persons_issue_for_the_team_once_its_sub_tasks_are_filed(self) -> None:
|
||||
self.run_split(says(TWO), by_person=True)
|
||||
self.assertEqual(self.store.comments, {self.key: ["Delat per repo: api och web."]})
|
||||
@@ -143,7 +154,7 @@ class Split_(unittest.TestCase):
|
||||
assert isinstance(key, str)
|
||||
bare = next(issue for issue in self.issues() if issue.key == key)
|
||||
claude = says(TWO)
|
||||
split(self.store, bare, False, RULE, "Swedish", (), RUNG, claude, "/rules")
|
||||
split(self.store, bare, {}, False, RULE, "Swedish", (), RUNG, claude, "/rules")
|
||||
prompt = claude.calls[0][2]
|
||||
self.assertIn("checked out at: none. Read them", prompt)
|
||||
self.assertTrue(prompt.endswith("\nLabels: none\n\n(no description)\n"))
|
||||
@@ -153,7 +164,7 @@ class Split_(unittest.TestCase):
|
||||
key = self.store.file("ABC-12", "Two labels.", "Why.", ("api", "urgent"))
|
||||
assert isinstance(key, str)
|
||||
claude = says(TWO)
|
||||
split(self.store, next(issue for issue in self.issues() if issue.key == key), False, RULE, "Swedish", (), RUNG, claude, "/rules")
|
||||
split(self.store, next(issue for issue in self.issues() if issue.key == key), {}, False, RULE, "Swedish", (), RUNG, claude, "/rules")
|
||||
self.assertIn("\nLabels: api, urgent\n", claude.calls[0][2])
|
||||
|
||||
def test_asks_a_persons_issue_for_a_comment(self) -> None:
|
||||
@@ -196,6 +207,16 @@ class Finished(unittest.TestCase):
|
||||
self.assertEqual([finished(self.issues((own, ()), ()), "ABC-1") for own in (True, False)], [True, False])
|
||||
self.assertEqual(finished(self.issues((True, ()), ()), "ABC-9"), False)
|
||||
|
||||
def test_an_item_with_a_persons_sub_tasks_is_split_without_the_mark_and_done_only_by_its_own_status(self) -> None:
|
||||
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:
|
||||
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))
|
||||
self.assertTrue(is_split(dataclasses.replace(parent, labels=(SPLIT_LABEL,)), ours))
|
||||
|
||||
def test_an_item_marked_split_whose_sub_tasks_are_not_filed_yet_is_done_by_its_own_status(self) -> None:
|
||||
self.assertEqual(finished(self.issues((False, (SPLIT_LABEL,)), ()), "ABC-1"), False)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class TheStatusLines(unittest.TestCase):
|
||||
os.utime(parked.file_of(self.folder, key), (SINCE, SINCE))
|
||||
|
||||
def lines(self, issues: list, *windows: tuple[str, str, bool, str]) -> list[str] | Failure:
|
||||
return status.lines("ABC-12", self.home, issues, Tmux(*windows))
|
||||
return status.lines("ABC-12", self.home, issues, {}, Tmux(*windows))
|
||||
|
||||
def test_a_chunk_that_asks_says_where_to_answer_and_one_that_works_runs(self) -> None:
|
||||
found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], (EPIC, "ABC-20 ?", False, ""), (EPIC, "ABC-21", False, ""))
|
||||
|
||||
@@ -12,7 +12,7 @@ def grounds_of(prompt: str, entries: list[Entry]) -> Grounds | Failure:
|
||||
"""What the quotes of a judge run on prompt are checked against, as judge_prompt would have made it for the transcript's entries: the premises and the records before the task are quotable, the transcript the judge was shown comes before the rules. The prompt is split on the headings judge_prompt writes, at the first of each; a Failure where it lacks one. Rules of an earlier wording stay part of the transcript, a slack that lets an evidence quote them pass."""
|
||||
before_task, task_heading, after_task = prompt.partition(f"\n\n{TASK_HEADING}")
|
||||
heading = transcript_heading(LOOP_CLAUDE)
|
||||
_, found_heading, shown = after_task.partition(heading)
|
||||
task, found_heading, shown = after_task.partition(heading)
|
||||
if not (task_heading and found_heading):
|
||||
return Failure(f"the archived prompt lacks the heading {TASK_HEADING.strip()!r} or {heading.strip()!r}, which judge_prompt writes")
|
||||
return Grounds(shown.removesuffix(f"\n\n{judge_rules(ANSWER_DESTINATIONS, LOOP_CLAUDE)}"), escalation_mark.after_mark(entries, 0), before_task, tuple(human_answers(entries, typed_answer)))
|
||||
return Grounds(shown.removesuffix(f"\n\n{judge_rules(ANSWER_DESTINATIONS, LOOP_CLAUDE)}"), escalation_mark.after_mark(entries, 0), before_task, tuple(human_answers(entries, typed_answer)), task.removesuffix("\n\n"))
|
||||
|
||||
@@ -399,6 +399,10 @@ class JudgeArchivedRuns(unittest.TestCase):
|
||||
self.assertIsInstance(self.judged(evidence="Ship fast.")[0], Rejected)
|
||||
self.assertIsInstance(self.judged(evidence="Worker chose option B.")[0], Unfinished)
|
||||
|
||||
def test_takes_the_task_as_evidence(self):
|
||||
self.assertIsInstance(self.judged(evidence="Do it.")[0], Unfinished)
|
||||
self.assertIsInstance(self.judged(evidence="Do it. ... Use Postgres.")[0], Unfinished)
|
||||
|
||||
def test_keeps_the_cost_and_the_run_of_a_rejected_reply(self):
|
||||
rejected, _ = self.judged(evidence="Never said.")
|
||||
self.assertEqual((rejected.cost, rejected.run.prompt), (0.25, self.PROMPT))
|
||||
|
||||
@@ -94,6 +94,11 @@ approval of the pull request, as its branch protection requires on GitHub, befor
|
||||
false. `project-config wait-for-approval` prints true or false; the full listing shows the setting only where
|
||||
it is true.
|
||||
|
||||
`merge` is an optional setting, "chunk" or "human": who merges a chunk's pull request. Left out, it is
|
||||
"chunk": `chunk-pr merge` merges it. Under "human", for a team whose rules keep the merge with a person,
|
||||
`chunk-pr merge` leaves the pull request ready and says it awaits a person's merge. `project-config merge`
|
||||
prints chunk or human; the full listing shows the setting only where it is human.
|
||||
|
||||
`tooling-on-host` is an optional setting, true or false: whether the loop may run the project's language
|
||||
runtime, package manager, tests and task runner directly on the host, for a project with no container
|
||||
setup. Left out, it is false, and they run through the project's container setup.
|
||||
@@ -142,7 +147,7 @@ and its commits and pull request are titled "ABC-123 - …".
|
||||
|
||||
Exit 1, naming each fault on stderr, where no config names the checkout, or its config leaves out a
|
||||
setting, names an unknown one, misspells a path, a language or a template, sets `coding-conventions` to anything but a list of paths, sets `wait-for-approval` or
|
||||
`tooling-on-host` to anything but true or false, sets `notifier` to anything but mattermost or slack or
|
||||
`tooling-on-host` to anything but true or false, sets `merge` to anything but chunk or human, sets `notifier` to anything but mattermost or slack or
|
||||
without `env-file`, sets `jira-finish-transition` or `jira-finish-status` to anything but a name, without the other or
|
||||
without a `plan` in Jira, names a Jira `plan` and leaves out `jira-score-formula` or `jira-score-bar`, sets
|
||||
one of those two without a `plan` in Jira, sets the formula to one that doesn't parse or the bar to anything
|
||||
|
||||
@@ -33,6 +33,10 @@ Notifier = typing.Literal["mattermost", "slack"]
|
||||
NOTIFIERS: tuple[Notifier, ...] = typing.get_args(Notifier)
|
||||
# An optional boolean setting: whether `chunk-pr merge` waits for a human's approval of the pull request. False where left out.
|
||||
WAIT_FOR_APPROVAL = "wait-for-approval"
|
||||
# An optional setting: who merges a chunk's pull request, one of MERGERS; the chunk where it is left out.
|
||||
MERGE = "merge"
|
||||
Merger = typing.Literal["chunk", "human"]
|
||||
MERGERS: tuple[Merger, ...] = typing.get_args(Merger)
|
||||
# An optional boolean setting: whether the loop may run the project's language runtime, package manager, tests and task runner on the host, for a project with no container setup. False where left out.
|
||||
TOOLING_ON_HOST = "tooling-on-host"
|
||||
# An optional number setting: the comprehension score under which code health is very important. A legacy project, whose code scores low, may lower it.
|
||||
@@ -124,6 +128,7 @@ class ProjectConfig:
|
||||
# The config's `env-file`, or None where it sets none.
|
||||
env_file: pathlib.Path | None = None
|
||||
wait_for_approval: bool = False
|
||||
merge: Merger = "chunk"
|
||||
tooling_on_host: bool = False
|
||||
readability_floor: decimal.Decimal = DEFAULT_FLOOR
|
||||
parallel_chunks: int = 1
|
||||
@@ -265,6 +270,10 @@ def parallel_read(value: object) -> int | Unfit:
|
||||
return value if type(value) is int and value >= 1 else Unfit(f"not a whole number of 1 or more, such as `{PARALLEL_CHUNKS} = 2`")
|
||||
|
||||
|
||||
def merger_read(value: object) -> Merger | Unfit:
|
||||
return next((name for name in MERGERS if name == value), None) or Unfit(f"not {' or '.join(f'"{name}"' for name in MERGERS)}")
|
||||
|
||||
|
||||
def notifier_read(value: object) -> Notifier | Unfit:
|
||||
return next((name for name in NOTIFIERS if name == value), None) or Unfit(f"not {' or '.join(NOTIFIERS)}")
|
||||
|
||||
@@ -341,6 +350,7 @@ def language_fault(value: object) -> str | None:
|
||||
# Each one-value setting, in the order `project-config` lists them.
|
||||
SCALARS = (
|
||||
Scalar(WAIT_FOR_APPROVAL, "wait_for_approval", switch, lambda on: "true" if on else "false"),
|
||||
Scalar(MERGE, "merge", merger_read),
|
||||
Scalar(TOOLING_ON_HOST, "tooling_on_host", switch, lambda on: "true" if on else "false"),
|
||||
Scalar(READABILITY_FLOOR, "readability_floor", floor_read),
|
||||
Scalar(PARALLEL_CHUNKS, "parallel_chunks", parallel_read),
|
||||
|
||||
@@ -390,6 +390,27 @@ class LoadTest(ConfigCase):
|
||||
(folder / "config.toml").write_text(CLIENT + f"coding-conventions = {value}\n", encoding="utf-8")
|
||||
self.assertIn(f"`coding-conventions` is {shown}, not a list of paths, each \"checkout:<path>\"", self.failure())
|
||||
|
||||
def test_merge_is_chunk_where_left_out_and_takes_human(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
left_out = load(self.checkout, self.checkout, self.home)
|
||||
assert isinstance(left_out, ProjectConfig), left_out
|
||||
self.assertEqual(left_out.merge, "chunk")
|
||||
for spelled in ("chunk", "human"):
|
||||
with self.subTest(spelled):
|
||||
(folder / "config.toml").write_text(CLIENT + f'merge = "{spelled}"\n')
|
||||
found = load(self.checkout, self.checkout, self.home)
|
||||
assert isinstance(found, ProjectConfig), found
|
||||
self.assertEqual(found.merge, spelled)
|
||||
|
||||
def test_a_merge_that_is_neither_chunk_nor_human_fails_naming_it(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
for spelled, named in (('"person"', "'person'"), ("true", "True")):
|
||||
with self.subTest(spelled):
|
||||
(folder / "config.toml").write_text(CLIENT + f"merge = {spelled}\n")
|
||||
found = load(self.checkout, self.checkout, self.home)
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertIn(f'`merge` is {named}, not "chunk" or "human"', found.reason)
|
||||
|
||||
def test_wait_for_approval_is_an_optional_boolean_that_is_false_where_left_out(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
left_out = load(self.checkout, self.checkout, self.home)
|
||||
@@ -506,7 +527,7 @@ class LoadTest(ConfigCase):
|
||||
|
||||
def test_the_failure_for_a_misplaced_env_file_and_a_missing_setting_names_both_and_lists_every_setting(self) -> None:
|
||||
folder = self.write("acme", "".join(line + "\n" for line in CLIENT.splitlines() if not line.startswith("plan")) + 'env-file = "checkout:.env"\n')
|
||||
self.assertEqual(self.failure(), f"{folder / 'config.toml'}: `plan` is missing; `env-file` is 'checkout:.env', not {OUTSIDE}. The settings are {', '.join(SETTINGS)}, and optionally branch, coding-conventions, commit-title, env-file, jira-finish-status, jira-finish-transition, jira-score-bar, jira-score-formula, language, notifier, parallel-chunks, pull-request-title, readability-floor, tooling-on-host, touch-predictions and wait-for-approval.")
|
||||
self.assertEqual(self.failure(), f"{folder / 'config.toml'}: `plan` is missing; `env-file` is 'checkout:.env', not {OUTSIDE}. The settings are {', '.join(SETTINGS)}, and optionally branch, coding-conventions, commit-title, env-file, jira-finish-status, jira-finish-transition, jira-score-bar, jira-score-formula, language, merge, notifier, parallel-chunks, pull-request-title, readability-floor, tooling-on-host, touch-predictions and wait-for-approval.")
|
||||
|
||||
def test_two_configs_naming_one_checkout_fail_naming_both(self) -> None:
|
||||
self.write("acme", CLIENT)
|
||||
@@ -685,6 +706,14 @@ class ToolTest(ConfigCase):
|
||||
self.assertEqual((self.run_tool("jira-score-formula").stdout, self.run_tool("jira-score-bar").stdout), ("100 * V / (2**S + 8)\n", "0.5\n"))
|
||||
self.assertIn("jira-score-formula: 100 * V / (2**S + 8)\njira-score-bar: 0.5\n", self.run_tool().stdout)
|
||||
|
||||
def test_prints_who_merges_and_lists_it_only_where_a_human_does(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
self.assertEqual(self.run_tool("merge").stdout, "chunk\n")
|
||||
self.assertNotIn("merge", self.run_tool().stdout)
|
||||
(folder / "config.toml").write_text(CLIENT + 'merge = "human"\n')
|
||||
self.assertEqual(self.run_tool("merge").stdout, "human\n")
|
||||
self.assertEqual(self.run_tool().stdout.splitlines()[-1], "merge: human")
|
||||
|
||||
def test_prints_true_or_false_for_wait_for_approval_and_lists_it_only_where_the_config_sets_it(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
left_out = self.run_tool("wait-for-approval")
|
||||
|
||||
+4
-4
@@ -145,15 +145,15 @@ Valid while `~/.claude` is a checkout of this repo.
|
||||
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 loop-claude, 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.** `~/.claude-projects/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.
|
||||
- **Machine settings.** `~/.claude-projects/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.
|
||||
- **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 never closes such an item, since a person's sub-tasks may cover only a part of it: once they are done, the item waits for the team to close it.
|
||||
- **Ranking.** Score, then Blocked by, in one weight chain: the epic's achieve goals, then code health, then the repo's goals. Where the epic and a repo disagree, the epic wins. do-epic re-ranks Jira's backlog to match, and people's issues keep their rank.
|
||||
- **Releases.** An epic item has no release. It ships into its repo's unreleased work: where the repo publishes something others consume, a bullet under `CHANGELOG.md` → `## Unreleased`, or nothing where the repo's plan is in Jira. The issue is no item of the repo's plan, so the chunk's worker writes the bullet in its branch and runs `chunk-pr merge` without `--finish`.
|
||||
- **Repos.** A repo's name is its main checkout's folder name, and a project config names that checkout. A missing checkout is cloned from the host of the epic's other repos; where unsure, do-epic asks. Unsure means the other repos don't all sit under one host and owner (the same host spelt as https and as ssh counts as two), an origin can't be read or isn't an https, ssh or scp-style address, the folder to clone into holds something else, or the clone fails. A repo no config names is cloned into the clone folder, and the human is asked to write its config. Each chunk uses its repo's model, routing, and language for commits and PRs. Jira text is in the epic's language, or else the machine's default.
|
||||
- **Running.** The epic caps the chunks running at once, and each repo's `parallel-chunks` still applies. do-epic and loop-claude never run chunks in the same repo at once. The cap is a line of the epic's description, `**Max parallel chunks:** 2`, and 1 without it, as `parallel-chunks` is. A repo's `parallel-chunks` counts the chunks of every epic in its checkout. Each window is named for its issue's key, and a tmux window option, `@chunk-root`, names the folder its chunk works in, which is how loop-claude sees do-epic's chunks in a checkout. do-epic and loop-claude each hold the checkout's `starting` lock from checking the checkout's chunks to starting a window there. A chunk without a repo works in `~/.local/state/do-epic/<EPIC-KEY>/`. do-epic archives its cycles under `~/.claude/do-epic-transcripts/`, not in loop-claude's archive, whose readers parse loop-claude's prompts. An open issue runs once a label records its repo; until do-epic picks repos itself, an issue without one waits, and `do-epic <EPIC-KEY>` says so.
|
||||
- **Long gates.** A chunk whose PR waits on a gate, such as a human approval, parks. It keeps its worktree, PR and session, and its state is in a file that survives a reboot. A parked chunk takes no running slot, and the items it blocks wait. do-epic polls the forge and resumes the chunk's session when the gate passes or a reviewer comments. It fixes reasonable feedback, replies to the rest, and changes the setup so review would have caught it. `do-epic <key> --status` and the tmux window names show what each chunk waits on. A gate is a pull request's pending checks or, on GitHub, the approval its branch protection requires; a draft waits on neither, since its worker has yet to mark it ready. On Gitea a draft is a pull request whose title opens with `WIP:` or `[WIP]`, Gitea's default `WORK_IN_PROGRESS_PREFIXES`. Changes a reviewer requested resume the chunk only while that review was made on the pull request's head commit and the pull request's author has not commented or replied after it; once the worker pushed or replied, the chunk parks on a new review, since GitHub keeps the decision until the reviewer reviews again. The chunk's window reads the forge once a minute, which no forge's rate limit notices. A chunk resumes only into a free slot, under the limits a starting chunk meets, and stays parked until then. `do-epic <key>` starts a parked chunk's window again whatever the limits, since the chunk stays parked. do-epic sets `CHUNK_PR_PARKS=1` for each worker, so `chunk-pr merge` fails at once where the pull request awaits an approval, and the worker's run doesn't hold a slot while the pull request waits.
|
||||
- **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 resumes when the forge no longer reports the pull request open, to clean up and finish. 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 tells the worker once to remove a worktree whose pull request is no longer open.
|
||||
- **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.
|
||||
@@ -386,7 +386,7 @@ Valid while the later fixes per finished chunk, which `score-outcomes` and the r
|
||||
- A file outside the checkout is read as it stands, never as the default branch held it: release standing, chunk-preflight and loop-claude's routing read such a plan or changelog from disk.
|
||||
- chunk-preflight and loop-claude's routing learn that a release's items are all done from the plan's commits. A plan outside the checkout no longer names such a release, so the release after it reads as next, and only the last release of all gets a release review called due and is called ready to cut. Both tools say so on every run, and that the release reviews and the cuts are the human's to call (`bin/release_plan/release_standing.py`, `UNSEEN_RELEASES`).
|
||||
|
||||
Messages keep each file's usual name, such as `todo.md`, as its label, since the config keeps the names. Revisit at 0.13.0, which plans the support for `score-outcomes`, the routing figures, the release standing and the owed scoring run.
|
||||
Messages keep each file's usual name, such as `todo.md`, as its label, since the config keeps the names. Revisit at 0.15.0, which plans the support for `score-outcomes`, the routing figures, the release standing and the owed scoring run.
|
||||
|
||||
## project config: `language` names the prose's language by its English name, and `commit-title`, `pull-request-title` and `branch` are brace templates over `{id}` and `{summary}`
|
||||
|
||||
|
||||
@@ -217,7 +217,9 @@ Launch prose-reviewer with what the diff touched and every section this review c
|
||||
- **An owed scoring run, or a queue another pull request holds.** Record the run, or wait, as the message says.
|
||||
- **A reviewer's comment**, where the project's config sets `wait-for-approval` (`chunk-pr --help`) and the pull request waits for a human's approval. Answer it in its thread on the forge, and fix what it asks as a finding of the chunk. Fixed or declined, it ends with the same setup change (§4 step 6). The wait doesn't hold the queue, so other chunks merge meanwhile.
|
||||
|
||||
A repo whose `AGENTS.md` names another method merges that way with the forge's CLI instead, after it finishes the chunk's items with `todo-item finish` in the branch, and once the pull request's checks pass, `~/.claude/bin/larv-review scoring-run-owed` exits 0 and, where `~/.claude/bin/project-config wait-for-approval` prints `true`, GitHub reports the pull request approved. A repo withholds this in its `AGENTS.md` → leave the PR ready and unmerged, and say which line withheld it.
|
||||
Where the project's config sets `merge = "human"` (`chunk-pr --help`), `chunk-pr merge` exits 0 instead, saying the pull request awaits a person's merge. Don't run it again: leave the pull request ready and unmerged, say so in the summary, and skip step 5, which whoever continues the chunk after the merge runs.
|
||||
|
||||
A repo whose `AGENTS.md` names another method merges that way with the forge's CLI instead, after it finishes the chunk's items with `todo-item finish` in the branch, and once the pull request's checks pass, `~/.claude/bin/larv-review scoring-run-owed` exits 0 and, where `~/.claude/bin/project-config wait-for-approval` prints `true`, GitHub reports the pull request approved. Where `~/.claude/bin/project-config merge` prints `human`, it doesn't merge at all: it finishes the items in the branch, marks the pull request ready and leaves it unmerged. A repo withholds this in its `AGENTS.md` → leave the PR ready and unmerged, and say which line withheld it.
|
||||
5. Merged → run `~/.claude/bin/chunk-pr clean` in the chunk's worktree, and put a failure it prints in the summary.
|
||||
6. Stop. The next chunk gets a fresh session.
|
||||
|
||||
|
||||
@@ -6,69 +6,229 @@
|
||||
|
||||
`Bar = 0.1`
|
||||
|
||||
`Next ID = 448`
|
||||
`Next ID = 461`
|
||||
|
||||
## Items
|
||||
|
||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 446 | 0.13.0 | | question | **Kill the process a stuck check names where its verdict is `stuck`, once the human says the recorded verdicts match what they would have done.** | 2 | 2 | 3 | 5 | 3 | 1.5 by 3 | 1.0 |
|
||||
| 445 | 0.13.0 | | | **Refuse a plan that holds an item a `Finish item <ID>` commit already removed, so a merge resolution cannot bring a finished item back.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3, 1.1 by 2 | 1.8 |
|
||||
| 365 | 0.13.0 | | | **Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 368 | 0.13.0 | | | **Call a release review due, call a release ready to cut, and tell whether a chunk owes a scoring run, for a plan outside the checkout, from the project repo's history or from Jira.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 309 | 0.13.0 | | | **Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.** | 2 | 2 | 2 | 4 | 2 | 1.4 by 3 | 1.2 |
|
||||
| 419 | 0.13.0 | | | **Run the external auto-reviewer until its review of the PR's head has no findings, and answer each of its threads on the PR.** | 3 | 2 | 3 | 6 | 5 | 1.1 by 5 | 1.1 |
|
||||
| 444 | 0.13.0 | | | **Rank an epic item that is split by repo, by the goals of each repo its sub-tasks name.** | 2 | 2 | 2 | 4 | 3 | 1 by 3 | 1.1 |
|
||||
| 366 | 0.13.0 | | | **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.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.4 by 2 | 1.1 |
|
||||
| 339 | 0.13.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 341 | 0.13.0 | | | **Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 298 | 0.13.0 | | | **Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.** | 3 | 3 | 3 | 7 | 4 | 1.4 by 2, 1.5 by 1 | 0.9 |
|
||||
| 395 | 0.13.0 | | decision | **Keep each block a save didn't change, with its localId, and the spacing paragraphs beside it as Jira or Confluence holds them.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 4 | 0.8 |
|
||||
| 425 | 0.13.0 | | | **Show on loop-claude's terminal why it doesn't start a chunk beside the next item, as chunk-preflight prints it.** | 1 | 1 | 2 | 2 | 2 | 1.5 by 2 | 0.7 |
|
||||
| 447 | 0.13.0 | | | **Stop a headless claude call that runs past a time limit, and report it as a failure, so a hung judge or stuck check can't hold the loop.** | 2 | 2 | 2 | 4 | 3 | 1.5 by 2 | 0.7 |
|
||||
| 367 | 0.13.0 | | | **Check that every write to a Jira plan leaves it ranked, as rule-hook's `todo-rank-check` checks `todo.md` today.** | 2 | 2 | 3 | 5 | 3 | 1.6 by 2 | 0.7 |
|
||||
| 423 | 0.13.0 | | | **Skip the judge's model call on a worker's final message that the offline classifier decides is finished.** | 3 | 3 | 3 | 7 | 5 | 1.4 by 2 | 0.4 |
|
||||
| 77 | 0.14.0 | | | **Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.** | 4 | 2 | 1 | 5 | 6 | 1.1 by 7, 1.4 by 7 | 2.1 |
|
||||
| 196 | 0.14.0 | | decision | **Replay the architecture, principles, overrides and product-owner passes with `review-replay` on Opus 5.5 projects, record each run in the review-replay routing decision, and, where a run qualifies a rung, add back the code that lowers a pass to it.** | 2 | 2 | 3 | 5 | 2 | 1.4 by 3 | 1.2 |
|
||||
| 321 | 0.14.0 | 196 | decision | **Evaluate the review passes that run on a rung `review-replay` qualified, against the chunks before them, and revert any pass whose findings or later fixes worsened.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 3, 1.4 by 2 | 2.0 |
|
||||
| 273 | 0.14.0 | | decision | **Re-tune the E + I steps of `REVIEW_STEPS` for 6 to 8 once 10 finished chunks have scored an E + I of 6 or more, from how well E + I orders their review rounds and 🔴 findings.** | 1 | 2 | 2 | 3 | 2 | 1.1 by 2, 1.4 by 3 | 2.0 |
|
||||
| 268 | 0.14.0 | | | **End a run whose release is ready to cut with a notice on loop-claude's terminal, in place of an interrupt that waits for an answer.** | 2 | 2 | 3 | 5 | 3 | 1 by 5 | 1.9 |
|
||||
| 171 | 0.14.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 1.8 |
|
||||
| 300 | 0.14.0 | | owner | **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, Self-sufficiency first; today the scoring runs at 81e8d8a1 scored Navigation 7.13 and 6.75, Locality 6.38 and 5.63, Shape 6.25 and 5.88, Self-sufficiency 5.88 and 5.25, and Overall 6.50 and 5.88.** | 4 | 2 | 3 | 7 | 8 | code health by 8 | 1.7 |
|
||||
| 264 | 0.14.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.7 |
|
||||
| 323 | 0.14.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.7 |
|
||||
| 342 | 0.14.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.7 |
|
||||
| 149 | 0.14.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.6 |
|
||||
| 165 | 0.14.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.6 |
|
||||
| 392 | 0.14.0 | | owner | **Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, forge and host), so a newcomer finds a tool's neighbours in one place.** | 3 | 1 | 3 | 5 | 7 | code health by 4 | 1.6 |
|
||||
| 151 | 0.14.0 | | decision | **Keep 10 to 20 settled decisions per project as its goals' test set, and rerun them after a goal changes.** | 3 | 2 | 2 | 5 | 5 | 1.2 by 7 | 1.6 |
|
||||
| 68 | 0.14.0 | | principle | **Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.** | 2 | 1 | 1 | 2 | 4 | 1.1 by 5 | 1.5 |
|
||||
| 102 | 0.14.0 | | | **Give loop-claude's retry delay, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 1.5 |
|
||||
| 135 | 0.14.0 | | | **Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 4 | 1.5 |
|
||||
| 443 | 0.14.0 | | | **Measure whether compacting a waiting worker's session cut the cost of 20 chunks with an interrupt, with quality holding.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4 | 1.4 |
|
||||
| 5 | 0.14.0 | | decision | **Key a project on its checkout's full path, and refuse to start while another session uses that key.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 6 | 1.4 |
|
||||
| 291 | 0.14.0 | | owner | **Let `principles/technical-principles.md` → "Sane defaults" allow a library whose README goals ask that it work with no config to default the clock and randomness in its public constructor, where a documented option overrides each.** | 1 | 2 | 3 | 4 | 1 | 1.2 by 3 | 1.3 |
|
||||
| 156 | 0.14.0 | | decision | **Drop `rank_todo.py`'s ranking of an old-shape table once no project under `~/code` holds one.** | 2 | 1 | 3 | 4 | 4 | 1.1 by 4 | 1.2 |
|
||||
| 388 | 0.14.0 | | | **Refuse an agent's Write or Edit of a routing ladder file in rule-hook, since a change to the ladder is the human's.** | 1 | 1 | 3 | 3 | 2 | 1.2 by 3 | 1.2 |
|
||||
| 260 | 0.14.0 | | decision | **Compare the first 20 chunks whose worker got the reading rule with the 20 before them, on review rounds past each pass's first, unfinished verdicts, 🔴, 🟡 and misread findings, dollars and hours per chunk, and drop the rule where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3 | 1.2 |
|
||||
| 51 | 0.14.0 | | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 2 | 1 | 3 | 4 | 5 | 1.1 by 5 | 1.1 |
|
||||
| 201 | 0.14.0 | | owner | **Save the human's tmux setups and restore them after a reboot, so work is up and running again quickly.** | 3 | 2 | 1 | 4 | 4 | 1.5 by 4 | 1.1 |
|
||||
| 267 | 0.14.0 | | | **Keep waiting when an interrupt gets an empty answer, at the terminal or in the claude opened for it, in place of stopping the loop.** | 2 | 1 | 3 | 4 | 2 | 1.5 by 3 | 1.1 |
|
||||
| 4 | 0.14.0 | | | **Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.** | 3 | 2 | 3 | 6 | 3 | 1.1 by 3 | 1.1 |
|
||||
| 324 | 0.14.0 | | | **Count in the routing figures the finished chunks whose worker wrote no `Chunk items:` line.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 2, 1.4 by 1 | 1.1 |
|
||||
| 187 | 0.14.0 | | | **Count the tokens a worker spends reading reviewers' reports, so goal 1.4's signal shows whether report files lowered what a review costs the worker's context.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 266 | 0.14.0 | | | **Move the chunks archived under the key `home/lilleman/.claude` to the key `claude-config`, so the routing figures and `score-outcomes` count this repo's chunks as one project.** | 3 | 2 | 2 | 5 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 181 | 0.14.0 | | principle | **Have the test of a quoted answer's step-up assert the stepped rung's facts as literals, not through `prompts.rungs_held`.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 193 | 0.14.0 | | | **Narrow `numbered`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.** | 1 | 1 | 3 | 3 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 194 | 0.14.0 | | | **Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 265 | 0.14.0 | | | **Archive each wait that costs a chunk wall time, for a usage limit, low memory, a failed worker start or a heavy slot, with its start and end stamps, so goal 1.5's hours split waiting from work.** | 3 | 2 | 2 | 5 | 4 | 1.5 by 3 | 0.8 |
|
||||
| 169 | 0.14.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 0.7 |
|
||||
| 197 | 0.14.0 | | | **Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.** | 2 | 2 | 3 | 5 | 2 | 1.5 by 1 | 0.4 |
|
||||
| 1 | 0.15.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 |
|
||||
| 397 | 0.15.0 | | owner | **Script each step that the chunks of releases 0.10.0 to 0.14.0 repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 2.3 |
|
||||
| 460 | 0.14.0 | | | **Review the judge's fix for quoting the worker's task as evidence with every larv-review pass it fires, and adjust it to their findings.** | 2 | 2 | 3 | 5 | 2 | code health by 3, 1.1 by 5 | 7.2 |
|
||||
| 452 | 0.14.0 | | | **Make do-epic's view of the Jira workflow settings: the statuses at which an issue unblocks the issues it blocks, and the moves the team's own automation makes, so do-epic makes none of those.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 7, 1.5 by 3 | 2.1 |
|
||||
| 449 | 0.14.0 | | | **Record do-epic's repo picks and sub-task summaries in the team's own spelling, such as `core-4` and `core-4: Bygg …`, as its config sets them.** | 2 | 2 | 2 | 4 | 3 | 1.6 by 6 | 2.0 |
|
||||
| 458 | 0.14.0 | | | **Resume a chunk whose pull request awaits a person's merge once it no longer merges cleanly into the default branch, so the worker brings it level again.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 4, 1.5 by 3 | 1.9 |
|
||||
| 453 | 0.14.0 | | | **Make the issue types that do-epic and `todo-item add` file in Jira settings, since a Jira project such as TW has no Task type.** | 2 | 2 | 1 | 3 | 2 | 1.6 by 5 | 1.8 |
|
||||
| 457 | 0.14.0 | | | **Keep loop-claude from starting a chunk for an item whose pull request is ready and awaits a person's merge under `merge = "human"`.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 5, 1.4 by 3 | 1.7 |
|
||||
| 450 | 0.14.0 | | | **Add `do-epic <EPIC-KEY> --dry-run`, which prints every Jira write planning would make and each chunk that would start, and makes none of them.** | 2 | 2 | 2 | 4 | 3 | 1.6 by 5 | 1.6 |
|
||||
| 459 | 0.14.0 | | | **Make the prose standard require that a sentence giving one property to several named tables, fields or flags holds for each of them.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 3 | 1.3 |
|
||||
| 454 | 0.14.0 | | | **Start a do-epic chunk's issue as the team's board expects, by settings: assigned to the account do-epic works as, moved by a start transition and added to a board's active sprint.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 4 | 1.1 |
|
||||
| 446 | 0.15.0 | | question | **Kill the process a stuck check names where its verdict is `stuck`, once the human says the recorded verdicts match what they would have done.** | 2 | 2 | 3 | 5 | 3 | 1.5 by 3 | 1.0 |
|
||||
| 77 | 0.15.0 | | | **Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.** | 4 | 2 | 1 | 5 | 6 | 1.1 by 7, 1.4 by 7 | 2.1 |
|
||||
| 196 | 0.15.0 | | decision | **Replay the architecture, principles, overrides and product-owner passes with `review-replay` on Opus 5.5 projects, record each run in the review-replay routing decision, and, where a run qualifies a rung, add back the code that lowers a pass to it.** | 2 | 2 | 3 | 5 | 2 | 1.4 by 3 | 1.2 |
|
||||
| 321 | 0.15.0 | 196 | decision | **Evaluate the review passes that run on a rung `review-replay` qualified, against the chunks before them, and revert any pass whose findings or later fixes worsened.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 3, 1.4 by 2 | 2.0 |
|
||||
| 273 | 0.15.0 | | decision | **Re-tune the E + I steps of `REVIEW_STEPS` for 6 to 8 once 10 finished chunks have scored an E + I of 6 or more, from how well E + I orders their review rounds and 🔴 findings.** | 1 | 2 | 2 | 3 | 2 | 1.1 by 2, 1.4 by 3 | 2.0 |
|
||||
| 268 | 0.15.0 | | | **End a run whose release is ready to cut with a notice on loop-claude's terminal, in place of an interrupt that waits for an answer.** | 2 | 2 | 3 | 5 | 3 | 1 by 5 | 1.9 |
|
||||
| 445 | 0.15.0 | | | **Refuse a plan that holds an item a `Finish item <ID>` commit already removed, so a merge resolution cannot bring a finished item back.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3, 1.1 by 2 | 1.8 |
|
||||
| 171 | 0.15.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 1.8 |
|
||||
| 300 | 0.15.0 | | owner | **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, Self-sufficiency first; today the scoring runs at 81e8d8a1 scored Navigation 7.13 and 6.75, Locality 6.38 and 5.63, Shape 6.25 and 5.88, Self-sufficiency 5.88 and 5.25, and Overall 6.50 and 5.88.** | 4 | 2 | 3 | 7 | 8 | code health by 8 | 1.7 |
|
||||
| 264 | 0.15.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.7 |
|
||||
| 323 | 0.15.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.7 |
|
||||
| 342 | 0.15.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.7 |
|
||||
| 149 | 0.15.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.6 |
|
||||
| 165 | 0.15.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.6 |
|
||||
| 392 | 0.15.0 | | owner | **Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, forge and host), so a newcomer finds a tool's neighbours in one place.** | 3 | 1 | 3 | 5 | 7 | code health by 4 | 1.6 |
|
||||
| 456 | 0.15.0 | | | **Make the child-shell stop test pass under load, so a full test run doesn't fail on a race.** | 2 | 2 | 2 | 4 | 2 | 1.1 by 2, 1.5 by 2 | 1.6 |
|
||||
| 151 | 0.15.0 | | decision | **Keep 10 to 20 settled decisions per project as its goals' test set, and rerun them after a goal changes.** | 3 | 2 | 2 | 5 | 5 | 1.2 by 7 | 1.6 |
|
||||
| 68 | 0.15.0 | | principle | **Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.** | 2 | 1 | 1 | 2 | 4 | 1.1 by 5 | 1.5 |
|
||||
| 102 | 0.15.0 | | | **Give loop-claude's retry delay, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 1.5 |
|
||||
| 135 | 0.15.0 | | | **Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 4 | 1.5 |
|
||||
| 443 | 0.15.0 | | | **Measure whether compacting a waiting worker's session cut the cost of 20 chunks with an interrupt, with quality holding.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4 | 1.4 |
|
||||
| 5 | 0.15.0 | | decision | **Key a project on its checkout's full path, and refuse to start while another session uses that key.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 6 | 1.4 |
|
||||
| 291 | 0.15.0 | | owner | **Let `principles/technical-principles.md` → "Sane defaults" allow a library whose README goals ask that it work with no config to default the clock and randomness in its public constructor, where a documented option overrides each.** | 1 | 2 | 3 | 4 | 1 | 1.2 by 3 | 1.3 |
|
||||
| 156 | 0.15.0 | | decision | **Drop `rank_todo.py`'s ranking of an old-shape table once no project under `~/code` holds one.** | 2 | 1 | 3 | 4 | 4 | 1.1 by 4 | 1.2 |
|
||||
| 388 | 0.15.0 | | | **Refuse an agent's Write or Edit of a routing ladder file in rule-hook, since a change to the ladder is the human's.** | 1 | 1 | 3 | 3 | 2 | 1.2 by 3 | 1.2 |
|
||||
| 365 | 0.15.0 | | | **Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 368 | 0.15.0 | | | **Call a release review due, call a release ready to cut, and tell whether a chunk owes a scoring run, for a plan outside the checkout, from the project repo's history or from Jira.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 260 | 0.15.0 | | decision | **Compare the first 20 chunks whose worker got the reading rule with the 20 before them, on review rounds past each pass's first, unfinished verdicts, 🔴, 🟡 and misread findings, dollars and hours per chunk, and drop the rule where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3 | 1.2 |
|
||||
| 309 | 0.15.0 | | | **Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.** | 2 | 2 | 2 | 4 | 2 | 1.4 by 3 | 1.2 |
|
||||
| 51 | 0.15.0 | | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 2 | 1 | 3 | 4 | 5 | 1.1 by 5 | 1.1 |
|
||||
| 419 | 0.15.0 | | | **Run the external auto-reviewer until its review of the PR's head has no findings, and answer each of its threads on the PR.** | 3 | 2 | 3 | 6 | 5 | 1.1 by 5 | 1.1 |
|
||||
| 444 | 0.15.0 | | | **Rank an epic item that is split by repo, by the goals of each repo its sub-tasks name.** | 2 | 2 | 2 | 4 | 3 | 1 by 3 | 1.1 |
|
||||
| 366 | 0.15.0 | | | **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.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.4 by 2 | 1.1 |
|
||||
| 201 | 0.15.0 | | owner | **Save the human's tmux setups and restore them after a reboot, so work is up and running again quickly.** | 3 | 2 | 1 | 4 | 4 | 1.5 by 4 | 1.1 |
|
||||
| 267 | 0.15.0 | | | **Keep waiting when an interrupt gets an empty answer, at the terminal or in the claude opened for it, in place of stopping the loop.** | 2 | 1 | 3 | 4 | 2 | 1.5 by 3 | 1.1 |
|
||||
| 4 | 0.15.0 | | | **Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.** | 3 | 2 | 3 | 6 | 3 | 1.1 by 3 | 1.1 |
|
||||
| 324 | 0.15.0 | | | **Count in the routing figures the finished chunks whose worker wrote no `Chunk items:` line.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 2, 1.4 by 1 | 1.1 |
|
||||
| 187 | 0.15.0 | | | **Count the tokens a worker spends reading reviewers' reports, so goal 1.4's signal shows whether report files lowered what a review costs the worker's context.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 266 | 0.15.0 | | | **Move the chunks archived under the key `home/lilleman/.claude` to the key `claude-config`, so the routing figures and `score-outcomes` count this repo's chunks as one project.** | 3 | 2 | 2 | 5 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 339 | 0.15.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 341 | 0.15.0 | | | **Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.0 |
|
||||
| 181 | 0.15.0 | | principle | **Have the test of a quoted answer's step-up assert the stepped rung's facts as literals, not through `prompts.rungs_held`.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 193 | 0.15.0 | | | **Narrow `numbered`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.** | 1 | 1 | 3 | 3 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 194 | 0.15.0 | | | **Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 298 | 0.15.0 | | | **Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.** | 3 | 3 | 3 | 7 | 4 | 1.4 by 2, 1.5 by 1 | 0.9 |
|
||||
| 265 | 0.15.0 | | | **Archive each wait that costs a chunk wall time, for a usage limit, low memory, a failed worker start or a heavy slot, with its start and end stamps, so goal 1.5's hours split waiting from work.** | 3 | 2 | 2 | 5 | 4 | 1.5 by 3 | 0.8 |
|
||||
| 395 | 0.15.0 | | decision | **Keep each block a save didn't change, with its localId, and the spacing paragraphs beside it as Jira or Confluence holds them.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 4 | 0.8 |
|
||||
| 425 | 0.15.0 | | | **Show on loop-claude's terminal why it doesn't start a chunk beside the next item, as chunk-preflight prints it.** | 1 | 1 | 2 | 2 | 2 | 1.5 by 2 | 0.7 |
|
||||
| 169 | 0.15.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 0.7 |
|
||||
| 447 | 0.15.0 | | | **Stop a headless claude call that runs past a time limit, and report it as a failure, so a hung judge or stuck check can't hold the loop.** | 2 | 2 | 2 | 4 | 3 | 1.5 by 2 | 0.7 |
|
||||
| 367 | 0.15.0 | | | **Check that every write to a Jira plan leaves it ranked, as rule-hook's `todo-rank-check` checks `todo.md` today.** | 2 | 2 | 3 | 5 | 3 | 1.6 by 2 | 0.7 |
|
||||
| 423 | 0.15.0 | | | **Skip the judge's model call on a worker's final message that the offline classifier decides is finished.** | 3 | 3 | 3 | 7 | 5 | 1.4 by 2 | 0.4 |
|
||||
| 197 | 0.15.0 | | | **Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.** | 2 | 2 | 3 | 5 | 2 | 1.5 by 1 | 0.4 |
|
||||
| 1 | 0.16.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 |
|
||||
| 397 | 0.16.0 | | owner | **Script each step that the chunks of releases 0.10.0 to 0.15.0 repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 2.3 |
|
||||
|
||||
## Details
|
||||
|
||||
### 460. Review the judge's fix for quoting the worker's task as evidence with every larv-review pass it fires, and adjust it to their findings.
|
||||
|
||||
The fix shipped without any larv-review pass, reviewer or comprehension check, at lilleman's request on 2026-11-19, so loop-claude could run unattended again: PR #641, commit "Let the judge quote the worker's task as evidence". Before it, the judge read the task above the transcript's tail but `quotes_checked` checked the evidence only against that tail. Once a session outgrew the tail, a verdict quoting the task, such as `Do the next chunk in 0.13.0`, was rejected three times running, and the loop exited after each merged chunk (items 448, 455 and 451). `Grounds` now carries the task, and the evidence must appear in the task, then the tail.
|
||||
|
||||
Run the passes the change fires: security, stability (with `~/.claude/rules/this-machine/cross-repo-review.md` where it applies), prose for the comments and docstrings it changed, and overrides if `rule-hook overrides` prints a line. Run the comprehension check where `larv-review` says one is due. Also weigh whether the evidence schema's description ("a verbatim quote of the one transcript passage") should name the task too, and whether `misquoted_evidence`'s message should say "the task or the transcript".
|
||||
|
||||
Touches:
|
||||
- `bin/agent_cycle/judge.py`: `Grounds` (small), `quotes_checked` (small), `judge_prompt` (small)
|
||||
- `bin/judge_replay/archived_prompt.py`: `grounds_of` (small)
|
||||
- `bin/agent_cycle/test_judge.py`
|
||||
- `bin/judge_replay/test_judge_replay.py`
|
||||
|
||||
### 452. Make do-epic's view of the Jira workflow settings: the statuses at which an issue unblocks the issues it blocks, and the moves the team's own automation makes, so do-epic makes none of those.
|
||||
|
||||
do-epic counts an issue as done only where Jira's status category is done, and moves a finished chunk's issue to done itself, by `jira-finish-transition`. On a team whose CI moves issues through the workflow, both are wrong. On TW, CI moves an issue to Code Review when its pull request opens, to Release Ready when it merges, and to Done when it is deployed. So do-epic would move an issue to Done before it is deployed, and would hold every blocked issue until the blocker is deployed, though the team wants blocked work to start once the blocker's pull request merges.
|
||||
|
||||
- Settings in do-epic's config.toml name the statuses at which an issue unblocks the issues it blocks, such as `jira-unblock-statuses = ["Release Ready", "Done"]`; without them, Jira's done category counts, as today.
|
||||
- A setting says which moves the team's workflow makes on its own, so do-epic makes none of them. With the setting, a finished chunk moves no status and stops with no reason; `jira-finish-transition` then only closes the epic.
|
||||
- The epic's finishing waits until every issue is in Jira's done category, so release reviews follow the deploy.
|
||||
- `--status` names the status an issue waits to reach.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/config.py`: `DoEpicConfig`, `load`
|
||||
- `bin/do_epic/backend/protocol.py`: `EpicIssue` (small)
|
||||
- `bin/do_epic/backend/jira.py`: `found_of` (small), `finish_issue`
|
||||
- `bin/do_epic/scheduler.py`: `open_blockers`
|
||||
- `bin/do_epic/main.py`: `handed_on`, `split_items_closed`
|
||||
- `bin/do_epic/finish.py`: `due` (small), `still_open` (small)
|
||||
- `bin/do_epic/status.py`: `lines` (small)
|
||||
- `bin/do_epic/test_scheduler.py`
|
||||
- `bin/do_epic/test_main.py`
|
||||
- `bin/do_epic/backend/test_jira.py`
|
||||
- `README.md`: `### Set up a project` (small)
|
||||
|
||||
### 449. Record do-epic's repo picks and sub-task summaries in the team's own spelling, such as `core-4` and `core-4: Bygg …`, as its config sets them.
|
||||
|
||||
do-epic writes its own spelling into a team's Jira: a pick as `repo:core-4` and a sub-task's summary as `[core-4] <the item's summary>`. A team with its own convention, such as TW's label `core-4` and summary `core-4: Bygg …` with a capital after the colon, then finds two labels on each issue and summaries in a shape its board doesn't use. Goal 1.6 asks the loop to fit the tracker's conventions, not change them.
|
||||
|
||||
- do-epic records a repo pick as the team's label for that repo, from the label table item 448 adds, and as `repo:<name>` only for a repo the table doesn't name.
|
||||
- A summary template in do-epic's config.toml shapes each sub-task's summary, such as `sub-task-summary = "{label}: {Summary}"`, where `{Summary}` is the item's summary with a capital first letter. Without the setting, the summary stays `[<repo>] <summary>`.
|
||||
- `do-epic-claude` and `do-epic-human` stay as they are: no team label means either.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/repo_pick.py`: `label_of`, `record`
|
||||
- `bin/do_epic/split.py`: `task_summary`, `split` (small)
|
||||
- `bin/do_epic/planning.py`: `placed` (small), `answered` (small)
|
||||
- `bin/do_epic/config.py`: `DoEpicConfig`, `load` (small)
|
||||
- `bin/do_epic/test_repo_pick.py`
|
||||
- `bin/do_epic/test_split.py`
|
||||
- `README.md`: `### Set up a project` (small)
|
||||
|
||||
### 458. Resume a chunk whose pull request awaits a person's merge once it no longer merges cleanly into the default branch, so the worker brings it level again.
|
||||
|
||||
Under `merge = "human"` a pull request stays ready for hours or days while the default branch moves. A conflict, such as each branch holding its own changelog bullet or plan edit, or a branch protection that requires an up-to-date branch, then blocks the person who would merge it. Yet `gate` in `bin/do_epic/gates.py` reads only the draft state, the checks, the review decision and the waiting threads, so the window and `--status` keep saying `awaits your merge`, and nothing resumes the chunk unless a reviewer comments.
|
||||
|
||||
- Where `by_human`, `gate` reads the forge's mergeability before it returns the `your merge` gate: GitHub's `mergeable` and `mergeStateStatus`, Gitea's `mergeable`. No reader exists yet under `bin/forge/`; add one beside `open_pull` in `bin/forge/pulls.py`.
|
||||
- A pull request that conflicts with the default branch, or is behind it where the branch protection requires an up-to-date branch, gives an `Open` whose news tells the worker to run `chunk-pr merge` again, which levels, pushes, waits for the checks and marks ready. Settle whether that rerun passes `--finish` again, since the items are already finished on the branch.
|
||||
- GitHub reports `mergeable` as `UNKNOWN` while it computes it: that keeps the `your merge` gate until the next read, rather than resuming the chunk.
|
||||
- State the new resume in `docs/decisions.md` → "Long gates".
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/gates.py`: `gate` (small)
|
||||
- `bin/forge/pulls.py`
|
||||
- `bin/forge/test_forge.py`
|
||||
- `bin/do_epic/test_gates.py`
|
||||
|
||||
### 453. Make the issue types that do-epic and `todo-item add` file in Jira settings, since a Jira project such as TW has no Task type.
|
||||
|
||||
do-epic and `todo-item add` file every new issue as a Task, the name `plan_store/jira_epic.py` sets as `ISSUE_TYPE`. A Jira project without a Task type, such as TW, whose types are Feature, Bug, Chore and Investigation, refuses each one. So `do-epic --file` fails there, and so does the epic's finishing, which files a release review for each repo.
|
||||
|
||||
- A setting in do-epic's config.toml names the type a finding is filed as, and another the type of a release review, such as `jira-finding-type = "Feature"` and `jira-review-type = "Chore"`; Task stays the default.
|
||||
- A project config whose plan is a Jira epic takes the same `jira-finding-type` for `todo-item add`.
|
||||
- A type the project doesn't have fails before anything is filed, naming the types the project has.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/plan_store/jira_epic.py`: `ISSUE_TYPE`
|
||||
- `bin/do_epic/backend/jira.py`: `JiraEpic.file`
|
||||
- `bin/do_epic/config.py`: `DoEpicConfig`, `load` (small)
|
||||
- `bin/do_epic/findings.py`: `written` (small)
|
||||
- `bin/project_config/settings.py`: `SCALARS` (small)
|
||||
- `bin/do_epic/backend/test_jira.py`
|
||||
- `README.md`: `### Set up a project` (small)
|
||||
|
||||
### 457. Keep loop-claude from starting a chunk for an item whose pull request is ready and awaits a person's merge under `merge = "human"`.
|
||||
|
||||
Under `merge = "human"`, `chunk-pr merge` leaves a chunk's pull request ready, with its item finished only on the branch. Until a person merges it, the default branch's plan still holds the item, so `chunk-preflight` names it as the next item again. loop-claude then starts a cycle that can only run `chunk-pr merge` once more and end, and it does so every cycle until the merge.
|
||||
|
||||
- `chunk-preflight` passes over an item whose branch has an open pull request that isn't a draft, where the project's config sets `merge = "human"`, and says so in its facts.
|
||||
- Where every remaining item of the release waits like that, loop-claude stops and says which pull requests await a merge.
|
||||
- Once the pull request is merged, the next chunk's preflight runs `chunk-pr clean` for the worktree it left, or tells the worker to.
|
||||
- Under `merge = "human"`, `chunk-pr merge --finish` finishes a plan kept in Jira, or a plan or changelog kept in the config's folder, at once, before the person merges; where the pull request is closed unmerged, the item stays finished. Settle whether loop-claude finishes such an item only after the merge.
|
||||
- Under loop-claude nobody answers a reviewer's comment on a pull request that awaits a person's merge, since the chunk's run has ended. Settle who does, or say in README that the person asks for it.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/chunk_preflight/main.py`
|
||||
- `bin/chunk_preflight/facts.py`: `item_lines`, `pulls_text`
|
||||
- `bin/chunk_preflight/test_chunk_preflight.py`
|
||||
- `bin/chunk_pr/main.py`: `levelled_and_finished`, `finished` (small)
|
||||
- `bin/chunk_pr/test_chunk_pr.py`
|
||||
- `README.md`: `### Set up a project` (small)
|
||||
|
||||
### 450. Add `do-epic <EPIC-KEY> --dry-run`, which prints every Jira write planning would make and each chunk that would start, and makes none of them.
|
||||
|
||||
`do-epic <EPIC-KEY>` writes to Jira before it starts any chunk: labels, sub-tasks, comments on a team's issues and a new backlog order. A person has no way to see those writes before they happen, so the first run on a team's epic is a gamble, and the writes can't be taken back in one step. On TW-13503 the first run would have filed duplicate sub-tasks and posted comments to the team.
|
||||
|
||||
- `do-epic <EPIC-KEY> --dry-run` runs planning and the scheduler against the epic as Jira holds it, through a store that records each write in place of making it. It prints each label, sub-task with its summary and labels, comment and rank move it would write, then each chunk that would start and why each other open issue waits, as `--status` words it.
|
||||
- It writes nothing to Jira, starts no window and asks no question; where planning would ask, it prints the question.
|
||||
- `do-epic --help` and README → Tools describe the flag.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/main.py`: `run`, `windows_opened`
|
||||
- `bin/do_epic/planning.py`: `planned` (small), `answered` (small)
|
||||
- `bin/do_epic/backend/fake.py`
|
||||
- `bin/do_epic/backend/protocol.py`: `EpicStore` (small)
|
||||
- `bin/do_epic/test_main.py`
|
||||
- `bin/do_epic/test_planning.py`
|
||||
- `README.md`: `## Tools` (small)
|
||||
|
||||
### 459. Make the prose standard require that a sentence giving one property to several named tables, fields or flags holds for each of them.
|
||||
|
||||
An outside reviewer's finding on a README raised it: a sentence described the rows of two tables, saying each has a `name`, and only one of the two tables has that column. The prose pass read the sentence and not the two sources behind it. Add the rule to `skills/larv-review/standards/prose.md`: a sentence that gives a property to several named things holds for every one, checked in each source; where it fails for one, the sentence splits.
|
||||
|
||||
Touches:
|
||||
- `skills/larv-review/standards/prose.md`
|
||||
|
||||
### 454. Start a do-epic chunk's issue as the team's board expects, by settings: assigned to the account do-epic works as, moved by a start transition and added to a board's active sprint.
|
||||
|
||||
When a do-epic chunk starts, its issue stays as Jira holds it: unassigned, in New and outside the sprint. A team whose board shows who works on what, such as TW, where an issue being worked is assigned to the person, In Progress and in the active sprint, then sees nothing of the loop's work. Today each worker would have to do this by hand, from rules only some machines hold.
|
||||
|
||||
- Settings in do-epic's config.toml name a transition to make when a chunk starts, such as `jira-start-transition = "In Progress"`, and a board whose active sprint the issue joins, such as `jira-board = 6`. Without them, nothing moves, as today.
|
||||
- A starting chunk assigns its issue to the account whose credentials do-epic uses, unless someone else holds it, which it leaves alone and says so. A sub-task's parent joins the sprint in its place, since Jira keeps a sub-task in its parent's sprint.
|
||||
- An issue already past the start transition, such as one in Code Review, keeps its status.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/config.py`: `DoEpicConfig`, `load` (small)
|
||||
- `bin/do_epic/backend/protocol.py`: `EpicStore`
|
||||
- `bin/do_epic/backend/jira.py`: `JiraEpic`
|
||||
- `bin/do_epic/backend/fake.py`
|
||||
- `bin/do_epic/backend/contract.py`: `EpicStoreContract`
|
||||
- `bin/do_epic/main.py`: `chunk_run`
|
||||
- `bin/do_epic/backend/test_jira.py`
|
||||
- `README.md`: `### Set up a project` (small)
|
||||
|
||||
### 446. Kill the process a stuck check names where its verdict is `stuck`, once the human says the recorded verdicts match what they would have done.
|
||||
|
||||
Item 422 judges a worker that stalls before its result, but only reports: each verdict goes to the terminal and to `stuck-workers.md` in the project's transcript archive. Question for the human: after a few days of verdicts there, do they match what you would have done? Once you say yes, kill only the process a `stuck` verdict names, and only where the pid is below the worker's claude, never the worker or the loop, and record the call in a decision.
|
||||
@@ -79,152 +239,6 @@ Touches:
|
||||
- `bin/loop_effects/child_shells.py`: `stop` (small)
|
||||
- `bin/loop_claude/loop/usage.py`: `HELP` (small)
|
||||
|
||||
### 445. Refuse a plan that holds an item a `Finish item <ID>` commit already removed, so a merge resolution cannot bring a finished item back.
|
||||
|
||||
Merging main into item-442 in 610edb1a resolved a todo.md conflict by keeping item 310's row and detail, which e019a6b7 had just finished. loop-claude then started a chunk on item 310, whose work had already merged, and that chunk only removed the item again. No check noticed: `rank_todo.py --check` reads one file, and rule-hook's `todo-rank-check` sees only an agent's writes, not what a merge resolution keeps.
|
||||
|
||||
Have the gate, or `rank_todo.py --check` where it runs in a checkout, refuse a plan that holds an ID a commit titled `Finish item <ID>` removed on the default branch, naming the commit. An item removed by mistake can come back only under a new ID, which keeps the check simple.
|
||||
|
||||
### 365. Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.
|
||||
|
||||
lilleman's call, 2026-11-12: 0.10.0 and 0.11.0 switch the history tools off for a plan outside the checkout, and 0.13.0 holds only their ports. In Jira a dropped item, which `Drop item` commit titles mark today, is an issue resolved by a resolution the config names.
|
||||
|
||||
### 368. Call a release review due, call a release ready to cut, and tell whether a chunk owes a scoring run, for a plan outside the checkout, from the project repo's history or from Jira.
|
||||
|
||||
One of 0.13.0's history ports, per lilleman's call of 2026-11-12. Filed from item 344's stability review, round 1.
|
||||
|
||||
Today a plan outside the checkout is read as it stands, since no commit holds it. So:
|
||||
|
||||
- `bin/release_plan/release_standing.py`'s `todos_since` holds one text. Once a release's last item ships, the plan no longer names the release, and `next_release` gives the release after it as next. chunk-preflight and loop-claude say `UNSEEN_RELEASES` on every run: the release reviews and the cuts are the human's to call.
|
||||
- `bin/larv_review/owed.py`'s `owed_scoring_run` says it cannot tell whether the chunk owes a scoring run, and the merge goes on. `needs-scoring-run` and `record-scoring` refuse the ID of an item the plan no longer holds.
|
||||
|
||||
Read the plan's earlier texts from the project repo's commits, which item 345 writes, or the releases Jira's issues name. Then drop `UNSEEN_RELEASES` and both refusals, and the bullets that record them in `docs/decisions.md` → "project config: a tool that reads a file's commits …".
|
||||
|
||||
The comprehension seats found `next_release` hard to read: the tag cases, dated headings, renames and `named_releases` meet in one function. Make it easier to read while there.
|
||||
|
||||
### 309. Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.
|
||||
|
||||
Seats cost $1,143 of the $9,154 measured from 2026-09-30 to 2026-11-11 (12.5%), scoring runs $470 of that. A scoring run today is four seats, run twice on one head: eight seat runs. Two seats on the second pass make it six, and two on both passes four.
|
||||
|
||||
Why it should hold quality: the seats are one model with different personas, so their errors are correlated, and a correlated extra seat adds little. `larv-review agreement` showed on 2026-11-11 that Mid A and the inherited architect voted alike in 58 of 75 paired rulings, while their scores moved alike between two runs on one commit in only 1 of 4 pairs: seats agree with each other more than a run agrees with its rerun, so the rerun carries more new information than the third and fourth seat. Nine judges from seven model families carried about two independent votes (arXiv 2605.29800), and ten with error correlation 0.21 carried 3.5 (arXiv 2609.22512).
|
||||
|
||||
Decide once `larv-review agreement` prints `Assumption holds:` or `Assumption fails:`; it needs 10 commits each scored twice before it can. Keep four seats on any pass that files a floor item, since its places come from seat reports. Revise the decision `review: the comprehension check records how hard a project is to read…`, which names the four-seat run.
|
||||
|
||||
lilleman moved it from 0.12.0 to 0.13.0 on 2026-11-17, when 6 commits had been scored twice.
|
||||
|
||||
Touches:
|
||||
- `bin/larv_review/seats.py`: `SCORING_SEATS`, `scores`
|
||||
- `bin/larv_review/history_commands.py`: `record_scoring`
|
||||
- `bin/larv_review/scoring_setup.py`: `SEATS`, `prepare_scoring`
|
||||
- `bin/larv_review/main.py`: `(module)` (small)
|
||||
- `bin/larv_review/test_larv_review.py`
|
||||
- `bin/larv_review/test_scoring_setup.py`
|
||||
- `skills/larv-review/SKILL.md`: `### Comprehension check`
|
||||
- `skills/comprehension-panel/SKILL.md`: `## The scoring run` (small)
|
||||
|
||||
### 419. Run the external auto-reviewer until its review of the PR's head has no findings, and answer each of its threads on the PR.
|
||||
|
||||
Today `larv-review` §3 → "Round cap" stops the auto-reviewer after two reviews. On a client project's pull request, CodeRabbit spent both reviews on the draft, before the internal passes were done, so its last finding got no answer on the PR. Change:
|
||||
|
||||
- §3 → "Round cap": drop the auto-reviewer's cap. Every finding it makes, whatever its severity, is fixed or shown wrong, and each push waits for its review of the new head. The pass is done when that review adds no finding.
|
||||
- §4 step 6: detect a clean review. CodeRabbit posts no review when it has no findings. Instead it updates its summary comment with "No actionable comments were generated in the recent review" and a `coveredCommitId` that matches the head. Wait for that, not for a new review.
|
||||
- Answer every thread in place, with the fix's commit or the reason for not making it.
|
||||
- `chunk-pr ready` and `chunk-pr merge` refuse while an auto-reviewer thread has neither our reply nor resolved status, read from the thread state GitHub's API reports.
|
||||
- `round-count`, rule-hook's round-cap and the "Answer … round" titles need no change, since the auto-reviewer's commits already take ordinary titles.
|
||||
- Once this ships, delete the first two bullets of the machine-local CodeRabbit rule file, which say the same thing for one machine.
|
||||
|
||||
The change touches `skills/larv-review/SKILL.md` "Re-entry", which the comprehension seats found hard to follow (Locality): make it easier to read while editing it.
|
||||
|
||||
### 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.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/planning.py`: `ranked_keys`
|
||||
- `bin/do_epic/ranking.py`: `ranked`
|
||||
- `bin/do_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.
|
||||
|
||||
One of 0.13.0's history ports, per lilleman's call of 2026-11-12.
|
||||
|
||||
### 339. Lower the reading cost of the files a chunk reads most before its first commit.
|
||||
|
||||
`reading-cost` printed `Rising:` on 2026-11-12: the last 5 chunks' median is 128,199 new input tokens before their first commit, the 5 before them 101,795. Read most over the last 5, as opens and searches: `todo.md` 34, `docs/decisions.md` 26, `README.md` 19, `skills/larv-review/SKILL.md` 13, `bin/agent_cycle/routing.py` 8, `CHANGELOG.md` 6. The chunk that ships this runs `reading-cost --reset`.
|
||||
|
||||
Touches:
|
||||
- `README.md`
|
||||
- `skills/larv-review/SKILL.md`
|
||||
- `bin/agent_cycle/routing.py`
|
||||
|
||||
### 341. Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.
|
||||
|
||||
Raised by item 312's research round, 2026-11-12. Over the 53 chunks archived since 2026-09-30, Read results held about 3.17M tokens (characters / 4) in 1,617 reads. Results over 20,000 characters, about 5,000 tokens, held 479k tokens beyond that size in 115 reads: prose reviewers 144k, stability reviewers 119k, product-owner reviewers 102k, general-purpose subagents 65k, principles auditors 28k, architects 21k. Workers had none, under the reading rule in their prompt. Measured with a script over loop-claude's archive that sums each Read tool_result's characters by the subagent's `agentType`. The decision of 2026-10-27 found Read results out of a PostToolUse hook's reach; this variable reaches them.
|
||||
|
||||
`CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS` overrides the Read tool's default limit of 25,000 tokens (https://code.claude.com/docs/en/env-vars, read 2026-11-12: "Override the default token limit for file reads, which is 25,000 tokens."). Claude Code 2.1.322's binary holds the name. A read over the limit fails and asks for an offset and a limit, so an agent may page through the same file and save nothing; the replay measures that.
|
||||
|
||||
loop-claude can hand it as it hands `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, and subagents inherit it, the principles auditors included. The choice of 2026-10-27 that the principles audit reads the project whole holds as long as it pages through what it reads.
|
||||
|
||||
The replay: `review-replay <pass> claude-opus-5-5 --read-limit` already replays a pass's archived rounds three times as archived and once at 5,000 tokens (`bin/review_replay/changes.py`, `bin/claude_code/output_limits.py`). Run it for the prose, stability, product-owner and principles rounds. Keeps quality where each pass finds every finding the two unchanged replays both find, or misses no more than the most an unchanged replay misses, as `--omit-claude-md` counts it. Keep it only where the replays' Read characters also fall; the archived runs hold each result. Then hand the variable over in `worker_environment` for what passes.
|
||||
|
||||
Touches:
|
||||
- `bin/agent_cycle/run.py`: `worker_environment` (small)
|
||||
- `bin/loop_claude/loop/usage.py`: `HELP` (small)
|
||||
- `bin/agent_cycle/test_run.py`: `Cycles` (small)
|
||||
- `bin/loop_claude/loop/test_usage.py`: `HelpLimits` (small)
|
||||
|
||||
### 298. Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.
|
||||
|
||||
153 `Judge cost:` entries total $109.76, a median of about $0.76 a verdict at every rung, and the cost follows the size of the records, not the transcript: about 76k characters in log and 188k in claude-config. In 224 of 251 recent verdicts (89%) the evidence sits in the worker's final message. A missed interrupt is the costly error, so the bar is zero changed interrupts and zero new rejections across the replay. The judge is about 4.5% of dollars, so the saving is small; each cycle also gets faster.
|
||||
|
||||
Touches:
|
||||
- `bin/agent_cycle/judge.py`: `Brief`, `judge_prompt`, `JUDGE_PROMPT_CHARS`
|
||||
- `bin/chunk_driver/project/records.py`: `read_records`
|
||||
- `bin/judge_replay/main.py`: `rule` (small)
|
||||
- `bin/judge_replay/replay.py`: `case_from` (small)
|
||||
- `bin/agent_cycle/test_judge.py`: `JudgePrompt`
|
||||
- `bin/chunk_driver/project/test_records.py`: `Records`
|
||||
- `bin/judge_replay/test_judge_replay.py`
|
||||
|
||||
### 395. Keep each block a save didn't change, with its localId, and the spacing paragraphs beside it as Jira or Confluence holds them.
|
||||
|
||||
Today a Jira detail edited in one line, or a Confluence record with one entry appended, is written back whole by adf-codec's portable pair, which drops each block's localId and the empty paragraphs Jira uses for spacing. A save whose text is the text a read showed already sends nothing (`docs/decisions.md` → `project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, …`). Match the saved markdown's top-level blocks against the held document's, each as the portable pair reads it, and send the held block where they match. The decision's limit on partial saves ends with this item.
|
||||
|
||||
### 425. Show on loop-claude's terminal why it doesn't start a chunk beside the next item, as chunk-preflight prints it.
|
||||
|
||||
`chunks_beside` names each item it refuses and why, such as an unreadable `Touches:` list, and chunk-preflight prints those lines, but loop-claude's `chunk_windows.may_start` keeps only `picked` and drops them, so idle slots show no reason. Found by item 424's product-owner review; a list a person edits in Jira's UI, or one filed before item 424, still reaches loop-claude unchecked.
|
||||
|
||||
### 447. Stop a headless claude call that runs past a time limit, and report it as a failure, so a hung judge or stuck check can't hold the loop.
|
||||
|
||||
Every headless claude that `claude_reply` runs, the judge's and the stuck check's included, runs without a time limit, and the stuck check runs while the worker's own claude waits for its output to be read. A call that hangs holds the loop, and the worker with it, until a person notices. Found by item 422's stability review.
|
||||
|
||||
Give the `claude` effect a timeout, and have `claude_reply` turn its expiry into a Failure that names who timed out, as it names a non-zero exit. Pick the limit from the longest such call the transcript archive shows, with room to spare, and say where it comes from in a comment at the constant.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/loop_effects/effects.py`: `system_effects` (small)
|
||||
- `bin/claude_code/reply.py`: `claude_reply`
|
||||
|
||||
### 367. Check that every write to a Jira plan leaves it ranked, as rule-hook's `todo-rank-check` checks `todo.md` today.
|
||||
|
||||
One of 0.13.0's history ports, per lilleman's call of 2026-11-12.
|
||||
|
||||
### 423. Skip the judge's model call on a worker's final message that the offline classifier decides is finished.
|
||||
|
||||
On 2026-11-18 lilleman ruled that the classifier's miss rate of about 1 in 100 decided is close enough to no missed interrupt (`docs/decisions.md` → `routing: the offline classifier may decide finished, since lilleman ruled a miss rate of about 1 in 100 decided close enough to none; the judge's model keeps every other verdict kind`).
|
||||
|
||||
Taking the item builds this: before the judge call, loop-claude runs the classifier trained on its archive over the worker's final message. Where the classifier decides finished, loop-claude skips the call. The classifier is re-trained as the archive grows. The judge call sits in `bin/agent_cycle/run.py` → `rule`, a place the comprehension seats found hard, since the order of stamping, archiving and stepping matters across three functions: make it easier to read.
|
||||
|
||||
The judge's model still decides every verdict the classifier leaves, the escalation a worker quotes, and whether a release is ready to cut, since the replay didn't test the classifier on those.
|
||||
|
||||
Evidence, from `judge-replay claude-opus-5-5 --offline`: the classifier reads only the final message, averages five seeded logistic regressions, and decides finished only where its chance of an interrupt is below that of every interrupt among its held-out training folds.
|
||||
- On the 1,116 archived verdicts it decided finished with no missed interrupt on both tests: held-out folds, 95 decided and none missed; latest fifth, 20 decided and none missed.
|
||||
- On the first 1,104 it missed one interrupt on the latest fifth, while the held-out folds decided 103 and missed none.
|
||||
- It decides about 1 in 12 verdicts. About 1 in 100 of those it decided were an interrupt, on the 1,104.
|
||||
|
||||
Savings: one judge call per about 12 verdicts. That is small, and nobody has measured it.
|
||||
|
||||
### 77. Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.
|
||||
|
||||
2026-10-08, lilleman: no metric enters review until a rerun on more data shows it tracking the panel.
|
||||
@@ -273,6 +287,12 @@ On 2026-11-08 the human answered notice only: the loop prints that the release i
|
||||
|
||||
Releases are the human's, and `CLAUDE.md` → "Working loop" already ends the loop once a release is ready to cut, so the ask settles nothing. 15 interrupts in the archive ask whether the human will cut a release, and about 6 of the 45 interrupts from 2026-11-02 to 2026-11-10 said a release was ready to cut; log's 2.5.0 was asked twice within an hour on 2026-11-10. On 2026-11-08 one of the 4 questions waiting in `~/.local/state/loop-claude/` is such an ask, plainpages-plugin-fastjira's 0.3.0 since 2026-11-03. Today a release ready to cut opens claude's session at once (`bin/agent_cycle/run.py` `ask`), and the loop stops if the human leaves it with nothing typed. The change also touches what an interrupt covers in `CLAUDE.md` → "Vocabulary". Where the change touches `ask`, make it easier to read, as the seats named it.
|
||||
|
||||
### 445. Refuse a plan that holds an item a `Finish item <ID>` commit already removed, so a merge resolution cannot bring a finished item back.
|
||||
|
||||
Merging main into item-442 in 610edb1a resolved a todo.md conflict by keeping item 310's row and detail, which e019a6b7 had just finished. loop-claude then started a chunk on item 310, whose work had already merged, and that chunk only removed the item again. No check noticed: `rank_todo.py --check` reads one file, and rule-hook's `todo-rank-check` sees only an agent's writes, not what a merge resolution keeps.
|
||||
|
||||
Have the gate, or `rank_todo.py --check` where it runs in a checkout, refuse a plan that holds an ID a commit titled `Finish item <ID>` removed on the default branch, naming the commit. An item removed by mistake can come back only under a new ID, which keeps the check simple.
|
||||
|
||||
### 171. Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.
|
||||
|
||||
Raised by the goals audit of PR #296. `bin/routing_figures/calls.py` groups a chunk's review rounds by the rung its worker started on, and calls for a routing change when a lower rung took more of them. Since PR #296 the reviewers may run above the worker's rung, on the one their item's E + I picks, and no figure groups rounds by it, though the archived worker line names the E + I it follows from. A cheap worker on an item of high E + I gets stronger reviewers, who may raise more rounds, and a call could then blame the worker's rung for them: an interrupt of lilleman that settles nothing (goal 1.2).
|
||||
@@ -347,6 +367,19 @@ Group `bin/` by concern, one package level per group, with the launchers left at
|
||||
|
||||
`repo_checks` stays at the root, since it tests the repo, not a tool. The README's `bin/` list then becomes seven short groups. That list is a place the comprehension seats found hard (`README.md` → the `bin/` package list): make it easier to read.
|
||||
|
||||
### 456. Make the child-shell stop test pass under load, so a full test run doesn't fail on a race.
|
||||
|
||||
Found in a full `bin/run-tests` run on 2026-11-19, on a loaded machine: `ChildShells.test_stops_a_shell_and_the_process_it_started_and_no_other` (`bin/loop_effects/test_effects.py:243`) failed at line 249 with `AssertionError: 0 != -15`, and its file passed alone right after (36 passed). The branch changed nothing under `bin/loop_effects`.
|
||||
|
||||
The race, as far as reading shows: `child_shells.stop` sends SIGTERM to the shell's descendants first and to the shell last. The test's shell runs `sleep 60; true`. Once `sleep` dies, bash goes on to `true` and exits 0. When the test's process is descheduled between the two `os.kill` calls, bash has already exited, and the SIGTERM to its zombie does nothing, so `wait` returns 0. The same window is open in production: a shell running a loop, such as `until false; do sleep 60; done`, can start its next child between the kills, and that child outlives the stop, against `stop`'s docstring. `stop` is called by loop-claude's lingering-worker check (`bin/agent_cycle/lingering_workers.py:29`, through `bin/loop_effects/effects.py:106`).
|
||||
|
||||
So the fix likely belongs in `stop`, not only in the test: signal the shell before its descendants, or SIGSTOP it first, so it can't run anything after its child dies. Make the test fail on the old order deterministically, for example with a shell whose loop restarts its child, rather than relying on timing.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/loop_effects/child_shells.py`: `stop` (small)
|
||||
- `bin/loop_effects/test_effects.py`: `ChildShells.test_stops_a_shell_and_the_process_it_started_and_no_other`
|
||||
|
||||
### 151. Keep 10 to 20 settled decisions per project as its goals' test set, and rerun them after a goal changes.
|
||||
|
||||
Each case is a question the project settled and the answer it chose. A fresh-context agent given only the README's premises answers each case; a case it answers differently says the goals no longer decide it. Written guidance can fail to change behaviour, which is why the goals get a test.
|
||||
@@ -391,14 +424,78 @@ Filed by PR #553, which made the routing ladder a file: `bin/model_routing/routi
|
||||
|
||||
Project principle 4 asks that a rule a program can check is enforced by a program. Refuse a Write, an Edit and a MultiEdit of a file named `routing-ladder.json` under `~/.claude-projects/`, with no override, and say that the ladder is the human's to change. The shipped file stays editable in the setup's own checkout, where a chunk's review covers it.
|
||||
|
||||
### 365. Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.
|
||||
|
||||
lilleman's call, 2026-11-12: 0.10.0 and 0.11.0 switch the history tools off for a plan outside the checkout, and 0.13.0 holds only their ports. In Jira a dropped item, which `Drop item` commit titles mark today, is an issue resolved by a resolution the config names.
|
||||
|
||||
### 368. Call a release review due, call a release ready to cut, and tell whether a chunk owes a scoring run, for a plan outside the checkout, from the project repo's history or from Jira.
|
||||
|
||||
One of 0.13.0's history ports, per lilleman's call of 2026-11-12. Filed from item 344's stability review, round 1.
|
||||
|
||||
Today a plan outside the checkout is read as it stands, since no commit holds it. So:
|
||||
|
||||
- `bin/release_plan/release_standing.py`'s `todos_since` holds one text. Once a release's last item ships, the plan no longer names the release, and `next_release` gives the release after it as next. chunk-preflight and loop-claude say `UNSEEN_RELEASES` on every run: the release reviews and the cuts are the human's to call.
|
||||
- `bin/larv_review/owed.py`'s `owed_scoring_run` says it cannot tell whether the chunk owes a scoring run, and the merge goes on. `needs-scoring-run` and `record-scoring` refuse the ID of an item the plan no longer holds.
|
||||
|
||||
Read the plan's earlier texts from the project repo's commits, which item 345 writes, or the releases Jira's issues name. Then drop `UNSEEN_RELEASES` and both refusals, and the bullets that record them in `docs/decisions.md` → "project config: a tool that reads a file's commits …".
|
||||
|
||||
The comprehension seats found `next_release` hard to read: the tag cases, dated headings, renames and `named_releases` meet in one function. Make it easier to read while there.
|
||||
|
||||
### 260. Compare the first 20 chunks whose worker got the reading rule with the 20 before them, on review rounds past each pass's first, unfinished verdicts, 🔴, 🟡 and misread findings, dollars and hours per chunk, and drop the rule where any rose.
|
||||
|
||||
Start once 20 chunks have run under the rule. The rule is `READING_RULE` in `bin/chunk_driver/prompts.py`, which every fresh worker prompt holds; `git log --first-parent -S READING_RULE` on the default branch finds the merge that added it. A chunk got it when its first worker started after that merge. Measure as `docs/decisions.md` → `loop-claude: the worker's claude compacts its context before it fills a 200k window…` measured the window: rounds past each pass's first and the 🔴, 🟡 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, hours from the worker's first message to its last, and dollars from the chunk's `cost-state` entry. Compare means, since the decision weighs the rule by all spend.
|
||||
|
||||
### 309. Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.
|
||||
|
||||
Seats cost $1,143 of the $9,154 measured from 2026-09-30 to 2026-11-11 (12.5%), scoring runs $470 of that. A scoring run today is four seats, run twice on one head: eight seat runs. Two seats on the second pass make it six, and two on both passes four.
|
||||
|
||||
Why it should hold quality: the seats are one model with different personas, so their errors are correlated, and a correlated extra seat adds little. `larv-review agreement` showed on 2026-11-11 that Mid A and the inherited architect voted alike in 58 of 75 paired rulings, while their scores moved alike between two runs on one commit in only 1 of 4 pairs: seats agree with each other more than a run agrees with its rerun, so the rerun carries more new information than the third and fourth seat. Nine judges from seven model families carried about two independent votes (arXiv 2605.29800), and ten with error correlation 0.21 carried 3.5 (arXiv 2609.22512).
|
||||
|
||||
Decide once `larv-review agreement` prints `Assumption holds:` or `Assumption fails:`; it needs 10 commits each scored twice before it can. Keep four seats on any pass that files a floor item, since its places come from seat reports. Revise the decision `review: the comprehension check records how hard a project is to read…`, which names the four-seat run.
|
||||
|
||||
lilleman moved it from 0.12.0 to 0.13.0 on 2026-11-17, when 6 commits had been scored twice.
|
||||
|
||||
Touches:
|
||||
- `bin/larv_review/seats.py`: `SCORING_SEATS`, `scores`
|
||||
- `bin/larv_review/history_commands.py`: `record_scoring`
|
||||
- `bin/larv_review/scoring_setup.py`: `SEATS`, `prepare_scoring`
|
||||
- `bin/larv_review/main.py`: `(module)` (small)
|
||||
- `bin/larv_review/test_larv_review.py`
|
||||
- `bin/larv_review/test_scoring_setup.py`
|
||||
- `skills/larv-review/SKILL.md`: `### Comprehension check`
|
||||
- `skills/comprehension-panel/SKILL.md`: `## The scoring run` (small)
|
||||
|
||||
### 51. Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.
|
||||
|
||||
"Functional core, imperative shell", in `principles/technical-principles.md`: `say` in `bin/loop_effects/effects.py` takes the effects but prints to stderr itself, and `retried` and the rest print through `say`. Two bare `print(file=sys.stderr)` calls remain outside them, in `bin/agent_cycle/interrupt.py` and `bin/chunk_driver/project/model_choice.py`. The tests swap the global stream.
|
||||
|
||||
### 419. Run the external auto-reviewer until its review of the PR's head has no findings, and answer each of its threads on the PR.
|
||||
|
||||
Today `larv-review` §3 → "Round cap" stops the auto-reviewer after two reviews. On a client project's pull request, CodeRabbit spent both reviews on the draft, before the internal passes were done, so its last finding got no answer on the PR. Change:
|
||||
|
||||
- §3 → "Round cap": drop the auto-reviewer's cap. Every finding it makes, whatever its severity, is fixed or shown wrong, and each push waits for its review of the new head. The pass is done when that review adds no finding.
|
||||
- §4 step 6: detect a clean review. CodeRabbit posts no review when it has no findings. Instead it updates its summary comment with "No actionable comments were generated in the recent review" and a `coveredCommitId` that matches the head. Wait for that, not for a new review.
|
||||
- Answer every thread in place, with the fix's commit or the reason for not making it.
|
||||
- `chunk-pr ready` and `chunk-pr merge` refuse while an auto-reviewer thread has neither our reply nor resolved status, read from the thread state GitHub's API reports.
|
||||
- `round-count`, rule-hook's round-cap and the "Answer … round" titles need no change, since the auto-reviewer's commits already take ordinary titles.
|
||||
- Once this ships, delete the first two bullets of the machine-local CodeRabbit rule file, which say the same thing for one machine.
|
||||
|
||||
The change touches `skills/larv-review/SKILL.md` "Re-entry", which the comprehension seats found hard to follow (Locality): make it easier to read while editing it.
|
||||
|
||||
### 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.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/do_epic/planning.py`: `ranked_keys`
|
||||
- `bin/do_epic/ranking.py`: `ranked`
|
||||
- `bin/do_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.
|
||||
|
||||
One of 0.13.0's history ports, per lilleman's call of 2026-11-12.
|
||||
|
||||
### 201. Save the human's tmux setups and restore them after a reboot, so work is up and running again quickly.
|
||||
|
||||
The human asked on 2026-10-21 for tmux support, above all for saving tmux setups. Don't build anything until the human has said exactly what they need. Ask them at least:
|
||||
@@ -431,6 +528,31 @@ Before PR #310, reports reached the worker as the Agent call's result, a median
|
||||
|
||||
The archive holds 277 chunk folders under `home/lilleman/.claude`, from 2026-09-24 on, and 39 under `claude-config` (2026-11-10). The routing figures of 2026-11-04 list no project `home/lilleman/.claude`. They find a chunk's later fixes on the default branch of the checkout its key names (`bin/routing_figures/archive.py` `measure_project`), and `/home/lilleman/.claude` is a release checkout on a detached HEAD. Item 5 fixes how keys are derived, not the chunks already archived. `~/.claude/loop-claude-models.json` still holds a `home/lilleman/.claude` entry; it is machine state outside the repo, so removing it is a one-off step on each machine, not part of the change.
|
||||
|
||||
### 339. Lower the reading cost of the files a chunk reads most before its first commit.
|
||||
|
||||
`reading-cost` printed `Rising:` on 2026-11-12: the last 5 chunks' median is 128,199 new input tokens before their first commit, the 5 before them 101,795. Read most over the last 5, as opens and searches: `todo.md` 34, `docs/decisions.md` 26, `README.md` 19, `skills/larv-review/SKILL.md` 13, `bin/agent_cycle/routing.py` 8, `CHANGELOG.md` 6. The chunk that ships this runs `reading-cost --reset`.
|
||||
|
||||
Touches:
|
||||
- `README.md`
|
||||
- `skills/larv-review/SKILL.md`
|
||||
- `bin/agent_cycle/routing.py`
|
||||
|
||||
### 341. Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.
|
||||
|
||||
Raised by item 312's research round, 2026-11-12. Over the 53 chunks archived since 2026-09-30, Read results held about 3.17M tokens (characters / 4) in 1,617 reads. Results over 20,000 characters, about 5,000 tokens, held 479k tokens beyond that size in 115 reads: prose reviewers 144k, stability reviewers 119k, product-owner reviewers 102k, general-purpose subagents 65k, principles auditors 28k, architects 21k. Workers had none, under the reading rule in their prompt. Measured with a script over loop-claude's archive that sums each Read tool_result's characters by the subagent's `agentType`. The decision of 2026-10-27 found Read results out of a PostToolUse hook's reach; this variable reaches them.
|
||||
|
||||
`CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS` overrides the Read tool's default limit of 25,000 tokens (https://code.claude.com/docs/en/env-vars, read 2026-11-12: "Override the default token limit for file reads, which is 25,000 tokens."). Claude Code 2.1.322's binary holds the name. A read over the limit fails and asks for an offset and a limit, so an agent may page through the same file and save nothing; the replay measures that.
|
||||
|
||||
loop-claude can hand it as it hands `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, and subagents inherit it, the principles auditors included. The choice of 2026-10-27 that the principles audit reads the project whole holds as long as it pages through what it reads.
|
||||
|
||||
The replay: `review-replay <pass> claude-opus-5-5 --read-limit` already replays a pass's archived rounds three times as archived and once at 5,000 tokens (`bin/review_replay/changes.py`, `bin/claude_code/output_limits.py`). Run it for the prose, stability, product-owner and principles rounds. Keeps quality where each pass finds every finding the two unchanged replays both find, or misses no more than the most an unchanged replay misses, as `--omit-claude-md` counts it. Keep it only where the replays' Read characters also fall; the archived runs hold each result. Then hand the variable over in `worker_environment` for what passes.
|
||||
|
||||
Touches:
|
||||
- `bin/agent_cycle/run.py`: `worker_environment` (small)
|
||||
- `bin/loop_claude/loop/usage.py`: `HELP` (small)
|
||||
- `bin/agent_cycle/test_run.py`: `Cycles` (small)
|
||||
- `bin/loop_claude/loop/test_usage.py`: `HelpLimits` (small)
|
||||
|
||||
### 181. Have the test of a quoted answer's step-up assert the stepped rung's facts as literals, not through `prompts.rungs_held`.
|
||||
|
||||
`bin/agent_cycle/test_run.py`'s `test_a_quoted_answer_that_cites_an_escalation_trigger_steps_the_worker_up_before_it_resumes_and_archives_the_step` builds its expected prompt from `prompts.rungs_held`, the code under test, so a bug there passes it. The technical principles' test bullet bans that shape. Assert the new rung and one review launch as literals, as the typed answer's step-up test does. Raised by the principles audit of PR #308.
|
||||
@@ -443,14 +565,65 @@ Found by review of PR #317. `bin/plan/goals_file.py`'s `numbered` writes `typing
|
||||
|
||||
Found by review of PR #317. The black-box test, `bin/loop_claude/test_black_box.py:609`, not the unit test of the same name in `bin/agent_cycle/test_retry.py`, which runs on a fake clock, sets `resets_at` from the test's `time.time()` and expects the wait, rounded to tens, to be 3720. When more than about 5 s pass between that read and the loop's, the wait rounds to 3710 and the test fails with no bug. Item 102 covers only replacing the `time.sleep` swap; this item changes the expected value, for example by asserting the wait against `resets_at + 120` minus the time the loop read, or a bound on it.
|
||||
|
||||
### 298. Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.
|
||||
|
||||
153 `Judge cost:` entries total $109.76, a median of about $0.76 a verdict at every rung, and the cost follows the size of the records, not the transcript: about 76k characters in log and 188k in claude-config. In 224 of 251 recent verdicts (89%) the evidence sits in the worker's final message. A missed interrupt is the costly error, so the bar is zero changed interrupts and zero new rejections across the replay. The judge is about 4.5% of dollars, so the saving is small; each cycle also gets faster.
|
||||
|
||||
Touches:
|
||||
- `bin/agent_cycle/judge.py`: `Brief`, `judge_prompt`, `JUDGE_PROMPT_CHARS`
|
||||
- `bin/chunk_driver/project/records.py`: `read_records`
|
||||
- `bin/judge_replay/main.py`: `rule` (small)
|
||||
- `bin/judge_replay/replay.py`: `case_from` (small)
|
||||
- `bin/agent_cycle/test_judge.py`: `JudgePrompt`
|
||||
- `bin/chunk_driver/project/test_records.py`: `Records`
|
||||
- `bin/judge_replay/test_judge_replay.py`
|
||||
|
||||
### 265. Archive each wait that costs a chunk wall time, for a usage limit, low memory, a failed worker start or a heavy slot, with its start and end stamps, so goal 1.5's hours split waiting from work.
|
||||
|
||||
No record holds these waits today. An outcomes file holds verdicts, stops, step-ups and the judge's cost (`bin/transcript_archive/outcomes.py`), and `~/.local/state/run-heavy/` holds only the slots' lock files. loop-claude waits out a usage limit and low memory in `bin/agent_cycle/retry.py`; run-heavy waits for a slot in `bin/run_heavy/`. A heavy slot's wait happens inside a worker's Bash call, so loop-claude doesn't see it; run-heavy would write it where the archive can find it.
|
||||
|
||||
### 395. Keep each block a save didn't change, with its localId, and the spacing paragraphs beside it as Jira or Confluence holds them.
|
||||
|
||||
Today a Jira detail edited in one line, or a Confluence record with one entry appended, is written back whole by adf-codec's portable pair, which drops each block's localId and the empty paragraphs Jira uses for spacing. A save whose text is the text a read showed already sends nothing (`docs/decisions.md` → `project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, …`). Match the saved markdown's top-level blocks against the held document's, each as the portable pair reads it, and send the held block where they match. The decision's limit on partial saves ends with this item.
|
||||
|
||||
### 425. Show on loop-claude's terminal why it doesn't start a chunk beside the next item, as chunk-preflight prints it.
|
||||
|
||||
`chunks_beside` names each item it refuses and why, such as an unreadable `Touches:` list, and chunk-preflight prints those lines, but loop-claude's `chunk_windows.may_start` keeps only `picked` and drops them, so idle slots show no reason. Found by item 424's product-owner review; a list a person edits in Jira's UI, or one filed before item 424, still reaches loop-claude unchecked.
|
||||
|
||||
### 169. Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.
|
||||
|
||||
The hook judges a call before it runs, and `changed` in `bin/rule_hook/todo_check.py` compares `todo.md` with the index and HEAD as they stand then. A call that edits `todo.md` and commits it, such as a heredoc script followed by `git commit`, passes unchecked: PR #296's commit 149108e did, and the override marker it carried was never logged. larv-review's gate still runs `rank_todo.py --check`, so an unranked plan stops at merge rather than at commit. A git pre-commit hook would see the staged file.
|
||||
|
||||
### 447. Stop a headless claude call that runs past a time limit, and report it as a failure, so a hung judge or stuck check can't hold the loop.
|
||||
|
||||
Every headless claude that `claude_reply` runs, the judge's and the stuck check's included, runs without a time limit, and the stuck check runs while the worker's own claude waits for its output to be read. A call that hangs holds the loop, and the worker with it, until a person notices. Found by item 422's stability review.
|
||||
|
||||
Give the `claude` effect a timeout, and have `claude_reply` turn its expiry into a Failure that names who timed out, as it names a non-zero exit. Pick the limit from the longest such call the transcript archive shows, with room to spare, and say where it comes from in a comment at the constant.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/loop_effects/effects.py`: `system_effects` (small)
|
||||
- `bin/claude_code/reply.py`: `claude_reply`
|
||||
|
||||
### 367. Check that every write to a Jira plan leaves it ranked, as rule-hook's `todo-rank-check` checks `todo.md` today.
|
||||
|
||||
One of 0.13.0's history ports, per lilleman's call of 2026-11-12.
|
||||
|
||||
### 423. Skip the judge's model call on a worker's final message that the offline classifier decides is finished.
|
||||
|
||||
On 2026-11-18 lilleman ruled that the classifier's miss rate of about 1 in 100 decided is close enough to no missed interrupt (`docs/decisions.md` → `routing: the offline classifier may decide finished, since lilleman ruled a miss rate of about 1 in 100 decided close enough to none; the judge's model keeps every other verdict kind`).
|
||||
|
||||
Taking the item builds this: before the judge call, loop-claude runs the classifier trained on its archive over the worker's final message. Where the classifier decides finished, loop-claude skips the call. The classifier is re-trained as the archive grows. The judge call sits in `bin/agent_cycle/run.py` → `rule`, a place the comprehension seats found hard, since the order of stamping, archiving and stepping matters across three functions: make it easier to read.
|
||||
|
||||
The judge's model still decides every verdict the classifier leaves, the escalation a worker quotes, and whether a release is ready to cut, since the replay didn't test the classifier on those.
|
||||
|
||||
Evidence, from `judge-replay claude-opus-5-5 --offline`: the classifier reads only the final message, averages five seeded logistic regressions, and decides finished only where its chance of an interrupt is below that of every interrupt among its held-out training folds.
|
||||
- On the 1,116 archived verdicts it decided finished with no missed interrupt on both tests: held-out folds, 95 decided and none missed; latest fifth, 20 decided and none missed.
|
||||
- On the first 1,104 it missed one interrupt on the latest fifth, while the held-out folds decided 103 and missed none.
|
||||
- It decides about 1 in 12 verdicts. About 1 in 100 of those it decided were an interrupt, on the 1,104.
|
||||
|
||||
Savings: one judge call per about 12 verdicts. That is small, and nobody has measured it.
|
||||
|
||||
### 197. Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.
|
||||
|
||||
`bin/loop_effects/effects.py` hands loop-claude Python's builtin `input`, and nothing under `bin/` imports `readline`, so the terminal gets no line editing: fixing a typo means erasing back to it. loop-claude asks two questions at its terminal. Both read through `effects.input`: the pick of the project's model, in `project/model_choice.py`'s `ask_for_model`, and the interrupt's answer, in `agent_cycle/interrupt.py`'s `typed_answer`. Importing `readline` in `effects.py` gives `input` line editing, at two costs. It moves the prompt from stderr to stdout, while the question above it stays on stderr. `test_black_box.py` waits for the prompt on stderr. `readline`'s bracketed paste takes a pasted block whole, so an answer can hold several lines. `worker_prompts.typed_answer` ends the answer at its first blank line, so the judge would read the rest of such a paste as loop-claude's words. The product-owner review of PR #308 raised the interrupt's case. lilleman, 2026-10-18: "Not super-important, but a bit irritating."
|
||||
@@ -463,7 +636,7 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost
|
||||
|
||||
The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3).
|
||||
|
||||
### 397. Script each step that the chunks of releases 0.10.0 to 0.14.0 repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.
|
||||
### 397. Script each step that the chunks of releases 0.10.0 to 0.15.0 repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.
|
||||
|
||||
lilleman asked, on 2026-10-16, for a standing audit each release, so the loop keeps moving work a program does as well from the model to scripts (goals 1.4 and 1.5). This audit reads the archived transcripts of the chunks that shipped releases 0.10.0 to 0.14.0 for every step that chunks repeated by hand, before, during or after review. It keeps the steps whose answer a program computes the same way each time, such as a lookup, a check, a prompt assembled for a reviewer, a cleanup. File one item per such step, with the time and tokens it cost, into the next release with items left. Leave a step that needs judgement with the model. Run `command-patterns <version>` first for each of 0.10.0 to 0.14.0; each run's table is the audit's starting point. `read_threads` and `calls` in `bin/command_patterns/tally.py` open the calls of one pattern, or `command-patterns <version> --calls <file>` dumps them all as JSON lines. The 0.7.0 audit found that most steps its chunks repeated were already scripted by that release's own tools, so a step a shipped item already covers is not filed.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user