Skip to content

feat: upgrade review template — YAML frontmatter, emoji badges, pipe tables - #18

Merged
WillIsback merged 12 commits into
mainfrom
feat/review-template-upgrade
May 14, 2026
Merged

WillIsback merged 12 commits into
mainfrom
feat/review-template-upgrade

Conversation

@WillIsback

Copy link
Copy Markdown
Owner

Summary

Closes #17

  • YAML frontmatter — every review now starts with a machine-readable block: findings (counts per severity), top_files (up to 3 most-affected files), risk_score (highest severity present)
  • Proper Markdown tables — pipe-syntax tables (| # | Location | Issue |) that render correctly on GitHub instead of plain text
  • Emoji severity badges — 🔴 Critical · 🟠 High · 🟡 Medium · 🟢 Low in every table row
  • Improved prompts — system prompts are now role-focused; full format specification lives in the user message as a few-shot template example
  • Removed Rust wrapper — LLM output is now self-contained; no duplicate header/footer added by Rust code
  • Extracted SUMMARIZE_USER_TEMPLATE — summarize path prompt extracted to named constant, enabling full test coverage

Files changed

File Change
crates/code-review-cli/src/review.rs All prompt constants, wrapper removal, 7 new/updated tests

Test plan

  • cargo test --workspace — 19 tests passing, 0 failures
  • Manually trigger the action on a PR and verify the posted comment renders with proper tables and emoji in the GitHub UI
  • Verify YAML frontmatter block is present at the top of the comment

Generated with Claude Code

WillIsback added 12 commits May 14, 2026 16:17
Forks cannot trigger the ai-code-review job on the self-hosted runner.
Condition: github.event.pull_request.head.repo.full_name == github.repository
- actions/checkout → 11bd719 (v4.2.2)
- dtolnay/rust-toolchain → 29eef33 (stable branch HEAD, toolchain: 1.87.0)
- softprops/action-gh-release → c95fe14 (v2.2.1)
- Rust toolchain pinned to 1.87.0 for reproducible builds

Also changes release trigger from push.branches[main] to push.tags[v*.*.*]
so releases only publish on explicit version tags.
- Pin cross to v0.2.5 to avoid unpinned HEAD in release pipeline
- Escape dots in SemVer tag pattern (glob wildcard fix)
- Add permissions: read-all at workflow level in ci.yml
Tests assert YAML frontmatter, emoji severity badges, and pipe table
syntax — all currently failing. Implementation follows in next commit.
…tables

- System prompts: role-focused, format instructions moved to user prompts
- SINGLE_ROUND_USER_TEMPLATE: full format spec with YAML frontmatter,
  pipe-syntax Markdown tables, emoji severity badges (🔴🟠🟡🟢)
- SUMMARIZE_SYSTEM_PROMPT: same role-focused prompt as single-round
- Summarization user message: full format spec with deduplication rule
- chunk_user_prompt: clarified bullet format with severity labels
- summarize_prompt_contains_both_sections → summarize_system_prompt_is_role_focused
  (SUMMARIZE_SYSTEM_PROMPT is now a short role prompt, not a format spec)
- single_round_prompt_contains_both_sections: updated heading level and sort wording
  to match new template (### with emoji, 'Sort rows: Critical first')
The LLM template now includes its own '## 🔍 AI Code Review' header
and attribution footer. Remove the Rust-side format wrapper to avoid
duplicating these elements in the posted GitHub comment.
Extract SUMMARIZE_USER_TEMPLATE const from inline format string in
summarize_review, enabling unit tests for the multi-file review path.
Add 3 tests: YAML frontmatter, emoji badges, deduplication rule.
cargo-audit v0.22.1 dependencies (home, smol_str, time) require Rust 1.88+.
--locked pins to versions compatible with our toolchain (1.87.0).
time 0.3.47, time-core 0.1.8, and time-macros 0.2.27 require Rust 1.88.0.
Update both CI and release workflows.
@github-actions

Copy link
Copy Markdown

AI Code Review

Code Quality Issues

# Location Issue Severity
1 post_pr_comment Removed source_label environment variable fallback; PR comments will no longer indicate the reviewer identity or configuration. Medium
2 SINGLE_ROUND_USER_TEMPLATE / SUMMARIZE_USER_TEMPLATE Prompt templates are excessively long and complex, increasing token usage and potential for LLM instruction drift. Low
3 SINGLE_ROUND_USER_TEMPLATE Hardcoded example rows in the prompt template may bias the LLM to replicate the example format strictly rather than generating dynamic content. Low

Security Issues

# Location Issue Risk Level
1 post_pr_comment Removed source_label sanitization/fallback; if REVIEW_ENGINE_LABEL is controlled by an attacker, it could inject malicious text into PR comments (though currently it falls back to a static string, the removal of the explicit fallback logic reduces defense-in-depth). Low
2 SINGLE_ROUND_USER_TEMPLATE Prompt injection risk: The diff content {chunk} is inserted directly into the prompt without escaping or separation, potentially allowing malicious code comments to manipulate the LLM's output format or logic. Medium
3 SUMMARIZE_USER_TEMPLATE Prompt injection risk: The combined findings {combined} are inserted directly into the prompt, allowing maliciously crafted previous review outputs to influence the final summary. Medium

This review was generated by self-hosted AI reviewer.

@WillIsback
WillIsback merged commit 8c64e20 into main May 14, 2026
2 checks passed
@WillIsback
WillIsback deleted the feat/review-template-upgrade branch May 14, 2026 19:34
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.

feat: upgrade review template — YAML frontmatter, emoji severity badges, pipe tables

1 participant