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,3 @@
schema: spec-driven
created: 2026-11-25
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Design

## Decisions
- **Reuse `_since_wait_start` and `_read_at` in `_has_trusted_comment_since_last_round`**: When `comments` contains a `CONST_ROADMAP_REFINE_COMMENT_MARKER` comment, `_has_trusted_comment_since_last_round` delegates directly to `any(trusted(c) for c in _since_wait_start(item, comments))` (`src/devops_cli/roadmap/refine/refine.py:2913-2932`). When no marker comment is present yet, it reads `read_at = _read_at(item)` (`src/devops_cli/roadmap/refine/refine.py:2893-2903`) and accepts trusted non-job comments with `as_utc(comment.created_at) > read_at`.
- **Replace `REPEATED_AT` test seeding in `test_roadmap_refine_ready_edits.py` with `READ_AT`**: Every written non-failed refine round writes `RefineRecordKey.READ_AT` and clears `RefineRecordKey.REPEATED_AT` (`src/devops_cli/roadmap/refine/refine.py:4817-4819`). Updating `test_roadmap_refine_ready_edits.py` and `openspec/specs/roadmap-refine/selection/spec.md` aligns `#6452` with `#6371`.

## Rejected alternatives
- **Re-introduce `_repeated_at` alongside `_read_at`**: Rejected because `#6371` (`44fb86a04`) intentionally retired writing `RefineRecordKey.REPEATED_AT` and clears it on every written round (`src/devops_cli/roadmap/refine/refine.py:4817-4819`), and `openspec/specs/roadmap-refine/comments/spec.md:38` requires writing `refine.read_at` only.
- **Duplicate timestamp comparison math inside `_has_trusted_comment_since_last_round`**: Rejected because `_since_wait_start` (`src/devops_cli/roadmap/refine/refine.py:2913-2932`) already implements the exact same-tick post and `read_at` boundary logic tested by `tests/roadmap/refine/test_roadmap_refine_event_comment.py`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Proposal: #7190

## Why
`src/devops_cli/roadmap/refine/refine.py:3493` calls `_repeated_at(item)` inside `_has_trusted_comment_since_last_round` (#7190). Commit `44fb86a04` (#7144, closes #6371) removed `_repeated_at` and replaced it with `_read_at(item)` (`RefineRecordKey.READ_AT`), while commit `3bb8a4891` (#7178, closes #6452) merged after `44fb86a04` and introduced `_has_trusted_comment_since_last_round` still calling `_repeated_at`. That leaves `main` failing `lint`, `typecheck`, `uv-check`, and `tests/roadmap/refine/test_roadmap_refine_ready_edits.py` at runtime with `NameError`.

## What Changes
Update Ready-item trusted comment detection to use `RefineRecordKey.READ_AT` and `_since_wait_start` rather than removed `_repeated_at`:

- Replace `_repeated_at(item)` in `_has_trusted_comment_since_last_round` (`src/devops_cli/roadmap/refine/refine.py`) by delegating to `_since_wait_start(item, comments)` when a refine marker comment is present, and comparing against `_read_at(item)` when no marker comment exists yet.
- Update `Requirement: New trusted comment is refinable` in `openspec/specs/roadmap-refine/selection/spec.md` to reference `refine.read_at` instead of `refine.repeated_at`.
- Update `tests/roadmap/refine/test_roadmap_refine_ready_edits.py` to seed and test `RefineRecordKey.READ_AT` (`read_at`), including a trusted comment posted between `read_at` and refine's marker comment.

This alters observable selection behavior on Ready items holding `refine.read_at` and updates the existing `roadmap-refine/selection` specification requirement (`MODIFIED`), so it carries a spec delta. Fits in one pull request.

## Capabilities
- `roadmap-refine/selection` (`openspec/specs/roadmap-refine/selection/spec.md`)

## Impact
- `src/devops_cli/roadmap/refine/refine.py`: `_has_trusted_comment_since_last_round`.
- `openspec/specs/roadmap-refine/selection/spec.md`: `Requirement: New trusted comment is refinable`.
- `tests/roadmap/refine/test_roadmap_refine_ready_edits.py`: updated `READ_AT` cases and in-flight comment coverage.

## Feasibility
Confirmed against `origin/main` (`ac8bdebdb`):
- `ruff check`, `mypy`, and `uv check` fail at `src/devops_cli/roadmap/refine/refine.py:3493` (`Name "_repeated_at" is not defined`).
- `src/devops_cli/roadmap/refine/refine.py:2893-2933` already provides `_read_at(item)` and `_since_wait_start(item, comments)`, which implements the `RefineRecordKey.READ_AT` comparison with refine-marker fallback and job-comment exclusion.

## Existing Tool Considered
No external tool covers internal `RefineRecordKey.READ_AT` comment filtering on in-repo roadmap items (`#6371`, `#6452`). Reusing `_read_at` and `_since_wait_start` deletes the stale inline timestamp scan in `_has_trusted_comment_since_last_round` rather than introducing new logic (~1k tokens, <15 min).
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## MODIFIED Requirements

### Requirement: New trusted comment is refinable
`_refinable` and `devops roadmap refine` SHALL select an open `Ready` item again, even when `unrefined_ready=False`, when a trusted person comment follows its last refine round (`refine.read_at` when set, else the newest comment carrying `CONST_ROADMAP_REFINE_COMMENT_MARKER`).

#### Scenario: Person comments on a Ready item
- **WHEN** an open `Ready` item holds a refine record and a comment by a trusted person after `refine.read_at` (or after its last refine marker comment when `refine.read_at` is absent), and `_refinable` runs with `unrefined_ready=False`
- **THEN** `_refinable` returns the item

#### Scenario: Trusted comment posted between read_at and marker comment
- **WHEN** an open `Ready` item holds `refine.read_at` earlier than its newest refine marker comment and a trusted person comment was posted between those two times
- **THEN** `_refinable` selects the item again
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tasks

## 1. Use _read_at for Ready item comment re-selection

> Kind: behavior

- [x] 1.1 Update `tests/roadmap/refine/test_roadmap_refine_ready_edits.py` to verify `RefineRecordKey.READ_AT` (`read_at`) and in-flight comments between `read_at` and refine's marker comment fail against the broken `refine.py`
- Verification: `$ uv run devops ci test tests/roadmap/refine/test_roadmap_refine_ready_edits.py tests/roadmap/refine/test_roadmap_refine_event_comment.py tests/roadmap/test_roadmap_explain.py`
- [x] 1.2 Replace `_repeated_at(item)` in `_has_trusted_comment_since_last_round` (`src/devops_cli/roadmap/refine/refine.py`) with `_since_wait_start` and `_read_at`
- Verification: `$ uv run devops ci test tests/roadmap/refine/test_roadmap_refine_ready_edits.py tests/roadmap/refine/test_roadmap_refine_event_comment.py tests/roadmap/test_roadmap_explain.py`

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).
8 changes: 6 additions & 2 deletions openspec/specs/roadmap-refine/selection/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,16 @@ The refine job SHALL leave out an open item whose sub-issues count is above zero
- **THEN** `_refinable` returns the item

