Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-17
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Design

## Decisions

### Drop job comments before the cap

A job comment in the last `CONST_ROADMAP_REFINE_MAX_REPLIES` comments would otherwise push a person
reply out of the request. The filter runs first, so the cap counts person replies only.

### One shared filter

`comments_without_jobs` in `refine.py` removes every comment that holds a marker of
`CONST_ROADMAP_JOB_COMMENT_MARKERS`. Refine already uses the same `_comments_without` filter for
its own job comments. Alternatives imports the public helper, so one copy keeps the behavior equal.

### The author type stays trusted

The owner account and the Service bot write both person replies and job comments, so the author
association cannot tell them apart. The marker tells them apart.

## Rejected alternatives

- **Filter by author type or association:** the intake reason comment is trusted, so a trusted
author keeps it.
- **Add a filter in `alternatives.py`:** two copies drift.
- **Make `replies_after_marker` drop job comments:** it answers which comments follow a marker, a
different question.
- **Cap, then drop job comments:** a job comment in the last N pushes a person reply out.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Proposal: #4960

## Why

The alternatives job sends the comments of other roadmap jobs to its model as person replies.
`_request` takes every trusted comment when the job left no comment, else every trusted comment
after its own comment. It drops no comment that holds a job marker. The intake reason comment is on
most new items and its author is trusted, so the model reads it as a person reply. A refine, stage
or retitle comment after the last alternatives comment reaches the model too. Closes #4960.

## What Changes

- A shared `comments_without_jobs` helper removes every comment that holds a marker of
`CONST_ROADMAP_JOB_COMMENT_MARKERS`.
- `_request` calls the helper after the replies-after-marker selection and before the reply cap.
- Tests cover an intake comment with a person reply, and a refine comment after a check.

## Capabilities

### Modified

- `roadmap-alternatives`: the request holds only the comments of persons.

## Impact

The alternatives model reads person replies only. The cap counts person replies, so a job comment
cannot push a person reply out of the request.

## Feasibility

Confirmed against the issue and the code: `_request` in `src/devops_cli/roadmap/alternatives.py`
builds the replies, and refine's marker filter already removes the comments of other jobs (#2650).
The existing test helpers build the request from an in-memory store.

## Existing Tool Considered

No open tool or library covers the request of this job. The alternatives check of 2026-11-15
returned `none`, and its searches found no filter for job-marker comments. The change reuses the
project's own marker filter and costs about 30,000 tokens and one hour to build and keep.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## ADDED Requirements

### Requirement: A job comment is not a reply

The request SHALL leave out every trusted comment that holds a marker of
`CONST_ROADMAP_JOB_COMMENT_MARKERS`, after the selection of the comments that follow the job's last
comment and before the cap of `CONST_ROADMAP_REFINE_MAX_REPLIES`. A comment of a person SHALL stay.

#### Scenario: An intake reason comment

- **WHEN** an item holds an intake reason comment and one person reply, and the job left no comment
- **THEN** the `replies` of the request hold only the person reply

#### Scenario: A refine comment after a check

- **WHEN** a check runs again after a refine comment
- **THEN** the `replies` of the request do not hold the refine comment

#### Scenario: A person reply after a check

- **WHEN** a person replies after the last alternatives comment
- **THEN** the `replies` of the request hold the person reply
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Tasks

## 1. Behavior

- [x] 1.1 Write the failing tests for an intake comment and a person reply, and for a refine
comment after a check.
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_alternatives.py`
- [x] 1.2 Share refine's job-marker filter and apply it to the alternatives request before the cap.
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_alternatives.py`

## 2. Documents

- [x] 2.1 Update the `roadmap-alternatives` specification.
- Verification: `$ uv run devops openspec check`
- [x] 2.2 Archive the change into the main specification.
- Verification: `$ uv run devops openspec archive 4960-alternatives-skips-the-comments-of-other-jobs`
21 changes: 21 additions & 0 deletions openspec/specs/roadmap-alternatives/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,3 +842,24 @@ phrase in the same option, so the ADR rejects no tool that it adopted.

- **WHEN** an option names a tool and holds both `chosen` and `not chosen`
- **THEN** the job confirms no rejection of that tool

### Requirement: A job comment is not a reply

The request SHALL leave out every trusted comment that holds a marker of
`CONST_ROADMAP_JOB_COMMENT_MARKERS`, after the selection of the comments that follow the job's last
comment and before the cap of `CONST_ROADMAP_REFINE_MAX_REPLIES`. A comment of a person SHALL stay.

#### Scenario: An intake reason comment

- **WHEN** an item holds an intake reason comment and one person reply, and the job left no comment
- **THEN** the `replies` of the request hold only the person reply

