Answer stability round 1: 1 🔴, 6 🟡 (2 misread); read the scoring rule from the clone, hand windows XDG_DATA_HOME, retry the home check where nobody watches, tell an unreadable sign-in status and settings file apart, and bound the claude commands that build the home
CI / tests (pull_request) Successful in 4m35s
CI / tests (pull_request) Successful in 4m35s
This commit is contained in:
@@ -27,6 +27,7 @@ from build_epic.backend.protocol import EpicIssue, EpicStore
|
||||
from build_epic.epic_record import EpicRecord
|
||||
from failure import Failure
|
||||
from agent_cycle.verdicts import Finished, TakenIn
|
||||
from agent_cycle.retry import home_unready
|
||||
from atlassian.jira import ISSUE_KEY
|
||||
from build_epic.backend.jira import JiraEpic
|
||||
from claude_code.reply import Limited
|
||||
@@ -51,6 +52,8 @@ HELP = f"""usage: build-epic <EPIC-KEY> [--status | --dry-run]
|
||||
{finish.USAGE}
|
||||
|
||||
Runs the chunks of one Jira epic, such as ABC-12, each in its own window of the tmux session epic-<EPIC-KEY>.
|
||||
It runs every claude in the loop's Claude home, ~/.local/share/build-release/claude-home, which it builds first, under --dry-run too.
|
||||
Until someone has signed in there, it stops and prints the command to sign in with. README.md → Install says what the home holds.
|
||||
Before it starts chunks, build-epic <EPIC-KEY> plans each open issue that has none of these labels:
|
||||
`repo:<name>` for its repo, `build-epic-claude` for work of Claude's that changes no repo, `build-epic-human` for a task of yours.
|
||||
A label that `[label-repos]` in config.toml maps to a repo counts as that repo's.
|
||||
@@ -123,7 +126,7 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
|
||||
if writes or closes:
|
||||
return epic_written(words[0], writes, paths, env, backend, stdin)
|
||||
# Before anything starts: a clone, a claude session or a tmux window. One stop names everything that is the person's to do. A dry run opens no window, but its planning runs claude.
|
||||
if needs := [reason for reason in (None if dry_run_asked else tmux.unusable(effects.tmux, chunk_prompt.DRIVER), effects.claude_home()) if reason]:
|
||||
if needs := [reason for reason in (None if dry_run_asked else tmux.unusable(effects.tmux, chunk_prompt.DRIVER), home_unready(effects, watched=chunk is None)) if reason]:
|
||||
return Stop(1, "\n".join(needs))
|
||||
config = load(paths.home, env)
|
||||
if isinstance(config, Failure):
|
||||
|
||||
@@ -11,7 +11,6 @@ import pathlib
|
||||
import re
|
||||
|
||||
from build_epic.config import BuildEpicConfig
|
||||
from loop_state.paths import CLAUDE_HOME
|
||||
from loop_effects.effects import Effects, say
|
||||
from build_epic.backend.protocol import EpicIssue, EpicStore, no_scores
|
||||
from build_epic.epic_record import EpicRecord
|
||||
@@ -22,6 +21,7 @@ from plan.todo_table import Item
|
||||
from claude_code.reply import Limited
|
||||
from plan_store.jira_epic import number
|
||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||
from loop_state.paths import RELEASE_ROOT
|
||||
from model_routing.ladder import Rung
|
||||
from build_epic.scheduler import unblocks
|
||||
from plan_store.scoring import weighing_texts
|
||||
@@ -30,8 +30,8 @@ from plan_store.scoring import weighing_texts
|
||||
FORMULA = re.compile(r"^`Score = ([^`]+)`$", re.M)
|
||||
# An epic item has no release, and ranking wants every item of one epic in the same one.
|
||||
NO_RELEASE = (0, 0, 0)
|
||||
# The rule every plan item is scored by, under the home folder, where each machine's setup keeps it.
|
||||
RULE = f"{CLAUDE_HOME}/rules/todo-items.md"
|
||||
# The rule every plan item is scored by, under the clone the setup ships in.
|
||||
RULE = pathlib.Path("rules/todo-items.md")
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -209,7 +209,7 @@ def scored(epic: Planned, issues: list[EpicIssue]) -> tuple[list[EpicIssue], Fai
|
||||
bare = [issue for issue in ours if not issue.scores]
|
||||
if not bare or len(ours) < 2:
|
||||
return issues, None
|
||||
rung, language, rule, weighed = planning_rung(epic.config.repoless_model), epic.record.language(), scoring_rule(epic.home), weighing(epic, bare)
|
||||
rung, language, rule, weighed = planning_rung(epic.config.repoless_model), epic.record.language(), scoring_rule(RELEASE_ROOT), weighing(epic, bare)
|
||||
if failed := next((each for each in (rung, language, rule, weighed) if isinstance(each, Failure)), None):
|
||||
return issues, failed
|
||||
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(rule, str) and isinstance(weighed, Weighing)
|
||||
@@ -241,12 +241,12 @@ def scores_set(epic: Planned, issue: EpicIssue, answer: issue_scores.Scores, wei
|
||||
return ranked if isinstance(ranked, Failure) else epic.store.set_scores(issue.key, answer.scores, answer.moves, answer.comment) or held
|
||||
|
||||
|
||||
def scoring_rule(home: pathlib.Path) -> str | Failure:
|
||||
"""The text every plan item is scored by, which says what L, E, I and S mean."""
|
||||
def scoring_rule(clone: pathlib.Path) -> str | Failure:
|
||||
"""The text every plan item is scored by, in clone, which says what L, E, I and S mean."""
|
||||
try:
|
||||
return (home / RULE).read_text(encoding="utf-8")
|
||||
return (clone / RULE).read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"cannot read the scoring rule {home / RULE}, so no issue is scored: {failure}")
|
||||
return Failure(f"cannot read the scoring rule {clone / RULE}, so no issue is scored: {failure}")
|
||||
|
||||
|
||||
def start_order(epic: Planned, issues: list[EpicIssue]) -> list[str] | Failure:
|
||||
|
||||
@@ -14,7 +14,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from build_epic.config import BuildEpicConfig
|
||||
from build_epic.parking import CHUNK_PR
|
||||
from build_epic import chunk_prompt, epic_run, main, planning
|
||||
from build_epic import chunk_prompt, epic_run, main
|
||||
from chunk_driver.chunk_run import ChunkRun
|
||||
from project_config.doubles import configured
|
||||
from project_config.settings import Epic, Finish
|
||||
@@ -162,7 +162,7 @@ class TheCommand(BuildEpicTest):
|
||||
self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out)
|
||||
self.assertIn("ABC-20 waits: it is a human's task\n", out)
|
||||
started = [args for args in fake.tmux_calls if args[0] == "new-session"]
|
||||
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/build-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/build-epic", "--chunk", "ABC-21", "ABC-12"]])
|
||||
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/build-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-e", "XDG_DATA_HOME=", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/build-epic", "--chunk", "ABC-21", "ABC-12"]])
|
||||
# The session is no checkout's, so nothing marks it as one's.
|
||||
self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"])
|
||||
|
||||
@@ -203,6 +203,15 @@ class TheCommand(BuildEpicTest):
|
||||
self.assertIn("--chunk is how build-epic starts itself in a tmux window; run build-epic <EPIC-KEY>\n", err)
|
||||
self.assertEqual(fake.dms, ["build-epic --chunk ABC-21 ABC-12 stopped: --chunk is how build-epic starts itself in a tmux window; run build-epic <EPIC-KEY>"])
|
||||
|
||||
def test_a_chunk_retries_a_failed_check_of_the_loops_claude_home_as_a_failed_worker_run_is(self) -> None:
|
||||
fake = FakeEffects()
|
||||
fake.home_unready = "could not build it"
|
||||
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, {"TMUX_PANE": "%1"})
|
||||
self.assertEqual(code, 1)
|
||||
self.assertEqual(err.count("retrying the check of the loop's Claude home in a minute: could not build it\n"), 2)
|
||||
self.assertEqual(fake.dms, ["build-epic --chunk ABC-21 ABC-12 stopped: the check of the loop's Claude home failed three times running: could not build it"])
|
||||
self.assertEqual(fake.calls, [("sleep", 60), ("sleep", 60)])
|
||||
|
||||
def test_a_chunk_of_an_issue_the_epic_lacks_stops(self) -> None:
|
||||
code, _, err = self.run_main(["--chunk", "ABC-99", "ABC-12"], FakeEffects(), {"TMUX_PANE": "%1"})
|
||||
self.assertEqual(code, 1)
|
||||
@@ -1477,8 +1486,6 @@ class TheDryRun(BuildEpicTest):
|
||||
self.assertEqual([what for seam, what in fake.calls if seam == "git" and "clone" in what], [])
|
||||
|
||||
def test_prints_the_scores_it_would_write_and_the_order_the_issues_would_start_in(self) -> None:
|
||||
(self.home / planning.RULE).parent.mkdir(parents=True, exist_ok=True)
|
||||
(self.home / planning.RULE).write_text("L is how much the item changes.\n", encoding="utf-8")
|
||||
self.description = DESCRIPTION.replace("Ship the import.", "1. **Achieve:** Ship the import.") + "\n## Scoring\n`Score = V`\n"
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
|
||||
answer = {"L": 2, "E": 1, "I": 2, "S": 3, "comment": "Scored to decide what starts first."}
|
||||
|
||||
@@ -21,6 +21,7 @@ from build_epic.config import load
|
||||
from build_epic.backend.fake import MemoryEpic
|
||||
from plan.todo_table import parse_moves
|
||||
from build_epic import planning
|
||||
from loop_state.paths import RELEASE_ROOT
|
||||
|
||||
RANKED = "## Goals\n1. **Achieve:** Ship the import.\n\n## Audience\nThe client's team.\n\n## Scoring\n`Score = V`\n"
|
||||
GOALS = "## Goals\n\n**Void:** code health, since it is a one-off script.\n\n1. **Achieve:** Serve the API.\n\n## Audience\nIts callers.\n"
|
||||
@@ -54,11 +55,6 @@ class Planning(BuildEpicTest):
|
||||
issues, stopped = planning.planned(epic, read)
|
||||
return issues if stopped is None else stopped, store, out.getvalue()
|
||||
|
||||
def rule(self) -> None:
|
||||
"""Writes the rule every plan item is scored by."""
|
||||
(self.home / planning.RULE).parent.mkdir(parents=True, exist_ok=True)
|
||||
(self.home / planning.RULE).write_text("L is how much the item changes.\n", encoding="utf-8")
|
||||
|
||||
def repo(self, name: str) -> None:
|
||||
"""Checks out the repo called name, whose goals file voids code health and states one achieve goal."""
|
||||
checkout = self.home / "code" / name
|
||||
@@ -378,7 +374,9 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual(self.plan(FakeEffects())[0], self.issues)
|
||||
|
||||
def test_scores_each_bare_issue_whoever_filed_it_and_tells_its_team_without_ranking_a_persons(self) -> None:
|
||||
self.rule()
|
||||
# The person's own Claude home may hold an older release's rule, which the scoring doesn't read.
|
||||
(self.home / ".claude/rules").mkdir(parents=True)
|
||||
(self.home / ".claude/rules/todo-items.md").write_text("An older release's rule.\n", encoding="utf-8")
|
||||
self.description = RANKED
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "build-epic-claude", by_loop=False), issue("ABC-21", "build-epic-claude")]
|
||||
# An earlier run made the folder the scoring runs in.
|
||||
@@ -392,12 +390,12 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual(out, "<1790000000> scoring ABC-21\n<1790000000> ABC-21 is scored L 2, E 1, I 2, S 3, Moves epic 1 by 9\n")
|
||||
self.assertEqual(planning.start_order(self.epic, found), ["ABC-21", "ABC-20"])
|
||||
(asked,) = fake.made("claude")
|
||||
for part in ("L is how much the item changes.", "Write the comment in English", "An item moves only these: `epic 1`.", "## Item ABC-21: Do ABC-21", "Labels: build-epic-claude"):
|
||||
self.assertNotIn("An older release's rule.", asked[1])
|
||||
for part in ((RELEASE_ROOT / "rules/todo-items.md").read_text(encoding="utf-8"), "Write the comment in English", "An item moves only these: `epic 1`.", "## Item ABC-21: Do ABC-21", "Labels: build-epic-claude"):
|
||||
self.assertIn(part, asked[1])
|
||||
self.assertIn("--json-schema", asked[0])
|
||||
|
||||
def test_scores_no_human_task_and_no_issue_that_is_the_only_one_to_start(self) -> None:
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-human")]
|
||||
fake = FakeEffects()
|
||||
@@ -407,7 +405,6 @@ class Planning(BuildEpicTest):
|
||||
def test_scores_no_issue_whose_work_has_landed(self) -> None:
|
||||
with (self.home / ".config/build-release/build-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write('\njira-unblocking-statuses = ["Release Ready"]\n')
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
self.issues = [issue("ABC-20", "build-epic-claude", status="release ready"), issue("ABC-21", "build-epic-claude"), scored("ABC-22", "epic 1 by 2", "build-epic-claude")]
|
||||
fake = FakeEffects(claude=[says(ANSWER)])
|
||||
@@ -417,7 +414,6 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual(planning.start_order(self.epic, found), ["ABC-21", "ABC-22"])
|
||||
|
||||
def test_names_an_issue_whose_scoring_fails_and_scores_the_next(self) -> None:
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude"), issue("ABC-22", "build-epic-claude"), issue("ABC-23", "build-epic-claude")]
|
||||
fake = FakeEffects(claude=[says({"L": "big"}), says(ANSWER | {"moves": "epic 7 by 5"}), says(ANSWER | {"L": 99}), says(ANSWER)])
|
||||
@@ -432,7 +428,6 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual(planning.start_order(self.epic, found), ["ABC-23"])
|
||||
|
||||
def test_names_each_issue_whose_goals_cannot_be_read_and_asks_claude_about_none(self) -> None:
|
||||
self.rule()
|
||||
self.description = RANKED.replace("1. **Achieve:** ", "")
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
|
||||
fake = FakeEffects()
|
||||
@@ -442,7 +437,6 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual(fake.made("claude"), [])
|
||||
|
||||
def test_the_scoring_call_runs_in_the_epics_state_folder(self) -> None:
|
||||
self.rule()
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
|
||||
effects, folders = FakeEffects(claude=[says(ANSWER), says(ANSWER)]).effects(), []
|
||||
|
||||
@@ -455,7 +449,6 @@ class Planning(BuildEpicTest):
|
||||
planning.planned(epic, list(self.issues))
|
||||
self.assertEqual(folders, [str(self.folder)] * 2)
|
||||
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
|
||||
fake = FakeEffects(claude=[subprocess.CompletedProcess([], 0, json.dumps(LIMIT), "")])
|
||||
@@ -464,7 +457,6 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual((store.writes, len(fake.made("claude"))), ([], 1))
|
||||
|
||||
def test_names_a_score_the_tracker_refuses(self) -> None:
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-human"), scored("ABC-22", "epic 1 by 2", "build-epic-claude")]
|
||||
store = MemoryEpic("ABC-12", list(self.issues))
|
||||
@@ -478,13 +470,12 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual((found, stopped, out.getvalue()), (self.issues, None, "<1790000000> scoring ABC-20\n<1790000000> ABC-20 is not scored: Jira answered 503\n"))
|
||||
|
||||
def test_scores_no_issue_without_the_scoring_rule_or_the_epics_formula(self) -> None:
|
||||
# A clone without the rule, here the test's home folder.
|
||||
rule = planning.scoring_rule(self.home)
|
||||
assert isinstance(rule, Failure), rule
|
||||
self.assertIn(f"cannot read the scoring rule {self.home}/rules/todo-items.md, so no issue is scored: ", rule.reason)
|
||||
self.issues = [issue("ABC-20", "build-epic-claude"), issue("ABC-21", "build-epic-claude")]
|
||||
self.description = RANKED
|
||||
fake = FakeEffects()
|
||||
found, _, _ = self.plan(fake)
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertIn(f"cannot read the scoring rule {self.home}/.claude/rules/todo-items.md, so no issue is scored: ", found.reason)
|
||||
self.rule()
|
||||
self.description = "## Goals\n1. **Achieve:** Ship the import.\n\n## Audience\nThe client's team.\n\n## Scoring\n"
|
||||
found, _, _ = self.plan(fake)
|
||||
assert isinstance(found, Failure), found
|
||||
@@ -492,7 +483,6 @@ class Planning(BuildEpicTest):
|
||||
self.assertEqual(fake.made("claude"), [])
|
||||
|
||||
def test_scores_a_sub_task_on_its_own_against_its_repos_goals_in_the_epics_language(self) -> None:
|
||||
self.rule()
|
||||
self.repo("api")
|
||||
self.description = RANKED + "\n**Language:** Swedish\n"
|
||||
self.issues = [issue("ABC-20", "split-by-repo"), issue("ABC-30", "repo:api", parent="ABC-20"), scored("ABC-21", "epic 1 by 2", "build-epic-claude")]
|
||||
|
||||
Reference in New Issue
Block a user