Skip to content

refactor(roadmap): One job-comment writer with a marker registry #6200

Open

Description

@dan-petty

Problem

Area 7 of the parent item; do it last, after #6194, #6195 and the other area items merge. Job comments are posted from many call sites, each with its own marker and repeat rules, so a new duplicate can come back.

  • steps/comment.py:130 post() reaches into private _write and _roadmap (:80-100). The Jev note (watch_row.py:277, stage_ready.py:130, :173) has neither marker nor key, so it always posts new. fix_checks.py:527 and :665 share the check-name key and write over each other.
  • comment_repeat.py:83 looks only at the trailing run of job comments, and skips PR targets.
  • CONST_ROADMAP_JOB_COMMENT_MARKERS (constants.py:4005) and COMMENT_JOBS (comment_repeat.py:50) leave out fix-checks, pr_conflicts, plan drift, release, the implement run marker and the AI review marker. A release comment on a reopened item and a plan-drift comment posted under a person's token read as a person's comment.

Expected behavior

  • One writer in the store, for example RoadmapStore.job_comment(target, JobComment), for issue and PR targets. It writes the job marker and an exact hidden key line; it matches the key exactly.
  • Two kinds: STATE (one comment per job and key, edited in place) and EVENT (a new comment only when its facts, hashed with sorted order, differ from the last event of that job and key). Keep the hash in the hidden key line of the comment, not in the job record (no extra body PATCH, no race with other record writers).
  • Key the implement stop and the stop-clear notes by Job (record implement.job), so a person's "implement: retry" is used once and a retry cannot loop (implement.py:260, stop_clear.py:279-285, :375).
  • The fingerprint guard stays as a last guard and covers PR targets.
  • One enum of comment jobs; derive both marker lists from it. Update every reader: item_comments.HeldComment.by_person, trust.is_person_comment, refine _comments_without, stage_rejected.reason_comment, retitle.py:262 _is_job_comment (so retitle never treats a person's rename as its own), repair.py:137 _unanswered.
  • An AST invariant in tests/invariants/test_architectural_invariants.py fails when src calls store.comment, comment_on_pull, create_issue_comment or update_issue_comment outside the writer (allow list: person commands only), and when a <!-- devops roadmap ... --> literal is not in the registry. Move every call site: release_comments.py:113, return_item.py:72, stop_clear.py:375, stage/plan_drift.py:220, :268, steps/review.py:475, steps/open.py:284, implement/implement_submit.py:358, github/pr_evidence.py:126-128, and the rest.
  • A writer test: the same EVENT facts in another order post once, and a person's comment in between does not let the same event post again.
  • The writer never drops or cuts text. A duplicate is a test failure, fixed in the builder at its source. Delete the dead code in stage_ready.py.

Source: #6193

regression of #5025

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

Proposed design

Problem statement

Job comments are posted from many call sites, each with its own marker and repeat rules. This lets duplicates return, lets two fix-check comments overwrite each other, and makes some job comments look like person comments. The change adds one store writer and one registry for job comments.

Acceptance criteria

Requirement: Single job-comment writer

RoadmapStore SHALL expose one job_comment method that writes a job comment for an issue target and for a pull request target.

Scenario: Issue and pull request targets use one writer

  • WHEN a test calls RoadmapStore.job_comment with an issue target and with a pull request target
  • THEN the fake store records both comments through the writer and each body ends with the hidden key line from the registry

Requirement: STATE edits in place

A STATE job comment SHALL edit the one comment of its job and key in place, and SHALL create one only when none exists.

Scenario: Second STATE post edits the first

  • WHEN a test posts a STATE job comment twice with the same job and key
  • THEN the store holds one comment and its body is the second body

Requirement: Jobs do not overwrite each other

A STATE job comment SHALL keep a comment for each job even when two jobs use the same check name.

Scenario: Two jobs with one check-name key keep two comments

  • WHEN a test posts STATE comments for two jobs with the same check-name key
  • THEN the store holds two comments

Requirement: EVENT uses sorted-facts hash

An EVENT job comment SHALL post only when the sorted-facts SHA-256 differs from the hash in the last event of its job and key.

Scenario: Reordered facts post once

  • WHEN a test posts an EVENT job comment with facts in one order and then with the same facts in another order
  • THEN the store holds one event comment

Requirement: Person comment does not reset EVENT

EVENT deduplication SHALL ignore comments by persons between two events of the same job and key.

Scenario: A person comment does not let the same event post again

  • WHEN a test posts an EVENT, adds a person comment, and posts the same EVENT facts again
  • THEN the store holds one event comment and one person comment

Requirement: Implement stop keyed by Job

The implement stop and stop-clear notes SHALL use the implement.job record value as the job key.

Scenario: A retry uses the same job key

  • WHEN a test runs a stop and then implement: retry with implement.job set
  • THEN the writer receives the same implement.job key for the stop note and the stop-clear note

Requirement: One comment-job enum

The comment-job enum SHALL be the only source of the job markers and COMMENT_JOBS, and SHALL list every comment job.

Scenario: Every named job has one marker and one repeat rule

  • WHEN a test builds the marker list and COMMENT_JOBS from the enum for fix-checks, pr-conflicts, plan drift, release, implement run, and AI review
  • THEN each named job has one marker and one repeat rule, and a release comment on a reopened item and a plan-drift comment under a person token are job comments

Requirement: Architectural invariant

The architectural invariant SHALL fail on a direct store comment call outside the writer and on a roadmap marker literal outside the registry.

Scenario: Direct comment calls and stray markers fail

  • WHEN the invariant runs on a fixture with a direct store.comment call and a &lt;!-- devops roadmap ... --> literal
  • THEN the invariant reports both violations

Requirement: Readers use the registry

Every reader of job comments SHALL classify comments by the registry enum, so a person's comment is never a job comment.

Scenario: A person comment with marker-like prose is not a job comment

  • WHEN a test gives each reader a person comment whose text contains a job marker in prose
  • THEN each reader classifies the comment as a person's comment

Requirement: Writer preserves text

The job-comment writer SHALL write the full body text and SHALL not truncate or drop text.

Scenario: Long body is preserved

  • WHEN a test posts a job comment whose body is longer than the old truncation limit
  • THEN the stored body equals the input body

Existing Tool Considered

The alternatives check in the issue body gives verdict not-applicable (class refactor, no search) and names no tool. The change builds its own writer. Written cost: about 80,000 tokens to build, 15,000 tokens per year to keep and fix, and 5 working days.

Key questions

  • Which component owns the job-comment write path?: Add RoadmapStore.job_comment(target, JobComment) and move every call site to it. The method writes the marker and the hidden key line, and it matches the key exactly. (best practice) [sources: src/devops_cli/roadmap/stores/comment_repeat.py:50, src/devops_cli/config/constants.py:4019, src/devops_cli/roadmap/steps/comment.py:130]
    • Chosen: Central store writer. One writer holds the marker, key and repeat rules for issue and pull request targets.
    • Rejected: Shared helper module. It still leaves many call sites and cannot enforce the store write path.
    • Rejected: Keep the current call sites. The issue shows that separate call sites let duplicates and overwrites return.
  • How does the writer deduplicate EVENT comments without a second record PATCH?: Store the SHA-256 of the facts in sorted order in the hidden key line of the last event comment. Read that line to compare. (best practice) [sources: src/devops_cli/roadmap/stores/comment_repeat.py:83, src/devops_cli/roadmap/stores/comment_repeat.py:50]
    • Chosen: Hidden key line. The comment holds its own hash, so no record writer races another one.
    • Rejected: Job record. It adds a body PATCH and races with other writers of the record.
    • Rejected: No deduplication. The issue needs EVENT comments to post only when their facts differ.
  • Which key do the implement stop and stop-clear notes use?: Use the implement.job record value as the key. A person's implement: retry is used once, and a retry cannot loop. (best practice) [sources: src/devops_cli/roadmap/implement/implement.py:260]
    • Chosen: implement.job record value. It ties the note to one implement Job and makes a retry use the note once.
    • Rejected: Issue number. It does not separate two implement Jobs for the same item.
    • Rejected: Comment text. It is not an exact key and can match a person's text.
  • How does the project keep direct job-comment calls and stray markers out of the source?: Add an AST invariant in tests/invariants/test_architectural_invariants.py. It fails on direct store comment calls outside the writer and on roadmap marker literals outside the registry. (best practice) [sources: tests/invariants/test_architectural_invariants.py, src/devops_cli/roadmap/retitle.py:262, src/devops_cli/roadmap/refine/refine.py:2127]
    • Chosen: AST invariant. It reads the source and fails the build at the call site or the literal.
    • Rejected: Code review only. A person can miss a new direct call or a copied marker.
    • Rejected: Runtime check. It runs after the write and cannot stop the bad call from landing.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#6194, #6195

Activity

  1. added
    type/refactor
    source/agent
    scope/roadmap
    status/new
    value/medium
    effort/high
    on Nov 17, 2026
  2. added
    priority/p2-medium
    on Nov 17, 2026
  3. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 4624bc7 (see proposed design in issue body).

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/highpriority/p2-mediumscope/roadmapsource/agentstatus/readytype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions