Skip to content

feat(workflows): unify bot reply format and harden research/resolve guards - #91

Merged
chrisleekr merged 2 commits into
mainfrom
chore/bot-replies-and-research-fixes
May 2, 2026
Merged

feat(workflows): unify bot reply format and harden research/resolve guards#91
chrisleekr merged 2 commits into
mainfrom
chore/bot-replies-and-research-fixes

Conversation

@chrisleekr

@chrisleekr chrisleekr commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary

Two related improvements bundled across the bot's review/comment surfaces:

  1. Unified reply format. All four bot output surfaces — review (inline findings), resolve (thread replies), bot:fix-thread, bot:explain-thread — now emit the same CodeRabbit-style three-block layout: a status line, a bold one-line title, then 1–3 sentences of reasoning. Severity/classification is encoded in the status line (_⚠️ Potential issue_ | _🔴 Blocker_, _✅ Addressed_, _💬 Design discussion_, etc.), and a small formatReply() helper in fix-thread.ts keeps handler-emitted replies consistent with what the LLM agent prompts demand.
  2. Resolve workflow waits for green CI. The resolve handler prompt now explicitly requires the agent to (a) mark threads resolved via the resolve-review-thread MCP tool after replying to Valid / Partially Valid threads, and (b) poll gh pr checks after its final commit until all checks reach a terminal non-failure state, capped at FIX_ATTEMPTS_CAP=3 per iteration. Surviving failures are recorded under ## Outstanding in RESOLVE.md.
  3. Research workflow hardening. Pre-installs @mermaid-js/mermaid-cli and adds a hard validation gate (Step 4.5) so every Mermaid block in the issue body must validate via mmdc before gh issue create runs — closes the failure mode from issue test(coverage): per-file Bun isolation overwrites coverage/lcov.info on every invocation, eliminating aggregate coverage signal #86. Also explicitly forbids test/smoke/placeholder issues (titles containing test, smoke, wip, todo, etc., or empty bodies) — closes the failure mode from issue test-can-delete #73.

Diagram

flowchart TD
    classDef before fill:#fde68a;color:#1f2937;stroke:#92400e;stroke-width:2px
    classDef after  fill:#bbf7d0;color:#064e3b;stroke:#065f46;stroke-width:2px

    Reviewer[Reviewer comment] --> BeforeReply["BEFORE<br/>severity tag in body<br/>e.g. major description<br/>thread NOT auto-resolved<br/>handlers and agents diverge"]:::before
    Reviewer --> AfterReply["AFTER<br/>3-block CR-style reply<br/>status line + bold title + reasoning<br/>thread resolved via MCP<br/>handlers and agents share format"]:::after

    ResolveStart[Resolve run starts] --> BeforeCI["BEFORE<br/>fix then push then exit<br/>CI may still be red on exit"]:::before
    ResolveStart --> AfterCI["AFTER<br/>fix then push then poll checks<br/>exit only when green or cap=3 hit<br/>survivors logged in RESOLVE.md"]:::after

    ResearchStart[Research workflow starts] --> BeforeMermaid["BEFORE<br/>prompt-only Mermaid rules<br/>invalid blocks ship as parse errors<br/>see issue #86"]:::before
    ResearchStart --> AfterMermaid["AFTER<br/>mermaid-cli pre-installed<br/>each block validated via mmdc<br/>discard issue if 3 attempts fail"]:::after
Loading

Changes

  • src/workflows/ship/scoped/fix-thread.ts — add formatReply() helper; rewrite all four reply paths (applied, design-discussion refusal, two skip paths) to use the unified 3-block layout; add optional reasoning field on ApplyMechanicalFixResult so callers can surface the why without the reviewer opening the commit.
  • src/workflows/ship/scoped/explain-thread.ts — rewrite EXPLAIN_THREAD_SYSTEM_PROMPT to require the same 3-block layout (_💡 Explanation_ status line, bold summary, prose body).
  • src/workflows/handlers/review.ts — replace the [blocker] / [major] / [minor] / [nit] body convention with the CR-style status line + suggested-fix block; keep the bracketed tags in REVIEW.md so the countFindings parser still works.
  • src/workflows/handlers/resolve.ts — split the per-classification reply guidance into four explicit cases; add the mandatory reply-body template; add the new "wait for CI to be green before exiting" step with FIX_ATTEMPTS_CAP=3 semantics; update RESOLVE.md template to include final post-fix CI state and per-thread resolution status.
  • test/workflows/ship/scoped/fix-thread.test.ts — assert the new status lines and bold titles in each reply path, and add a new test covering the generic-reasoning fallback when the callback omits reasoning.
  • docs/use/workflows/resolve.md — document the unified reply-body format, the per-classification status-line table, the thread-resolution behaviour, and the new wait-for-green step.
  • docs/use/workflows/review.md — replace the severity-prefix table with the new dual-column table that covers both inline-comment status lines and REVIEW.md tags; explain why both are required.
  • .github/workflows/research.yml — install @mermaid-js/mermaid-cli; add Step 4.5 (Mermaid validation gate) with retry-up-to-3 semantics and discard-on-final-failure; expand the forbidden-issues rules with the explicit blocklist of placeholder titles and the empty-body floor; widen --allowedTools to include mmdc, awk, grep for the validation step.

Related Issues

Test plan

  • bun test test/workflows/ship/scoped/fix-thread.test.ts
  • CI green on the PR
  • Manual smoke: trigger a resolve run on a stale-CI PR and confirm it polls until green and resolves Valid threads
  • Manual smoke: workflow_dispatch the research workflow with a focus that historically produced a Mermaid diagram and confirm the validation gate runs

Summary by CodeRabbit

Release Notes

  • New Features

    • Added automatic validation of diagram syntax in automated workflows, with retry handling for parse failures.
    • Enhanced review comments with consistent, CodeRabbit-style formatting including status indicators and clearer messaging.
    • Improved resolve workflow with explicit thread classification and better CI status handling.
  • Documentation

    • Updated review and resolve workflow documentation with detailed step-by-step instructions and formatting specifications.
  • Tests

    • Expanded test coverage for fix application reply formatting and status line assertions.

- All bot reply surfaces (review/resolve/fix-thread/explain-thread) now
  emit the same CodeRabbit-style 3-block layout: status line, bold one-
  line title, prose reasoning. New formatReply() helper in fix-thread.ts
  keeps handler-emitted output consistent with what the LLM agent prompts
  demand.
- Resolve handler now requires the agent to mark threads resolved via
  the resolve-review-thread MCP tool after replying to Valid / Partially
  Valid threads, and to poll gh pr checks until all checks reach a
  terminal non-failure state (FIX_ATTEMPTS_CAP=3 per iteration). Survivors
  are recorded under ## Outstanding in RESOLVE.md.
