From 50d34ce8049717d92faec9358fd9082c9e518225 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:10:17 +0100 Subject: [PATCH 01/14] Re-score item 352: L 3 to 4 --- todo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.md b/todo.md index f3379b04..d4a6b54a 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 352 | 0.11.0 | | | **Write a project's plan to its Jira epic: file items as child issues, edit those the loop filed, score unscored issues with a comment, and move a finished item to the status its config names.** | 3 | 2 | 3 | 6 | 5 | 1.6 by 6 | 1.2 | +| 352 | 0.11.0 | | | **Write a project's plan to its Jira epic: file items as child issues, edit those the loop filed, score unscored issues with a comment, and move a finished item to the status its config names.** | 4 | 2 | 3 | 7 | 5 | 1.6 by 6 | 1.2 | | 355 | 0.11.0 | | | **Store a record on the Confluence Cloud page its config names, as markdown converted through the adf-codec shim, and interrupt the human when a teammate saved the page since the loop read it.** | 3 | 2 | 3 | 6 | 5 | 1.6 by 6 | 1.2 | | 356 | 0.11.0 | | | **Hand reviewers the review standards from the folder a project's config names, in place of `~/.claude/skills/larv-review/standards/`.** | 2 | 2 | 3 | 5 | 2 | 1.6 by 3 | 1.1 | | 372 | 0.11.0 | | | **Key loop-claude's session, archive, routing state and config-folder commits per chunk, so two chunks of one project run side by side without touching each other's state.** | 3 | 2 | 3 | 6 | 6 | 1.5 by 3 | 0.4 | -- 2.52.0 From 6804b9496efc481c69e48f3992e75e13b74a05fe Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:12:53 +0100 Subject: [PATCH 02/14] Split item 352 into items 352, 382, 383 and 384 --- todo.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/todo.md b/todo.md index d4a6b54a..be5bab92 100644 --- a/todo.md +++ b/todo.md @@ -6,18 +6,21 @@ `Bar = 0.1` -`Next ID = 382` +`Next ID = 385` ## Items | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 352 | 0.11.0 | | | **Write a project's plan to its Jira epic: file items as child issues, edit those the loop filed, score unscored issues with a comment, and move a finished item to the status its config names.** | 4 | 2 | 3 | 7 | 5 | 1.6 by 6 | 1.2 | +| 352 | 0.11.0 | | | **File a plan item as a child issue of the project's Jira epic, marked as the loop's, with a security finding labelled `security`.** | 4 | 2 | 3 | 7 | 4 | 1.6 by 4 | 1.1 | +| 384 | 0.11.0 | 352 | question | **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 | | 355 | 0.11.0 | | | **Store a record on the Confluence Cloud page its config names, as markdown converted through the adf-codec shim, and interrupt the human when a teammate saved the page since the loop read it.** | 3 | 2 | 3 | 6 | 5 | 1.6 by 6 | 1.2 | | 356 | 0.11.0 | | | **Hand reviewers the review standards from the folder a project's config names, in place of `~/.claude/skills/larv-review/standards/`.** | 2 | 2 | 3 | 5 | 2 | 1.6 by 3 | 1.1 | +| 383 | 0.11.0 | | | **Move a finished item of a Jira plan by the transition, and to the status, that the project's config names.** | 4 | 2 | 3 | 7 | 3 | 1.6 by 3 | 1.0 | | 372 | 0.11.0 | | | **Key loop-claude's session, archive, routing state and config-folder commits per chunk, so two chunks of one project run side by side without touching each other's state.** | 3 | 2 | 3 | 6 | 6 | 1.5 by 3 | 0.4 | | 374 | 0.11.0 | 372 | decision | **Merge open chunks one at a time: rebase, finish the item in todo.md and CHANGELOG.md, rerun the gate and the paired ruling, and keep a chunk waiting for approval in the queue without blocking the next.** | 4 | 2 | 3 | 7 | 6 | 1.5 by 4, 1.6 by 3 | 1.0 | | 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 | 352 | | **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 | | 375 | 0.11.0 | 372, 374 | 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 | | 309 | 0.12.0 | | | **Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.** | 2 | 2 | 2 | 4 | 2 | 1.4 by 3 | 1.2 | @@ -31,10 +34,10 @@ | 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 | 352 | | **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 | 352 | | **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 | 352 | | **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 | 352 | | **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 | +| 365 | 0.13.0 | 352, 382, 383 | | **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 | 352, 382, 383 | | **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 | 352, 382, 383 | | **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 | 352, 382, 383, 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,9 +81,26 @@ ## Details -### 352. Write a project's plan to its Jira epic: file items as child issues, edit those the loop filed, score unscored issues with a comment, and move a finished item to the status its config names. +### 352. File a plan item as a child issue of the project's Jira epic, marked as the loop's, with a security finding labelled `security`. -lilleman's calls, 2026-11-12. Without asking, the loop may create child issues in the epic, edit the summary, description and scores of issues it created, and comment on and transition any issue in the epic. It never edits 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. A finished item moves by the transition and to the status the config names, since each Jira workflow differs. An issue the loop files goes into Jira rank by its score among the issues the loop filed. A security finding is filed in the epic like any item, labelled `security` and ranked first, never with a secret's value. R is above 5, so this item ships alone. +lilleman's calls, 2026-11-12. Without asking, the loop may create child issues in the epic, edit the summary, description and scores of issues it created, and comment on and transition any issue in the epic. It never edits the summary or description of an issue a person filed. A security finding is filed in the epic like any item, labelled `security`, never with a secret's value. R is above 5, so this item ships alone. + +Split from the first item 352 on 2026-11-15, which also held what the items it now blocks take: editing and scoring, finishing, and ranking. The filed issue holds the scores in the `plan-item` issue property, with a mark that the loop filed it, which the edit item reads. Jira puts a new issue last in the backlog until the ranking item ships. + +Touches: +- `bin/plan_store/jira_epic.py`: the module docstring, `JiraPlan.add`, and new functions that check the fields and build the issue +- `bin/plan_store/test_jira_epic.py`: new tests of `add` +- `bin/plan_store/stores.py`: the module docstring, `PlanStore`'s docstring, `store` +- `bin/todo_item/main.py`: the help +- `docs/decisions.md`: "project config: `plan` may name a Jira Cloud epic …" +- `rules/todo-items.md`: the first bullet +- `CLAUDE.md`: "Working loop", the sentences on a plan in Jira + +### 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. + +Question for lilleman: where does a plan in Jira state its score formula and its bar? A `todo.md` states both under `## Scoring`, as the project's own to tune, and a Jira epic has no such place. One option is two settings in the project's `config.toml`. Another is to rank without a score: security findings first, then by Moves. ### 355. Store a record on the Confluence Cloud page its config names, as markdown converted through the adf-codec shim, and interrupt the human when a teammate saved the page since the loop read it. @@ -90,6 +110,17 @@ lilleman's calls, 2026-11-12: one page per record, whose ID the config names. Th lilleman's call, 2026-11-12: the folder replaces the default, as item 347's principles folder does. Readers: the reviewers under `agents/`, the judge's records, larv-review, and the repo check that keeps the standards present. +### 383. Move a finished item of a Jira plan by the transition, and to the status, that the project's config names. + +Split from item 352 on 2026-11-15; lilleman's call, 2026-11-12: a finished item moves by the transition and to the status the config names, since each Jira workflow differs. The loop may transition any issue in the epic. A bench of readers, seated as the person who writes a client's `config.toml`, picks the setting's spelling. `PlanStore`'s docstring then stops saying `jira_epic` only reads, once this item and the edit item have shipped. + +Touches: +- `bin/plan_store/jira_epic.py`: `JiraPlan.finish` +- `bin/plan_store/test_jira_epic.py`: new tests of `finish` +- `bin/project_config/settings.py`: `OPTIONAL`, `ProjectConfig`, `load` +- `bin/project_config/main.py`: the help +- `bin/todo_item/main.py`: the help + ### 372. Key loop-claude's session, archive, routing state and config-folder commits per chunk, so two chunks of one project run side by side without touching each other's state. lilleman's call, 2026-11-13, splitting item 361. Items 373 to 375 run several chunks of one project at once. Today a project has one session and one chunk at a time. This item makes two loop-claudes in one project, each on its own chunk, safe to run side by side. It doesn't yet start them; item 375 does that. @@ -110,6 +141,16 @@ Where the rebase conflicts, the chunk's worker resolves it, and only the review 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 item 352's mark 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 + ### 375. 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. lilleman's call, 2026-11-13, splitting item 361. lilleman knows tmux and prefers it. loop-claude runs each chunk in its own window of one tmux session named for the project, such as session `loop-claude-config` with windows `item-372` and `item-373`. It runs up to the number of chunks the project's config allows at once, with 1 as the default, and starts the next chunk item 373's pass allows as each one merges. It uses tmux even at 1, so every project runs the same workflow (goal 1.3). Each window holds a loop-claude for its one chunk, so the interrupt and `/talk` work there as on any terminal. When a chunk waits for the human, loop-claude marks its window, renaming it to end in ` ?` and ringing the bell so tmux's status bar shows it, and clears the mark once it is answered. The DM each interrupt sends names the session and window to answer in, such as `loop-claude-config:item-372`, so the human goes straight to it. -- 2.52.0 From 8e79cb7dc85f101d48790d5b471f6789d20fb069 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:16:11 +0100 Subject: [PATCH 03/14] File a plan item as a child issue of the project's Jira epic --- CLAUDE.md | 4 +- README.md | 2 +- bin/plan_store/jira_epic.py | 103 +++++++++++++++++++++++-- bin/plan_store/stores.py | 4 +- bin/plan_store/test_jira_epic.py | 125 ++++++++++++++++++++++++++++++- bin/todo_item/main.py | 8 +- docs/decisions.md | 3 +- rules/todo-items.md | 2 +- 8 files changed, 230 insertions(+), 21 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 16f21be5..b9378a4c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,11 +2,11 @@ ## Working loop -How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The *next release* is the earliest one not yet cut. A rule names a project's files by their usual paths: `todo.md`, `AGENTS.md`, `CHANGELOG.md` and the files under `docs/`. Each is where the project's config puts it, which `~/.claude/bin/project-config` prints and `chunk-preflight`'s facts quote. Where the config names a Jira epic as the plan, the plan is the epic's open child issues, which no tool writes yet. Read and edit a project record in the file `~/.claude/bin/project-record open ` prints, and run `project-record save ` after each edit. Other words, such as *chunk*, are defined under "Vocabulary" at the end of this file. +How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The *next release* is the earliest one not yet cut. A rule names a project's files by their usual paths: `todo.md`, `AGENTS.md`, `CHANGELOG.md` and the files under `docs/`. Each is where the project's config puts it, which `~/.claude/bin/project-config` prints and `chunk-preflight`'s facts quote. Where the config names a Jira epic as the plan, the plan is the epic's open child issues, where `todo-item` files an item as a new one. Read and edit a project record in the file `~/.claude/bin/project-record open ` prints, and run `project-record save ` after each edit. Other words, such as *chunk*, are defined under "Vocabulary" at the end of this file. - **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 writes only a file for now. 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, and there it files an item but doesn't edit, move or finish 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. - **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. - **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. diff --git a/README.md b/README.md index 9c31d549..53095c49 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,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 only reads such a plan so far. `todo-item add`, `edit`, `move` and `finish` fail, so file, edit and finish its issues in Jira. `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, and doesn't edit or finish an issue yet. `todo-item add`, `edit`, `move` and `finish` fail, so file, edit and finish its issues in Jira. `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. diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 81383554..9e41698e 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -2,21 +2,21 @@ 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. -The store only reads so far: every write is a Failure.""" +The store reads and files: `add` creates a child issue, and edit and finish are a Failure until todo.md's items 382 and 383. An issue it files holds FILED_BY in PROPERTY, which tells it from one a person filed, whose summary and description the loop never edits.""" import base64 import dataclasses import pathlib import re import typing -from adf_codec.convert import adfs_to_markdown, Refused -from plan_store.markdown_edits import bold_cell +from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused +from plan_store.markdown_edits import bold_cell, plain, unfit_text from project_config.settings import Epic -from release_plan.todo_table import EXEMPTIONS, is_exempt, Item, MOVES, parse_moves, parse_scores, SHAPE +from release_plan.todo_table import BLOCKED_BY, EXEMPTIONS, is_exempt, Item, MOVES, parse_ids, parse_moves, parse_scores, SHAPE from failure import Failure from rest_client import json_request from release_plan.release import parsed, Release, tagged -from plan_store.stores import Plan, Written +from plan_store.stores import cells, Plan, Written from rest_client.env_file import read_env # One pair of keys for Jira and Confluence: one Atlassian account's API token opens both. @@ -29,11 +29,19 @@ 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 = "a plan in Jira is only read so far: file, edit and finish its issues in Jira" +READ_ONLY = "a plan in Jira is only read and filed into so far: edit and finish its issues in Jira" +# The key in PROPERTY's value that marks an issue the loop filed, and its value. +FILED_BY = ("Filed by", "loop") +# The issue type of an issue the loop files: every Jira Cloud project template has it, and a project without it refuses the issue, saying so. +ISSUE_TYPE = "Task" +# The name of the link type whose inward side reads "is blocked by", as Jira Cloud ships it. +BLOCKS = "Blocks" +SECURITY = "security" # Sends a request with the Authorization header given, the body as JSON where there is one, and returns the JSON answer, or a Failure saying why there is none. Http = typing.Callable[[str, str, str, object], object] ToMarkdown = typing.Callable[[list[dict[str, typing.Any]]], list[str] | Refused | Failure] +ToAdf = typing.Callable[[str], dict[str, typing.Any] | Failure] def http_json(method: str, url: str, authorization: str, body: object) -> object: @@ -68,11 +76,12 @@ class Issue: @dataclasses.dataclass(frozen=True) class JiraPlan: - """The plan under epic, read with the credentials env_file holds.""" + """The plan under epic, read and written with the credentials env_file holds.""" epic: Epic env_file: pathlib.Path http: Http = http_json to_markdown: ToMarkdown = adfs_to_markdown + to_adf: ToAdf = markdown_to_adf @property def label(self) -> str: @@ -93,7 +102,40 @@ class JiraPlan: return next((issue for issue in issues if isinstance(issue, Failure)), None) or plan_of([issue for issue in issues if isinstance(issue, Issue)], self.epic, self.to_markdown) def add(self, fields: dict[str, str], detail: str) -> Written | Failure: - return Failure(READ_ONLY) + """Files the item as a child issue, which Jira ranks last in the backlog. It doesn't weigh the item against a bar or the goals file, which a plan in Jira doesn't state yet (todo.md's item 384). Jira takes the links after the issue, so a link it refuses leaves the issue filed, and the Failure says so.""" + filing = filing_of(fields, detail, self.epic) + if isinstance(filing, Failure): + return filing + authorization = basic_auth(self.env_file) + if isinstance(authorization, Failure): + return authorization + if detail.strip(): + description = self.to_adf(detail) + if isinstance(description, Failure): + return Failure(f"cannot convert the item's detail to a Jira description: {description.reason}") + filing.body["fields"]["description"] = description + if filing.blockers and (missing := self.missing_blocker(filing.blockers, authorization)): + return missing + created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, filing.body) + if isinstance(created, Failure): + return Failure(f"cannot file the item under {self.epic.key}: {created.reason}") + key = created.get("key") if isinstance(created, dict) else None + if not isinstance(key, str) or not ISSUE_KEY.fullmatch(key) or project_of(key) != project_of(self.epic.key): + return Failure(f"Jira answered the new issue without an issue key in {project_of(self.epic.key)}; look for it under {self.epic.key} before filing the item again") + for blocker in filing.blockers: + # Jira names the two ends by the link type's sides: the inward issue blocks the outward one, which then reads "is blocked by" it. + linked = self.http("POST", f"{self.epic.site}/rest/api/3/issueLink", authorization, {"type": {"name": BLOCKS}, "inwardIssue": {"key": blocker}, "outwardIssue": {"key": key}}) + if isinstance(linked, Failure): + return Failure(f"filed {key}, but cannot link it as blocked by {blocker}: {linked.reason}; link it in Jira, and do not file the item again") + return Written(number(key)) + + 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, since only such a blocker reads back as one.""" + answered = children(self.epic, authorization, self.http) + if isinstance(answered, Failure): + return answered + 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) @@ -102,6 +144,51 @@ class JiraPlan: return Failure(READ_ONLY) +@dataclasses.dataclass(frozen=True) +class Filing: + """An item checked and ready to file.""" + # What Jira's create-issue request takes, without the description. + body: dict[str, typing.Any] + # The key of each issue the item is blocked by. + blockers: tuple[str, ...] + + +def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failure: + """The issue that holds an item with these fields under epic, or why a field cannot be filed. It holds only what `item` reads back.""" + named = cells(fields) + summary = plain(named.get("Item", "")).strip() + if not summary: + return Failure("the item has no tagline") + if unfit := unfit_text(summary, detail): + return unfit + release = named.get("Release", "") + if parsed(release) is None: + return Failure(f"the item's Release {release!r} is not a version such as 1.2.0") + # Named so the shared messages read "item to file's L". + levels = parse_scores("to file", named, SHAPE.score_columns) + if isinstance(levels, Failure): + return levels + moves, exempt = named.get(MOVES, ""), named.get("Exempt", "") + if isinstance(unfit_moves := parse_moves("to file", moves), Failure): + return unfit_moves + if not is_exempt(exempt): + return Failure(f"the item's Exempt {exempt!r} is not empty or one of {', '.join(EXEMPTIONS[1:])}") + blockers = parse_ids(named.get(BLOCKED_BY, "")) + if blockers is None: + return Failure(f"the item's {BLOCKED_BY} {named[BLOCKED_BY]!r} is not empty or IDs separated by \", \"") + project = project_of(epic.key) + issue_fields: dict[str, typing.Any] = {"project": {"key": project}, "parent": {"key": epic.key}, "issuetype": {"name": ISSUE_TYPE}, "summary": summary, "fixVersions": [{"name": release}]} + if exempt == SECURITY: + issue_fields["labels"] = [SECURITY] + value = levels | {MOVES: moves, "Exempt": exempt, FILED_BY[0]: FILED_BY[1]} + return Filing({"fields": issue_fields, "properties": [{"key": PROPERTY, "value": value}]}, tuple(f"{project}-{blocker}" for blocker in blockers)) + + +def project_of(key: str) -> str: + """The key of the Jira project an issue key lies in.""" + return key.rpartition("-")[0] + + def basic_auth(env_file: pathlib.Path) -> str | Failure: """The Authorization header for the email and API token that env_file holds.""" values = read_env(env_file, KEYS, "an API token") diff --git a/bin/plan_store/stores.py b/bin/plan_store/stores.py index f8110af6..f1278ce3 100644 --- a/bin/plan_store/stores.py +++ b/bin/plan_store/stores.py @@ -1,6 +1,6 @@ """The one way a tool reads or writes a project's plan: through the store its config names. -The config's `plan` setting names the backend. A path names a markdown file, todo.md. `jira:` and an epic's address name a Jira epic, whose open child issues `jira_epic` reads and nothing writes yet. An agent reads and changes the plan with `todo-item`, which works through the same store. +The config's `plan` setting names the backend. A path names a markdown file, todo.md. `jira:` and an epic's address name a Jira epic, whose open child issues `jira_epic` reads, and where it files an item as a new one. An agent reads and changes the plan with `todo-item`, which works through the same store. A tool that reads what a past commit held, such as `score-outcomes`, still parses that commit's todo.md itself, with `release_plan.todo_table`: only the markdown backend has commits, and todo.md's items 365, 366 and 368 port those tools to the other backends.""" import dataclasses @@ -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` only reads until todo.md's item 352. A write that fails leaves the plan as it was.""" + """A project's plan. plan_store.contract holds every backend that writes to the same behaviour; `jira_epic` reads and files, and fails an edit or a finish until todo.md's items 382 and 383. A write that fails leaves the plan as it was.""" @property def label(self) -> str: diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 7d233c33..45cf6b69 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -10,7 +10,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from project_config.settings import Epic from failure import Failure from plan_store import jira_epic -from plan_store.stores import Plan +from plan_store.stores import Plan, Written from adf_codec.convert import Refused from release_plan.release import release_of @@ -209,17 +209,134 @@ class JiraPlan(unittest.TestCase): self.pages = [{"issues": [issue("OTHER-5")]}] self.assertNotIn("s3cret", self.store().read().reason) # type: ignore[union-attr] - def test_every_write_fails_since_the_store_only_reads(self): + def test_edit_and_finish_fail_since_the_store_only_files(self): store = self.store() - for written in (store.add({}, ""), store.edit(34, {"L": "2"}, None), store.finish(34)): + for written in (store.edit(34, {"L": "2"}, None), store.finish(34)): with self.subTest(written=written): - self.assertEqual(written, Failure("a plan in Jira is only read so far: file, edit and finish its issues in Jira")) + self.assertEqual(written, Failure("a plan in Jira is only read and filed into so far: edit and finish its issues 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)) +ISSUES = "https://acme.atlassian.net/rest/api/3/issue" +LINKS = "https://acme.atlassian.net/rest/api/3/issueLink" +FIELDS = {"Release": "0.1.0", "Tagline": "Count the runs.", "L": "1", "E": "2", "I": "3", "S": "1", "Moves": "1 by 9"} +PROPERTY = {"L": 1, "E": 2, "I": 3, "S": 1, "Moves": "1 by 9", "Exempt": "", "Filed by": "loop"} + + +class Filing(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]] = [] + self.open: list[dict[str, object]] = [] + self.created: object = {"id": "10040", "key": "ABC-40"} + self.linked: object = None + + def http(self, method: str, url: str, authorization: str, body: object) -> object: + """Stands in for Jira: answers the epic, self.open to the search, self.created to a new issue and self.linked to a new link.""" + self.calls.append((method, url, body)) + assert authorization == AUTHORIZATION + return {SEARCH: {"issues": self.open}, ISSUES: self.created, LINKS: self.linked}.get(url, {"key": "ABC-12"}) + + def to_adf(self, markdown: str) -> dict[str, object] | Failure: + return adf(markdown) + + def add(self, fields: dict[str, str] = FIELDS, detail: str = ""): + return jira_epic.JiraPlan(EPIC, self.env, self.http, text_of, self.to_adf).add(fields, detail) + + def sent(self, url: str) -> list[object]: + return [body for _, sent_to, body in self.calls if sent_to == url] + + def test_files_the_item_as_a_task_under_the_epic_marked_as_the_loops(self): + self.assertEqual(self.add(), Written(40)) + self.assertEqual(self.calls, [("POST", ISSUES, { + "fields": {"project": {"key": "ABC"}, "parent": {"key": "ABC-12"}, "issuetype": {"name": "Task"}, "summary": "Count the runs.", "fixVersions": [{"name": "0.1.0"}]}, + "properties": [{"key": "plan-item", "value": PROPERTY}], + })]) + + def test_a_bold_tagline_is_filed_plain(self): + self.add(FIELDS | {"Tagline": "**Count the runs.**"}) + self.assertEqual(self.sent(ISSUES)[0]["fields"]["summary"], "Count the runs.") # type: ignore[index] + + def test_the_detail_is_the_description_as_adf(self): + self.add(detail="Why it counts.") + self.assertEqual(self.sent(ISSUES)[0]["fields"]["description"], adf("Why it counts.")) # type: ignore[index] + + def test_a_security_finding_is_labelled_security(self): + self.add(FIELDS | {"Exempt": "security"}) + sent, = self.sent(ISSUES) + self.assertEqual((sent["fields"]["labels"], sent["properties"][0]["value"]["Exempt"]), (["security"], "security")) # type: ignore[index] + + def test_no_other_item_is_labelled(self): + self.add(FIELDS | {"Exempt": "owner"}) + self.assertNotIn("labels", self.sent(ISSUES)[0]["fields"]) # type: ignore[index] + + def test_links_the_issue_as_blocked_by_each_blocker_once_filed(self): + self.open = [issue("ABC-34"), issue("ABC-35")] + self.assertEqual(self.add(FIELDS | {"Blocked by": "34, 35"}), Written(40)) + self.assertEqual([url for _, url, _ in self.calls][-3:], [ISSUES, LINKS, LINKS]) + self.assertEqual(self.sent(LINKS), [{"type": {"name": "Blocks"}, "inwardIssue": {"key": f"ABC-{blocker}"}, "outwardIssue": {"key": "ABC-40"}} for blocker in (34, 35)]) + + def test_a_blocker_that_is_no_open_child_fails_before_anything_is_filed(self): + self.open = [issue("ABC-34")] + self.assertEqual(self.add(FIELDS | {"Blocked by": "34, 36"}), Failure("jira:https://acme.atlassian.net/browse/ABC-12 holds no item 36 to be blocked by")) + self.assertEqual(self.sent(ISSUES), []) + + def test_a_field_out_of_format_fails_before_any_request(self): + cases = ({"L": "9"}, {"Release": "soon"}, {"Release": ""}, {"Moves": "much"}, {"Exempt": "whim"}, {"Blocked by": "ABC-34"}, {"Tagline": "Count\nthe runs."}, {"Tagline": " "}) + for change in cases: + with self.subTest(change=change): + self.assertIsInstance(self.add(FIELDS | change), Failure) + self.assertEqual(self.calls, []) + + def test_a_field_the_plan_does_not_have_is_a_programming_error(self): + with self.assertRaises(ValueError): + self.add(FIELDS | {"Colour": "red"}) + + def test_an_item_without_a_release_fails_naming_the_field(self): + self.assertEqual(self.add({name: value for name, value in FIELDS.items() if name != "Release"}), Failure("the item's Release '' is not a version such as 1.2.0")) + + def test_a_detail_that_does_not_convert_fails_before_any_request(self): + self.to_adf = lambda markdown: Failure("docker is not running") # type: ignore[method-assign] + self.assertEqual(self.add(detail="Why."), Failure("cannot convert the item's detail to a Jira description: docker is not running")) + self.assertEqual(self.calls, []) + + def test_an_item_jira_refuses_fails_with_jiras_reason(self): + self.created = Failure("POST /rest/api/3/issue answered 400: Version name '0.1.0' is not valid") + self.assertEqual(self.add(), Failure("cannot file the item under ABC-12: POST /rest/api/3/issue answered 400: Version name '0.1.0' is not valid")) + + def test_an_answer_that_names_no_issue_of_the_epics_project_fails(self): + for answer in ({}, {"key": 7}, {"key": "OTHER-5"}, ["ABC-40"]): + with self.subTest(answer=answer): + self.created = answer + self.assertEqual(self.add(), Failure("Jira answered the new issue without an issue key in ABC; look for it under ABC-12 before filing the item again")) + + def test_a_link_jira_refuses_fails_naming_the_issue_it_filed(self): + self.open, self.linked = [issue("ABC-34")], Failure("POST /rest/api/3/issueLink answered 404: No issue link type with name 'Blocks' found.") + self.assertEqual(self.add(FIELDS | {"Blocked by": "34"}), Failure("filed ABC-40, but cannot link it as blocked by ABC-34: POST /rest/api/3/issueLink answered 404: No issue link type with name 'Blocks' found.; link it in Jira, and do not file the item again")) + + def test_what_it_files_reads_back_as_the_item(self): + self.add(FIELDS | {"Exempt": "owner"}, "Why it counts.") + sent, = self.sent(ISSUES) + raw = {"key": "ABC-40", "fields": sent["fields"] | {"issuelinks": []}, "properties": {entry["key"]: entry["value"] for entry in sent["properties"]}} # type: ignore[index] + filed = jira_epic.issue_of(raw) + assert isinstance(filed, jira_epic.Issue), filed + plan = jira_epic.plan_of([filed], EPIC, lambda documents: [text_of(document) for document in documents]) + assert isinstance(plan, Plan), plan + item, = plan.items + self.assertEqual((item.id, item.release, item.exempt, item.tagline, item.moves, item.detail), (40, release_of("0.1.0"), "owner", "**Count the runs.**", (("1", 9),), "Why it counts.")) + self.assertEqual({name: item.scores[name] for name in "LEIS"}, {"L": 1, "E": 2, "I": 3, "S": 1}) + + def test_a_missing_env_file_fails_before_any_request(self): + self.env.unlink() + self.assertIsInstance(self.add(), Failure) + self.assertEqual(self.calls, []) + + class Requests(unittest.TestCase): def test_sends_each_request_through_the_shared_client_with_jiras_error_messages(self): with unittest.mock.patch.object(jira_epic.json_request, "http_json", return_value={"issues": []}) as sent: diff --git a/bin/todo_item/main.py b/bin/todo_item/main.py index c373369c..22e59c2c 100644 --- a/bin/todo_item/main.py +++ b/bin/todo_item/main.py @@ -10,8 +10,8 @@ usage: todo-item list [--release ] todo-item finish [--changelog | --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. A plan in a Jira epic is -only read so far: list and show work, and add, edit, move and finish fail. Each command that changes +`project-config plan` prints: a markdown file, todo.md, or a Jira epic. In a Jira epic, list, +show and add work, and edit, move and finish fail so far. 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. @@ -28,6 +28,10 @@ list and show read only the plan, and print no Score: an item's place in list's add files the item under the next free ID, with the tagline in bold, and the detail it reads from stdin, if any. The detail may hold no ## or ### heading. It prints `Filed item in .` It doesn't write anything where ranking fails or scores the item under the bar. +In a Jira epic, add files a Task under the epic, last in the backlog, and is the new issue's +number. The release must be one of the Jira project's Fix Versions, and --exempt security also +labels the issue `security`. No bar applies there yet. Where Jira files the issue and then refuses +a --blocked-by link, add fails, naming the issue: link it in Jira, and don't file it again. edit sets the cells whose flag is given and leaves the rest; an empty value, as in --blocked-by "", empties the cell. --detail replaces the detail with the text on stdin, and --clear-detail removes it. diff --git a/docs/decisions.md b/docs/decisions.md index 8c0f5faf..cae5221a 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -302,7 +302,8 @@ Messages keep each file's usual name, such as `todo.md`, as its label, since the - **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 store only reads**, until todo.md's item 352 writes. `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 loop files an item as a Task under the epic, and marks it as its own** (item 352, on 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 the one issue type every Jira Cloud project template has; a project without it refuses the issue, saying so. 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, and a link Jira still refuses leaves the issue filed, which the failure says. +- **The store reads and files, and doesn't edit or finish an issue** until todo.md's items 382 and 383. `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 diff --git a/rules/todo-items.md b/rules/todo-items.md index acd7bd88..b35497d0 100644 --- a/rules/todo-items.md +++ b/rules/todo-items.md @@ -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, and `todo-item` can't write one 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 one there, and nothing edits, moves or finishes one 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. - **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 --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. -- 2.52.0 From 800f7b303185ff178c063da65b7cdc6b945238ef Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:17:25 +0100 Subject: [PATCH 04/14] Sort the Jira store's imports and spell a citation as the check asks --- bin/plan_store/jira_epic.py | 6 +++--- todo.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 9e41698e..87bfc01c 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -10,13 +10,13 @@ import re import typing from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused -from plan_store.markdown_edits import bold_cell, plain, unfit_text -from project_config.settings import Epic from release_plan.todo_table import BLOCKED_BY, EXEMPTIONS, is_exempt, Item, MOVES, parse_ids, parse_moves, parse_scores, SHAPE +from plan_store.markdown_edits import bold_cell, plain, unfit_text +from plan_store.stores import cells, Plan, Written +from project_config.settings import Epic from failure import Failure from rest_client import json_request from release_plan.release import parsed, Release, tagged -from plan_store.stores import cells, Plan, Written from rest_client.env_file import read_env # One pair of keys for Jira and Confluence: one Atlassian account's API token opens both. diff --git a/todo.md b/todo.md index be5bab92..10bbe51b 100644 --- a/todo.md +++ b/todo.md @@ -94,7 +94,7 @@ Touches: - `bin/todo_item/main.py`: the help - `docs/decisions.md`: "project config: `plan` may name a Jira Cloud epic …" - `rules/todo-items.md`: the first bullet -- `CLAUDE.md`: "Working loop", the sentences on a plan in Jira +- `CLAUDE.md` → "Working loop": the sentences on a plan in Jira ### 384. Rank an issue the loop files in Jira by its score among the issues the loop filed, a security finding first. -- 2.52.0 From a0945b6dae6620b42bf6edde05590a5dbfd572da Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:17:33 +0100 Subject: [PATCH 05/14] Record the chunk's reading cost --- docs/reading-cost.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 63a8dce6..559c4689 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -2169,3 +2169,19 @@ Read most (opens and searches): - `agents/principles-auditor.md` 2 - `bin/larv_review/main.py` 2 - `bin/larv_review/plan.py` 2 + +## Reading cost, chunk b3bdb6c3ea26, finished 2026-11-15T02:08:49Z + +103160 new input tokens before the first commit. + +Read most (opens and searches): + +- `rules/todo-items.md` 3 +- `todo.md` 2 +- `bin/chunk_preflight/choices.py` 1 +- `bin/chunk_preflight/facts.py` 1 +- `bin/chunk_preflight/gathered.py` 1 +- `bin/chunk_preflight/main.py` 1 +- `bin/release_plan/release_standing.py` 1 +- `docs/decisions.md` 1 +- `docs/score-anchors.md` 1 -- 2.52.0 From 2a7018dc43e18c3507cb418e2c33a8b2bf657540 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:24:22 +0100 Subject: [PATCH 06/14] Pin each filing failure's message and the links' method --- bin/plan_store/test_jira_epic.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 45cf6b69..b0592299 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -8,6 +8,7 @@ import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from project_config.settings import Epic +from release_plan.todo_table import EXEMPTIONS from failure import Failure from plan_store import jira_epic from plan_store.stores import Plan, Written @@ -278,7 +279,7 @@ class Filing(unittest.TestCase): def test_links_the_issue_as_blocked_by_each_blocker_once_filed(self): self.open = [issue("ABC-34"), issue("ABC-35")] self.assertEqual(self.add(FIELDS | {"Blocked by": "34, 35"}), Written(40)) - self.assertEqual([url for _, url, _ in self.calls][-3:], [ISSUES, LINKS, LINKS]) + self.assertEqual([(method, url) for method, url, _ in self.calls][-3:], [("POST", ISSUES), ("POST", LINKS), ("POST", LINKS)]) self.assertEqual(self.sent(LINKS), [{"type": {"name": "Blocks"}, "inwardIssue": {"key": f"ABC-{blocker}"}, "outwardIssue": {"key": "ABC-40"}} for blocker in (34, 35)]) def test_a_blocker_that_is_no_open_child_fails_before_anything_is_filed(self): @@ -293,6 +294,22 @@ class Filing(unittest.TestCase): self.assertIsInstance(self.add(FIELDS | change), Failure) self.assertEqual(self.calls, []) + def test_each_field_out_of_format_fails_saying_how(self): + cases = ( + ({"Tagline": "** **"}, "the item has no tagline"), + ({"L": "9"}, "item to file's L '9' is not a whole number from 1 to 4"), + ({"Exempt": "whim"}, f"the item's Exempt 'whim' is not empty or one of {', '.join(EXEMPTIONS[1:])}"), + ({"Blocked by": "ABC-34"}, "the item's Blocked by 'ABC-34' is not empty or IDs separated by \", \""), + ) + for change, reason in cases: + with self.subTest(change=change): + self.assertEqual(self.add(FIELDS | change), Failure(reason)) + self.assertEqual(self.add({name: value for name, value in FIELDS.items() if name != "Tagline"}), Failure("the item has no tagline")) + + def test_an_item_without_moves_files_with_none(self): + self.assertEqual(self.add({name: value for name, value in FIELDS.items() if name != "Moves"}), Written(40)) + self.assertEqual(self.sent(ISSUES)[0]["properties"][0]["value"]["Moves"], "") # type: ignore[index] + def test_a_field_the_plan_does_not_have_is_a_programming_error(self): with self.assertRaises(ValueError): self.add(FIELDS | {"Colour": "red"}) -- 2.52.0 From af8e7ad3d12eab3096b728b6364d6727866e8b0e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:30:15 +0100 Subject: [PATCH 07/14] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20nothing=20t?= =?UTF-8?q?o=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 35f1f5e70f0498fe06f8c1d3caf17d1b9fc012be Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:35:48 +0100 Subject: [PATCH 08/14] =?UTF-8?q?Answer=20stability=20round=201:=202=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20count=20an?= =?UTF-8?q?=20item=20as=20filed=20once=20Jira=20holds=20it,=20try=20every?= =?UTF-8?q?=20link,=20say=20when=20a=20failed=20create=20may=20have=20file?= =?UTF-8?q?d,=20and=20drop=20README's=20stale=20sentence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 2 +- README.md | 2 +- bin/plan_store/jira_epic.py | 63 +++++++++++++++++++++----------- bin/plan_store/stores.py | 4 +- bin/plan_store/test_jira_epic.py | 39 +++++++++++++++----- bin/todo_item/main.py | 10 +++-- docs/decisions.md | 2 +- rules/todo-items.md | 2 +- todo.md | 4 +- 9 files changed, 86 insertions(+), 42 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b9378a4c..5f5fbbb3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,7 +2,7 @@ ## Working loop -How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The *next release* is the earliest one not yet cut. A rule names a project's files by their usual paths: `todo.md`, `AGENTS.md`, `CHANGELOG.md` and the files under `docs/`. Each is where the project's config puts it, which `~/.claude/bin/project-config` prints and `chunk-preflight`'s facts quote. Where the config names a Jira epic as the plan, the plan is the epic's open child issues, where `todo-item` files an item as a new one. Read and edit a project record in the file `~/.claude/bin/project-record open ` prints, and run `project-record save ` after each edit. Other words, such as *chunk*, are defined under "Vocabulary" at the end of this file. +How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The *next release* is the earliest one not yet cut. A rule names a project's files by their usual paths: `todo.md`, `AGENTS.md`, `CHANGELOG.md` and the files under `docs/`. Each is where the project's config puts it, which `~/.claude/bin/project-config` prints and `chunk-preflight`'s facts quote. Where the config names a Jira epic as the plan, the plan is the epic's open child issues. Read and edit a project record in the file `~/.claude/bin/project-record open ` prints, and run `project-record save ` after each edit. Other words, such as *chunk*, are defined under "Vocabulary" at the end of this file. - **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. diff --git a/README.md b/README.md index 53095c49..2258e144 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,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 or finish an issue yet. `todo-item add`, `edit`, `move` and `finish` fail, so file, edit and finish its issues in Jira. `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, and doesn't edit or finish an issue yet. `todo-item edit`, `move` and `finish` fail, so edit and finish its issues in Jira. `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. diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 87bfc01c..38c79e20 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -1,8 +1,8 @@ -"""A plan kept as the child issues of one Jira Cloud epic, read over Jira's REST API. +"""A plan kept as the child issues of one Jira Cloud epic, read and filed into 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. -The store reads and files: `add` creates a child issue, and edit and finish are a Failure until todo.md's items 382 and 383. An issue it files holds FILED_BY in PROPERTY, which tells it from one a person filed, whose summary and description the loop never edits.""" +`add` files an item as a new child issue, marked with FILED_BY. edit and finish are a Failure until todo.md's items 382 and 383.""" import base64 import dataclasses import pathlib @@ -30,13 +30,15 @@ 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 = "a plan in Jira is only read and filed into so far: edit and finish its issues in Jira" -# The key in PROPERTY's value that marks an issue the loop filed, and its value. +# 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. FILED_BY = ("Filed by", "loop") -# The issue type of an issue the loop files: every Jira Cloud project template has it, and a project without it refuses the issue, saying so. +# 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" # The name of the link type whose inward side reads "is blocked by", as Jira Cloud ships it. BLOCKS = "Blocks" SECURITY = "security" +# What a failed create ends with: a request Jira never answered, or answered brokenly, may still have filed the issue. +PERHAPS_FILED = "unless Jira refused the request, the issue may exist: look under {epic} before filing the item again" # Sends a request with the Authorization header given, the body as JSON where there is one, and returns the JSON answer, or a Failure saying why there is none. Http = typing.Callable[[str, str, str, object], object] @@ -102,35 +104,51 @@ class JiraPlan: return next((issue for issue in issues if isinstance(issue, Failure)), None) or plan_of([issue for issue in issues if isinstance(issue, Issue)], self.epic, self.to_markdown) def add(self, fields: dict[str, str], detail: str) -> Written | Failure: - """Files the item as a child issue, which Jira ranks last in the backlog. It doesn't weigh the item against a bar or the goals file, which a plan in Jira doesn't state yet (todo.md's item 384). Jira takes the links after the issue, so a link it refuses leaves the issue filed, and the Failure says so.""" + """Files the item as a child issue, which Jira ranks last in the backlog. No bar applies and the goals file isn't read, since a plan in Jira has no place for a formula or a bar yet (todo.md's item 384). + + Jira takes the links after the issue. A link it refuses leaves the issue filed, so the write counts as landed, and a note names each link to make by hand.""" filing = filing_of(fields, detail, self.epic) if isinstance(filing, Failure): return filing authorization = basic_auth(self.env_file) if isinstance(authorization, Failure): return authorization + issue_fields = filing.fields if detail.strip(): description = self.to_adf(detail) if isinstance(description, Failure): return Failure(f"cannot convert the item's detail to a Jira description: {description.reason}") - filing.body["fields"]["description"] = description + issue_fields = issue_fields | {"description": description} + version = self.fix_version(filing.release, authorization) + if isinstance(version, Failure): + return version if filing.blockers and (missing := self.missing_blocker(filing.blockers, authorization)): return missing - created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, filing.body) + created = self.http("POST", f"{self.epic.site}/rest/api/3/issue", authorization, {"fields": issue_fields | {"fixVersions": [{"name": version}]}, "properties": [{"key": PROPERTY, "value": filing.scores}]}) if isinstance(created, Failure): - return Failure(f"cannot file the item under {self.epic.key}: {created.reason}") + return Failure(f"cannot file the item under {self.epic.key}: {created.reason}; {PERHAPS_FILED.format(epic=self.epic.key)}") key = created.get("key") if isinstance(created, dict) else None if not isinstance(key, str) or not ISSUE_KEY.fullmatch(key) or project_of(key) != project_of(self.epic.key): - return Failure(f"Jira answered the new issue without an issue key in {project_of(self.epic.key)}; look for it under {self.epic.key} before filing the item again") + return Failure(f"Jira answered the new issue without an issue key in {project_of(self.epic.key)}; {PERHAPS_FILED.format(epic=self.epic.key)}") + notes = [] for blocker in filing.blockers: # Jira names the two ends by the link type's sides: the inward issue blocks the outward one, which then reads "is blocked by" it. linked = self.http("POST", f"{self.epic.site}/rest/api/3/issueLink", authorization, {"type": {"name": BLOCKS}, "inwardIssue": {"key": blocker}, "outwardIssue": {"key": key}}) if isinstance(linked, Failure): - return Failure(f"filed {key}, but cannot link it as blocked by {blocker}: {linked.reason}; link it in Jira, and do not file the item again") - return Written(number(key)) + notes.append(f"filed {key}, but cannot link it as blocked by {blocker}: {linked.reason}; link it in Jira") + return Written(number(key), tuple(notes)) + + def fix_version(self, release: str, authorization: str) -> str | Failure: + """The name of the Jira project's Fix Version for release, which a project may spell with a leading v, as `earliest_release` reads it.""" + project = project_of(self.epic.key) + versions = self.http("GET", f"{self.epic.site}/rest/api/3/project/{project}/versions", authorization, None) + if isinstance(versions, Failure): + return Failure(f"cannot read {project}'s Fix Versions: {versions.reason}") + names = {version.get("name") for version in versions if isinstance(version, dict)} 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") 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, since only such a blocker reads back as one.""" + """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.""" answered = children(self.epic, authorization, self.http) if isinstance(answered, Failure): return answered @@ -147,14 +165,17 @@ class JiraPlan: @dataclasses.dataclass(frozen=True) class Filing: """An item checked and ready to file.""" - # What Jira's create-issue request takes, without the description. - body: dict[str, typing.Any] + # The new issue's fields, without its description and its Fix Version. + fields: dict[str, typing.Any] + release: str + # PROPERTY's value. + scores: dict[str, typing.Any] # The key of each issue the item is blocked by. blockers: tuple[str, ...] def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failure: - """The issue that holds an item with these fields under epic, or why a field cannot be filed. It holds only what `item` reads back.""" + """The issue to file for an item with these fields under epic, or why a field cannot be filed.""" named = cells(fields) summary = plain(named.get("Item", "")).strip() if not summary: @@ -164,7 +185,7 @@ def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failu release = named.get("Release", "") if parsed(release) is None: return Failure(f"the item's Release {release!r} is not a version such as 1.2.0") - # Named so the shared messages read "item to file's L". + # Named so the shared messages read "item to file's L": they open with "item" and an ID, which this item has none of yet. levels = parse_scores("to file", named, SHAPE.score_columns) if isinstance(levels, Failure): return levels @@ -177,11 +198,11 @@ def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failu if blockers is None: return Failure(f"the item's {BLOCKED_BY} {named[BLOCKED_BY]!r} is not empty or IDs separated by \", \"") project = project_of(epic.key) - issue_fields: dict[str, typing.Any] = {"project": {"key": project}, "parent": {"key": epic.key}, "issuetype": {"name": ISSUE_TYPE}, "summary": summary, "fixVersions": [{"name": release}]} + issue_fields: dict[str, typing.Any] = {"project": {"key": project}, "parent": {"key": epic.key}, "issuetype": {"name": ISSUE_TYPE}, "summary": summary} if exempt == SECURITY: issue_fields["labels"] = [SECURITY] value = levels | {MOVES: moves, "Exempt": exempt, FILED_BY[0]: FILED_BY[1]} - return Filing({"fields": issue_fields, "properties": [{"key": PROPERTY, "value": value}]}, tuple(f"{project}-{blocker}" for blocker in blockers)) + return Filing(issue_fields, release, value, tuple(f"{project}-{blocker}" for blocker in blockers)) def project_of(key: str) -> str: @@ -241,8 +262,8 @@ def issue_of(raw: object) -> Issue | Failure: def plan_of(issues: list[Issue], epic: Epic, to_markdown: ToMarkdown) -> Plan | Failure: """The plan the issues hold, in their order.""" - project = epic.key.rpartition("-")[0] - if strangers := [issue.key for issue in issues if issue.key.rpartition("-")[0] != project]: + project = project_of(epic.key) + if strangers := [issue.key for issue in issues if project_of(issue.key) != project]: return Failure(f"{strangers[0]} is a child of {epic.key} in another Jira project, and an item's ID is its number in {project}; move it into {project} or out of the epic") ids = {issue.number for issue in issues} items = [item(issue, project, ids) for issue in issues] @@ -279,7 +300,7 @@ def item(issue: Issue, project: str, ids: set[int]) -> Item | Failure: scored = scores(issue.key, issue.scores) if isinstance(scored, Failure): return scored - blockers = {number(key) for key in issue.blockers if key.rpartition("-")[0] == project} + blockers = {number(key) for key in issue.blockers if project_of(key) == project} return Item(issue.number, release, scored[2], bold_cell(issue.summary), scored[0], scored[1], tuple(sorted(blockers & ids)), "") diff --git a/bin/plan_store/stores.py b/bin/plan_store/stores.py index f1278ce3..8d466ed8 100644 --- a/bin/plan_store/stores.py +++ b/bin/plan_store/stores.py @@ -1,6 +1,6 @@ """The one way a tool reads or writes a project's plan: through the store its config names. -The config's `plan` setting names the backend. A path names a markdown file, todo.md. `jira:` and an epic's address name a Jira epic, whose open child issues `jira_epic` reads, and where it files an item as a new one. An agent reads and changes the plan with `todo-item`, which works through the same store. +The config's `plan` setting names the backend. A path names a markdown file, todo.md. `jira:` and an epic's address name a Jira epic, whose open child issues are the plan: `jira_epic` reads them, and files an item as a new child issue. An agent reads and changes the plan with `todo-item`, which works through the same store. A tool that reads what a past commit held, such as `score-outcomes`, still parses that commit's todo.md itself, with `release_plan.todo_table`: only the markdown backend has commits, and todo.md's items 365, 366 and 368 port those tools to the other backends.""" import dataclasses @@ -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 and files, and fails an edit or a finish until todo.md's items 382 and 383. A write that fails leaves the plan as it was.""" + """A project's plan. plan_store.contract holds every backend that writes to the same behaviour; `jira_epic` reads and files, and fails an edit or a finish until todo.md's items 382 and 383. A write that fails leaves the plan as it was, except where its Failure says a tracker may hold the item all the same, as when Jira's answer to a new issue is lost.""" @property def label(self) -> str: diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index b0592299..b1c258bd 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -223,6 +223,8 @@ class JiraPlan(unittest.TestCase): ISSUES = "https://acme.atlassian.net/rest/api/3/issue" LINKS = "https://acme.atlassian.net/rest/api/3/issueLink" +VERSIONS = "https://acme.atlassian.net/rest/api/3/project/ABC/versions" +PERHAPS_FILED = "unless Jira refused the request, the issue may exist: look under ABC-12 before filing the item again" FIELDS = {"Release": "0.1.0", "Tagline": "Count the runs.", "L": "1", "E": "2", "I": "3", "S": "1", "Moves": "1 by 9"} PROPERTY = {"L": 1, "E": 2, "I": 3, "S": 1, "Moves": "1 by 9", "Exempt": "", "Filed by": "loop"} @@ -236,12 +238,13 @@ class Filing(unittest.TestCase): self.open: list[dict[str, object]] = [] self.created: object = {"id": "10040", "key": "ABC-40"} self.linked: object = None + self.versions: object = [{"name": "0.1.0"}, {"name": "v0.2.0"}, "odd"] def http(self, method: str, url: str, authorization: str, body: object) -> object: - """Stands in for Jira: answers the epic, self.open to the search, self.created to a new issue and self.linked to a new link.""" + """Stands in for Jira: answers the epic, self.versions for the project's Fix Versions, self.open to the search, self.created to a new issue and self.linked to a new link.""" self.calls.append((method, url, body)) assert authorization == AUTHORIZATION - return {SEARCH: {"issues": self.open}, ISSUES: self.created, LINKS: self.linked}.get(url, {"key": "ABC-12"}) + return {SEARCH: {"issues": self.open}, ISSUES: self.created, LINKS: self.linked, VERSIONS: self.versions}.get(url, {"key": "ABC-12"}) def to_adf(self, markdown: str) -> dict[str, object] | Failure: return adf(markdown) @@ -254,7 +257,7 @@ class Filing(unittest.TestCase): def test_files_the_item_as_a_task_under_the_epic_marked_as_the_loops(self): self.assertEqual(self.add(), Written(40)) - self.assertEqual(self.calls, [("POST", ISSUES, { + self.assertEqual(self.calls, [("GET", VERSIONS, None), ("POST", ISSUES, { "fields": {"project": {"key": "ABC"}, "parent": {"key": "ABC-12"}, "issuetype": {"name": "Task"}, "summary": "Count the runs.", "fixVersions": [{"name": "0.1.0"}]}, "properties": [{"key": "plan-item", "value": PROPERTY}], })]) @@ -324,22 +327,40 @@ class Filing(unittest.TestCase): def test_an_item_jira_refuses_fails_with_jiras_reason(self): self.created = Failure("POST /rest/api/3/issue answered 400: Version name '0.1.0' is not valid") - self.assertEqual(self.add(), Failure("cannot file the item under ABC-12: POST /rest/api/3/issue answered 400: Version name '0.1.0' is not valid")) + self.assertEqual(self.add(), Failure(f"cannot file the item under ABC-12: POST /rest/api/3/issue answered 400: Version name '0.1.0' is not valid; {PERHAPS_FILED}")) def test_an_answer_that_names_no_issue_of_the_epics_project_fails(self): for answer in ({}, {"key": 7}, {"key": "OTHER-5"}, ["ABC-40"]): with self.subTest(answer=answer): self.created = answer - self.assertEqual(self.add(), Failure("Jira answered the new issue without an issue key in ABC; look for it under ABC-12 before filing the item again")) + self.assertEqual(self.add(), Failure(f"Jira answered the new issue without an issue key in ABC; {PERHAPS_FILED}")) - def test_a_link_jira_refuses_fails_naming_the_issue_it_filed(self): - self.open, self.linked = [issue("ABC-34")], Failure("POST /rest/api/3/issueLink answered 404: No issue link type with name 'Blocks' found.") - self.assertEqual(self.add(FIELDS | {"Blocked by": "34"}), Failure("filed ABC-40, but cannot link it as blocked by ABC-34: POST /rest/api/3/issueLink answered 404: No issue link type with name 'Blocks' found.; link it in Jira, and do not file the item again")) + def test_a_link_jira_refuses_leaves_the_item_filed_with_a_note_and_the_other_links_made(self): + refusal = "POST /rest/api/3/issueLink answered 404: No issue link type with name 'Blocks' found." + self.open, self.linked = [issue("ABC-34"), issue("ABC-35")], Failure(refusal) + self.assertEqual(self.add(FIELDS | {"Blocked by": "34, 35"}), Written(40, tuple(f"filed ABC-40, but cannot link it as blocked by ABC-{blocker}: {refusal}; link it in Jira" for blocker in (34, 35)))) + self.assertEqual(len(self.sent(LINKS)), 2) + + def test_files_under_the_fix_version_as_the_project_spells_it(self): + self.assertEqual(self.add(FIELDS | {"Release": "0.2.0"}), Written(40)) + self.assertEqual(self.sent(ISSUES)[0]["fields"]["fixVersions"], [{"name": "v0.2.0"}]) # type: ignore[index] + + def test_a_release_the_project_has_no_fix_version_for_fails_before_anything_is_filed(self): + for versions in ([{"name": "0.1.0"}], {"name": "0.3.0"}, []): + 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.sent(ISSUES), []) + + def test_fix_versions_that_cannot_be_read_fail_before_anything_is_filed(self): + self.versions = Failure("GET /rest/api/3/project/ABC/versions answered 403: Forbidden") + self.assertEqual(self.add(), Failure("cannot read ABC's Fix Versions: GET /rest/api/3/project/ABC/versions answered 403: Forbidden")) + self.assertEqual(self.sent(ISSUES), []) def test_what_it_files_reads_back_as_the_item(self): self.add(FIELDS | {"Exempt": "owner"}, "Why it counts.") sent, = self.sent(ISSUES) - raw = {"key": "ABC-40", "fields": sent["fields"] | {"issuelinks": []}, "properties": {entry["key"]: entry["value"] for entry in sent["properties"]}} # type: ignore[index] + raw = {"key": "ABC-40", "fields": sent["fields"] | {"issuelinks": []}, "properties": {entry["key"]: entry["value"] for entry in sent["properties"]}} # type: ignore[index, operator, union-attr] filed = jira_epic.issue_of(raw) assert isinstance(filed, jira_epic.Issue), filed plan = jira_epic.plan_of([filed], EPIC, lambda documents: [text_of(document) for document in documents]) diff --git a/bin/todo_item/main.py b/bin/todo_item/main.py index 22e59c2c..2177d4be 100644 --- a/bin/todo_item/main.py +++ b/bin/todo_item/main.py @@ -29,9 +29,10 @@ add files the item under the next free ID, with the tagline in bold, and the det stdin, if any. The detail may hold no ## or ### heading. It prints `Filed item in .` It doesn't write anything where ranking fails or scores the item under the bar. In a Jira epic, add files a Task under the epic, last in the backlog, and is the new issue's -number. The release must be one of the Jira project's Fix Versions, and --exempt security also -labels the issue `security`. No bar applies there yet. Where Jira files the issue and then refuses -a --blocked-by link, add fails, naming the issue: link it in Jira, and don't file it again. +number. The release must be one of the Jira project's Fix Versions, named as 1.2.0 or v1.2.0 there, +and --exempt security also labels the issue `security`. No bar applies there yet. Where Jira files +the issue and then refuses a --blocked-by link, add still prints `Filed item …`, and says on +stderr which link to make in Jira. edit sets the cells whose flag is given and leaves the rest; an empty value, as in --blocked-by "", empties the cell. --detail replaces the detail with the text on stdin, and --clear-detail removes it. @@ -49,7 +50,8 @@ mistake. It prints `Finished item in .` It doesn't write anything whi finish --no-changelog also drops an item no chunk built. 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. +`not edited:`, `not moved:` or `not finished:` means it didn't write anything. The one exception is an add to a +Jira epic that Jira didn't answer or answered brokenly: the message then says the issue may exist. """ import argparse import pathlib diff --git a/docs/decisions.md b/docs/decisions.md index cae5221a..eafaf307 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -302,7 +302,7 @@ Messages keep each file's usual name, such as `todo.md`, as its label, since the - **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 loop files an item as a Task under the epic, and marks it as its own** (item 352, on 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 the one issue type every Jira Cloud project template has; a project without it refuses the issue, saying so. 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, and a link Jira still refuses leaves the issue filed, which the failure says. +- **The loop files an item as a Task under the epic, and marks it as its own** (item 352, on 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 and files, and doesn't edit or finish an issue** until todo.md's items 382 and 383. `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 diff --git a/rules/todo-items.md b/rules/todo-items.md index b35497d0..3725f937 100644 --- a/rules/todo-items.md +++ b/rules/todo-items.md @@ -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 one there, and nothing edits, moves or finishes one 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` can't edit, move or finish 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. - **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 --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. diff --git a/todo.md b/todo.md index 10bbe51b..61a8f54c 100644 --- a/todo.md +++ b/todo.md @@ -85,7 +85,7 @@ lilleman's calls, 2026-11-12. Without asking, the loop may create child issues in the epic, edit the summary, description and scores of issues it created, and comment on and transition any issue in the epic. It never edits the summary or description of an issue a person filed. A security finding is filed in the epic like any item, labelled `security`, never with a secret's value. R is above 5, so this item ships alone. -Split from the first item 352 on 2026-11-15, which also held what the items it now blocks take: editing and scoring, finishing, and ranking. The filed issue holds the scores in the `plan-item` issue property, with a mark that the loop filed it, which the edit item reads. Jira puts a new issue last in the backlog until the ranking item ships. +On 2026-11-15 this item was split in four. Item 382 took editing and scoring, item 383 finishing, and item 384 ranking. The filed issue holds the scores in the `plan-item` issue property, with a mark that the loop filed it, which item 382 reads. Jira puts a new issue last in the backlog until item 384 ships. Touches: - `bin/plan_store/jira_epic.py`: the module docstring, `JiraPlan.add`, and new functions that check the fields and build the issue @@ -112,7 +112,7 @@ lilleman's call, 2026-11-12: the folder replaces the default, as item 347's prin ### 383. Move a finished item of a Jira plan by the transition, and to the status, that the project's config names. -Split from item 352 on 2026-11-15; lilleman's call, 2026-11-12: a finished item moves by the transition and to the status the config names, since each Jira workflow differs. The loop may transition any issue in the epic. A bench of readers, seated as the person who writes a client's `config.toml`, picks the setting's spelling. `PlanStore`'s docstring then stops saying `jira_epic` only reads, once this item and the edit item have shipped. +Split from item 352 on 2026-11-15; lilleman's call, 2026-11-12: a finished item moves by the transition and to the status the config names, since each Jira workflow differs. The loop may transition any issue in the epic. A bench of readers, seated as the person who writes a client's `config.toml`, picks the setting's spelling. Once this item and item 382 have shipped, `PlanStore`'s docstring stops saying that `jira_epic` fails an edit or a finish. Touches: - `bin/plan_store/jira_epic.py`: `JiraPlan.finish` -- 2.52.0 From fe31d6eae53f154171ca4cad99f2a2d88e10ab56 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:35:48 +0100 Subject: [PATCH 09/14] =?UTF-8?q?Answer=20product-owner=20round=201:=201?= =?UTF-8?q?=20=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20file=20u?= =?UTF-8?q?nder=20the=20Fix=20Version=20as=20the=20project=20spells=20it,?= =?UTF-8?q?=20and=20check=20it=20before=20filing=20(fixed=20in=20the=20sta?= =?UTF-8?q?bility=20round's=20commit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 669a2833c5f1cac78600e835a58b4aa8e6500c17 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:35:48 +0100 Subject: [PATCH 10/14] =?UTF-8?q?Answer=20prose=20round=201:=203=20?= =?UTF-8?q?=F0=9F=94=B4,=207=20=F0=9F=9F=A1=20(1=20misread);=20make=20the?= =?UTF-8?q?=20help=20and=20PlanStore=20true=20of=20a=20filed=20issue,=20an?= =?UTF-8?q?d=20name=20items=20by=20ID=20(fixed=20in=20the=20stability=20ro?= =?UTF-8?q?und's=20commit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 0aa89d283e0754c351e79673f6efb8d324eb4f5e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:42:32 +0100 Subject: [PATCH 11/14] Test a Fix Versions answer that is no list --- bin/plan_store/test_jira_epic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index b1c258bd..16bac3e8 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -346,7 +346,7 @@ class Filing(unittest.TestCase): self.assertEqual(self.sent(ISSUES)[0]["fields"]["fixVersions"], [{"name": "v0.2.0"}]) # type: ignore[index] def test_a_release_the_project_has_no_fix_version_for_fails_before_anything_is_filed(self): - for versions in ([{"name": "0.1.0"}], {"name": "0.3.0"}, []): + 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")) -- 2.52.0 From 155f1e873c23770d47f851f5bc0cf26f08f9ac0f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:46:03 +0100 Subject: [PATCH 12/14] =?UTF-8?q?Answer=20stability=20round=202:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20read=20an?= =?UTF-8?q?=20empty=20answer=20to=20a=20new=20link=20as=20success,=20and?= =?UTF-8?q?=20skip=20a=20Fix=20Version=20whose=20name=20is=20no=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/mattermost_dm/dm.py | 2 +- bin/plan_store/jira_epic.py | 4 ++-- bin/plan_store/test_jira_epic.py | 2 +- bin/rest_client/json_request.py | 6 ++++-- bin/rest_client/test_json_request.py | 6 ++++++ bin/slack_dm/dm.py | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/mattermost_dm/dm.py b/bin/mattermost_dm/dm.py index e99f47dd..85ed5683 100644 --- a/bin/mattermost_dm/dm.py +++ b/bin/mattermost_dm/dm.py @@ -54,7 +54,7 @@ def id_of(answer: object, request: str) -> str | Failure: def http_json(method: str, url: str, token: str, body: object) -> object: - """The JSON that url answers to the bot's request, or a Failure saying why there is none.""" + """The JSON that url answers to the bot's request, None where the answer has no body, or a Failure saying why there is none.""" return json_request.http_json(method, url, f"Bearer {token}", body, TIMEOUT, error_message) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 38c79e20..1d59fca6 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -40,7 +40,7 @@ SECURITY = "security" # What a failed create ends with: a request Jira never answered, or answered brokenly, may still have filed the issue. PERHAPS_FILED = "unless Jira refused the request, the issue may exist: look under {epic} before filing the item again" -# Sends a request with the Authorization header given, the body as JSON where there is one, and returns the JSON answer, or a Failure saying why there is none. +# 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] ToMarkdown = typing.Callable[[list[dict[str, typing.Any]]], list[str] | Refused | Failure] ToAdf = typing.Callable[[str], dict[str, typing.Any] | Failure] @@ -144,7 +144,7 @@ class JiraPlan: versions = self.http("GET", f"{self.epic.site}/rest/api/3/project/{project}/versions", authorization, None) if isinstance(versions, Failure): return Failure(f"cannot read {project}'s Fix Versions: {versions.reason}") - names = {version.get("name") for version in versions if isinstance(version, dict)} if isinstance(versions, list) else set() + 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") def missing_blocker(self, blockers: tuple[str, ...], authorization: str) -> Failure | None: diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 16bac3e8..20f496d6 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -238,7 +238,7 @@ class Filing(unittest.TestCase): self.open: list[dict[str, object]] = [] self.created: object = {"id": "10040", "key": "ABC-40"} self.linked: object = None - self.versions: object = [{"name": "0.1.0"}, {"name": "v0.2.0"}, "odd"] + self.versions: object = [{"name": "0.1.0"}, {"name": "v0.2.0"}, "odd", {"name": ["0.1.0"]}, {"name": {"en": "0.1.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.created to a new issue and self.linked to a new link.""" diff --git a/bin/rest_client/json_request.py b/bin/rest_client/json_request.py index 369cda81..a60f36ab 100644 --- a/bin/rest_client/json_request.py +++ b/bin/rest_client/json_request.py @@ -19,14 +19,14 @@ class NoRedirect(urllib.request.HTTPRedirectHandler): return None -# Sends a request: method, url, token and the body as JSON where there is one. It returns the JSON answer, or a Failure saying why there is none. +# Sends a request: method, url, token and the body as JSON where there is one. It 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] OPENER = urllib.request.build_opener(NoRedirect) def http_json(method: str, url: str, authorization: str, body: object, seconds: int, message_of: MessageOf) -> object: - """The JSON that url answers to a request with the Authorization header given, and body as JSON where there is one. A Failure names the server where it cannot be reached, and the request where it answers an error, breaks HTTP or answers something other than JSON. Each connect and each read may wait that many seconds.""" + """The JSON that url answers to a request with the Authorization header given, and body as JSON where there is one; None where it answers a success without a body, as Jira does to a new issue link. A Failure names the server where it cannot be reached, and the request where it answers an error, breaks HTTP or answers something other than JSON. Each connect and each read may wait that many seconds.""" request_name = f"{method} {urllib.parse.urlsplit(url).path}" data = None if body is None else json.dumps(body).encode() request = urllib.request.Request(url, data, {"Authorization": authorization, "Content-Type": "application/json", "Accept": "application/json"}, method=method) @@ -41,6 +41,8 @@ def http_json(method: str, url: str, authorization: str, body: object, seconds: except (OSError, ValueError) as failure: server = urllib.parse.urlunsplit(urllib.parse.urlsplit(url)[:2] + ("", "", "")) return Failure(f"cannot reach {server}: {getattr(failure, 'reason', failure)}") + if not raw.strip(): + return None try: return json.loads(raw) except ValueError: diff --git a/bin/rest_client/test_json_request.py b/bin/rest_client/test_json_request.py index 845747d3..b3e1fd64 100644 --- a/bin/rest_client/test_json_request.py +++ b/bin/rest_client/test_json_request.py @@ -66,6 +66,12 @@ class HttpJson(unittest.TestCase): [(method, path, headers, body)] = self.server.got # type: ignore[attr-defined] self.assertEqual((method, path, headers["Authorization"], headers["Content-Type"], headers["Accept"], json.loads(body)), ("POST", "/api/v4/posts", "Bearer secret-token", "application/json", "application/json", {"message": "hi"})) + def test_reads_an_answer_without_a_body_as_none(self): + for body in (b"", b"\n"): + with self.subTest(body=body): + base = self.serve((201, body)) + self.assertIsNone(send("POST", f"{base}/rest/api/3/issueLink", "t", {"type": {"name": "Blocks"}})) + def test_names_the_request_the_status_and_the_apis_message_on_an_error(self): base = self.serve((401, b'{"message": "Invalid or expired session, please login again."}')) self.assertEqual(send("GET", f"{base}/api/v4/users/me", "bad", None), Failure("GET /api/v4/users/me answered 401: Invalid or expired session, please login again.")) diff --git a/bin/slack_dm/dm.py b/bin/slack_dm/dm.py index 201c5fd7..f96fe94c 100644 --- a/bin/slack_dm/dm.py +++ b/bin/slack_dm/dm.py @@ -42,7 +42,7 @@ def send(config: Config, message: str, http: Http) -> Failure | None: def http_json(method: str, url: str, token: str, body: object) -> object: - """The JSON that url answers to the bot's request, or a Failure saying why there is none.""" + """The JSON that url answers to the bot's request, None where the answer has no body, or a Failure saying why there is none.""" return json_request.http_json(method, url, f"Bearer {token}", body, TIMEOUT, error_message) -- 2.52.0 From a9c15b79a02eda9bb562359983ab162cf448373d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:46:21 +0100 Subject: [PATCH 13/14] =?UTF-8?q?Answer=20product-owner=20round=202:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20every=20?= =?UTF-8?q?answer=20holds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 73f7cf1a62f2a91b279b939da4bad270c104ad97 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 03:55:46 +0100 Subject: [PATCH 14/14] Drop item 352 from the plan: shipped --- CHANGELOG.md | 1 + docs/decisions.md | 2 +- todo.md | 30 +++++++----------------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index feb662a4..ca62d14f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `todo-item add` files an item into a plan kept in a Jira epic: a Task under the epic, under the project's Fix Version for the release, labelled `security` for a security finding and linked to each item that blocks it. Editing and finishing an issue still happen in Jira. - An item of the next release may predict the files and parts it will touch, under a `Touches:` line in its detail. `chunk-preflight` then names the items that may start chunks at once, and the new `touch-predictions record` keeps each prediction beside what the merged chunk touched, in the record a project's config places with `touch-predictions`. - CLAUDE.md and the todo-items rule define the plan as a todo.md or a Jira epic, and say plan where todo.md was false for a Jira plan. - Reviewers without a shell read the plan from a listing that larv-review writes into the review folder, whichever store holds it. diff --git a/docs/decisions.md b/docs/decisions.md index eafaf307..04928fbd 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -302,7 +302,7 @@ Messages keep each file's usual name, such as `todo.md`, as its label, since the - **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 loop files an item as a Task under the epic, and marks it as its own** (item 352, on 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 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 and files, and doesn't edit or finish an issue** until todo.md's items 382 and 383. `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 diff --git a/todo.md b/todo.md index 61a8f54c..45f46286 100644 --- a/todo.md +++ b/todo.md @@ -12,15 +12,14 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 352 | 0.11.0 | | | **File a plan item as a child issue of the project's Jira epic, marked as the loop's, with a security finding labelled `security`.** | 4 | 2 | 3 | 7 | 4 | 1.6 by 4 | 1.1 | -| 384 | 0.11.0 | 352 | question | **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 | +| 384 | 0.11.0 | | question | **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 | | 355 | 0.11.0 | | | **Store a record on the Confluence Cloud page its config names, as markdown converted through the adf-codec shim, and interrupt the human when a teammate saved the page since the loop read it.** | 3 | 2 | 3 | 6 | 5 | 1.6 by 6 | 1.2 | | 356 | 0.11.0 | | | **Hand reviewers the review standards from the folder a project's config names, in place of `~/.claude/skills/larv-review/standards/`.** | 2 | 2 | 3 | 5 | 2 | 1.6 by 3 | 1.1 | | 383 | 0.11.0 | | | **Move a finished item of a Jira plan by the transition, and to the status, that the project's config names.** | 4 | 2 | 3 | 7 | 3 | 1.6 by 3 | 1.0 | | 372 | 0.11.0 | | | **Key loop-claude's session, archive, routing state and config-folder commits per chunk, so two chunks of one project run side by side without touching each other's state.** | 3 | 2 | 3 | 6 | 6 | 1.5 by 3 | 0.4 | | 374 | 0.11.0 | 372 | decision | **Merge open chunks one at a time: rebase, finish the item in todo.md and CHANGELOG.md, rerun the gate and the paired ruling, and keep a chunk waiting for approval in the queue without blocking the next.** | 4 | 2 | 3 | 7 | 6 | 1.5 by 4, 1.6 by 3 | 1.0 | | 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 | 352 | | **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 | +| 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 | | 375 | 0.11.0 | 372, 374 | 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 | | 309 | 0.12.0 | | | **Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.** | 2 | 2 | 2 | 4 | 2 | 1.4 by 3 | 1.2 | @@ -34,10 +33,10 @@ | 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 | 352, 382, 383 | | **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 | 352, 382, 383 | | **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 | 352, 382, 383 | | **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 | 352, 382, 383, 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 | +| 365 | 0.13.0 | 382, 383 | | **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, 383 | | **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, 383 | | **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, 383, 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 | @@ -81,21 +80,6 @@ ## Details -### 352. File a plan item as a child issue of the project's Jira epic, marked as the loop's, with a security finding labelled `security`. - -lilleman's calls, 2026-11-12. Without asking, the loop may create child issues in the epic, edit the summary, description and scores of issues it created, and comment on and transition any issue in the epic. It never edits the summary or description of an issue a person filed. A security finding is filed in the epic like any item, labelled `security`, never with a secret's value. R is above 5, so this item ships alone. - -On 2026-11-15 this item was split in four. Item 382 took editing and scoring, item 383 finishing, and item 384 ranking. The filed issue holds the scores in the `plan-item` issue property, with a mark that the loop filed it, which item 382 reads. Jira puts a new issue last in the backlog until item 384 ships. - -Touches: -- `bin/plan_store/jira_epic.py`: the module docstring, `JiraPlan.add`, and new functions that check the fields and build the issue -- `bin/plan_store/test_jira_epic.py`: new tests of `add` -- `bin/plan_store/stores.py`: the module docstring, `PlanStore`'s docstring, `store` -- `bin/todo_item/main.py`: the help -- `docs/decisions.md`: "project config: `plan` may name a Jira Cloud epic …" -- `rules/todo-items.md`: the first bullet -- `CLAUDE.md` → "Working loop": the sentences on a plan in Jira - ### 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. @@ -143,7 +127,7 @@ lilleman's call, 2026-11-12: what a release is differs per client. With none, it ### 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 item 352's mark 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. +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` -- 2.52.0