Skip to content

refactor: split LLM workflow update comment assembly - #2608

Merged
stranske merged 1 commit into
mainfrom
orchestrator/issue-2605
Jun 28, 2026
Merged

stranske merged 1 commit into
mainfrom
orchestrator/issue-2605

Conversation

@stranske

@stranske stranske commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Source: Issue #2605

Closes #2605

Automated Status Summary

Scope

Refactor scripts/generate_llm_workflow_update_comment.py comment assembly into small pure-helper paths while preserving output text.

Tasks

  • Preserve build_comment() output for required inputs and optional notes.
  • Add tests in tests/scripts/test_generate_llm_workflow_update_comment.py for empty notes, multiline notes, and repository/workflow names containing Markdown-sensitive characters.
  • Keep behavior deterministic and dependency-free.

Acceptance criteria

  • pytest tests/scripts/test_generate_llm_workflow_update_comment.py -q passes.
  • Existing comment text remains compatible for covered cases.
  • Refactor stays file-local and does not alter workflow YAML.

Head SHA: b743379
Latest Runs: ✅ success — Gate
Required: gate: ✅ success

Workflow / Job Result Logs
Gate ✅ success View run
Health 40 Sweep ❔ startup failure View run
Health 44 Gate Branch Protection ❔ in progress View run
Health 45 Agents Guard ✅ success View run
Health 50 Security Scan ❔ in progress View run
Health 52 Semgrep Scan ✅ success View run
Maint 52 Validate Workflows ✅ success View run
PR 11 - Minimal invariant CI ✅ success View run
Selftest CI ✅ success View run

Summary by CodeRabbit

  • New Features

    • Added support for including optional notes in generated workflow update comments.
    • Improved comment formatting so Markdown-sensitive characters are handled safely.
  • Bug Fixes

    • Fixed rendering issues in generated comments when workflow paths or notes contain special characters.
    • Preserved the existing comment output when notes are not provided.
  • Tests

    • Expanded test coverage for comment building, notes formatting, and character escaping.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

scripts/generate_llm_workflow_update_comment.py is refactored into modular helper functions (_escape_markdown, _build_label_line, _build_main_body, _build_workflows_section, _build_notes_section). build_comment gains an optional notes parameter; the CLI gains --notes. Tests are added for all helpers and build_comment integration.

Changes

Comment Assembly Refactor and Notes Support

Layer / File(s) Summary
Markdown escaping and section builder helpers
scripts/generate_llm_workflow_update_comment.py
Adds _escape_markdown, _build_label_line, _build_main_body, _build_workflows_section, and _build_notes_section; rewrites build_comment to assemble output from these components and accept notes: str | None = None.
CLI --notes wiring
scripts/generate_llm_workflow_update_comment.py
Adds --notes argument to the CLI parser and passes notes=args.notes into build_comment.
Unit and integration tests
tests/scripts/test_generate_llm_workflow_update_comment.py
Imports internal helpers and adds tests for _escape_markdown, each section builder, build_comment with absent/empty/multiline notes, Markdown escaping of workflow paths, and a combined label+notes+workflow integration test.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

agent:codex

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: refactoring the LLM workflow update comment assembly.
Linked Issues check ✅ Passed The refactor adds pure helpers, optional notes, and tests for empty/multiline notes and markdown escaping, matching #2605.
Out of Scope Changes check ✅ Passed Changes stay within the comment-generation script and its tests, with no workflow YAML, API, or bot-behavior changes.
Docstring Coverage ✅ Passed Docstring coverage is 85.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch orchestrator/issue-2605

Comment @coderabbitai help to get the list of available commands.

