From 174261faa6ca747efec6652cb9c65bcbd65c1837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:07:41 -0300 Subject: [PATCH 01/19] feat: add claude settings turning off commit attribution --- .claude/settings.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .claude/settings.json diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..671a084 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,6 @@ +{ + "attribution": { + "commit": "", + "pr": "" + } +} From 6ca452825cfde9efbaa9109a4634de2dcf81d7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:09:36 -0300 Subject: [PATCH 02/19] ci: add ChatGPT reviewer --- .github/workflows/pr_review_chatgpt.yaml | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/pr_review_chatgpt.yaml diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml new file mode 100644 index 0000000..3a00412 --- /dev/null +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -0,0 +1,57 @@ +name: PR Review - ChatGPT + +on: + pull_request: + types: [opened, synchronize, reopened] + pull_request_review_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 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: ChatGPT Code Review + uses: anc95/ChatGPT-CodeReview@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + with: + openai_engine: gpt-4o + language: en + review_comment_lgtm: false + max_tokens: 4096 + prompt: | + You are a senior code reviewer for ethrex, a Rust-based Ethereum execution client. + + 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 + + Ethereum-specific considerations: + - EVM opcode correctness and gas accounting + - Consensus rules and EIP compliance + - State trie and storage operations + - RLP encoding/decoding correctness + - Transaction and block validation logic + + Be concise and specific. Provide line references when suggesting changes. + If the code looks good, acknowledge it briefly. + From 1ea78de9775d6d003e719a6209fdadecc4a1e18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:10:55 -0300 Subject: [PATCH 03/19] ci: add Claude reviewer --- .github/workflows/pr_review_claude.yaml | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/pr_review_claude.yaml diff --git a/.github/workflows/pr_review_claude.yaml b/.github/workflows/pr_review_claude.yaml new file mode 100644 index 0000000..5947f13 --- /dev/null +++ b/.github/workflows/pr_review_claude.yaml @@ -0,0 +1,62 @@ +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@v4 + with: + fetch-depth: 0 + + - name: Claude Code Review + uses: anthropics/claude-code-action@beta + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + model: claude-sonnet-4-20250514 + trigger_phrase: "@claude" + timeout_minutes: 30 + direct_prompt: | + You are a senior code reviewer for ethrex, a Rust-based Ethereum execution client. + + 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 + + Ethereum-specific considerations: + - EVM opcode correctness and gas accounting + - Consensus rules and EIP compliance + - State trie and storage operations + - RLP encoding/decoding correctness + - Transaction and block validation logic + + Be concise and specific. Provide line references when suggesting changes. + If the code looks good, acknowledge it briefly. + From 6d97b7dc10765a44e9d7e64caca6a0e3937a895b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:11:04 -0300 Subject: [PATCH 04/19] ci: add Kimi reviewer --- .github/workflows/pr_review_kimi.yaml | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/pr_review_kimi.yaml diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml new file mode 100644 index 0000000..cc536fa --- /dev/null +++ b/.github/workflows/pr_review_kimi.yaml @@ -0,0 +1,101 @@ +name: PR Review - Kimi + +on: + pull_request: + types: [opened, synchronize, reopened] + +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 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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 }} + 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" \ + '{ + "model": "moonshot-v1-128k", + "messages": [ + { + "role": "system", + "content": "You are a senior code reviewer for ethrex, a Rust-based Ethereum execution client." + }, + { + "role": "user", + "content": ("PR Title: " + $title + "\n\nReview this PR focusing on:\n- Code correctness and potential bugs\n- Security vulnerabilities (critical for blockchain code)\n- Performance implications\n- Rust best practices and idiomatic patterns\n- Memory safety and proper error handling\n- Code readability and maintainability\n\nEthereum-specific considerations:\n- EVM opcode correctness and gas accounting\n- Consensus rules and EIP compliance\n- State trie and storage operations\n- RLP encoding/decoding correctness\n- Transaction and block validation logic\n\nBe concise and specific. Provide line references when suggesting changes.\nIf the code looks good, acknowledge it briefly.\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: | + REVIEW_CONTENT=$(cat kimi_review.txt) + + gh pr comment ${{ github.event.pull_request.number }} --body "## Kimi AI Code Review + + $REVIEW_CONTENT + + --- + *Automated review by Kimi (Moonshot AI)*" + From cc6a8f59eecc862460b9be006d247e43e2951946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:49:31 -0300 Subject: [PATCH 05/19] ci: improve PR review workflows for ethlambda - Extract shared review prompt to .github/prompts/pr_review.md - Update all workflows to use consensus-layer terminology instead of execution-layer - Add @chatgpt trigger to ChatGPT workflow (issue_comment + conditional) - Add @kimi trigger to Kimi workflow (issue_comment + pull_request_review_comment + conditional) - Pin ChatGPT action to specific commit (6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0) - Replace ethrex references with ethlambda across all workflows - Update Ethereum-specific considerations to focus on: * 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 --- .github/prompts/pr_review.md | 20 +++++++++++++ .github/workflows/pr_review_chatgpt.yaml | 37 ++++++++++-------------- .github/workflows/pr_review_claude.yaml | 29 ++++++------------- .github/workflows/pr_review_kimi.yaml | 22 ++++++++++++-- 4 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 .github/prompts/pr_review.md diff --git a/.github/prompts/pr_review.md b/.github/prompts/pr_review.md new file mode 100644 index 0000000..559b037 --- /dev/null +++ b/.github/prompts/pr_review.md @@ -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. diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 3a00412..590eb27 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -5,6 +5,8 @@ on: types: [opened, synchronize, reopened] pull_request_review_comment: types: [created] + issue_comment: + types: [created] permissions: contents: read @@ -17,6 +19,10 @@ concurrency: 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 @@ -24,8 +30,16 @@ jobs: with: fetch-depth: 0 + - name: Read review prompt + id: prompt + run: | + PROMPT=$(cat .github/prompts/pr_review.md) + echo "content<> $GITHUB_OUTPUT + echo "$PROMPT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + - name: ChatGPT Code Review - uses: anc95/ChatGPT-CodeReview@main + uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} @@ -34,24 +48,5 @@ jobs: language: en review_comment_lgtm: false max_tokens: 4096 - prompt: | - You are a senior code reviewer for ethrex, a Rust-based Ethereum execution client. - - 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 - - Ethereum-specific considerations: - - EVM opcode correctness and gas accounting - - Consensus rules and EIP compliance - - State trie and storage operations - - RLP encoding/decoding correctness - - Transaction and block validation logic - - Be concise and specific. Provide line references when suggesting changes. - If the code looks good, acknowledge it briefly. + prompt: ${{ steps.prompt.outputs.content }} diff --git a/.github/workflows/pr_review_claude.yaml b/.github/workflows/pr_review_claude.yaml index 5947f13..fb1b42b 100644 --- a/.github/workflows/pr_review_claude.yaml +++ b/.github/workflows/pr_review_claude.yaml @@ -32,6 +32,14 @@ jobs: with: fetch-depth: 0 + - name: Read review prompt + id: prompt + run: | + PROMPT=$(cat .github/prompts/pr_review.md) + echo "content<> $GITHUB_OUTPUT + echo "$PROMPT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + - name: Claude Code Review uses: anthropics/claude-code-action@beta with: @@ -39,24 +47,5 @@ jobs: model: claude-sonnet-4-20250514 trigger_phrase: "@claude" timeout_minutes: 30 - direct_prompt: | - You are a senior code reviewer for ethrex, a Rust-based Ethereum execution client. - - 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 - - Ethereum-specific considerations: - - EVM opcode correctness and gas accounting - - Consensus rules and EIP compliance - - State trie and storage operations - - RLP encoding/decoding correctness - - Transaction and block validation logic - - Be concise and specific. Provide line references when suggesting changes. - If the code looks good, acknowledge it briefly. + direct_prompt: ${{ steps.prompt.outputs.content }} diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml index cc536fa..58c621d 100644 --- a/.github/workflows/pr_review_kimi.yaml +++ b/.github/workflows/pr_review_kimi.yaml @@ -3,6 +3,10 @@ name: PR Review - Kimi on: pull_request: types: [opened, synchronize, reopened] + pull_request_review_comment: + types: [created] + issue_comment: + types: [created] permissions: contents: read @@ -15,6 +19,10 @@ concurrency: 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 @@ -22,6 +30,14 @@ jobs: with: fetch-depth: 0 + - name: Read review prompt + id: prompt + run: | + PROMPT=$(cat .github/prompts/pr_review.md) + echo "content<> $GITHUB_OUTPUT + echo "$PROMPT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + - name: Get PR diff id: diff env: @@ -36,6 +52,7 @@ jobs: 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 @@ -48,16 +65,17 @@ jobs: REQUEST_BODY=$(jq -n \ --arg diff "$DIFF_CONTENT" \ --arg title "$PR_TITLE" \ + --arg prompt "$REVIEW_PROMPT" \ '{ "model": "moonshot-v1-128k", "messages": [ { "role": "system", - "content": "You are a senior code reviewer for ethrex, a Rust-based Ethereum execution client." + "content": $prompt }, { "role": "user", - "content": ("PR Title: " + $title + "\n\nReview this PR focusing on:\n- Code correctness and potential bugs\n- Security vulnerabilities (critical for blockchain code)\n- Performance implications\n- Rust best practices and idiomatic patterns\n- Memory safety and proper error handling\n- Code readability and maintainability\n\nEthereum-specific considerations:\n- EVM opcode correctness and gas accounting\n- Consensus rules and EIP compliance\n- State trie and storage operations\n- RLP encoding/decoding correctness\n- Transaction and block validation logic\n\nBe concise and specific. Provide line references when suggesting changes.\nIf the code looks good, acknowledge it briefly.\n\nDiff:\n" + $diff) + "content": ("PR Title: " + $title + "\n\nDiff:\n" + $diff) } ], "temperature": 0.3, From a8846f5e305945d1aa6db053aafa9c2c34cad04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:14:29 -0300 Subject: [PATCH 06/19] ci: fix chatgpt code review action parameters The actual action doesn't receive parameters normally, it fetches everything from its env --- .github/workflows/pr_review_chatgpt.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 590eb27..3ec126f 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -43,10 +43,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - with: - openai_engine: gpt-4o - language: en - review_comment_lgtm: false + MODEL: gpt-4o + LANGUAGE: English max_tokens: 4096 - prompt: ${{ steps.prompt.outputs.content }} - + PROMPT: ${{ steps.prompt.outputs.content }} From 37f57c6aa5ba0c7a5323ac525f7c092af3b55932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:29:07 -0300 Subject: [PATCH 07/19] ci: bump checkout version and remove fetch-depth 0 --- .github/workflows/ci.yml | 4 ++-- .github/workflows/docker_publish.yaml | 2 +- .github/workflows/pr_review_chatgpt.yaml | 4 +--- .github/workflows/pr_review_claude.yaml | 5 +---- .github/workflows/pr_review_kimi.yaml | 5 +---- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 637c299..3eea9cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup Rust uses: dtolnay/rust-toolchain@master @@ -45,7 +45,7 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Download test fixtures env: diff --git a/.github/workflows/docker_publish.yaml b/.github/workflows/docker_publish.yaml index 3d3d994..a7ab50b 100644 --- a/.github/workflows/docker_publish.yaml +++ b/.github/workflows/docker_publish.yaml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 3ec126f..6b5a296 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -26,9 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 + uses: actions/checkout@v6 - name: Read review prompt id: prompt diff --git a/.github/workflows/pr_review_claude.yaml b/.github/workflows/pr_review_claude.yaml index fb1b42b..f984f3d 100644 --- a/.github/workflows/pr_review_claude.yaml +++ b/.github/workflows/pr_review_claude.yaml @@ -28,9 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 + uses: actions/checkout@v6 - name: Read review prompt id: prompt @@ -48,4 +46,3 @@ jobs: trigger_phrase: "@claude" timeout_minutes: 30 direct_prompt: ${{ steps.prompt.outputs.content }} - diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml index 58c621d..5b04099 100644 --- a/.github/workflows/pr_review_kimi.yaml +++ b/.github/workflows/pr_review_kimi.yaml @@ -26,9 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 + uses: actions/checkout@v6 - name: Read review prompt id: prompt @@ -116,4 +114,3 @@ jobs: --- *Automated review by Kimi (Moonshot AI)*" - From ec9c041bc22d34f9fd704dff38e86831f920ad28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:29:35 -0300 Subject: [PATCH 08/19] ci: bump claude-code-action to v1 --- .github/workflows/pr_review_claude.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr_review_claude.yaml b/.github/workflows/pr_review_claude.yaml index f984f3d..83379e1 100644 --- a/.github/workflows/pr_review_claude.yaml +++ b/.github/workflows/pr_review_claude.yaml @@ -39,10 +39,11 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Claude Code Review - uses: anthropics/claude-code-action@beta + uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - model: claude-sonnet-4-20250514 + claude_args: | + --max-turns 5 + --model claude-sonnet-4-20250514 trigger_phrase: "@claude" - timeout_minutes: 30 - direct_prompt: ${{ steps.prompt.outputs.content }} + prompt: ${{ steps.prompt.outputs.content }} From 2228501427dd4e98a10797dd3cbab261c6d4aaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:39:31 -0300 Subject: [PATCH 09/19] docs: add CLAUDE.md --- CLAUDE.md | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b3633e0 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,189 @@ +# ethlambda Development Guide + +Development reference for ethlambda - minimalist Lean Ethereum consensus client. +Not to be confused with Ethereum consensus clients AKA Beacon Chain clients AKA Eth2 clients. + +## Quick Reference + +**Main branch:** `main` +**Rust version:** 1.92.0 (edition 2024) +**Test fixtures commit:** Check `LEAN_SPEC_COMMIT_HASH` in Makefile + +## Codebase Structure (10 crates) + +``` +bin/ethlambda/ # Entry point, CLI, orchestration +crates/ + blockchain/ # State machine actor (GenServer pattern) + ├─ src/lib.rs # BlockChain actor, tick events, validator duties + ├─ src/store.rs # Fork choice store, block/attestation processing + ├─ fork_choice/ # LMD GHOST implementation (3SF-mini) + └─ state_transition/ # STF: process_slots, process_block, attestations + common/ + ├─ types/ # Core types (State, Block, Attestation, Checkpoint) + ├─ crypto/ # XMSS aggregation (leansig wrapper) + └─ metrics/ # Prometheus metrics + net/ + ├─ p2p/ # libp2p: gossipsub + req-resp (Status, BlocksByRoot) + └─ rpc/ # Axum HTTP endpoints (/lean/v0/* and /metrics) + storage/ # RocksDB backend, in-memory for tests +``` + +## Key Architecture Patterns + +### Actor Concurrency (spawned-concurrency) +- **BlockChain**: Main state machine (GenServer pattern) +- **P2P**: Network event loop with libp2p swarm +- Communication via `mpsc::unbounded_channel` +- Shared storage via `Arc` (clone Store, share backend) + +### Tick-Based Validator Duties (4-second slots, 4 intervals per slot) +``` +Interval 0: Proposer check → accept attestations → build/publish block +Interval 1: Non-proposers produce attestations +Interval 2: Safe target update (fork choice with 2/3 threshold) +Interval 3: Accept accumulated attestations +``` + +### Attestation Pipeline +``` +Gossip → Signature verification → new_attestations (pending) + ↓ (intervals 0/3) +promote → known_attestations (fork choice active) + ↓ +Fork choice head update +``` + +### State Transition Phases +1. **process_slots()**: Advance through empty slots, update historical roots +2. **process_block()**: Validate header → process attestations → update justifications/finality +3. **Justification**: 3SF-mini rules (delta ≤ 5 OR n² OR n(n+1)) +4. **Finalization**: Source with no unjustifiable gaps to target + +## Development Workflow + +### Before Committing +```bash +cargo fmt # Format code +make lint # Clippy with -D warnings +make test # All tests + forkchoice (with skip-signature-verification) +``` + +### Common Operations +```bash +make run-devnet # Docker build → lean-quickstart local devnet +rm -rf leanSpec && make leanSpec/fixtures # Regenerate test fixtures (requires uv) +``` + +### Debugging + + + +## Important Patterns & Idioms + +### Metrics (RAII Pattern) +```rust +// Timing guard automatically observes duration on drop +let _timing = metrics::time_state_transition(); +``` + +### Relative Indexing (justified_slots) +```rust +// Bounded storage: index relative to finalized_slot +actual_slot = finalized_slot + 1 + relative_index +// Helper ops in justified_slots_ops.rs +``` + +## Cryptography & Signatures + +**XMSS (eXtended Merkle Signature Scheme):** +- Post-quantum signature scheme +- 52-byte public keys, 3112-byte signatures +- Epoch-based to prevent reuse +- Aggregation via leanVM for efficiency + +**Signature Aggregation (Two-Phase):** +1. **Gossip signatures**: Fresh XMSS from network → aggregate via leanVM +2. **Fallback to proofs**: Reuse previous block proofs for missing validators + +## Networking (libp2p) + +### Protocols +- **Transport**: QUIC over UDP (TLS 1.3) +- **Gossipsub**: Blocks + Attestations (snappy raw compression) + - Topic: `/leanconsensus/{network}/{block|attestation}/ssz_snappy` + - Mesh size: 8 (6-12 bounds), heartbeat: 700ms +- **Req/Resp**: Status, BlocksByRoot (snappy frame compression + varint length) + +### Retry Strategy on Block Requests +- Exponential backoff: 10ms, 40ms, 160ms, 640ms, 2560ms +- Max 5 attempts, random peer selection on retry + +### Message IDs +- 20-byte truncated SHA256 of: domain (valid/invalid snappy) + topic + data + +## Configuration Files + +**Genesis:** `genesis.json` (JSON format, cross-client compatible) +- `GENESIS_TIME`: Unix timestamp for slot 0 +- `GENESIS_VALIDATORS`: Array of 52-byte XMSS pubkeys (hex) + +**Validators:** JSON array of `{"pubkey": "...", "index": 0}` +**Bootnodes:** ENR records (Base64-encoded, RLP decoded for QUIC port + secp256k1 pubkey) + +## Testing + +### Test Categories +1. **Unit tests**: Embedded in source files +2. **Spec tests**: From `leanSpec/fixtures/consensus/` + - `forkchoice_spectests.rs` (requires `skip-signature-verification`) + - `signature_spectests.rs` + - `stf_spectests.rs` (state transition) + +### Running Tests +```bash +cargo test --workspace --release # All workspace tests +cargo test -p ethlambda-blockchain --features skip-signature-verification --test forkchoice_spectests +``` + +## Common Gotchas + +### Signature Verification +- Tests require `skip-signature-verification` feature for performance +- Crypto tests marked `#[ignore]` (slow leanVM operations) + +### State Root Computation +- Always computed via `tree_hash_root()` after full state transition +- Must match proposer's pre-computed `block.state_root` + +### Finalization Checks +- Use `original_finalized_slot` for justifiability checks during attestation processing +- Finalization updates can occur mid-processing + +### `justified_slots` Window Shifting +- Call `shift_window()` when finalization advances +- Prunes justifications for now-finalized slots + +## External Dependencies + +**Critical:** +- `leansig`: XMSS signatures (leanEthereum project) +- `ethereum_ssz`: SSZ serialization +- `tree_hash`: Merkle tree hashing +- `spawned-concurrency`: Actor model +- `libp2p`: P2P networking (custom LambdaClass fork) + +**Storage:** +- `rocksdb`: Persistent backend +- In-memory backend for tests + +## Resources + +**Specs:** `leanSpec/src/lean_spec/` (Python reference implementation) +**Devnet:** `lean-quickstart` (github.com/blockblaz/lean-quickstart) + +## Other implementations + +- zeam (Zig): +- ream (Rust): +- qlean (C++): From 34c5f2f04e6e9220e03a89f7be68c46391f44952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:35:49 -0300 Subject: [PATCH 10/19] ci: use official codex action --- .github/workflows/pr_review_chatgpt.yaml | 37 ++++++++++++++---------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 6b5a296..7221807 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -28,20 +28,27 @@ jobs: - name: Checkout repository uses: actions/checkout@v6 - - name: Read review prompt - id: prompt - run: | - PROMPT=$(cat .github/prompts/pr_review.md) - echo "content<> $GITHUB_OUTPUT - echo "$PROMPT" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + - name: Run Codex + id: run_codex + uses: openai/codex-action@v1 + with: + openai-api-key: ${{ secrets.OPENAI_API_KEY }} + prompt-file: .github/prompts/pr_review.md + output-file: codex-output.md + safety-strategy: drop-sudo + model: gpt-4o + sandbox: workspace-write - - name: ChatGPT Code Review - uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0 + - name: Post Codex feedback + uses: actions/github-script@v8 + with: + github-token: ${{ github.token }} + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: process.env.CODEX_FINAL_MESSAGE, + }); env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - MODEL: gpt-4o - LANGUAGE: English - max_tokens: 4096 - PROMPT: ${{ steps.prompt.outputs.content }} + CODEX_FINAL_MESSAGE: ${{ steps.run_codex.outputs.final-message }} From ba4dd5a711ebba9da252f4f9acfc5ffe5c185770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:41:29 -0300 Subject: [PATCH 11/19] ci: pre-fetch base and head refs --- .github/workflows/pr_review_chatgpt.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 7221807..2d6f171 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -27,6 +27,14 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v6 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Pre-fetch base and head refs + run: | + git fetch --no-tags origin \ + ${{ github.event.pull_request.base.ref }} \ + +refs/pull/${{ github.event.pull_request.number }}/head - name: Run Codex id: run_codex From 2c9a41f054dc128b0ce422e2d1eb7f0a41679065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:44:08 -0300 Subject: [PATCH 12/19] chore: remove chatgpt workflow --- .github/workflows/pr_review_chatgpt.yaml | 62 ------------------------ 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/pr_review_chatgpt.yaml diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml deleted file mode 100644 index 2d6f171..0000000 --- a/.github/workflows/pr_review_chatgpt.yaml +++ /dev/null @@ -1,62 +0,0 @@ -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 - with: - ref: refs/pull/${{ github.event.pull_request.number }}/merge - - - name: Pre-fetch base and head refs - run: | - git fetch --no-tags origin \ - ${{ github.event.pull_request.base.ref }} \ - +refs/pull/${{ github.event.pull_request.number }}/head - - - name: Run Codex - id: run_codex - uses: openai/codex-action@v1 - with: - openai-api-key: ${{ secrets.OPENAI_API_KEY }} - prompt-file: .github/prompts/pr_review.md - output-file: codex-output.md - safety-strategy: drop-sudo - model: gpt-4o - sandbox: workspace-write - - - name: Post Codex feedback - uses: actions/github-script@v8 - with: - github-token: ${{ github.token }} - script: | - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - body: process.env.CODEX_FINAL_MESSAGE, - }); - env: - CODEX_FINAL_MESSAGE: ${{ steps.run_codex.outputs.final-message }} From 448ecf82dacd6897fd90c051ee2471187ff6e5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:47:11 -0300 Subject: [PATCH 13/19] ci: use claude-code for kimi code review --- .github/workflows/pr_review_kimi.yaml | 91 +++++---------------------- 1 file changed, 15 insertions(+), 76 deletions(-) diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml index 5b04099..bb2d010 100644 --- a/.github/workflows/pr_review_kimi.yaml +++ b/.github/workflows/pr_review_kimi.yaml @@ -36,81 +36,20 @@ jobs: 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 + uses: anthropics/claude-code-action@v1 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: | - REVIEW_CONTENT=$(cat kimi_review.txt) - - gh pr comment ${{ github.event.pull_request.number }} --body "## Kimi AI Code Review - - $REVIEW_CONTENT - - --- - *Automated review by Kimi (Moonshot AI)*" + ANTHROPIC_BASE_URL: https://api.moonshot.ai/anthropic + ANTHROPIC_AUTH_TOKEN: ${{ secrets.KIMI_API_KEY }} + ANTHROPIC_MODEL: moonshot-v1-128k + ANTHROPIC_DEFAULT_OPUS_MODEL: moonshot-v1-128k + ANTHROPIC_DEFAULT_SONNET_MODEL: moonshot-v1-128k + ANTHROPIC_DEFAULT_HAIKU_MODEL: moonshot-v1-128k + CLAUDE_CODE_SUBAGENT_MODEL: moonshot-v1-128k + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_args: | + --max-turns 5 + --model claude-sonnet-4-20250514 + trigger_phrase: "@kimi" + prompt: ${{ steps.prompt.outputs.content }} From e6efe7042669c7e27edcd567c3d6c021b82831bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:49:30 -0300 Subject: [PATCH 14/19] Revert "ci: use claude-code for kimi code review" This reverts commit 448ecf82dacd6897fd90c051ee2471187ff6e5e7. --- .github/workflows/pr_review_kimi.yaml | 91 ++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml index bb2d010..5b04099 100644 --- a/.github/workflows/pr_review_kimi.yaml +++ b/.github/workflows/pr_review_kimi.yaml @@ -36,20 +36,81 @@ jobs: 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 - uses: anthropics/claude-code-action@v1 + id: kimi_review env: - ANTHROPIC_BASE_URL: https://api.moonshot.ai/anthropic - ANTHROPIC_AUTH_TOKEN: ${{ secrets.KIMI_API_KEY }} - ANTHROPIC_MODEL: moonshot-v1-128k - ANTHROPIC_DEFAULT_OPUS_MODEL: moonshot-v1-128k - ANTHROPIC_DEFAULT_SONNET_MODEL: moonshot-v1-128k - ANTHROPIC_DEFAULT_HAIKU_MODEL: moonshot-v1-128k - CLAUDE_CODE_SUBAGENT_MODEL: moonshot-v1-128k - with: - anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - claude_args: | - --max-turns 5 - --model claude-sonnet-4-20250514 - trigger_phrase: "@kimi" - prompt: ${{ steps.prompt.outputs.content }} + 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: | + REVIEW_CONTENT=$(cat kimi_review.txt) + + gh pr comment ${{ github.event.pull_request.number }} --body "## Kimi AI Code Review + + $REVIEW_CONTENT + + --- + *Automated review by Kimi (Moonshot AI)*" From c6dc39f2cae5831322a87f9a8e9e1b1fc11ad44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:17:47 -0300 Subject: [PATCH 15/19] Revert "chore: remove chatgpt workflow" This reverts commit 2c9a41f054dc128b0ce422e2d1eb7f0a41679065. --- .github/workflows/pr_review_chatgpt.yaml | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/pr_review_chatgpt.yaml diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml new file mode 100644 index 0000000..2d6f171 --- /dev/null +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -0,0 +1,62 @@ +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 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Pre-fetch base and head refs + run: | + git fetch --no-tags origin \ + ${{ github.event.pull_request.base.ref }} \ + +refs/pull/${{ github.event.pull_request.number }}/head + + - name: Run Codex + id: run_codex + uses: openai/codex-action@v1 + with: + openai-api-key: ${{ secrets.OPENAI_API_KEY }} + prompt-file: .github/prompts/pr_review.md + output-file: codex-output.md + safety-strategy: drop-sudo + model: gpt-4o + sandbox: workspace-write + + - name: Post Codex feedback + uses: actions/github-script@v8 + with: + github-token: ${{ github.token }} + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: process.env.CODEX_FINAL_MESSAGE, + }); + env: + CODEX_FINAL_MESSAGE: ${{ steps.run_codex.outputs.final-message }} From 85659d37b2bbd3de52ab06c7c6e5329502323003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:18:14 -0300 Subject: [PATCH 16/19] Revert "ci: pre-fetch base and head refs" This reverts commit ba4dd5a711ebba9da252f4f9acfc5ffe5c185770. --- .github/workflows/pr_review_chatgpt.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 2d6f171..7221807 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -27,14 +27,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v6 - with: - ref: refs/pull/${{ github.event.pull_request.number }}/merge - - - name: Pre-fetch base and head refs - run: | - git fetch --no-tags origin \ - ${{ github.event.pull_request.base.ref }} \ - +refs/pull/${{ github.event.pull_request.number }}/head - name: Run Codex id: run_codex From b2fea8a98cafc6c7188f37cfdc00b14e32099027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:18:20 -0300 Subject: [PATCH 17/19] Revert "ci: use official codex action" This reverts commit 34c5f2f04e6e9220e03a89f7be68c46391f44952. --- .github/workflows/pr_review_chatgpt.yaml | 37 ++++++++++-------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 7221807..6b5a296 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -28,27 +28,20 @@ jobs: - name: Checkout repository uses: actions/checkout@v6 - - name: Run Codex - id: run_codex - uses: openai/codex-action@v1 - with: - openai-api-key: ${{ secrets.OPENAI_API_KEY }} - prompt-file: .github/prompts/pr_review.md - output-file: codex-output.md - safety-strategy: drop-sudo - model: gpt-4o - sandbox: workspace-write + - name: Read review prompt + id: prompt + run: | + PROMPT=$(cat .github/prompts/pr_review.md) + echo "content<> $GITHUB_OUTPUT + echo "$PROMPT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - - name: Post Codex feedback - uses: actions/github-script@v8 - with: - github-token: ${{ github.token }} - script: | - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - body: process.env.CODEX_FINAL_MESSAGE, - }); + - name: ChatGPT Code Review + uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0 env: - CODEX_FINAL_MESSAGE: ${{ steps.run_codex.outputs.final-message }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + MODEL: gpt-4o + LANGUAGE: English + max_tokens: 4096 + PROMPT: ${{ steps.prompt.outputs.content }} From 6e7d7c24ca79a546398f9dd865e9a9919ac4cd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:32:35 -0300 Subject: [PATCH 18/19] ci: put Kimi review in collapsible section --- .github/workflows/pr_review_kimi.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml index 5b04099..5599be2 100644 --- a/.github/workflows/pr_review_kimi.yaml +++ b/.github/workflows/pr_review_kimi.yaml @@ -106,11 +106,8 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - REVIEW_CONTENT=$(cat kimi_review.txt) + echo "

Kimi AI Code Review

" > body.md + cat kimi_review.txt >> body.md + echo -e "\n---\n*Automated review by Kimi (Moonshot AI)*\n
" >> body.md - gh pr comment ${{ github.event.pull_request.number }} --body "## Kimi AI Code Review - - $REVIEW_CONTENT - - --- - *Automated review by Kimi (Moonshot AI)*" + gh pr comment ${{ github.event.pull_request.number }} --body-file body.md From eb57870ec05d9701d4eeeeebd8cc90fd60c3719b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:22:02 -0300 Subject: [PATCH 19/19] ci: limit ChatGPT review pr diff to 100k chars --- .github/workflows/pr_review_chatgpt.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml index 6b5a296..70affed 100644 --- a/.github/workflows/pr_review_chatgpt.yaml +++ b/.github/workflows/pr_review_chatgpt.yaml @@ -43,5 +43,6 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} MODEL: gpt-4o LANGUAGE: English + MAX_PATCH_LENGTH: 100000 max_tokens: 4096 PROMPT: ${{ steps.prompt.outputs.content }}