Skip to content

ci: request exact-head AI reviews on PR updates - #339

Merged
khaliqgant merged 2 commits into
mainfrom
hygiene/ai-review-request-workflow
Aug 23, 2026
Merged

ci: request exact-head AI reviews on PR updates#339
khaliqgant merged 2 commits into
mainfrom
hygiene/ai-review-request-workflow

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • add a standalone comment-only pull_request_target workflow for opened, reopened, ready, and synchronized PR heads
  • request both @coderabbitai review and @codex review, stamped with the exact head SHA
  • skip drafts, serialize per PR/head, and grant only issues: write for posting the review-request comment
  • never checkout or execute contributor-controlled code

This is the gap-closing workflow-only split assessed on #207. It intentionally leaves #207 open for its separate durable publisher-identity, retry, recovery, and shutdown work.

Validation

  • workflow YAML parses successfully
  • git diff --check passes
  • security boundary is inspectable in one 36-line workflow: no checkout and no PR-controlled code execution

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@khaliqgant, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dd0e5852-290d-4450-8f01-ddd2a30846e4

📥 Commits

Reviewing files that changed from the base of the PR and between 472c76f and b64a338.

📒 Files selected for processing (1)
  • .github/workflows/request-ai-reviews.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaliqgant

Copy link
Copy Markdown
Member Author

Exact-head review request for 50952f8 (2026-08-23 16:59Z): @codex review

@coderabbitai review

Please review the workflow security boundary in particular: pull_request_target, no checkout or contributor-code execution, least-privilege issue-comment permission, draft skip, and exact-head concurrency/comment stamp.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Changed files:"
git diff --name-status HEAD^ HEAD

echo
echo "Workflow candidates:"
fd -t f -e yml -e yaml .github 2>/dev/null || true

echo
echo "Workflow outlines:"
while IFS= read -r f; do
  ast-grep outline "$f" --items all || true
done < <(fd -t f -e yml -e yaml .github 2>/dev/null)

Length of output: 786


🏁 Script executed:

#!/bin/bash
set -euo pipefail

workflow=".github/workflows/request-ai-reviews.yml"

echo "Workflow outline:"
ast-grep outline "$workflow" --items all || true

echo
echo "Workflow content:"
cat -n "$workflow"

echo
echo "Added diff:"
git diff --no-ext-diff --unified=80 HEAD^ HEAD -- "$workflow"

echo
echo "Execution-related keys in workflow:"
rg -n -i -C2 '(^|[[:space:]])(uses|run|checkout|container|services|defaults|working-directory|shell):' "$workflow" || true

Length of output: 3922


@khaliqgant Reviewed the workflow security boundary. I found no issue.

  • pull_request_target uses the trusted base-branch workflow definition.
  • The workflow has no checkout action.
  • The workflow does not read or execute contributor-controlled repository code.
  • The only shell step formats quoted event values and posts a PR issue comment through gh api.
  • Default permissions are empty. The job grants only contents: read and issues: write.
  • Draft PRs skip the job.
  • The concurrency group includes both the PR number and exact head SHA.
  • The comment includes the exact head SHA in visible text and in the HTML marker.
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@khaliqgant

Copy link
Copy Markdown
Member Author

Exact-head review request for b64a338 (2026-08-23 17:02Z): @codex review

@coderabbitai review

This head removes the unnecessary contents permission. Please review the exact 36-line workflow security boundary; earlier review and CI state is stale.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected_head="b64a338b0b08093ef02fba01585bfbb3e9fb5400"
actual_head="$(git rev-parse HEAD)"
printf 'Expected head: %s\nActual head:   %s\n' "$expected_head" "$actual_head"
if [ "$actual_head" != "$expected_head" ]; then
  echo "ERROR: sandbox is not at the requested PR head" >&2
  exit 2
fi

workflow="$(fd -t f -e yml -e yaml .github/workflows | while IFS= read -r file; do
  if rg -q 'coderabbitai review|`@codex` review|pull_request_target' "$file"; then
    printf '%s\n' "$file"
  fi
done | head -n 1)"

if [ -z "$workflow" ]; then
  echo "ERROR: review-request workflow was not found" >&2
  exit 3
fi

printf '\nWorkflow: %s\n\n' "$workflow"
ast-grep outline "$workflow" --items all || true
printf '\nWorkflow content:\n'
cat -n "$workflow"

printf '\nDiff from first parent:\n'
git diff --check HEAD^ HEAD
git diff --no-ext-diff --unified=80 HEAD^ HEAD -- "$workflow"

printf '\nExecution and permission-related keys:\n'
rg -n -i -C2 '(^|[[:space:]])(permissions|uses|run|checkout|container|services|defaults|working-directory|shell):' "$workflow" || true

printf '\nRequired security-boundary fields:\n'
rg -n -C2 'pull_request_target|draft|concurrency|head\.sha|head\.ref|issues:[[:space:]]*write|gh[[:space:]]+api|comments' "$workflow" || true

printf '\nYAML parse check:\n'
python3 - "$workflow" <<'PY'
import sys
from pathlib import Path
try:
    import yaml
except ImportError:
    print("PyYAML is unavailable; parser check could not run.")
    raise SystemExit(0)
with Path(sys.argv[1]).open() as f:
    yaml.safe_load(f)
print("YAML parsed successfully.")
PY

Length of output: 2400


🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected_head="b64a338b0b08093ef02fba01585bfbb3e9fb5400"
test "$(git rev-parse HEAD)" = "$expected_head"

mapfile -t workflows < <(
  fd -t f -e yml -e yaml . .github/workflows 2>/dev/null |
  while IFS= read -r file; do
    if rg -q 'coderabbitai review|`@codex` review|pull_request_target' "$file"; then
      printf '%s\n' "$file"
    fi
  done
)

printf 'Matching workflow files:\n'
printf '%s\n' "${workflows[@]}"

if [ "${`#workflows`[@]}" -ne 1 ]; then
  echo "ERROR: expected exactly one matching workflow" >&2
  exit 3
fi
workflow="${workflows[0]}"

printf '\nWorkflow outline:\n'
ast-grep outline "$workflow" --items all || true

printf '\nWorkflow content:\n'
cat -n "$workflow"

printf '\nDiff and whitespace validation:\n'
git diff --check HEAD^ HEAD
git diff --no-ext-diff --unified=80 HEAD^ HEAD -- "$workflow"

printf '\nExecution- and permission-related keys:\n'
rg -n -i -C2 '(^|[[:space:]])(permissions|uses|run|checkout|container|services|defaults|working-directory|shell):' "$workflow" || true

printf '\nSecurity-boundary fields:\n'
rg -n -C2 'pull_request_target|draft|concurrency|head\.sha|issues:[[:space:]]*write|gh[[:space:]]+api|comments' "$workflow" || true

printf '\nYAML parse check:\n'
python3 - "$workflow" <<'PY'
import sys
from pathlib import Path

try:
    import yaml
except ImportError:
    print("PyYAML is unavailable; parser check could not run.")
    raise SystemExit(0)

with Path(sys.argv[1]).open(encoding="utf-8") as file:
    yaml.safe_load(file)
print("YAML parsed successfully.")
PY

Length of output: 1919


🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected_head="b64a338b0b08093ef02fba01585bfbb3e9fb5400"
actual_head="$(git rev-parse HEAD)"
if [ "$actual_head" != "$expected_head" ]; then
  echo "ERROR: expected $expected_head but found $actual_head" >&2
  exit 2
fi

workflow="$(
  fd -t f -e yml -e yaml . .github/workflows 2>/dev/null |
  while IFS= read -r file; do
    if rg -q 'coderabbitai review|`@codex` review|pull_request_target' "$file"; then
      printf '%s\n' "$file"
    fi
  done
)"

count="$(printf '%s\n' "$workflow" | sed '/^$/d' | wc -l | tr -d ' ')"
printf 'Matching workflow files:\n%s\n' "$workflow"
if [ "$count" != "1" ]; then
  echo "ERROR: expected exactly one matching workflow; found $count" >&2
  exit 3
fi

printf '\nWorkflow content:\n'
cat -n "$workflow"

printf '\nDiff and whitespace validation:\n'
git diff --check HEAD^ HEAD
git diff --no-ext-diff --unified=80 HEAD^ HEAD -- "$workflow"

printf '\nExecution- and permission-related keys:\n'
rg -n -i -C2 '(^|[[:space:]])(permissions|uses|run|checkout|container|services|defaults|working-directory|shell):' "$workflow" || true

printf '\nSecurity-boundary fields:\n'
rg -n -C2 'pull_request_target|draft|concurrency|head\.sha|issues:[[:space:]]*write|gh[[:space:]]+api|comments' "$workflow" || true

printf '\nYAML parse check:\n'
python3 - "$workflow" <<'PY'
import sys
from pathlib import Path

try:
    import yaml
except ImportError:
    print("PyYAML is unavailable; parser check could not run.")
    raise SystemExit(0)

with Path(sys.argv[1]).open(encoding="utf-8") as file:
    yaml.safe_load(file)
print("YAML parsed successfully.")
PY

Length of output: 6488


@khaliqgant Reviewed b64a338b0b08093ef02fba01585bfbb3e9fb5400. I found no issue in .github/workflows/request-ai-reviews.yml.

  • pull_request_target runs for the required PR events.
  • The workflow has no checkout step.
  • The workflow does not execute contributor-controlled repository code.
  • Root permissions are empty.
  • The request job has only issues: write.
  • The job skips draft PRs.
  • The concurrency group contains the PR number and exact head SHA.
  • The posted comment and HTML marker contain the exact head SHA.
  • git diff --check passed.
  • The independent YAML parser check was inconclusive because PyYAML is unavailable. The workflow structure is otherwise valid on inspection.
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: b64a338b0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@khaliqgant

Copy link
Copy Markdown
Member Author

Pre-merge gate at exact head b64a338b0b08093ef02fba01585bfbb3e9fb5400 (2026-08-23 17:07Z): all five CI jobs green; zero unresolved threads; exact-head Codex clean; CodeRabbit exact-head workflow analysis found no issue but reported the account review limit; non-draft; MERGEABLE/CLEAN. The repository-mandated Veto MCP tools are not exposed in this session and no Veto CLI is installed, so veto_diff_review could not be invoked. Fallback inspection covered the complete one-file diff, git diff --check, the pull_request_target trust boundary, permissions, contributor-input execution paths, and secret-pattern scan; all clean.

@khaliqgant
khaliqgant merged commit aa2a406 into main Aug 23, 2026
8 checks passed
@khaliqgant
khaliqgant deleted the hygiene/ai-review-request-workflow branch August 23, 2026 17:07
@khaliqgant

Copy link
Copy Markdown
Member Author

Post-merge live validation correction (2026-08-23): this workflow's supported scope is CodeRabbit only, not both AI reviewers.

Run 32655006792 proved the combined-permission workflow can post as github-actions[bot]. CodeRabbit accepted the exact-head request. Codex rejected that actor with “create a Codex account and connect to github,” so a GITHUB_TOKEN-authored @codex review cannot replace the mandatory human-authored exact-head Codex request and would add noise on every sync.

PR #340 both fixes the live 403 (the repository empirically requires issues: write plus pull-requests: write) and removes the unsupported Codex mention/renames the workflow to match reality. Until #340 lands, this merged workflow remains nonfunctional because the comment POST gets HTTP 403.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

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