Skip to content

fix(roadmap): Upserts edit only comments of the tool account #6222

Closed

Description

@dan-petty

Problem

Two writers edit a marked comment in place and find the comment by its marker only, not by its author:

The token of the tool can edit the comments of other accounts. So a person who copies the marker into a comment gets that comment overwritten. publish_pr_evidence() in src/devops_cli/github/pr_evidence.py already matches only a comment whose author is the login of the session.

Expected behavior

An in-place edit matches only a comment that the account running the tool wrote: its author is the login of the process's GitHub session. A comment of another author that holds the marker is not edited, and the writer posts a new comment.

Source: #6219

Proposed design

Problem statement

Restrict both in-place comment writers to comments written by the tool account. post() and post_pr_review_comment() currently match a marked comment by its marker alone. A person who copies the marker can lose that comment. The fix compares the comment author with the session login and posts a new comment when no match exists.

Acceptance criteria

Requirement: Shared writer filters by session author

The shared post() writer SHALL edit an existing marked comment only when the comment author login equals the GitHub session login.

Scenario: Another author's marked comment is left unchanged

  • WHEN post() finds a comment with the marker and key whose author login is not the session login.
  • THEN post() creates a new comment and does not call update_comment for the other author's comment.

Requirement: Shared writer updates its own comment

The shared post() writer SHALL update the marked comment when its author login equals the GitHub session login and its body differs.

Scenario: Own marked comment is edited in place

  • WHEN post() finds a comment with the marker, the key and the session login, and its body differs from the new body.
  • THEN post() calls update_comment with that comment id and creates no new comment.

Requirement: Shared writer checks store comments

The shared post() writer SHALL apply the author check to comments from RoadmapStore and from GitHubClient.

Scenario: Store comment of another author is not edited

  • WHEN Target uses a store whose comment list includes a marked comment of another author.
  • THEN post() creates a new comment through the store and leaves the stored comment unchanged.

Requirement: Review writer filters by session author

post_pr_review_comment() SHALL edit the review comment for the head only when its author login equals the GitHub session login.

Scenario: Another author's head marker is left unchanged

  • WHEN the pull request has a comment with the head marker whose author login is not the session login, and no comment of the session login holds that marker.
  • THEN post_pr_review_comment() creates a new review comment and does not call update_issue_comment for the other author's comment.

Requirement: Review writer updates its own head comment

post_pr_review_comment() SHALL update the head review comment when its author login equals the GitHub session login and its body differs.

Scenario: Own head review comment is edited

  • WHEN the pull request has a head-marker comment of the session login with a different body.
  • THEN post_pr_review_comment() calls update_issue_comment with that comment id and creates no new comment.

Requirement: Writer ignores comment with no author

Each in-place writer SHALL treat a marked comment with no author login as not written by the session.

Scenario: A marked comment with no author is not edited

  • WHEN a marked comment has no author login.
  • THEN the writer posts a new comment and leaves the marked comment unchanged.

Existing Tool Considered

No alternatives check has run. The GitHub REST API issue-comments endpoint, through the existing devops_cli.github.client.GitHubClient and devops_cli.github.session, covers the need. It returns the author of each comment, and publish_pr_evidence() already compares that author with the session login. It lacks no author field; the two writers must add the same comparison. No new library is needed.

Key questions

  • Which author must an in-place edit match?: The login of the process's GitHub session. The code must not use a hardcoded account name. [sources: src/devops_cli/github/pr_evidence.py, src/devops_cli/github/session.py]
  • Where should the shared marked-comment writer apply the author check?: Inside post() in src/devops_cli/roadmap/steps/comment.py, before it accepts a comment as the match. (best practice) [sources: src/devops_cli/roadmap/steps/comment.py]
    • Chosen: Filter inside shared post(). One place covers every caller, including the keyless watch conflict comment.
    • Rejected: Filter in each caller. Many callers use post(), and a new caller can omit the check.
    • Rejected: Filter in Target.list_comments(). Reads must still see other authors' comments; only the edit match changes.
  • How should the review comment writer get the session login?: Use the authenticated login from get_github_session(), and compare it with the comment author. (best practice) [sources: src/devops_cli/ai/review/runner.py, src/devops_cli/github/session.py, src/devops_cli/github/pr_evidence.py]
    • Chosen: Reuse the session login. The session already holds the token and the login, so no new setting or secret is needed.
    • Rejected: Pass the login from each caller. post_pr_review_comment() has one caller path, and a parameter adds no value.
    • Rejected: Use a fixed bot login from config. A fixed login duplicates the session identity and can drift.
  • What should a writer do when no marked comment of the session author exists?: Post a new comment, and leave every marked comment of another author unchanged. (best practice) [sources: src/devops_cli/roadmap/steps/comment.py, src/devops_cli/ai/review/runner.py]
    • Chosen: Post a new comment. The writer still records its update, and another author's comment stays intact.
    • Rejected: Skip the write. The caller needs its marked comment, so skipping loses the update.
    • Rejected: Edit the first marker comment. That is the current bug: the tool token can overwrite another person's comment.
  • How should the shared writer treat comments from RoadmapStore and from GitHubClient?: Apply the same author check to both comment sources, and require the store comment to carry its author. (best practice) [sources: src/devops_cli/roadmap/steps/comment.py]
    • Chosen: Check the author on both store and client comments. Target reads either source, so one source must not bypass the fix.
    • Rejected: Check only client comments. The store path can still edit another author's comment.
    • Rejected: Filter the store list before post() sees it. That hides comments from reads and splits the rule across layers.
  • How should a writer treat a marked comment with no author login?: Treat it as not written by the session, so it is never edited. (best practice) [sources: src/devops_cli/roadmap/steps/comment.py, src/devops_cli/ai/review/runner.py]
    • Chosen: Treat a missing author as no match. The writer cannot show that the session wrote the comment.
    • Rejected: Treat a missing author as a match. That keeps the overwrite risk for a malformed comment.
    • Rejected: Raise an error. A new comment still records the update without stopping the step.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    status/new
    on Nov 17, 2026
  2. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The bug lets the tool overwrite a user's comment, which is user data loss triggered by a specific condition.
    • Related: refactor(roadmap): One job-comment writer with a marker registry #6200, which asks for a different change. Both touch steps/comment.py post() and the roadmap comment-writing area, but the candidate adds an author match to prevent overwriting others' comments while #6200 refactors the writer into a marker registry.
  3. added
    value/medium
    effort/low
    priority/p1-high
    on Nov 17, 2026
  4. devops-cli-service commented on Nov 17, 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. added
    status/in-progress
    and removed
    status/new
    on Nov 18, 2026
  6. added
    status/in-review
    and removed
    status/in-progress
    on Nov 18, 2026
  7. removed
    status/in-review
    on Nov 18, 2026
  8. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor
  9. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-18 01:44 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/p1-highscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions