Skip to content

fix(dev-lead): add chatgpt-codex-connector[bot] to TRUSTED_BOTS + fix pre-existing test failures - #291

Merged
don-petry merged 3 commits into
mainfrom
fix/issue-290-codex-trusted-bot
May 19, 2026
Merged

fix(dev-lead): add chatgpt-codex-connector[bot] to TRUSTED_BOTS + fix pre-existing test failures#291
don-petry merged 3 commits into
mainfrom
fix/issue-290-codex-trusted-bot

Conversation

@don-petry

Copy link
Copy Markdown
Collaborator

Fixes #290

Summary

  • Root cause: chatgpt-codex-connector[bot] was not in the TRUSTED_BOTS default list, so dev-lead-intent.sh was classifying its pull_request_review_comment events as skip/no-trigger-or-untrusted instead of fix-reviews
  • Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default in dev-lead.yml
  • Adds test fixtures and test cases for codex bot review and review-comment events
  • Fixes 3 pre-existing test fixture bugs (missing author_association on comment objects causing human-trigger tests to fail)
  • Fixes pre-existing _get_env helper bug in test_intent_ci.bats and test_intent_issue.batsINTENT_CONTEXT is written in GitHub Actions multiline heredoc format (KEY<<DELIM) but the helper only parsed KEY=value format
  • Fixes pre-existing copilot rate-limit test failures: tests were creating standalone copilot stubs but the engine uses gh copilot; updated to set COPILOT_GITHUB_TOKEN and stub gh copilot calls correctly; use case "$1" to guard copilot dispatch before pattern-matching on full args (prompt text may contain "graphql")

All 116 unit tests now pass (was 18 failing before this PR).

Test plan

🤖 Generated with Claude Code

don-petry and others added 3 commits May 19, 2026 07:16
When copilot_chat passes the full prompt via -p, the prompt text itself
may contain "graphql" causing gh stubs with *"graphql"* patterns to match
copilot invocations instead of actual gh api graphql calls. Check \$1
(the subcommand) first so copilot calls are handled before pattern matching
on the full argument string.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 19, 2026 12:20
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@don-petry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 56 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 38f3ae06-1a86-4e60-b5fa-5519fd2d0ee9

📥 Commits

Reviewing files that changed from the base of the PR and between 31d9e9d and 229c300.

📒 Files selected for processing (12)
  • .github/workflows/dev-lead.yml
  • tests/dev-lead/fixtures/events/issue_comment_human_trigger.json
  • tests/dev-lead/fixtures/events/pr_review_codex_commented.json
  • tests/dev-lead/fixtures/events/pr_review_comment_codex.json
  • tests/dev-lead/fixtures/events/pr_review_comment_human_trigger.json
  • tests/dev-lead/unit/test_engine_fallback.bats
  • tests/dev-lead/unit/test_engine_writer.bats
  • tests/dev-lead/unit/test_fix_ci.bats
  • tests/dev-lead/unit/test_fix_reviews.bats
  • tests/dev-lead/unit/test_intent_ci.bats
  • tests/dev-lead/unit/test_intent_issue.bats
  • tests/dev-lead/unit/test_intent_reviews.bats
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-290-codex-trusted-bot

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 and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry merged commit 237618d into main May 19, 2026
19 checks passed
@don-petry
don-petry deleted the fix/issue-290-codex-trusted-bot branch May 19, 2026 12:21

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the test suite to simulate GitHub Copilot interactions via the gh CLI, adds support for the chatgpt-codex-connector[bot], and improves environment variable parsing in tests. Review feedback highlighted the need for more robust argument checking in CLI stubs to avoid false positives caused by prompt text and suggested centralizing the _get_env helper to reduce code duplication.

Comment on lines +303 to 314
export COPILOT_GITHUB_TOKEN="stub-token"
cat > "$STUB_BIN_DIR/gh" << 'GHEOF'
#!/usr/bin/env bash
case "$*" in
*"issues/42/comments"*) echo "[]" ;;
*"pr checkout"*) exit 0 ;;
*"pr comment"*) echo "COMMENT_POSTED: $*"; exit 0 ;;
*"run view"*) echo "log output" ;;
*"copilot"*) echo "rate limit exceeded"; exit 1 ;;
*) echo "{}" ;;
esac
GHEOF

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The gh stub uses pattern matching on the full argument string ($*) to detect copilot calls. As correctly identified in other parts of this PR (e.g., test_fix_reviews.bats), the prompt text passed via the -p flag can contain arbitrary strings like issues/42/comments, which would cause a false positive match in the preceding cases. It is safer to check the first argument ($1) specifically for the copilot command before falling back to pattern matching on the full argument string.

  export COPILOT_GITHUB_TOKEN="stub-token"
  cat > "$STUB_BIN_DIR/gh" << 'GHEOF'
#!/usr/bin/env bash
case "$1" in
  copilot) echo "rate limit exceeded"; exit 1 ;;
esac
case "$*" in
  *"issues/42/comments"*) echo "[]" ;;
  *"pr checkout"*) exit 0 ;;
  *"pr comment"*) echo "COMMENT_POSTED: $*"; exit 0 ;;
  *"run view"*) echo "log output" ;;
  *) echo "{}" ;;
esac
GHEOF

Comment on lines +228 to +229
*"copilot"*)
echo "hit your limit"; exit 1 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This stub implementation is inconsistent with the more robust pattern introduced elsewhere in this file (e.g., at line 177). Matching *"copilot"* against the full argument string is risky because the prompt text might contain patterns that match other cases (like pulls/ at line 226). Please use the $1 check at the top of the stub to reliably identify the command.

Comment on lines +322 to +323
*"copilot"*)
echo "rate limit exceeded"; exit 1 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the issue at line 228, this stub should use a $1 check for copilot at the top of the script to avoid false positives from the prompt text matching other patterns in the case block.

Comment on lines +23 to +31
# Handle multiline heredoc format: KEY<<DELIM\nvalue\nDELIM
local delim_line delimiter
delim_line=$(grep "^${key}<<" "$GITHUB_ENV" 2>/dev/null | head -1)
if [ -n "$delim_line" ]; then
delimiter="${delim_line#*<<}"
awk -v start="${key}<<${delimiter}" -v end="${delimiter}" \
'found && $0==end{exit} found{print} $0==start{found=1}' "$GITHUB_ENV"
return
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _get_env helper logic for handling multiline heredocs is duplicated across test_intent_ci.bats and test_intent_issue.bats, but remains un-updated in test_intent_reviews.bats. While functional, this duplication makes maintenance harder. Consider centralizing this helper if the test framework allows, or at least ensuring consistency across all intent test files to avoid confusing behavior when inspecting INTENT_CONTEXT.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates dev-lead’s trust configuration and test suite so review/review-comment events from chatgpt-codex-connector[bot] route to fix-reviews, while also repairing several previously failing unit tests/fixtures and Copilot rate-limit stubbing.

Changes:

  • Add chatgpt-codex-connector[bot] to the default TRUSTED_BOTS list (and add unit tests/fixtures to cover codex review + review-comment events).
  • Fix unit test fixture data to include required author_association fields for human-trigger scenarios.
  • Update bats helpers/stubs to correctly parse multiline GITHUB_ENV heredocs and to stub gh copilot (with COPILOT_GITHUB_TOKEN) in rate-limit scenarios.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/dev-lead.yml Adds codex bot to default TRUSTED_BOTS for the main dev-lead workflow.
tests/dev-lead/unit/test_intent_reviews.bats Extends trusted bot list for unit tests and adds new codex routing test cases.
tests/dev-lead/unit/test_intent_issue.bats Fixes _get_env helper to parse multiline heredoc entries from GITHUB_ENV.
tests/dev-lead/unit/test_intent_ci.bats Same _get_env heredoc parsing fix for CI intent tests.
tests/dev-lead/unit/test_fix_reviews.bats Adjusts rate-limit tests to stub gh copilot correctly and sets COPILOT_GITHUB_TOKEN.
tests/dev-lead/unit/test_fix_ci.bats Updates GH stubs to simulate Copilot rate-limit behavior via gh copilot.
tests/dev-lead/unit/test_engine_writer.bats Aligns Copilot writer tests with the gh copilot invocation path and token requirement.
tests/dev-lead/unit/test_engine_fallback.bats Aligns Copilot fallback test with gh copilot and rate-limit text detection.
tests/dev-lead/fixtures/events/pr_review_comment_human_trigger.json Adds missing comment.author_association for human-trigger routing correctness.
tests/dev-lead/fixtures/events/issue_comment_human_trigger.json Adds missing comment.author_association for human-trigger routing correctness.
tests/dev-lead/fixtures/events/pr_review_comment_codex.json New fixture for codex PR review-comment event.
tests/dev-lead/fixtures/events/pr_review_codex_commented.json New fixture for codex PR review (COMMENTED) event.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

env:
BOT_USER: ${{ vars.BOT_USER || 'donpetry-bot' }}
TRUSTED_BOTS: ${{ vars.TRUSTED_BOTS || 'copilot-pull-request-reviewer[bot],gemini-code-assist[bot],sonarqubecloud[bot],coderabbitai[bot]' }}
TRUSTED_BOTS: ${{ vars.TRUSTED_BOTS || 'copilot-pull-request-reviewer[bot],gemini-code-assist[bot],sonarqubecloud[bot],coderabbitai[bot],chatgpt-codex-connector[bot]' }}
don-petry added a commit that referenced this pull request Jun 7, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 7, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 8, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 12, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 14, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 18, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 25, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
don-petry added a commit that referenced this pull request Jun 25, 2026
… test suite (#291)

Fixes #290

- Adds chatgpt-codex-connector[bot] to the TRUSTED_BOTS default so codex review comments trigger fix-reviews intent
- Adds test fixtures and cases for codex bot events
- Fixes 18 pre-existing test failures: human-trigger fixture missing author_association, _get_env heredoc parsing, copilot rate-limit stubs using wrong binary
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.

dev-lead not handling codex comments

2 participants