@stranske
stranske temporarily deployed to agent-standard June 28, 2026 02:27 — with GitHub Actions Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/generate_llm_workflow_update_comment.py`:
- Around line 16-44: The markdown escaping in _escape_markdown is incomplete for
notes and paths, so text can still render as code, headings, or list items.
Update _escape_markdown and the note emission flow in
generate_llm_workflow_update_comment to neutralize backticks and other
block-triggering markdown characters, and make sure the note lines built around
the referenced workflow/comment rendering path are fully escaped before output.
Verify the new “markdown-safe notes/workflow text” handling covers inputs like
backticks, headings, bullets, and numbered lists.

In `@tests/scripts/test_generate_llm_workflow_update_comment.py`:
- Around line 40-52: The test for build_comment(include_label=True) is too loose
and can miss unintended wording or spacing changes. Update
test_build_comment_preserves_output_without_notes in
test_generate_llm_workflow_update_comment.py to assert the entire legacy comment
string exactly, using build_comment as the target behavior, instead of checking
only a few substrings like “Workflow updates required” and “Affected
workflows:”.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 509635cb-66ed-4acd-a2db-8e7e0935034e

📥 Commits

Reviewing files that changed from the base of the PR and between 101a210 and 8e96612.

📒 Files selected for processing (2)
  • scripts/generate_llm_workflow_update_comment.py
  • tests/scripts/test_generate_llm_workflow_update_comment.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • stranske/Template (auto-detected)
  • stranske/Fine-Art-Archive (auto-detected)
  • stranske/Ready (auto-detected)
  • stranske/Workflows-Integration-Tests (auto-detected)

Comment thread scripts/generate_llm_workflow_update_comment.py
Comment on lines +40 to +52
def test_build_comment_preserves_output_without_notes() -> None:
"""Verify backward compatibility: output unchanged when notes not provided."""
comment = build_comment(include_label=True)

# Verify structure is preserved
lines = comment.split("\n")
assert lines[0] == "Label: needs-human"
assert "Workflow updates required" in comment
assert "Affected workflows:" in comment
assert "- .github/workflows/agents-auto-pilot.yml" in comment
assert "- .github/workflows/reusable-agents-verifier.yml" in comment
# Verify no notes section is added
assert "Notes:" not in comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Assert the full legacy string here.

This test only checks a few substrings, so spacing or wording drift in build_comment(include_label=True) would still pass even though the PR objective is to preserve the pre-refactor comment text unchanged. Compare against the exact expected string instead of partial contains checks.

Suggested tightening
 def test_build_comment_preserves_output_without_notes() -> None:
     """Verify backward compatibility: output unchanged when notes not provided."""
     comment = build_comment(include_label=True)
-
-    # Verify structure is preserved
-    lines = comment.split("\n")
-    assert lines[0] == "Label: needs-human"
-    assert "Workflow updates required" in comment
-    assert "Affected workflows:" in comment
-    assert "- .github/workflows/agents-auto-pilot.yml" in comment
-    assert "- .github/workflows/reusable-agents-verifier.yml" in comment
-    # Verify no notes section is added
-    assert "Notes:" not in comment
+    expected = "\n".join(
+        [
+            "Label: needs-human",
+            "Workflow updates required in .github/workflows/agents-auto-pilot.yml and "
+            ".github/workflows/reusable-agents-verifier.yml. Add pinned installs "
+            "(`pip install -r tools/requirements-llm.txt` and "
+            "`pip install -r .workflows-lib/tools/requirements-llm.txt` for evaluate/compare), "
+            "add actions/cache@v4 pip cache keyed by requirements hash + Python version, "
+            "and remove any floating `pip install langchain*` lines. Workflow edits require "
+            "agent-high-privilege.",
+            "",
+            "Affected workflows:",
+            "- .github/workflows/agents-auto-pilot.yml",
+            "- .github/workflows/reusable-agents-verifier.yml",
+        ]
+    )
+    assert comment == expected
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_build_comment_preserves_output_without_notes() -> None:
"""Verify backward compatibility: output unchanged when notes not provided."""
comment = build_comment(include_label=True)
# Verify structure is preserved
lines = comment.split("\n")
assert lines[0] == "Label: needs-human"
assert "Workflow updates required" in comment
assert "Affected workflows:" in comment
assert "- .github/workflows/agents-auto-pilot.yml" in comment
assert "- .github/workflows/reusable-agents-verifier.yml" in comment
# Verify no notes section is added
assert "Notes:" not in comment
def test_build_comment_preserves_output_without_notes() -> None:
"""Verify backward compatibility: output unchanged when notes not provided."""
comment = build_comment(include_label=True)
expected = "\n".join(
[
"Label: needs-human",
"Workflow updates required in .github/workflows/agents-auto-pilot.yml and "
".github/workflows/reusable-agents-verifier.yml. Add pinned installs "
"(`pip install -r tools/requirements-llm.txt` and "
"`pip install -r .workflows-lib/tools/requirements-llm.txt` for evaluate/compare), "
"add actions/cache@v4 pip cache keyed by requirements hash + Python version, "
"and remove any floating `pip install langchain*` lines. Workflow edits require "
"agent-high-privilege.",
"",
"Affected workflows:",
"- .github/workflows/agents-auto-pilot.yml",
"- .github/workflows/reusable-agents-verifier.yml",
]
)
assert comment == expected
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/scripts/test_generate_llm_workflow_update_comment.py` around lines 40 -
52, The test for build_comment(include_label=True) is too loose and can miss
unintended wording or spacing changes. Update
test_build_comment_preserves_output_without_notes in
test_generate_llm_workflow_update_comment.py to assert the entire legacy comment
string exactly, using build_comment as the target behavior, instead of checking
only a few substrings like “Workflow updates required” and “Affected
workflows:”.

@stranske-keepalive

stranske-keepalive Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 132466e
Latest Runs: ⏳ pending — Gate
Required contexts: Gate / gate, Health 45 Agents Guard / guard
Required: core tests (3.12): ⏳ pending, core tests (3.13): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 1

Coverage Trend

Metric Value
Current 71.69%
Baseline 85.00%
Delta -13.31%
Minimum 70.00%
Status ✅ Pass

Top Coverage Hotspots (lowest coverage)

File Coverage Missing
scripts/cleanup_labels.py 0.0% 127
scripts/issue_dedup_smoke.py 0.0% 4
scripts/repo_review_backlog_scan.py 0.0% 203
scripts/repo_review_round1_runner.py 0.0% 225
scripts/repo_review_round1_schema.py 0.0% 194
scripts/runner_lib/__main__.py 0.0% 3
scripts/update_langchain_versions.py 0.0% 34
scripts/validate_dependency_test_setup.py 0.0% 112
scripts/validate_template_sync.py 0.0% 77
scripts/repo_review_round2_schema.py 8.8% 185
scripts/langchain/topic_splitter.py 19.1% 57
tools/codex_log_analyzer.py 19.6% 140
scripts/repo_review_round2_runner.py 25.1% 344
scripts/validate_template_completeness.py 38.1% 53
scripts/prune_agent_stubs.py 39.7% 26

Low Coverage Files (<50.0%)

File Coverage Missing
scripts/cleanup_labels.py 0.0% 127
scripts/issue_dedup_smoke.py 0.0% 4
scripts/repo_review_backlog_scan.py 0.0% 203
scripts/repo_review_round1_runner.py 0.0% 225
scripts/repo_review_round1_schema.py 0.0% 194
scripts/runner_lib/__main__.py 0.0% 3
scripts/update_langchain_versions.py 0.0% 34
scripts/validate_dependency_test_setup.py 0.0% 112
scripts/validate_template_sync.py 0.0% 77
scripts/repo_review_round2_schema.py 8.8% 185
scripts/langchain/topic_splitter.py 19.1% 57
tools/codex_log_analyzer.py 19.6% 140
scripts/repo_review_round2_runner.py 25.1% 344
scripts/validate_template_completeness.py 38.1% 53
scripts/prune_agent_stubs.py 39.7% 26

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

Refactor scripts/generate_llm_workflow_update_comment.py comment assembly into small pure-helper paths while preserving output text.

Tasks

  • Preserve build_comment() output for required inputs and optional notes.
  • Add tests in tests/scripts/test_generate_llm_workflow_update_comment.py for empty notes, multiline notes, and repository/workflow names containing Markdown-sensitive characters.
  • Keep behavior deterministic and dependency-free.

Acceptance criteria

  • pytest tests/scripts/test_generate_llm_workflow_update_comment.py -q passes.
  • Existing comment text remains compatible for covered cases.
  • Refactor stays file-local and does not alter workflow YAML.

- Split build_comment() into small pure helper functions:
  - _escape_markdown(): Escape markdown-sensitive characters
  - _build_label_line(): Build optional label line
  - _build_main_body(): Build main instruction text
  - _build_workflows_section(): Build affected workflows list
  - _build_notes_section(): Build optional notes section
- Add notes parameter to build_comment() for optional notes
- Escape markdown-sensitive characters in workflow paths and notes
- Add comprehensive tests for:
  - Empty and multiline notes
  - Markdown-sensitive characters in repo/workflow names
  - All helper functions
  - Backward compatibility

Validation: pytest tests/scripts/test_generate_llm_workflow_update_comment.py -q
Result: 13 passed in 0.05s

Closes #2605

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@stranske
stranske force-pushed the orchestrator/issue-2605 branch from 8e96612 to b743379 Compare June 28, 2026 02:30
@stranske

stranske commented Jun 28, 2026

Copy link
Copy Markdown
Owner Author

Runner dispatch state for autofix on PR #2608. Do not edit.

@stranske
stranske temporarily deployed to agent-standard June 28, 2026 02:31 — with GitHub Actions Inactive
@stranske
stranske merged commit 85a6010 into main Jun 28, 2026
66 of 67 checks passed
@stranske
stranske deleted the orchestrator/issue-2605 branch June 28, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Route Weight][codemod] Refactor LLM workflow update comment assembly

1 participant