Skip to content

feat(roadmap): grade stage by the plans that build #5603

Description

@dan-petty

Problem

The grade of the stage job counts an attempt as a success when it opens a plan pull request (docs/roadmap/job-success.md, devops roadmap eval grades). This measure does not show if the plan can be built.

On 2026-11-14, an agent vetted 9 plan pull requests that the stage job opened between 23:23Z and 01:59Z: #5576, #5580, #5581, #5586, #5587, #5589, #5591, #5592 and #5593. Only #5580 (#3332) was safe. The other 8 had blocking defects, for example:

In the same window, the stage grade was 9/10 over 6 h. The cost of a bad plan shows later, in the implement job: the implement attempt of #3257 used 36.2M tokens (the item budget is 40M) and 4710 s on that plan, and it stopped. Over 24 h, implement was 2/8, and its top failure class was outside_plan: the plan did not name a path that the failed check needed (#4449, #5272).

So the stage grade says that the job meets the 80% target, while most of its plans cannot be built.

Expected behavior

The stage grade shows how many plans can be built, from data that a program reads (no model judges the plan for the grade). Keep "opens a plan pull request" as the first step of a funnel, and add a measure of the plan outcome.

Fix options (the plan decides)

  • A lagging plan outcome for each staged attempt. Success: the implement job reaches a ready pull request on that plan with no stop of a plan class (outside_plan, plan_defect, tests_lost) and no plan revision. Failure: the plan pull request gets plan/needs-fix, a person closes it, or the implement job stops with a plan class. Open: no outcome yet. Show the funnel: attempts, plan pull requests, plans that build.
  • Report the tokens of failed implement attempts for each plan, so the cost of a bad plan shows next to the stage grade.
  • Use the result lines and labels that already exist (roadmap job result, implement attempt, plan/needs-fix). Add a field to a result line only where no current signal holds the outcome.

Test first: a fixture with a staged attempt whose plan later gets plan/needs-fix counts as a plan failure, and a staged attempt whose implement reaches a ready pull request counts as a plan success.

Related

