diff --git a/docs/roadmap/alternatives.md b/docs/roadmap/alternatives.md index 3db76878ee..33bb5e3d1d 100644 --- a/docs/roadmap/alternatives.md +++ b/docs/roadmap/alternatives.md @@ -65,11 +65,13 @@ A check changes no label and closes no issue. A person decides what a tool means The comment gives: -- the verdict and the reason of the model for it, in one or two sentences; -- the tool, with its URL, license and last activity, and what it covers and lacks; -- the tools considered: every tool whose facts the run read, each with its URL, license and last activity; -- the answered searches, each with its number of results; -- at most five sources, and a line that says how many more the comment leaves out. GitHub shows each URL as a link. +- the verdict and the reason of the model for it; +- the tool on one line, with its URL, license, last activity and maintained state, as in the block; +- what the tool covers and lacks; +- one block that GitHub shows closed, `Searches ()`. It holds the tools considered: every tool whose facts the run read, each with its URL, license and last activity. It also holds the answered searches with their number of results. Last, it holds at most five sources, and a line that says how many more the comment leaves out. GitHub shows each URL as a link; +- one sentence that says a person decides what the check means for the item. + +The prompt asks the model for a brief reply: a reason of one sentence, and a few short items in `covers`, `lacks` and `sources`. The check refuses no reply for its length and cuts no text of the model. The comment of a skip class is one line, for example `Alternatives check: not-applicable (docs item; no search).` A check that posts a comment adds a new one. It never changes the comment of an earlier check. diff --git a/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/.openspec.yaml b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/.openspec.yaml new file mode 100644 index 0000000000..bbe8b39365 --- /dev/null +++ b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-11-17 diff --git a/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/design.md b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/design.md new file mode 100644 index 0000000000..9277d46189 --- /dev/null +++ b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/design.md @@ -0,0 +1,13 @@ +# Design + +## Decisions +- **Guidance, not a cap.** The prompt asks for a brief reply. The schema sets no length, so a long reply passes and the job writes it whole. A cap would make a check fail, or drop context that refine, stage and implement read (owner, 2026-11-17). +- **Fold, do not cut.** The tools considered, the searches and the sources go into one `
` block. Its summary counts the answered searches. The block holds every line that the comment held before, so a reader of the comment text loses nothing. +- **One tool line.** The comment uses the tool line of the block of the body (`_tool_line`), so the comment and the block state the same facts in the same form. +- **Machine-read lines stay.** The marker, the heading, `Reason:`, `Covers:`, `Lacks:` and `Tool: none found` stay. The block of the body does not change. +- **The source bound stays.** The comment keeps its bound of `CONST_ROADMAP_ALTERNATIVES_MAX_COMMENT_SOURCES` sources and its line that counts the rest, as before this change. + +## Rejected alternatives +- **Length limits in the schema of the reply**, with one retry for a longer reply: the owner refused hard caps that make a job fail or miss context (2026-11-17). +- **A character cap in the render**: it cuts text that other jobs read. +- **No tools considered and no searches in the comment**: they are the evidence of a `none` verdict, and #2944 added them on purpose. diff --git a/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/proposal.md b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/proposal.md new file mode 100644 index 0000000000..2829e40b0d --- /dev/null +++ b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/proposal.md @@ -0,0 +1,37 @@ +# Proposal: #6168 + +## Why +The comment of `devops roadmap alternatives` is too long to read quickly. The owner asked on 2026-11-17 for a brief and concise comment. The comment on #5384 has 2,210 characters, and the comment on #5398 has 1,585 characters. Two sources make it long. + +1. The prompt asks for a reason of "one or two sentences" and sets no size for `covers`, `lacks` and `sources`. The model writes 2 or 3 long sentences and items of 15 to 25 words. +2. The render shows a "Tools considered" list, a "Searches run" list of up to 10 lines, a tool block of 4 lines and a footer of two sentences. For `not-applicable` it shows three lines that say little. + +## What Changes +- The prompt `roadmap_alternatives.md` asks for a reason of one sentence of about 30 words, and a few items, about 3, in `covers`, `lacks` and `sources`. Each item is a plain phrase of about 12 words with no filler. This is guidance only: the schema of the reply sets no length, and the job refuses no reply for its length and cuts no text of it (owner, 2026-11-17). +- The comment shows the tool on one line, the same line as the block of the body. +- One `
Searches (N)` block, which GitHub shows closed, holds the tools considered, the answered searches and the sources. Nothing is left out of it. +- The footer is one sentence. +- The comment of a skip class is one line: `Alternatives check: not-applicable ( item; no search).` +- The marker, the heading `## Alternatives check: `, `Reason:`, `Covers:`, `Lacks:`, `Tool: none found` and the block of the body stay as they are. + +## Capabilities +- `roadmap-alternatives`: the comment requirements and the skip-class requirement change. + +## Impact +- On the open page of GitHub, the comment of #5384 drops from 2,210 to 1,259 characters with the same text of the model, and to about 700 characters with a reply that follows the new prompt. The folded block keeps the rest. The comment of a skip class drops to one line. +- Refine, stage and implement read the comment and the block. The marker and the block do not change. The comment keeps `Covers:` and `Lacks:`, which the refine prompt reads. +- No setting, no command and no dependency changes. The change fits one pull request. + +## Feasibility +- `devops gh api repos/dan-petty/devops-cli/issues/5384/comments` and `.../5398/comments` give the two comments with the marker ``, of 2,210 and 1,585 characters. +- The readers of the comment: + - `_latest_check_comment` and `covers_question` in `src/devops_cli/roadmap/refine/refine.py` read the marker, through `replies_after_marker`. + - `_request` in `src/devops_cli/roadmap/alternatives.py` reads the marker. + - `COMMENT_JOBS` in `src/devops_cli/roadmap/stores/comment_repeat.py` reads the marker. + - The refine prompt `roadmap_refine_proposal.md` reads what the tool lacks, "as the `comment` states". + - `recorded_check` reads the block of the body, which does not change. +- No code parses a line of the comment other than the marker. +- GitHub renders Markdown inside `
` when a blank line follows ``. + +## Existing Tool Considered +The `
` element of GitHub Markdown folds the evidence, so the change needs no new tool. The rest is the text of one prompt and one render function. diff --git a/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/specs/roadmap-alternatives/spec.md b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/specs/roadmap-alternatives/spec.md new file mode 100644 index 0000000000..9abdb705d3 --- /dev/null +++ b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/specs/roadmap-alternatives/spec.md @@ -0,0 +1,74 @@ +## MODIFIED Requirements + +### Requirement: The comment gives the verdict and its evidence +The comment SHALL give the verdict, the reason of the verdict in the model's words, the tool on one line with its URL, its license, its last activity and whether it is maintained, and what it covers and lacks. The model SHALL give a reason in every reply, and the job SHALL refuse a reply with none. The prompt SHALL ask for a brief reply, and the job SHALL refuse no reply for its length and SHALL cut no text of it. + +#### Scenario: A comment +- **WHEN** a check ends with a covering tool +- **THEN** the comment names the verdict, the reason, the tool, its URL, its license, its last push and its maintained state on one line, the lists of covers and lacks, and, in a folded block, the tools considered and the queries run + +#### Scenario: A reply with no reason +- **WHEN** the model replies with no reason +- **THEN** the reply fails the schema of the output and the model is asked again + +#### Scenario: A reply longer than the prompt asks +- **WHEN** the model replies with a reason of six sentences and five long items in `lacks` +- **THEN** the model gets no request to write the reply again, and the comment holds the whole reason and each item + +### Requirement: The comment lists the searches and the tools considered +The comment SHALL list every tool whose facts the run read with its URL, license and last activity, and each search that a provider answered with its number of results. It SHALL put them, with the sources, in one `
` block whose summary is `Searches ()`, so GitHub shows them closed. It SHALL show no query outside that block. + +#### Scenario: Two searches with results +- **WHEN** a run makes two searches and the fake search returns two results each +- **THEN** the folded block `Searches (2)` lists each query with `results: 2`, and no query is outside the block + +#### Scenario: Two tools read +- **WHEN** the run reads the facts of two repositories and names one as the tool +- **THEN** the folded block lists both under `Tools considered:`, each with its license and last activity + +#### Scenario: Ten searches +- **WHEN** a run makes ten searches and names a covering tool with three covers and three lacks +- **THEN** the comment outside the folded block holds only the marker, the heading, the reason, the tool line, the covers, the lacks and the footer, and the block `Searches (10)` lists the ten queries + +### Requirement: The comment shows at most five sources +The folded block of the comment SHALL show at most five sources, and SHALL say how many more it leaves out. + +#### Scenario: More sources than the bound +- **WHEN** the reply cites eight sources that the tools returned +- **THEN** the folded block shows five and the line `3 more sources are left out` + +### Requirement: A skip-class item is not-applicable with no model call +The check SHALL give the verdict `not-applicable`, with no model call and no search, to an item whose title has the Conventional Commit type `test`, `docs`, `refactor`, `chore`, `ci` or `perf`, and to an item whose title has the type `fix` and whose body holds the text `Traceback (most recent call last)`. The comment and the block of the body SHALL name the class: the type, or `fix-with-stack-trace`. An item of any other type, and an item with no type, SHALL NOT be a skip class. + +#### Scenario: Each type is a skip class +- **WHEN** the check runs on six items whose titles have the types `test`, `docs`, `refactor`, `chore`, `ci` and `perf` +- **THEN** each check has the verdict `not-applicable`, each comment is the one line that names the type, and the model received no request and no search ran + +#### Scenario: The base rule of one agent run holds for non-skip items only +- **WHEN** the check runs on a skip-class item +- **THEN** no agent run happens for it, and the rule "The check of one item SHALL be one agent run" of the requirement "The agent finds facts with three tools only" holds for an item that is not a skip class + +#### Scenario: A fix with a stack trace +- **WHEN** the check runs on an item titled `fix(roadmap): a crash` whose body holds `Traceback (most recent call last)` +- **THEN** the check has the verdict `not-applicable`, the comment is the one line that names `fix-with-stack-trace`, and the model received no request + +#### Scenario: A fix with no stack trace +- **WHEN** the check runs on an item titled `fix(roadmap): a crash` whose body holds no traceback +- **THEN** the model receives a request for the item + +#### Scenario: A type that is no skip class +- **WHEN** the check runs on items whose titles have the types `feat`, `build` and `style`, and on an item whose title has no type +- **THEN** the model receives a request for each of them + +#### Scenario: A skip class with an unpaired marker +- **WHEN** the body of a skip-class item holds the start marker of the block with no end marker +- **THEN** the item is skipped with a named reason and nothing is written for it + +## ADDED Requirements + +### Requirement: The comment of a skip class is one line +The comment of a skip-class item SHALL be the marker and one line, `Alternatives check: not-applicable ( item; no search).` + +#### Scenario: A docs item +- **WHEN** the check runs on an item titled `docs(roadmap): a change` +- **THEN** its comment is the marker and the line `Alternatives check: not-applicable (docs item; no search).` diff --git a/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/tasks.md b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/tasks.md new file mode 100644 index 0000000000..8c27c5f6a2 --- /dev/null +++ b/openspec/changes/archive/2026-11-17-6168-make-the-alternatives-comment-brief/tasks.md @@ -0,0 +1,13 @@ +# Tasks + +## 1. Behavior + +- [x] 1.1 Change the render tests to the new form: the folded block, the one tool line, the one-line skip class, and a long reply that the job writes whole + - Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_alternatives.py` +- [x] 1.2 Fold the evidence, write the tool on one line, make the footer and the skip-class comment short, and ask for a brief reply in the prompt + - Verification: `$ uv run devops ci test tests/roadmap/` + +## 2. Documents + +- [x] 2.1 Update the comment form in `docs/roadmap/alternatives.md` and in the spec `roadmap-alternatives` + - Verification: `$ uv run devops openspec check` diff --git a/openspec/specs/roadmap-alternatives/spec.md b/openspec/specs/roadmap-alternatives/spec.md index 82581a3015..c2a315df82 100644 --- a/openspec/specs/roadmap-alternatives/spec.md +++ b/openspec/specs/roadmap-alternatives/spec.md @@ -138,33 +138,41 @@ A check SHALL post one comment with the marker `devops roadmap alternatives` whe - **THEN** the check posts one comment and records the new verdict, the new tool and the new date ### Requirement: The comment gives the verdict and its evidence -The comment SHALL give the verdict, the reason of the verdict in the model's words, the tool with its license, its last activity, whether it is maintained and its URL, and what it covers and lacks. The model SHALL give a reason in every reply, and the job SHALL refuse a reply with none. +The comment SHALL give the verdict, the reason of the verdict in the model's words, the tool on one line with its URL, its license, its last activity and whether it is maintained, and what it covers and lacks. The model SHALL give a reason in every reply, and the job SHALL refuse a reply with none. The prompt SHALL ask for a brief reply, and the job SHALL refuse no reply for its length and SHALL cut no text of it. #### Scenario: A comment - **WHEN** a check ends with a covering tool -- **THEN** the comment names the verdict, the reason, the tool, its license, its last push, its maintained state, its URL, the lists of covers and lacks, the tools considered, and the queries run +- **THEN** the comment names the verdict, the reason, the tool, its URL, its license, its last push and its maintained state on one line, the lists of covers and lacks, and, in a folded block, the tools considered and the queries run #### Scenario: A reply with no reason - **WHEN** the model replies with no reason - **THEN** the reply fails the schema of the output and the model is asked again +#### Scenario: A reply longer than the prompt asks +- **WHEN** the model replies with a reason of six sentences and five long items in `lacks` +- **THEN** the model gets no request to write the reply again, and the comment holds the whole reason and each item + ### Requirement: The comment lists the searches and the tools considered -The comment SHALL list every tool whose facts the run read with its URL, license and last activity, and each search that a provider answered with its number of results. +The comment SHALL list every tool whose facts the run read with its URL, license and last activity, and each search that a provider answered with its number of results. It SHALL put them, with the sources, in one `
` block whose summary is `Searches ()`, so GitHub shows them closed. It SHALL show no query outside that block. #### Scenario: Two searches with results - **WHEN** a run makes two searches and the fake search returns two results each -- **THEN** the comment lists each query with `results: 2` +- **THEN** the folded block `Searches (2)` lists each query with `results: 2`, and no query is outside the block #### Scenario: Two tools read - **WHEN** the run reads the facts of two repositories and names one as the tool -- **THEN** the comment lists both under `Tools considered:`, each with its license and last activity +- **THEN** the folded block lists both under `Tools considered:`, each with its license and last activity + +#### Scenario: Ten searches +- **WHEN** a run makes ten searches and names a covering tool with three covers and three lacks +- **THEN** the comment outside the folded block holds only the marker, the heading, the reason, the tool line, the covers, the lacks and the footer, and the block `Searches (10)` lists the ten queries ### Requirement: The comment shows at most five sources -The comment SHALL show at most five sources, and SHALL say how many more it leaves out. +The folded block of the comment SHALL show at most five sources, and SHALL say how many more it leaves out. #### Scenario: More sources than the bound - **WHEN** the reply cites eight sources that the tools returned -- **THEN** the comment shows five and the line `3 more sources are left out` +- **THEN** the folded block shows five and the line `3 more sources are left out` ### Requirement: A check never changes an earlier comment A check SHALL add a new comment and SHALL NOT change the comment of an earlier check. @@ -322,7 +330,7 @@ The check SHALL give the verdict `not-applicable`, with no model call and no sea #### Scenario: Each type is a skip class - **WHEN** the check runs on six items whose titles have the types `test`, `docs`, `refactor`, `chore`, `ci` and `perf` -- **THEN** each check has the verdict `not-applicable`, each comment names the type, and the model received no request and no search ran +- **THEN** each check has the verdict `not-applicable`, each comment is the one line that names the type, and the model received no request and no search ran #### Scenario: The base rule of one agent run holds for non-skip items only - **WHEN** the check runs on a skip-class item @@ -330,7 +338,7 @@ The check SHALL give the verdict `not-applicable`, with no model call and no sea #### Scenario: A fix with a stack trace - **WHEN** the check runs on an item titled `fix(roadmap): a crash` whose body holds `Traceback (most recent call last)` -- **THEN** the check has the verdict `not-applicable`, the comment names `fix-with-stack-trace`, and the model received no request +- **THEN** the check has the verdict `not-applicable`, the comment is the one line that names `fix-with-stack-trace`, and the model received no request #### Scenario: A fix with no stack trace - **WHEN** the check runs on an item titled `fix(roadmap): a crash` whose body holds no traceback @@ -344,6 +352,13 @@ The check SHALL give the verdict `not-applicable`, with no model call and no sea - **WHEN** the body of a skip-class item holds the start marker of the block with no end marker - **THEN** the item is skipped with a named reason and nothing is written for it +### Requirement: The comment of a skip class is one line +The comment of a skip-class item SHALL be the marker and one line, `Alternatives check: not-applicable ( item; no search).` + +#### Scenario: A docs item +- **WHEN** the check runs on an item titled `docs(roadmap): a change` +- **THEN** its comment is the marker and the line `Alternatives check: not-applicable (docs item; no search).` + ### Requirement: A non-skip item needs a search before any verdict For an item that is no skip class, the check SHALL refuse a reply that follows no answered `search_web` call, and SHALL give the model one more turn to search. A second reply that follows no answered search SHALL end as a failed check: the job skips the item with a named reason and writes nothing for it. The check SHALL refuse a reply with the verdict `not-applicable` from the model, because the job sets that verdict for a skip class only. diff --git a/src/devops_cli/ai/tasks/roadmap_alternatives.md b/src/devops_cli/ai/tasks/roadmap_alternatives.md index 96d6c00c05..92a00d7574 100644 --- a/src/devops_cli/ai/tasks/roadmap_alternatives.md +++ b/src/devops_cli/ai/tasks/roadmap_alternatives.md @@ -22,9 +22,11 @@ Reply with these keys: - `tool_name`: the name that the ADR or the issue writes for the tool of `tool_url`, such as `Argo Workflows`. Set it when you set `adr` or `in_use`. - `adr`: for the verdicts `covers` and `partly` only: the number of the ADR in `decisions` that rejected the tool of `tool_url`. Give a number only when that ADR names the tool and rejects it. The job drops a number that it cannot confirm in `decisions`. Leave it empty in any other case. - `in_use`: `true` or `false`. Give `true` for a `covers` or `partly` verdict when the issue already names the tool of `tool_url` as a tool that the project uses. The `title` or the `body` must name it. The job drops `true` when the text does not name the tool. -- `reason`: the reason of the verdict in one or two sentences. Say what the searches found and why it does cover, partly cover or not cover the need. For `none`, say what the searches found and why it does not cover the need. -- `covers`: short statements of what the tool covers. -- `lacks`: short statements of what the tool does not cover, or what the issue needs that it lacks. -- `sources`: the URLs that support your statements. Each one is a URL that a tool gave you. +- `reason`: the reason of the verdict in one sentence, of about 30 words. Say what the searches found and why it does cover, partly cover or not cover the need. For `none`, say what the searches found and why it does not cover the need. +- `covers`: a few items, about 3, of what the tool covers. +- `lacks`: a few items, about 3, of what the tool does not cover, or what the issue needs that it lacks. +- `sources`: a few URLs, about 3, that support your statements. Each one is a URL that a tool gave you. + +Keep the reply brief, because a person reads it in a comment. Write each item of `covers` and `lacks` as a plain phrase of about 12 words, such as `No SARIF output`. Do not repeat the reason, the issue or the tool name, and write no filler words. Keep each fact that a person needs for the decision. The job writes the license, the dates, whether the tool is maintained and the answered searches. Do not write them. diff --git a/src/devops_cli/lang/en/messages.py b/src/devops_cli/lang/en/messages.py index 6e384fc946..6099843ba7 100644 --- a/src/devops_cli/lang/en/messages.py +++ b/src/devops_cli/lang/en/messages.py @@ -3216,8 +3216,11 @@ class RoadmapMessages: alternatives_no: str = "no" # The comment and the body block the check writes. alternatives_comment_heading: str = "## Alternatives check: {verdict}" - alternatives_comment_tool: str = "Tool: {name} ({url})" alternatives_comment_no_tool: str = "Tool: none found" + # The one line of the comment of a skip class (#6168). + alternatives_comment_skipped: str = ( + "Alternatives check: {verdict} ({skip_class} item; no search)." + ) # The line that says why the job, not the model, gave the verdict `rejected` or `in-use` # (#3505). The ADR number has four digits, as in the file name. alternatives_basis_rejected: str = ( @@ -3225,13 +3228,6 @@ class RoadmapMessages: ) alternatives_basis_in_use: str = "The item already names this tool." alternatives_basis_in_repository: str = "The repository already uses this tool." - alternatives_comment_skip_class: str = ( - "Class: {skip_class}. The check makes no search and no model call for an item of this " - "class." - ) - alternatives_comment_license: str = "- License: {license}" - alternatives_comment_activity: str = "- Last activity: {date}" - alternatives_comment_maintained: str = "- Maintained: {answer}" alternatives_comment_covers: str = "Covers:" alternatives_comment_lacks: str = "Lacks:" alternatives_comment_reason: str = "Reason: {reason}" @@ -3244,9 +3240,11 @@ class RoadmapMessages: alternatives_comment_sources: str = "Sources:" alternatives_comment_sources_left_out: str = "{count} more sources are left out" alternatives_comment_item: str = "- {text}" + # The block that GitHub shows closed: the tools considered, the searches and the sources. + alternatives_comment_fold_open: str = "
Searches ({count})" + alternatives_comment_fold_close: str = "
" alternatives_comment_footer: str = ( - "Checked on {date}. A person decides what this means for the item. " - "The check changes no label and closes no issue." + "A person decides what this check of {date} means for the item." ) alternatives_block_verdict: str = "Alternatives check of {date}: {verdict}." alternatives_block_tool: str = ( diff --git a/src/devops_cli/roadmap/alternatives.py b/src/devops_cli/roadmap/alternatives.py index 63d6b3eda2..b5ad5536de 100644 --- a/src/devops_cli/roadmap/alternatives.py +++ b/src/devops_cli/roadmap/alternatives.py @@ -50,10 +50,12 @@ **Writes.** With `--confirm` a check replaces the job's block in the body, records `alternatives.*` in the job record, and posts one comment that carries `CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER`. It changes no label and closes no issue. The comment -gives the verdict, the model's reason for it, the tool, what it covers and lacks, every tool whose -facts the run read, each search with its number of results, and at most -`CONST_ROADMAP_ALTERNATIVES_MAX_COMMENT_SOURCES` sources (#2944). A check adds a comment and never -changes an earlier one. A comment after the job's last one reaches the next check as a reply. A skipped item gets only +gives the verdict, the model's reason for it, the tool on one line, and what it covers and lacks +(#2944). One block that GitHub shows closed holds every tool whose facts the run read, each search +with its number of results, and at most `CONST_ROADMAP_ALTERNATIVES_MAX_COMMENT_SOURCES` sources +(#6168). A skip class gets one line. The prompt asks for a brief reply; the job refuses no reply +for its length and cuts no text of it. A check adds a comment and never changes an earlier one. A +comment after the job's last one reaches the next check as a reply. A skipped item gets only `alternatives.failed_at` and `alternatives.failed_error` in its job record; a written check clears both. @@ -190,7 +192,8 @@ class AlternativesReply(BaseModel): verdict, and the verdict `in-use` with `in_use`, when the item already names that tool. `tool_name` is the name that the ADR or the item writes for the tool. The job confirms each proposal against the text, and keeps the verdict of the reply when it cannot (#3505). - `reason` is the reason of the verdict in one or two sentences (#2944).""" + `reason` is the reason of the verdict (#2944). The prompt asks for a brief reply, and the schema + sets no length: a long reply is written whole (#6168).""" verdict: Verdict reason: str = Field(min_length=1) @@ -823,18 +826,19 @@ def _clean(texts: Sequence[str], allowed_urls: set[str]) -> tuple[str, ...]: return tuple(sanitize_text(" ".join(text.split()), allowed_urls) for text in texts) -def _tool_section(tool: CheckedTool | None) -> list[str]: +def _tool_line(tool: CheckedTool) -> str: + """The tool on one line, with its URL, license, last activity and maintained state: the same + line in the comment and in the block.""" texts = MESSAGES.roadmap - if tool is None: - return [texts.alternatives_comment_no_tool] - return [ - texts.alternatives_comment_tool.format(name=tool.name, url=tool.url), - texts.alternatives_comment_license.format( - license=tool.license or texts.alternatives_not_stated + return texts.alternatives_block_tool.format( + name=tool.name, + url=tool.url, + license=tool.license or texts.alternatives_not_stated, + date=_day(tool.last_activity), + maintained=( + texts.alternatives_maintained if tool.maintained else texts.alternatives_not_maintained ), - texts.alternatives_comment_activity.format(date=_day(tool.last_activity)), - texts.alternatives_comment_maintained.format(answer=_yes_no(tool.maintained)), - ] + ) def _basis(check: Check) -> list[str]: @@ -878,6 +882,29 @@ def _search_section(searches: Sequence[Search]) -> list[str]: ) +def _folded_section(check: Check) -> list[str]: + """The tools considered, the searches and the sources in one block that GitHub shows closed, + so the comment shows the verdict and its evidence first (#6168); none when all three are + empty.""" + texts = MESSAGES.roadmap + lists = [ + _considered_section(check.considered), + _search_section(check.searches), + _source_section(check.sources), + ] + shown = [section for section in lists if section] + if not shown: + return [] + inside = "\n\n".join("\n".join(section) for section in shown) + return [ + texts.alternatives_comment_fold_open.format(count=len(check.searches)), + "", + inside, + "", + texts.alternatives_comment_fold_close, + ] + + def _source_section(sources: Sequence[str]) -> list[str]: """At most `CONST_ROADMAP_ALTERNATIVES_MAX_COMMENT_SOURCES` sources, each a URL that GitHub shows as a link, and a line that says how many the comment leaves out (#2944).""" @@ -895,30 +922,31 @@ def _list_section(title: str, lines: Sequence[str]) -> list[str]: def _comment_of(check: Check) -> str: - """The comment of a check: the marker, the verdict, the tool with its facts, the lists, and a - line that says what the check does not do.""" + """The comment of a check: the marker, the verdict, the reason, the tool with its facts, what + it covers and lacks, the folded evidence, and who decides. A skip class gets one line.""" texts = MESSAGES.roadmap + if check.skip_class: + return "\n".join( + [ + CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER, + texts.alternatives_comment_skipped.format( + verdict=check.verdict.value, skip_class=check.skip_class + ), + ] + ) heading = [ CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER, texts.alternatives_comment_heading.format(verdict=check.verdict.value), ] - skip = ( - [texts.alternatives_comment_skip_class.format(skip_class=check.skip_class)] - if check.skip_class - else [] - ) reason = [texts.alternatives_comment_reason.format(reason=check.reason)] if check.reason else [] sections = [ heading, - skip, reason, _basis(check), - _tool_section(check.tool), + [texts.alternatives_comment_no_tool if check.tool is None else _tool_line(check.tool)], _list_section(texts.alternatives_comment_covers, check.covers), _list_section(texts.alternatives_comment_lacks, check.lacks), - _considered_section(check.considered), - _search_section(check.searches), - _source_section(check.sources), + _folded_section(check), [texts.alternatives_comment_footer.format(date=check.checked_at.date().isoformat())], ] return "\n\n".join("\n".join(section) for section in sections if section) @@ -927,21 +955,7 @@ def _comment_of(check: Check) -> str: def _block_of(check: Check) -> str: """The block of the body: the latest verdict and tool, between the job's two markers.""" texts = MESSAGES.roadmap - tool = check.tool - if tool is None: - detail = texts.alternatives_block_no_tool - else: - detail = texts.alternatives_block_tool.format( - name=tool.name, - url=tool.url, - license=tool.license or texts.alternatives_not_stated, - date=_day(tool.last_activity), - maintained=( - texts.alternatives_maintained - if tool.maintained - else texts.alternatives_not_maintained - ), - ) + detail = texts.alternatives_block_no_tool if check.tool is None else _tool_line(check.tool) skip = ( [texts.alternatives_block_skip_class.format(skip_class=check.skip_class)] if check.skip_class diff --git a/tests/roadmap/test_roadmap_alternatives.py b/tests/roadmap/test_roadmap_alternatives.py index 91a5e334a3..10ac340e62 100644 --- a/tests/roadmap/test_roadmap_alternatives.py +++ b/tests/roadmap/test_roadmap_alternatives.py @@ -256,6 +256,16 @@ def _plan(store: RoadmapStore, script: Script | None, **options: Any) -> Any: ) +def _fold_of(comment: str) -> tuple[str, str]: + """The text of `comment` that GitHub shows open, and its one folded block, or "" when it has + none.""" + start = comment.find("
") + if start < 0: + return comment, "" + end = comment.index("
", start) + len("
") + return comment[:start] + comment[end:], comment[start:end] + + def _prompt_of(messages: list[ModelMessage]) -> dict[str, Any]: """The request document of a model request.""" text = next( @@ -1173,7 +1183,7 @@ def test_a_tool_that_an_adr_rejected_gives_the_verdict_rejected_and_no_question( assert ( (check.verdict, check.adr, check.tool.url if check.tool else None), "## Alternatives check: rejected" in comment, - f"Tool: temporalio/temporal ({TEMPORAL_URL})" in comment, + any(line.startswith(f"Tool: temporalio/temporal ({TEMPORAL_URL}), ") for line in comment), REJECTION in comment, REJECTION in block, _recorded(store, number, AlternativesRecordKey.VERDICT), @@ -1533,10 +1543,8 @@ def test_a_covering_tool_makes_one_comment_one_block_and_the_record( "", f"Reason: {REASON}", "", - f"Tool: example/scanner ({TOOL_URL})", - "- License: MIT", - f"- Last activity: {_days_ago(5).date()}", - "- Maintained: yes", + f"Tool: example/scanner ({TOOL_URL}), MIT, last activity " + f"{_days_ago(5).date()}, maintained.", "", "Covers:", "- Scans a directory.", @@ -1544,6 +1552,8 @@ def test_a_covering_tool_makes_one_comment_one_block_and_the_record( "Lacks:", "- No SARIF output.", "", + "
Searches (1)", + "", "Tools considered:", f"- example/scanner ({TOOL_URL}), license MIT, last activity {_days_ago(5).date()}", "", @@ -1554,8 +1564,9 @@ def test_a_covering_tool_makes_one_comment_one_block_and_the_record( f"- {TOOL_URL}", f"- {SEARCH_URL}", "", - f"Checked on {NOW.date()}. A person decides what this means for the item. " - "The check changes no label and closes no issue.", + "
", + "", + f"A person decides what this check of {NOW.date()} means for the item.", ] ) ], @@ -1655,10 +1666,58 @@ def test_the_comment_lists_each_query_with_its_result_count_and_the_reason( apply_alternatives(store, _plan(store, script)) (comment,) = [c.body for c in store.comments_on(number)] + shown, folded = _fold_of(comment) assert ( - f"Reason: {REASON}" in comment, - "Searches run:\n- first query, results: 2\n- second query, results: 2" in comment, - ) == (True, True) + f"Reason: {REASON}" in shown, + "first query" in shown, + folded.startswith("
Searches (2)\n"), + "Searches run:\n- first query, results: 2\n- second query, results: 2" in folded, + ) == (True, False, True, True) + + +def test_ten_searches_stay_folded_and_the_comment_shows_only_the_verdict_and_its_evidence( + store: InMemoryRoadmapStore, web_key: None, web: WebFake +) -> None: + _firecrawl(web, SEARCH_URL, TOOL_URL) + number = _item(store) + queries = [f"query number {n}" for n in range(10)] + script = Script( + *(call("search_web", query=query) for query in queries), + call("github_repository", name="example/scanner"), + _covers( + covers=["Scans a directory.", "Reads each file once.", "Runs offline."], + lacks=["No SARIF output.", "No Python API.", "No watch mode."], + ), + ) + + apply_alternatives(store, _plan(store, script)) + + (comment,) = [c.body for c in store.comments_on(number)] + shown, folded = _fold_of(comment) + assert ( + [line for line in shown.splitlines() if line], + folded.startswith("
Searches (10)\n"), + [query for query in queries if f"- {query}, results: 2" in folded], + ) == ( + [ + CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER, + "## Alternatives check: covers", + f"Reason: {REASON}", + f"Tool: example/scanner ({TOOL_URL}), MIT, last activity " + f"{_days_ago(5).date()}, maintained.", + "Covers:", + "- Scans a directory.", + "- Reads each file once.", + "- Runs offline.", + "Lacks:", + "- No SARIF output.", + "- No Python API.", + "- No watch mode.", + f"A person decides what this check of {NOW.date()} means for the item.", + ], + True, + queries, + ) def test_the_comment_lists_every_tool_the_run_read_with_its_license_and_last_activity( @@ -1686,12 +1745,17 @@ def test_the_comment_lists_every_tool_the_run_read_with_its_license_and_last_act apply_alternatives(store, _plan(store, script)) (comment,) = [c.body for c in store.comments_on(number)] + shown, folded = _fold_of(comment) assert ( - "Tools considered:\n" - f"- example/scanner ({TOOL_URL}), license MIT, last activity {_days_ago(5).date()}\n" - f"- example/other (https://github.com/example/other), license not stated, " - f"last activity {_days_ago(400).date()}" - ) in comment + "example/other" in shown, + ( + "Tools considered:\n" + f"- example/scanner ({TOOL_URL}), license MIT, last activity {_days_ago(5).date()}\n" + f"- example/other (https://github.com/example/other), license not stated, " + f"last activity {_days_ago(400).date()}" + ) + in folded, + ) == (False, True) def test_a_reply_with_no_reason_is_refused_by_its_schema() -> None: @@ -1699,7 +1763,7 @@ def test_a_reply_with_no_reason_is_refused_by_its_schema() -> None: AlternativesReply.model_validate({"verdict": "none"}) -def test_the_comment_shows_at_most_the_bound_of_sources_and_says_how_many_it_left_out( +def test_the_comment_folds_at_most_the_bound_of_sources_and_says_how_many_it_left_out( store: InMemoryRoadmapStore, ) -> None: urls = [ @@ -1716,13 +1780,33 @@ def test_the_comment_shows_at_most_the_bound_of_sources_and_says_how_many_it_lef check = alternatives.validate_reply(item, reply, tools, NOW, ()) assert not isinstance(check, alternatives.CheckFailure) - shown = [line for line in check.comment.splitlines() if line.startswith("- https://")] - assert (shown, "- 3 more sources are left out" in check.comment) == ( + _, folded = _fold_of(check.comment) + shown = [line for line in folded.splitlines() if line.startswith("- https://")] + assert (shown, "- 3 more sources are left out" in folded) == ( [f"- {url}" for url in urls[:CONST_ROADMAP_ALTERNATIVES_MAX_COMMENT_SOURCES]], True, ) +def test_a_reply_longer_than_the_prompt_asks_is_written_whole( + store: InMemoryRoadmapStore, web_key: None +) -> None: + number = _item(store) + reason = " ".join(["The search found a scanner that reads a directory."] * 6) + lacks = [f"Lack number {n}: " + " ".join(["a long phrase"] * 10) for n in range(5)] + script = _searching(AlternativesReply(reason=reason, verdict=Verdict.NONE, lacks=lacks)) + + plan = _plan(store, script) + apply_alternatives(store, plan) + + (comment,) = store.comments_on(number) + assert ( + len(script.seen), + f"Reason: {reason}" in comment.body, + [lack for lack in lacks if f"- {lack}" in comment.body], + ) == (2, True, lacks) + + def test_a_later_check_adds_a_comment_and_leaves_the_comment_of_the_first_unchanged( store: InMemoryRoadmapStore, web_key: None, web: WebFake ) -> None: @@ -2080,7 +2164,7 @@ def test_skip_class_an_item_of_the_type_is_not_applicable_with_no_model_call( script.seen, len(web.sent) == searches_before, written, - f"Class: {kind}. The check makes no search" in comment.body, + comment.body, f"Class: {kind}, no search." in store.read_issue_body(number), _recorded(store, number, AlternativesRecordKey.VERDICT), otlp.points(ROADMAP_ALTERNATIVES_TOTAL.name), @@ -2089,7 +2173,8 @@ def test_skip_class_an_item_of_the_type_is_not_applicable_with_no_model_call( [], True, 1, - True, + f"{CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER}\n" + f"Alternatives check: not-applicable ({kind} item; no search).", True, "not-applicable", [({"verdict": "not-applicable"}, 1.0)], @@ -2110,8 +2195,12 @@ def test_skip_class_a_fix_with_a_stack_trace_is_not_applicable_with_no_model_cal assert ( [(c.verdict, c.skip_class) for c in plan.checks], script.seen, - "Class: fix-with-stack-trace." in comment.body, - ) == ([(Verdict.NOT_APPLICABLE, "fix-with-stack-trace")], [], True) + comment.body.splitlines()[1:], + ) == ( + [(Verdict.NOT_APPLICABLE, "fix-with-stack-trace")], + [], + ["Alternatives check: not-applicable (fix-with-stack-trace item; no search)."], + ) @pytest.mark.parametrize(