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
Expand Up @@ -342,3 +342,5 @@ The naming record of #4533 owns the object names, the labels, the Valkey key for
2026-11-21: Fact out of date: section 8, row `fix-conflict`, tiers. The step has no tier 2 model fix, and tier 1 drops an archive commit with `git rebase --skip` (#6618).

2026-11-21: Fact out of date: section 8, row `fix-conflict`, Before the push. Only `openspec validate --specs --strict` runs; the step runs no scoped checks (#6618).

2026-11-25: Fact out of date: section 2 and section 8 (`fix-plan`) now use `verdict/fix-plan`, with `verdict/mergeable`, `verdict/discard-plan`, `verdict/issue-changed`, `verdict/fix-implementation` and `verdict/discard-implementation`, replacing `plan/needs-fix` (#5984).
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-25
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Design

## Decisions
- **Title at first verdict label**: Order `timelineItems` events (`LABELED_EVENT` and `RENAMED_TITLE_EVENT`). For the first verdict label event at index `i`, take `previous_title` of the earliest `RENAMED_TITLE_EVENT` after `i` (or `node.title` if none follows `i`) so pre-rename labels use the prior title and post-rename labels use the renamed title. When a PR has no verdict label event, use `node.title`.
- **Single-page timeline guard**: Add `pageInfo { hasNextPage }` to `timelineItems` (defaulting to `False` in Pydantic when omitted by older mocks) and raise `GitHubUnreadError` naming the PR number and timeline page limit when true.
- **Loki row isolation on GitHub failure**: Add `GradeReport.verdict_error: str | None = None`. Catch `GitHubUnreadError` in `grade_report` and store `str(exc)` so `render_grade_report` renders `verdicts not read: <reason>` while preserving all Loki workflow rows and JSON output.
- **Single `FIX_PLAN_LABEL` source without startup penalty**: Define `FIX_PLAN_LABEL = "verdict/fix-plan"` in `workflow_labels.py` and re-export it from `stage_verify.py` (`__all__` unchanged). Importing `stage_verify.py` directly in `phase.py` loads `pydantic_ai` during `devops gh --help` (via `github/metrics.py`), and importing it in `workflow_labels.py` or `failure.py` causes a circular import.

## Rejected alternatives
- **Current title or initial title for every event**: Using current title loses pre-rename stage verdicts; forcing initial title on post-rename delivery verdicts misattributes implement verdicts to stage.
- **Keep literal `"verdict/fix-plan"` in `stage_verify.py` alone**: Impossible without lazy imports in `phase.py` and circular imports in `workflow_labels.py`/`failure.py`.
- **Paginate nested `timelineItems`**: Adds extra GraphQL round trips and complexity instead of matching `_search_page`'s fail-closed overflow guard.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Proposal: #5984

## Why
`read_bot_pulls` reads `node.title` at report time, so a plan draft renamed to a delivery title loses its stage verdict, scores post-rename labels inconsistently, or drops timeline items past 100 events without failing. A `GitHubUnreadError` also aborts the Loki grade report, `"verdict/fix-plan"` is duplicated as raw literals, and docs still omit the full verdict label set or name `plan/needs-fix`.

## What Changes
- Request `RENAMED_TITLE_EVENT` (`previousTitle`) and `timelineItems.pageInfo { hasNextPage }` in `pr_verdict._SEARCH_QUERY`.
- Score each bot pull request by the title active when its first verdict label event occurred, and raise `GitHubUnreadError` with PR number and timeline page reason if `hasNextPage` is true.
- Catch `GitHubUnreadError` in `grade_report`, recording `GradeReport.verdict_error` and rendering `verdicts not read: <reason>` while preserving Loki rows.
- Define `FIX_PLAN_LABEL` once in `workflow_labels.py`, re-export it in `stage_verify.py`, and replace raw `"verdict/fix-plan"` literals in `pr_verdict.py`, `phase.py`, `workflow_labels.py`, and `failure.py`.
- Update ADR 0021 (`plan/needs-fix` -> `verdict/fix-plan`, list all six verdict labels) and `github_project_management.md` (list all six verdict labels).

## Capabilities
- `roadmap-job-grades`: Rename-aware verdict attribution, timeline overflow error, grade report error isolation, shared `FIX_PLAN_LABEL` constant, and verdict label documentation.

## Impact
- `src/devops_cli/roadmap/pr_verdict.py`
- `src/devops_cli/roadmap/job_grade_report.py`
- `src/devops_cli/lang/en/messages.py`
- `src/devops_cli/roadmap/workflow_labels.py`
- `src/devops_cli/roadmap/stage/stage_verify.py`
- `src/devops_cli/roadmap/phase.py`
- `src/devops_cli/roadmap/failure.py`
- `docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md`
- `src/devops_cli/ai/knowledge_base/devops_cli/tasks/github_project_management.md`

## Feasibility
Confirmed against `origin/main`: `pr_verdict.py:139,366` reads `node.title` and omits `RENAMED_TITLE_EVENT` and `timelineItems.pageInfo`; `job_grade_report.py:913` calls `_read_verdicts` without catching `GitHubUnreadError`; `pr_verdict.py:97`, `phase.py:275`, `workflow_labels.py:130`, and `failure.py:373` still hold literal `verdict/fix-plan`; ADR 0021 lines 60 and 215 use `plan/needs-fix`.

## Existing Tool Considered
PyGithub/PyGithub was rejected by ADR 0006. No external library replaces the project's custom GraphQL verdict scoring, Loki report isolation, and internal constant consolidation; extending `pr_verdict.py`, `job_grade_report.py`, and `workflow_labels.py` directly avoids extra dependencies.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## MODIFIED Requirements

### Requirement: The first verdict label scores a bot pull request
The verdict search SHALL select `LABELED_EVENT` and `RENAMED_TITLE_EVENT` (`previousTitle`) with `pageInfo.hasNextPage` in one `timelineItems` call and raise `GitHubUnreadError` with pull request number and timeline reason if `hasNextPage` is true. A bot pull request SHALL score by the title active at its first verdict label event (before the rename uses `previousTitle`; after uses the current title). Unlabeled PRs SHALL use the current title, and cross-kind first labels SHALL stay unscored.

#### Scenario: A plan that needs a fix and then can merge
- **WHEN** the label events of a plan pull request are `type/docs`, `verdict/fix-plan` and `verdict/mergeable`, in this order, and the step fix-plan removed `verdict/fix-plan`
- **THEN** the verdict of the plan is needs fix

#### Scenario: A delivery with the label of a plan
- **WHEN** the label events of a delivery pull request are `type/feature`, `verdict/fix-plan` and `verdict/mergeable`
- **THEN** the delivery is unscored, and the read logs that its first verdict label is a label of the other kind

#### Scenario: The old label
- **WHEN** the label events of a plan pull request are `plan/needs-fix` and `verdict/mergeable`
- **THEN** the verdict of the plan is mergeable

#### Scenario: Plan verdict before rename
- **WHEN** a bot pull request opens with a plan title, gets `verdict/mergeable`, and later renames to a delivery title
- **THEN** `read_bot_pulls` returns `PullKind.PLAN` with `Verdict.MERGEABLE` and counts it for stage

#### Scenario: Delivery verdict after rename
- **WHEN** a bot pull request opens with a plan title, renames to a delivery title, and gets `verdict/fix-implementation`
- **THEN** `read_bot_pulls` returns `PullKind.DELIVERY` with `Verdict.NEEDS_FIX` and counts it for implement

#### Scenario: More than one page of timeline events
- **WHEN** GitHub returns `timelineItems.pageInfo.hasNextPage` as true on a pull request
- **THEN** `read_bot_pulls` raises `GitHubUnreadError` naming the pull request number and timeline page limit

### Requirement: eval grades reads the bot pull requests of the window with one search
`devops roadmap eval grades` SHALL read the pull requests of the bot of `service.github_app.slug` that changed in the window, with their label and rename events, head branch, state, draft flag, and creation time, in one GraphQL search per 100 pull requests (`--repo` scopes the search). When the verdict read raises `GitHubUnreadError`, `grade_report` SHALL record `verdict_error`, keep all Loki rows, and render `verdicts not read: <reason>`.

#### Scenario: The search of the window and the repository
- **WHEN** a person runs `devops roadmap eval grades --repo example/app` at 2026-11-09T12:00:00Z with the slug `example-bot`
- **THEN** the command sends one GraphQL search for `is:pr author:app/example-bot updated:>=2026-11-02T12:00:00Z repo:example/app`

#### Scenario: No slug
- **WHEN** `service.github_app.slug` is not set
- **THEN** the command sends no request to GitHub, and its text names `service.github_app.slug`

#### Scenario: GitHub verdict read fails while Loki succeeds
- **WHEN** Loki returns grade rows and the GitHub verdict read raises `GitHubUnreadError`
- **THEN** `devops roadmap eval grades` prints `verdicts not read: <reason>` and keeps the Loki grade rows

## ADDED Requirements

### Requirement: One fix-plan label constant
Every reader and writer of `verdict/fix-plan` under `src/devops_cli/roadmap` SHALL import `FIX_PLAN_LABEL` from `workflow_labels.py` (re-exported by `stage_verify.py`), with only that single literal declaration in `workflow_labels.py`. A test SHALL verify `VERDICT_LABELS[PullKind.PLAN][FIX_PLAN_LABEL]` equals `Verdict.NEEDS_FIX`.

#### Scenario: Single source and VERDICT_LABELS match
- **WHEN** a test inspects `FIX_PLAN_LABEL` from `stage_verify.py` and scans `src/devops_cli/roadmap`
- **THEN** `VERDICT_LABELS[PullKind.PLAN][FIX_PLAN_LABEL]` is `Verdict.NEEDS_FIX` and no other module defines the literal `verdict/fix-plan`

### Requirement: Six verdict labels in docs
ADR 0021 Status History and `github_project_management.md` SHALL list all six verdict labels (`verdict/mergeable`, `verdict/fix-plan`, `verdict/discard-plan`, `verdict/issue-changed`, `verdict/fix-implementation`, and `verdict/discard-implementation`), and ADR 0021 Status History SHALL note that `plan/needs-fix` is out of date while preserving the accepted body hash.

#### Scenario: Documents match VERDICT_LABELS
- **WHEN** a test compares every label key in `VERDICT_LABELS` against ADR 0021 Status History and `github_project_management.md`
- **THEN** all six labels appear in both files and ADR 0021 Status History records that `plan/needs-fix` was replaced
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tasks

## 1. Behavior

- [x] 1.1 Write failing tests for renamed PR verdicts, timeline overflow, grade report error isolation, `FIX_PLAN_LABEL` consistency, and verdict docs in `tests/roadmap/test_pr_verdict.py`, `tests/roadmap/test_job_grade_report.py`, and `tests/commands/test_roadmap_eval_grades.py`
- Verification: `$ uv run devops ci test tests/roadmap/test_pr_verdict.py tests/roadmap/test_job_grade_report.py tests/commands/test_roadmap_eval_grades.py`
- [x] 1.2 Implement rename-aware verdict scoring, timeline overflow guard, Loki isolation, and shared `FIX_PLAN_LABEL` across `pr_verdict.py`, `job_grade_report.py`, `messages.py`, `workflow_labels.py`, `stage_verify.py`, `phase.py`, and `failure.py`
- Verification: `$ uv run devops ci test tests/roadmap/ tests/commands/test_roadmap_eval_grades.py tests/invariants/test_source_tree.py`

## 2. Documents

- [x] 2.1 Update ADR 0021 and `github_project_management.md` to name all six verdict labels and remove `plan/needs-fix` from current sections
- Verification: `$ uv run devops openspec check && uv run devops ci docs`
34 changes: 32 additions & 2 deletions openspec/specs/roadmap-job-grades/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The package SHALL declare the workflow labels `verdict/mergeable`, `verdict/fix-
- **THEN** the plan reads `verdict/mergeable`, `verdict/fix-plan`, `verdict/discard-plan` and `verdict/issue-changed`, the delivery reads `verdict/mergeable`, `verdict/fix-implementation`, `verdict/discard-implementation` and `verdict/issue-changed`, and each label is a workflow label

### Requirement: The first verdict label scores a bot pull request
A bot pull request whose title starts with `docs(spec): plan #` or legacy `docs(openspec): plan #` SHALL score stage, and each other bot pull request SHALL score implement. The first label event of a verdict label SHALL give the verdict of the pull request. A pull request with no such event SHALL be open. A first verdict label of the other kind SHALL leave the pull request unscored, and the read SHALL log why.
A bot pull request whose title at its first verdict label event starts with `docs(spec): plan #` or `docs(openspec): plan #` SHALL score stage; others SHALL score implement. The search SHALL read `LABELED_EVENT` and `RENAMED_TITLE_EVENT` (`previousTitle`) with `pageInfo.hasNextPage` in one `timelineItems` call and raise `GitHubUnreadError` on overflow. Unlabeled PRs SHALL use the current title, and cross-kind first labels SHALL stay unscored.

#### Scenario: A plan that needs a fix and then can merge
- **WHEN** the label events of a plan pull request are `type/docs`, `verdict/fix-plan` and `verdict/mergeable`, in this order, and the step fix-plan removed `verdict/fix-plan`
Expand All @@ -103,8 +103,20 @@ A bot pull request whose title starts with `docs(spec): plan #` or legacy `docs(
- **WHEN** the label events of a plan pull request are `plan/needs-fix` and `verdict/mergeable`
- **THEN** the verdict of the plan is mergeable

#### Scenario: Plan verdict before rename
- **WHEN** a bot pull request opens with a plan title, gets `verdict/mergeable`, and later renames to a delivery title
- **THEN** `read_bot_pulls` returns `PullKind.PLAN` with `Verdict.MERGEABLE` and counts it for stage

#### Scenario: Delivery verdict after rename
- **WHEN** a bot pull request opens with a plan title, renames to a delivery title, and gets `verdict/fix-implementation`
- **THEN** `read_bot_pulls` returns `PullKind.DELIVERY` with `Verdict.NEEDS_FIX` and counts it for implement

#### Scenario: More than one page of timeline events
- **WHEN** GitHub returns `timelineItems.pageInfo.hasNextPage` as true on a pull request
- **THEN** `read_bot_pulls` raises `GitHubUnreadError` naming the pull request number and timeline page limit

### Requirement: eval grades reads the bot pull requests of the window with one search
`devops roadmap eval grades` SHALL read the pull requests of the bot of `service.github_app.slug` that changed in the window, with their label events, head branch, state, draft flag and creation time, in one GraphQL search for each 100 pull requests. `--repo` SHALL put the repository in the search.
`devops roadmap eval grades` SHALL read the pull requests of the bot of `service.github_app.slug` that changed in the window, with their label and rename events, head branch, state, draft flag, and creation time, in one GraphQL search per 100 pull requests (`--repo` scopes the search). When the verdict read raises `GitHubUnreadError`, `grade_report` SHALL record `verdict_error`, keep all Loki rows, and render `verdicts not read: <reason>`.

#### Scenario: The search of the window and the repository
- **WHEN** a person runs `devops roadmap eval grades --repo example/app` at 2026-11-09T12:00:00Z with the slug `example-bot`
Expand All @@ -114,6 +126,10 @@ A bot pull request whose title starts with `docs(spec): plan #` or legacy `docs(
- **WHEN** `service.github_app.slug` is not set
- **THEN** the command sends no request to GitHub, and its text names `service.github_app.slug`

#### Scenario: GitHub verdict read fails while Loki succeeds
- **WHEN** Loki returns grade rows and the GitHub verdict read raises `GitHubUnreadError`
- **THEN** `devops roadmap eval grades` prints `verdicts not read: <reason>` and keeps the Loki grade rows

### Requirement: The report gives the verdict score beside the attempt ratio
For the stage and implement rows the report SHALL give the pull requests, the open and the unscored ones, the count and the share of each verdict over the pull requests with a verdict, the attempt ratio `p`, and the verdict score `(mergeable + w × needs fix) / (mergeable + needs fix + discards)`, where `w` is `roadmap.verdict_partial_score` (default 0.5). Issue changed SHALL stay out of the score.

Expand Down Expand Up @@ -226,3 +242,17 @@ The report SHALL NOT split a query when Loki returns HTTP 400 without `maximum n
#### Scenario: A query with a syntax error
- **WHEN** Loki answers HTTP 400 with `parse error`
- **THEN** `grade_report` sends one query and raises `ServiceRequestError` with status 400

### Requirement: One fix-plan label constant
Every reader and writer of `verdict/fix-plan` under `src/devops_cli/roadmap` SHALL import `FIX_PLAN_LABEL` from `workflow_labels.py` (re-exported by `stage_verify.py`), with only that single literal declaration in `workflow_labels.py`. A test SHALL verify `VERDICT_LABELS[PullKind.PLAN][FIX_PLAN_LABEL]` equals `Verdict.NEEDS_FIX`.

#### Scenario: Single source and VERDICT_LABELS match
- **WHEN** a test inspects `FIX_PLAN_LABEL` from `stage_verify.py` and scans `src/devops_cli/roadmap`
- **THEN** `VERDICT_LABELS[PullKind.PLAN][FIX_PLAN_LABEL]` is `Verdict.NEEDS_FIX` and no other module defines the literal `verdict/fix-plan`

### Requirement: Six verdict labels in docs
ADR 0021 Status History and `github_project_management.md` SHALL list all six verdict labels (`verdict/mergeable`, `verdict/fix-plan`, `verdict/discard-plan`, `verdict/issue-changed`, `verdict/fix-implementation`, and `verdict/discard-implementation`), and ADR 0021 Status History SHALL note that `plan/needs-fix` is out of date while preserving the accepted body hash.

#### Scenario: Documents match VERDICT_LABELS
- **WHEN** a test compares every label key in `VERDICT_LABELS` against ADR 0021 Status History and `github_project_management.md`
- **THEN** all six labels appear in both files and ADR 0021 Status History records that `plan/needs-fix` was replaced
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GitHub project governance in `devops-cli` standardizes repository metadata acros
3. **GitHub Projects v2 Lifecycle**: Board creation, multi-board listing, reconciliation of Status and Priority on the board's cards from issue and pull request state and labels, and automated drift auditing against standardized template schemas.
4. **Standardized Projects v2 Views**: Continuous auditing and synchronization of the 4 canonical views (`Sprint Kanban`, `Roadmap Timeline`, `Triage & Quality Table`, and `Value vs Effort Priority Matrix`) ensuring full alignment across `https://github.com/dan-petty/devops-cli/projects` and `https://github.com/dan-petty/devops-cli/issues/views`.
5. **Roadmap Milestones**: GitHub is the roadmap's source of truth (ADR 0001). A milestone is a planning bucket with issue completion ratios and health metrics. A milestone never names a version, and no release reads one.
6. **Declarative Label Taxonomy & PR Auditing**: Repository label synchronization from two sources. The package declares the workflow labels that the roadmap code reads or writes (`type/*`, `status/*`, `priority/*`, `value/*`, `effort/*`, `owner/*`, `verdict/fix-plan`, `needs-split` and `source/agent`, in `roadmap/workflow_labels.py`). `.github/labels.yml` declares the labels of the repository, such as `scope/*`.
6. **Declarative Label Taxonomy & PR Auditing**: Repository label synchronization from two sources. The package declares the workflow labels that the roadmap code reads or writes (`type/*`, `status/*`, `priority/*`, `value/*`, `effort/*`, `owner/*`, `verdict/mergeable`, `verdict/fix-plan`, `verdict/discard-plan`, `verdict/issue-changed`, `verdict/fix-implementation`, `verdict/discard-implementation`, `needs-split` and `source/agent`, in `roadmap/workflow_labels.py`). `.github/labels.yml` declares the labels of the repository, such as `scope/*`.

---

Expand Down
1 change: 1 addition & 0 deletions src/devops_cli/lang/en/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6981,6 +6981,7 @@ class RoadmapMessages:
"Verdicts: not read. Set service.github_app.slug to read the verdicts of the pull "
"requests of the bot."
)
grades_verdicts_error: str = "verdicts not read: {reason}"
grades_verdicts_title: str = (
"Verdicts of the pull requests that {bot} opened in the {window} window. The first "
"verdict of each pull request counts, and needs fix scores {partial}. A share counts the "
Expand Down
Loading