- Research workflow pre-installs @mermaid-js/mermaid-cli and adds a hard
  validation gate (Step 4.5) so every Mermaid block must validate via
  mmdc before gh issue create runs (closes #86). Forbidden-issue rules
  expanded with explicit blocklist of placeholder titles and an empty-
  body floor (closes #73).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 2, 2026 04:07
@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@chrisleekr has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 14 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bb5fb72f-e4ae-4405-921b-276080ec3e88

📥 Commits

Reviewing files that changed from the base of the PR and between 9326742 and 72d38cf.

📒 Files selected for processing (7)
  • .github/workflows/research.yml
  • docs/use/workflows/resolve.md
  • src/workflows/format-reply.ts
  • src/workflows/handlers/resolve.ts
  • src/workflows/handlers/review.ts
  • src/workflows/ship/scoped/explain-thread.ts
  • src/workflows/ship/scoped/fix-thread.ts
📝 Walkthrough

Walkthrough

The PR standardizes output formatting across multiple bot workflows by enforcing a consistent three-block Markdown structure (status line, bold title, reasoning) for replies and inline comments, updating handler prompts to specify exact formatting requirements, adding Mermaid diagram validation to the research workflow, and extending test assertions to verify the new formats are present.

Changes

Standardized Bot Output Formatting

Layer / File(s) Summary
Format Specifications
docs/use/workflows/resolve.md, docs/use/workflows/review.md
Documents standardized three-block reply format with status-line emojis, bold one-line titles, reasoning prose, and mappings between classification types and resolution behavior. Resolve workflow adds explicit control flow for CI polling, retry logic, and outstanding-failures tracking.
LLM Prompt Instructions
src/workflows/handlers/resolve.ts, src/workflows/handlers/review.ts, src/workflows/ship/scoped/explain-thread.ts
Updates agent prompts to enforce CodeRabbit-style markdown format with exact status lines (e.g., _✅ Fix applied_), required section structure, severity taxonomy, and validation requirements. Resolve handler adds instruction to use resolve-review-thread MCP tool for valid/partially-valid threads and defines CI retry/poll behavior within FIX_ATTEMPTS_CAP=3.
Handler Implementation
src/workflows/ship/scoped/fix-thread.ts
Adds optional reasoning field to ApplyMechanicalFixResult. Implements new formatReply helper that constructs standardized reply blocks with status, optional metadata, title, and trimmed reasoning text. Routes design-discussion refusals, skipped cases, and successful fixes through the formatter.
Research Workflow Validation
.github/workflows/research.yml
Adds Mermaid CLI installation step, updates Claude Code tool allowlist to include Bash(mmdc:*), and inserts a hard-gate validation step ("Step 4.5") that writes each mermaid block to /tmp/diag-N.mmd, runs mmdc with retry logic, discards the issue on diagram failures, and gates gh issue create until all blocks validate.
Test Verification
test/workflows/ship/scoped/fix-thread.test.ts
Extends assertions to verify reply bodies include emoji-labelled status lines (e.g., _✅ Fix applied_, _⏭️ Skipped_, _💬 Design discussion_), formatted titles (e.g., **Mechanical fix pushed.**), and exact reasoning text matching expected phrasing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Modifications to .github/workflows/research.yml and prompt/tool configuration for issue creation validation (Mermaid diagram enforcement)
  • Updates to src/workflows/handlers/review.ts and resolve.ts prompts and output formatting specifications (severity taxonomy and resolution behavior)
  • Changes to src/workflows/ship/scoped/fix-thread.ts and related handler logic for standardized reply formatting across mechanical-fix workflows

Suggested labels

type: feature ✨, type: docs 📋, bot:resolve, bot:review, bot:research

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: unifying bot reply format across multiple handlers and hardening research/resolve workflows with new guards and validations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 46 minutes and 14 seconds.

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

Copilot AI 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.

Pull request overview

Unifies the bot’s reply formatting across review/resolve and scoped thread commands, and tightens resolve + research workflow guards (CI wait-for-green, Mermaid validation, and placeholder-issue prevention).

Changes:

  • Standardize bot replies to a CodeRabbit-style 3-block format (status line → bold title → reasoning) across prompts and fix-thread.
  • Extend resolve agent instructions to resolve Valid/Partially Valid threads via MCP and to poll gh pr checks until CI is green (with a per-iteration attempts cap).
  • Harden the scheduled research workflow by installing @mermaid-js/mermaid-cli, adding a mandatory Mermaid validation gate, and forbidding placeholder issues.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/workflows/ship/scoped/fix-thread.ts Adds formatReply() helper and updates reply bodies; introduces optional reasoning in results.
test/workflows/ship/scoped/fix-thread.test.ts Updates assertions for the new reply format and adds fallback-reasoning coverage.
src/workflows/ship/scoped/explain-thread.ts Updates system prompt to require the unified 3-block reply layout.
src/workflows/handlers/review.ts Updates the review agent prompt to require the unified inline-comment layout and status lines.
src/workflows/handlers/resolve.ts Updates resolve agent prompt: explicit per-class behavior, mandatory reply template, and CI wait-for-green step.
docs/use/workflows/review.md Documents the new inline status lines alongside existing REVIEW.md severity tags.
docs/use/workflows/resolve.md Documents unified reply format, thread resolution behavior, and CI polling requirement.
.github/workflows/research.yml Installs mermaid-cli, adds Mermaid validation gate instructions, and expands placeholder-issue forbiddance + allowed tools.

Comment thread docs/use/workflows/resolve.md Outdated
Comment thread src/workflows/handlers/review.ts Outdated
Comment thread src/workflows/handlers/resolve.ts Outdated
Comment thread src/workflows/ship/scoped/fix-thread.ts Outdated

@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: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/research.yml:
- Around line 349-354: The blacklist currently forbids any title containing the
literal word "test", which conflicts with the allowed test(...) type and
examples like "test(webhook): ..."; update the banned-title rule so it only
blocks standalone or single-word titles containing test (e.g., "test",
"test-can-delete") but explicitly permits conventional-commit style type
prefixes such as "test(...):" (e.g., "test(webhook): ...") and adjust the
example or wording to mention the allowed "test(...)" format to remove the
contradiction.
- Around line 64-67: Update the GitHub Actions step that installs the Mermaid
CLI to pin the package to a stable release instead of grabbing latest; change
the npm install invocation for the package symbol "@mermaid-js/mermaid-cli" to
include a specific version (e.g., `@mermaid-js/mermaid-cli`@11.14.0) so subsequent
runs use a reproducible CLI, and keep the verification step that calls "mmdc
--version" to confirm the pinned version is installed.

In `@src/workflows/handlers/resolve.ts`:
- Around line 272-288: The handler currently treats any successful runPipeline()
as an overall success even when post-fix CI still shows failing checks; change
the finalization logic in this file to re-query GitHub checks after the agent
finishes fixes (use the same gh/octokit check routine used in the CI polling
loop), evaluate terminal conclusions against the "all-green" definition, and
only set/return status: "succeeded" when checks are all-green, all comments
resolved, and reviewDecision is APPROVED; if FIX_ATTEMPTS_CAP is reached with
remaining failures, ensure RESOLVE.md has an "Outstanding" section and
set/return a non-success status (e.g., "failed" or "incomplete") and post that
state via update_claude_comment so downstream workflows see the true post-fix CI
result (update references to runPipeline, update_claude_comment, and RESOLVE.md
in the finalization block).

In `@src/workflows/handlers/review.ts`:
- Around line 258-277: The guidance incorrectly states the emoji STATUS_LINE
strings drive REVIEW.md severity counts but the parser function countFindings()
actually looks for bracketed tags ([blocker]/[major]/[minor]/[nit]), so update
the text around the STATUS_LINE example to explicitly say that REVIEW.md must
include bracketed severity tags (and show the bracketed example) and remove or
correct the claim that the emoji lines drive counting; ensure references to
findings.total and countFindings() are consistent with this change so authors
can't rely on emojis alone.

In `@src/workflows/ship/scoped/explain-thread.ts`:
- Around line 19-33: The template example in explain-thread.ts contains a
two-space indentation before the sample layout which causes the header to become
" _💡 Explanation_" instead of the exact required "_💡 Explanation_"; locate the
prompt/template string (the constant or variable that holds the three-block
layout sample used by the explain thread generator) and remove the leading
spaces so the first line is exactly "_💡 Explanation_" with no extra characters,
ensure the blank second and fourth lines remain, and keep the bold one-sentence
third line format and the bulleted/body formatting unchanged.

In `@src/workflows/ship/scoped/fix-thread.ts`:
- Around line 181-199: Extract the file-local formatReply function into a shared
exported helper (keep the same signature: status, meta?, title, reasoning) and
import it from that single module wherever formatting is needed; replace the
duplicated formatter logic in the explain-thread, review handler, and resolve
handler code paths with calls to the shared formatReply function so all reply
surfaces (including buildResolvePrompt/buildReviewPrompt consumers) use the same
implementation and stay in sync.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e41dae56-336a-47ad-8260-0630ea9ee78c

📥 Commits

Reviewing files that changed from the base of the PR and between 641f138 and 9326742.

📒 Files selected for processing (8)
  • .github/workflows/research.yml
  • docs/use/workflows/resolve.md
  • docs/use/workflows/review.md
  • src/workflows/handlers/resolve.ts
  • src/workflows/handlers/review.ts
  • src/workflows/ship/scoped/explain-thread.ts
  • src/workflows/ship/scoped/fix-thread.ts
  • test/workflows/ship/scoped/fix-thread.test.ts

Comment thread .github/workflows/research.yml
Comment thread .github/workflows/research.yml
Comment thread src/workflows/handlers/resolve.ts
Comment thread src/workflows/handlers/review.ts Outdated
Comment thread src/workflows/ship/scoped/explain-thread.ts Outdated
Comment thread src/workflows/ship/scoped/fix-thread.ts Outdated
- Pin @mermaid-js/mermaid-cli to 11.14.0 in research.yml so the
  Mermaid validation gate behaves reproducibly across runs.
- Tighten the placeholder-issue blocklist so legitimate conventional-
  commit test(<scope>): ... titles are no longer banned alongside
  actual placeholders like "smoke test" / "test-can-delete".
- Clarify in review.ts that STATUS_LINE strings drive inline-comment
  presentation only; REVIEW.md severity counts come from the
  bracketed [blocker]/[major]/[minor]/[nit] tags (one source of
  truth, no contradictory guidance).
- Align resolve.ts step 3 wording with the FIX_ATTEMPTS_CAP=3 cap
  in step 6 — total fix attempts across both steps share the same
  cap; remove the contradictory "do NOT retry more than once".
- Remove leading 2-space indent from the explain-thread template
  example so the model doesn't mirror it into a contract-violating
  " _💡 Explanation_" header.
- Extract formatReply() to src/workflows/format-reply.ts so future
  reply surfaces import the helper instead of duplicating it.
- Hoist the redundant trim() chain in fix-thread.ts into a single
  trimmedReasoning local.
- Fix British "summarising" -> American "summarizing" in resolve.md
  to match the resolve.ts handler prompt.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chrisleekr
chrisleekr merged commit 7d39fb4 into main May 2, 2026
9 checks passed
@chrisleekr
chrisleekr deleted the chore/bot-replies-and-research-fixes branch May 2, 2026 04:41
chrisleekr pushed a commit that referenced this pull request May 2, 2026
# [1.8.0](v1.7.0...v1.8.0) (2026-05-02)

### Bug Fixes

* **logger:** redact paths and scrub err.* before pino emits (closes [#52](#52)) ([#89](#89)) ([641f138](641f138))
* **security:** redact raw error messages from public PR comments ([#90](#90)) ([cc70949](cc70949))

### Features

* **workflows:** unify bot reply format and harden research/resolve guards ([#91](#91)) ([7d39fb4](7d39fb4))
@chrisleekr

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(coverage): per-file Bun isolation overwrites coverage/lcov.info on every invocation, eliminating aggregate coverage signal test-can-delete

2 participants