ci(pr-review): fetch existing PR comments before LLM analysis
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
Test / frontend-typecheck (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Has been cancelled
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Has been cancelled
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
Test / frontend-typecheck (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Has been cancelled
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Has been cancelled
Add a new 'Fetch PR comment history' step that pulls both review posts and issue comments from the Gitea API before the LLM is called. The full comment history is injected into the prompt with an explicit instruction to silently discard any finding already marked as invalid, acknowledged as intentional, or confirmed fixed in a prior round. This prevents the reviewer from repeatedly raising refuted findings across successive push events on the same PR.
This commit is contained in:
parent
468a69d89e
commit
91b6bf3d90
@ -136,6 +136,45 @@ jobs:
|
||||
echo "index_lines=${INDEX_LINES}" >> $GITHUB_OUTPUT
|
||||
echo "Built codebase index: ${INDEX_LINES} lines"
|
||||
|
||||
- name: Fetch PR comment history
|
||||
id: pr_history
|
||||
if: steps.context.outputs.diff_size != '0'
|
||||
shell: bash
|
||||
env:
|
||||
TF_TOKEN: ${{ secrets.TFT_GITEA_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
> /tmp/pr_comments.txt
|
||||
|
||||
# Fetch automated review posts (what this action posts each round)
|
||||
REVIEWS=$(curl -sf --max-time 30 --connect-timeout 10 \
|
||||
"https://gogs.tftsr.com/api/v1/repos/${REPOSITORY}/pulls/${PR_NUMBER}/reviews" \
|
||||
-H "Authorization: Bearer $TF_TOKEN" || echo '[]')
|
||||
|
||||
# Fetch regular PR/issue comments (human responses, rebuttals, etc.)
|
||||
COMMENTS=$(curl -sf --max-time 30 --connect-timeout 10 \
|
||||
"https://gogs.tftsr.com/api/v1/repos/${REPOSITORY}/issues/${PR_NUMBER}/comments" \
|
||||
-H "Authorization: Bearer $TF_TOKEN" || echo '[]')
|
||||
|
||||
{
|
||||
printf '%s\n\n' '## PREVIOUS REVIEW ROUNDS'
|
||||
printf '%s\n\n' '### Automated review posts (oldest first):'
|
||||
echo "$REVIEWS" \
|
||||
| jq -r '.[] | "#### Review by \(.user.login) [state: \(.state // "COMMENT")]:\n\(.body)\n---"' \
|
||||
2>/dev/null || true
|
||||
|
||||
printf '\n%s\n\n' '### PR comments (oldest first):'
|
||||
echo "$COMMENTS" \
|
||||
| jq -r '.[] | "#### Comment by \(.user.login):\n\(.body)\n---"' \
|
||||
2>/dev/null || true
|
||||
} >> /tmp/pr_comments.txt
|
||||
|
||||
LINES=$(wc -l < /tmp/pr_comments.txt | tr -d ' ')
|
||||
echo "comment_lines=${LINES}" >> $GITHUB_OUTPUT
|
||||
echo "Fetched PR history: ${LINES} lines"
|
||||
|
||||
- name: Analyze with LLM
|
||||
id: analyze
|
||||
if: steps.context.outputs.diff_size != '0'
|
||||
@ -165,6 +204,18 @@ jobs:
|
||||
printf '%s\n' '---'
|
||||
cat /tmp/pr_context.txt
|
||||
printf '%s\n\n' '---'
|
||||
if [ -s /tmp/pr_comments.txt ]; then
|
||||
cat /tmp/pr_comments.txt
|
||||
printf '%s\n\n' '---'
|
||||
printf '%s\n' '## CRITICAL: Prior review context above'
|
||||
printf '%s\n' 'Before raising ANY finding, check the review history above.'
|
||||
printf '%s\n' 'SILENTLY DISCARD any finding that has already been:'
|
||||
printf '%s\n' ' - Marked as invalid or incorrect by a reviewer'
|
||||
printf '%s\n' ' - Acknowledged as an intentional design decision or known limitation'
|
||||
printf '%s\n\n' ' - Confirmed fixed in a prior commit'
|
||||
printf '%s\n\n' 'Raising a previously-refuted finding is a critical error.'
|
||||
printf '%s\n' '---'
|
||||
fi
|
||||
printf '%s\n\n' '## Instructions'
|
||||
printf '%s\n' 'Before raising any finding:'
|
||||
printf '%s\n' '1. Confirm every symbol you cite exists in the CODEBASE INDEX or file'
|
||||
@ -330,4 +381,4 @@ jobs:
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
shell: bash
|
||||
run: rm -f /tmp/pr_diff.txt /tmp/pr_context.txt /tmp/codebase_index.txt /tmp/prompt.txt /tmp/body.json /tmp/llm_response.json /tmp/pr_review.txt /tmp/review_post_response.json /tmp/pr_files.txt
|
||||
run: rm -f /tmp/pr_diff.txt /tmp/pr_context.txt /tmp/codebase_index.txt /tmp/pr_comments.txt /tmp/prompt.txt /tmp/body.json /tmp/llm_response.json /tmp/pr_review.txt /tmp/review_post_response.json /tmp/pr_files.txt
|
||||
|
||||
Loading…
Reference in New Issue
Block a user