docs: add RFC-0117 deterministic execution context (v1.1) #500
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # AI Review Automation | ||
|
Check failure on line 1 in .github/workflows/agent-review.yml
|
||
| # CipherOcto becomes AI-native | ||
| name: AI Agent Review | ||
| on: | ||
| pull_request: | ||
| branches: [main, next, feat/**, agent/**] | ||
| jobs: | ||
| ai-review: | ||
| runs-on: ubuntu-latest | ||
| # Skip if OPENAI_API_KEY is not set | ||
| if: vars.OPENAI_API_KEY != '' || secrets.OPENAI_API_KEY != '' | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Get PR diff | ||
| id: diff | ||
| run: | | ||
| git fetch origin ${{ github.base_ref }} | ||
| git diff origin/${{ github.base_ref }} > pr.diff | ||
| echo "has_changes=$(wc -l < pr.diff | awk '{print $1}' | xargs -I {} test {} -gt 0 && echo true || echo false)" >> $GITHUB_OUTPUT | ||
| - name: Build review prompt | ||
| if: steps.diff.outputs.has_changes == 'true' | ||
| run: | | ||
| cat > review_prompt.txt << 'PROMPT_EOF' | ||
| Review this pull request diff for bugs, security risks, and architectural concerns. | ||
| Context: This is a Rust-first decentralized AI platform with blockchain components. | ||
| For Rust changes, check for: | ||
| - Memory safety issues | ||
| - Correct error handling (Result, Option) | ||
| - Unsafe code usage | ||
| - Concurrency patterns (Arc, Mutex, channels) | ||
| - Clippy warnings adherence | ||
| === DIFF START === | ||
| PROMPT_EOF | ||
| cat pr.diff >> review_prompt.txt | ||
| echo "=== DIFF END ===" >> review_prompt.txt | ||
| - name: AI Review | ||
| if: steps.diff.outputs.has_changes == 'true' | ||
| env: | ||
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
| run: | | ||
| # Read prompt and escape for JSON | ||
| PROMPT=$(cat review_prompt.txt | jq -Rs .) | ||
| # Build JSON request | ||
| cat > request.json << EOF | ||
| { | ||
| "model": "gpt-4o-mini", | ||
| "messages": [ | ||
| { | ||
| "role": "user", | ||
| "content": $PROMPT | ||
| } | ||
| ], | ||
| "max_tokens": 2000 | ||
| } | ||
| EOF | ||
| # Call OpenAI API | ||
| curl -s https://api.openai.com/v1/chat/completions \ | ||
| -H "Authorization: Bearer $OPENAI_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d @request.json \ | ||
| -o response.json | ||
| # Extract and format the review | ||
| if [ -s response.json ]; then | ||
| CONTENT=$(jq -r '.choices[0].message.content // "Error: No review content generated"' response.json) | ||
| echo "## 🤖 AI Review" > review.md | ||
| echo "" >> review.md | ||
| echo "$CONTENT" >> review.md | ||
| else | ||
| echo "## 🤖 AI Review" > review.md | ||
| echo "" >> review.md | ||
| echo "**Error:** Failed to get AI review." >> review.md | ||
| fi | ||
| - name: Post Comment | ||
| if: steps.diff.outputs.has_changes == 'true' | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const review = fs.readFileSync('review.md', 'utf8'); | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: review | ||
| }); | ||
| - name: Skip notice | ||
| if: steps.diff.outputs.has_changes != 'true' || (vars.OPENAI_API_KEY == '' && secrets.OPENAI_API_KEY == '') | ||
| run: | | ||
| echo "AI review skipped: no changes or API key not configured" | ||