Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d685c52b3 | |||
| c56b3166a0 | |||
| b6a53ef98b | |||
| c46a117088 | |||
| 121aba05ea | |||
| eb5a63edd2 | |||
| 2707cfc04e | |||
| 53a54e50dd | |||
| 2e9d9dd714 | |||
| 0681e9be17 | |||
| 2fdc75d035 | |||
| bad76b07c8 | |||
| 9dd8441f3b | |||
| 1210f8cd68 | |||
| 0f0ba7fa43 | |||
| 37078cffa9 | |||
| 30129051ad | |||
| 58055f0fac | |||
| 55ad029df2 | |||
| b89ac805d3 | |||
| 8b649682dc | |||
| 4447e89e48 | |||
| 3c522160c9 | |||
| 39bf6e6d94 | |||
| 0339a515fc | |||
| 75c3c581ef | |||
| cca16e702a | |||
| 36d9ddb6f5 | |||
| dbc8cfe854 | |||
| fffba3d454 | |||
| 2695e9b530 | |||
| 4873ee9e74 |
@@ -2,6 +2,9 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- `todo-item edit` and `move` work on a plan kept in a Jira epic. They change only an issue the loop filed, and never a link. Of an issue a person filed, `edit` sets only the scores, and posts the new `--comment` on the issue to tell the team why; a plan in a file takes the flag and keeps no comment.
|
||||
- A release someone else cut while it still held plan items no longer stops the loop: those items count as the next release's, `chunk-preflight` tells the worker to move them there, and `loop-claude` routes on them. Where the plan names no later release and `todo.md` named none since the cut, the loop still asks which release they belong to.
|
||||
- `project-record open` now writes the copy of a record kept outside a file under a folder of the worktree that ran it, `~/.local/state/project-record/<key>/<worktree>/`, so two chunks of one project no longer overwrite each other's unsaved edit. It also removes the folders of worktrees git no longer lists.
|
||||
- `chunk-pr merge` merges the chunks of one project on a machine one at a time, and `--finish <ID>` finishes each plan item in the chunk's turn, so `todo.md` and `CHANGELOG.md` no longer conflict between open chunks. A pull request that waits for an approval leaves the queue while it waits, and merge stops where a reviewer's comment waits for an answer.
|
||||
- Two loop-claude runs in one project now work side by side, each on its own chunk. Each loop holds a slot of the project, a locked file under `~/.local/state/loop-claude/<key>/`, and names its session after it: the first loop's session keeps its name, `A <key> loop-claude`, and the second's is `A <key> loop-claude 2`. A rerun resumes a chunk left open first. A commit in the config's folder now takes only the file it changed, as `git commit -m <title> -- <file>`.
|
||||
- `todo-item finish` finishes an item of a plan kept in a Jira epic: it moves the item's issue by the workflow transition, and to the status, that the config's new optional settings `jira-finish-transition` and `jira-finish-status` name, both as Jira shows them. It refuses a transition that leads to another status, or to one Jira doesn't count as done, and fails where the config sets neither.
|
||||
|
||||
@@ -6,9 +6,10 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The
|
||||
|
||||
- **Until the goals file has a `## Goals` and an `## Audience` section, writing them is the only work.** Not even planning. In a README both are public: an outside reader judges a project by where it is heading and who it is for. Goals or an audience written anywhere else, such as `AGENTS.md` or `docs/`, do not count; the one exception is code health, which "Shared goal" below states for every project.
|
||||
- **Keep a plan in `todo.md` as one scored table, in the shape whose example `~/.claude/bin/rank_todo.py --help` shows**: every item names the release that ships it. Until `todo.md` has that shape, reshaping it is the only work, and the human approves it.
|
||||
- **Read and change the plan's items only with `~/.claude/bin/todo-item`**, which lists, shows, files, edits, moves and finishes them; `todo-item --help` says how. It reads a plan in Jira as it does a file, and there it files and finishes an item but doesn't edit or move one yet. Two open the file itself: whoever plans a release, to compare Scores across releases, which `todo-item list` doesn't print; and whoever edits `## Scoring` or `## Renamed`, or reshapes an old table.
|
||||
- **Read and change the plan's items only with `~/.claude/bin/todo-item`**, which lists, shows, files, edits, moves and finishes them; `todo-item --help` says how. It reads a plan in Jira as it does a file. There it edits and moves only an issue the loop filed; of an issue a person filed it sets only the scores, with `--comment` telling the team why. Two open the file itself: whoever plans a release, to compare Scores across releases, which `todo-item list` doesn't print; and whoever edits `## Scoring` or `## Renamed`, or reshapes an old table.
|
||||
- **When the next release has no items and no work has landed towards it, plan it as this chunk.** Move the highest-scoring items of later releases into it, and get the human's approval of that set before writing any code.
|
||||
- **When the next release has no items left and work has landed towards it, its release review is the chunk** (`larv-review` §3 → "Release review"). **Once that has merged and the release holds no item, the release is finished: stop.** Report what it holds and that it is ready to cut. Under `/loop`, this ends the loop. Until the human cuts it, only a security fix, or an item its release review filed, lands, into that release; never start a later release's items or plan a new one.
|
||||
- **Where someone cut a release that still holds items, those items are the next release's.** Move them there as the chunk's first change and say so in its opening line; where `todo-item` cannot move an item, such as an issue a person filed in a Jira plan, ask the human in the chunk's summary to move it. Where the plan names no later release, ask the human which one they belong to.
|
||||
- **Open every chunk with one line:** the last version cut, how many changes are unreleased (the entries under `CHANGELOG.md` → `## Unreleased`, or else the commits since the last tag), and the release this chunk ships into. A repo that doesn't publish anything says so once.
|
||||
- **A client project's `CLAUDE.md` and `AGENTS.md` in its repo belong to its team.** Read both at the start of each chunk there. Propose each change that aligns them with this setup in a pull request of its own, never inside a chunk's; the one edit a chunk makes there is a decision's title in `AGENTS.md`. Until the team accepts a proposal, and after it declines or doesn't answer, follow the team's rule unless it breaks one of the project's goals. Record each such conflict as a decision in the `decisions` record, as `rules/decisions.md` asks: which rule you follow, why, and the open proposal's PR. Then nobody is asked twice.
|
||||
- **Read the goals file's `## Goals` and `## Audience` before starting a chunk, unless your prompt quotes them.** The chunk's items set its scope. The goals choose between ways to deliver those items, and never add to them.
|
||||
@@ -138,7 +139,7 @@ Claude Code reads this section by its heading when it compacts a conversation. K
|
||||
- **premises** — the goals and audience under `## Goals` and `## Audience` in the project's goals file, with code health ("Shared goal") first among the goals unless the goals file voids it.
|
||||
- **project's rung** — the cheapest rung on loop-claude's routing ladder of the project's model, which is the model loop-claude's prompt names as the project's, or else your own.
|
||||
- **project record** — one of five documents a project keeps beside its plan, each where its config names it: `decisions`, `score-anchors`, `comprehension-history`, `reading-cost` and `changelog`.
|
||||
- **release** — a semver version the human cuts.
|
||||
- **release** — a semver version the human cuts, or in a client's project someone on its team.
|
||||
- **release review** — a release's last chunk: the architecture and principles passes over the whole project, before the release is ready to cut; `larv-review` §3 → "Release review".
|
||||
- **reviewer** — a reporter of findings: an agent under `~/.claude/agents/`, `/security-review` or a forge's auto-reviewer.
|
||||
- **round cap** — the rounds one pass may take per chunk; `larv-review` §3 → "Round cap".
|
||||
|
||||
@@ -120,7 +120,7 @@ A client that plans in Jira Cloud names an epic as its project's plan: `plan = "
|
||||
- A blocker is an "is blocked by" link to another open child.
|
||||
- The scores are the issue property `plan-item`, a JSON object such as `{"L": 2, "E": 2, "I": 3, "S": 3, "Moves": "1.6 by 4", "Exempt": ""}`. An issue without it reads as an item nobody scored yet.
|
||||
|
||||
A read fails, naming the issue, where a child is in another Jira project or names no such Fix Version. The config's `env-file` must hold `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, an API token of that Atlassian account, and only its owner may read that file: `chmod 600` it. The loop reads such a plan and files items into it, each as a Task under the epic, and doesn't edit an issue yet. `todo-item edit` and `move` fail, so edit its issues in Jira. For `todo-item finish`, the config names the workflow transition that finishes an item and the status it leads to, both as Jira shows them: `jira-finish-transition = "Mark as done"` and `jira-finish-status = "Done"`. Finish then moves the item's issue by that transition. It refuses a transition that leads to another status, or to one Jira doesn't count as done, and fails where the config sets neither. `todo-item add` needs the item's release among the Jira project's Fix Versions, named as `1.2.0` or `v1.2.0`. `rank_todo.py` doesn't rank it, since Jira's backlog does. The four things not supported for a plan outside the checkout, above, are not supported for a plan in Jira either.
|
||||
A read fails, naming the issue, where a child is in another Jira project or names no such Fix Version. The config's `env-file` must hold `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, an API token of that Atlassian account, and only its owner may read that file: `chmod 600` it. The loop reads such a plan and files items into it, each as a Task under the epic. `todo-item edit` and `move` change only an issue the loop filed. Of an issue a person filed, `edit` sets only the scores, and posts its `--comment` on the issue to tell the team why; the summary, description and Fix Version stay the team's to change in Jira, as do every issue's links. For `todo-item finish`, the config names the workflow transition that finishes an item and the status it leads to, both as Jira shows them: `jira-finish-transition = "Mark as done"` and `jira-finish-status = "Done"`. Finish then moves the item's issue by that transition. It refuses a transition that leads to another status, or to one Jira doesn't count as done, and fails where the config sets neither. `todo-item add` needs the item's release among the Jira project's Fix Versions, named as `1.2.0` or `v1.2.0`. `rank_todo.py` doesn't rank it, since Jira's backlog does. The four things not supported for a plan outside the checkout, above, are not supported for a plan in Jira either.
|
||||
|
||||
A client that keeps its goals and audience in an epic's description names that epic as the goals file: `goals-and-audience = "jira:https://acme.atlassian.net/browse/ABC-12"`, which may be the plan's own epic. Such a config keeps its plan in Jira too, and reads both with the same `env-file`. The description needs `## Goals` and `## Audience` as headings, level-2 headings in Jira's editor. The loop only reads the description, so edit it in Jira; `project-record open goals-and-audience` prints a file holding its text. Whoever may edit that description sets the premises every worker and judge follows, so keep its edit rights to the people who own the project's goals.
|
||||
|
||||
@@ -205,7 +205,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
|
||||
- `machine_load/` takes the machine's heavy slots, its shared lock files, for `run_heavy` and `adf_codec`, and reads the memory share that loop-claude waits for. It also gives `mutate_changes` a slot's CPU count.
|
||||
- `model_routing/` holds the shipped routing ladder (`routing-ladder.json`) and its steps (`ladder.py`), and reads a ladder from that file or a project's own (`ladder_file.py`), for loop-claude, `rule_hook`, both replay tools and `subagent-rung`. It finds a project's config folder through `project_config`. It also holds the list prices, which `routing_figures` and `transcript_archive` read.
|
||||
- `notifier/` sends the human a DM through the notifier a project's config names, for `notify` and for loop-claude through `loop_effects`; `mattermost_dm/` and `slack_dm/` are its two backends.
|
||||
- `plan_store/` reads and writes a project's plan through the store the project's config names (`stores.py`), with the markdown file's edits in `markdown_edits.py`. `contract.py` holds the tests every backend that writes must pass, which `jira_epic.py` doesn't yet, and `fakes.py` a plan in memory.
|
||||
- `plan_store/` reads and writes a project's plan through the store the project's config names (`stores.py`), with the markdown file's edits in `markdown_edits.py`. `contract.py` holds the tests every backend that writes must pass, which `jira_epic.py` doesn't yet, since it changes no link, and `fakes.py` a plan in memory.
|
||||
- `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them.
|
||||
- `record_store/` reads and writes a project's records, each through the store the project's config names (`stores.py`): a markdown file, a Confluence Cloud page (`confluence_page.py`), or, for the goals, a Jira epic's description (`jira_description.py`). `contract.py` holds the tests every backend must pass, and `fakes.py` a store in memory that the tests of other tools use.
|
||||
- `release_plan/` reads `todo.md`'s items table and release versions, says which release is next and whether it is ready to cut (`release_standing.py`), and ranks the plan (`ranking.py`, with its score formula in `formula.py` and its blocker order in `blockers.py`). `goals_file.py` reads the goals file's sections, goals and goal weights, for the ranking and for `loop_claude`'s premises, and `citations.py` holds `todo.md` and `docs/decisions.md` to each other. `plan_file.py` ranks, checks and writes a `todo.md`, for `larv_review`, `rank_todo.py` and `rule_hook`.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""The pure choices the preflight's steps act on."""
|
||||
import pathlib
|
||||
|
||||
from release_plan.release_standing import chunk_item, Cut, dated_cut, LastCut, ReadyToCut, ReviewDue, Unknown, Unplanned
|
||||
from release_plan.release_standing import carried, chunk_item, Cut, dated_cut, LastCut, ReadyToCut, ReviewDue, Unknown, Unplanned
|
||||
from chunk_preflight.gathered import CarriedOver, Forge, NoItem, Plan
|
||||
from failure import Failure
|
||||
from chunk_preflight.gathered import Forge, NoItem, Plan
|
||||
from release_plan.todo_table import NoItemsTable
|
||||
from plan_store import stores as plan_stores
|
||||
from release_plan.release import version
|
||||
@@ -52,7 +52,11 @@ def planned(todo: plan_stores.Plan | Failure, cut: LastCut, default: str, branch
|
||||
first = pick.item
|
||||
if first is None:
|
||||
return NoItem(f"every item of release {version(pick.release)} in {where} waits." if pick.release is not None else f"{where}'s items table holds no item.")
|
||||
return Plan(found, first, f"{first.tagline}\n\n{first.detail}".strip(), branch)
|
||||
held = carried(found, cut)
|
||||
moved = [(was, now) for was, now in zip(found, held) if was.release != now.release]
|
||||
# Every carried item takes one release, the next.
|
||||
over = CarriedOver(moved[0][1].release, tuple(was.id for was, _ in moved)) if moved else None
|
||||
return Plan(held, first, f"{first.tagline}\n\n{first.detail}".strip(), branch, over)
|
||||
|
||||
|
||||
def worktree_on(porcelain: str, branch: str) -> pathlib.Path | None:
|
||||
|
||||
@@ -45,7 +45,8 @@ def item_lines(plan: str, item: ItemFacts) -> list[str]:
|
||||
first = item.plan.first
|
||||
worktree = item.worktree.reason if isinstance(item.worktree, Failure) else f"{item.worktree.path}, {item.worktree.how}"
|
||||
return [
|
||||
f"- The earliest release in {plan}: {version(first.release)}. Its first item that does not wait: item {first.id}, {levels(first)}.",
|
||||
f"- The {'next release, after the last cut, that ' + plan + ' names' if item.plan.carried else 'earliest release in ' + plan}: {version(first.release)}. Its first item that does not wait: item {first.id}, {levels(first)}.",
|
||||
*carried_lines(item.plan),
|
||||
f"- Worktree: {worktree}",
|
||||
f"- Open pull requests from {item.plan.branch}: {pulls_text(item.pulls, item.plan.branch)}",
|
||||
*bundled(item.plan),
|
||||
@@ -57,6 +58,15 @@ def item_lines(plan: str, item: ItemFacts) -> list[str]:
|
||||
]
|
||||
|
||||
|
||||
def carried_lines(plan: Plan) -> list[str]:
|
||||
"""What the worker does about the items of a release someone cut while it held them."""
|
||||
over = plan.carried
|
||||
if over is None:
|
||||
return []
|
||||
items, count, them = (f"Items {listed([str(id_) for id_ in over.ids], 'and')} are", "they count", "them") if len(over.ids) > 1 else (f"Item {over.ids[0]} is", "it counts", "it")
|
||||
return [f"- {items} filed under a release already cut, so {count} as release {version(over.into)}'s, the next. Move {them} there as this chunk's first change, with `~/.claude/bin/todo-item move`, and say so in the chunk's opening line. Where todo-item cannot move this plan's items, as in a Jira plan, leave {them} and ask the human, in the chunk's summary, to move {them}."]
|
||||
|
||||
|
||||
def joining_details(plan: Plan) -> list[str]:
|
||||
"""The detail of each of the first JOINING_DETAILS items that may join the chunk, in the table's order, and what the worker lacks: an item with no detail, or the items left out."""
|
||||
joining = bundle_candidates(plan.items, plan.first)
|
||||
|
||||
@@ -6,6 +6,7 @@ import typing
|
||||
from failure import Failure
|
||||
from release_plan.todo_table import Item
|
||||
from release_plan.release_standing import LastCut
|
||||
from release_plan.release import Release
|
||||
from project_config import templates
|
||||
|
||||
# The CLI that lists a forge's pull requests: gh for a github.com origin, tea for any other.
|
||||
@@ -20,6 +21,13 @@ class Ran:
|
||||
stderr: str
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CarriedOver:
|
||||
"""The items, by ID in the plan's order, that the plan files under a release already cut, and that count as `into`'s, the next release: release_standing.carried."""
|
||||
into: Release
|
||||
ids: tuple[int, ...]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Plan:
|
||||
"""The default branch's plan items, each with its detail, and `first`: the item the next chunk takes first."""
|
||||
@@ -28,6 +36,8 @@ class Plan:
|
||||
# first's tagline and detail.
|
||||
text: str
|
||||
branch_template: str
|
||||
# The items of a release already cut, which `items` and `first` hold as the next release's. None where every item's release is after the last cut.
|
||||
carried: CarriedOver | None = None
|
||||
|
||||
@property
|
||||
def branch(self) -> str:
|
||||
|
||||
@@ -27,7 +27,9 @@ and prints that the release reviews and the cuts are the human's to call. It pri
|
||||
commits since the cut) and no commit titled `Release review of <release>` followed the tag,
|
||||
finished and ready to cut once one did, and else to be planned first. On a branch with no tag,
|
||||
such a commit counts only where its <release> is after the version under the dated heading.
|
||||
Where todo.md's earliest release is x.y.z or earlier, it says todo.md files items under a release
|
||||
Where todo.md files items under x.y.z or earlier, someone cut a release that still held them:
|
||||
they count as the next release, the earliest after x.y.z that todo.md names or has named
|
||||
since the cut, and a line says to move them there. Where there is no such release, it says todo.md files items under a release
|
||||
already cut;
|
||||
- with --worktree, the item's worktree: a sibling of the checkout named <checkout>-<branch>,
|
||||
each / of the branch a dash, on the branch the config's `branch` template names, which is
|
||||
|
||||
@@ -10,10 +10,10 @@ import unittest
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from project_config.templates import BRANCH
|
||||
from chunk_preflight.gathered import CarriedOver, Gathered, ItemFacts, NamedPath, NoItem, Ran, Worktree
|
||||
from chunk_preflight import choices
|
||||
from failure import Failure
|
||||
from chunk_preflight.choices import forge_of, worktree_add
|
||||
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, NoItem, Ran, Worktree
|
||||
from test_env import isolated_env
|
||||
from release_plan.release_standing import LastCut, UNSEEN_RELEASES
|
||||
from chunk_preflight.main import line_count, ran, seconds, TIMEOUT
|
||||
@@ -54,6 +54,10 @@ Change `src/app.py`'s `run` and the files under `src`, not `gone.py`.
|
||||
SHIPPED = TODO.replace("| 3 | 0.2.0 | | | **Do the next thing.** | 2 | 2 | 3 | 5 | 3 | 1 by 9 | 56.2 |\n", "").replace("| 7 | 0.2.0 | 3 |", "| 7 | 0.2.0 | |").replace("### 3. Do the next thing.", "### 7. Do the thing after.")
|
||||
# The plan once release 0.2.0 has shipped all its items: only release 0.3.0's item 9 is left.
|
||||
LATER = TODO[:TODO.index("| 5 |")] + "| 9 | 0.3.0 | | | **Do a later thing.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 | 90.0 |\n"
|
||||
# Item 9's row, the only one under release 0.3.0.
|
||||
NINTH = "| 9 | 0.3.0 | | | **Do a later thing.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 | 90.0 |\n"
|
||||
# A plan whose release 0.2.0 holds item 3 alone, before release 0.3.0's item 9.
|
||||
SHIPPED_BUT_3 = TODO[:TODO.index("| 5 |")] + "| 3 | 0.2.0 | | | **Do the next thing.** | 2 | 2 | 3 | 5 | 3 | 1 by 9 | 56.2 |\n" + NINTH
|
||||
# An items table that holds no row.
|
||||
EMPTY = TODO[:TODO.index("| 5 |")]
|
||||
CHANGELOG = "# Changelog\n\n## Unreleased\n\n- One.\n - A nested line.\n- Two.\n\n## 0.1.0\n\n- Old.\n"
|
||||
@@ -576,8 +580,27 @@ class Plans(unittest.TestCase):
|
||||
def test_takes_the_earliest_release_where_no_earlier_one_was_named_since_the_last_cut(self):
|
||||
self.assertEqual(planned(LATER, LastCut("v0.1.0", "", 4, [LATER]), "origin/main", BRANCH).first.id, 9)
|
||||
|
||||
def test_counts_the_items_of_a_release_already_cut_as_the_next_releases_and_says_to_move_them(self):
|
||||
plan = planned(TODO, LastCut("v0.2.0", "", 4, []), "origin/main", BRANCH)
|
||||
self.assertEqual((plan.first.id, plan.first.release), (3, (0, 3, 0)))
|
||||
self.assertEqual({item.release for item in plan.items}, {(0, 3, 0)})
|
||||
self.assertEqual(plan.carried, CarriedOver((0, 3, 0), (5, 3, 7, 8)))
|
||||
said = rendered(dataclasses.replace(item_facts(), plan=plan), LastCut("v0.2.0", "", 4, []))
|
||||
self.assertIn("- Items 5, 3, 7 and 8 are filed under a release already cut, so they count as release 0.3.0's, the next.", said)
|
||||
self.assertIn("`~/.claude/bin/todo-item move`", said)
|
||||
self.assertIn("- The next release, after the last cut, that origin/main's todo.md names: 0.3.0. Its first item that does not wait: item 3,", said)
|
||||
self.assertNotIn("already cut", rendered(item_facts()))
|
||||
|
||||
def test_says_to_move_one_or_two_items_of_a_release_already_cut_in_the_singular_or_the_plural(self):
|
||||
cut = LastCut("v0.2.0", "", 4, [])
|
||||
for todo, ids, said in ((SHIPPED_BUT_3, (3,), "- Item 3 is filed under a release already cut, so it counts as release 0.3.0's, the next. Move it there"), (SHIPPED_BUT_3 + NINTH.replace("| 9 | 0.3.0 |", "| 4 | 0.1.0 |"), (3, 4), "- Items 3 and 4 are filed under a release already cut, so they count as release 0.3.0's, the next. Move them there")):
|
||||
with self.subTest(ids=ids):
|
||||
plan = planned(todo, cut, "origin/main", BRANCH)
|
||||
self.assertEqual(plan.carried, CarriedOver((0, 3, 0), ids))
|
||||
self.assertIn(said, rendered(dataclasses.replace(item_facts(), plan=plan), cut))
|
||||
|
||||
def test_says_the_plan_files_items_under_a_release_already_cut(self):
|
||||
why = planned(TODO, LastCut("v0.2.0", "", 4, []), "origin/main", BRANCH).why
|
||||
why = planned(TODO.replace(NINTH, ""), LastCut("v0.2.0", "", 4, []), "origin/main", BRANCH).why
|
||||
self.assertIn("release 0.2.0", why)
|
||||
self.assertIn("v0.2.0", why)
|
||||
self.assertIn("not after", why)
|
||||
|
||||
@@ -984,7 +984,9 @@ class Routing(unittest.TestCase):
|
||||
|
||||
def test_routes_on_no_item_where_the_release_after_the_last_cut_has_none(self):
|
||||
self.assertEqual(routed_item(TODO, LastCut("v0.1.0", "", 3, [TODO])).id, 3)
|
||||
self.assertIsNone(routed_item(TODO, LastCut("v0.2.0", "", 3, [TODO])))
|
||||
# Someone cut 0.2.0 while it held items: they count as 0.3.0's, the next release, and where no later release is known, no item routes.
|
||||
self.assertEqual(routed_item(TODO, LastCut("v0.2.0", "", 3, [TODO])).id, 3)
|
||||
self.assertIsNone(routed_item(re.sub(r"(?m)^\| \d+ \| 0\.3\.0 \|.*\n", "", TODO), LastCut("v0.2.0", "", 3, [])))
|
||||
later_only = TODO[:TODO.index("| 7 |")] + TODO[TODO.index("| 1 | 0.3.0 |"):]
|
||||
self.assertIsNone(routed_item(later_only, LastCut("v0.1.0", "", 3, [TODO])))
|
||||
self.assertIsNone(routed_item(later_only, LastCut("v0.1.0", "", 0, [TODO])))
|
||||
@@ -1125,7 +1127,7 @@ class RouteSources(unittest.TestCase):
|
||||
def test_routes_on_the_plan_item_and_says_why_it_routes_on_the_projects_rung(self):
|
||||
self.assertIsNone(chunk_start.plan_item(DefaultPlan(plan_of(""), NO_CUT), FakeEffects().effects()))
|
||||
self.assertEqual(chunk_start.plan_item(DefaultPlan(plan_of(TODO), LastCut("v0.1.0", "", 3, [TODO])), FakeEffects().effects()).id, 3)
|
||||
self.assertIsNone(chunk_start.plan_item(DefaultPlan(plan_of(TODO), LastCut("v0.2.0", "", 3, [TODO])), FakeEffects().effects()))
|
||||
self.assertIsNone(chunk_start.plan_item(DefaultPlan(plan_of(TODO), LastCut("v0.3.0", "", 3, [TODO])), FakeEffects().effects()))
|
||||
unreadable = Failure("git show origin/main:todo.md printed text that is not UTF-8")
|
||||
for plan, said in ((DefaultPlan(plan_of(TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |")), NO_CUT), "routing on the project's rung: item 3's L 'x' is not a whole number from 1 to 4\n"), (DefaultPlan(unreadable, NO_CUT), f"routing on the project's rung: {unreadable.reason}\n"), (Failure("no origin remote"), "routing on the project's rung: no origin remote\n")):
|
||||
with self.subTest(said=said):
|
||||
|
||||
@@ -72,6 +72,13 @@ class PlanStoreContract:
|
||||
self.assertEqual(self.items(store)[id_].release, release_of("0.3.0"))
|
||||
self.assertEqual(self.items(store)[id_].detail, "")
|
||||
|
||||
def test_an_edit_with_a_comment_sets_the_fields_as_one_without(self) -> None:
|
||||
store = self.new_store()
|
||||
id_ = self.filed(store, FIRST, "Why it counts.")
|
||||
self.assertEqual(store.edit(id_, {"L": "2"}, None, "A small change to one module."), Written(id_))
|
||||
item = self.items(store)[id_]
|
||||
self.assertEqual((item.scores["L"], item.detail), (2, "Why it counts."))
|
||||
|
||||
def test_finish_removes_the_item_and_keeps_the_others(self) -> None:
|
||||
store = self.new_store()
|
||||
first, second = self.filed(store, FIRST, "Why it counts."), self.filed(store, SECOND, "Later detail.")
|
||||
|
||||
@@ -12,6 +12,8 @@ class MemoryPlan:
|
||||
"""A plan held in memory, as a tracker holds one: in the order filed, unranked, with no bar. Where fails is set, every read and write fails with it as the reason."""
|
||||
rows: dict[int, dict[str, str]] = dataclasses.field(default_factory=dict)
|
||||
details: dict[int, str] = dataclasses.field(default_factory=dict)
|
||||
# Each comment an edit gave, under its item's ID, as a tracker posts them on the item's issue.
|
||||
comments: dict[int, list[str]] = dataclasses.field(default_factory=dict)
|
||||
next_id: int = 1
|
||||
label: str = "the plan in memory"
|
||||
tracked: str | None = None
|
||||
@@ -26,10 +28,13 @@ class MemoryPlan:
|
||||
def add(self, fields: dict[str, str], detail: str) -> Written | Failure:
|
||||
return self.put(self.next_id, cells(fields), detail)
|
||||
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None) -> Written | Failure:
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
|
||||
if id_ not in self.rows:
|
||||
return Failure(f"{self.label} holds no item {id_}")
|
||||
return self.put(id_, self.rows[id_] | cells(fields), self.details.get(id_, "") if detail is None else detail)
|
||||
written = self.put(id_, self.rows[id_] | cells(fields), self.details.get(id_, "") if detail is None else detail)
|
||||
if comment is not None and isinstance(written, Written):
|
||||
self.comments.setdefault(id_, []).append(comment)
|
||||
return written
|
||||
|
||||
def finish(self, id_: int) -> Written | Failure:
|
||||
if self.fails or id_ not in self.rows:
|
||||
|
||||
+103
-9
@@ -1,8 +1,8 @@
|
||||
"""A plan kept as the child issues of one Jira Cloud epic, read, filed into and finished over Jira's REST API.
|
||||
"""A plan kept as the child issues of one Jira Cloud epic, read, filed into, edited and finished over Jira's REST API.
|
||||
|
||||
An item is an open child issue. Its ID is the issue's number, so every child must be in the epic's own Jira project: ABC-34 is item 34 of the plan under ABC-12. The summary is the tagline, the description the detail, the earliest Fix Version the release, and an "is blocked by" link a blocker. L, E, I, S, Moves and Exempt sit in one issue property, PROPERTY, which needs no Jira admin to set up; an issue a teammate filed holds none, and reads as an item without scores.
|
||||
An item is an open child issue. Its ID is the issue's number, so every child must be in the epic's own Jira project: ABC-34 is item 34 of the plan under ABC-12. The summary is the tagline, the description the detail, the earliest Fix Version the release, and an "is blocked by" link a blocker. L, E, I, S, Moves and Exempt sit in one issue property, PROPERTY, which needs no Jira admin to set up; an issue a person filed holds none, and reads as an item without scores.
|
||||
|
||||
`add` files an item as a new child issue, marked with FILED_BY, and `finish` moves an item's issue to a done status. edit is a Failure until todo.md's item 382."""
|
||||
`add` files an item as a new child issue, marked with FILED_BY, and `finish` moves an item's issue to a done status. `edit` changes an issue the loop filed, but never its links. Of an issue a person filed it sets only the scores, with a comment that tells the team why."""
|
||||
import base64
|
||||
import dataclasses
|
||||
import pathlib
|
||||
@@ -29,8 +29,7 @@ TIMEOUT = 30
|
||||
PAGE = 100
|
||||
# The pages one read asks for at most, so an answer that never names a last page ends the read.
|
||||
MAX_PAGES = 100
|
||||
READ_ONLY = "the loop doesn't edit an issue of a plan in Jira yet: edit it in Jira"
|
||||
# The key in PROPERTY's value that marks an issue the loop filed, and its value. The loop never edits the summary or description of an issue without it, which a person filed.
|
||||
# The key in PROPERTY's value that marks an issue the loop filed, and its value. An edit of an issue without it, which a person filed, writes only PROPERTY and a comment.
|
||||
FILED_BY = ("Filed by", "loop")
|
||||
# The issue type of an issue the loop files, which Jira Software's project templates all have; a project without it refuses the issue, saying so.
|
||||
ISSUE_TYPE = "Task"
|
||||
@@ -43,6 +42,12 @@ DONE = "done"
|
||||
PERHAPS_FILED = "unless Jira refused the request, the issue may exist: look under {epic} before filing the item again"
|
||||
# What a failed move ends with, for the same reason.
|
||||
PERHAPS_MOVED = "unless Jira refused the request, the issue may have moved: look at {key} before finishing the item again"
|
||||
# What a failed edit ends with, for the same reason.
|
||||
PERHAPS_EDITED = "unless Jira refused the request, the issue may have changed: look at {key} before editing the item again"
|
||||
# The scores a caller sets, L, E, I and S; R is worked out from them.
|
||||
SET_SCORES = tuple(name for name in SHAPE.score_columns if name not in SHAPE.derived)
|
||||
# The fields of PROPERTY's value that an edit may set.
|
||||
SCORED = (*SET_SCORES, MOVES, "Exempt")
|
||||
|
||||
# Sends a request with the Authorization header given, the body as JSON where there is one, and returns the JSON answer, None where the answer has no body, or a Failure saying why there is none.
|
||||
Http = typing.Callable[[str, str, str, object], object]
|
||||
@@ -151,7 +156,7 @@ class JiraPlan:
|
||||
if isinstance(versions, Failure):
|
||||
return Failure(f"cannot read {project}'s Fix Versions: {versions.reason}")
|
||||
names = {name for version in versions if isinstance(version, dict) and isinstance(name := version.get("name"), str)} if isinstance(versions, list) else set()
|
||||
return next((name for name in (release, f"v{release}") if name in names), None) or Failure(f"the Jira project {project} has no Fix Version {release} or v{release}; create it in Jira, or file the item under a release it has")
|
||||
return next((name for name in (release, f"v{release}") if name in names), None) or Failure(f"the Jira project {project} has no Fix Version {release} or v{release}; create it in Jira, or name a release it has")
|
||||
|
||||
def missing_blocker(self, blockers: tuple[str, ...], authorization: str) -> Failure | None:
|
||||
"""A Failure naming the first of blockers that is no open child of the epic. `item` reads only an open child as a blocker, so a link to any other issue would be lost on the next read."""
|
||||
@@ -161,8 +166,48 @@ class JiraPlan:
|
||||
held = {raw.get("key") for raw in answered if isinstance(raw, dict)}
|
||||
return next((Failure(f"{self.label} holds no item {number(blocker)} to be blocked by") for blocker in blockers if blocker not in held), None)
|
||||
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None) -> Written | Failure:
|
||||
return Failure(READ_ONLY)
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
|
||||
"""Sets the fields and the detail in one request, so Jira takes all of the edit or none, and then posts comment on the issue. `revision_of` says what an edit may set.
|
||||
|
||||
A comment Jira refuses leaves the edit made, so the write counts as landed, and a note says to post the comment by hand."""
|
||||
authorization = basic_auth(self.env_file)
|
||||
if isinstance(authorization, Failure):
|
||||
return authorization
|
||||
answered = children(self.epic, authorization, self.http)
|
||||
if isinstance(answered, Failure):
|
||||
return answered
|
||||
key = f"{project_of(self.epic.key)}-{id_}"
|
||||
raw = next((raw for raw in answered if isinstance(raw, dict) and raw.get("key") == key), None)
|
||||
if raw is None:
|
||||
return Failure(f"{self.label} holds no item {id_}")
|
||||
issue = issue_of(raw)
|
||||
if isinstance(issue, Failure):
|
||||
return issue
|
||||
revision = revision_of(issue, cells(fields), detail, comment)
|
||||
if isinstance(revision, Failure):
|
||||
return revision
|
||||
body = revision.body
|
||||
if detail is not None:
|
||||
description = self.to_adf(detail) if detail.strip() else None
|
||||
if isinstance(description, Failure):
|
||||
return Failure(f"cannot convert the item's detail to a Jira description: {description.reason}")
|
||||
body = body | {"fields": body.get("fields", {}) | {"description": description}}
|
||||
said = self.to_adf(comment) if comment and comment.strip() else None
|
||||
if isinstance(said, Failure):
|
||||
return Failure(f"cannot convert the comment to a Jira comment: {said.reason}")
|
||||
if revision.release is not None:
|
||||
version = self.fix_version(revision.release, authorization)
|
||||
if isinstance(version, Failure):
|
||||
return version
|
||||
body = body | {"fields": body.get("fields", {}) | {"fixVersions": [{"name": version}]}}
|
||||
url = f"{self.epic.site}/rest/api/3/issue/{key}"
|
||||
edited = self.http("PUT", url, authorization, body)
|
||||
if isinstance(edited, Failure):
|
||||
return Failure(f"cannot edit {key}: {edited.reason}; {PERHAPS_EDITED.format(key=key)}")
|
||||
if said is None:
|
||||
return Written(id_)
|
||||
posted = self.http("POST", f"{url}/comment", authorization, {"body": said})
|
||||
return Written(id_, (f"edited {key}, but cannot post the comment: {posted.reason}; post it in Jira",) if isinstance(posted, Failure) else ())
|
||||
|
||||
def finish(self, id_: int) -> Written | Failure:
|
||||
"""Moves item id_'s issue by the transition that the config names, to the status it names. Any open child of the epic may move, whoever filed it."""
|
||||
@@ -231,6 +276,56 @@ def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failu
|
||||
return Filing(issue_fields, release, value, tuple(f"{project}-{blocker}" for blocker in blockers))
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Revision:
|
||||
"""An edit checked as far as the issue and the flags allow. The description, the comment and the Fix Version's name still need the codec or a request."""
|
||||
# The body of the request that edits the issue, without its description and its Fix Version.
|
||||
body: dict[str, typing.Any]
|
||||
# The release to move the issue to; None where the edit names none.
|
||||
release: str | None
|
||||
|
||||
|
||||
def revision_of(issue: Issue, named: dict[str, str], detail: str | None, comment: str | None) -> Revision | Failure:
|
||||
"""The edit of issue that sets the cells in named, and the detail unless None, or why it cannot be made.
|
||||
|
||||
The summary, description and Fix Version of an issue a person filed are the team's, so there an edit may set only SCORED. Jira's screens don't show PROPERTY, so such an edit needs a comment, which tells the team. L, E, I and S are set together, so no issue is left partly scored. An issue the loop filed also keeps the label SECURITY in step with its Exempt. No edit changes a link."""
|
||||
held = issue.scores
|
||||
if not isinstance(held, dict):
|
||||
return Failure(f"{issue.key}'s issue property {PROPERTY} is not a JSON object")
|
||||
if BLOCKED_BY in named:
|
||||
return Failure(f"the loop doesn't change an issue's links: link {issue.key} in Jira")
|
||||
own = held.get(FILED_BY[0]) == FILED_BY[1]
|
||||
if not own and ("Item" in named or "Release" in named or detail is not None):
|
||||
return Failure(f"a person filed {issue.key}, so the loop sets only its scores: change its summary, description and Fix Version in Jira")
|
||||
if not own and not (comment and comment.strip()):
|
||||
return Failure(f"a person filed {issue.key}, and Jira doesn't show its team the scores: pass a comment saying that it is scored, and why")
|
||||
body: dict[str, typing.Any] = {}
|
||||
if "Item" in named:
|
||||
summary = plain(named["Item"]).strip()
|
||||
if not summary:
|
||||
return Failure("the item has no tagline")
|
||||
body["fields"] = {"summary": summary}
|
||||
if unfit := unfit_text(named.get("Item", ""), detail or ""):
|
||||
return unfit
|
||||
release = named.get("Release")
|
||||
if release is not None and parsed(release) is None:
|
||||
return Failure(f"the item's Release {release!r} is not a version such as 1.2.0")
|
||||
if not is_exempt(named.get("Exempt", "")):
|
||||
return Failure(f"the item's Exempt {named['Exempt']!r} is not empty or one of {', '.join(EXEMPTIONS[1:])}")
|
||||
if any(name in named for name in SCORED):
|
||||
texts = {name: str(value) for name, value in held.items()} | {name: named[name] for name in SCORED if name in named}
|
||||
scored = scores(issue.key, texts)
|
||||
if isinstance(scored, Failure):
|
||||
return scored
|
||||
if scored[0] and any(name not in scored[0] for name in SET_SCORES):
|
||||
return Failure(f"{issue.key} would hold some of {', '.join(SET_SCORES)} and not the rest: set them together")
|
||||
value = held | scored[0] | {MOVES: texts.get(MOVES, ""), "Exempt": scored[2]}
|
||||
body["properties"] = [{"key": PROPERTY, "value": value}]
|
||||
if own and (scored[2] == SECURITY) != (held.get("Exempt") == SECURITY):
|
||||
body["update"] = {"labels": [{"add" if scored[2] == SECURITY else "remove": SECURITY}]}
|
||||
return Revision(body, release)
|
||||
|
||||
|
||||
def offer_of(raw: object) -> tuple[str, str, str, str] | None:
|
||||
"""One transition Jira offers, as its ID, its name, the name of the status it leads to and the key of that status's category; None where raw holds no such transition."""
|
||||
to = raw.get("to") if isinstance(raw, dict) else None
|
||||
@@ -350,7 +445,6 @@ def item(issue: Issue, project: str, ids: set[int]) -> Item | Failure:
|
||||
"""The item an issue holds, without its detail. It is blocked by each of its blockers among ids, the plan's items: a blocker that is done or lies outside the epic doesn't make the item wait."""
|
||||
release = earliest_release(issue.fix_versions)
|
||||
if release is None:
|
||||
# Until a project can tie its releases to something other than semver versions, an item with no release cannot be placed in the plan.
|
||||
return Failure(f"{issue.key} names no Fix Version that is a semver version, such as 1.2.0; set one in Jira")
|
||||
scored = scores(issue.key, issue.scores)
|
||||
if isinstance(scored, Failure):
|
||||
|
||||
@@ -47,7 +47,7 @@ class Written:
|
||||
|
||||
|
||||
class PlanStore(typing.Protocol):
|
||||
"""A project's plan. plan_store.contract holds every backend that writes to the same behaviour; `jira_epic` reads, files and finishes, and fails an edit until todo.md's item 382. A write that fails leaves the plan as it was, except where its Failure says the tracker may have taken the write all the same, as when Jira's answer to a new issue or to a move is lost."""
|
||||
"""A project's plan. plan_store.contract holds every backend that writes to the same behaviour; `jira_epic` doesn't hold it yet: it changes no link, and its own tests stand in for Jira. A write that fails leaves the plan as it was, except where its Failure says the tracker may have taken the write all the same, as when Jira's answer to a new issue, an edit or a finish is lost."""
|
||||
|
||||
@property
|
||||
def label(self) -> str:
|
||||
@@ -63,8 +63,10 @@ class PlanStore(typing.Protocol):
|
||||
def add(self, fields: dict[str, str], detail: str) -> Written | Failure:
|
||||
"""Files an item under an ID the backend picks. fields holds each of FIELDS the caller sets; detail may be empty."""
|
||||
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None) -> Written | Failure:
|
||||
"""Sets item id_'s fields to those given, and its detail unless None, leaving the rest. Moving an item sets its Release."""
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
|
||||
"""Sets item id_'s fields to those given, and its detail unless None, leaving the rest. Moving an item sets its Release.
|
||||
|
||||
comment tells the plan's other readers why, in the project's language. A tracker posts it on the item's issue; a backend with no place for comments drops it."""
|
||||
|
||||
def finish(self, id_: int) -> Written | Failure:
|
||||
"""Removes item id_ with its detail."""
|
||||
@@ -98,7 +100,7 @@ class FilePlan:
|
||||
filed = markdown_edits.added(texts[0], cells(fields), detail, self.label)
|
||||
return filed if isinstance(filed, Failure) else self.kept(*filed, texts)
|
||||
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None) -> Written | Failure:
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
|
||||
texts = self.texts()
|
||||
if isinstance(texts, Failure):
|
||||
return texts
|
||||
|
||||
@@ -210,10 +210,6 @@ class JiraPlan(unittest.TestCase):
|
||||
self.pages = [{"issues": [issue("OTHER-5")]}]
|
||||
self.assertNotIn("s3cret", self.store().read().reason) # type: ignore[union-attr]
|
||||
|
||||
def test_edit_fails_since_the_store_does_not_edit_yet(self):
|
||||
self.assertEqual(self.store().edit(34, {"L": "2"}, None), Failure("the loop doesn't edit an issue of a plan in Jira yet: edit it in Jira"))
|
||||
self.assertEqual(self.calls + self.epic_calls, [])
|
||||
|
||||
def test_names_itself_by_the_configs_spelling_and_no_commit_holds_it(self):
|
||||
self.assertEqual((self.store().label, self.store().tracked), ("jira:https://acme.atlassian.net/browse/ABC-12", None))
|
||||
|
||||
@@ -346,7 +342,7 @@ class Filing(unittest.TestCase):
|
||||
for versions in ([{"name": "0.1.0"}], {"name": "0.3.0"}, [], 7):
|
||||
with self.subTest(versions=versions):
|
||||
self.versions = versions
|
||||
self.assertEqual(self.add(FIELDS | {"Release": "0.3.0"}), Failure("the Jira project ABC has no Fix Version 0.3.0 or v0.3.0; create it in Jira, or file the item under a release it has"))
|
||||
self.assertEqual(self.add(FIELDS | {"Release": "0.3.0"}), Failure("the Jira project ABC has no Fix Version 0.3.0 or v0.3.0; create it in Jira, or name a release it has"))
|
||||
self.assertEqual(self.sent(ISSUES), [])
|
||||
|
||||
def test_fix_versions_that_cannot_be_read_fail_before_anything_is_filed(self):
|
||||
@@ -375,6 +371,176 @@ class Filing(unittest.TestCase):
|
||||
TRANSITIONS = "https://acme.atlassian.net/rest/api/3/issue/ABC-34/transitions"
|
||||
|
||||
|
||||
COMMENT = "Scored for planning: a small change to one module."
|
||||
PERHAPS_EDITED = "unless Jira refused the request, the issue may have changed: look at ABC-34 before editing the item again"
|
||||
|
||||
|
||||
class Editing(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.env = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) / "acme.env"
|
||||
self.env.write_text("ATLASSIAN_EMAIL=me@example.com\nATLASSIAN_API_TOKEN=s3cret\n")
|
||||
self.env.chmod(0o600)
|
||||
self.calls: list[tuple[str, str, object]] = []
|
||||
# The loop filed ABC-34. A person filed ABC-35, which nobody scored, and ABC-36, which holds scores.
|
||||
self.open: list[object] = [issue("ABC-34", scores=PROPERTY), issue("ABC-35"), issue("ABC-36", scores={"L": 3, "E": 1, "I": 1, "S": 2})]
|
||||
self.edited: object = None
|
||||
self.commented: object = {"id": "10100"}
|
||||
self.versions: object = [{"name": "0.1.0"}, {"name": "v0.2.0"}]
|
||||
|
||||
def http(self, method: str, url: str, authorization: str, body: object) -> object:
|
||||
"""Stands in for Jira: answers the epic, self.versions for the project's Fix Versions, self.open to the search, self.edited to an edit and self.commented to a new comment."""
|
||||
self.calls.append((method, url, body))
|
||||
assert authorization == AUTHORIZATION
|
||||
if method == "PUT":
|
||||
return self.edited
|
||||
return self.commented if url.endswith("/comment") else {SEARCH: {"issues": self.open}, VERSIONS: self.versions}.get(url, {"key": "ABC-12"})
|
||||
|
||||
def to_adf(self, markdown: str) -> dict[str, object] | Failure:
|
||||
return adf(markdown)
|
||||
|
||||
def edit(self, id_: int, fields: dict[str, str], detail: str | None = None, comment: str | None = None):
|
||||
return jira_epic.JiraPlan(EPIC, self.env, self.http, text_of, self.to_adf).edit(id_, fields, detail, comment)
|
||||
|
||||
def writes(self) -> list[tuple[str, str, object]]:
|
||||
"""Each request that changes Jira, in order."""
|
||||
return [call for call in self.calls if call[0] == "PUT" or call[1].endswith("/comment")]
|
||||
|
||||
def test_sets_the_summary_description_and_scores_of_an_issue_the_loop_filed_in_one_request(self):
|
||||
self.assertEqual(self.edit(34, {"Tagline": "**Count every run.**", "L": "2", "Moves": ""}, "Why it counts."), Written(34))
|
||||
self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {
|
||||
"fields": {"summary": "Count every run.", "description": adf("Why it counts.")},
|
||||
"properties": [{"key": "plan-item", "value": PROPERTY | {"L": 2, "Moves": ""}}],
|
||||
})])
|
||||
|
||||
def test_sends_only_what_the_edit_names(self):
|
||||
self.edit(34, {"Tagline": "Count every run."})
|
||||
self.edit(34, {"E": "3"})
|
||||
self.assertEqual([body for _, _, body in self.writes()], [{"fields": {"summary": "Count every run."}}, {"properties": [{"key": "plan-item", "value": PROPERTY | {"E": 3}}]}])
|
||||
|
||||
def test_an_empty_detail_removes_the_description(self):
|
||||
self.edit(34, {}, " \n")
|
||||
self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {"fields": {"description": None}})])
|
||||
|
||||
def test_an_edit_of_the_release_sets_the_fix_version_as_the_project_spells_it(self):
|
||||
self.assertEqual(self.edit(34, {"Release": "0.2.0"}), Written(34))
|
||||
self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {"fields": {"fixVersions": [{"name": "v0.2.0"}]}})])
|
||||
|
||||
def test_an_edit_of_the_release_and_the_tagline_sends_both(self):
|
||||
self.edit(34, {"Release": "0.2.0", "Tagline": "Count every run."})
|
||||
self.assertEqual(self.writes()[0][2], {"fields": {"summary": "Count every run.", "fixVersions": [{"name": "v0.2.0"}]}})
|
||||
|
||||
def test_an_empty_tagline_fails_before_any_write(self):
|
||||
self.assertEqual(self.edit(34, {"Tagline": "** **"}), Failure("the item has no tagline"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_a_release_the_project_has_no_fix_version_for_fails_before_any_write(self):
|
||||
self.assertEqual(self.edit(34, {"Release": "0.3.0"}), Failure("the Jira project ABC has no Fix Version 0.3.0 or v0.3.0; create it in Jira, or name a release it has"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_an_exempt_that_becomes_or_stops_being_security_adds_or_removes_the_label(self):
|
||||
self.edit(34, {"Exempt": "security"})
|
||||
self.open = [issue("ABC-34", scores=PROPERTY | {"Exempt": "security"})]
|
||||
self.edit(34, {"Exempt": "owner"})
|
||||
self.edit(34, {"Exempt": "security"})
|
||||
self.assertEqual([body.get("update") for _, _, body in self.writes()], [{"labels": [{"add": "security"}]}, {"labels": [{"remove": "security"}]}, None]) # type: ignore[attr-defined]
|
||||
|
||||
def test_scores_an_issue_a_person_filed_and_comments_why(self):
|
||||
self.assertEqual(self.edit(35, {"L": "2", "E": "2", "I": "3", "S": "3", "Moves": "1 by 4"}, None, COMMENT), Written(35))
|
||||
self.assertEqual(self.writes(), [
|
||||
("PUT", f"{ISSUES}/ABC-35", {"properties": [{"key": "plan-item", "value": {"L": 2, "E": 2, "I": 3, "S": 3, "Moves": "1 by 4", "Exempt": ""}}]}),
|
||||
("POST", f"{ISSUES}/ABC-35/comment", {"body": adf(COMMENT)}),
|
||||
])
|
||||
|
||||
def test_rescores_a_persons_issue_that_holds_scores_keeping_the_rest(self):
|
||||
self.edit(36, {"L": "2"}, None, COMMENT)
|
||||
self.assertEqual(self.writes()[0][2], {"properties": [{"key": "plan-item", "value": {"L": 2, "E": 1, "I": 1, "S": 2, "Moves": "", "Exempt": ""}}]})
|
||||
|
||||
def test_a_persons_issue_is_never_labelled(self):
|
||||
self.edit(36, {"Exempt": "security"}, None, COMMENT)
|
||||
self.assertNotIn("update", self.writes()[0][2]) # type: ignore[operator]
|
||||
|
||||
def test_scoring_a_persons_issue_without_a_comment_fails_before_any_write(self):
|
||||
for comment in (None, "", " \n"):
|
||||
with self.subTest(comment=comment):
|
||||
self.assertEqual(self.edit(35, {"L": "2"}, None, comment), Failure("a person filed ABC-35, and Jira doesn't show its team the scores: pass a comment saying that it is scored, and why"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_what_a_person_wrote_or_planned_is_never_edited(self):
|
||||
for fields, detail in (({"Tagline": "Count every run."}, None), ({}, "Why."), ({}, ""), ({"Release": "0.2.0"}, None), ({"Tagline": "Count.", "Release": "0.2.0", "L": "1"}, "")):
|
||||
with self.subTest(fields=fields, detail=detail):
|
||||
self.assertEqual(self.edit(36, fields, detail, COMMENT), Failure("a person filed ABC-36, so the loop sets only its scores: change its summary, description and Fix Version in Jira"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_scoring_an_unscored_issue_in_part_fails_before_any_write(self):
|
||||
self.assertEqual(self.edit(35, {"L": "2", "E": "2"}, None, COMMENT), Failure("ABC-35 would hold some of L, E, I, S and not the rest: set them together"))
|
||||
self.assertEqual(self.edit(35, {"Exempt": "question"}, None, COMMENT), Written(35))
|
||||
self.assertEqual(len(self.writes()), 2)
|
||||
|
||||
def test_a_comment_on_an_edit_of_the_loops_own_issue_is_posted_too(self):
|
||||
self.edit(34, {"L": "2"}, None, COMMENT)
|
||||
self.assertEqual(self.writes()[1], ("POST", f"{ISSUES}/ABC-34/comment", {"body": adf(COMMENT)}))
|
||||
|
||||
def test_a_comment_jira_refuses_leaves_the_edit_made_with_a_note(self):
|
||||
self.commented = Failure("HTTP 403")
|
||||
self.assertEqual(self.edit(36, {"L": "2"}, None, COMMENT), Written(36, ("edited ABC-36, but cannot post the comment: HTTP 403; post it in Jira",)))
|
||||
|
||||
def test_an_edit_of_the_blockers_fails_since_the_store_changes_no_link(self):
|
||||
self.assertEqual(self.edit(34, {"Blocked by": "35"}), Failure("the loop doesn't change an issue's links: link ABC-34 in Jira"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_an_issue_that_is_no_open_child_of_the_epic_is_not_edited(self):
|
||||
self.assertEqual(self.edit(40, {"L": "2"}), Failure("jira:https://acme.atlassian.net/browse/ABC-12 holds no item 40"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_each_field_out_of_format_fails_before_any_write_saying_how(self):
|
||||
for fields, detail, reason in (
|
||||
({"L": "9"}, None, "item ABC-34's L '9' is not a whole number from 1 to 4"),
|
||||
({"Moves": "much"}, None, "item ABC-34's Moves 'much' is not"),
|
||||
({"Exempt": "tired"}, None, f"the item's Exempt 'tired' is not empty or one of {', '.join(EXEMPTIONS[1:])}"),
|
||||
({"Release": "soon"}, None, "the item's Release 'soon' is not a version such as 1.2.0"),
|
||||
({"Tagline": " "}, None, "the item has no tagline"),
|
||||
({"Tagline": "Count\nruns."}, None, "the tagline holds a line break; keep it on one line"),
|
||||
({}, "## Why", "the detail holds a ## or ### heading"),
|
||||
):
|
||||
with self.subTest(fields=fields, detail=detail):
|
||||
failed = self.edit(34, fields, detail)
|
||||
self.assertIsInstance(failed, Failure)
|
||||
self.assertIn(reason, failed.reason)
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_a_detail_or_a_comment_that_does_not_convert_fails_before_any_write(self):
|
||||
self.to_adf = lambda markdown: Failure("the codec is down") # type: ignore[method-assign]
|
||||
self.assertEqual(self.edit(34, {}, "Why."), Failure("cannot convert the item's detail to a Jira description: the codec is down"))
|
||||
self.assertEqual(self.edit(34, {"L": "2"}, None, COMMENT), Failure("cannot convert the comment to a Jira comment: the codec is down"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_an_edit_jira_refuses_fails_with_jiras_reason_and_posts_no_comment(self):
|
||||
self.edited = Failure("HTTP 400: Summary is too long")
|
||||
self.assertEqual(self.edit(34, {"L": "2"}, None, COMMENT), Failure(f"cannot edit ABC-34: HTTP 400: Summary is too long; {PERHAPS_EDITED}"))
|
||||
self.assertEqual(len(self.writes()), 1)
|
||||
|
||||
def test_an_issue_in_another_shape_or_a_search_that_fails_fails_the_edit(self):
|
||||
self.open = [{"key": "ABC-34", "fields": {}}]
|
||||
self.assertIn("ABC-34 is not in the shape", self.edit(34, {"L": "2"}).reason)
|
||||
self.open = [issue("ABC-34", scores=["odd"])] # type: ignore[arg-type]
|
||||
self.assertEqual(self.edit(34, {"L": "2"}), Failure("ABC-34's issue property plan-item is not a JSON object"))
|
||||
self.assertEqual(self.writes(), [])
|
||||
|
||||
def test_a_missing_env_file_fails_before_any_request(self):
|
||||
self.env.unlink()
|
||||
self.assertIsInstance(self.edit(34, {"L": "2"}), Failure)
|
||||
self.assertEqual(self.calls, [])
|
||||
|
||||
def test_what_it_edits_reads_back_as_the_item(self):
|
||||
self.edit(34, {"Tagline": "Count every run.", "S": "4"}, "Why it counts.")
|
||||
body = self.writes()[0][2]
|
||||
held = issue("ABC-34", summary=body["fields"]["summary"], scores=body["properties"][0]["value"], description=body["fields"]["description"]) # type: ignore[index]
|
||||
self.open = [held]
|
||||
plan = jira_epic.JiraPlan(EPIC, self.env, self.http, lambda documents: [text_of(document) for document in documents]).read()
|
||||
assert isinstance(plan, Plan), plan
|
||||
self.assertEqual((plan.items[0].tagline, plan.items[0].scores["S"], plan.items[0].scores["L"], plan.items[0].detail), ("**Count every run.**", 4, 1, "Why it counts."))
|
||||
|
||||
|
||||
def transition(id_: str, name: str, status: str, category: str = "done") -> dict[str, object]:
|
||||
return {"id": id_, "name": name, "to": {"name": status, "statusCategory": {"key": category}}}
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@ save refuses them: edit the epic in Jira.
|
||||
|
||||
open prints the path of a file holding the record's text, and nothing else. Read and edit that
|
||||
file. Where the record is kept as a file, the path is that file. Where it is kept elsewhere, the
|
||||
path is a copy under ~/.local/state/project-record/<key>/, written afresh with the record as it
|
||||
stands, so open it again before each edit. A record that doesn't exist yet has no file at the path:
|
||||
path is a copy under ~/.local/state/project-record/<key>/<worktree>/, a folder named for the
|
||||
worktree that ran open, so two worktrees of one project don't share a copy. The copy is written
|
||||
afresh with the record as it stands, so open it again before each edit. open also removes the
|
||||
folders of worktrees git no longer lists. A record that doesn't exist yet has no file at the path:
|
||||
create it there.
|
||||
|
||||
save stores the file's text in the record, and prints one line saying so. Where the record is kept
|
||||
@@ -24,17 +26,20 @@ writes the copy afresh.
|
||||
|
||||
Exit 2 on bad arguments, and 1, saying why, on any other failure.
|
||||
"""
|
||||
import hashlib
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from failure import Failure
|
||||
from record_store.stores import FileStore, goals_store, local_file, RECORDS, RecordStore, store, stored
|
||||
from git_cli.git_repo import git, Git
|
||||
from project_config.main import located
|
||||
from project_config.settings import ProjectConfig
|
||||
|
||||
# Not git's verbs, such as checkout and commit: those read as acting on the repo.
|
||||
COMMANDS = ("open", "save")
|
||||
# Where the copy of a record kept outside files goes, under the user's home, in a folder per project.
|
||||
# Where the copy of a record kept outside files goes, under the user's home, in a folder per project and worktree.
|
||||
COPIES = ".local/state/project-record"
|
||||
# The goals file opens like a record, though it is a setting of its own.
|
||||
GOALS = "goals-and-audience"
|
||||
@@ -49,7 +54,7 @@ def main(argv: list[str]) -> int:
|
||||
return 2
|
||||
home = pathlib.Path.home()
|
||||
config = located(None, home)
|
||||
done = config if isinstance(config, Failure) else act(argv[0], *opened(config, argv[1], home))
|
||||
done = config if isinstance(config, Failure) else performed(config, argv[0], argv[1], home)
|
||||
if isinstance(done, Failure):
|
||||
print(f"project-record: {done.reason}", file=sys.stderr)
|
||||
return 1
|
||||
@@ -57,12 +62,36 @@ def main(argv: list[str]) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def performed(config: ProjectConfig, command: str, name: str, home: pathlib.Path, run: Git = git) -> str | Failure:
|
||||
"""What command, one of COMMANDS, prints for the record called name. An open also prunes the copies of removed worktrees."""
|
||||
if command == "open":
|
||||
pruned(config, home, run)
|
||||
return act(command, *opened(config, name, home))
|
||||
|
||||
|
||||
def opened(config: ProjectConfig, name: str, home: pathlib.Path) -> tuple[RecordStore, pathlib.Path]:
|
||||
"""The store of the record called name, and the copy it gets where it isn't kept as a file. A store that keeps the version it read, for a later save, keeps it beside the copy."""
|
||||
copy = home / COPIES / config.key / f"{name}.md"
|
||||
copy = home / COPIES / config.key / worktree_folder(config.top) / f"{name}.md"
|
||||
return (goals_store(config) if name == GOALS else store(config, name, copy.with_suffix(".version"))), copy
|
||||
|
||||
|
||||
def worktree_folder(top: pathlib.Path) -> str:
|
||||
"""The name of the folder that holds the copies of the worktree at top: the worktree's own name, for a reader, and a hash of its path, since two worktrees in different folders may share a name."""
|
||||
return f"{top.name}-{hashlib.sha256(str(top).encode()).hexdigest()[:8]}"
|
||||
|
||||
|
||||
def pruned(config: ProjectConfig, home: pathlib.Path, run: Git = git) -> None:
|
||||
"""Remove the copies of the worktrees git no longer lists, so the folders don't pile up one per chunk. Best effort: a folder that stays only takes disk, and where git can't list the worktrees nothing is removed."""
|
||||
listed = run("worktree", "list", "--porcelain")
|
||||
folders = home / COPIES / config.key
|
||||
if isinstance(listed, Failure) or not folders.is_dir():
|
||||
return
|
||||
worktrees = [config.top, *(pathlib.Path(line.removeprefix("worktree ")) for line in listed.splitlines() if line.startswith("worktree "))]
|
||||
kept = {worktree_folder(worktree) for worktree in worktrees}
|
||||
for stale in (folder for folder in folders.iterdir() if folder.is_dir() and folder.name not in kept):
|
||||
shutil.rmtree(stale, ignore_errors=True)
|
||||
|
||||
|
||||
def act(command: str, record: RecordStore, copy: pathlib.Path) -> str | Failure:
|
||||
"""What command, one of COMMANDS, prints for record. copy is where a record kept outside files gets its file."""
|
||||
if command == "open":
|
||||
|
||||
@@ -17,19 +17,92 @@ from project_config.settings import Page, ProjectConfig
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-record"
|
||||
|
||||
|
||||
COPIES = pathlib.Path("/home/me/.local/state/project-record/acme")
|
||||
|
||||
|
||||
def worktree_config(top: str, **kept: Page) -> ProjectConfig:
|
||||
return ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), pathlib.Path(top), {"goals-and-audience": pathlib.Path(top, "README.md")}, pathlib.Path("/home/me/acme.env"), pages=kept)
|
||||
|
||||
|
||||
class Opened(unittest.TestCase):
|
||||
def test_a_record_on_a_confluence_page_keeps_the_version_it_read_beside_its_copy(self):
|
||||
page = Page("https://acme.atlassian.net", "2293761", "confluence:https://acme.atlassian.net/wiki/spaces/ENG/pages/2293761")
|
||||
config = ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), pathlib.Path("/code/acme"), {}, pathlib.Path("/home/me/acme.env"), pages={"decisions": page})
|
||||
record, copy = main.opened(config, "decisions", pathlib.Path("/home/me"))
|
||||
self.assertEqual(copy, pathlib.Path("/home/me/.local/state/project-record/acme/decisions.md"))
|
||||
record, copy = main.opened(worktree_config("/code/acme", decisions=page), "decisions", pathlib.Path("/home/me"))
|
||||
self.assertEqual((copy.parent.parent, copy.name), (COPIES, "decisions.md"))
|
||||
self.assertRegex(copy.parent.name, r"^acme-[0-9a-f]{8}$")
|
||||
assert isinstance(record, ConfluencePage), record
|
||||
self.assertEqual(record.kept, pathlib.Path("/home/me/.local/state/project-record/acme/decisions.version"))
|
||||
self.assertEqual(record.kept, copy.with_suffix(".version"))
|
||||
|
||||
def test_the_goals_file_opens_through_the_goals_store(self):
|
||||
config = ProjectConfig("acme", pathlib.Path("/home/me/.claude-projects/acme"), pathlib.Path("/code/acme"), {"goals-and-audience": pathlib.Path("/code/acme/README.md")})
|
||||
record, copy = main.opened(config, "goals-and-audience", pathlib.Path("/home/me"))
|
||||
self.assertEqual((record.label, copy), ("/code/acme/README.md", pathlib.Path("/home/me/.local/state/project-record/acme/goals-and-audience.md")))
|
||||
record, copy = main.opened(worktree_config("/code/acme"), "goals-and-audience", pathlib.Path("/home/me"))
|
||||
self.assertEqual((record.label, copy.parent.parent, copy.name), ("/code/acme/README.md", COPIES, "goals-and-audience.md"))
|
||||
|
||||
def test_two_worktrees_of_one_project_get_copies_that_differ(self):
|
||||
home = pathlib.Path("/home/me")
|
||||
main_checkout = main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1]
|
||||
other = main.opened(worktree_config("/code/acme-item-5"), "goals-and-audience", home)[1]
|
||||
self.assertNotEqual(main_checkout, other)
|
||||
|
||||
def test_one_worktree_always_gets_the_same_copy(self):
|
||||
home = pathlib.Path("/home/me")
|
||||
first = main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1]
|
||||
self.assertEqual(first, main.opened(worktree_config("/code/acme"), "goals-and-audience", home)[1])
|
||||
|
||||
def test_two_worktrees_named_alike_in_different_folders_get_copies_that_differ(self):
|
||||
home = pathlib.Path("/home/me")
|
||||
first = main.opened(worktree_config("/code/acme-item-5"), "goals-and-audience", home)[1]
|
||||
second = main.opened(worktree_config("/other/acme-item-5"), "goals-and-audience", home)[1]
|
||||
self.assertNotEqual(first, second)
|
||||
|
||||
|
||||
class Pruned(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||
self.config = worktree_config("/code/acme-item-5")
|
||||
self.folders = self.home / ".local/state/project-record/acme"
|
||||
for top in ("/code/acme", "/code/acme-item-5", "/code/acme-item-6"):
|
||||
copy = main.opened(worktree_config(top), "goals-and-audience", self.home)[1]
|
||||
copy.parent.mkdir(parents=True)
|
||||
copy.write_text("edit")
|
||||
|
||||
def kept(self) -> set[str]:
|
||||
return {folder.name for folder in self.folders.iterdir()}
|
||||
|
||||
def listed(self, *tops: str):
|
||||
return lambda *args, **kwargs: "" if args != ("worktree", "list", "--porcelain") else "".join(f"worktree {top}\nHEAD abc\nbranch refs/heads/x\n\n" for top in tops)
|
||||
|
||||
def test_removes_the_copies_of_worktrees_git_no_longer_lists_and_keeps_the_others(self):
|
||||
main.pruned(self.config, self.home, self.listed("/code/acme", "/code/acme-item-5"))
|
||||
self.assertEqual(self.kept(), {main.worktree_folder(pathlib.Path(top)) for top in ("/code/acme", "/code/acme-item-5")})
|
||||
|
||||
def test_always_keeps_the_copy_of_the_worktree_that_asked(self):
|
||||
main.pruned(self.config, self.home, self.listed("/code/acme"))
|
||||
self.assertIn(main.worktree_folder(pathlib.Path("/code/acme-item-5")), self.kept())
|
||||
|
||||
def test_removes_nothing_where_git_cannot_list_the_worktrees(self):
|
||||
main.pruned(self.config, self.home, lambda *args, **kwargs: Failure("not a repository"))
|
||||
self.assertEqual(len(self.kept()), 3)
|
||||
|
||||
def test_leaves_files_beside_the_folders_alone(self):
|
||||
(self.folders / "decisions.md").write_text("from before the folders")
|
||||
main.pruned(self.config, self.home, self.listed("/code/acme"))
|
||||
self.assertTrue((self.folders / "decisions.md").exists())
|
||||
|
||||
def test_a_copy_that_cannot_be_removed_does_not_fail_the_open(self):
|
||||
self.folders.chmod(0o500)
|
||||
self.addCleanup(self.folders.chmod, 0o700)
|
||||
main.pruned(self.config, self.home, self.listed("/code/acme"))
|
||||
self.assertEqual(len(self.kept()), 3)
|
||||
|
||||
def test_an_open_prunes_and_a_save_does_not(self):
|
||||
run = self.listed("/code/acme", "/code/acme-item-5")
|
||||
self.assertEqual(main.performed(self.config, "save", "goals-and-audience", self.home, run), "/code/acme-item-5/README.md is the record itself, so nothing is left to store.")
|
||||
self.assertEqual(len(self.kept()), 3)
|
||||
self.assertEqual(main.performed(self.config, "open", "goals-and-audience", self.home, run), "/code/acme-item-5/README.md")
|
||||
self.assertEqual(self.kept(), {main.worktree_folder(pathlib.Path(top)) for top in ("/code/acme", "/code/acme-item-5")})
|
||||
|
||||
def test_does_nothing_where_the_project_has_no_copies(self):
|
||||
main.pruned(worktree_config("/code/acme"), self.home / "elsewhere", self.listed("/code/acme"))
|
||||
|
||||
|
||||
class Act(unittest.TestCase):
|
||||
|
||||
@@ -156,18 +156,32 @@ def todos_since(tag: str | None | Failure, ref: str, plan: str | None, cwd: str,
|
||||
def chunk_item(found: list[Item], cut: LastCut) -> Pick:
|
||||
"""The pick from todo.md's items, weighed against the last cut. Routing and chunk-preflight both pick with it, so they name one item."""
|
||||
upcoming = next_release(found, cut)
|
||||
return standing(upcoming, next_item(found), cut.reviewed) if isinstance(upcoming, Upcoming) else upcoming
|
||||
return standing(upcoming, next_item(carried(found, cut)), cut.reviewed) if isinstance(upcoming, Upcoming) else upcoming
|
||||
|
||||
|
||||
def carried(found: list[Item], cut: LastCut) -> list[Item]:
|
||||
"""found, with the release of each item that the plan files under the last cut's version, or an earlier one, replaced by the next release: the earliest after the cut that the plan holds or todo.md has named since it.
|
||||
|
||||
Someone cut a release while it held those items, and the loop works on: lilleman's call, 2026-11-16. found itself where nothing is cut, and where no release after the cut is known, since naming one is the human's.
|
||||
"""
|
||||
version = cut_version(cut)
|
||||
named = named_releases(cut.todos_since)
|
||||
known = {item.release for item in found} | (set() if isinstance(named, Failure) else named)
|
||||
after = set() if version is None else {release for release in known if release > version}
|
||||
if not after or all(item.release >= min(after) for item in found):
|
||||
return found
|
||||
return [dataclasses.replace(item, release=max(item.release, min(after))) for item in found]
|
||||
|
||||
|
||||
def next_release(found: list[Item], cut: LastCut) -> Upcoming | Cut | Unknown:
|
||||
"""The next release after cut, and whether work has landed towards it. found holds the plan's items.
|
||||
|
||||
Cut where the plan files items under the last cut's version or earlier, and Unknown where the tags, or todo.md's texts since the cut, cannot be read.
|
||||
Cut where the plan files items under the last cut's version or earlier and no later release is known for carried to file them under, and Unknown where the tags, or todo.md's texts since the cut, cannot be read.
|
||||
Where the branch has no tag, todos_since holds every version of todo.md, so a release todo.md named whose items are all done still reads as the next release.
|
||||
"""
|
||||
if isinstance(cut.tag, Failure):
|
||||
return Unknown()
|
||||
earliest = min((item.release for item in found), default=None)
|
||||
earliest = min((item.release for item in carried(found, cut)), default=None)
|
||||
version = cut_version(cut)
|
||||
if version is None:
|
||||
return Upcoming(earliest, True, has_unreleased(cut))
|
||||
@@ -186,6 +200,7 @@ def next_release(found: list[Item], cut: LastCut) -> Upcoming | Cut | Unknown:
|
||||
|
||||
def cut_version(cut: LastCut) -> Release | None:
|
||||
"""Which version is cut. It is the tag's, or None where the tag names no version. On a branch with no tag, it is the newest version under a dated CHANGELOG.md heading, else BEFORE_FIRST_RELEASE."""
|
||||
# The loop reads no other mark of a cut, such as another tag spelling or a Jira Fix Version marked released, until lilleman says to add one: his call, 2026-11-16.
|
||||
if cut.tag is None:
|
||||
return dated_cut(cut.tag, cut.changelog) or BEFORE_FIRST_RELEASE
|
||||
return tagged(cut.tag) if isinstance(cut.tag, str) else None
|
||||
|
||||
@@ -77,6 +77,33 @@ class NextRelease(unittest.TestCase):
|
||||
self.assertEqual(release_standing.next_release([one((1, 3, 0))], cut(Failure("count unreadable"))), release_standing.Upcoming((1, 3, 0), True, Failure("count unreadable")))
|
||||
|
||||
|
||||
class Carried(unittest.TestCase):
|
||||
def test_files_each_item_of_a_release_already_cut_under_the_earliest_release_the_plan_names_after_the_cut(self):
|
||||
held = [dataclasses.replace(one((1, 2, 3)), id=1), dataclasses.replace(one((1, 2, 0)), id=2), dataclasses.replace(one((1, 4, 0)), id=3), dataclasses.replace(one((1, 3, 0)), id=4)]
|
||||
carried = release_standing.carried(held, release_standing.LastCut("v1.2.3", "", 4, []))
|
||||
self.assertEqual([(item.id, item.release) for item in carried], [(1, (1, 3, 0)), (2, (1, 3, 0)), (3, (1, 4, 0)), (4, (1, 3, 0))])
|
||||
|
||||
def test_leaves_the_plan_as_it_is_where_nothing_is_cut_or_it_names_no_release_after_the_cut(self):
|
||||
held = [one((1, 2, 3))]
|
||||
for tag in ("v1.2.3", "v1.2.2", None, Failure("tags unreadable")):
|
||||
with self.subTest(tag=tag):
|
||||
self.assertIs(release_standing.carried(held, release_standing.LastCut(tag, "", 4, [])), held)
|
||||
|
||||
def test_files_them_under_a_release_todo_md_named_since_the_cut_though_the_plan_holds_no_item_of_it(self):
|
||||
held = [one((1, 2, 3)), dataclasses.replace(one((1, 4, 0)), id=2)]
|
||||
cut = release_standing.LastCut("v1.2.3", "", 4, naming({(1, 2, 3), (1, 3, 0)}))
|
||||
self.assertEqual([item.release for item in release_standing.carried(held, cut)], [(1, 3, 0), (1, 4, 0)])
|
||||
self.assertEqual(release_standing.chunk_item(held, cut), release_standing.Next((1, 3, 0), dataclasses.replace(held[0], release=(1, 3, 0))))
|
||||
self.assertEqual(release_standing.carried(held[:1], dataclasses.replace(cut, todos_since=Failure("log unreadable"))), held[:1])
|
||||
|
||||
def test_takes_the_cut_releases_item_first_as_the_next_releases(self):
|
||||
held = [dataclasses.replace(one((1, 2, 3)), id=1), dataclasses.replace(one((1, 3, 0)), id=2)]
|
||||
cut = release_standing.LastCut("v1.2.3", "", 4, [])
|
||||
self.assertEqual(release_standing.chunk_item(held, cut), release_standing.Next((1, 3, 0), dataclasses.replace(held[0], release=(1, 3, 0))))
|
||||
self.assertEqual(release_standing.next_release(held, cut), release_standing.Upcoming((1, 3, 0), True, True))
|
||||
self.assertEqual(release_standing.next_release(held[:1], cut), release_standing.Cut((1, 2, 3)))
|
||||
|
||||
|
||||
class ChunkItem(unittest.TestCase):
|
||||
def test_takes_the_earliest_release_where_it_is_the_next_and_else_says_whether_the_next_is_ready_to_cut_or_to_plan(self):
|
||||
cases = (
|
||||
@@ -91,7 +118,8 @@ class ChunkItem(unittest.TestCase):
|
||||
(Failure("tags unreadable"), 4, (0, 2, 0), set(), release_standing.Unknown()),
|
||||
(Failure("tags unreadable"), 4, None, set(), release_standing.Unknown()),
|
||||
("v1.2.3", 4, (1, 2, 3), set(), release_standing.Cut((1, 2, 3))),
|
||||
("v1.2.3", 4, (1, 2, 2), {(1, 2, 4)}, release_standing.Cut((1, 2, 2))),
|
||||
("v1.2.3", 4, (1, 2, 2), set(), release_standing.Cut((1, 2, 2))),
|
||||
("v1.2.3", 4, (1, 2, 2), {(1, 2, 4)}, release_standing.Next((1, 2, 4), one((1, 2, 4)))),
|
||||
("v1.2.3", 4, (1, 3, 0), {(1, 2, 4), (1, 3, 0)}, release_standing.ReadyToCut((1, 2, 4))),
|
||||
("v0.9.2", 4, (1, 0, 0), {(0, 9, 3)}, release_standing.ReadyToCut((0, 9, 3))),
|
||||
("v1.2.3", 4, (1, 4, 0), {(1, 2, 2), (1, 3, 0)}, release_standing.ReadyToCut((1, 3, 0))),
|
||||
@@ -140,7 +168,8 @@ class ChunkItem(unittest.TestCase):
|
||||
self.assertNotEqual(release_standing.chunk_item([], without_unreleased), release_standing.ReviewDue((0, 0, 1)), "0.0.1 is cut under its dated heading")
|
||||
later = [HEADER + ROW.format(id=1, release="0.0.1") + ROW.format(id=2, release="0.1.0"), HEADER + ROW.format(id=2, release="0.1.0")]
|
||||
self.assertEqual(release_standing.chunk_item(plan_under((0, 1, 0)), release_standing.LastCut(None, changelog, 4, later)), release_standing.Next((0, 1, 0), one((0, 1, 0))))
|
||||
self.assertEqual(release_standing.chunk_item(plan_under((0, 0, 1)), release_standing.LastCut(None, changelog, 4, later)), release_standing.Cut((0, 0, 1)))
|
||||
self.assertEqual(release_standing.chunk_item(plan_under((0, 0, 1)), release_standing.LastCut(None, changelog, 4, later)), release_standing.Next((0, 1, 0), one((0, 1, 0))))
|
||||
self.assertEqual(release_standing.chunk_item(plan_under((0, 0, 1)), release_standing.LastCut(None, changelog, 4, history)), release_standing.Cut((0, 0, 1)))
|
||||
|
||||
def test_counts_neither_an_undated_heading_nor_a_heading_behind_a_tag_as_cut(self):
|
||||
history = [HEADER + ROW.format(id=1, release="0.0.1"), HEADER]
|
||||
|
||||
+17
-6
@@ -6,12 +6,12 @@ usage: todo-item list [--release <version>]
|
||||
[--blocked-by <IDs>] [--exempt <reason>] <tagline> [<<'EOF' detail EOF]
|
||||
todo-item edit <ID> [--tagline <tagline>] [--l <L>] [--e <E>] [--i <I>] [--s <S>] [--moves <moves>]
|
||||
[--blocked-by <IDs>] [--exempt <reason>] [--detail <<'EOF' detail EOF | --clear-detail]
|
||||
[--comment <why>]
|
||||
todo-item move <ID> --release <version>
|
||||
todo-item finish <ID> [--changelog <bullet> | --no-changelog]
|
||||
|
||||
Run inside a checkout. Every command works on the plan the project's config names, which
|
||||
`project-config plan` prints: a markdown file, todo.md, or a Jira epic. In a Jira epic, list,
|
||||
show, add and finish work, and edit and move fail so far. Each command that changes
|
||||
`project-config plan` prints: a markdown file, todo.md, or a Jira epic. Each command that changes
|
||||
a todo.md ranks it as rank_todo.py does, and so reads the goals file, docs/decisions.md and the
|
||||
comprehension history, each where the config puts it.
|
||||
The cells take the format rank_todo.py --help states; the letter flags take upper case too, as --L.
|
||||
@@ -39,8 +39,18 @@ empties the cell. --detail replaces the detail with the text on stdin, and --cle
|
||||
Text on stdin without --detail, and --detail without text on stdin, are refused, so no detail is
|
||||
dropped or wiped by mistake. It prints `Edited item <ID> in <plan>.` It doesn't write anything where
|
||||
ranking fails or scores the item under the bar.
|
||||
In a Jira epic, edit changes an issue the loop filed: its summary, description and scores, and
|
||||
the label `security` with --exempt. It doesn't change a link, so --blocked-by fails.
|
||||
Of an issue a person filed it sets only the scores, --moves and --exempt, and only with --comment.
|
||||
The four scores are set together where the issue holds none yet.
|
||||
--comment is posted as a comment on the Jira issue, for the client's team, in the project's
|
||||
language. Jira doesn't show the team the scores, so say that the issue is scored, and why.
|
||||
A todo.md keeps no comment, so there the flag doesn't do anything.
|
||||
Where Jira takes the edit and then refuses the comment, edit still prints `Edited item <ID> …`,
|
||||
and says on stderr to post the comment in Jira.
|
||||
|
||||
move sets the item's release, as edit sets a cell. It prints `Moved item <ID> to release <version> in <plan>.`
|
||||
In a Jira epic, move sets the Fix Version of an issue the loop filed; a person moves their own.
|
||||
|
||||
finish removes the item and its detail. With --changelog it adds the bullet first under
|
||||
CHANGELOG.md's ## Unreleased, or a ## heading that says unreleased, creating the section, or the
|
||||
@@ -56,9 +66,9 @@ from its present status, or where the transition leads to another status or to o
|
||||
count as done. An issue that no chunk built is dropped in Jira, not with finish, which would mark it done.
|
||||
|
||||
Exit 2 on bad arguments, and 1, saying why, on any other failure. A message opening `not filed:`,
|
||||
`not edited:`, `not moved:` or `not finished:` means it didn't write anything. The one exception is an add to, or a
|
||||
finish in, a Jira epic that Jira didn't answer or answered brokenly: the message then says the issue
|
||||
may exist, or may have moved.
|
||||
`not edited:`, `not moved:` or `not finished:` means it didn't write anything. The one exception is an add,
|
||||
an edit, a move or a finish in a Jira epic that Jira didn't answer or answered brokenly: the message then
|
||||
says the issue may exist, may have changed or may have moved.
|
||||
"""
|
||||
import argparse
|
||||
import pathlib
|
||||
@@ -126,6 +136,7 @@ def parser() -> argparse.ArgumentParser:
|
||||
detail = editing.add_mutually_exclusive_group()
|
||||
detail.add_argument("--detail", action="store_true")
|
||||
detail.add_argument("--clear-detail", action="store_true")
|
||||
editing.add_argument("--comment")
|
||||
moving = commands.add_parser("move")
|
||||
moving.add_argument("id", type=int)
|
||||
moving.add_argument("--release", required=True)
|
||||
@@ -199,7 +210,7 @@ def edit(args: argparse.Namespace, plan: PlanStore, text: str) -> str | Failure:
|
||||
detail = text if args.detail else "" if args.clear_detail else None
|
||||
if not fields(args) and detail is None:
|
||||
return Failure("not edited: no flag names a change; todo-item --help lists them")
|
||||
return reported(plan.edit(args.id, fields(args), detail), "not edited", lambda written: f"Edited item {written.id} in {plan.label}.")
|
||||
return reported(plan.edit(args.id, fields(args), detail, args.comment), "not edited", lambda written: f"Edited item {written.id} in {plan.label}.")
|
||||
|
||||
|
||||
def finish(args: argparse.Namespace, plan: PlanStore, changelog: RecordStore) -> str | Failure:
|
||||
|
||||
@@ -13,6 +13,7 @@ from project_config.settings import DEFAULT_FLOOR
|
||||
from todo_item import edits, main
|
||||
from failure import Failure
|
||||
from project_config.main import located
|
||||
from plan_store.fakes import MemoryPlan
|
||||
from release_plan import plan_file, ranking
|
||||
from plan_store.stores import plan_of
|
||||
from todo_item.table import table
|
||||
@@ -415,6 +416,18 @@ class Edit(TodoItem):
|
||||
|
||||
def test_refuses_an_edit_that_changes_nothing(self):
|
||||
self.assertEqual(self.run_main("edit", "3"), (1, "", "not edited: no flag names a change; todo-item --help lists them\n"))
|
||||
self.assertEqual(self.run_main("edit", "3", "--comment", "Why.")[::2], (1, "not edited: no flag names a change; todo-item --help lists them\n"))
|
||||
|
||||
def test_an_edit_hands_the_comment_to_the_plan(self):
|
||||
for argv, comments in ((["--comment", "A small change."], {3: ["A small change."]}), ([], {})):
|
||||
with self.subTest(argv=argv):
|
||||
plan = MemoryPlan({3: {"Release": "0.1.0", "Item": "**Count the runs.**", "L": "1", "E": "2", "I": "3", "S": "1"}})
|
||||
self.assertEqual(main.edit(main.parser().parse_args(["edit", "3", "--l", "3", *argv]), plan, ""), "Edited item 3 in the plan in memory.")
|
||||
self.assertEqual((plan.rows[3]["L"], plan.comments), ("3", comments))
|
||||
|
||||
def test_a_plan_in_a_file_takes_an_edit_with_a_comment_and_keeps_no_comment(self):
|
||||
self.assertEqual(self.run_main("edit", "3", "--l", "3", "--comment", "A small change.")[:2], (0, f"Edited item 3 in {self.todo}.\n"))
|
||||
self.assertNotIn("A small change.", self.todo.read_text())
|
||||
|
||||
def test_leaves_the_file_ranked(self):
|
||||
self.run_main("edit", "1", "--s", "2", "--moves", "1 by 10")
|
||||
|
||||
+6
-3
@@ -299,7 +299,7 @@ Valid while the later fixes per finished chunk, which `score-outcomes` and the r
|
||||
- **A bench of readers picked the spelling.** Three fresh readers, seated as the person who writes a client's `config.toml`, each picked `decisions = "confluence:https://<site>/wiki/spaces/<space>/pages/<page ID>"`, pasted from the browser with or without the title at its end, over the bare address, a page ID beside a `confluence-site` key, and a table. Each named the match with `jira:`. Any of the five records may name a page; the goals file, the plan, the working rules and the principles may not.
|
||||
- **`decisions` and `comprehension-history` may name a page only where `plan` names a Jira epic.** rule-hook ranks a plan kept as a file before tool calls, inside its 30-second limit, and ranking reads those two records. A Confluence read and two adf-codec container runs would hold up every guarded tool call, and fail it while Confluence is down. `load` refuses goals in Jira beside a plan in a file for the same reason.
|
||||
- **A write sends the version number the store read, plus one, and Confluence refuses it with 409 where someone saved the page since.** The store then fails, saying to ask the human, and doesn't write the page; the loop never overwrites a teammate's edit on its own (lilleman, 2026-11-12). A write with no read before it replaces the page as it stands, as the record contract asks.
|
||||
- **`project-record` keeps the version `open` read in a file beside its copy**, `~/.local/state/project-record/<key>/<record>.version`, since `save` runs in a later process. The store keeps the version itself, so `write` still takes only the text. Every other tool reads and writes a record in one process, and its store keeps the version in memory, so a read by another tool, such as larv-review's, never moves the version an edit in `project-record` rests on.
|
||||
- **`project-record` keeps the version `open` read in a file beside its copy**, `~/.local/state/project-record/<key>/<worktree>/<record>.version`, since `save` runs in a later process. The store keeps the version itself, so `write` still takes only the text. Every other tool reads and writes a record in one process, and its store keeps the version in memory, so a read by another tool, such as larv-review's, never moves the version an edit in `project-record` rests on. The folder `<worktree>` is named for the worktree that ran `open`, and `open` removes the folders of worktrees git no longer lists, so a chunk's copy doesn't outlive its worktree.
|
||||
- **The page holds ADF, which adf-codec converts both ways**, so a teammate reads the record as Confluence renders it. Where adf-codec cannot convert the markdown, the write fails with adf-codec's error. A node markdown cannot hold reads as text: a mention as its name, a macro as `_(<macro> not included)_`. So the next write replaces it with that text, and a record page should hold only what markdown can.
|
||||
|
||||
## project config: a tool that reads a file's commits says where it does not support that file, and the work goes on
|
||||
@@ -335,9 +335,12 @@ Messages keep each file's usual name, such as `todo.md`, as its label, since the
|
||||
- **A bench of readers picked the spelling.** Three fresh readers, seated as the person who writes a client's `config.toml`, each picked `plan = "jira:https://<site>/browse/<key>"` over the bare address, a `jira:<key>` beside a `jira-site` key, and a `[plan]` table. Each also picked one pair of env-file keys, `ATLASSIAN_EMAIL` and `ATLASSIAN_API_TOKEN`, for Jira and Confluence over a pair for each, since one account's token opens both.
|
||||
- **An item's ID stays a whole number: the issue's number in the epic's Jira project.** About 30 modules read an ID as an int, and the `branch` and title templates already spell a ticket's name, as `ABC-{id}`. So the store refuses a child issue from another Jira project, and counts a blocker only among the plan's own items (`bin/plan_store/jira_epic.py`).
|
||||
- **The scores sit in one issue property, `plan-item`**, which needs no Jira admin (lilleman, 2026-11-12). An issue without it reads as an item nobody scored.
|
||||
- **The release is the earliest Fix Version named as a semver version**, and an issue with none fails the read, naming it, until todo.md's item 359 ties releases to something else.
|
||||
- **The release is the earliest Fix Version named as a semver version**, and an issue with none fails the read, naming it.
|
||||
- **The loop files an item as a Task under the epic, and marks it as its own** (lilleman's calls of 2026-11-12). `"Filed by": "loop"` in the `plan-item` property tells such an issue from one a person filed, whose summary and description the loop never edits. Task is an issue type every Jira Software project template has; a project without it refuses the issue, saying so. The issue takes the project's Fix Version named as the release, with a leading v or without, and the store refuses an item whose release the project has no Fix Version for, before it files anything. A security finding also gets the label `security`, and its text never holds a secret's value. Jira ranks the new issue last, and no bar or goals check applies, until todo.md's item 384 says where a plan in Jira states its formula. Jira takes a blocker's link only after the issue exists, so the store first checks that each blocker is an open child. A link Jira still refuses leaves the issue filed: the write counts as landed, with a note naming the link to make by hand. A failed create says the issue may exist all the same, since a lost answer doesn't tell.
|
||||
- **The store reads, files and finishes, and doesn't edit an issue** until todo.md's item 382. It finishes an item with the transition that the config's `jira-finish-transition` names, which must lead to the status `jira-finish-status` names, since each Jira workflow differs (lilleman's call, 2026-11-12); any open child of the epic may move. It refuses a status outside Jira's done status category: the read counts an issue as finished only in that category, so the item would stay in the plan. Where the issue's present status has no direct transition to the status `jira-finish-status` names, `todo-item finish` fails and a person moves the issue in Jira: the store never walks an issue through other statuses to reach it. lilleman answered on 2026-11-15: "If it is possible to move it to done without a transisiont, that should happen. If not, fail." The implementer read "without a transition" as "without a transition in between". `rank_todo.py` refuses to rank a plan in Jira, and its `--check` passes, since Jira's backlog ranks it; rule-hook's rank check skips it. Each read first asks Jira for the epic itself, since a search under an epic the account cannot see answers no issues, as a finished plan does.
|
||||
- **The store edits and moves only an issue the loop filed, and of an issue a person filed it sets only the scores** (lilleman's calls of 2026-11-12). On its own issue it sets the summary, description, scores and Fix Version in one request, so Jira takes all of an edit or none, and it keeps the label `security` in step with Exempt. Of a person's issue it writes only the `plan-item` property, and a comment: the team's screens don't show the property, so the comment tells the team why the scores changed, and the store refuses the edit without one. The comment's text comes from whoever scores, in the project's `language`. Where Jira takes the edit and then refuses the comment, the edit counts as made, and a note says to post the comment by hand. No edit changes a link, until `todo.md` item 389.
|
||||
- **The loop may re-score a person's issue that already holds scores, and never moves it.** lilleman's calls of 2026-11-12 cover an issue nobody scored, and say nothing of one that holds scores; larv-review chose on 2026-11-16, through todo item 382. A re-score changes only the loop's own reading of the issue, and not what the person wrote, so it is allowed, with a comment as the first scores need. L, E, I and S are set together, so no issue is left partly scored. The Fix Version says when the team ships the issue, and a release is its team's, so the store refuses the move and `CLAUDE.md` has the worker ask the human to move the issue.
|
||||
- **`todo-item edit --comment` carries the comment, and a plan in a file takes the flag and keeps no comment**, so one command works in every project, as goal 1.3 asks. A bench of readers picked the spelling: three fresh readers, seated as the consultant who runs the loop in a client's project, each picked `--comment` over `--reason`, `--why` and `--because`. Only it says the text is posted where the team reads it, and `--reason` read as `--exempt`'s reason.
|
||||
- **The store finishes an item with the transition that the config's `jira-finish-transition` names**, which must lead to the status `jira-finish-status` names, since each Jira workflow differs (lilleman's call, 2026-11-12); any open child of the epic may move. It refuses a status outside Jira's done status category: the read counts an issue as finished only in that category, so the item would stay in the plan. Where the issue's present status has no direct transition to the status `jira-finish-status` names, `todo-item finish` fails and a person moves the issue in Jira: the store never walks an issue through other statuses to reach it. lilleman answered on 2026-11-15: "If it is possible to move it to done without a transisiont, that should happen. If not, fail." The implementer read "without a transition" as "without a transition in between". `rank_todo.py` refuses to rank a plan in Jira, and its `--check` passes, since Jira's backlog ranks it; rule-hook's rank check skips it. Each read first asks Jira for the epic itself, since a search under an epic the account cannot see answers no issues, as a finished plan does.
|
||||
|
||||
## project config: `tooling-on-host = true` lets a project with no container setup run its language runtime, package manager, tests and task runner on the host
|
||||
|
||||
|
||||
@@ -2266,3 +2266,48 @@ Read most (opens and searches):
|
||||
- `bin/loop_claude/loop/main.py` 2
|
||||
- `rules/todo-items.md` 2
|
||||
- `README.md` 1
|
||||
|
||||
## Reading cost, chunk 8026e60ea27c, finished 2026-11-15T21:44:03Z
|
||||
|
||||
199967 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `docs/decisions.md` 11
|
||||
- `bin/chunk_pr/test_chunk_pr.py` 8
|
||||
- `skills/larv-review/SKILL.md` 8
|
||||
- `CLAUDE.md` 5
|
||||
- `README.md` 5
|
||||
- `bin/chunk_pr/main.py` 5
|
||||
- `bin/project_config/templates.py` 4
|
||||
- `rules/todo-items.md` 4
|
||||
- `bin/project_config/main.py` 3
|
||||
- `bin/chunk_pr/approval.py` 2
|
||||
|
||||
## Reading cost, chunk 0851f830bb67, finished 2026-11-15T22:41:58Z
|
||||
|
||||
50560 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `README.md` 1
|
||||
- `bin/project_config/main.py` 1
|
||||
- `bin/project_config/settings.py` 1
|
||||
- `bin/project_record/main.py` 1
|
||||
- `bin/project_record/test_project_record.py` 1
|
||||
- `docs/decisions.md` 1
|
||||
- `rules/decisions.md` 1
|
||||
- `settings.json` 1
|
||||
|
||||
## Reading cost, chunk a8246f8e9771, finished 2026-11-16T00:48:07Z
|
||||
|
||||
97222 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `todo.md` 7
|
||||
- `bin/project_config/settings.py` 3
|
||||
- `rules/todo-items.md` 3
|
||||
- `docs/score-anchors.md` 2
|
||||
- `bin/release_plan/release.py` 1
|
||||
- `bin/release_plan/release_standing.py` 1
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
paths:
|
||||
- "**/AGENTS.md"
|
||||
- "**/docs/decisions.md"
|
||||
- "**/project-record/*/decisions.md"
|
||||
- "**/project-record/*/*/decisions.md"
|
||||
---
|
||||
|
||||
# Decisions: one home, each linked to a goal or a technical principle
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ paths:
|
||||
|
||||
# Todo items (`todo.md`)
|
||||
|
||||
- **A plan is mandatory in every project, and a plan kept as `todo.md` has the shape `rank_todo.py --help` shows**, which `~/.claude/bin/rank_todo.py` checks and ranks; its `--help` shows a valid file. A plan in a Jira epic is read from the epic's open child issues. `todo-item add` files an item there as a new child issue, and `todo-item finish` moves an item's issue to done, and `todo-item` can't edit or move an issue yet. Below, `todo.md` means a plan kept as a file, and "the plan" either kind. `## Scoring` holds the formula and the bar; `## Items` is one table of every item; `## Details` holds each item's detail under its ID. `## Renamed` marks each renamed release with a line such as `- 0.2.1 renamed to 0.3.0`; `rank_todo.py --help` says what a mark does. Cite an item by its ID. The formula and bar are the project's own to tune.
|
||||
- **A plan is mandatory in every project, and a plan kept as `todo.md` has the shape `rank_todo.py --help` shows**, which `~/.claude/bin/rank_todo.py` checks and ranks; its `--help` shows a valid file. A plan in a Jira epic is read from the epic's open child issues. `todo-item add` files an item there as a new child issue, and `todo-item finish` moves an item's issue to done. `todo-item --help` says what `edit` and `move` change there. Below, `todo.md` means a plan kept as a file, and "the plan" either kind. `## Scoring` holds the formula and the bar; `## Items` is one table of every item; `## Details` holds each item's detail under its ID. `## Renamed` marks each renamed release with a line such as `- 0.2.1 renamed to 0.3.0`; `rank_todo.py --help` says what a mark does. Cite an item by its ID. The formula and bar are the project's own to tune.
|
||||
- **File an item with `~/.claude/bin/todo-item add`, and change one with `todo-item edit` or `todo-item move`.** `add` and `edit --detail` read the item's detail from stdin, and all three commands rank the plan; `todo-item --help` shows the flags. `todo-item finish <ID> --no-changelog` drops an item no chunk built. Edit `todo.md` itself only for what `todo-item` has no command for: `## Scoring`, `## Renamed`, and reshaping an old table.
|
||||
- **Order items only by score and the Blocked by column.** An item's Blocked by cell lists the IDs of the items that must be done before it starts, such as `12, 14`; `rank_todo.py --help` says how it ranks them. No text in `todo.md` outside the table orders items: where an item must go first, score it so, and say why in its detail.
|
||||
- **Plan only on the project's rung or above.** loop-claude's prompt tells you when you run below it. Below it, never score or re-score an item, move it between releases, split a milestone into items, delete an item under the bar, rewrite a filed item's tagline or detail, or choose or replace an item in `docs/score-anchors.md`. Draft each new item, each change to a filed item, and each change to the anchors, instead. Before your next commit, launch one subagent to apply the drafts, score them and set their release. Launch it on the rung `CLAUDE.md`'s delegation rule gives a subagent that files or scores items. Keep the scores and releases it writes. For a security finding, launch it at once. Any rung may remove a finished item's row and detail, and score a delegated task's L. A subagent launched for another task leaves the plan alone.
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
|
||||
`Bar = 0.1`
|
||||
|
||||
`Next ID = 389`
|
||||
`Next ID = 390`
|
||||
|
||||
## Items
|
||||
|
||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 386 | 0.11.0 | | | **Key project-record's copies per worktree, so two chunks of one project editing the same record kept outside a file don't overwrite each other's unsaved edit.** | 2 | 2 | 2 | 4 | 2 | 1.1 by 2 | 0.8 |
|
||||
| 359 | 0.11.0 | | | **Tie a project's releases to what its config names: semver tags, Jira Fix Versions, sprints, or none.** | 3 | 2 | 3 | 6 | 4 | 1.6 by 3 | 0.8 |
|
||||
| 382 | 0.11.0 | | | **Edit a Jira issue the loop filed, and score an unscored issue a teammate filed with a comment saying why.** | 4 | 2 | 3 | 7 | 4 | 1.6 by 3 | 0.8 |
|
||||
| 384 | 0.11.0 | | | **Rank an issue the loop files in Jira by its score among the issues the loop filed, a security finding first.** | 3 | 2 | 2 | 5 | 3 | 1.6 by 2 | 0.7 |
|
||||
| 375 | 0.11.0 | | decision | **Run up to the project's configured number of chunks at once, each in its own window of one tmux session named for the project, mark a window whose chunk waits for the human, and refuse to start without tmux at the needed version.** | 4 | 2 | 3 | 7 | 7 | 1.5 by 7 | 0.6 |
|
||||
| 319 | 0.12.0 | | | **Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session.** | 3 | 2 | 3 | 6 | 4 | 1.1 by 2, 1.4 by 2 | 1.2 |
|
||||
@@ -29,10 +26,11 @@
|
||||
| 331 | 0.12.0 | | | **Reword four decisions to expire when the rungs their replays tested change, not whenever a model joins the ladder.** | 1 | 1 | 1 | 1 | 2 | 1.4 by 2 | 0.8 |
|
||||
| 381 | 0.12.0 | | | **Read a `Touches:` list from a plan kept in Jira as from one in todo.md, with a test that converts a description through `adf_codec`.** | 1 | 2 | 1 | 2 | 2 | 1.5 by 2 | 0.7 |
|
||||
| 327 | 0.12.0 | | | **Have `larv-review` print a round commit's title prefix, counted from the round's report, and have rule-hook refuse a round title whose counts differ from it.** | 3 | 2 | 3 | 6 | 4 | 1.1 by 1, 1.4 by 1 | 0.6 |
|
||||
| 365 | 0.13.0 | 382 | | **Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 368 | 0.13.0 | 382 | | **Call a release review due, call a release ready to cut, and tell whether a chunk owes a scoring run, for a plan outside the checkout, from the project repo's history or from Jira.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 366 | 0.13.0 | 382 | | **Count the chunks of a project whose plan sits outside the checkout in the routing figures, from the project repo's history or from Jira.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.4 by 2 | 1.1 |
|
||||
| 367 | 0.13.0 | 382, 384 | | **Check that every write to a Jira plan leaves it ranked, as rule-hook's `todo-rank-check` checks `todo.md` today.** | 2 | 2 | 3 | 5 | 3 | 1.6 by 2 | 0.7 |
|
||||
| 389 | 0.12.0 | | decision | **Set a Jira issue's "is blocked by" links from `todo-item edit --blocked-by`, on an issue the loop filed.** | 2 | 2 | 2 | 4 | 4 | 1.6 by 2 | 0.5 |
|
||||
| 365 | 0.13.0 | | | **Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 368 | 0.13.0 | | | **Call a release review due, call a release ready to cut, and tell whether a chunk owes a scoring run, for a plan outside the checkout, from the project repo's history or from Jira.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.1 by 2 | 1.2 |
|
||||
| 366 | 0.13.0 | | | **Count the chunks of a project whose plan sits outside the checkout in the routing figures, from the project repo's history or from Jira.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 2, 1.4 by 2 | 1.1 |
|
||||
| 367 | 0.13.0 | 384 | | **Check that every write to a Jira plan leaves it ranked, as rule-hook's `todo-rank-check` checks `todo.md` today.** | 2 | 2 | 3 | 5 | 3 | 1.6 by 2 | 0.7 |
|
||||
| 303 | 0.14.0 | | defect | **Archive each judge run's prompt and json reply beside the verdict it gave, so judge cost, replays and backups cover the judge as they cover the worker.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3, 3 by 2 | 4.2 |
|
||||
| 306 | 0.14.0 | | | **Set a strategy that keeps loop-claude's archive and larv-review's review folders backed up and small over the years, compressing older entries without losing any.** | 3 | 2 | 4 | 7 | 5 | 3 by 5 | 3.9 |
|
||||
| 304 | 0.14.0 | 303 | defect | **Archive each review-replay and judge-replay run's transcript beside its result, so a replay that decided a rung can be checked and re-priced later.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 2, 3 by 2 | 3.8 |
|
||||
@@ -78,28 +76,6 @@
|
||||
|
||||
## Details
|
||||
|
||||
### 386. Key project-record's copies per worktree, so two chunks of one project editing the same record kept outside a file don't overwrite each other's unsaved edit.
|
||||
|
||||
Found in item 372's chunk. `project-record open` writes a record kept on a Confluence page to a copy under `~/.local/state/project-record/<key>/`, keyed by the project alone (`bin/project_record/main.py`, `COPIES`). Two chunks of one project, running side by side as item 375 will run them, share that copy: the second `open` rewrites it, and the first chunk's unsaved edit is lost. Key the copy by the worktree as well as the project.
|
||||
|
||||
Touches:
|
||||
- `bin/project_record/main.py`: `(module)` (small)
|
||||
- `bin/project_record/test_project_record.py`
|
||||
|
||||
### 359. Tie a project's releases to what its config names: semver tags, Jira Fix Versions, sprints, or none.
|
||||
|
||||
lilleman's call, 2026-11-12: what a release is differs per client. With none, items name no release, and the architecture and principles passes the release review runs need another trigger, which this item settles and records. Readers: `rank_todo.py`'s release order, chunk-preflight's next release, loop-claude's "release ready to cut", larv-review's release review, `CLAUDE.md` → "Working loop". Cutting a release stays the human's.
|
||||
|
||||
### 382. Edit a Jira issue the loop filed, and score an unscored issue a teammate filed with a comment saying why.
|
||||
|
||||
Split from item 352 on 2026-11-15; lilleman's calls, 2026-11-12. The loop edits the summary, description and scores of issues it created, which the `Filed by` mark in the `plan-item` property tells apart, and never the summary or description of an issue a person filed. An issue a teammate files without scores gets scored like any item, with a short comment saying it was scored and why; its scope stays as written. The comment reaches the client's team, so it is in the project's `language`, and its reason comes from whoever scores: `PlanStore.edit` and `todo-item edit` gain a way to pass it, whose spelling a bench of readers picks. Say in `docs/decisions.md` whether the loop may re-score or move a person's issue that already holds scores; the calls name neither.
|
||||
|
||||
Touches:
|
||||
- `bin/plan_store/jira_epic.py`: `JiraPlan.edit`
|
||||
- `bin/plan_store/test_jira_epic.py`: new tests of `edit`
|
||||
- `bin/plan_store/stores.py`: `PlanStore.edit`, `FilePlan.edit`
|
||||
- `bin/todo_item/main.py`: the help, `edit`'s flags
|
||||
|
||||
### 384. Rank an issue the loop files in Jira by its score among the issues the loop filed, a security finding first.
|
||||
|
||||
Split from item 352 on 2026-11-15; lilleman's call, 2026-11-12: an issue the loop files goes into Jira rank by its score among the issues the loop filed, and a security finding ranks first. The team's own rank of every other issue stays as it is.
|
||||
@@ -203,6 +179,15 @@ Add a `larv-review` subcommand that prints a round title's prefix, up to and inc
|
||||
|
||||
Left with the model: the summary after the `;`, and answering the findings.
|
||||
|
||||
### 389. Set a Jira issue's "is blocked by" links from `todo-item edit --blocked-by`, on an issue the loop filed.
|
||||
|
||||
Filed by item 382's chunk on 2026-11-16. `JiraPlan.edit` refuses an edit of Blocked by, saying to link the issue in Jira, so a worker cannot mark an item it filed as blocked once it exists. Read each link's id from the search's `issuelinks`, make a link per new blocker as `add` does, and delete one per blocker removed, after `missing_blocker`'s check. Say in `docs/decisions.md` whether the loop may link an issue a person filed; the decision on the Jira epic as a plan says the loop writes only the scores of such an issue.
|
||||
|
||||
Touches:
|
||||
- `bin/plan_store/jira_epic.py`: `Issue`, `issue_of`, `JiraPlan.edit`, `revision_of`
|
||||
- `bin/plan_store/test_jira_epic.py`: `Editing`
|
||||
- `bin/todo_item/main.py`: the help
|
||||
|
||||
### 365. Have `score-outcomes` read the finished and dropped items of a plan outside the checkout, from the project repo's history or from Jira's issue changelogs.
|
||||
|
||||
lilleman's call, 2026-11-12: 0.10.0 and 0.11.0 switch the history tools off for a plan outside the checkout, and 0.13.0 holds only their ports. In Jira a dropped item, which `Drop item` commit titles mark today, is an issue resolved by a resolution the config names.
|
||||
|
||||
Reference in New Issue
Block a user