### Requirement: New trusted comment is refinable
`_refinable` and `devops roadmap refine` SHALL select an open `Ready` item again, even when `unrefined_ready=False`, when a trusted person comment follows its last refine round (`refine.repeated_at` when set, else the newest comment carrying `CONST_ROADMAP_REFINE_COMMENT_MARKER`).
`_refinable` and `devops roadmap refine` SHALL select an open `Ready` item again, even when `unrefined_ready=False`, when a trusted person comment follows its last refine round (`refine.read_at` when set, else the newest comment carrying `CONST_ROADMAP_REFINE_COMMENT_MARKER`).

#### Scenario: Person comments on a Ready item
- **WHEN** an open `Ready` item holds a refine record and a comment by a trusted person after its last refine round, and `_refinable` runs with `unrefined_ready=False`
- **WHEN** an open `Ready` item holds a refine record and a comment by a trusted person after `refine.read_at` (or after its last refine marker comment when `refine.read_at` is absent), and `_refinable` runs with `unrefined_ready=False`
- **THEN** `_refinable` returns the item

#### Scenario: Trusted comment posted between read_at and marker comment
- **WHEN** an open `Ready` item holds `refine.read_at` earlier than its newest refine marker comment and a trusted person comment was posted between those two times
- **THEN** `_refinable` selects the item again

### Requirement: Bot comment is not refinable
`_refinable` and `devops roadmap refine` MUST NOT select an unchanged open `Ready` item again when the only comment after its last refine round was written by a bot or an untrusted account.

