Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -17,7 +17,7 @@ from do_epic.backend.jira_start import Start, started
|
||||
FIELDS = ["summary", "description", "labels", "assignee", "status", "parent", "issuelinks"]
|
||||
# How many child issues one search for sub-tasks names, which keeps its JQL well inside the length Jira takes.
|
||||
PARENTS_PER_SEARCH = 50
|
||||
NO_FINISH = "do-epic's settings name no transition to {to} by: set `{transition}` and `{status}` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""
|
||||
NO_FINISH = "do-epic's settings name no transition to {to} by: set `{transition}` and `{status}` in ~/.config/build-release/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
|
||||
@@ -228,7 +228,7 @@ class Jira(Case):
|
||||
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
|
||||
unconverted = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, lambda markdown: Failure("adf-codec refused it"), Finish("Mark as done", "Done"))
|
||||
for store, reason in (
|
||||
(unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""),
|
||||
(unnamed, "do-epic's settings name no transition to close an epic by: set `jira-finish-transition` and `jira-finish-status` in ~/.config/build-release/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""),
|
||||
(wrong_status, "ABC-12's transition 'Start' leads to the status 'In Progress', not to 'Done', which `jira-finish-status` names"),
|
||||
(unconverted, "cannot convert the summary to a Jira comment: adf-codec refused it"),
|
||||
):
|
||||
@@ -523,7 +523,7 @@ class Jira(Case):
|
||||
unnamed = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf)
|
||||
wrong_status = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Mark as done", "Closed"))
|
||||
no_such = JiraEpic(EPIC, self.env_file, self.jira, to_markdown, to_adf, Finish("Close", "Done"))
|
||||
self.assertEqual(unnamed.finish_issue(key), Failure("do-epic's settings name no transition to finish an issue by: set `jira-finish-transition` and `jira-finish-status` in ~/.claude-projects/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""))
|
||||
self.assertEqual(unnamed.finish_issue(key), Failure("do-epic's settings name no transition to finish an issue by: set `jira-finish-transition` and `jira-finish-status` in ~/.config/build-release/do-epic/config.toml, to the names Jira shows, such as \"Mark as done\" and \"Done\""))
|
||||
self.assertEqual(wrong_status.finish_issue(key), Failure(f"{key}'s transition 'Mark as done' leads to the status 'Done', not to 'Closed', which `jira-finish-status` names"))
|
||||
refused = no_such.finish_issue(key)
|
||||
assert isinstance(refused, Failure)
|
||||
|
||||
+12
-9
@@ -1,4 +1,4 @@
|
||||
"""do-epic's machine-wide settings: `~/.claude-projects/do-epic/config.toml`, and `repo-rule.md` beside it.
|
||||
"""do-epic's machine-wide settings: `~/.config/build-release/do-epic/config.toml`, and `repo-rule.md` beside it.
|
||||
|
||||
One pair per machine, the same for every epic (docs/decisions.md → `do-epic: drives one Jira epic …`). The config is TOML:
|
||||
|
||||
@@ -12,7 +12,7 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
||||
twu-4 = "tenant-web-ui-4"
|
||||
|
||||
- `jira-url` is the Jira site's address: https, a host, and no path.
|
||||
- `env-file` is the file of Jira credentials: a path that starts with / or ~/, outside every folder of `~/.claude-projects` and outside the clone folder, which hold git checkouts. `~/.claude-projects/<key>.env` is fine.
|
||||
- `env-file` is the file of Jira credentials: a path that starts with / or ~/, outside every folder of `~/.config/build-release` and outside the clone folder, which hold git checkouts. `~/.config/build-release/<key>.env` is fine.
|
||||
- `repoless-model` is the model that works an epic item with no repo: a model on the routing ladder, `model_routing/routing-ladder.json`.
|
||||
- `clone-folder` is the folder a missing repo is cloned into: a path that starts with / or ~/. `~/code` where left out.
|
||||
- `language` is the default language of Jira text, by its English name. English where left out.
|
||||
@@ -27,12 +27,14 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
||||
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself. Where several lines name one repo, do-epic writes the label of the first.
|
||||
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
|
||||
import dataclasses
|
||||
from collections.abc import Mapping
|
||||
import pathlib
|
||||
import re
|
||||
import string
|
||||
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 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, SITE, type_fault
|
||||
from loop_state.paths import config_folder
|
||||
from failure import Failure
|
||||
from do_epic.backend.protocol import LABEL, REVIEW_LABEL
|
||||
from do_epic.repo_pick import LabelRepos, of_label, REPO_NAME
|
||||
@@ -64,7 +66,7 @@ LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTION
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class DoEpicConfig:
|
||||
"""folder is `~/.claude-projects/do-epic`; repo_rule is `repo-rule.md`'s text."""
|
||||
"""folder is `~/.config/build-release/do-epic`; repo_rule is `repo-rule.md`'s text."""
|
||||
folder: pathlib.Path
|
||||
jira_url: str
|
||||
env_file: pathlib.Path
|
||||
@@ -151,9 +153,10 @@ def workflow_faults(values: dict[str, object]) -> list[str]:
|
||||
]
|
||||
|
||||
|
||||
def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
|
||||
"""The settings and the repo rule under home; a Failure naming the file it can't read, else each missing or misspelt setting it finds, so that do-epic refuses to start."""
|
||||
folder = home / PROJECTS / DO_EPIC
|
||||
def load(home: pathlib.Path, env: Mapping[str, str], ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfig | Failure:
|
||||
"""The settings and the repo rule in the config folder; a Failure naming the file it can't read, else each missing or misspelt setting it finds, so that do-epic refuses to start."""
|
||||
configs = config_folder(env, home)
|
||||
folder = configs / DO_EPIC
|
||||
values = parsed(folder / CONFIG)
|
||||
if isinstance(values, Failure):
|
||||
return Failure(f"{values.reason}. {LISTED}")
|
||||
@@ -166,7 +169,7 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
||||
rule = (folder / REPO_RULE).read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
rule = Failure(f"cannot read {folder / REPO_RULE}: {failure}")
|
||||
config_folders = [path for path in (home / PROJECTS).iterdir() if path.is_dir()]
|
||||
config_folders = [path for path in configs.iterdir() if path.is_dir()]
|
||||
clone_folder = anywhere(values.get(CLONE_FOLDER, "~/code"), home)
|
||||
env_file = anywhere(values.get(ENV_FILE), home)
|
||||
language = values.get(LANGUAGE, "English")
|
||||
@@ -177,7 +180,7 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
||||
*([f"`{JIRA_URL}` is {url!r}, not a site's https address without a path, such as \"https://acme.atlassian.net\""] if JIRA_URL in values and not (isinstance(url, str) and re.fullmatch(SITE, url)) else []),
|
||||
*([f"`{CLONE_FOLDER}` is {values[CLONE_FOLDER]!r}, not a path that starts with / or ~/"] if clone_folder is None else []),
|
||||
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, not a path that starts with / or ~/"] if ENV_FILE in values and env_file is None else []),
|
||||
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of ~/{PROJECTS} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []),
|
||||
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of {configs} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []),
|
||||
*([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []),
|
||||
*([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []),
|
||||
*finish_faults(values),
|
||||
|
||||
@@ -6,7 +6,7 @@ import tempfile
|
||||
import typing
|
||||
|
||||
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL
|
||||
from loop_state.paths import CONFIG_FOLDER
|
||||
from loop_state.paths import config_folder, without_xdg_folders
|
||||
from project_config.settings import Epic, Finish
|
||||
from do_epic import epic_record, findings, finish
|
||||
from record_store.jira_description import EpicDescription
|
||||
@@ -56,7 +56,9 @@ class Machine:
|
||||
|
||||
|
||||
def machine_made(home: pathlib.Path, sandbox: Sandbox, launcher: pathlib.Path, env: typing.Mapping[str, str]) -> Machine | Failure:
|
||||
folder = home / CONFIG_FOLDER / "do-epic"
|
||||
# So that do-epic keeps its config and state under home.
|
||||
env = without_xdg_folders(env)
|
||||
folder = config_folder(env, home) / "do-epic"
|
||||
folder.mkdir(parents=True)
|
||||
ladder = read_ladder(SHIPPED)
|
||||
if isinstance(ladder, Failure):
|
||||
|
||||
@@ -254,7 +254,7 @@ class MachineTest(unittest.TestCase):
|
||||
machine = scenario.machine_made(home, self.sandbox, pathlib.Path("do-epic"), {"A": "b"})
|
||||
assert not isinstance(machine, Failure), machine
|
||||
self.assertEqual((machine.home, machine.launcher, machine.env), (home, pathlib.Path("do-epic"), {"A": "b"}))
|
||||
config = load(home)
|
||||
config = load(home, {})
|
||||
assert not isinstance(config, Failure), config
|
||||
self.assertEqual((config.jira_url, config.env_file, config.repo_rule), ("https://acme.atlassian.net", self.env_file, scenario.RULE))
|
||||
self.assertEqual((config.finish.transition, config.finish.status) if config.finish else None, ("Done", "Done"))
|
||||
|
||||
@@ -57,7 +57,7 @@ def chunks_started(epic: EpicRun, issues: list[EpicIssue], own: str | None, told
|
||||
|
||||
def planned_epic(epic: EpicRun) -> planning.Planned:
|
||||
"""The epic as planning reads and writes it."""
|
||||
return planning.Planned(epic.key, epic.config, epic.store, epic.record, epic.paths.home, epic.effects)
|
||||
return planning.Planned(epic.key, epic.config, epic.store, epic.record, epic.paths.home, epic.env, epic.effects)
|
||||
|
||||
|
||||
def scheduled_epic(epic: EpicRun, order: tuple[str, ...]) -> scheduler.Epic | Failure:
|
||||
@@ -69,7 +69,7 @@ def scheduled_epic(epic: EpicRun, order: tuple[str, ...]) -> scheduler.Epic | Fa
|
||||
seen: list[pathlib.Path] = []
|
||||
|
||||
def located(name: str) -> tuple[pathlib.Path, int] | Failure:
|
||||
found = locate(name, [checkout for checkout in seen], epic.config, epic.paths.home, epic.effects.git)
|
||||
found = locate(name, [checkout for checkout in seen], epic.config, epic.paths.home, epic.env, epic.effects.git)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
seen.append(found.checkout)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""A human's task that holds up other issues of an epic (docs/decisions.md → `do-epic: drives one Jira epic …`, "Human tasks").
|
||||
|
||||
A window that starts again, as after a reboot, DMs again, and so does one whose DM failed, on its next read."""
|
||||
from collections.abc import Mapping
|
||||
import pathlib
|
||||
|
||||
from project_config.settings import by_name, ProjectConfig
|
||||
@@ -27,17 +28,17 @@ def message(task: EpicIssue, epic: str, held: list[str]) -> str:
|
||||
return f"do-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. do-epic goes on once you close {task.key} in Jira."
|
||||
|
||||
|
||||
def notifier_checkout(issues: list[EpicIssue], team: LabelRepos, home: pathlib.Path) -> str | None:
|
||||
def notifier_checkout(issues: list[EpicIssue], team: LabelRepos, home: pathlib.Path, env: Mapping[str, str]) -> str | None:
|
||||
"""The checkout of the first of issues whose repo has a git checkout and a project config that names a notifier: where the DM finds that notifier, since the window runs in no checkout. None where there is none."""
|
||||
for issue in issues:
|
||||
pick = recorded(issue, team)
|
||||
found = by_name(pick.name, home) if isinstance(pick, Repo) else None
|
||||
found = by_name(pick.name, home, env) if isinstance(pick, Repo) else None
|
||||
if isinstance(found, ProjectConfig) and found.notifier and (found.top / ".git").exists():
|
||||
return str(found.top)
|
||||
return None
|
||||
|
||||
|
||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, unblocking: tuple[str, ...], window: tmux.Window, poll: int, home: pathlib.Path, effects: Effects) -> None:
|
||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, unblocking: tuple[str, ...], window: tmux.Window, poll: int, home: pathlib.Path, env: Mapping[str, str], effects: Effects) -> None:
|
||||
"""Waits in window for the human to close the human's task `task` of the epic called epic, and returns once it no longer holds up any issue. A read of the epic that fails is said once and tried again."""
|
||||
tmux.park(window, AWAITS, effects.tmux)
|
||||
told, said = False, None
|
||||
@@ -53,7 +54,7 @@ def awaited(task: EpicIssue, epic: str, store: EpicStore, team: LabelRepos, unbl
|
||||
text = message(task, epic, held)
|
||||
say(text, effects, stdout=True)
|
||||
# The issues it holds up come first; any other issue of the epic may do where they have no repo with a notifier.
|
||||
where = notifier_checkout(sorted(issues, key=lambda issue: issue.key not in held), team, home)
|
||||
where = notifier_checkout(sorted(issues, key=lambda issue: issue.key not in held), team, home, env)
|
||||
if where is None:
|
||||
say("no DM went out: no issue of the epic has a repo whose project config names a notifier and whose checkout exists", effects, stdout=True)
|
||||
told = where is None or tell(text, effects, where)
|
||||
|
||||
+18
-18
@@ -14,7 +14,6 @@ from chunk_driver.claims import CHUNK_FLAG
|
||||
from do_epic import chunk_prompt, dry_run, findings, finish, human_tasks, parent_moves, planning, scheduler, split, status
|
||||
from chunk_driver.chunk_run import ChunkRun, closed_cycle
|
||||
from do_epic.epic_run import chunks_started, EpicRun, planned_epic, POLL_SECONDS, real
|
||||
from loop_state.paths import CLAUDE_HOME, Paths
|
||||
from do_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo
|
||||
from project_config.main import located as config_located
|
||||
from chunk_driver.project.records import CONSEQUENCE, read_records
|
||||
@@ -36,6 +35,7 @@ from do_epic.repos import locate
|
||||
from chunk_driver.this_loop import Loop
|
||||
from do_epic.parking import Merged, parked_through
|
||||
from chunk_driver.project.model_choice import Models, overridden
|
||||
from loop_state.paths import Paths
|
||||
from chunk_driver.project.premises import read_premises
|
||||
from git_cli.git_repo import record_chunk_base
|
||||
from forge.commands import Run, runner
|
||||
@@ -73,9 +73,9 @@ request is ready, with nothing else to wait on, the window's name says `awaits y
|
||||
A repo that is missing isn't cloned. Planning then stops there, so its writes are only those made before it, and the issues of that repo wait, and a chunk of another repo may start in the place a real run gives them; a real run would clone it and go on.
|
||||
{findings.HELP}
|
||||
{finish.HELP}
|
||||
The Jira site and its credentials are set in ~/.claude-projects/do-epic/config.toml."""
|
||||
# Under the home folder, where a chunk's cycles are archived, a folder per epic. It is not build-release's archive, since that archive's readers, such as judge-replay and the routing figures, read build-release's prompts.
|
||||
ARCHIVE = f"{CLAUDE_HOME}/do-epic-transcripts"
|
||||
The Jira site and its credentials are set in ~/.config/build-release/do-epic/config.toml."""
|
||||
# In the state folder, where a chunk's cycles are archived, a folder per epic. It is not build-release's archive, since that archive's readers, such as judge-replay and the routing figures, read build-release's prompts.
|
||||
ARCHIVE = "do-epic-transcripts"
|
||||
# The flag that prints what each open issue does.
|
||||
STATUS_FLAG = "--status"
|
||||
# The flag that prints what planning and the scheduler would do, without doing it.
|
||||
@@ -119,11 +119,11 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
|
||||
if (len(words) != 1 and not writes and not closes) or not ISSUE_KEY.fullmatch(words[0]) or (chunk is not None and not ISSUE_KEY.fullmatch(chunk)):
|
||||
return Stop(0 if words in (["-h"], ["--help"]) else 1, HELP)
|
||||
if writes or closes:
|
||||
return epic_written(words[0], writes, paths, backend, stdin)
|
||||
return epic_written(words[0], writes, paths, env, backend, stdin)
|
||||
# Before anything starts: a clone, a claude session or a tmux window.
|
||||
if not dry_run_asked and (reason := tmux.unusable(effects.tmux, chunk_prompt.DRIVER)):
|
||||
return Stop(1, reason)
|
||||
config = load(paths.home)
|
||||
config = load(paths.home, env)
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
store, record = backend(config, words[0])
|
||||
@@ -142,17 +142,17 @@ def status_printed(epic: EpicRun) -> Stop:
|
||||
reading = dataclasses.replace(epic, effects=dataclasses.replace(epic.effects, git=dry_run.without_clones(epic.effects.git)))
|
||||
order = issues if isinstance(issues, Failure) else planning.start_order(planned_epic(reading), issues)
|
||||
# Where the issues cannot be put in order of score, they start in the backlog's order, as a run says.
|
||||
lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.config.label_repos, epic.config.unblocking, epic.effects.tmux, () if isinstance(order, Failure) else tuple(order))
|
||||
lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.state_folder, issues, epic.config.label_repos, epic.config.unblocking, epic.effects.tmux, () if isinstance(order, Failure) else tuple(order))
|
||||
return Stop(1, lines.reason) if isinstance(lines, Failure) else Stop(0, "\n".join(lines) or f"the epic {epic.key} has no open issue")
|
||||
|
||||
|
||||
def epic_written(key: str, writes: findings.Write | None, paths: Paths, backend: Backend, stdin: typing.TextIO) -> Stop:
|
||||
def epic_written(key: str, writes: findings.Write | None, paths: Paths, env: typing.Mapping[str, str], backend: Backend, stdin: typing.TextIO) -> Stop:
|
||||
"""Files a finding in the epic or records a decision in its description, as writes says; closes the epic where writes is None. It needs no tmux, so a chunk's worker may run it anywhere."""
|
||||
config = load(paths.home)
|
||||
config = load(paths.home, env)
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
store, record = backend(config, key)
|
||||
done = findings.written(key, writes, store, config.label_repos, record, stdin, paths.home / scheduler.STATE / key) if writes else finish.closed(key, store, config.label_repos, stdin, config.pull_merged_status)
|
||||
done = findings.written(key, writes, store, config.label_repos, record, stdin, scheduler.epic_folder(paths.state_folder, key)) if writes else finish.closed(key, store, config.label_repos, stdin, config.pull_merged_status)
|
||||
return Stop(1, done.reason) if isinstance(done, Failure) else Stop(0, done)
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
||||
if isinstance(issue, Stop):
|
||||
return issue
|
||||
if issue and isinstance(recorded(issue, epic.config.label_repos), HumanTask):
|
||||
human_tasks.awaited(issue, epic.key, epic.store, epic.config.label_repos, epic.config.unblocking, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.effects)
|
||||
human_tasks.awaited(issue, epic.key, epic.store, epic.config.label_repos, epic.config.unblocking, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.env, epic.effects)
|
||||
return handed_on(key, epic, Landed.WITH_A_HUMAN)
|
||||
place = chunk_root(key, issue, epic)
|
||||
if isinstance(place, Stop):
|
||||
@@ -289,7 +289,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
||||
|
||||
def epic_based(key: str, root: str, epic: EpicRun) -> str | None | Stop:
|
||||
"""Readies the epic's working branch for the chunk called key, whose repo is checked out at root: the branch, or None where the repo's config sets no `epic-branch`. It makes the branch on origin, or brings it level with the default branch, and records it as the base of the chunk's branch. A default branch that doesn't merge into it cleanly stops the loop, since a person resolves the conflict (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`)."""
|
||||
config = config_located(root, epic.paths.home)
|
||||
config = config_located(root, epic.paths.home, epic.env)
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
if config.epic_branch is None:
|
||||
@@ -328,10 +328,10 @@ def chunk_root(key: str, issue: EpicIssue | None, epic: EpicRun) -> tuple[str, s
|
||||
if isinstance(pick, Failure):
|
||||
return Stop(1, pick.reason)
|
||||
if isinstance(pick, ClaudeWork):
|
||||
return str(epic.paths.home / scheduler.STATE / epic.key), None
|
||||
return str(scheduler.epic_folder(epic.paths.state_folder, epic.key)), None
|
||||
if not isinstance(pick, Repo):
|
||||
return Stop(1, f"{key} is no chunk: no label names its repo")
|
||||
found = locate(pick.name, [], epic.config, epic.paths.home, epic.effects.git)
|
||||
found = locate(pick.name, [], epic.config, epic.paths.home, epic.env, epic.effects.git)
|
||||
return Stop(1, found.reason) if isinstance(found, Failure) else (str(real(found.checkout)), pick.name)
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ def next_cycle(run: ChunkRun, loop: Loop, in_repo: bool, epic: EpicRun, news: st
|
||||
routing = project_routing(loop, chunk_prompt.DRIVER) if in_repo else routing_on(repoless_models(epic), SHIPPED)
|
||||
if isinstance(routing, Stop):
|
||||
return routing
|
||||
archive_folder = epic.paths.home / ARCHIVE / epic.key
|
||||
archive_folder = epic.paths.state_folder / ARCHIVE / epic.key
|
||||
route = announced_route(run.cycle_number, run.route, routing, archive_folder, lambda: issue, loop)
|
||||
prompts = chunk_prompt.unparked(news) if news else chunk_prompt.restating(task) if loop.window.name == epic.key else chunk_prompt.WORKER
|
||||
return cycle_of(loop, routing, route, archive_folder, task=task, facts="", premises=premises, records=records, unfinished_evidence=run.unfinished_evidence, prompts=prompts, taken_in=lambda entries: TakenIn())
|
||||
@@ -524,7 +524,7 @@ def chunk_work(key: str, checkout: str | None, language: str, epic: EpicRun) ->
|
||||
issue = issue_read(key, epic)
|
||||
if isinstance(issue, Stop):
|
||||
return issue
|
||||
config = config_located(checkout, epic.paths.home) if checkout else None
|
||||
config = config_located(checkout, epic.paths.home, epic.env) if checkout else None
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
return chunk_prompt.task(issue, epic.key, epic.config.label_repos, checkout, epic.launcher, language, config), RoutingIssue(issue) if "L" in issue.scores else None
|
||||
@@ -550,7 +550,7 @@ def records_read(root: str | None, epic: EpicRun) -> str | Failure:
|
||||
if isinstance(body, Failure):
|
||||
return Failure(f"the epic {epic.key}'s description: {body.reason} - {CONSEQUENCE}.")
|
||||
sections.append((f"the epic {epic.key}'s description, ## {name}", body))
|
||||
return read_records(root, epic.paths.home, epic.paths.claude_dir, tuple(sections))
|
||||
return read_records(root, epic.paths.home, epic.env, epic.paths.claude_dir, tuple(sections))
|
||||
|
||||
|
||||
def premises_read(root: str | None, epic: EpicRun) -> str | Failure:
|
||||
@@ -563,7 +563,7 @@ def premises_read(root: str | None, epic: EpicRun) -> str | Failure:
|
||||
if not body.strip():
|
||||
return Failure(f"the epic {epic.key}'s description has no text under a `## {name}` heading - no premises.")
|
||||
bodies.append(body)
|
||||
theirs = read_premises(root, epic.paths.home) if root else ""
|
||||
theirs = read_premises(root, epic.paths.home, epic.env) if root else ""
|
||||
if isinstance(theirs, Failure):
|
||||
return theirs
|
||||
return f"the epic {epic.key}'s description:\n## Goals\n{bodies[0]}\n\n## Audience\n{bodies[1]}" + (f"\n\nThe repo's goals, which rank after the epic's and after code health, are from {theirs}" if theirs else "")
|
||||
|
||||
@@ -30,11 +30,11 @@ def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finis
|
||||
|
||||
A chunk parks in three steps: its file is written, its window is shown as parked, and the epic's next chunks start in the slot it frees. It resumes in the reverse order: `scheduler.resume` gives it a running slot, then its file is removed. So a window that ends in between finds the chunk parked when it starts again.
|
||||
"""
|
||||
key, folder = loop.window.name, epic.paths.home / scheduler.STATE / epic.key
|
||||
key, folder = loop.window.name, scheduler.epic_folder(epic.paths.state_folder, epic.key)
|
||||
recorded_as = parked.parked_chunks(folder)
|
||||
if isinstance(recorded_as, Failure):
|
||||
return Stop(1, recorded_as.reason)
|
||||
config = config_located(loop.root, epic.paths.home)
|
||||
config = config_located(loop.root, epic.paths.home, epic.env)
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
# A pull request into an epic's working branch merges without a person, whatever `merge` says. The base recorded says so, not the config: the gate fails where the forge merges the pull request elsewhere.
|
||||
|
||||
@@ -6,12 +6,14 @@ Planning runs only in the `do-epic <EPIC-KEY>` the human starts. A chunk that fi
|
||||
|
||||
Planning holds no lock: one `do-epic <EPIC-KEY>` at a time is assumed. A second one started meanwhile finds the sub-tasks the first filed, since `split` reads them before it files, unless Jira's search lags."""
|
||||
import dataclasses
|
||||
from collections.abc import Mapping
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
from loop_state.paths import CLAUDE_HOME
|
||||
from loop_state.paths import CLAUDE_HOME, state_folder
|
||||
from do_epic.config import DoEpicConfig
|
||||
from loop_effects.effects import Effects, say
|
||||
from do_epic.scheduler import epic_folder, unblocks
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore, no_scores
|
||||
from do_epic.epic_record import EpicRecord
|
||||
from failure import Failure
|
||||
@@ -22,7 +24,6 @@ from claude_code.reply import Limited
|
||||
from plan_store.jira_epic import number
|
||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||
from model_routing.ladder import Rung
|
||||
from do_epic.scheduler import STATE, unblocks
|
||||
from plan_store.scoring import weighing_texts
|
||||
|
||||
# The epic's formula, stated under its `## Scoring` as a todo.md states its own.
|
||||
@@ -41,6 +42,7 @@ class Planned:
|
||||
store: EpicStore
|
||||
record: EpicRecord
|
||||
home: pathlib.Path
|
||||
env: Mapping[str, str]
|
||||
effects: Effects
|
||||
|
||||
|
||||
@@ -92,7 +94,7 @@ def placed(epic: Planned, issues: list[EpicIssue], unplaced: list[EpicIssue], ad
|
||||
if failed := next((each for each in (rung, language, places) if isinstance(each, Failure)), None):
|
||||
return failed
|
||||
assert isinstance(rung, Rung) and not isinstance(language, Failure) and isinstance(places, dict)
|
||||
folder = epic.home / STATE / epic.key
|
||||
folder = epic_folder(state_folder(epic.env, epic.home), epic.key)
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
checkouts = tuple(str(place.checkout) for place in places.values())
|
||||
for issue in unplaced:
|
||||
@@ -151,7 +153,7 @@ def located(epic: Planned, picks: list[repo_pick.Repo]) -> dict[str, repos.Locat
|
||||
"""Each picked repo's checkout and project config, by the repo's name."""
|
||||
places: dict[str, repos.Located] = {}
|
||||
for name in sorted({pick.name for pick in picks}):
|
||||
place = repos.locate(name, [each.checkout for each in places.values()], epic.config, epic.home, epic.effects.git)
|
||||
place = repos.locate(name, [each.checkout for each in places.values()], epic.config, epic.home, epic.env, epic.effects.git)
|
||||
if isinstance(place, Failure):
|
||||
return place
|
||||
places[name] = place
|
||||
@@ -210,7 +212,7 @@ def scored(epic: Planned, issues: list[EpicIssue]) -> tuple[list[EpicIssue], Fai
|
||||
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)
|
||||
folder = epic.home / STATE / epic.key
|
||||
folder = epic_folder(state_folder(epic.env, epic.home), epic.key)
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
for issue in bare:
|
||||
say(f"scoring {issue.key}", epic.effects, stdout=True)
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
A missing checkout is cloned from the host and owner of the epic's other repos (docs/decisions.md → `do-epic: drives one Jira epic …`). Where that is unclear, the answer is an Unsure."""
|
||||
import dataclasses
|
||||
from collections.abc import Mapping
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from project_config.settings import by_name, CONFIG, ProjectConfig, PROJECTS
|
||||
from project_config.settings import by_name, CONFIG, ProjectConfig
|
||||
from loop_state.paths import config_folder
|
||||
from do_epic.config import DoEpicConfig
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import Git
|
||||
@@ -34,14 +36,14 @@ class Unsure(Failure):
|
||||
"""reason is a question for the human."""
|
||||
|
||||
|
||||
def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pathlib.Path, git: Git) -> Located | Failure:
|
||||
def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pathlib.Path, env: Mapping[str, str], git: Git) -> Located | Failure:
|
||||
"""The checkout and project config of the repo called name; others are the checkouts of the epic's other repos.
|
||||
|
||||
A project config names the repo's checkout, and it is cloned where missing. Where no config names the repo, it is cloned into the clone folder, if it isn't there, and the human is asked to write the config, since the repo's plan, goals and records are theirs to place.
|
||||
A name that is no repo's name, or a config that can't be read, is a plain Failure. Any other fault is an Unsure."""
|
||||
if not re.fullmatch(REPO_NAME, name):
|
||||
return Failure(f"{name!r} is not a repo's name: one folder name that starts with a letter, digit or underscore")
|
||||
found = by_name(name, home)
|
||||
found = by_name(name, home, env)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
checkout = found.top if found else config.clone_folder / name
|
||||
@@ -49,7 +51,7 @@ def locate(name: str, others: list[pathlib.Path], config: DoEpicConfig, home: pa
|
||||
if isinstance(cloned, Failure):
|
||||
return cloned
|
||||
if found is None:
|
||||
return Unsure(f"{checkout} {'was cloned' if cloned else 'holds the repo'}, but no project config names it. Write {home / PROJECTS}/<key>/{CONFIG} with `checkout = \"{checkout}\"`, as `project-config --help` shows, and run do-epic again.")
|
||||
return Unsure(f"{checkout} {'was cloned' if cloned else 'holds the repo'}, but no project config names it. Write {config_folder(env, home)}/<key>/{CONFIG} with `checkout = \"{checkout}\"`, as `project-config --help` shows, and run do-epic again.")
|
||||
return Located(checkout, found)
|
||||
|
||||
|
||||
|
||||
@@ -15,11 +15,16 @@ from text_files.markdown_text import listed
|
||||
from project_config.settings import PARALLEL_CHUNKS
|
||||
from do_epic.parked import parked_chunks
|
||||
from chunk_pr.approval import PARKS
|
||||
from loop_state.paths import STATE_FOLDER
|
||||
from loop_state.paths import state_folder
|
||||
from agent_cycle import tmux
|
||||
|
||||
# Under the home folder, a folder per epic key holds the epic's lock file, which `claims.LOCK` names. A chunk without a repo works there.
|
||||
STATE = f"{STATE_FOLDER}/do-epic"
|
||||
# In the state folder, where a folder per epic key holds the epic's lock file, which `claims.LOCK` names. A chunk without a repo works there.
|
||||
STATE = "do-epic"
|
||||
|
||||
|
||||
def epic_folder(state: pathlib.Path, key: str) -> pathlib.Path:
|
||||
"""The folder of the epic called key, in the state folder state."""
|
||||
return state / STATE / key
|
||||
# Why a human's task with a live window waits, as the epic's status says.
|
||||
HUMAN_WAIT = "it is a human's task; do-epic polls Jira until you close it"
|
||||
|
||||
@@ -82,7 +87,7 @@ class Epic:
|
||||
|
||||
@property
|
||||
def folder(self) -> pathlib.Path:
|
||||
return self.home / STATE / self.key
|
||||
return epic_folder(state_folder(self.env, self.home), self.key)
|
||||
|
||||
|
||||
def unblocks(status: str, unblocking: tuple[str, ...]) -> bool:
|
||||
@@ -228,7 +233,7 @@ def start_chunk(epic: Epic, chunk: Chunk, own: str | None, windows: list[tmux.Li
|
||||
if isinstance(located, Failure):
|
||||
return Waits(chunk.issue, located.reason)
|
||||
checkout, limit = located
|
||||
with starting(project_lock(str(checkout), epic.home)) as unlocked:
|
||||
with starting(project_lock(str(checkout), epic.home, epic.env)) as unlocked:
|
||||
if unlocked:
|
||||
return unlocked
|
||||
if reason := refusal(chunk.repo, room_in(str(checkout), limit, (session, own), epic.home, run)):
|
||||
@@ -254,7 +259,7 @@ def resume(epic: Epic, repo: str, window: tmux.Window, run: tmux.Tmux) -> str |
|
||||
if isinstance(located, Failure):
|
||||
return located.reason
|
||||
checkout, limit = located
|
||||
with starting(project_lock(str(checkout), epic.home)) as unlocked:
|
||||
with starting(project_lock(str(checkout), epic.home, epic.env)) as unlocked:
|
||||
if unlocked:
|
||||
return unlocked.reason
|
||||
if reason := refusal(repo, room_in(str(checkout), limit, (window.session, window.name), epic.home, run)):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import datetime
|
||||
import pathlib
|
||||
|
||||
from do_epic.scheduler import chunks, HUMAN_WAIT, STATE
|
||||
from do_epic.scheduler import chunks, epic_folder, HUMAN_WAIT
|
||||
from do_epic.backend.protocol import EpicIssue
|
||||
from failure import Failure
|
||||
from do_epic.parked import file_of, Parked, parked_chunks, SLOT
|
||||
@@ -20,10 +20,10 @@ def since(folder: pathlib.Path, chunk: Parked) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...], run: tmux.Tmux, order: tuple[str, ...]) -> list[str] | Failure:
|
||||
def lines(key: str, state: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...], run: tmux.Tmux, order: tuple[str, ...]) -> list[str] | Failure:
|
||||
"""A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. order holds the keys of the issues that start by score, as planning.start_order puts them; a chunk it leaves out says that it starts after them. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back."""
|
||||
found, waits = chunks(issues, team, unblocking)
|
||||
folder = home / STATE / key
|
||||
folder = epic_folder(state, key)
|
||||
parked = parked_chunks(folder)
|
||||
if isinstance(parked, Failure):
|
||||
return parked
|
||||
|
||||
+27
-27
@@ -21,7 +21,7 @@ class ConfigTest(unittest.TestCase):
|
||||
made = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(made.cleanup)
|
||||
self.home = pathlib.Path(made.name).resolve()
|
||||
self.folder = self.home / ".claude-projects" / "do-epic"
|
||||
self.folder = self.home / ".config/build-release" / "do-epic"
|
||||
self.folder.mkdir(parents=True)
|
||||
|
||||
def write(self, settings: str | None = SETTINGS, rule: str | None = "A label that equals a repo's name names that repo.\n") -> None:
|
||||
@@ -31,17 +31,17 @@ class ConfigTest(unittest.TestCase):
|
||||
(self.folder / "repo-rule.md").write_text(rule, encoding="utf-8")
|
||||
|
||||
def failure(self) -> str:
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, Failure), found
|
||||
return found.reason
|
||||
|
||||
def test_reads_the_settings_and_the_rule_and_defaults_the_clone_folder_and_language(self) -> None:
|
||||
self.write()
|
||||
self.assertEqual(load(self.home), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
|
||||
self.assertEqual(load(self.home, {}), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
|
||||
|
||||
def test_reads_the_teams_labels_for_its_repos(self) -> None:
|
||||
self.write(SETTINGS + '[label-repos]\ntwu-4 = "tenant-web-ui-4"\n"core-4" = "core-4"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(dict(found.label_repos), {"twu-4": "tenant-web-ui-4", "core-4": "core-4"})
|
||||
|
||||
@@ -63,13 +63,13 @@ class ConfigTest(unittest.TestCase):
|
||||
|
||||
def test_reads_a_template_for_a_sub_tasks_summary(self) -> None:
|
||||
self.write(SETTINGS + 'sub-task-summary = "{label}: {Summary}"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.sub_task_summary, "{label}: {Summary}")
|
||||
|
||||
def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None:
|
||||
self.write()
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertIsNone(found.sub_task_summary)
|
||||
|
||||
@@ -92,7 +92,7 @@ class ConfigTest(unittest.TestCase):
|
||||
for template in ("{Summary}", "{Summary}{{", "{Summary} for {label} in Jira"):
|
||||
with self.subTest(template=template):
|
||||
self.write(SETTINGS + f'sub-task-summary = "{template}"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.sub_task_summary, template)
|
||||
|
||||
@@ -102,13 +102,13 @@ class ConfigTest(unittest.TestCase):
|
||||
|
||||
def test_reads_a_clone_folder_and_language_the_config_sets(self) -> None:
|
||||
self.write(SETTINGS + 'clone-folder = "/srv/repos"\nlanguage = "Brazilian Portuguese"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.clone_folder, found.language), (pathlib.Path("/srv/repos"), "Brazilian Portuguese"))
|
||||
|
||||
def test_reads_how_a_finished_epic_closes_and_wants_both_names_or_neither(self) -> None:
|
||||
self.write(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.finish, Finish("Mark as done", "Done"))
|
||||
self.write(SETTINGS + 'jira-finish-status = " "\n')
|
||||
@@ -116,11 +116,11 @@ class ConfigTest(unittest.TestCase):
|
||||
|
||||
def test_reads_how_a_starting_issue_moves_and_which_boards_sprint_it_joins(self) -> None:
|
||||
self.write(SETTINGS)
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.start, Start(None, None))
|
||||
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 1\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.start, Start("In Progress", 1))
|
||||
for board, read in (('"6"', "'6'"), ("0", "0"), ("true", "True"), ("6.0", "6.0")):
|
||||
@@ -130,11 +130,11 @@ class ConfigTest(unittest.TestCase):
|
||||
|
||||
def test_reads_the_transition_that_moves_a_parent_whose_sub_tasks_have_all_landed(self) -> None:
|
||||
self.write(SETTINGS)
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertIsNone(found.sub_tasks_landed_transition)
|
||||
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = "Release Ready"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.sub_tasks_landed_transition, "Release Ready")
|
||||
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = 5\n')
|
||||
@@ -142,23 +142,23 @@ class ConfigTest(unittest.TestCase):
|
||||
|
||||
def test_reads_the_unblocking_statuses_and_that_the_teams_automation_moves_issues(self) -> None:
|
||||
self.write(SETTINGS)
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.unblocking, found.automation_moves), ((), False))
|
||||
self.write(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Done"]\njira-automation-moves-issues = true\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.unblocking, found.automation_moves), (("Release Ready", "Done"), True))
|
||||
|
||||
def test_the_issue_types_of_a_finding_and_a_release_review_are_task_where_left_out(self) -> None:
|
||||
self.write()
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.finding_type, found.review_type), ("Task", "Task"))
|
||||
|
||||
def test_reads_the_issue_types_of_a_finding_and_a_release_review(self) -> None:
|
||||
self.write(SETTINGS + 'jira-finding-type = "Feature"\njira-review-type = "Chore"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.finding_type, found.review_type), ("Feature", "Chore"))
|
||||
|
||||
@@ -171,11 +171,11 @@ class ConfigTest(unittest.TestCase):
|
||||
|
||||
def test_reads_the_statuses_of_an_issue_whose_pull_request_into_an_epic_branch_opened_and_merged(self) -> None:
|
||||
self.write(SETTINGS)
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.pull_open_status, found.pull_merged_status), (None, None))
|
||||
self.write(SETTINGS + 'jira-unblocking-statuses = ["release ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual((found.pull_open_status, found.pull_merged_status), ("Code Review", "Release Ready"))
|
||||
|
||||
@@ -243,8 +243,8 @@ class ConfigTest(unittest.TestCase):
|
||||
self.assertIn(f"`{name}` is", self.failure())
|
||||
|
||||
def test_keeps_the_credentials_outside_every_config_folder_and_the_clone_folder(self) -> None:
|
||||
(self.home / ".claude-projects" / "acme").mkdir()
|
||||
for env_file in ("~/.claude-projects/do-epic/jira.env", "~/.claude-projects/acme/jira.env", "~/code/acme/jira.env"):
|
||||
(self.home / ".config/build-release" / "acme").mkdir()
|
||||
for env_file in ("~/.config/build-release/do-epic/jira.env", "~/.config/build-release/acme/jira.env", "~/code/acme/jira.env"):
|
||||
with self.subTest(env_file):
|
||||
self.write(SETTINGS.replace("~/jira.env", env_file))
|
||||
self.assertIn("`env-file` is", self.failure())
|
||||
@@ -254,14 +254,14 @@ class ConfigTest(unittest.TestCase):
|
||||
self.assertIn("`env-file` is", self.failure())
|
||||
|
||||
def test_accepts_credentials_beside_the_config_folders(self) -> None:
|
||||
self.write(SETTINGS.replace("~/jira.env", "~/.claude-projects/do-epic.env"))
|
||||
found = load(self.home)
|
||||
self.write(SETTINGS.replace("~/jira.env", "~/.config/build-release/do-epic.env"))
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.env_file, self.home / ".claude-projects" / "do-epic.env")
|
||||
self.assertEqual(found.env_file, self.home / ".config/build-release" / "do-epic.env")
|
||||
|
||||
def test_refuses_while_the_routing_ladder_cannot_be_read(self) -> None:
|
||||
self.write()
|
||||
found = load(self.home, self.home / "no-ladder.json")
|
||||
found = load(self.home, {}, self.home / "no-ladder.json")
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertIn("no-ladder.json", found.reason)
|
||||
|
||||
@@ -276,12 +276,12 @@ class ConfigTest(unittest.TestCase):
|
||||
ladder = self.home / "ladder.json"
|
||||
ladder.write_text('[{"model": "claude-sonnet-5-5", "effort": "low"}, {"model": "claude-opus-5-5", "effort": "low"}]', encoding="utf-8")
|
||||
self.write(SETTINGS.replace("claude-opus-5-5", "claude-haiku-5-5"))
|
||||
found = load(self.home, ladder)
|
||||
found = load(self.home, {}, ladder)
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertIn("not a model on the routing ladder: claude-opus-5-5, claude-sonnet-5-5.", found.reason)
|
||||
|
||||
def test_reads_the_rule_and_the_settings_as_utf8(self) -> None:
|
||||
self.write(SETTINGS + 'language = "Svenska"\n', rule="Etiketten är repots namn.\n")
|
||||
found = load(self.home)
|
||||
found = load(self.home, {})
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.repo_rule, "Etiketten är repots namn.\n")
|
||||
|
||||
@@ -53,7 +53,7 @@ class FindingsTest(DoEpicTest):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
self.store = MemoryEpic("ABC-12", list(self.issues))
|
||||
self.written = WrittenDescription([DESCRIPTION], self.home / ".local/state/do-epic/ABC-12/decisions.lock")
|
||||
self.written = WrittenDescription([DESCRIPTION], self.home / ".local/state/build-release/do-epic/ABC-12/decisions.lock")
|
||||
self.keys: list[str] = []
|
||||
|
||||
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
|
||||
@@ -63,7 +63,7 @@ class FindingsTest(DoEpicTest):
|
||||
def run_with(self, argv: list[str], stdin: str = "") -> tuple[int, str, str, FakeEffects]:
|
||||
out, err, fake = io.StringIO(), io.StringIO(), FakeEffects()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
code = main.main(argv, {}, paths_from(self.home), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, io.StringIO(stdin))
|
||||
code = main.main(argv, {}, paths_from(self.home, {}), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, io.StringIO(stdin))
|
||||
# Without the time each line of do-epic opens with.
|
||||
return code, out.getvalue().replace("<1790000000> ", ""), err.getvalue().replace("<1790000000> ", ""), fake
|
||||
|
||||
@@ -85,7 +85,7 @@ class FilingAFinding(FindingsTest):
|
||||
self.assertEqual((code, out, filed.labels, filed.detail), (0, f"Filed {filed.key} in the epic ABC-12.\n", (label,), ""))
|
||||
|
||||
def test_a_label_of_the_teams_says_where_the_issue_is_worked(self) -> None:
|
||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\n')
|
||||
code, out, _, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu-4"])
|
||||
filed = self.store.issues[-1]
|
||||
@@ -139,7 +139,7 @@ class FilingAFinding(FindingsTest):
|
||||
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: Jira answered 401\n"))
|
||||
|
||||
def test_stops_where_the_machines_settings_cannot_be_read(self) -> None:
|
||||
(self.home / ".claude-projects/do-epic/config.toml").unlink()
|
||||
(self.home / ".config/build-release/do-epic/config.toml").unlink()
|
||||
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry"])
|
||||
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
|
||||
self.assertIn("config.toml", err)
|
||||
|
||||
@@ -102,7 +102,7 @@ class ClosingTheEpic(DoEpicTest):
|
||||
def close(self, summary: str = "## Shipped\n\napi: the import.\n") -> tuple[int, str, str]:
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
code = main.main(["ABC-12", "--close-epic"], {}, paths_from(self.home), LAUNCHER, FakeEffects().effects(), self.backend, io.StringIO(summary))
|
||||
code = main.main(["ABC-12", "--close-epic"], {}, paths_from(self.home, {}), LAUNCHER, FakeEffects().effects(), self.backend, io.StringIO(summary))
|
||||
return code, out.getvalue(), err.getvalue()
|
||||
|
||||
def test_posts_the_summary_on_the_epic_and_closes_it(self) -> None:
|
||||
@@ -127,15 +127,15 @@ class ClosingTheEpic(DoEpicTest):
|
||||
self.assertEqual(finish.closed("ABC-12", Unreadable("ABC-12", list(REVIEWED)), {}, io.StringIO("Shipped.")), Failure("cannot close the epic ABC-12: Jira answered 503"))
|
||||
|
||||
def test_the_jira_backend_closes_an_epic_by_the_transition_the_settings_name(self) -> None:
|
||||
with open(self.home / ".claude-projects/do-epic/config.toml", "a", encoding="utf-8") as settings:
|
||||
with open(self.home / ".config/build-release/do-epic/config.toml", "a", encoding="utf-8") as settings:
|
||||
settings.write('jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
|
||||
config = load(self.home)
|
||||
config = load(self.home, {})
|
||||
assert isinstance(config, DoEpicConfig), config
|
||||
store, _ = main.jira_backend(config, "ABC-12")
|
||||
self.assertEqual(store.finish, Finish("Mark as done", "Done")) # type: ignore[attr-defined]
|
||||
|
||||
def test_closes_an_epic_whose_open_issues_all_have_the_merged_status(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
||||
self.issues.append(issue("ABC-31", "repo:api", status="Release Ready"))
|
||||
code, out, err = self.close()
|
||||
self.assertEqual(code, 0, err)
|
||||
@@ -201,7 +201,7 @@ class TheFinishingChunk(DoEpicTest):
|
||||
self.assertIn(["/b/do-epic", "--chunk", "ABC-12", "ABC-12"], [args[-4:] for args in fake.tmux_calls])
|
||||
|
||||
def test_starts_once_each_open_issue_has_the_merged_status(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n', encoding="utf-8")
|
||||
self.issues = [issue("ABC-20", "do-epic-claude", status="Release Ready"), issue("ABC-21", "do-epic-claude", done=True)]
|
||||
fake = FakeEffects(on_terminal=False)
|
||||
code, out, err = self.run_main(["ABC-12"], fake)
|
||||
@@ -227,7 +227,7 @@ class TheFinishingChunk(DoEpicTest):
|
||||
|
||||
def test_its_worker_is_handed_the_finishing_task_and_runs_until_the_judge_rules_it_finished(self) -> None:
|
||||
self.issues = list(REVIEWED)
|
||||
worker = Worker(paths_from(self.home).claude_code_transcripts.parent)
|
||||
worker = Worker(paths_from(self.home, {}).claude_code_transcripts.parent)
|
||||
fake = FakeEffects(streams=[worker], claude=[judged("finished")], git=UNREAD, windows="ABC-12\t0\t@9\n")
|
||||
code, out, err = self.run_main(["--chunk", "ABC-12", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
@@ -237,11 +237,11 @@ class TheFinishingChunk(DoEpicTest):
|
||||
self.assertIn("`/b/do-epic ABC-12 --close-epic`", streamed)
|
||||
self.assertIn("From the epic ABC-12's description:\n## Goals\nShip the import.", streamed)
|
||||
self.assertIn("write a summary in English, the epic's language", streamed)
|
||||
self.assertTrue((self.home / ".local/state/do-epic/ABC-12").is_dir())
|
||||
self.assertTrue((self.home / ".local/state/build-release/do-epic/ABC-12").is_dir())
|
||||
|
||||
def test_a_worker_that_resumes_is_told_the_task_as_the_epic_now_stands(self) -> None:
|
||||
self.issues = list(REVIEWED)
|
||||
transcripts = paths_from(self.home).claude_code_transcripts
|
||||
transcripts = paths_from(self.home, {}).claude_code_transcripts
|
||||
worker = Worker(transcripts.parent)
|
||||
session = session_named("A ABC-12 do-epic ABC-12", transcripts)
|
||||
(transcripts / "-fake").mkdir(parents=True)
|
||||
@@ -256,7 +256,7 @@ class TheFinishingChunk(DoEpicTest):
|
||||
|
||||
def test_stops_where_the_epics_issues_cannot_be_read_or_its_lock_cannot_be_taken(self) -> None:
|
||||
self.issues = [issue("ABC-20", "do-epic-claude", done=True)]
|
||||
(self.home / ".local/state/do-epic/ABC-12" / LOCK).mkdir(parents=True)
|
||||
(self.home / ".local/state/build-release/do-epic/ABC-12" / LOCK).mkdir(parents=True)
|
||||
code, _, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False))
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("cannot lock ", err)
|
||||
|
||||
@@ -35,7 +35,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
|
||||
folder = configured(self, checkout, home=self.home)
|
||||
if notifier:
|
||||
with (folder / "config.toml").open("a") as config:
|
||||
config.write('env-file = "~/.claude-projects/notifier.env"\nnotifier = "slack"\n')
|
||||
config.write('env-file = "~/.config/build-release/notifier.env"\nnotifier = "slack"\n')
|
||||
return checkout
|
||||
|
||||
def awaited(self, fake: FakeEffects, closes_after: int) -> tuple[int, str, str]:
|
||||
@@ -52,7 +52,7 @@ class AHumanTaskThatBlocksAnIssue(DoEpicTest):
|
||||
|
||||
def moved_to_an_unblocking_status(self, switch: str, frees: tuple[str, dict[str, object]] = ("ABC-19", {"status": "Release Ready"}), starts: str = "ABC-21") -> bool:
|
||||
"""Whether Jira counts the task done after its window's run, where the config ends with switch. frees is the change in Jira that ends the wait: by default the human moves the task to an unblocking status. starts is what the window then starts."""
|
||||
with (self.home / ".claude-projects" / "do-epic" / "config.toml").open("a") as config:
|
||||
with (self.home / ".config/build-release" / "do-epic" / "config.toml").open("a") as config:
|
||||
config.write('jira-unblocking-statuses = ["Release Ready"]\n' + switch)
|
||||
fake = FakeEffects(git=UNREAD, windows=WINDOW)
|
||||
slept: list[int] = []
|
||||
|
||||
+34
-34
@@ -56,7 +56,7 @@ class DoEpicTest(unittest.TestCase):
|
||||
made = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(made.cleanup)
|
||||
self.home = pathlib.Path(made.name).resolve()
|
||||
folder = self.home / ".claude-projects" / "do-epic"
|
||||
folder = self.home / ".config/build-release" / "do-epic"
|
||||
folder.mkdir(parents=True)
|
||||
(folder / "config.toml").write_text(SETTINGS, encoding="utf-8")
|
||||
(folder / "repo-rule.md").write_text("A label that equals a repo's name names that repo.\n", encoding="utf-8")
|
||||
@@ -77,7 +77,7 @@ class DoEpicTest(unittest.TestCase):
|
||||
return MemoryEpic(key, list(self.issues)), EpicRecord(Description(self.description)) # type: ignore[arg-type]
|
||||
|
||||
def worker(self) -> Worker:
|
||||
return Worker(paths_from(self.home).claude_code_transcripts.parent)
|
||||
return Worker(paths_from(self.home, {}).claude_code_transcripts.parent)
|
||||
|
||||
def repo_chunk(self) -> pathlib.Path:
|
||||
"""Makes ABC-20 the one issue, a chunk in the repo api whose checkout holds its premises; the folder of the repo's config."""
|
||||
@@ -88,15 +88,15 @@ class DoEpicTest(unittest.TestCase):
|
||||
return folder
|
||||
|
||||
def epic_run(self, fake: FakeEffects, env: dict[str, str] | None = None) -> epic_run.EpicRun:
|
||||
config = main.load(self.home)
|
||||
config = main.load(self.home, {})
|
||||
assert not isinstance(config, Failure)
|
||||
store, record = self.backend(config, "ABC-12")
|
||||
return epic_run.EpicRun("ABC-12", config, store, record, paths_from(self.home), env or {}, pathlib.Path("/b/do-epic"), fake.effects())
|
||||
return epic_run.EpicRun("ABC-12", config, store, record, paths_from(self.home, env or {}), env or {}, pathlib.Path("/b/do-epic"), fake.effects())
|
||||
|
||||
def run_main(self, argv: list[str], fake: FakeEffects, env: dict[str, str] | None = None) -> tuple[int, str, str]:
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
code = main.main(argv, env or {}, paths_from(self.home), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, forge_at=self.forge_at)
|
||||
code = main.main(argv, env or {}, paths_from(self.home, env or {}), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, forge_at=self.forge_at)
|
||||
return code, out.getvalue(), err.getvalue()
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ class TheCommand(DoEpicTest):
|
||||
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/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-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/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-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"])
|
||||
|
||||
@@ -195,22 +195,22 @@ class TheCommand(DoEpicTest):
|
||||
|
||||
class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
||||
def test_naming_the_chunks_folder_doesnt_make_it(self) -> None:
|
||||
folder = self.home / ".local/state/do-epic/ABC-12"
|
||||
folder = self.home / ".local/state/build-release/do-epic/ABC-12"
|
||||
self.assertEqual(main.chunk_root("ABC-21", self.issues[1], self.epic_run(FakeEffects())), (str(folder), None))
|
||||
self.assertFalse(folder.exists())
|
||||
self.assertIsNone(main.folder_made(str(folder)))
|
||||
self.assertTrue(folder.is_dir())
|
||||
|
||||
def test_a_chunk_whose_folder_cannot_be_made_stops_with_the_reason(self) -> None:
|
||||
(self.home / ".local/state").mkdir(parents=True, exist_ok=True)
|
||||
(self.home / ".local/state/do-epic").write_text("", encoding="utf-8")
|
||||
(self.home / ".local/state/build-release").mkdir(parents=True, exist_ok=True)
|
||||
(self.home / ".local/state/build-release/do-epic").write_text("", encoding="utf-8")
|
||||
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], FakeEffects(), {"TMUX_PANE": "%1"})
|
||||
self.assertEqual(code, 1)
|
||||
self.assertRegex(err, f"could not make the chunk's folder {self.home}/.local/state/do-epic/ABC-12: \\w")
|
||||
self.assertRegex(err, f"could not make the chunk's folder {self.home}/.local/state/build-release/do-epic/ABC-12: \\w")
|
||||
|
||||
def cycle(self, env: dict[str, str] | None = None, run: ChunkRun = ChunkRun(1)) -> main.Cycle:
|
||||
fake = FakeEffects(git=[Failure("no git"), Failure("no git")])
|
||||
paths = paths_from(self.home)
|
||||
paths = paths_from(self.home, env or {})
|
||||
epic = self.epic_run(fake, env)
|
||||
place = main.chunk_root("ABC-21", self.issues[1], epic)
|
||||
assert isinstance(place, tuple)
|
||||
@@ -243,7 +243,7 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
||||
|
||||
def test_works_in_the_epics_folder_and_archives_apart_from_build_release(self) -> None:
|
||||
cycle = self.cycle()
|
||||
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/do-epic/ABC-12"), self.home / ".claude/do-epic-transcripts/ABC-12", ""))
|
||||
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/build-release/do-epic/ABC-12"), self.home / ".local/state/build-release/do-epic-transcripts/ABC-12", ""))
|
||||
|
||||
def test_the_records_are_the_epics_scoring_and_decisions_then_the_humans_rules(self) -> None:
|
||||
self.description = DESCRIPTION + "\n## Scoring\nE + I, bar 4.\n\n## Decisions\n### Merges squash\nAlways.\n"
|
||||
@@ -315,7 +315,7 @@ class TheHumansRun(DoEpicTest):
|
||||
code, _, err = self.run_main(["ABC-12"], FakeEffects())
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("`**Max parallel chunks:** many`, which is not a whole number of 1 or more", err)
|
||||
(self.home / ".claude-projects/do-epic/config.toml").unlink()
|
||||
(self.home / ".config/build-release/do-epic/config.toml").unlink()
|
||||
code, out, err = self.run_main(["ABC-12"], FakeEffects())
|
||||
self.assertEqual((code, out), (1, ""))
|
||||
self.assertIn("config.toml", err)
|
||||
@@ -413,9 +413,9 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertNotIn("=== cycle 3", out)
|
||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||
self.assertEqual(fake.dms, [])
|
||||
archive = self.home / ".claude/do-epic-transcripts/ABC-12"
|
||||
archive = self.home / ".local/state/build-release/do-epic-transcripts/ABC-12"
|
||||
self.assertTrue(any(archive.iterdir()))
|
||||
self.assertFalse((self.home / ".claude/loop-claude-transcripts").exists())
|
||||
self.assertFalse((self.home / ".local/state/build-release/transcripts").exists())
|
||||
streamed = [what for seam, what in fake.calls if seam == "stream_claude"]
|
||||
self.assertIn("Work the Jira issue ABC-21 of the epic ABC-12 as one chunk", " ".join(streamed[0]))
|
||||
self.assertNotIn("Work the Jira issue", " ".join(streamed[1]))
|
||||
@@ -428,7 +428,7 @@ class AChunksRun(DoEpicTest):
|
||||
judged_with = [" ".join(what[0]) + (what[1] or "") for seam, what in fake.calls if seam == "claude"]
|
||||
self.assertEqual((len(prompts), len(judged_with)), (3, 3))
|
||||
for text in (*prompts, *judged_with, *fake.dms, *[str(what) for seam, what in fake.calls if seam == "input"]):
|
||||
self.assertNotIn("build-release", text)
|
||||
self.assertNotIn("build-release", text.replace(str(self.home / ".local/state/build-release"), "<state>"), "but for the state folder's name")
|
||||
self.assertNotIn("None", text)
|
||||
self.assertIn(" do-epic runs you on claude-", prompts[1])
|
||||
self.assertIn("The human answered your question at do-epic's terminal:\nUse B.", prompts[2])
|
||||
@@ -449,7 +449,7 @@ class AChunksRun(DoEpicTest):
|
||||
fake = FakeEffects(streams=[self.worker()] * 6, claude=[judged("unfinished", escalation="working")] + [judged("unfinished")] * 5, git=UNREAD)
|
||||
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 2, out)
|
||||
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".claude/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
||||
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
||||
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
|
||||
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
|
||||
|
||||
@@ -460,7 +460,7 @@ class AChunksRun(DoEpicTest):
|
||||
"""Writes the file, and adds a line to the worker's transcript after each copy of it, as a worker that still writes does."""
|
||||
unwritten = replace_file(path, data)
|
||||
if path.suffix == ".jsonl":
|
||||
for transcript in (paths_from(self.home).claude_code_transcripts.parent / "projects" / "-fake").glob("*.jsonl"):
|
||||
for transcript in (paths_from(self.home, {}).claude_code_transcripts.parent / "projects" / "-fake").glob("*.jsonl"):
|
||||
with open(transcript, "a", encoding="utf-8") as handle:
|
||||
handle.write(json.dumps({"type": "queue-operation", "timestamp": str(path)}) + "\n")
|
||||
return unwritten
|
||||
@@ -468,7 +468,7 @@ class AChunksRun(DoEpicTest):
|
||||
fake.replace_file = grown_after_each_copy
|
||||
code, out, _ = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 2, out)
|
||||
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".claude/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
||||
outcomes = [path.read_text(encoding="utf-8") for path in (self.home / ".local/state/build-release/do-epic-transcripts/ABC-12").glob("*/*.outcomes.md")]
|
||||
self.assertTrue(any("Z Stepped up\n" in text for text in outcomes) and any("Z Stopped: " in text for text in outcomes), outcomes)
|
||||
self.assertEqual([text for text in outcomes if not text.startswith("Task: Work the Jira issue ABC-21 of the epic ABC-12 as one chunk")], [])
|
||||
|
||||
@@ -492,7 +492,7 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||
|
||||
def test_where_the_teams_automation_moves_issues_a_finished_chunk_without_a_repo_still_moves_its_own(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||
parent = issue("ABC-23", "split-by-repo")
|
||||
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-21", "do-epic-claude", parent="ABC-23"), issue("ABC-22", "do-epic-claude", blockers=("ABC-23",))])
|
||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
@@ -515,7 +515,7 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||
|
||||
def test_the_last_sub_task_a_person_filed_to_finish_moves_its_parent_to_done_and_starts_what_it_blocks(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||
tasks = [issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-24", "do-epic-claude", parent="ABC-21", done=True)]
|
||||
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), *tasks, issue("ABC-22", "do-epic-claude", blockers=("ABC-21",))])
|
||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
@@ -526,7 +526,7 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("the chunk finished; started ABC-22\n", out)
|
||||
|
||||
def test_a_parent_jira_will_not_move_is_said_and_the_next_chunk_still_starts(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||
store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-21"), issue("ABC-23", "do-epic-claude", parent="ABC-21"), issue("ABC-22", "do-epic-claude")])
|
||||
finish = store.finish_issue
|
||||
store.finish_issue = lambda key: Failure("no way to done") if key == "ABC-21" else finish(key) # type: ignore[method-assign]
|
||||
@@ -614,7 +614,7 @@ class AChunksRun(DoEpicTest):
|
||||
|
||||
def test_a_chunk_in_a_repo_routes_on_the_repos_model(self) -> None:
|
||||
folder = self.repo_chunk()
|
||||
models = self.home / ".claude/loop-claude-models.json"
|
||||
models = self.home / ".config/build-release/models.json"
|
||||
models.parent.mkdir(parents=True, exist_ok=True)
|
||||
models.write_text(json.dumps({folder.name: "claude-fable-5-2", "other": "claude-opus-5-5"}), encoding="utf-8")
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD)
|
||||
@@ -661,7 +661,7 @@ class AChunksRun(DoEpicTest):
|
||||
store.issues[:] = [issue("ABC-20", "do-epic-claude")]
|
||||
return super().__call__(*args, **kwargs)
|
||||
|
||||
worker = Relabelling(paths_from(self.home).claude_code_transcripts.parent)
|
||||
worker = Relabelling(paths_from(self.home, {}).claude_code_transcripts.parent)
|
||||
fake = FakeEffects(streams=[worker, self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD)
|
||||
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
@@ -710,7 +710,7 @@ class WhatAWorkerJudgeAndHumanRead(DoEpicTest):
|
||||
str(judge.judge_schema(prompts.driver)),
|
||||
]
|
||||
for text in texts:
|
||||
self.assertNotIn("build-release", text)
|
||||
self.assertNotIn("build-release", text.replace(str(self.home / ".local/state/build-release"), "<state>"), "but for the state folder's name")
|
||||
self.assertIn(f"do-epic runs you on {cycle.route.rung}, routed by the issue's L of 3. Where a sentence below names item 21, it means the issue.", texts[0])
|
||||
self.assertRegex(texts[0], r"it means the issue\.( \S|\n\n)")
|
||||
self.assertNotIn("Chunk items:", texts[1])
|
||||
@@ -738,8 +738,8 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
super().setUp()
|
||||
self.repo_config = self.repo_chunk() / "config.toml"
|
||||
self.issues.append(issue("ABC-22", "do-epic-claude"))
|
||||
self.file = parked.file_of(self.home / ".local/state/do-epic/ABC-12", "ABC-20")
|
||||
self.session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home).claude_code_transcripts)
|
||||
self.file = parked.file_of(self.home / ".local/state/build-release/do-epic/ABC-12", "ABC-20")
|
||||
self.session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
|
||||
|
||||
def parked_run(self, fake: FakeEffects) -> tuple[int, str, str, list[str]]:
|
||||
"""The chunk's run, as its exit code, what it printed, and each prompt its workers got."""
|
||||
@@ -855,7 +855,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
self.assertEqual((code, len(prompts)), (0, 1), err)
|
||||
|
||||
def test_where_the_teams_automation_moves_issues_a_finished_chunk_in_a_repo_moves_none_and_waits_for_the_move(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
self.forges = [awaiting(pulls="")]
|
||||
@@ -953,7 +953,7 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
self.assertFalse(self.file.exists())
|
||||
|
||||
def test_where_the_teams_automation_moves_issues_a_merged_parked_chunk_waits_for_the_move_as_a_finished_one_does(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Shipped"]\njira-automation-moves-issues = true\n', encoding="utf-8")
|
||||
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
self.forges = [awaiting(), awaiting(pulls="", merged=True)]
|
||||
@@ -1117,7 +1117,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
self.git_timeouts: list[tuple[str, object]] = []
|
||||
|
||||
def settings(self, more: str) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
|
||||
|
||||
def with_git(self, fake: FakeEffects, **answers: str | Failure) -> FakeEffects:
|
||||
"""fake, whose git answers each command by its first word: as answers has it, else as a checkout whose origin has the branch ABC-12, which holds origin/main."""
|
||||
@@ -1157,7 +1157,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
def test_a_folder_no_checkout_holds_stops_with_the_reason_its_config_cannot_be_found(self) -> None:
|
||||
elsewhere = self.home / "elsewhere"
|
||||
elsewhere.mkdir()
|
||||
unnamed = main.config_located(str(elsewhere), self.home)
|
||||
unnamed = main.config_located(str(elsewhere), self.home, {})
|
||||
assert isinstance(unnamed, Failure), unnamed
|
||||
self.assertEqual(main.epic_based("ABC-20", str(elsewhere), self.epic_run(self.with_git(FakeEffects()))), main.Stop(1, unnamed.reason))
|
||||
|
||||
@@ -1210,8 +1210,8 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
|
||||
def test_a_chunk_parked_on_a_persons_merge_into_the_default_branch_stays_parked_until_its_pull_request_goes_into_the_branch(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home).claude_code_transcripts)
|
||||
parked.park(self.home / ".local/state/do-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
|
||||
session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home, {}).claude_code_transcripts)
|
||||
parked.park(self.home / ".local/state/build-release/do-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
|
||||
self.worker()(["--session-id", str(session.id)])
|
||||
# The pull request was opened into main before the setting was on; a person then changes its base to ABC-12.
|
||||
self.forges = [self.recorded(decision="APPROVED"), self.recorded(decision="APPROVED"), self.recorded(base="ABC-12", decision="APPROVED")]
|
||||
@@ -1419,7 +1419,7 @@ class TheDryRun(DoEpicTest):
|
||||
self.assertEqual([args for args in fake.tmux_calls if args[0] in changing], [])
|
||||
|
||||
def test_prints_each_move_of_a_parent_whose_sub_tasks_a_person_filed(self) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-sub-tasks-landed-transition = "Release Ready"\njira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||
(self.home / ".config/build-release" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-sub-tasks-landed-transition = "Release Ready"\njira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n', encoding="utf-8")
|
||||
self.issues = [issue("ABC-20", status="In Progress"), issue("ABC-30", "do-epic-claude", parent="ABC-20", status="Release Ready"), issue("ABC-21"), issue("ABC-31", "do-epic-claude", parent="ABC-21", done=True), issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))]
|
||||
code, out, err = self.run_main(["ABC-12", "--dry-run"], FakeEffects())
|
||||
self.assertEqual((code, err), (0, ""))
|
||||
|
||||
@@ -38,10 +38,10 @@ def scored(key: str, moves: str, *labels: str, blockers: tuple[str, ...] = (), b
|
||||
class Planning(DoEpicTest):
|
||||
def plan(self, fake: FakeEffects) -> tuple[list[EpicIssue] | Failure | Limited, MemoryEpic, str]:
|
||||
"""What planning answers for self.issues, the store it changed and what it printed on stdout. self.asked holds what it asked the human, on stderr."""
|
||||
config = load(self.home)
|
||||
config = load(self.home, {})
|
||||
assert not isinstance(config, Failure), config
|
||||
store = MemoryEpic("ABC-12", list(self.issues))
|
||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, fake.effects()) # type: ignore[arg-type]
|
||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, {}, fake.effects()) # type: ignore[arg-type]
|
||||
out, self.asked = io.StringIO(), io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(self.asked):
|
||||
read = store.read()
|
||||
@@ -73,7 +73,7 @@ class Planning(DoEpicTest):
|
||||
self.assertEqual((found, out, fake.made("claude")), (self.issues, "", []))
|
||||
|
||||
def test_an_epic_shaped_as_a_teams_is_planned_without_claude_and_without_a_write(self) -> None:
|
||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write('\n[label-repos]\ntwu-4 = "tenant-web-ui-4"\ncore-4 = "core-4"\n')
|
||||
self.description = RANKED
|
||||
self.repo("tenant-web-ui-4")
|
||||
@@ -120,7 +120,7 @@ class Planning(DoEpicTest):
|
||||
self.assertIn("in English, that tells the team why it is split by repo", fake.made("claude")[0][1])
|
||||
|
||||
def test_a_failed_runs_sub_task_under_the_teams_label_is_not_filed_again_and_another_label_is_no_pick(self) -> None:
|
||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write('\n[label-repos]\nbackend = "api"\n')
|
||||
configured(self, self.home / "code" / "api", home=self.home)
|
||||
self.issues = [issue("ABC-20", "urgent"), dataclasses.replace(issue("ABC-23", "backend", parent="ABC-20"), by_loop=True), issue("ABC-21", "urgent")]
|
||||
@@ -151,11 +151,11 @@ class Planning(DoEpicTest):
|
||||
def claude(args: object, cwd: str, stdin: object) -> object:
|
||||
folders.append(cwd)
|
||||
return effects.claude(args, cwd, stdin) # type: ignore[arg-type]
|
||||
config = load(self.home)
|
||||
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description("")), self.home, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
||||
config = load(self.home, {})
|
||||
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description("")), self.home, {}, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
planning.planned(epic, list(self.issues))
|
||||
folder = self.home / ".local" / "state" / "do-epic" / "ABC-12"
|
||||
folder = self.home / ".local" / "state" / "build-release" / "do-epic" / "ABC-12"
|
||||
self.assertEqual((folders, folder.is_dir()), ([str(folder)] * 2, True))
|
||||
|
||||
def test_a_model_off_the_routing_ladder_has_no_rung(self) -> None:
|
||||
@@ -181,7 +181,7 @@ class Planning(DoEpicTest):
|
||||
self.assertEqual(args[args.index("--add-dir") + 1], str(checkout))
|
||||
|
||||
def test_asks_for_one_of_the_teams_labels_too_and_takes_it(self) -> None:
|
||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write('\n[label-repos]\nbackend = "api"\n')
|
||||
self.issues = [issue("ABC-20")]
|
||||
fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "Is the importer in api or in web?"})], inputs=["backend"])
|
||||
@@ -190,7 +190,7 @@ class Planning(DoEpicTest):
|
||||
|
||||
def configure_team(self, *above: str) -> None:
|
||||
"""Gives the config the team's label `backend` for api, and the settings in above."""
|
||||
path = self.home / ".claude-projects/do-epic/config.toml"
|
||||
path = self.home / ".config/build-release/do-epic/config.toml"
|
||||
path.write_text("".join(f"{line}\n" for line in above) + path.read_text(encoding="utf-8") + '\n[label-repos]\nbackend = "api"\n', encoding="utf-8")
|
||||
|
||||
def test_files_sub_tasks_under_the_teams_label_and_summary_template(self) -> None:
|
||||
@@ -379,7 +379,7 @@ class Planning(DoEpicTest):
|
||||
self.description = RANKED
|
||||
self.issues = [scored("ABC-20", "epic 1 by 2", "do-epic-claude", by_loop=False), issue("ABC-21", "do-epic-claude")]
|
||||
# An earlier run made the folder the scoring runs in.
|
||||
(self.home / planning.STATE / "ABC-12").mkdir(parents=True, exist_ok=True)
|
||||
(self.home / ".local/state/build-release/do-epic/ABC-12").mkdir(parents=True, exist_ok=True)
|
||||
fake = FakeEffects(claude=[says(ANSWER)])
|
||||
found, store, out = self.plan(fake)
|
||||
assert not isinstance(found, Failure | Limited), found
|
||||
@@ -402,7 +402,7 @@ class Planning(DoEpicTest):
|
||||
self.assertEqual((found, store.writes, out, fake.made("claude")), (self.issues, [], "", []))
|
||||
|
||||
def test_scores_no_issue_whose_work_has_landed(self) -> None:
|
||||
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
with (self.home / ".config/build-release/do-epic/config.toml").open("a", encoding="utf-8") as config:
|
||||
config.write('\njira-unblocking-statuses = ["Release Ready"]\n')
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
@@ -446,11 +446,11 @@ class Planning(DoEpicTest):
|
||||
def claude(args: object, cwd: str, stdin: object) -> object:
|
||||
folders.append(cwd)
|
||||
return effects.claude(args, cwd, stdin) # type: ignore[arg-type]
|
||||
config = load(self.home)
|
||||
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description(RANKED)), self.home, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
||||
config = load(self.home, {})
|
||||
epic = planning.Planned("ABC-12", config, MemoryEpic("ABC-12", list(self.issues)), EpicRecord(Description(RANKED)), self.home, {}, dataclasses.replace(effects, claude=claude)) # type: ignore[arg-type]
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
planning.planned(epic, list(self.issues))
|
||||
self.assertEqual(folders, [str(self.home / ".local" / "state" / "do-epic" / "ABC-12")] * 2)
|
||||
self.assertEqual(folders, [str(self.home / ".local" / "state" / "build-release" / "do-epic" / "ABC-12")] * 2)
|
||||
|
||||
self.rule()
|
||||
self.description = RANKED
|
||||
@@ -467,9 +467,9 @@ class Planning(DoEpicTest):
|
||||
store = MemoryEpic("ABC-12", list(self.issues))
|
||||
store.fails = "Jira answered 503"
|
||||
out = io.StringIO()
|
||||
config = load(self.home)
|
||||
config = load(self.home, {})
|
||||
assert not isinstance(config, Failure), config
|
||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, FakeEffects(claude=[says(ANSWER)]).effects()) # type: ignore[arg-type]
|
||||
epic = planning.Planned("ABC-12", config, store, EpicRecord(Description(self.description)), self.home, {}, FakeEffects(claude=[says(ANSWER)]).effects()) # type: ignore[arg-type]
|
||||
with contextlib.redirect_stdout(out):
|
||||
found, stopped = planning.scored(epic, list(self.issues))
|
||||
self.assertEqual((found, stopped, out.getvalue()), (self.issues, None, "<1790000000> scoring ABC-20\n<1790000000> ABC-20 is not scored: Jira answered 503\n"))
|
||||
@@ -518,9 +518,9 @@ class Planning(DoEpicTest):
|
||||
|
||||
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)
|
||||
config = load(self.home, {})
|
||||
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]
|
||||
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()):
|
||||
return planning.planned(epic, list(self.issues))
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class LocateTest(unittest.TestCase):
|
||||
made = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(made.cleanup)
|
||||
self.home = pathlib.Path(made.name).resolve()
|
||||
self.projects = self.home / ".claude-projects"
|
||||
self.projects = self.home / ".config/build-release"
|
||||
self.config = DoEpicConfig(self.projects / "do-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "clones", "English", "claude-opus-5-5", "rule")
|
||||
self.billing, self.payments = self.home / "elsewhere" / "billing", self.home / "elsewhere" / "payments"
|
||||
self.origins: dict[str, str | Failure] = {str(self.billing): "git@github.com:acme/billing.git", str(self.payments): "git@github.com:acme/payments"}
|
||||
@@ -52,7 +52,7 @@ class LocateTest(unittest.TestCase):
|
||||
write_config(self.home, self.home / "code" / "ledger")
|
||||
|
||||
def locate(self, git: FakeGit, name: str = "ledger") -> Located | Failure:
|
||||
return locate(name, [self.billing, self.payments], self.config, self.home, git)
|
||||
return locate(name, [self.billing, self.payments], self.config, self.home, {}, git)
|
||||
|
||||
def unsure(self, git: FakeGit, name: str = "ledger") -> str:
|
||||
found = self.locate(git, name)
|
||||
@@ -100,7 +100,7 @@ class LocateTest(unittest.TestCase):
|
||||
|
||||
def test_asks_where_no_other_repo_shows_where_to_clone_from(self) -> None:
|
||||
self.configure()
|
||||
found = locate("ledger", [], self.config, self.home, FakeGit({}))
|
||||
found = locate("ledger", [], self.config, self.home, {}, FakeGit({}))
|
||||
assert isinstance(found, Unsure), found
|
||||
self.assertIn("no other repo of the epic", found.reason)
|
||||
|
||||
|
||||
@@ -222,12 +222,12 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
||||
found = self.start(self.epic(2, api=1, web=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "do-epic-claude"), issue("ABC-22", "repo:web")], run)
|
||||
self.assertEqual(found, Started(["ABC-20", "ABC-21"], [Waits("ABC-22", "the epic runs as many chunks as its `**Max parallel chunks:**` line allows: 2")]))
|
||||
self.assertEqual(run.started(), [("epic-ABC-12", "ABC-20", f"{CHUNK_FLAG} ABC-20 ABC-12"), ("epic-ABC-12", "ABC-21", f"{CHUNK_FLAG} ABC-21 ABC-12")])
|
||||
self.assertEqual([args[args.index("-c") + 1] for args in run.calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / ".local/state/do-epic/ABC-12")])
|
||||
self.assertEqual([args[args.index("-c") + 1] for args in run.calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / ".local/state/build-release/do-epic/ABC-12")])
|
||||
self.assertIn("BUILD_RELEASE_X=1", run.calls[[args[0] for args in run.calls].index("new-session")])
|
||||
self.assertNotIn("OTHER=2", run.calls[[args[0] for args in run.calls].index("new-session")])
|
||||
|
||||
def parked(self, issue_key: str, on: str = "an approval") -> None:
|
||||
self.assertIsNone(park(self.home / ".local/state/do-epic/ABC-12", Parked(issue_key, f"/code/api-{issue_key}", "7", "0c0f", on)))
|
||||
self.assertIsNone(park(self.home / ".local/state/build-release/do-epic/ABC-12", Parked(issue_key, f"/code/api-{issue_key}", "7", "0c0f", on)))
|
||||
|
||||
def test_starts_the_chunks_in_the_epics_start_order_and_those_it_leaves_out_last_in_backlog_order(self) -> None:
|
||||
self.order = ("ABC-23", "ABC-21")
|
||||
@@ -260,7 +260,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
||||
run = Tmux(*windows, ("epic-ABC-12", "ABC-21", False, str(self.home / "code/api")))
|
||||
found = self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], run)
|
||||
self.assertEqual(found, Started(["ABC-20"], []))
|
||||
self.assertEqual(run.windows[-1], ("epic-ABC-12", "ABC-20", False, str(self.home / ".local/state/do-epic/ABC-12")))
|
||||
self.assertEqual(run.windows[-1], ("epic-ABC-12", "ABC-20", False, str(self.home / ".local/state/build-release/do-epic/ABC-12")))
|
||||
self.assertEqual([name for _, name, dead, _ in run.windows if dead], [""] * len(windows))
|
||||
|
||||
def test_a_human_task_that_blocks_an_issue_gets_a_window_that_takes_no_slot_of_the_epics_cap(self) -> None:
|
||||
@@ -292,7 +292,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
||||
|
||||
def test_stops_on_a_parked_chunk_it_cannot_read_and_starts_none(self) -> None:
|
||||
self.parked("ABC-20")
|
||||
file_of(self.home / ".local/state/do-epic/ABC-12", "ABC-20").write_text("{")
|
||||
file_of(self.home / ".local/state/build-release/do-epic/ABC-12", "ABC-20").write_text("{")
|
||||
run = Tmux()
|
||||
found = start_chunks(self.epic(2, api=2), [issue("ABC-21", "repo:api")], False, None, run)
|
||||
assert isinstance(found, Failure)
|
||||
@@ -314,7 +314,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
||||
self.assertEqual(run.windows[0], ("epic-ABC-12", "ABC-20", False, str(self.home / "code/api")))
|
||||
|
||||
def test_a_parked_chunk_whose_window_started_again_doesnt_count_itself_as_running(self) -> None:
|
||||
for root in (str(self.home / ".local/state/do-epic/ABC-12"), str(self.home / "code/api")):
|
||||
for root in (str(self.home / ".local/state/build-release/do-epic/ABC-12"), str(self.home / "code/api")):
|
||||
with self.subTest(root=root):
|
||||
run = Tmux(("epic-ABC-12", "ABC-20", False, root))
|
||||
self.assertIsNone(self.resumed(self.epic(1, api=1), run))
|
||||
@@ -373,12 +373,12 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
||||
|
||||
def test_holds_each_repos_starting_lock_that_build_release_holds(self) -> None:
|
||||
self.start(self.epic(1, api=1), [issue("ABC-20", "repo:api")], Tmux())
|
||||
self.assertTrue((self.home / ".local/state/loop-claude/api/starting").is_file())
|
||||
self.assertTrue((self.home / ".local/state/do-epic/ABC-12/starting").is_file())
|
||||
self.assertTrue((self.home / ".local/state/build-release/claims/api/starting").is_file())
|
||||
self.assertTrue((self.home / ".local/state/build-release/do-epic/ABC-12/starting").is_file())
|
||||
|
||||
def test_a_parked_chunk_resumes_under_the_starting_lock_of_its_repos_checkout(self) -> None:
|
||||
self.assertIsNone(self.resumed(self.epic(1, api=1), Tmux(("epic-ABC-12", "ABC-20 awaits an approval", False, ""))))
|
||||
self.assertEqual([lock.parent.name for lock in (self.home / ".local/state/loop-claude").glob("*/starting")], ["api"])
|
||||
self.assertEqual([lock.parent.name for lock in (self.home / ".local/state/build-release/claims").glob("*/starting")], ["api"])
|
||||
|
||||
def test_the_waits_keep_the_trackers_rank_order(self) -> None:
|
||||
run = Tmux(("epic-ABC-12", "ABC-20", True, str(self.home / "code/api")), ("epic-ABC-12", "ABC-22", False, str(self.home / "code/api")))
|
||||
@@ -393,19 +393,19 @@ class StartingAnEpicsChunks(unittest.TestCase):
|
||||
self.assertNotIn(tmux.OWNER, options)
|
||||
|
||||
def test_says_which_lock_it_could_not_take(self) -> None:
|
||||
(self.home / ".local/state/do-epic").mkdir(parents=True)
|
||||
(self.home / ".local/state/do-epic/ABC-12").write_text("", encoding="utf-8")
|
||||
(self.home / ".local/state/build-release/do-epic").mkdir(parents=True)
|
||||
(self.home / ".local/state/build-release/do-epic/ABC-12").write_text("", encoding="utf-8")
|
||||
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
|
||||
assert isinstance(found, Failure)
|
||||
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/do-epic/ABC-12: \\w")
|
||||
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/build-release/do-epic/ABC-12: \\w")
|
||||
|
||||
def test_says_which_repos_lock_it_could_not_take(self) -> None:
|
||||
(self.home / ".local/state").mkdir(parents=True)
|
||||
(self.home / ".local/state/loop-claude").write_text("", encoding="utf-8")
|
||||
(self.home / ".local/state/build-release").mkdir(parents=True)
|
||||
(self.home / ".local/state/build-release/claims").write_text("", encoding="utf-8")
|
||||
found = start_chunks(self.epic(1, api=1), [issue("ABC-20", "repo:api")], False, None, Tmux())
|
||||
assert isinstance(found, Failure)
|
||||
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/loop-claude/\\S+: \\w")
|
||||
self.assertRegex(self.resumed(self.epic(1, api=1), Tmux()) or "", f"^cannot lock {self.home}/.local/state/loop-claude/\\S+: \\w")
|
||||
self.assertRegex(found.reason, f"^cannot lock {self.home}/.local/state/build-release/claims/\\S+: \\w")
|
||||
self.assertRegex(self.resumed(self.epic(1, api=1), Tmux()) or "", f"^cannot lock {self.home}/.local/state/build-release/claims/\\S+: \\w")
|
||||
|
||||
def test_an_error_raised_under_the_lock_is_not_reported_as_the_locks(self) -> None:
|
||||
def failing(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||
|
||||
Reference in New Issue
Block a user