Tell an epic chunk's worker how its repo ships a change, and bound the interrupt test's helper shell
CI / tests (pull_request) Failing after 5m1s
CI / tests (pull_request) Failing after 5m1s
This commit is contained in:
@@ -7,6 +7,7 @@ from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
||||
from text_files.markdown_text import listed
|
||||
import pathlib
|
||||
from model_routing.ladder import ProjectRung
|
||||
from project_config.settings import ProjectConfig
|
||||
from loop_claude.cycle import prompts
|
||||
from model_routing.route import Route
|
||||
from agent_cycle.worker_prompts import WorkerPrompts
|
||||
@@ -15,10 +16,18 @@ from agent_cycle.worker_prompts import WorkerPrompts
|
||||
DRIVER = "do-epic"
|
||||
|
||||
|
||||
def task(issue: EpicIssue, epic: str, checkout: str | None, launcher: pathlib.Path, language: str) -> 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, and language the one the epic's Jira text is in."""
|
||||
def shipping(config: ProjectConfig) -> str:
|
||||
"""How a chunk in the repo that config names ships its change. An epic's issue is no item of the repo's plan, so the worker finishes none: its bullet, where the repo has a changelog to put one in, is its own to write (docs/decisions.md → `do-epic: drives one Jira epic …`, "Releases")."""
|
||||
opening = "The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`."
|
||||
if config.epic:
|
||||
return f"{opening} The repo's plan is a Jira epic, whose issues' history is its changelog, so write no changelog bullet."
|
||||
return f"{opening} Where the repo publishes something others consume, ship the change with one bullet for its users under `## Unreleased` in {config.places['changelog']}, added in the branch; otherwise write none."
|
||||
|
||||
|
||||
def task(issue: EpicIssue, epic: str, checkout: str | None, launcher: pathlib.Path, language: str, shipped: str) -> 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 shipped how the chunk ships its change, which `shipping` words for a chunk in a repo and is empty without one."""
|
||||
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}. {findings.instructions(epic, launcher, language)} 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}. {findings.instructions(epic, launcher, language)}{f' {shipped}' if shipped else ''} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
|
||||
|
||||
|
||||
CODE_HEALTH = '~/.claude/CLAUDE.md → "Shared goal"'
|
||||
|
||||
+5
-1
@@ -16,6 +16,7 @@ from loop_claude.project.records import CONSEQUENCE, read_records
|
||||
from agent_cycle.run import Cycle, run_cycle
|
||||
from do_epic.config import DoEpicConfig, load
|
||||
from loop_effects.effects import Effects, say
|
||||
from project_config.main import located as config_located
|
||||
from project_config.settings import Epic
|
||||
from record_store.jira_description import EpicDescription
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
@@ -417,7 +418,10 @@ def chunk_work(key: str, checkout: str | None, language: str, epic: EpicRun) ->
|
||||
issue = issue_read(key, epic)
|
||||
if isinstance(issue, Stop):
|
||||
return issue
|
||||
return chunk_prompt.task(issue, epic.key, checkout, epic.launcher, language), RoutingIssue(issue) if "L" in issue.scores else None
|
||||
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, chunk_prompt.shipping(config) if config else ""), RoutingIssue(issue) if "L" in issue.scores else None
|
||||
issues = epic.store.read()
|
||||
if isinstance(issues, Failure):
|
||||
return Stop(1, issues.reason)
|
||||
|
||||
@@ -424,6 +424,7 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("Ship the import.", prompt)
|
||||
self.assertIn("The repo's goals, which rank after the epic's and after code health, are from", prompt)
|
||||
self.assertIn("Serve the API.", prompt)
|
||||
self.assertIn(f"give `chunk-pr merge` no `--finish`. Where the repo publishes something others consume, ship the change with one bullet for its users under `## Unreleased` in {checkout}/CHANGELOG.md", prompt)
|
||||
self.assertIn("the chunk finished; started ABC-12\n", out)
|
||||
judge_prompt = [what[1] for seam, what in fake.calls if seam == "claude"][0]
|
||||
self.assertIn("The records: the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project:\nFrom the epic ABC-12's description, ## Decisions:\nKeep the v1 endpoints.\n\nFrom AGENTS.md:\nSquash every merge.", judge_prompt)
|
||||
|
||||
@@ -8,6 +8,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from do_epic.scheduler import Chunk, CHUNK_FLAG, chunks, Epic, refusal, RepoRoom, resume, start_chunks, Started, Waits
|
||||
from do_epic import chunk_prompt
|
||||
from project_config import settings
|
||||
from do_epic.backend.protocol import EpicIssue
|
||||
from failure import Failure
|
||||
from do_epic.parked import file_of, park, Parked
|
||||
@@ -299,7 +300,15 @@ class TheFirstPrompt(unittest.TestCase):
|
||||
"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."
|
||||
)
|
||||
self.assertEqual(chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api", pathlib.Path("/b/do-epic"), "Swedish"), 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} Its summary: Do ABC-20")
|
||||
self.assertEqual(chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api", pathlib.Path("/b/do-epic"), "Swedish", "Ship it so."), 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} Ship it so. Its summary: Do ABC-20")
|
||||
|
||||
def test_a_repo_with_a_plan_file_ships_the_chunk_with_a_bullet_in_its_changelog(self) -> None:
|
||||
config = settings.ProjectConfig("api", pathlib.Path("/c/api"), pathlib.Path("/code/api"), {"changelog": pathlib.Path("/code/api/CHANGELOG.md")})
|
||||
self.assertEqual(chunk_prompt.shipping(config), "The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`. Where the repo publishes something others consume, ship the change with one bullet for its users under `## Unreleased` in /code/api/CHANGELOG.md, added in the branch; otherwise write none.")
|
||||
|
||||
def test_a_repo_with_its_plan_in_jira_ships_the_chunk_with_no_bullet(self) -> None:
|
||||
config = settings.ProjectConfig("api", pathlib.Path("/c/api"), pathlib.Path("/code/api"), {"changelog": pathlib.Path("/code/api/CHANGELOG.md")}, epic=settings.Epic("https://acme.atlassian.net", "API-1"))
|
||||
self.assertEqual(chunk_prompt.shipping(config), "The issue is no item of the repo's plan, so give `chunk-pr merge` no `--finish`. The repo's plan is a Jira epic, whose issues' history is its changelog, so write no changelog bullet.")
|
||||
|
||||
def test_an_answer_the_judge_quoted_names_the_epics_description_first(self) -> None:
|
||||
self.assertTrue(chunk_prompt.WORKER.answered("Q", "A", Route(Rung("off-the-ladder")), None, False).startswith("Your question: Q\n\nthe epic's description, "))
|
||||
|
||||
@@ -220,8 +220,9 @@ class ToolProcess(unittest.TestCase):
|
||||
|
||||
def test_an_interrupt_reaches_the_tool_before_the_run_kills_it(self):
|
||||
# A container's CLI, such as docker compose, stops its container on the SIGINT it is passed, and can't once killed.
|
||||
# The loop ends by itself after about 40 seconds: under mutmut, the interrupt doesn't reach this shell, and an endless one hung the run.
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
self.interrupted(folder, "trap 'echo > stopped; exit 130' INT; echo $$ > started; while :; do sleep 0.1; done;")
|
||||
self.interrupted(folder, "trap 'echo > stopped; exit 130' INT; echo $$ > started; n=0; while [ $n -lt 400 ]; do sleep 0.1; n=$((n+1)); done;")
|
||||
self.assertTrue(pathlib.Path(folder, "stopped").is_file())
|
||||
|
||||
def test_an_interrupted_tool_that_ignores_sigint_is_killed_after_the_grace_period(self):
|
||||
|
||||
Reference in New Issue
Block a user