Expand Down
33 changes: 11 additions & 22 deletions src/devops_cli/roadmap/refine/refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3487,28 +3487,17 @@ def _has_trusted_comment_since_last_round(
trusted: Callable[[IssueComment], bool],
) -> bool:
"""Whether `comments` holds a trusted person comment after the last refine round on `item`
(#6452): after `refine.repeated_at` when set and newer than any refine marker comment, else
after the newest comment carrying `CONST_ROADMAP_REFINE_COMMENT_MARKER`. Roadmap job comments
are ignored."""
repeated = _repeated_at(item)
marked = [
i
for i, comment in enumerate(comments)
if CONST_ROADMAP_REFINE_COMMENT_MARKER in comment.body
]
if not marked:
if repeated is None:
return False
candidates = comments_without_jobs(comments)
return any(
trusted(comment) and as_utc(comment.created_at) > repeated for comment in candidates
)
marker_idx = marked[-1]
since = as_utc(comments[marker_idx].created_at)
after = comments_without_jobs(comments[marker_idx + 1 :])
if repeated is not None and repeated > since:
return any(trusted(comment) and as_utc(comment.created_at) > repeated for comment in after)
return any(trusted(comment) and as_utc(comment.created_at) >= since for comment in after)
(#6452, #7190): after `refine.read_at` when set (#6371), else after the newest comment
carrying `CONST_ROADMAP_REFINE_COMMENT_MARKER`. Roadmap job comments are ignored."""
if any(CONST_ROADMAP_REFINE_COMMENT_MARKER in comment.body for comment in comments):
return any(trusted(comment) for comment in _since_wait_start(item, comments))
read_at = _read_at(item)
if read_at is None:
return False
return any(
trusted(comment) and as_utc(comment.created_at) > read_at
for comment in comments_without_jobs(comments)
)


def _is_unrefined_ready(item: Item) -> bool:
Expand Down
62 changes: 51 additions & 11 deletions tests/roadmap/refine/test_roadmap_refine_ready_edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _seed_refined_ready(
*,
author_login: str | None = "alice",
author_association: str | None = "OWNER",
repeated_at: datetime | None = None,
read_at: datetime | None = None,
) -> int:
"""An open refined Ready item with matching refine hashes and a refine marker comment at `_T0`."""
store.seed_visibility(is_private=True)
Expand All @@ -68,8 +68,8 @@ def _seed_refined_ready(
RefineRecordKey.SECTION_HASH: section_hash,
RefineRecordKey.NEXT_STEP: "ready",
}
if repeated_at is not None:
marks[RefineRecordKey.REPEATED_AT] = repeated_at.isoformat()
if read_at is not None:
marks[RefineRecordKey.READ_AT] = read_at.isoformat()
store.set_marks(item, marks)
store.seed_comment(number, f"{CONST_ROADMAP_REFINE_COMMENT_MARKER}\nNext step: ready.")
return number
Expand All @@ -86,13 +86,13 @@ def test_refinable_takes_ready_item_edited_outside_refine_section(
assert [it.number for it in selected] == [number]


@pytest.mark.parametrize("use_repeated_at", [False, True], ids=["refine-comment", "repeated-at"])
@pytest.mark.parametrize("use_read_at", [False, True], ids=["refine-comment", "read-at"])
def test_refinable_takes_ready_item_with_trusted_comment_after_last_round(
store: InMemoryRoadmapStore, use_repeated_at: bool
store: InMemoryRoadmapStore, use_read_at: bool
) -> None:
repeated = _T0 + timedelta(minutes=10) if use_repeated_at else None
number = _seed_refined_ready(store, repeated_at=repeated)
comment_at = (repeated or _T0) + timedelta(minutes=5)
read_at = _T0 + timedelta(minutes=10) if use_read_at else None
number = _seed_refined_ready(store, read_at=read_at)
comment_at = (read_at or _T0) + timedelta(minutes=5)
with time_machine.travel(comment_at, tick=False):
store.seed_comment(
number,
Expand All @@ -106,6 +106,46 @@ def test_refinable_takes_ready_item_with_trusted_comment_after_last_round(
assert [it.number for it in selected] == [number]


def test_refinable_takes_ready_item_with_trusted_comment_between_read_at_and_marker(
store: InMemoryRoadmapStore,
) -> None:
store.seed_visibility(is_private=True)
read_time = _T0 - timedelta(minutes=2)
with time_machine.travel(read_time, tick=False):
number = store.seed_issue(
"feat(roadmap): ready item",
body=f"Original scope.\n\n{_SECTION}",
fields={ItemField.STATUS: CONST_ROADMAP_STATUS_READY, ItemField.PRIORITY: "P2-Medium"},
author_login="alice",
author_association="OWNER",
)
store.set_field(require_item(store, number), ItemField.STATUS, CONST_ROADMAP_STATUS_READY)
with time_machine.travel(_T0 - timedelta(minutes=1), tick=False):
store.seed_comment(
number,
"Clarifying scope while round runs.",
author_association="OWNER",
author_login="alice",
)
with time_machine.travel(_T0, tick=False):
item = require_item(store, number)
body_hash, section_hash = body_hashes(item.body)
store.set_marks(
item,
{
RefineRecordKey.BODY_HASH: body_hash,
RefineRecordKey.SECTION_HASH: section_hash,
RefineRecordKey.NEXT_STEP: "ready",
RefineRecordKey.READ_AT: read_time.isoformat(),
},
)
store.seed_comment(number, f"{CONST_ROADMAP_REFINE_COMMENT_MARKER}\nNext step: ready.")

selected, _ = select_candidates(store)

assert [it.number for it in selected] == [number]


@pytest.mark.parametrize(
("association", "login"),
[
Expand Down Expand Up @@ -135,12 +175,12 @@ def test_refinable_skips_ready_item_with_bot_or_untrusted_comment(
def test_refinable_skips_unchanged_ready_item_with_no_comment_after_last_round(
store: InMemoryRoadmapStore,
) -> None:
repeated = _T0 + timedelta(minutes=10)
number = _seed_refined_ready(store, repeated_at=repeated)
read_at = _T0 + timedelta(minutes=10)
number = _seed_refined_ready(store, read_at=read_at)
with time_machine.travel(_T0 + timedelta(minutes=5), tick=False):
store.seed_comment(
number,
"Comment before repeated_at.",
"Comment before read_at.",
author_association="OWNER",
author_login="alice",
)
Expand Down