-
Notifications
You must be signed in to change notification settings - Fork 8
ci: add agent reviewers #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
174261f
6ca4528
1ea78de
6d97b7d
cc6a8f5
a8846f5
37f57c6
ec9c041
2228501
34c5f2f
ba4dd5a
2c9a41f
448ecf8
e6efe70
c6dc39f
85659d3
b2fea8a
6e7d7c2
eb57870
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "attribution": { | ||
| "commit": "", | ||
| "pr": "" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| You are a senior code reviewer for ethlambda, a minimalist Lean Ethereum consensus client written in Rust. | ||
|
|
||
| Review this PR focusing on: | ||
| - Code correctness and potential bugs | ||
| - Security vulnerabilities (critical for blockchain code) | ||
| - Performance implications | ||
| - Rust best practices and idiomatic patterns | ||
| - Memory safety and proper error handling | ||
| - Code readability and maintainability | ||
|
|
||
| Consensus-layer considerations: | ||
| - Fork choice (LMD GHOST / 3SF-mini) correctness | ||
| - Attestation processing and validation | ||
| - Justification and finalization logic | ||
| - State transition functions (process_slots, process_block) | ||
| - XMSS signature verification and aggregation | ||
| - SSZ encoding/decoding correctness | ||
|
|
||
| Be concise and specific. Provide line references when suggesting changes. | ||
| If the code looks good, acknowledge it briefly. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: PR Review - ChatGPT | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| chatgpt-review: | ||
| name: ChatGPT Code Review | ||
| if: | | ||
| github.event_name == 'pull_request' || | ||
| (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@chatgpt')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@chatgpt')) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Read review prompt | ||
| id: prompt | ||
| run: | | ||
| PROMPT=$(cat .github/prompts/pr_review.md) | ||
| echo "content<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$PROMPT" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: ChatGPT Code Review | ||
| uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review CommentsCode Correctness & Potential Bugs
Security Vulnerabilities
Performance Implications
Rust Best Practices & Idiomatic Patterns
Memory Safety & Proper Error Handling
Code Readability & Maintainability
Consensus-layer Considerations
Overall, this PR introduces a cleaner and potentially more effective way to handle code reviews via automated workflows. Please ensure all preconditions (e.g., the existence of files and correct secrets configuration) are thoroughly checked and validated prior to merging. |
||
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
| MODEL: gpt-4o | ||
| LANGUAGE: English | ||
| MAX_PATCH_LENGTH: 100000 | ||
| max_tokens: 4096 | ||
| PROMPT: ${{ steps.prompt.outputs.content }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: PR Review - Claude | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| claude-review: | ||
| name: Claude Code Review | ||
| if: | | ||
| github.event_name == 'pull_request' || | ||
| (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Read review prompt | ||
| id: prompt | ||
| run: | | ||
| PROMPT=$(cat .github/prompts/pr_review.md) | ||
| echo "content<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$PROMPT" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Claude Code Review | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| claude_args: | | ||
| --max-turns 5 | ||
| --model claude-sonnet-4-20250514 | ||
| trigger_phrase: "@claude" | ||
| prompt: ${{ steps.prompt.outputs.content }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| name: PR Review - Kimi | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| kimi-review: | ||
| name: Kimi Code Review | ||
| if: | | ||
| github.event_name == 'pull_request' || | ||
| (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@kimi')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@kimi')) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Read review prompt | ||
| id: prompt | ||
| run: | | ||
| PROMPT=$(cat .github/prompts/pr_review.md) | ||
| echo "content<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$PROMPT" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Get PR diff | ||
| id: diff | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh pr diff ${{ github.event.pull_request.number }} > pr_diff.txt | ||
| # Truncate if too large (Kimi has context limits) | ||
| head -c 100000 pr_diff.txt > pr_diff_truncated.txt | ||
|
|
||
| - name: Kimi Code Review | ||
| id: kimi_review | ||
| env: | ||
| KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }} | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| REVIEW_PROMPT: ${{ steps.prompt.outputs.content }} | ||
| run: | | ||
| if [ -z "$KIMI_API_KEY" ]; then | ||
| echo "Error: KIMI_API_KEY secret is not set" > kimi_review.txt | ||
| exit 0 | ||
| fi | ||
|
|
||
| DIFF_CONTENT=$(cat pr_diff_truncated.txt) | ||
|
|
||
| # Build the request body | ||
| REQUEST_BODY=$(jq -n \ | ||
| --arg diff "$DIFF_CONTENT" \ | ||
| --arg title "$PR_TITLE" \ | ||
| --arg prompt "$REVIEW_PROMPT" \ | ||
| '{ | ||
| "model": "moonshot-v1-128k", | ||
| "messages": [ | ||
| { | ||
| "role": "system", | ||
| "content": $prompt | ||
| }, | ||
| { | ||
| "role": "user", | ||
| "content": ("PR Title: " + $title + "\n\nDiff:\n" + $diff) | ||
| } | ||
| ], | ||
| "temperature": 0.3, | ||
| "max_tokens": 4096 | ||
| }') | ||
|
|
||
| # Try the API call | ||
| HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" https://api.moonshot.ai/v1/chat/completions \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "Authorization: Bearer $KIMI_API_KEY" \ | ||
| -d "$REQUEST_BODY") | ||
|
|
||
| HTTP_CODE=$(echo "$HTTP_RESPONSE" | tail -n1) | ||
| RESPONSE=$(echo "$HTTP_RESPONSE" | sed '$d') | ||
|
|
||
| if [ "$HTTP_CODE" != "200" ]; then | ||
| echo "API Error (HTTP $HTTP_CODE): $RESPONSE" > kimi_review.txt | ||
| else | ||
| # Check for API errors in response | ||
| ERROR=$(echo "$RESPONSE" | jq -r '.error.message // empty') | ||
| if [ -n "$ERROR" ]; then | ||
| echo "API Error: $ERROR" > kimi_review.txt | ||
| else | ||
| REVIEW=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "Error: Unexpected API response"') | ||
| echo "$REVIEW" > kimi_review.txt | ||
| fi | ||
| fi | ||
|
|
||
| - name: Post review comment | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| echo "<details><summary><h2>Kimi AI Code Review</h2></summary>" > body.md | ||
| cat kimi_review.txt >> body.md | ||
| echo -e "\n---\n*Automated review by Kimi (Moonshot AI)*\n</details>" >> body.md | ||
|
|
||
| gh pr comment ${{ github.event.pull_request.number }} --body-file body.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General Feedback
The PR adds a new environment variable
MAX_PATCH_LENGTH: 100000. This addition is not related to the core functionalities typically reviewed for consensus clients such as EthLambda. As such, the feedback will focus on the correctness of the integration, potential implications, and overall impact on system performance.Code Correctness and Potential Bugs
Security Vulnerabilities
MAX_PATCH_LENGTHdoesn't expose the system to buffer overflow or similar vulnerabilities by focusing on well-defined limits and ensuring safe handling of environment variables.Performance Implications
MAX_PATCH_LENGTHto100000may have performance implications depending on how it's used. If it leads to larger allocations or more processing, you may experience performance degradation. Profile or test this change to ensure it doesn't negatively affect critical paths.Rust Best Practices and Idiomatic Patterns
Memory Safety and Error Handling
std::env::varand proper error handling withResulttypes.Code Readability and Maintainability
Final Considerations
Without the rest of the codebase, it's crucial to analyze further how this change interacts with process_slots, process_block, or other core functions. Testing high-load scenarios will help determine if
MAX_PATCH_LENGTHimpacts memory consumption or processing times.In conclusion, while this change is isolated, ensuring it integrates smoothly with the broader system operationally and performance-wise is crucial.