Answer architecture round 2: 0 🔴, 1 🟡 (0 misread); move task_bench's shared Side and Rust test-module scanner to the package top, rename figures.py to run_figures.py, check for cycles between a package's parts, and move REVIEW_LABEL into the backend protocol
CI / tests (pull_request) Successful in 5m13s

This commit is contained in:
2026-11-27 11:36:37 +01:00
parent b563a597f1
commit 7c7d43023b
23 changed files with 84 additions and 45 deletions
+1 -2
View File
@@ -8,11 +8,10 @@ from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
from plan_store.jira_epic import BLOCKS, FILED_BY, scores as held_scores, PROPERTY
from project_config.settings import DEFAULT_ISSUE_TYPE, Epic, Finish, JIRA_FINDING_TYPE, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION, JIRA_REVIEW_TYPE
from atlassian.jira import DONE, edit_issue, entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, issue_types_of, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, SHAPE, status_category, unshaped
from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, unfit, unfit_label
from do_epic.backend.protocol import EpicIssue, no_blocker, no_child, no_parent, no_scores, no_words, REVIEW_LABEL, unfit, unfit_label
from failure import Failure
from do_epic.backend.jira_status import moved_by, moved_to
from plan.todo_table import MOVES
from do_epic.repo_pick import REVIEW_LABEL
from do_epic.backend.jira_start import Start, started
FIELDS = ["summary", "description", "labels", "assignee", "status", "parent", "issuelinks"]
+2
View File
@@ -9,6 +9,8 @@ from plan.todo_table import Exempt, item_fields, ItemFields, Moves, MOVES
from failure import Failure
from plan_store.jira_epic import SET_SCORES
# Marks the issue that asks for a repo's release review, beside the label that names the repo (finish.py). Not `release-review`, which could pass for the team's own release process: three readers, seated as the human, as a chunk's worker and as one of the client's team, picked this one 3-0 from four.
REVIEW_LABEL = "do-epic-release-review"
# What a tracker accepts as a label: Jira refuses a label holding white space.
LABEL = re.compile(r"\S+")
+1 -1
View File
@@ -13,7 +13,7 @@ from do_epic.backend.contract import EpicStoreContract
from failure import Failure
from do_epic.backend.jira import JiraEpic
from adf_codec.convert import Refused
from do_epic.repo_pick import REVIEW_LABEL
from do_epic.backend.protocol import REVIEW_LABEL
from do_epic.backend.jira_start import Start
SITE = "https://acme.atlassian.net"
+2 -2
View File
@@ -34,8 +34,8 @@ import types
from project_config.settings import anywhere, CONFIG, DEFAULT_ISSUE_TYPE, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINDING_TYPE, JIRA_FINISH, JIRA_REVIEW_TYPE, LANGUAGE, language_fault, lies_in, name_of, parsed, PROJECTS, SITE, type_fault
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 do_epic.backend.protocol import LABEL, REVIEW_LABEL
from do_epic.repo_pick import LabelRepos, of_label, REPO_NAME
from text_files.markdown_text import listed
from model_routing.ladder_file import read_ladder, SHIPPED
from do_epic.split import SPLIT_LABEL
+2 -2
View File
@@ -7,8 +7,8 @@ import fcntl
import pathlib
import typing
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, label_of, LabelRepos, of_label, REPO_PREFIX, REVIEW_LABEL, team_label
from do_epic.backend.protocol import EpicIssue, EpicStore
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, label_of, LabelRepos, of_label, REPO_PREFIX, team_label
from do_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL
from do_epic.epic_record import EpicRecord
from failure import Failure
from text_files.markdown_text import listed
+2 -2
View File
@@ -12,11 +12,11 @@ import pathlib
import typing
from do_epic.chunk_prompt import DRIVER
from do_epic.backend.protocol import EpicIssue, EpicStore
from do_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL
from failure import Failure
from do_epic import findings
from do_epic.split import finished
from do_epic.repo_pick import label_of, LabelRepos, recorded, Repo, REVIEW_LABEL
from do_epic.repo_pick import label_of, LabelRepos, recorded, Repo
from text_files.markdown_text import listed
from text_files.piped_text import piped
-2
View File
@@ -16,8 +16,6 @@ from claude_code.entries import structured_output
REPO_PREFIX = "repo:"
CLAUDE_LABEL = "do-epic-claude"
HUMAN_LABEL = "do-epic-human"
# Marks the issue that asks for a repo's release review, beside the label that names the repo (finish.py). Not `release-review`, which could pass for the team's own release process: three readers, seated as the human, as a chunk's worker and as one of the client's team, picked this one 3-0 from four.
REVIEW_LABEL = "do-epic-release-review"
# 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.-]*")
+51 -8
View File
@@ -31,6 +31,36 @@ def package_imports(bin_folder: pathlib.Path) -> dict[str, set[str]]:
return imported
def imported_names(module: pathlib.Path) -> list[str]:
"""The dotted name of each thing the file module imports, as `a.b.c` for `from a.b import c`. A deferred import inside a function counts."""
found: list[str] = []
for node in ast.walk(ast.parse(module.read_text(encoding="utf-8"))):
found += [alias.name for alias in node.names] if isinstance(node, ast.Import) else [f"{node.module}.{alias.name}" for alias in node.names] if isinstance(node, ast.ImportFrom) and node.level == 0 and node.module else []
return found
def part_imports(package: pathlib.Path) -> dict[str, set[str]]:
"""Each part of the package, with the other parts of it that its modules import, tests aside. A part is a module at the package's top, or a folder there with every module under it: a folder states that its modules belong together, so the top may not lean on a folder that leans on the top."""
imported: dict[str, set[str]] = {}
for module in package.rglob("*.py"):
if module.name.startswith("test_"):
continue
part = module.relative_to(package).parts[0].removesuffix(".py")
inside = [name.split(".")[1] for name in imported_names(module) if name.startswith(f"{package.name}.")]
imported.setdefault(part, set()).update(other for other in inside if other != part)
return imported
def part_cycles(bin_folder: pathlib.Path) -> dict[str, list[str]]:
"""Each package under bin_folder whose parts import in a cycle, with the parts along one."""
found = {}
for package in sorted(init.parent for init in bin_folder.glob("*/__init__.py")):
imported = part_imports(package)
if cycle(imported):
found[package.name] = cycle(imported)
return found
# The entry points that drive chunks. What two of them need lives in bin/chunk_driver/, so no other package imports one, its tests included.
DRIVERS = ("do_epic", "loop_claude")
@@ -62,18 +92,16 @@ def imports_of_test_modules(bin_folder: pathlib.Path) -> list[str]:
found = []
for module in sorted(bin_folder.rglob("*.py")):
package = module.relative_to(bin_folder).parts[0]
for node in ast.walk(ast.parse(module.read_text(encoding="utf-8"))):
names = [alias.name for alias in node.names] if isinstance(node, ast.Import) else [f"{node.module}.{alias.name}" for alias in node.names] if isinstance(node, ast.ImportFrom) and node.level == 0 and node.module else []
for name in names:
top, *below = name.split(".")
tests = [part for part in below if part.startswith("test_")]
if tests and top != package:
found.append(f"{module.relative_to(bin_folder)} imports {name[:name.index(tests[0]) + len(tests[0])]}")
for name in imported_names(module):
top, *below = name.split(".")
tests = [part for part in below if part.startswith("test_")]
if tests and top != package:
found.append(f"{module.relative_to(bin_folder)} imports {name[:name.index(tests[0]) + len(tests[0])]}")
return sorted(set(found))
def cycle(imported: dict[str, set[str]]) -> list[str]:
"""One cycle among the packages, as the packages along it; empty where there is none."""
"""One cycle among the packages or parts that imported names, as those along it; empty where there is none."""
try:
graphlib.TopologicalSorter(imported).prepare()
except graphlib.CycleError as found:
@@ -135,6 +163,21 @@ class PackageCycles(unittest.TestCase):
})
self.assertEqual(package_imports(folder), {"a": {"b"}, "b": {"a"}, "c": set()})
def test_no_part_of_a_package_imports_one_that_imports_it_back(self):
self.assertEqual(part_cycles(ROOT / "bin"), {}, "move what both parts need into a module at the package's top that imports neither")
def test_reads_a_folder_of_a_package_as_one_part_and_a_module_at_its_top_as_another(self):
with tempfile.TemporaryDirectory() as temp:
folder = pathlib.Path(temp)
tree(folder, {
"a/__init__.py": "", "a/main.py": "from a.kind.plant import x\nfrom a import shared\nimport b.kind\n",
"a/shared.py": "def f():\n\tfrom a.kind import plant\n",
"a/kind/__init__.py": "", "a/kind/plant.py": "import a.shared\nfrom a.kind.deep import other\n", "a/kind/deep/other.py": "import a.kind.plant\n",
"a/test_shared.py": "import a.main\n", "a/kind/test_plant.py": "import a.main\n",
})
self.assertEqual(part_imports(folder / "a"), {"__init__": set(), "main": {"kind", "shared"}, "shared": {"kind"}, "kind": {"shared"}})
self.assertEqual(sorted(cycle(part_imports(folder / "a"))[:2]), ["kind", "shared"])
def test_a_cycle_through_a_deferred_import_is_found(self):
self.assertEqual(sorted(cycle({"a": {"b"}, "b": {"a"}})[:2]), ["a", "b"])
self.assertEqual(cycle({"a": {"b"}, "b": set()}), [])
+1 -1
View File
@@ -2,7 +2,7 @@
import re
import typing
from task_bench.figures.figures import Side
from task_bench.tasks import Side
HUNK = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", re.MULTILINE)
+1 -2
View File
@@ -10,14 +10,13 @@ import pathlib
import shutil
import typing
from task_bench.tasks import Bench, check_made, committed, DATA_SOURCE, FEATURE, Kind, on_disk, Planned, Task
from task_bench.tasks import Bench, check_made, committed, DATA_SOURCE, FEATURE, Kind, on_disk, Planned, Side, SIDES, Task
from project_config.settings import BENCH_TASKS, CONFIG
from failure import Failure
from task_bench.features.registers import GENERATE, NotGenerated, registered_trees
from project_config.main import located
from mutate_changes.tool_process import Ran
from task_bench.runs import ran_tests, TimedOut
from task_bench.figures.figures import Side, SIDES
SPEC = "spec.md"
PATCH = "reference.patch"
+1 -2
View File
@@ -5,10 +5,9 @@ import os
import pathlib
import shutil
from task_bench.tasks import Bench, committed, on_disk
from task_bench.tasks import Bench, committed, on_disk, Side, SIDES
from task_bench.runs import Containers, entries, in_tree, NotStarted, run_in_image, TimedOut
from failure import Failure
from task_bench.figures.figures import Side, SIDES
# A panel of three readers, seated as the README's audience, picked the name on 2026-11-23: each had it first or second, over
# `register`, which reads as a data file, and `generate-source`, which two read as generating source code.
+1 -2
View File
@@ -10,7 +10,7 @@ import shutil
import typing
from task_bench.features.feature_tasks import ACCEPTANCE, Feature, PATCH, why_passed_over
from task_bench.tasks import Bench, committed, on_disk, Planned, Task
from task_bench.tasks import Bench, committed, on_disk, Planned, Side, SIDES, Task
from branch_chunks.read import cut_with_shipped, unsupported
from failure import Failure
from git_cli.git_repo import Git
@@ -18,7 +18,6 @@ from plan.todo_table import Item, tagline_text
from project_config.main import located
from task_bench.runs import of_tests
from project_config.settings import RECORDS
from task_bench.figures.figures import Side, SIDES
# Why a feature that landed by fast-forward is passed over: no earlier chunk says where its commits start, or its branch merged
# the default branch into itself, so its commits hold what other features built.
+1 -1
View File
@@ -8,7 +8,7 @@ import typing
from claude_code.entries import AssistantTurn, Entry, Text, tool_calls, ToolCall, ToolResult, ToolResults
from task_bench.runs import HOME, WORK
from reading_cost.measure import reads_of
from task_bench.figures.figures import Side
from task_bench.tasks import Side
# A trace keeps the first TEXT_LINES lines of the model's text between two calls, and the first TEXT_WIDTH characters of each.
TEXT_LINES = 3
+2 -2
View File
@@ -15,10 +15,10 @@ from text_files.utc_stamp import utc
# The digest's line that names the commits, as task_bench.digest.digest writes it.
SIDES = re.compile(r"^Base ([0-9a-f]{7,40}), head ([0-9a-f]{7,40})\.", re.M)
# How the table's three rows over every task open, as task_bench.figures.figures.table writes them: the base, the head and the head's change.
# How the table's three rows over every task open, as task_bench.figures.run_figures.table writes them: the base, the head and the head's change.
OVER_ALL = "| All |"
COMMIT_LENGTH = 8
# What a bench's name says its tasks are, by how its table's header opens, as task_bench.figures.figures.table writes it. A bench of
# What a bench's name says its tasks are, by how its table's header opens, as task_bench.figures.run_figures.table writes it. A bench of
# bugs has the bare name.
TASKS_NAMED = {f"| {kind.noun.capitalize()} |": f" {tasks}" for tasks, kind in KINDS.items() if kind is not BUG}
@@ -7,13 +7,11 @@ from claude_code.entries import Entry, entry_from, tool_calls, ToolCall
from failure import Failure
from task_bench.runs import HOME, WORK
from reading_cost.measure import reads_of
from task_bench.tasks import Side, SIDES
from claude_code.tokens import Tokens, tokens_of
# The tools that read or search without a shell. A Bash call counts where `reads_of` finds a file it reads.
READING_TOOLS = frozenset({"Glob", "Grep", "Read"})
# A bench's two sides: the commit before the change and the one after it.
Side = typing.Literal["base", "head"]
SIDES: tuple[Side, Side] = ("base", "head")
@dataclasses.dataclass(frozen=True)
@@ -6,9 +6,9 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
from task_bench.figures import figures as bench_figures
from task_bench.figures import run_figures as bench_figures
from failure import Failure
from task_bench.figures.figures import Figures, Result, table
from task_bench.figures.run_figures import Figures, Result, table
from claude_code.entries import json_objects
from claude_code.tokens import Tokens
+3 -3
View File
@@ -196,7 +196,7 @@ import time
import typing
import uuid
from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, SHIPPED, Task, tests_in_copy
from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, SHIPPED, Side, SIDES, Task, tests_in_copy
from task_bench.bugs.planted_mutant import bug_at_sides, Mutant
from claude_code.reply import Claude
from task_bench.bench_folder import clear_left, held
@@ -210,14 +210,14 @@ from claude_code.entries import entry_from, json_objects
from mutate_changes.tool_process import failed, Ran, run_tool
from failure import Failure
from task_bench.features.feature_tasks import feature_tasks, Features, read_features
from task_bench.figures.figures import figures, Result, Side, SIDES, table
from task_bench.figures.run_figures import figures, Result, table
from git_cli import git_repo
from review_rules.review_folder import made_review_folder, REPORTS
from larv_review.history_commands import read_places
from task_bench.features.shipped_features import read_shipped, shipped_tasks, ShippedFeatures
from task_bench.figures.record_figures import recorded_bench
from run_heavy.capped_docker import SHARE_VARIABLE
from task_bench.bugs.rust_test_modules import tells_apart
from task_bench.rust_test_modules import tells_apart
USAGE = "usage: task-bench --image <image> --test <shell text> [--base <ref>] [--head <ref>] [--prefix <shell text>] [--seed <n>] [--bugs <n>] [--runs <n>] [--record-figures], or task-bench --tasks features|data-sources --image <image> --test <shell text> [--base <ref>] [--head <ref>] [--runs <n>] [--record-figures], or task-bench --tasks shipped-features --image <image> --test <shell text> [--base <ref>] [--head <ref>] [--shipped <n>] [--runs <n>] [--record-figures], or task-bench gather"
# A panel of three readers, seated as the README's audience, picked these options on 2026-11-21, each 3 to 0.
+1 -1
View File
@@ -12,7 +12,7 @@ from mutate_changes.tool_process import failed, Ran
from failure import Failure
from mutate_changes.changed_lines import is_test
from task_bench.api_proxy import PORT
from task_bench.bugs.rust_test_modules import with_tests_of
from task_bench.rust_test_modules import with_tests_of
MODEL = "claude-haiku-5-5"
# Where each run's container mounts its copy of the code, and its home folder: the paths in a run's stream start there.
+3 -1
View File
@@ -9,8 +9,10 @@ from task_bench.runs import checked_tree, Containers, ran_tests
from failure import Failure
from git_cli.git_repo import Git
from mutate_changes.tool_process import Ran
from task_bench.figures.figures import Side
# A bench's two sides: the commit before the change and the one after it.
Side = typing.Literal["base", "head"]
SIDES: tuple[Side, Side] = ("base", "head")
# The one commit of a task's tree doesn't name anyone, and neither a hook nor a signing key of the caller's reaches it.
COMMIT = ["-c", "user.name=task-bench", "-c", "user.email=task-bench@localhost", "-c", "commit.gpgsign=false", "-c", "core.hooksPath=/dev/null", "commit", "--quiet", "--message", "Import"]
@@ -4,10 +4,10 @@ import sys
import textwrap
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench.bugs import rust_test_modules
from task_bench.bugs.rust_test_modules import tells_apart
from task_bench import rust_test_modules
from task_bench.rust_test_modules import tells_apart
LIB = textwrap.dedent("""\
pub fn add(a: i32, b: i32) -> i32 {
+1 -1
View File
@@ -21,7 +21,7 @@ from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_at
from task_bench.bugs.plant import drawn
from claude_code.entries import Entry, entry_from
from failure import Failure
from task_bench.figures.figures import Figures, Result
from task_bench.figures.run_figures import Figures, Result
from task_bench.bugs.planted_mutant import Mutant
from mutate_changes.tool_process import Ran
from claude_code.tokens import Tokens
+2 -2
View File
@@ -169,11 +169,11 @@ Touches:
Rust may keep its unit tests out of line: `#[cfg(test)] mod tests;` in `src/lib.rs`, the tests in `src/tests.rs`. `mutate_changes.changed_lines.is_test` tells a test by a folder named `test`, `tests` or `__tests__`, or by a file name such as `test_*.py` or `*_test.go`, so `src/tests.rs` counts as code, and `checked_tree` in `bin/task_bench/runs.py` takes it as Haiku left it. A fix that edits or deletes the failing test there passes. The help's Check paragraph says so. It holds at the base and at the head alike.
Recommended: treat as a test a `.rs` file that a `#[cfg(test)] mod <name>;` declaration in another file of the planted tree names (src/<name>.rs or src/<name>/mod.rs, beside the declaring file), found with the scanner in `bin/task_bench/bugs/rust_test_modules.py`; where the file cannot be found, pass the mutant over. A product-owner / stability finding on item 532's chunk raised this. Changing `is_test` itself would change what `mutate-changes` skips, so keep the change inside task-bench.
Recommended: treat as a test a `.rs` file that a `#[cfg(test)] mod <name>;` declaration in another file of the planted tree names (src/<name>.rs or src/<name>/mod.rs, beside the declaring file), found with the scanner in `bin/task_bench/rust_test_modules.py`; where the file cannot be found, pass the mutant over. A product-owner / stability finding on item 532's chunk raised this. Changing `is_test` itself would change what `mutate-changes` skips, so keep the change inside task-bench.
Touches:
- `bin/task_bench/runs.py`: `of_tests`, `checked_tree` (small)
- `bin/task_bench/bugs/rust_test_modules.py`
- `bin/task_bench/rust_test_modules.py`
- `bin/task_bench/test_task_bench.py`
- `bin/task_bench/main.py`: lines 30-37