"""What a chunk's worker writes into its epic: a finding, filed as an issue, and a decision, appended to the description. A finding about one of the epic's goals is filed in the epic, and one about a repo's goals by that repo's rules (docs/decisions.md → `do-epic: drives one Jira epic …` → "Findings"). A decision that governs the epic goes under the description's ## Decisions, where the judge of each later chunk reads it.""" import contextlib import dataclasses import fcntl import pathlib import typing from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, label_of, LabelRepos, of_label, REPO_PREFIX, team_label from do_epic.backend.protocol import EpicIssue, EpicStore, REVIEW_LABEL from do_epic.epic_record import EpicRecord from failure import Failure from text_files.markdown_text import listed from text_files.piped_text import piped # Three readers, seated as the human and as a chunk's worker, picked each spelling from four: ` --file` over `--file `, `add` and `--finding`, and `--record-decision` over `--decision` and `--decide`. FILE = "--file" LABEL = "--label" BLOCKED_BY = "--blocked-by" PARENT = "--parent" RECORD_DECISION = "--record-decision" def worked_by(team: LabelRepos) -> str: """The labels that say where an issue is worked, as do-epic's scheduler reads them: for each repo the team's table names, the label on its first line for that repo, and `repo:` for any other repo.""" named = [f"`{label}` for the repo {name}" for name in sorted(set(team.values())) if (label := team_label(name, team))] repos = ", ".join([*named, f"`{REPO_PREFIX}` for {'any other repo' if named else 'the repo'} that works it"]) return f"{repos}, `{CLAUDE_LABEL}` for work of Claude's that changes no repo, or `{HUMAN_LABEL}` for a task of the human's" # Under the epic's folder, the file a do-epic holds locked while it appends a decision. DECISIONS_LOCK = "decisions.lock" USAGE = f"""do-epic {FILE} [{LABEL}