#### Scenario: A refine comment after a check

- **WHEN** a check runs again after a refine comment
- **THEN** the `replies` of the request do not hold the refine comment

#### Scenario: A person reply after a check

- **WHEN** a person replies after the last alternatives comment
- **THEN** the `replies` of the request hold the person reply
5 changes: 4 additions & 1 deletion src/devops_cli/roadmap/alternatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
from devops_cli.roadmap.job_result import RoadmapJob, log_job_result
from devops_cli.roadmap.page_fetch import TOOLSET_ALTERNATIVES, PageFetch, named_urls
from devops_cli.roadmap.refine.refine import (
comments_without_jobs,
replies_after_marker,
sanitize_text,
web_search_of,
Expand Down Expand Up @@ -720,7 +721,9 @@ def _request(
item.body, CONST_ROADMAP_ALTERNATIVES_START_MARKER, CONST_ROADMAP_ALTERNATIVES_END_MARKER
)
after = replies_after_marker(comments, CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER)
replies = (comments if after is None else after)[-CONST_ROADMAP_REFINE_MAX_REPLIES:]
replies = comments_without_jobs(comments if after is None else after)[
-CONST_ROADMAP_REFINE_MAX_REPLIES:
]
document = {
"number": item.number,
"title": item.title,
Expand Down
6 changes: 6 additions & 0 deletions src/devops_cli/roadmap/refine/refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,11 @@ def _comments_without(
return [c for c in comments if not any(marker in c.body for marker in markers)]


def comments_without_jobs(comments: Sequence[IssueComment]) -> list[IssueComment]:
"""The comments that no roadmap job wrote, oldest first (#2650, #4960)."""
return _comments_without(comments, CONST_ROADMAP_JOB_COMMENT_MARKERS)


def _without_other_jobs_comments(comments: Sequence[IssueComment]) -> list[IssueComment]:
"""The comments that no roadmap job but refine wrote: those of persons and of refine."""
others = [
Expand Down Expand Up @@ -4096,6 +4101,7 @@ def render_refine_plan(plan: RefinePlan) -> str:
"check_person_edits",
"check_ready",
"collect_context",
"comments_without_jobs",
"dry_run_refine",
"form_checks",
"inspect_checkout",
Expand Down
31 changes: 31 additions & 0 deletions tests/roadmap/test_roadmap_alternatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
CONST_ROADMAP_ALTERNATIVES_MAX_FACT_READS,
CONST_ROADMAP_ALTERNATIVES_MAX_SEARCHES,
CONST_ROADMAP_ALTERNATIVES_START_MARKER,
CONST_ROADMAP_INTAKE_REASON_MARKER,
CONST_ROADMAP_PAGE_FETCH_MAX,
CONST_ROADMAP_REFINE_COMMENT_MARKER,
CONST_ROADMAP_REFINE_END_MARKER,
CONST_ROADMAP_REFINE_START_MARKER,
)
Expand Down Expand Up @@ -901,6 +903,35 @@ def test_the_request_holds_every_comment_when_the_job_left_none(
assert _prompt_of(script.seen[0])["replies"] == ["A person's note."]


def test_the_request_leaves_out_the_comment_of_another_job(
store: InMemoryRoadmapStore, web_key: None
) -> None:
"""The intake reason comment is trusted text of a job, not a person reply (#4960)."""
number = _item(store)
store.comment(number, f"{CONST_ROADMAP_INTAKE_REASON_MARKER}\nWhy this item.")
store.comment(number, "A person's note.")
script = _searching(AlternativesReply(reason=REASON, verdict=Verdict.NONE))

_plan(store, script)

assert _prompt_of(script.seen[0])["replies"] == ["A person's note."]


def test_the_request_leaves_out_a_job_comment_after_the_last_check(
store: InMemoryRoadmapStore, web_key: None
) -> None:
"""A recheck reads the person replies after the check, not the refine or retitle comments."""
number = _item(store)
store.comment(number, f"{CONST_ROADMAP_ALTERNATIVES_COMMENT_MARKER}\nThe last check.")
store.comment(number, f"{CONST_ROADMAP_REFINE_COMMENT_MARKER}\nThe refine step.")
store.comment(number, "A person's note.")
script = _searching(AlternativesReply(reason=REASON, verdict=Verdict.NONE))

_plan(store, script)

assert _prompt_of(script.seen[0])["replies"] == ["A person's note."]


def test_the_request_holds_no_comment_of_an_account_that_the_jobs_do_not_trust(
store: InMemoryRoadmapStore, web_key: None
) -> None:
Expand Down