Skip to content

feat(guardian): polish AI code reviewer — ruff/mypy clean, real Gemini API#80

Merged
zaebee merged 7 commits into
mainfrom
feat/ai-review
Jun 8, 2026
Merged

feat(guardian): polish AI code reviewer — ruff/mypy clean, real Gemini API#80
zaebee merged 7 commits into
mainfrom
feat/ai-review

Conversation

@zaebee

@zaebee zaebee commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix all ruff/mypy errors in the guardian module (was failing CI with ~8 violations)
  • Implement real google-generativeai async API (was mock placeholder)
  • Add missing __init__.py files so the package is importable
  • Fix git diff command: origin/{base}...HEAD instead of git diff HEAD
  • Add base_branch parameter to ContextCollector
  • Add mypy override for optional google.* dep (installed via uv sync --extra guardian)

Test plan

  • make format && make lint && make type-check — all pass (226 tests green)
  • GEMINI_API_KEY=... uv run python scripts/guardian_review.py on a feature branch to smoke-test the real API path
  • Verify uv sync --extra guardian installs google-generativeai correctly

🤖 Generated with Claude Code

zaebee and others added 2 commits June 9, 2026 00:13
- Add missing __init__.py for guardian and providers packages
- Fix all type annotations (-> None on __init__ methods)
- Fix TRY300: move return to else branch in collector.get_git_diff
- Fix RET504: inline returns in core.run_review
- Fix ARG002: remove unused system_prompt from mock base provider
- Fix EM101/TRY003: extract error message to variable in gemini provider
- Implement real google-generativeai API (lazy import, async call)
- Fix git diff to use origin/{base}...HEAD for proper branch comparison
- Add base_branch param to ContextCollector
- Remove duplicate GeminiProvider from base.py (keep only ABC)
- Add mypy override for optional google.* dependency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

zaebee and others added 5 commits June 8, 2026 21:35
GuardianReviewer is library code — removed print from run_review.
guardian_review.py now logs progress via structlog and owns the UI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…comment

- Triggers on issue_comment when body is exactly '/guardian review' on a PR
- Validates PR number format before using in git ref (injection hardening)
- Runs guardian_review.py with GEMINI_API_KEY secret
- Posts result as PR comment via peter-evans/create-or-update-comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add module-level docstrings to all guardian modules
- Add method docstrings to __init__ and generate_content
- Add commenter write-access gate to guardian.yml (Pwn Request fix)
- Pin all third-party actions to full commit SHAs
- Use structlog in guardian_review.py, remove prints from library code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…odel

- guardian_review.py now accepts --output path and writes markdown directly
  to guardian_report.md, eliminating the fragile tail -n +4 stdout parsing
- workflow uses body-path: guardian_report.md — special chars in review output
  can no longer break the GHA heredoc or GITHUB_OUTPUT multiline encoding
- GeminiProvider default model: gemini-1.5-pro → gemini-2.0-flash

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@zaebee zaebee merged commit 321f036 into main Jun 8, 2026
3 checks passed
@zaebee zaebee deleted the feat/ai-review branch June 8, 2026 21:58
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.

1 participant