From 90cc5e473a86f1aca214f6f2381823991ec32a35 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Fri, 13 Nov 2026 06:11:25 +0000 Subject: [PATCH 1/2] fix(roadmap): title the delivery by the summary of its plan The implement job wrote the summary of the issue title in the title of the delivery pull request. An issue title often states a goal, and the plan states a smaller change, so the squash commit and the changelog line claimed work that the change did not do (#5336 for #3785). The job now reads the summary of the plan from the subject of the commit that adds the change folder: the stage commit on a staged branch, or the squash commit of the plan pull request on the default branch. The title keeps the type and the declared scope of the issue. The summary of the issue title stands in when that subject holds no plan title, or when the form refuses the title with the plan summary. Refs #5341 --- docs/roadmap/implement.md | 2 +- .../.openspec.yaml | 3 + .../design.md | 17 +++++ .../proposal.md | 50 +++++++++++++ .../pull-request/spec.md | 45 ++++++++++++ .../tasks.md | 26 +++++++ .../roadmap/implement/implement_run.py | 33 +++++++-- src/devops_cli/roadmap/stage/stage_change.py | 34 ++++++--- .../implement/test_roadmap_implement_job.py | 46 +++++++++++- .../roadmap/stage/test_roadmap_stage_title.py | 70 +++++++++++++++++++ tests/support/roadmap_implement.py | 32 +++++++-- 11 files changed, 333 insertions(+), 25 deletions(-) create mode 100644 openspec/changes/5341-title-the-delivery-by-its-plan/.openspec.yaml create mode 100644 openspec/changes/5341-title-the-delivery-by-its-plan/design.md create mode 100644 openspec/changes/5341-title-the-delivery-by-its-plan/proposal.md create mode 100644 openspec/changes/5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md create mode 100644 openspec/changes/5341-title-the-delivery-by-its-plan/tasks.md diff --git a/docs/roadmap/implement.md b/docs/roadmap/implement.md index a907673ae0..ae287e2052 100644 --- a/docs/roadmap/implement.md +++ b/docs/roadmap/implement.md @@ -69,7 +69,7 @@ For each item, the job does these things in order: 3. It regenerates the documentation and archives the change, each step only where the default branch of the target declares it in `.devops/roadmap.toml` (`[implement.steps]` with `docs = true` and `archive = true`). The Job reads the file from the default branch, so an edit of the checkout adds or removes no step. A default branch with no file declares no step. A step that the Job skips has a line in its comment on the pull request. devops-cli declares both steps. 4. It runs the scoped checks: the pre-push stage of the hooks, the `devops ci` rows `constructs`, `docs` and `openspec`, and the tests that cover the changed files. A failed check gets a fix step. A stop here still pushes the commits that passed, and the draft stays a draft. 5. It pushes. -6. It sets the title and the body of the pull request: the title of the issue, and a body that `build_body` of `pull_form` builds. The body is the Why of the archived proposal, the line `Closes #`, then the line `Change:` with the archived folder, or the active folder when the project declares no archive step. The job cuts no text. A Why that does not fit in the 1,000 characters, or that holds a closing keyword, gives way to the title of the issue. A body that breaks the form stops the item at the step `pull request`, before the job writes it. It adds the labels of the new title and removes the labels of the staging title that do not fit. A refused label is a comment on the pull request. +6. It sets the title and the body of the pull request. The title has the type and the declared scope of the title of the issue, and the summary of the plan: the text after `docs(openspec): plan #` in the subject of the commit that adds the change folder, without the end `(#)` of a squash merge. That subject is the title of the plan pull request, so the title names the change that the branch makes, and not the goal of the issue. The summary of the title of the issue stands in when that commit has no plan title, or when the form refuses the title with the summary of the plan. The job also writes this title when it opens the draft of a Planned item. The body is one that `build_body` of `pull_form` builds. The body is the Why of the archived proposal, the line `Closes #`, then the line `Change:` with the archived folder, or the active folder when the project declares no archive step. The job cuts no text. A Why that does not fit in the 1,000 characters, or that holds a closing keyword, gives way to the title of the issue. A body that breaks the form stops the item at the step `pull request`, before the job writes it. It adds the labels of the new title and removes the labels of the staging title that do not fit. A refused label is a comment on the pull request. 7. It watches the checks of the pull request, and runs a fix step for each failed check. The setting `roadmap.implement.repair_rounds` bounds the rounds. A fix step may change only the paths that the plan names and the files of the change folder (the repair scope). A failed check whose log names no path of the repair scope gets no fix step: the job makes no model request, and it stops the item as Blocked with a reason that names the check and the repair scope. 8. It asks `draft_readiness` and stops with the reason on a refusal, then marks the pull request ready. diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/.openspec.yaml b/openspec/changes/5341-title-the-delivery-by-its-plan/.openspec.yaml new file mode 100644 index 0000000000..34aeac47ab --- /dev/null +++ b/openspec/changes/5341-title-the-delivery-by-its-plan/.openspec.yaml @@ -0,0 +1,3 @@ +schema: spec-driven +created: 2026-11-13 +skip_specs: false diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/design.md b/openspec/changes/5341-title-the-delivery-by-its-plan/design.md new file mode 100644 index 0000000000..8ddaa54084 --- /dev/null +++ b/openspec/changes/5341-title-the-delivery-by-its-plan/design.md @@ -0,0 +1,17 @@ +# Design + +## Decisions + +- **The source is the commit that adds the change folder.** The stage job commits the plan with the plan title (`stage.py`, `_git(path, "commit", "-q", "-m", change.title, ...)`), the step `fix-plan` writes it again as one commit with the plan title, and a squash merge writes the title of the plan pull request and the end `(#)`. So the newest commit of `HEAD` that adds `openspec/changes/-*/proposal.md` holds the current plan title on a staged branch, on a Planned branch and on the retry of either. The read is local: it sends no request to GitHub. +- **The path glob uses `:(glob)`**, so `*` matches in one folder only, and `-` with its hyphen does not match a longer issue number. +- **The type and the scope stay the ones of the issue.** The plan title has the type `docs(openspec)`, which the delivery must not keep (#2714). `delivery_title` keeps its scope rule (#2800). +- **The issue summary stands in** when the subject holds no plan title, for example a plan that a person committed with another subject, or when the form refuses the title with the plan summary. The stage schema limits a plan summary to 47 characters, so only a person's longer plan title can be refused. The title of the issue then gives the old behavior, and a title that the form refuses still stops the item. +- **The summary keeps its first letter as the plan wrote it.** The check `Semantic PR title` accepts a capital letter (#4980 had `Fix check-readiness ...`), and a change of case would break a name such as `OpenSpec`. + +## Rejected alternatives + +- **The first bullet of "What Changes"** (the design of #4127): the bullets are full sentences. For #3785 the first bullet has 169 characters and for #4697 188, over the limit of 60, so the job would fall back to the issue title in the very case of #5341. +- **The title of the plan pull request through `stage.pr`**, as `devops roadmap retitle` does: on a Staged item (#4980) the plan pull request becomes the delivery pull request. After the first write of the delivery title it holds no plan title, so a retry would go back to the issue title. It also costs a GitHub request. +- **A new record key with the plan summary**: the stage job would write it, but the step `fix-plan` and a person's edit of the plan title would not change it, and the items that are staged now have no such key. +- **A model call that writes the title**: the plan already holds a checked summary, and a model call costs tokens and gives a title that no check ties to the plan. +- **A type from the changed paths** (#4127): it is a different decision with its own design, and #5341 asks only for the summary. It stays open in #4127. diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/proposal.md b/openspec/changes/5341-title-the-delivery-by-its-plan/proposal.md new file mode 100644 index 0000000000..cd973f91e4 --- /dev/null +++ b/openspec/changes/5341-title-the-delivery-by-its-plan/proposal.md @@ -0,0 +1,50 @@ +# Proposal: #5341 + +## Why + +The implement job copies the summary of the issue title into the title of the delivery pull request, and the squash commit and the changelog line take that title (#5341). An issue title often states a goal, and the plan often states a smaller change. For #3785 the issue title is `fix(k8s): find the source of the host crashes`, but #5336 only removes a profiler exclusion. Its squash commit and its changelog line say that the change found the source of the crashes. The plan of each item already has a short summary of the change: the stage job writes it in the title of the plan pull request, `docs(openspec): plan # `. + +## What Changes + +- Add `plan_summary` to `src/devops_cli/roadmap/stage/stage_change.py`, beside `staging_title`: it reads the summary of the plan of an item from the subject of the commit that adds its change folder. It removes the end `(#)` that GitHub adds to a squash commit. It gives None for a subject that is no plan title of the item. +- Give `delivery_title` an optional `summary`, the summary of the plan. The title keeps the type and the declared scope of the issue title. With no `summary`, the title keeps the summary of the issue title. +- Add `_plan_summary` to `src/devops_cli/roadmap/implement/implement_run.py`: one `git log -1 --diff-filter=A` on `HEAD` for `openspec/changes/-*/proposal.md`. On a staged branch that commit is the commit of the stage job. On the default branch it is the squash commit of the plan pull request. +- `_delivery_title` uses the summary of the plan when the form accepts the title. Else it uses the summary of the issue title, and a title that the form refuses still stops the item. The body keeps `Closes #`. +- Add tests with the real issue titles and plan subjects of #5336, #5324, #5355 and #4980, and tests of a Staged item, a Planned item and a plan summary that the form refuses. +- Update `docs/roadmap/implement.md`, step 6. +- The change carries a spec delta: the title of the delivery pull request is behavior that a person and release-please observe. +- The type of the title stays the type of the issue. #4127 asks also for a type from the changed paths. This change does not do that part, and it does not close #4127. +- The change fits one pull request. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `roadmap-implement-job/pull-request`: The pull request that delivers the code has the type of the issue, The summary of the delivery title comes from the plan + +## Impact + +- Code: `src/devops_cli/roadmap/stage/stage_change.py`, `src/devops_cli/roadmap/implement/implement_run.py` +- Documents: `docs/roadmap/implement.md` +- Tests: `tests/roadmap/stage/test_roadmap_stage_title.py`, `tests/roadmap/implement/test_roadmap_implement_job.py`, `tests/support/roadmap_implement.py` +- Release: the implement job runs in the runner image, and `release.yml` builds that image only when release-please makes a release. The fix takes effect after the next release. + +## Feasibility + +- `git show origin/main:src/devops_cli/roadmap/implement/implement_run.py` at `f299667c9`: `_delivery_title` calls `delivery_title(self.target.item.title, declared)`, and `delivery_title` in `stage_change.py` keeps `issue_title.partition(":")[2]` as the summary. The job reads no part of the plan for the title. +- `devops gh api repos/dan-petty/devops-cli/pulls/` for #5336, #5324, #5355 and #4980: each title is the title of its issue (#3785, #4697, #5107 with the undeclared scope `tools` removed, and #2530). +- `git log --diff-filter=A --format=%s origin/main -- openspec/changes//proposal.md` gives the plan titles: `docs(openspec): plan #3785 Remove the profiler exclusion of the node (#5182)`, `docs(openspec): plan #4697 Keep one metric stream for each workload (#5283)` and `docs(openspec): plan #5107 Read the OpenSpec version on PATH in the check (#5333)`. The first commit of #4980 is the stage commit `docs(openspec): plan #2530 Fix readiness files and merged monitor output`. Each summary states the change, and the stage schema limits it to 47 characters, under the 60 of the title. +- Later commits change the folder and do not add it: the plan fix `docs(openspec): plan #3785 name the renamed profiler test (#5310)` changes `proposal.md`, so `--diff-filter=A` skips it. The step `fix-plan` writes the plan as one new commit with the plan title (`src/devops_cli/roadmap/steps/fix_plan.py`, `_push`). +- The first "What Changes" bullet is no usable title: for #3785 it has 169 characters, over the limit of 60. So the job uses the summary of the plan title, which the issue calls the summary of the plan. +- A miss of `git log -1 --diff-filter=A` with the path glob takes about 2.5 s on the 1,657 commits of `origin/main`, and a hit takes 0.14 s. The job calls it at most twice in a run. +- `.github/workflows/release.yml`: the job `runner-image` runs only `if: needs.release-please.outputs.release_created == 'true'`, so a merge alone does not change the runner Jobs. + +## Existing Tool Considered + +- No tool reads the summary of a plan from the project's own plan title. `devops roadmap retitle` already reads a plan summary from the title of the plan pull request (`retitle._plan_title`), through `stage.pr` and a GitHub request. The implement job cannot use that source: on a Staged item the plan pull request becomes the delivery pull request, so after the first title write it holds no plan title. +- commitizen (MIT) checks and writes Conventional Commit messages, but it does not read an OpenSpec plan or a squash subject. +- Cost to build: about 40,000 tokens to write and test, about 2,000 tokens a year to keep, 1 hour of elapsed time. The change deletes no internal code: `delivery_title` stays and gets one optional argument. diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md b/openspec/changes/5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md new file mode 100644 index 0000000000..e930ed34b6 --- /dev/null +++ b/openspec/changes/5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md @@ -0,0 +1,45 @@ +## MODIFIED Requirements + +### Requirement: The pull request that delivers the code has the type of the issue +The job SHALL set the title of the pull request of a Staged or a Planned item to the type and the scope of the issue title and the summary of the plan. Before it writes the title, the job SHALL check it with the form of the pull request and SHALL stop the item when the form refuses it. The job SHALL leave out the scope when `.github/labels.yml` on the default branch declares no label `scope/`. The job SHALL set the title in the same call that sets the body `Closes #`. + +#### Scenario: A Staged item +- **WHEN** the title of the issue is `fix(roadmap): the job drops a comment`, the commit of the staged branch that adds the change folder has the subject `docs(openspec): plan #1 Keep the last comment of a thread`, and the job finishes the change +- **THEN** the title of the pull request becomes `fix(roadmap): Keep the last comment of a thread` + +#### Scenario: An issue that states a goal and a plan that states a smaller change +- **WHEN** the title of issue 3785 is `fix(k8s): find the source of the host crashes` and its plan commit has the subject `docs(openspec): plan #3785 Remove the profiler exclusion of the node (#5182)` +- **THEN** the title of the pull request is `fix(k8s): Remove the profiler exclusion of the node` + +#### Scenario: A summary at the limit +- **WHEN** the item has no plan title and the summary of the title of the issue is 60 UTF-16 code units +- **THEN** the form accepts the title, and the job writes it unchanged + +#### Scenario: A long summary +- **WHEN** the item has no plan title and the summary of the title of the issue is 61 UTF-16 code units +- **THEN** the job stops the item, and the title of the pull request is not written + +#### Scenario: A summary of emoji over the limit +- **WHEN** the item has no plan title and the summary of the title of the issue is 40 emoji of one code point each, which is 80 UTF-16 code units +- **THEN** the job stops the item, and the title of the pull request is not written + +#### Scenario: A scope that no label declares +- **WHEN** the title of the issue is `fix(floor): the job drops a comment` and `.github/labels.yml` declares no `scope/floor` +- **THEN** the title of the pull request is `fix: the job drops a comment` + +## ADDED Requirements + +### Requirement: The summary of the delivery title comes from the plan +The summary of the plan SHALL be the text after `docs(openspec): plan #` and one space in the subject of the newest commit of the branch that adds `proposal.md` to a folder `openspec/changes/-/`, without the end `(#)` that a squash merge adds. The job SHALL use the whole summary of the title of the issue when that subject holds no such text, or when the form of the pull request refuses the title with the summary of the plan. + +#### Scenario: A Planned item +- **WHEN** the commit on `main` that adds the change folder of item 1 has the subject `docs(openspec): plan #1 Keep the last comment of a thread (#4)` +- **THEN** the job opens the draft with the title `fix(roadmap): Keep the last comment of a thread`, and writes the same title when it finishes the change + +#### Scenario: No plan title +- **WHEN** the commit that adds the change folder has the subject `fix(roadmap): plan` and the title of the issue is `fix(roadmap): the job drops a comment` +- **THEN** the title of the pull request is `fix(roadmap): the job drops a comment`, the title of the issue + +#### Scenario: A plan summary that the form refuses +- **WHEN** the summary of the plan has 64 characters, and the title of the issue is `fix(roadmap): the job drops a comment` +- **THEN** the title of the pull request is `fix(roadmap): the job drops a comment`, and the job does not stop the item diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/tasks.md b/openspec/changes/5341-title-the-delivery-by-its-plan/tasks.md new file mode 100644 index 0000000000..3d9ccb54b3 --- /dev/null +++ b/openspec/changes/5341-title-the-delivery-by-its-plan/tasks.md @@ -0,0 +1,26 @@ +# Tasks + +## 1. The delivery title takes the summary of the plan + +Kind: behavior. Reads: `src/devops_cli/roadmap/pull_form.py`, `src/devops_cli/roadmap/stage/stage.py`. Changes: `src/devops_cli/roadmap/stage/stage_change.py`, `src/devops_cli/roadmap/implement/implement_run.py`, `tests/roadmap/stage/test_roadmap_stage_title.py`, `tests/roadmap/implement/test_roadmap_implement_job.py`, `tests/support/roadmap_implement.py`. + +- [x] 1.1 Write the failing tests: `test_the_delivery_title_names_the_change_of_the_plan_and_not_the_goal_of_the_issue` with the real titles and plan subjects of #5336, #5324, #5355 and #4980, `test_a_subject_that_is_no_plan_title_of_the_item_gives_no_summary` and `test_no_plan_summary_keeps_the_summary_of_the_issue` in `tests/roadmap/stage/test_roadmap_stage_title.py`. Add the fixture `plan_subject` and the option `subject` of `push_staged_branch` and `merge_plan` to `tests/support/roadmap_implement.py`. + - Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_title.py` +- [x] 1.2 Write the failing tests `test_the_title_of_a_staged_item_names_the_change_of_its_plan`, `test_the_title_of_a_planned_item_names_the_change_of_its_merged_plan` and `test_a_plan_summary_that_the_form_refuses_gives_way_to_the_summary_of_the_issue` in `tests/roadmap/implement/test_roadmap_implement_job.py`. + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_job.py` +- [x] 1.3 Add `plan_summary` and the argument `summary` of `delivery_title` to `src/devops_cli/roadmap/stage/stage_change.py`. + - Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_title.py` +- [x] 1.4 Add `_plan_summary` to `src/devops_cli/roadmap/implement/implement_run.py`, and make `_delivery_title` use the summary of the plan when the form accepts the title. + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_job.py` + +## 2. Documents + +Kind: documents. Changes: `docs/roadmap/implement.md`. + +- [x] 2.1 Describe the title of the delivery pull request in step 6 of `docs/roadmap/implement.md`. + - Verification: `$ uv run devops ci docs` + +## Workflow follow-up + +- A Conventional Commit type from the changed paths of the plan stays in #4127. +- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD). diff --git a/src/devops_cli/roadmap/implement/implement_run.py b/src/devops_cli/roadmap/implement/implement_run.py index ff513e2373..f47f7478a8 100644 --- a/src/devops_cli/roadmap/implement/implement_run.py +++ b/src/devops_cli/roadmap/implement/implement_run.py @@ -183,6 +183,7 @@ delivery_title, group_text, measure_groups, + plan_summary, safe_text, ) from devops_cli.roadmap.stage.stage_criteria import StageCriterion, criterion_problems @@ -1419,12 +1420,29 @@ def _publish(self, tip: str | None = None) -> int: self.store.set_marks(self._fresh(), {ImplementRecordKey.PR: str(created.number)}) return created.number + def _plan_summary(self) -> str | None: + """The summary of the plan of the item (#5341), from the subject of the newest commit of + the branch that adds the `proposal.md` of its change folder: the commit of the stage job + on a staged branch, or the squash commit of the plan pull request on the default branch. + None when that subject holds no plan title of the item, or no commit adds the file.""" + proposal = f":(glob){CONST_OPENSPEC_CHANGES_DIR}/{self.number}-*/proposal.md" + subject = self._git("log", "-1", "--diff-filter=A", "--format=%s", "HEAD", "--", proposal) + return plan_summary(subject, self.number) + def _delivery_title(self) -> str: - """The title of the pull request: the title of the issue, with a scope that - `.github/labels.yml` declares on the default branch and no other (#2800). The check - `Semantic PR title` counts the summary in UTF-16 units, so a long summary stops the item - before the job writes a title that the check refuses (#3292).""" + """The title of the pull request: the type of the title of the issue, with a scope that + `.github/labels.yml` declares on the default branch and no other (#2800), and the summary + of the plan, which names the change that the branch makes (#5341). The summary of the + title of the issue stands in when the item has no plan title, or when the form refuses the + title with the summary of the plan. The check `Semantic PR title` counts the summary in + UTF-16 units, so a long summary stops the item before the job writes a title that the + check refuses (#3292).""" declared = declared_labels(self.store, ref=None) + summary = self._plan_summary() + if summary is not None: + title = delivery_title(self.target.item.title, declared, summary) + if not title_problems(title, declared): + return title title = delivery_title(self.target.item.title, declared) problems = title_problems(title, declared) if problems: @@ -1474,9 +1492,10 @@ def _body(self, change: str) -> str: ) from exc def _pull_request(self, pull: int) -> None: - """Set the title and the body of the pull request. The title is the one of the issue: the - staging pull request of a Staged item has the type `docs(openspec)` (#2714). The body is - built with `build_body`, so a body that breaks the form stops the item (#3215).""" + """Set the title and the body of the pull request. The title has the type of the issue and + the summary of the plan (`_delivery_title`): the staging pull request of a Staged item has + the type `docs(openspec)` (#2714). The body is built with `build_body`, so a body that + breaks the form stops the item (#3215).""" self.step = MESSAGES.roadmap.implement_step_names["pull_request"] texts = MESSAGES.roadmap archived = self._archived_name() diff --git a/src/devops_cli/roadmap/stage/stage_change.py b/src/devops_cli/roadmap/stage/stage_change.py index 5134f025f6..48cd4f5bec 100644 --- a/src/devops_cli/roadmap/stage/stage_change.py +++ b/src/devops_cli/roadmap/stage/stage_change.py @@ -102,6 +102,8 @@ # A plan is documentation, not a fix or a feature: only the types feat, fix, perf, refactor and # revert add a line to the changelog, so a pull request that only plans an item has this type. STAGING_TYPE: Final[str] = "docs(openspec)" +# The end that GitHub adds to the subject of a squash commit: ` (#)` (CONTRIBUTING.md). +_SQUASH_SUFFIX: Final[re.Pattern[str]] = re.compile(r" \(#[0-9]+\)$") _ELLIPSIS: Final[str] = "..." # A character shows nothing to a reader when its category is a space, a control, a format mark # (such as U+200B or U+FEFF), a surrogate, a private use or an unassigned mark, or when it is one @@ -2817,20 +2819,34 @@ def staging_title(number: int, summary: str) -> str: return f"{STAGING_TYPE}: {lead}{shown}" -def delivery_title(issue_title: str, declared: Collection[str]) -> str: +def plan_summary(subject: str, number: int) -> str | None: + """The summary of the plan of item `number` in `subject`, the subject of the commit that adds + its change folder (#5341). The stage job writes that subject as `staging_title` does, and the + squash merge of the plan pull request writes its title and adds ` (#)`. None when + `subject` is no plan title of the item, or holds no summary.""" + lead = f"{STAGING_TYPE}: {MESSAGES.roadmap.stage_title_lead.format(number=number)}" + title = _SQUASH_SUFFIX.sub("", subject.strip()) + if not title.startswith(lead): + return None + return title.removeprefix(lead).strip() or None + + +def delivery_title(issue_title: str, declared: Collection[str], summary: str | None = None) -> str: """The title of the pull request that delivers the code of an item (#2714): the type and the - scope of the issue's title, and its whole summary. It is never cut, because a cut text ends - with `...` and hides the summary (#3200): the form check of the pull request judges a long - one. The staging pull request has the type `docs(openspec)`, which the delivery must not keep. - A mark of a breaking change is dropped: the project has none before 1.0.0. A scope whose - `scope/*` label is not in `declared` is dropped too, because the `Semantic PR title` check - refuses it (#2800).""" - head, _, summary = issue_title.partition(":") + scope of the issue's title, and `summary`, the summary of the plan (#5341). The issue states a + goal, and the plan states the change that the branch makes. With no `summary`, the title keeps + the whole summary of the issue's title. It is never cut, because a cut text ends with `...` + and hides the summary (#3200): the form check of the pull request judges a long one. The + staging pull request has the type `docs(openspec)`, which the delivery must not keep. A mark + of a breaking change is dropped: the project has none before 1.0.0. A scope whose `scope/*` + label is not in `declared` is dropped too, because the `Semantic PR title` check refuses it + (#2800).""" + head, _, issue_summary = issue_title.partition(":") head = head.strip().removesuffix("!") scope = commit_scope(issue_title) if scope and f"{CONST_ROADMAP_SCOPE_LABEL_PREFIX}{scope}" not in declared: head = head.partition("(")[0] - return f"{head}: {safe_title(summary)}" + return f"{head}: {safe_title(issue_summary if summary is None else summary)}" def pull_request_body(number: int, change: str, proposal: StageProposal) -> str: diff --git a/tests/roadmap/implement/test_roadmap_implement_job.py b/tests/roadmap/implement/test_roadmap_implement_job.py index dbdd84fe4c..c5e09e230c 100644 --- a/tests/roadmap/implement/test_roadmap_implement_job.py +++ b/tests/roadmap/implement/test_roadmap_implement_job.py @@ -30,7 +30,7 @@ plan_implement, ) from devops_cli.roadmap.implement.implement_run import apply_implement, raise_for_failed -from devops_cli.roadmap.pull_form import body_problems +from devops_cli.roadmap.pull_form import SUMMARY_MAX_CHARS, body_problems from devops_cli.roadmap.stage.stage_change import closing_keyword_in from devops_cli.roadmap.stores.store import ImplementRecordKey from tests.support.base_replay import ( @@ -356,6 +356,50 @@ def test_the_title_of_the_pull_request_has_no_scope_that_the_labels_file_lacks( assert patched["title"] == "fix: the job drops a comment" +PLAN_SUMMARY = "Keep the last comment of a thread" + + +@pytest.mark.parametrize("plan_subject", [f"docs(openspec): plan #1 {PLAN_SUMMARY}"]) +def test_the_title_of_a_staged_item_names_the_change_of_its_plan(job_world: JobWorld) -> None: + """The issue states a goal, and the commit of the stage job that adds the change folder holds + the plan title (#5341). The title keeps the type and the scope of the issue and takes the + summary of the plan.""" + job_world.run(two_groups()) + + (patched,) = job_world.sent("PATCH", f"pulls/{PULL}") + assert patched["title"] == f"fix(roadmap): {PLAN_SUMMARY}" + + +@pytest.mark.parametrize("plan_subject", [f"docs(openspec): plan #1 {PLAN_SUMMARY} (#4)"]) +def test_the_title_of_a_planned_item_names_the_change_of_its_merged_plan( + planned_world: JobWorld, +) -> None: + """The squash commit of the plan pull request on `main` holds its title and the ` (#)` + that GitHub adds (#5341). The draft and the final write both take the summary of the plan.""" + planned_world.run(two_groups()) + + (created,) = planned_world.sent("POST", "pulls") + (patched,) = planned_world.sent("PATCH", f"pulls/{PULL}") + assert (created["title"], patched["title"]) == (f"fix(roadmap): {PLAN_SUMMARY}",) * 2 + + +LONG_PLAN_SUMMARY = "Keep the last comment of a thread when the job rewrites the body" + + +@pytest.mark.parametrize("plan_subject", [f"docs(openspec): plan #1 {LONG_PLAN_SUMMARY}"]) +def test_a_plan_summary_that_the_form_refuses_gives_way_to_the_summary_of_the_issue( + job_world: JobWorld, +) -> None: + """A person can give the plan pull request a longer title than the stage schema allows. The + title with the summary of the plan then breaks the form, so the job writes the title of the + issue, as it does for an item with no plan title.""" + job_world.run(two_groups()) + + (patched,) = job_world.sent("PATCH", f"pulls/{PULL}") + assert len(LONG_PLAN_SUMMARY) > SUMMARY_MAX_CHARS + assert patched["title"] == "fix(roadmap): the job drops a comment" + + def test_a_title_that_the_check_refuses_stops_the_item_before_the_job_writes_it( job_world: JobWorld, monkeypatch: pytest.MonkeyPatch ) -> None: diff --git a/tests/roadmap/stage/test_roadmap_stage_title.py b/tests/roadmap/stage/test_roadmap_stage_title.py index f0213065d9..f85f966c60 100644 --- a/tests/roadmap/stage/test_roadmap_stage_title.py +++ b/tests/roadmap/stage/test_roadmap_stage_title.py @@ -19,6 +19,7 @@ StageProposal, content_problems, delivery_title, + plan_summary, staging_title, ) from devops_cli.roadmap.stores.store import ItemField @@ -408,3 +409,72 @@ def test_the_delivery_title_drops_a_scope_that_no_label_declares() -> None: delivery_title("fix(cli, floor): report a clear error", DECLARED), delivery_title("fix: report a clear error", DECLARED), ) == ("fix: report a clear error",) * 3 + + +# Four delivery pull requests of the implement job that took the title of the issue (#5341): the +# item, the title of the issue, the subject of the commit that added its change folder, and the +# title that names the change of the plan. The plans of #3785 (#5336, its node name is a role +# here), #4697 (#5324) and #5107 (#5355) are squash commits on `main`. The plan of #2530 (#4980) +# is the commit of the stage job on its branch. `.github/labels.yml` declares no `scope/tools`. +REAL_DECLARED = (*DECLARED, "scope/github", "scope/k8s", "scope/telemetry") +REAL_DELIVERIES = [ + ( + 3785, + "fix(k8s): find the source of the host crashes", + "docs(openspec): plan #3785 Remove the profiler exclusion of the node (#5182)", + "fix(k8s): Remove the profiler exclusion of the node", + ), + ( + 4697, + "fix(telemetry): keep one metric stream per workload", + "docs(openspec): plan #4697 Keep one metric stream for each workload (#5283)", + "fix(telemetry): Keep one metric stream for each workload", + ), + ( + 5107, + "fix(tools): install-tools --check passes an older openspec binary", + "docs(openspec): plan #5107 Read the OpenSpec version on PATH in the check (#5333)", + "fix: Read the OpenSpec version on PATH in the check", + ), + ( + 2530, + "fix(github): Fix check-readiness base and monitor merged state", + "docs(openspec): plan #2530 Fix readiness files and merged monitor output", + "fix(github): Fix readiness files and merged monitor output", + ), +] + + +@pytest.mark.parametrize(("number", "issue", "subject", "title"), REAL_DELIVERIES) +def test_the_delivery_title_names_the_change_of_the_plan_and_not_the_goal_of_the_issue( + number: int, issue: str, subject: str, title: str +) -> None: + """The issue states a goal, and the plan states the change that the branch makes (#5341). The + title keeps the type and the declared scope of the issue, and the form accepts it.""" + summary = plan_summary(subject, number) + + assert delivery_title(issue, REAL_DECLARED, summary) == title + assert title_problems(title, REAL_DECLARED) == [] + + +@pytest.mark.parametrize( + "subject", + [ + "fix(roadmap): plan", + "fix(k8s): find the source of the host crashes (#5336)", + "docs(openspec): plan #3785", + "docs(openspec): plan #3785 (#5182)", + "docs(openspec): plan #37850 Remove the profiler exclusion (#5182)", + "docs(openspec): archive the change (#3785)", + ], +) +def test_a_subject_that_is_no_plan_title_of_the_item_gives_no_summary(subject: str) -> None: + """A commit of a person, the delivery squash, a plan title with no summary and the plan of + another item hold no summary of the plan of item 3785.""" + assert plan_summary(subject, 3785) is None + + +def test_no_plan_summary_keeps_the_summary_of_the_issue() -> None: + assert delivery_title("fix(config): report a clear error", DECLARED, None) == ( + "fix(config): report a clear error" + ) diff --git a/tests/support/roadmap_implement.py b/tests/support/roadmap_implement.py index 80a4fa204f..31fca9ced0 100644 --- a/tests/support/roadmap_implement.py +++ b/tests/support/roadmap_implement.py @@ -152,10 +152,12 @@ def push_staged_branch( number: int = 1, slug: str = "the-job-drops-a-comment", files: Mapping[str, str] | None = None, + subject: str | None = None, ) -> None: """Push the branch of item `number` with one commit by `author` that adds the change and the `files` of `files`, as the stage job does; the clone stays on `main` with no local branch. - `slug` names the branch and the change folder.""" + `slug` names the branch and the change folder. `subject` is the subject of the commit, which + holds no plan title unless a test gives one.""" branch = branch_of(number, slug) repo.git("switch", "-q", "-c", branch) write_change(repo.clone, tasks, number, slug=slug) @@ -163,7 +165,8 @@ def push_staged_branch( (repo.clone / name).parent.mkdir(parents=True, exist_ok=True) (repo.clone / name).write_text(text, encoding="utf-8") repo.git("add", "-A") - repo.git("-c", f"user.name={author}", "commit", "-q", "-m", "fix(roadmap): plan") + message = subject or "fix(roadmap): plan" + repo.git("-c", f"user.name={author}", "commit", "-q", "-m", message) repo.git("push", "-q", "origin", branch) repo.git("switch", "-q", "main") repo.git("branch", "-q", "-D", branch) @@ -176,12 +179,14 @@ def merge_plan( tasks: str = TASKS, slug: str = "the-job-drops-a-comment", archived: bool = False, + subject: str | None = None, ) -> None: """Merge the change of item `number` into `main` of `origin`, as the merge of its staging - pull request does: one commit on `main`, and no branch.""" + pull request does: one commit on `main`, and no branch. `subject` is the subject of the + commit, which holds no summary of the plan unless a test gives one.""" write_change(repo.clone, tasks, number, slug=slug, archived=archived) repo.git("add", "-A") - repo.git("commit", "-q", "-m", f"docs(openspec): plan #{number}") + repo.git("commit", "-q", "-m", subject or f"docs(openspec): plan #{number}") repo.git("push", "-q", "origin", "main") @@ -256,12 +261,24 @@ def staged_files() -> dict[str, str]: return {} +@pytest.fixture +def plan_subject() -> str | None: + """The subject of the commit that adds the change folder: the commit of the staged branch, or + the merge of the plan into `main`. None keeps a subject with no summary of the plan. A test + parametrizes it to give a plan title (#5341).""" + return None + + @pytest.fixture def staged_repo( - stage_repo: StageRepo, app_slug: None, staged_tasks: str, staged_files: dict[str, str] + stage_repo: StageRepo, + app_slug: None, + staged_tasks: str, + staged_files: dict[str, str], + plan_subject: str | None, ) -> StageRepo: """`stage_repo` with the staged branch pushed.""" - push_staged_branch(stage_repo, tasks=staged_tasks, files=staged_files) + push_staged_branch(stage_repo, tasks=staged_tasks, files=staged_files, subject=plan_subject) return stage_repo @@ -672,6 +689,7 @@ def planned_world( stage_repo: StageRepo, app_slug: None, planned_tasks: str, + plan_subject: str | None, github_api_and_gh: tuple[GitHubApiFake, ProcessFake], config: Callable[..., Path], clock: ClockFake, @@ -680,7 +698,7 @@ def planned_world( ) -> JobWorld: """The job in a runner with a Planned item: the change is on `main`, and no branch and no pull request exist.""" - merge_plan(stage_repo, tasks=planned_tasks) + merge_plan(stage_repo, tasks=planned_tasks, subject=plan_subject) return _world( stage_repo, github_api_and_gh, config, clock, roadmap_store, monkeypatch, planned=True ) From 0b39e5cd1a40f7c0031a8c3cabb95bf2842554d9 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Fri, 13 Nov 2026 06:17:10 +0000 Subject: [PATCH 2/2] docs(openspec): archive 5341-title-the-delivery-by-its-plan Refs #5341 --- .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../pull-request/spec.md | 0 .../tasks.md | 0 .../pull-request/spec.md | 31 +++++++++++++++---- 6 files changed, 25 insertions(+), 6 deletions(-) rename openspec/changes/{5341-title-the-delivery-by-its-plan => archive/2026-11-13-5341-title-the-delivery-by-its-plan}/.openspec.yaml (100%) rename openspec/changes/{5341-title-the-delivery-by-its-plan => archive/2026-11-13-5341-title-the-delivery-by-its-plan}/design.md (100%) rename openspec/changes/{5341-title-the-delivery-by-its-plan => archive/2026-11-13-5341-title-the-delivery-by-its-plan}/proposal.md (100%) rename openspec/changes/{5341-title-the-delivery-by-its-plan => archive/2026-11-13-5341-title-the-delivery-by-its-plan}/specs/roadmap-implement-job/pull-request/spec.md (100%) rename openspec/changes/{5341-title-the-delivery-by-its-plan => archive/2026-11-13-5341-title-the-delivery-by-its-plan}/tasks.md (100%) diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/.openspec.yaml b/openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/.openspec.yaml similarity index 100% rename from openspec/changes/5341-title-the-delivery-by-its-plan/.openspec.yaml rename to openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/.openspec.yaml diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/design.md b/openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/design.md similarity index 100% rename from openspec/changes/5341-title-the-delivery-by-its-plan/design.md rename to openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/design.md diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/proposal.md b/openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/proposal.md similarity index 100% rename from openspec/changes/5341-title-the-delivery-by-its-plan/proposal.md rename to openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/proposal.md diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md b/openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md similarity index 100% rename from openspec/changes/5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md rename to openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/specs/roadmap-implement-job/pull-request/spec.md diff --git a/openspec/changes/5341-title-the-delivery-by-its-plan/tasks.md b/openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/tasks.md similarity index 100% rename from openspec/changes/5341-title-the-delivery-by-its-plan/tasks.md rename to openspec/changes/archive/2026-11-13-5341-title-the-delivery-by-its-plan/tasks.md diff --git a/openspec/specs/roadmap-implement-job/pull-request/spec.md b/openspec/specs/roadmap-implement-job/pull-request/spec.md index c1be4cfb28..48fbf793e4 100644 --- a/openspec/specs/roadmap-implement-job/pull-request/spec.md +++ b/openspec/specs/roadmap-implement-job/pull-request/spec.md @@ -96,22 +96,26 @@ The job SHALL push the branch of a Planned item with `-u origin` when it first h - **THEN** the job removes the branch from `origin`, stops the item, and the record holds no pull request ### Requirement: The pull request that delivers the code has the type of the issue -The job SHALL set the title of the pull request, for a Staged item and for a Planned item, to the type and the scope of the title of the issue and its whole summary. Before it writes the title, the job SHALL check it with the form of the pull request and SHALL stop the item when the form refuses it. The job SHALL leave out the scope when `.github/labels.yml` on the default branch declares no label `scope/`. The job SHALL set the title in the same call that sets the body `Closes #`. +The job SHALL set the title of the pull request of a Staged or a Planned item to the type and the scope of the issue title and the summary of the plan. Before it writes the title, the job SHALL check it with the form of the pull request and SHALL stop the item when the form refuses it. The job SHALL leave out the scope when `.github/labels.yml` on the default branch declares no label `scope/`. The job SHALL set the title in the same call that sets the body `Closes #`. #### Scenario: A Staged item -- **WHEN** the staging pull request of a bug has the title `docs(openspec): plan #1 keep every comment` and the job finishes the change -- **THEN** the title of the pull request becomes `fix(roadmap): the job drops a comment`, the title of the issue +- **WHEN** the title of the issue is `fix(roadmap): the job drops a comment`, the commit of the staged branch that adds the change folder has the subject `docs(openspec): plan #1 Keep the last comment of a thread`, and the job finishes the change +- **THEN** the title of the pull request becomes `fix(roadmap): Keep the last comment of a thread` + +#### Scenario: An issue that states a goal and a plan that states a smaller change +- **WHEN** the title of issue 3785 is `fix(k8s): find the source of the host crashes` and its plan commit has the subject `docs(openspec): plan #3785 Remove the profiler exclusion of the node (#5182)` +- **THEN** the title of the pull request is `fix(k8s): Remove the profiler exclusion of the node` #### Scenario: A summary at the limit -- **WHEN** the summary of the title of the issue is 60 UTF-16 code units +- **WHEN** the item has no plan title and the summary of the title of the issue is 60 UTF-16 code units - **THEN** the form accepts the title, and the job writes it unchanged #### Scenario: A long summary -- **WHEN** the summary of the title of the issue is 61 UTF-16 code units +- **WHEN** the item has no plan title and the summary of the title of the issue is 61 UTF-16 code units - **THEN** the job stops the item, and the title of the pull request is not written #### Scenario: A summary of emoji over the limit -- **WHEN** the summary of the title of the issue is 40 emoji of one code point each, which is 80 UTF-16 code units +- **WHEN** the item has no plan title and the summary of the title of the issue is 40 emoji of one code point each, which is 80 UTF-16 code units - **THEN** the job stops the item, and the title of the pull request is not written #### Scenario: A scope that no label declares @@ -355,3 +359,18 @@ The implement job watch SHALL stop the item when the pull request is merged or c #### Scenario: Closed while the job runs - **WHEN** the watch reads the pull request as closed and not merged - **THEN** the watch stops the item with the reason "The pull request was merged or closed while the job ran." + +### Requirement: The summary of the delivery title comes from the plan +The summary of the plan SHALL be the text after `docs(openspec): plan #` and one space in the subject of the newest commit of the branch that adds `proposal.md` to a folder `openspec/changes/-/`, without the end `(#)` that a squash merge adds. The job SHALL use the whole summary of the title of the issue when that subject holds no such text, or when the form of the pull request refuses the title with the summary of the plan. + +#### Scenario: A Planned item +- **WHEN** the commit on `main` that adds the change folder of item 1 has the subject `docs(openspec): plan #1 Keep the last comment of a thread (#4)` +- **THEN** the job opens the draft with the title `fix(roadmap): Keep the last comment of a thread`, and writes the same title when it finishes the change + +#### Scenario: No plan title +- **WHEN** the commit that adds the change folder has the subject `fix(roadmap): plan` and the title of the issue is `fix(roadmap): the job drops a comment` +- **THEN** the title of the pull request is `fix(roadmap): the job drops a comment`, the title of the issue + +#### Scenario: A plan summary that the form refuses +- **WHEN** the summary of the plan has 64 characters, and the title of the issue is `fix(roadmap): the job drops a comment` +- **THEN** the title of the pull request is `fix(roadmap): the job drops a comment`, and the job does not stop the item