diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index 470bbb23..cd7cdb4d 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -17,7 +17,7 @@ def render(found: Gathered) -> list[str]: note = [f"- {found.note}"] if found.note else [] unseen = [f"- {UNSEEN_RELEASES}"] if found.plan_outside else [] head = [*note, f"- {last_release(found.default, found.cut)}", *unseen] - paths = f"- The project's config puts its files at: {'; '.join(f'{setting} {path}' for setting, path in found.places.items())}." + paths = f"- The project's config puts its files and plan at: {'; '.join(f'{setting} {path}' for setting, path in found.places.items())}." texts = f"- The project's config sets: {'; '.join(f'{setting} {text}' for setting, text in found.texts.items())}." if isinstance(found.item, NoItem): return [*head, f"- No plan item: {found.item.why} No worktree was made.", paths, texts] @@ -94,7 +94,7 @@ def bundled(plan: Plan) -> list[str]: return [f"- Item {first.id} has R above {BUNDLE_MAX_R}, so it ships alone."] if not candidates: return [f"- No other item of release {version(first.release)} may join item {first.id}'s chunk."] - listed = [f" - item {item.id}, {levels(item)}, S {item.scores['S']}: {item.tagline}" for item in candidates] + listed = [f" - item {item.id}, {levels(item)}, S {item.scores.get('S', 'unscored')}: {item.tagline}" for item in candidates] return [f'- The items of release {version(first.release)} that may join the chunk of item {first.id}, where `~/.claude/CLAUDE.md` → "Working loop" lets them share it:', *listed] diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index e6e42ac7..511692cc 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -1,3 +1,4 @@ +import dataclasses import os import pathlib import shutil @@ -139,7 +140,7 @@ class ChunkPreflightTool(unittest.TestCase): self.assertEqual(done.returncode, 0, done.stderr) worktree = repo.temp / "proj-item-7" self.assertIn("item 7, L 1, E + I 2", done.stdout, "origin's todo.md still holds item 3, which the plan in the config's folder does not") - self.assertIn(f"- The project's config puts its files at: plan {folder}/todo.md; working-rules {worktree}/AGENTS.md; decisions {worktree}/docs/decisions.md; ", done.stdout) + self.assertIn(f"- The project's config puts its files and plan at: plan {folder}/todo.md; working-rules {worktree}/AGENTS.md; decisions {worktree}/docs/decisions.md; ", done.stdout) self.assertIn("`rank_todo.py --check` exited 0", done.stdout) self.assertIn(f"- {UNSEEN_RELEASES}\n", done.stdout) config.unlink() @@ -388,7 +389,7 @@ class Render(unittest.TestCase): def test_states_each_fact_once_with_the_paths_between_the_worktree_and_the_open_pull_requests(self): lines = render(gathered(item_facts())) - self.assertEqual([line.partition(":")[0] for line in lines[:6]], ["- Last version cut", "- The earliest release in origin/main's todo.md", "- Worktree", "- The project's config puts its files at", "- The project's config sets", "- Open pull requests from item-3"]) + self.assertEqual([line.partition(":")[0] for line in lines[:6]], ["- Last version cut", "- The earliest release in origin/main's todo.md", "- Worktree", "- The project's config puts its files and plan at", "- The project's config sets", "- Open pull requests from item-3"]) self.assertEqual([line for line in lines[6:] if line.startswith("- Open pull requests")], []) def test_says_that_a_plan_outside_the_checkout_hides_a_release_whose_items_are_all_done(self): @@ -404,6 +405,12 @@ class Render(unittest.TestCase): self.assertIn("Item 7's detail:\n\n> Touch `src/other.py`.\n> \n> Run the e2e leg.", said) self.assertNotIn("Not quoted", said) + def test_lists_a_joining_item_nobody_scored_as_unscored(self): + plan = item_facts().plan + unscored = [dataclasses.replace(item, scores={}) if item.id == 7 else item for item in plan.items] + said = rendered(item_facts(plan=dataclasses.replace(plan, items=unscored))) + self.assertIn(" - item 7, L unscored, E + I unscored, S unscored: ", said) + def test_states_that_a_joining_item_has_no_detail(self): said = rendered(item_facts()) self.assertIn("Item 7 has no detail.", said) diff --git a/bin/rank_todo.py b/bin/rank_todo.py index ff2ee2e1..14130d0f 100755 --- a/bin/rank_todo.py +++ b/bin/rank_todo.py @@ -106,6 +106,9 @@ def main(argv: list[str]) -> int: config = located(None, pathlib.Path.home()) if isinstance(config, Failure): return fail(config) + if config.plan_file is None and args == (True, None): + # Jira's backlog ranks a plan kept there, so the check passes, as silently as on a ranked todo.md: chunk-preflight runs it on every project. + return 0 if config.plan_file is None: return fail(Failure(f"rank_todo.py ranks a todo.md, and this checkout's config keeps the plan in Jira, whose backlog ranks it: {config.plan_label}")) check, todo = args[0], args[1] or config.plan_file diff --git a/bin/test_rank_todo.py b/bin/test_rank_todo.py index 13f2a5d2..3fc726de 100644 --- a/bin/test_rank_todo.py +++ b/bin/test_rank_todo.py @@ -64,8 +64,10 @@ class Main(unittest.TestCase): config.write_text(config.read_text().replace('"checkout:todo.md"', '"jira:https://acme.atlassian.net/browse/ABC-12"') + 'env-file = "~/acme.env"\n') todo = pathlib.Path(temp, "todo.md") todo.write_text(TODO) - for args in ((), ("--check",), (str(todo),)): - self.assertEqual(self.run_main(*args), (1, "rank_todo.py ranks a todo.md, and this checkout's config keeps the plan in Jira, whose backlog ranks it: jira:https://acme.atlassian.net/browse/ABC-12\n")) + for args in ((), (str(todo),), ("--check", str(todo))): + with self.subTest(args=args): + self.assertEqual(self.run_main(*args), (1, "rank_todo.py ranks a todo.md, and this checkout's config keeps the plan in Jira, whose backlog ranks it: jira:https://acme.atlassian.net/browse/ABC-12\n")) + self.assertEqual(self.run_main("--check"), (0, "")) self.assertEqual(todo.read_text(), TODO) def test_refuses_a_file_that_is_not_the_plan_the_config_names_and_a_checkout_no_config_names(self):