Alternatives check of 2026-11-26: partly.
Tool: apache/devlake (https://github.com/apache/devlake), Apache-2.0, last activity 2026-11-26, maintained.
Reason: Searches found Apache DevLake, an open dev-data platform that ingests GitHub and CI data and builds metric dashboards, so it covers the collection and counting part; it reads none of the project's result lines and sums no implement tokens.

Covers:

  • Ingests GitHub pull requests, issues and CI data sources
  • Prebuilt Grafana dashboards for delivery and success rates
  • Custom SQL metrics over the collected data

Lacks:

  • No read of the plan= result lines
  • No join of a staged attempt to its plan pull request
  • No sum of tokens of failed implement attempts
  • Needs a deployed platform beside the existing report

Proposed design

Problem statement

The stage grade counts a plan pull request as a success. It does not show if the plan can be built. Eight of nine plans from 2026-11-14 had blocking defects while the stage grade was 9/10. The change keeps plan pull requests as the first funnel step and adds a plan outcome measure from result lines and labels, with no model judgment.

Acceptance criteria

Requirement: Plan verdict failure

The plan outcome classifier SHALL mark a staged plan as a failure when the first verdict label of its plan pull request is verdict/fix-plan or verdict/discard-plan.

Scenario: Plan verdict is failure

  • WHEN A fixture stage line has result=staged plan=101, and plan pull request 101 has a first verdict label verdict/fix-plan or verdict/discard-plan.
  • THEN plan_outcome returns failure with reason plan_needs_fix for verdict/fix-plan and plan_discarded for verdict/discard-plan.

Requirement: Closed plan is failure

The plan outcome classifier SHALL mark a staged plan as a failure when a person closes its plan pull request without a merge.

Scenario: Plan closed

  • WHEN A fixture stage line has result=staged plan=101, and plan pull request 101 has state CLOSED and mergedAt null.
  • THEN plan_outcome returns failure with reason plan_closed.

Requirement: Built plan is success

The plan outcome classifier SHALL mark a staged plan as a success only when its implement line is drafted with forge outcome success and no failure signal exists.

Scenario: Plan builds

  • WHEN A fixture has a stage line with item=#1 result=staged plan=101, an implement line with item=#1 result=drafted pull=202, pull 202 is merged, and plan 101 has no first verdict/fix-plan or verdict/discard-plan label event.
  • THEN plan_outcome returns success.

Requirement: Plan class stop is failure with tokens

The plan outcome classifier SHALL mark a staged plan as a failure and carry its tokens when its implement line stops with one of outside_plan, plan_defect or tests_lost.

Scenario: Implement stops with a plan class

  • WHEN A fixture has a stage line with item=#1 result=staged plan=101, and three implement lines with item=#1 result=stopped, classes outside_plan, plan_defect and tests_lost, and tokens=36200000.
  • THEN plan_outcome returns failure with the class as the reason and tokens 36200000 for each line.

Requirement: Open plan

The plan outcome classifier SHALL return open when no success or failure signal exists.

Scenario: No outcome yet

  • WHEN A fixture stage line has item=#1 result=staged plan=101, plan 101 is open with no fix label, and no implement line exists.
  • THEN plan_outcome returns open.

Requirement: Funnel counts

The plan funnel SHALL count stage attempts, unique plan pull requests, plans that build, plan failures and open plans.

Scenario: Mixed plan outcomes

  • WHEN A fixture holds four staged stage lines, three unique plan pull requests, one success, one failure and one open plan.
  • THEN plan_funnel returns attempts 4, plan_pull_requests 3, plans_that_build 1, failures 1 and open 1.

Requirement: JSON stage row

The JSON report SHALL give each stage row a plan_outcome object with the funnel counts and the tokens of failed implement attempts.

Scenario: Stage row with plan cost

  • WHEN build_report runs on a fixture with one plan success and one plan failure whose implement line has tokens=36200000.
  • THEN The stage row plan_outcome has plans_that_build 1, failures 1 and tokens 36200000.

Requirement: Text report

The text report SHALL print the plan funnel and the tokens of failed implement attempts beside the stage grade.

Scenario: Text stage section

  • WHEN The text report runs on the same fixture.
  • THEN The stage section contains Plans that build 1/2 and Failed implement tokens 36200000.

Requirement: Stage line plan field

A stage result line for a staged attempt MUST contain a plan field that names its plan pull request.

Scenario: Stage line names plan

  • WHEN The stage job writes a result line for a staged attempt that opened plan pull request 101.
  • THEN The line contains plan=101.

Requirement: Plan query captures plan

The stage query builder MUST capture the plan field and group the stage and implement outcomes by it.

Scenario: Plan query

  • WHEN The stage query builder returns the LogQL query for a fixture.
  • THEN The query contains plan=(?P<plan>\S+) and a grouping clause by (plan).

Requirement: No model call

The plan outcome report MUST read only result lines and pull request labels, with no model call.

Scenario: No model judgment

  • WHEN build_report runs on the fixture with a patched model client that raises on any call.
  • THEN The report returns the funnel and the patched client records no call.

Requirement: Latest stage line joins

The plan outcome join SHALL attach an implement line to the latest staged line of the same item before the implement line.

Scenario: Second plan of one item

  • WHEN Fixtures hold stage lines for item Release v0.1.8 #1 at 00:00 with plan=100 and at 01:00 with plan=101, and an implement line for item Release v0.1.8 #1 at 02:00.
  • THEN plan_outcome uses the plan number 101 from the 01:00 stage line.

Existing Tool Considered

The alternatives check of 2026-11-20 in the issue body records verdict none and no tool. No open, maintained tool or library covers the join of result lines to plan pull request labels and the plan-outcome funnel. The proposal extends the existing devops roadmap eval grades report and adds no library. Written cost of the new join: 40k tokens to build, 12k to keep and 8k to fix, about 2 days.

Key questions

  • Which labels mark a plan that needs repair or discard?: verdict/fix-plan marks a plan that needs repair, and verdict/discard-plan marks a plan that cannot be built. Both are plan failures. The issue text's plan/needs-fix is not the current workflow label. [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/workflow_labels.py]
  • Which failure classes count as plan failures in an implement stop?: The plan classes are outside_plan, plan_defect and tests_lost. An implement line with result=stopped and one of these classes is a plan failure. Other classes are not plan failures. [sources: src/devops_cli/roadmap/failure.py, docs/roadmap/job-success.md, src/devops_cli/config/settings.py:1387]
  • How does the report link a staged attempt to its plan pull request?: Add an optional plan=<n> field to the stage result line when result=staged. The stage job knows the plan pull request that it opened. The implement line joins to the latest staged stage line of the same item before it. An item and time join alone is ambiguous after a re-stage. (best practice) [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/job_result.py]
    • Chosen: Add plan field to stage line. The stage job knows the pull request number, and the line identifies the plan with no search.
    • Rejected: Join by item and time only. A re-stage and a second plan of the same item make the join ambiguous.
    • Rejected: Search GitHub by title for each attempt. It adds a request for each attempt and can match the wrong plan after a re-stage.
  • What makes a staged plan a success?: A plan is a success when an implement line for the same item is drafted, its delivery pull request has forge outcome success, no plan-class stop exists, and the plan pull request has no first verdict/fix-plan or verdict/discard-plan label event. A ready line after a plan revision is not a success. (best practice) [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/job_grade_report.py, docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: Drafted with forge success and no failure label. It follows the success rule in the issue and uses the existing forge outcome, labels and result lines.
    • Rejected: Any implement drafted line. It counts a plan that needed a fix as a success.
    • Rejected: Drafted with no plan failure class. It misses the plan revision signal.
  • What makes a staged plan a failure?: A plan is a failure when its plan pull request has a first verdict/fix-plan or verdict/discard-plan label event, a person closes it without a merge, or an implement line is stopped with a plan class. An open plan with no such signal is open. (best practice) [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/failure.py, src/devops_cli/roadmap/workflow_labels.py]
    • Chosen: Failure label, close or plan-class stop. It uses the failure signals that the issue names and the existing labels and result lines.
    • Rejected: Only a plan-class implement stop. It misses a plan that a label or a close already refused.
    • Rejected: Any implement result that is not drafted. It counts an open plan and an infrastructure cut as a plan failure.
  • How does the funnel count a re-staged plan pull request?: Each stage result line is an attempt. A plan pull request counts once by its plan number. The latest stage line for that plan gives its outcome. An earlier attempt on the same plan is not a second plan. (best practice) [sources: docs/roadmap/job-success.md, CONTEXT.md]
    • Chosen: Count each plan number once. A re-stage updates one pull request, and the funnel shows attempts and plan pull requests as different steps.
    • Rejected: Count each stage attempt as a plan. A re-stage updates one pull request and would inflate the plan count.
    • Rejected: Count only the latest stage line. It hides the attempts that the funnel must show.
  • How does the report get per-plan outcomes with no model call?: Use Loki metric instant queries grouped by the plan field to get the sets of stage and implement outcomes. Add plan to the result-line regexp. Use the existing GraphQL search of bot pull requests for label events and closed state. Do the set operations in job_grade_report.py. A model makes no judgment. (best practice) [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/job_grade_report.py, docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: Loki metric queries by plan plus the GitHub search. It uses the existing report queries and the existing bot pull request search.
    • Rejected: Loki range query of every result line. The line limit and the volume of 7 days of lines make the report fragile.
    • Rejected: A model reads the plans. The expected behavior forbids model judgment for the grade.
  • How does the report show the tokens of failed implement attempts?: Sum the tokens field of implement lines whose plan outcome is failure. Show the sum for each plan and in the stage row. A plan failure by label or close has no implement line, so its token value is none. (best practice) [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/job_result.py]
    • Chosen: Sum tokens of failed implement lines per plan. It shows the cost of a bad plan next to the stage grade.
    • Rejected: Sum tokens of every implement line. It mixes the cost of good plans with the cost of bad plans.
    • Rejected: Show one aggregate only. The issue asks for the cost of each plan.
  • Where does the report show the plan funnel?: Add a plan_outcome object to each stage row in the JSON report. Print the funnel and the failed implement tokens in the text stage section. Do not add a separate dashboard or a new report. (best practice) [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/job_grade_report.py]
    • Chosen: Add to the stage row and text report. The stage grade and its plan outcome stay in one place for a person and for an agent.
    • Rejected: Add a separate report command. It splits one grade across two commands and two reads.
    • Rejected: Add a dashboard only. The command and its JSON report are the contract that tests check.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 14, 2026
  2. dan-petty commented on Nov 14, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 14, 2026
  4. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • CI pipeline analytics tool DORA metrics GitHub pull request labels Loki logs join, results: 5
    • open source tool join CI job result lines with GitHub pull request labels outcome report, results: 5
    • open source engineering metrics tool GitHub pull requests labels deployment outcome funnel, results: 5
    • Grafana Loki GitHub label join query metrics dashboard pull request cycle time, results: 5
    • Loki, results: 5
    • DORA metrics open source, results: 5
    • Apache DevLake GitHub pull request labels Grafana dashboards, results: 5
    • DevLake, results: 5
    • engineering productivity metrics self-hosted open source GitHub pull requests labels, results: 5
    • Grafana Loki log lines GitHub pull request labels correlation dashboard, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Nov 21, 2026
  7. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: none, no tool. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • Apache DevLake GitHub pull request labels CI pipeline metrics dashboard, results: 5
    • open source tool compute CI job success rate from GitHub pull request labels and logs, results: 5
    • DevLake github.com/apache/incubator-devlake, results: 5
    • Grafana Loki LogQL count log lines grouped by extracted label, results: 5
    • "apache/devlake" GitHub repository open source dev data platform, results: 5
    • self-hosted open source engineering metrics ingest GitHub PR labels and CI results DORA, results: 5
    • engineering metrics open source tool, results: 5
    • devlake, results: 5
    • parse CI logs aggregate metrics tool, results: 5
    • devlake github plugin pull request labels data source docs, results: 5

    Sources:

  9. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  10. removed
    status/in-review
    on Nov 29, 2026
  11. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 18:59 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions