Answer stability round 1: 0 🔴, 5 🟡 (1 misread); start chunks after a partial planning and keep what planning wrote
This commit is contained in:
+100
-24
@@ -3,6 +3,7 @@ import dataclasses
|
||||
import io
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -43,7 +44,8 @@ class Planning(DoEpicTest):
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(self.asked):
|
||||
read = store.read()
|
||||
assert not isinstance(read, Failure)
|
||||
return planning.planned(epic, read), store, out.getvalue()
|
||||
issues, stopped = planning.planned(epic, read)
|
||||
return issues if stopped is None else stopped, store, out.getvalue()
|
||||
|
||||
def labels(self, store: MemoryEpic) -> dict[str, tuple[str, ...]]:
|
||||
return {each.key: each.labels for each in store.issues}
|
||||
@@ -140,19 +142,62 @@ class Planning(DoEpicTest):
|
||||
found, store, out = self.plan(fake)
|
||||
self.assertEqual(found, [issue("ABC-20", "repo:web")])
|
||||
self.assertIn("ABC-20, Do ABC-20: Is the importer in api or in web?\n", self.asked.getvalue())
|
||||
self.assertIn("`api` is none of those labels\n", self.asked.getvalue())
|
||||
self.assertEqual(fake.made("input"), ["The label that says where ABC-20 is worked, `repo:<name>`, `do-epic-claude` or `do-epic-human`: "] * 2)
|
||||
self.assertIn("`api` is none of those labels; the repo api's label is `repo:api`\n", self.asked.getvalue())
|
||||
self.assertEqual(fake.made("input"), ["The label that says where ABC-20 is worked, `repo:<name>`, `do-epic-claude` or `do-epic-human`, or Enter alone to leave it waiting: "] * 2)
|
||||
|
||||
def test_an_unclear_issue_waits_where_nobody_can_answer_and_the_next_is_planned(self) -> None:
|
||||
def unclear_then_claudes(self, **fake: object) -> tuple[dict[str, tuple[str, ...]], str]:
|
||||
"""The labels and the output after planning ABC-20, which the rule leaves unclear, and ABC-21, which is Claude's, on a FakeEffects made with fake."""
|
||||
self.issues = [issue("ABC-20"), issue("ABC-21")]
|
||||
unclear = says({"pick": "unclear", "question": "Is the importer in api or in web?"})
|
||||
for fake in (FakeEffects(claude=[says({"parts": []}), unclear, says({"parts": []}), says({"pick": "claude"})], on_terminal=False), FakeEffects(claude=[says({"parts": []}), unclear, says({"parts": []}), says({"pick": "claude"})], inputs=[EOFError()])):
|
||||
with self.subTest(on_terminal=fake.terminal):
|
||||
self.issues = [issue("ABC-20"), issue("ABC-21")]
|
||||
_, store, out = self.plan(fake)
|
||||
self.assertEqual(self.labels(store), {"ABC-20": (), "ABC-21": ("do-epic-claude",)})
|
||||
self.assertNotIn("ABC-20 is labelled", out)
|
||||
if not fake.terminal:
|
||||
self.assertIn("ABC-20 waits for your answer: Is the importer in api or in web? Run `do-epic ABC-12` on a terminal to answer, or label the issue in Jira.\n", out)
|
||||
_, store, out = self.plan(FakeEffects(claude=[says({"parts": []}), unclear, says({"parts": []}), says({"pick": "claude"})], **fake)) # type: ignore[arg-type]
|
||||
return self.labels(store), out
|
||||
|
||||
def test_an_unclear_issue_waits_off_a_terminal_and_the_next_is_planned(self) -> None:
|
||||
labels, out = self.unclear_then_claudes(on_terminal=False)
|
||||
self.assertEqual(labels, {"ABC-20": (), "ABC-21": ("do-epic-claude",)})
|
||||
self.assertNotIn("ABC-20 is labelled", out)
|
||||
self.assertIn("ABC-20 waits for your answer: Is the importer in api or in web? Run `do-epic ABC-12` on a terminal to answer, or label the issue in Jira.\n", out)
|
||||
|
||||
def test_an_unclear_issue_waits_where_the_human_answers_with_enter_alone(self) -> None:
|
||||
labels, out = self.unclear_then_claudes(inputs=[" "])
|
||||
self.assertEqual((labels, "ABC-20 is labelled" in out), ({"ABC-20": (), "ABC-21": ("do-epic-claude",)}, False))
|
||||
|
||||
def test_an_unclear_issue_waits_where_the_terminals_input_ends(self) -> None:
|
||||
labels, out = self.unclear_then_claudes(inputs=[EOFError()])
|
||||
self.assertEqual((labels, "ABC-20 is labelled" in out), ({"ABC-20": (), "ABC-21": ("do-epic-claude",)}, False))
|
||||
|
||||
def test_clones_a_labelled_repo_without_a_checkout_beside_the_origin_of_the_others(self) -> None:
|
||||
configured(self, self.home / "code" / "api", home=self.home)
|
||||
configured(self, self.home / "code" / "web", home=self.home)
|
||||
shutil.rmtree(self.home / "code" / "web")
|
||||
self.issues = [issue("ABC-18", "repo:api", done=True), issue("ABC-19", "repo:web", done=True), issue("ABC-20")]
|
||||
fake = FakeEffects(git=["https://git.example/acme/api.git\n", ""], claude=[says({"parts": []}), says({"pick": "claude"})])
|
||||
self.plan(fake)
|
||||
origin, clone = fake.made("git")
|
||||
self.assertEqual((origin, clone[-4:]), (["remote", "get-url", "origin"], ["clone", "--", "https://git.example/acme/web", str(self.home / "code" / "web")]))
|
||||
|
||||
def health_first(self, floor: str) -> list[str]:
|
||||
"""The order of ABC-20, which moves the epic's goal by 9, and ABC-21, which moves code health by 3 in a repo that scored 7.5 and whose config ends with the line floor."""
|
||||
checkout = self.home / "code" / "api"
|
||||
folder = configured(self, checkout, home=self.home)
|
||||
with (folder / "config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write(floor)
|
||||
(checkout / "README.md").write_text("## Goals\n\n1. **Achieve:** Serve the API.\n\n## Audience\nIts callers.\n", encoding="utf-8")
|
||||
(checkout / "docs").mkdir()
|
||||
(checkout / "docs" / "comprehension-history.md").write_text("# Comprehension history\n\n## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\n| Seat | Overall |\n|---|---|\n| Mid A | 6 |\n| Mean | 7.5 |\n", encoding="utf-8")
|
||||
self.description = RANKED
|
||||
self.issues = [scored("ABC-20", "epic 1 by 9", "do-epic-claude"), scored("ABC-21", "code health by 3", "repo:api")]
|
||||
found = self.plan(FakeEffects())[0]
|
||||
assert not isinstance(found, Failure | Limited), found
|
||||
return [each.key for each in found]
|
||||
|
||||
def test_code_health_weighs_four_times_in_a_repo_under_the_floor_its_config_sets(self) -> None:
|
||||
# 4 * 3 * 0.97 is above the 9 of the epic's first goal.
|
||||
self.assertEqual(self.health_first("readability-floor = 8.0\n"), ["ABC-21", "ABC-20"])
|
||||
|
||||
def test_code_health_weighs_once_in_a_repo_at_its_floor(self) -> None:
|
||||
# 3 * 0.97 is under the 9 of the epic's first goal.
|
||||
self.assertEqual(self.health_first(""), ["ABC-20", "ABC-21"])
|
||||
|
||||
def test_an_issue_claude_fails_on_is_named_and_the_next_is_planned(self) -> None:
|
||||
self.issues = [issue("ABC-20"), issue("ABC-21")]
|
||||
@@ -175,7 +220,7 @@ class Planning(DoEpicTest):
|
||||
assert not isinstance(found, Failure | Limited), found
|
||||
# ABC-22 scores highest, and ABC-24 blocks it. ABC-21 is a person's, and nobody scored ABC-23.
|
||||
self.assertEqual([each.key for each in found], ["ABC-24", "ABC-21", "ABC-22", "ABC-23", "ABC-20"])
|
||||
self.assertIn("re-ranking the loop's issues in ABC-12's backlog\n", out)
|
||||
self.assertIn("re-ranking the issues do-epic filed in ABC-12's backlog\n", out)
|
||||
|
||||
def test_ranks_an_issue_in_a_repo_by_that_repos_goals_after_the_epics(self) -> None:
|
||||
checkout = self.home / "code" / "api"
|
||||
@@ -196,7 +241,7 @@ class Planning(DoEpicTest):
|
||||
def test_fails_where_the_epic_states_no_formula_to_rank_two_scored_issues_by(self) -> None:
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9", "do-epic-claude")]
|
||||
found, store, _ = self.plan(FakeEffects())
|
||||
self.assertEqual(found, Failure("the epic ABC-12's description states `Score = ...` 0 times under ## Scoring; state the formula that ranks its issues once, on a line of its own, such as `Score = 100 * V / (2**S + 32)`"))
|
||||
self.assertEqual(found, Failure("the epic ABC-12's description states `Score = ...` 0 times under ## Scoring; state the formula that ranks its issues once, on a line of its own and inside backticks, such as `Score = 100 * V / (2**S + 32)`"))
|
||||
self.assertEqual([each.key for each in store.issues], ["ABC-20", "ABC-21"])
|
||||
|
||||
def test_fails_where_the_formula_names_a_score_no_issue_holds(self) -> None:
|
||||
@@ -207,7 +252,7 @@ class Planning(DoEpicTest):
|
||||
def test_fails_where_two_issues_to_rank_share_a_number(self) -> None:
|
||||
self.description = RANKED
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("XYZ-20", "epic 1 by 9", "do-epic-claude")]
|
||||
self.assertEqual(self.plan(FakeEffects())[0], Failure("two of the loop's issues in the epic ABC-12 share a number in different Jira projects, so they cannot be ranked; move one of them"))
|
||||
self.assertEqual(self.plan(FakeEffects())[0], Failure("ABC-20 and XYZ-20 share a number in different Jira projects, so the issues do-epic filed in the epic ABC-12 cannot be ranked; move one of the two to the other's Jira project"))
|
||||
|
||||
def test_fails_where_the_description_cannot_be_read_to_rank_by(self) -> None:
|
||||
self.description = Failure("Jira answered 503")
|
||||
@@ -235,14 +280,45 @@ class Planning(DoEpicTest):
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), issue("ABC-21", "do-epic-claude")]
|
||||
self.assertEqual(self.plan(FakeEffects())[0], self.issues)
|
||||
|
||||
def test_fails_where_the_tracker_cannot_be_read_after_a_pick(self) -> None:
|
||||
self.issues = [issue("ABC-20")]
|
||||
|
||||
def failing(_: object) -> subprocess.CompletedProcess[str]:
|
||||
self.store.fails = "Jira answered 503"
|
||||
return says({"parts": []})
|
||||
def planned_on(self, store: MemoryEpic, fake: FakeEffects) -> tuple[list[EpicIssue], Failure | Limited | None]:
|
||||
"""What planning answers for self.issues on a store that doesn't read as MemoryEpic does."""
|
||||
config = load(self.home)
|
||||
self.store = MemoryEpic("ABC-12", list(self.issues))
|
||||
epic = planning.Planned("ABC-12", config, self.store, EpicRecord(Description(self.description)), self.home, FakeEffects(claude=[failing, says({"pick": "claude"})]).effects()) # type: ignore[arg-type]
|
||||
assert not isinstance(config, Failure), config
|
||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, fake.effects()) # type: ignore[arg-type]
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
self.assertEqual(planning.planned(epic, list(self.issues)), Failure("Jira answered 503"))
|
||||
return planning.planned(epic, list(self.issues))
|
||||
|
||||
def test_a_label_it_added_counts_where_the_tracker_cannot_be_read_afterwards(self) -> None:
|
||||
self.issues = [issue("ABC-20")]
|
||||
found = self.planned_on(Unreadable("ABC-12", list(self.issues)), FakeEffects(claude=[says({"parts": []}), says({"pick": "claude"})]))
|
||||
self.assertEqual(found, ([issue("ABC-20", "do-epic-claude")], Failure("Jira answered 503")))
|
||||
|
||||
def test_a_label_and_an_order_it_wrote_count_where_the_trackers_search_lags(self) -> None:
|
||||
self.description = RANKED
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "epic 1 by 9"), issue("ABC-22")]
|
||||
parts = says({"parts": [{"repo": "api", "change": "Add the endpoint."}, {"repo": "web", "change": "Call it."}], "comment": "Split by repo: api and web."})
|
||||
found, stopped = self.planned_on(Lagging("ABC-12", list(self.issues)), FakeEffects(claude=[says({"parts": []}), says({"pick": "claude"}), parts]))
|
||||
self.assertEqual(([(each.key, each.labels) for each in found], stopped), ([("ABC-21", ("do-epic-claude",)), ("ABC-20", ("do-epic-claude",)), ("ABC-22", ("split-by-repo",))], None))
|
||||
|
||||
def test_an_issue_without_a_pick_is_not_ranked(self) -> None:
|
||||
self.description = RANKED
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude"), scored("ABC-21", "code health by 9")]
|
||||
found, _, out = self.plan(FakeEffects(claude=[subprocess.CompletedProcess([], 1, "", "")]))
|
||||
self.assertEqual((found, "re-ranking" in out), (self.issues, False))
|
||||
|
||||
|
||||
class Unreadable(MemoryEpic):
|
||||
"""A tracker that fails each read once an issue is labelled."""
|
||||
def add_label(self, key: str, label: str) -> None | Failure:
|
||||
self.fails = "Jira answered 503"
|
||||
return None
|
||||
|
||||
|
||||
class Lagging(MemoryEpic):
|
||||
"""A tracker whose search shows the issues as they were before any write."""
|
||||
def read(self) -> list[EpicIssue] | Failure:
|
||||
return list(self.before)
|
||||
|
||||
def __init__(self, key: str, issues: list[EpicIssue]) -> None:
|
||||
super().__init__(key, issues)
|
||||
self.before = list(issues)
|
||||
|
||||
Reference in New Issue
Block a user