Skip to content

refactor(roadmap): one marked-comment writer for every job #5025

Closed

Description

@dan-petty

Problem or Motivation

18 comment sites use 5 rules (a marker read, a ledger, a record key, an upsert or none): stage.py:2599, :2660, :2733, :2774, :2800, :2859; implement_run.py:865, :1515, :1715, :1780, :1809; implement_submit.py:249; stop_clear.py:276; refine.py:3220; stage_ready.py:122, :143; pr_conflicts.py:129; release_comments.py:110. PR #4978 (#4793) adds a repeat guard in the store, but not one upsert rule. ADR 0021 section 3 rule 5 needs a marker read before each post.

Proposed Solution & Architectural Design

steps/comment.py post(target, marker, key, body): upsert by marker and key, read the marker before a post, and let the #4793 guard refuse a repeat. Change every site in the same pull request. Run the stop-after-each-write harness of #4793 (tests/support/write_stops.py) on stage, refine and implement. Coordinate with #4702 (the gate result on the issue), which also writes a marked comment.

Start after PR #4978 merges and after open-step, which moves implement_run.py:1515. Cost: about 1M tokens and 1 agent-day.

Target Subsystem

Every roadmap job that posts a marked comment (stage, refine, implement, release comments).

Existing Tool Considered

No new tool. The change builds on the repeat guard of #4793 and its write-stop harness.

Acceptance Criteria

  • Unit tests: an upsert edits the comment; a second run posts nothing; a repeat is refused.
  • The write-stop harness passes for stage, refine and implement.
  • A structural test fails when a module other than steps/comment.py calls comment_on_issue or comment_on_pull.

Dependencies

Source: #5014

Alternatives check of 2026-11-15: not-applicable.
Class: refactor, no search.
Tool: none found.

Proposed design

Problem statement

Roadmap jobs post marked comments through 18 sites with five inconsistent rules. The change adds one writer in steps/comment.py that upserts by marker and key, reads the marker before each post, and uses the #4793 repeat guard. It moves every site in one pull request and checks stop replay for stage, refine and implement.

Acceptance criteria

Requirement: Shared marked-comment writer

The roadmap SHALL provide one marked-comment writer in steps/comment.py with post(target, marker, key, body).

Scenario: Writer updates an existing marked comment

  • WHEN A target already holds a comment with the marker and key.
  • THEN The writer edits that comment and adds no second comment.

Requirement: Marker read before post

The writer SHALL read the target's marked comments before it writes a comment.

Scenario: Read precedes write

  • WHEN The writer posts a marked comment to a target.
  • THEN The target records a comment list before the create or update call.

Requirement: Repeat guard refuses a repeat

The writer MUST rely on the #4793 store guard to refuse a repeated marked comment.

Scenario: Second run posts nothing

  • WHEN The same marker, key and body already exist on the target.
  • THEN The writer makes no comment write, and the store guard refuses the repeat.

Requirement: All comment sites use one writer

Every roadmap module that posts a marked comment SHALL call steps/comment.py, and no other module SHALL call comment_on_issue or comment_on_pull.

Scenario: Structural test rejects a direct caller

  • WHEN A module outside steps/comment.py calls comment_on_issue or comment_on_pull.
  • THEN The structural test fails.

Requirement: Stop replay leaves no extra comments

The stage, refine and implement jobs SHALL pass the stop-after-each-write harness with no extra comments.

Scenario: A stop after each write leaves no extra comment

  • WHEN stop_after_each_write runs each job.
  • THEN StopReplay.extra_comments() is empty for every stop.

Existing Tool Considered

No open, maintained tool or library covers this internal refactor. The alternatives check of 2026-11-15 gave not-applicable for the refactor class and made no search. The project builds steps/comment.py and migrates all comment sites for about 1M tokens and one agent-day.

Key questions

  • Should the shared writer live in one roadmap step module?: Yes. Put it in steps/comment.py and make every comment site call it. (best practice) [sources: CONTEXT.md, tests/support/write_stops.py]
    • Chosen: One shared writer in steps/comment.py. CONTEXT.md says a roadmap step is one module and every caller uses it.
    • Rejected: Keep per-job comment helpers. Five rules remain and the structural test cannot pass.
  • How should the writer update or create a marked comment?: Read the marked comments, find the key, and update that comment. If no key matches, create one comment. (best practice) [sources: CONTEXT.md, tests/support/write_stops.py]
    • Chosen: Read, then upsert by marker and key. It keeps one comment for each key and stops a second run from adding a comment.
    • Rejected: Create a new comment each run. Stop replay leaves extra comments.
    • Rejected: Edit the last comment by the bot. It can edit the wrong marker or a person's comment.
  • Must every comment site move in the same pull request?: Yes. Move every comment site in one pull request. (best practice) [sources: CONTEXT.md, tests/support/write_stops.py]
    • Chosen: Move every site in one pull request. A structural test can then forbid direct callers.
    • Rejected: Move one job at a time. Mixed rules remain and direct callers pass the structural test.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4793, #5020

Activity

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

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: refactor. The check makes no search and no model call for an item of this class.

    Tool: none found

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

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

    @devops-cli-service
    Contributor

    Status set to Ready at 181f85e (see proposed design in issue body).

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

    @devops-cli-service
    Contributor

    Live since 2026-11-16 18:27 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/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions