Skip to content

fix(code-review): respect agent execution contexts - #25

Open
esthor wants to merge 7 commits into
mainfrom
esthor/fix-codex-host-auth
Open

fix(code-review): respect agent execution contexts#25
esthor wants to merge 7 commits into
mainfrom
esthor/fix-codex-host-auth

Conversation

@esthor

@esthor esthor commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • verify CodeRabbit CLI authentication from the same execution context that runs the review
  • keep host-native agents on their normal shell and authentication path
  • tell sandboxed agents to use command-scoped host/network approval for the auth check and review
  • inspect the complete selected scope for credentials before transmitting a diff
  • document and forward the current CLI scope flags, including mutually exclusive --base and --base-commit selectors

Why

A restricted command sandbox may not expose authentication already stored by the host CodeRabbit CLI. A sandbox-only preflight can therefore report a false unauthenticated state. Authentication must be checked in the same authoritative execution context that performs the review.

The direct command and reviewer agent now apply the portable skill's credential preflight to the complete selected scope, including untracked files when requested, before invoking CodeRabbit.

Validation

  • CodeRabbit CLI 0.7.1 help confirms --committed, --uncommitted, --include-untracked, --base, --base-commit, and --dir
  • all changed Markdown frontmatter parses as YAML
  • git diff --check
  • host-context coderabbit auth status --agent reused existing authentication
  • hosted CodeRabbit review on exact head c983dcf generated no actionable comments

The repository-level CodeRabbit policy remains isolated in #26.

Summary by CodeRabbit

  • New Features

    • Added support for committed, uncommitted, and untracked review scopes.
    • Added base-commit selection and validation for review requests.
    • Added execution-context authentication checks and guidance for sandboxed environments.
    • Added credential and secret scanning across the selected review scope before submission.
  • Documentation

    • Updated review command usage, supported review types, scope options, installation guidance, and authentication workflows.
    • Clarified that automatic login and sandbox bypasses are not supported.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The review workflow now checks CLI availability and authentication in the execution context. It scans the selected scope for secrets before review execution. Commands use explicit committed, uncommitted, and untracked scope flags with validated base selectors.

Changes

Review workflow and scope updates

Layer / File(s) Summary
Execution-context authentication
skills/code-review/SKILL.md, agents/code-reviewer.md, commands/coderabbit-review.md, README.md
The workflow checks CLI availability and authentication, requires consent, provides sandbox host-context guidance, and scans the selected scope for credentials before review execution.
Explicit review scope
commands/coderabbit-review.md, skills/code-review/SKILL.md
Review types use explicit scope flags. Untracked files are supported. Base branch and base commit selectors are validated as mutually exclusive.
Documentation alignment
CHANGELOG.md
The changelog records the authentication, scope, and credential-preflight updates.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: juanpflores

Poem

A rabbit checks the CLI with care,
Then scans each selected file with care.
Auth stays bound to its context,
Scope flags guide the review path,
Safe changes hop from burrow to branch.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore (reviewers only)

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Agent Guidance Structure ❌ Error The changed agent only documents default coderabbit review --agent and --dir; it omits the canonical skill's scope flags and provides no deterministic credential-scan procedure. Add shared scope parsing and flag forwarding, plus a documented reusable credential-scan tool or script, to the agent and command entry points.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adapting code review execution to respect agent execution contexts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch esthor/fix-codex-host-auth

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@esthor

esthor commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

move the yaml config to its own PR; mark this PR ready for review (not draft)

@esthor esthor left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

address all before mergeable

Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml
Comment thread .coderabbit.yaml
Comment thread .coderabbit.yaml Outdated
@esthor
esthor marked this pull request as ready for review August 7, 2026 02:47
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@esthor

esthor commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Moved the repository CodeRabbit policy to #26 and applied every requested setting there: inheritance disabled, assertive profile, review status/fortune/poem enabled, simplify enabled, one-commit auto-pause, and the request-changes workflow as the all-comments approval gate. PR #25 is now auth-only and ready for review.

@esthor
esthor marked this pull request as draft August 8, 2026 11:00
@esthor esthor changed the title fix(code-review): reuse host authentication in Codex fix(code-review): respect agent execution contexts Aug 8, 2026
@esthor

esthor commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@commands/coderabbit-review.md`:
- Around line 40-61: In commands/coderabbit-review.md at lines 40-61, add a
fail-closed secret/credential preflight over the complete selected review scope,
including untracked files when requested, before invoking coderabbit
"${args[@]}"; stop without running the review when a secret is detected. Apply
the same preflight before coderabbit review --agent in agents/code-reviewer.md
at lines 38-44, preserving each entry point’s existing scope selection and
authentication behavior.
- Around line 40-61: The review command flow must perform the fail-closed secret
preflight before invoking coderabbit with args. Update the Run Review section
around the args construction to apply the complete-scope check from
skills/code-review/SKILL.md for all review types, including untracked files, and
abort rather than running the command when secrets are detected.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 2e6029b1-dd9b-4dee-9613-2382ccbd6706

📥 Commits

Reviewing files that changed from the base of the PR and between bbb4ab2 and 90d32b6.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • README.md
  • agents/code-reviewer.md
  • commands/coderabbit-review.md
  • skills/code-review/SKILL.md
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • coderabbitai/bitbucket (manual)
📜 Review details
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~148-~148: Consider using a different verb for a more formal wording.
Context: ...dings grouped by severity 4. Optionally fix issues and re-review Sandboxed agents ...

(FIX_RESOLVE)

🔇 Additional comments (5)
skills/code-review/SKILL.md (1)

31-74: LGTM!

Also applies to: 83-100, 110-126

README.md (1)

145-154: LGTM!

commands/coderabbit-review.md (2)

3-3: 🎯 Functional Correctness

Keep the base selector consistent with the shared skill.

skills/code-review/SKILL.md documents --base-commit, but this command accepts only --base <branch> and forwards only base. A commit-based review cannot use this entry point. Add a separate base_commit argument and forward --base-commit, or remove that mode from the shared skill.


29-30: LGTM!

Also applies to: 71-72

CHANGELOG.md (1)

21-25: LGTM!

Comment thread commands/coderabbit-review.md
@esthor
esthor marked this pull request as ready for review August 10, 2026 22:36

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CHANGELOG.md (1)

9-12: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the stale policy entry or move it to PR #26.

The PR objective states that the repository-level CodeRabbit policy moved to PR #26. This entry says that this PR added the policy, so the public release history is inaccurate. Remove this entry or record it with the PR that adds the policy.

As per path instructions, public source-of-truth claims must remain accurate and mutually consistent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` around lines 9 - 12, Remove the changelog entry describing the
repository-level CodeRabbit policy, or move it to the release-history entry for
PR `#26`. Ensure the CHANGELOG no longer attributes adding that policy to this PR
and remains consistent with the stated source-of-truth history.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@CHANGELOG.md`:
- Around line 9-12: Remove the changelog entry describing the repository-level
CodeRabbit policy, or move it to the release-history entry for PR `#26`. Ensure
the CHANGELOG no longer attributes adding that policy to this PR and remains
consistent with the stated source-of-truth history.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 3228852e-c028-44bc-92b8-f27cf562f74f

📥 Commits

Reviewing files that changed from the base of the PR and between c983dcf and 3a32e6a.

📒 Files selected for processing (1)
  • CHANGELOG.md
📜 Review details
⚠️ CI failures not shown inline (2)

GitHub Actions: Required approver / verify: fix(code-review): respect agent execution contexts

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1m�[0m
 �[36;1mowner="${REPOSITORY%%/*}"�[0m
 �[36;1mrepo="${REPOSITORY#*/}"�[0m
 �[36;1m�[0m
 �[36;1mresponse="$(�[0m
 �[36;1m  gh api graphql \�[0m
 �[36;1m    -f owner="$owner" \�[0m
 �[36;1m    -f repo="$repo" \�[0m
 �[36;1m    -F number="$PR_NUMBER" \�[0m
 �[36;1m    -f query='�[0m
 �[36;1m      query($owner: String!, $repo: String!, $number: Int!) {�[0m
 �[36;1m        repository(owner: $owner, name: $repo) {�[0m
 �[36;1m          pullRequest(number: $number) {�[0m
 �[36;1m            isDraft�[0m
 �[36;1m            reviews(last: 100) {�[0m
 �[36;1m              nodes {�[0m
 �[36;1m                author {�[0m
 �[36;1m                  login�[0m
 �[36;1m                }�[0m
 �[36;1m                commit {�[0m
 �[36;1m                  oid�[0m
 �[36;1m                }�[0m
 �[36;1m                state�[0m
 �[36;1m                submittedAt�[0m
 �[36;1m              }�[0m
 �[36;1m            }�[0m
 �[36;1m          }�[0m
 �[36;1m        }�[0m
 �[36;1m      }�[0m
 �[36;1m    '�[0m
 �[36;1m)"�[0m
 �[36;1m�[0m
 �[36;1mis_draft="$(jq -r '.data.repository.pullRequest.isDraft' <<<"$response")"�[0m
 �[36;1mif [[ "$is_draft" == "true" ]]; then�[0m
 �[36;1m  echo "Draft PRs cannot merge; approver gate will run when ready for review."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mapproved_by="$(�[0m
 �[36;1m  jq -r \�[0m
 �[36;1m    --arg head "$HEAD_SHA" \�[0m
 �[36;1m    --argjson approvers "$(jq -Rc 'split(",")' <<<"$REQUIRED_APPROVERS")" \�[0m
 �[36;1m    '�[0m
 �[36;1m      .data.repository.pullRequest.reviews.nodes�[0m
 �[36;1m      | map(select((.author.login // "") as $login | $approvers | index($login)))�[0m
 �[36;1m      | sort_by(.author.login)�[0m
 �[36;1m      | group_by(.author.login)�[0m
 �[36;1m      | map(max_by(.submittedAt))�[0m
 �[36;1m      | map(select(.state == "APPROVED" and .commit.oid == $head))�[0m
 �[36;1m      | first.author.login // empty�[0m
 �[36;1m    ...

GitHub Actions: Required approver / 0_verify.txt: fix(code-review): respect agent execution contexts

Conclusion: failure

View job details

##[group]Run set -euo pipefail
 �[36;1mset -euo pipefail�[0m
 �[36;1m�[0m
 �[36;1mowner="${REPOSITORY%%/*}"�[0m
 �[36;1mrepo="${REPOSITORY#*/}"�[0m
 �[36;1m�[0m
 �[36;1mresponse="$(�[0m
 �[36;1m  gh api graphql \�[0m
 �[36;1m    -f owner="$owner" \�[0m
 �[36;1m    -f repo="$repo" \�[0m
 �[36;1m    -F number="$PR_NUMBER" \�[0m
 �[36;1m    -f query='�[0m
 �[36;1m      query($owner: String!, $repo: String!, $number: Int!) {�[0m
 �[36;1m        repository(owner: $owner, name: $repo) {�[0m
 �[36;1m          pullRequest(number: $number) {�[0m
 �[36;1m            isDraft�[0m
 �[36;1m            reviews(last: 100) {�[0m
 �[36;1m              nodes {�[0m
 �[36;1m                author {�[0m
 �[36;1m                  login�[0m
 �[36;1m                }�[0m
 �[36;1m                commit {�[0m
 �[36;1m                  oid�[0m
 �[36;1m                }�[0m
 �[36;1m                state�[0m
 �[36;1m                submittedAt�[0m
 �[36;1m              }�[0m
 �[36;1m            }�[0m
 �[36;1m          }�[0m
 �[36;1m        }�[0m
 �[36;1m      }�[0m
 �[36;1m    '�[0m
 �[36;1m)"�[0m
 �[36;1m�[0m
 �[36;1mis_draft="$(jq -r '.data.repository.pullRequest.isDraft' <<<"$response")"�[0m
 �[36;1mif [[ "$is_draft" == "true" ]]; then�[0m
 �[36;1m  echo "Draft PRs cannot merge; approver gate will run when ready for review."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mapproved_by="$(�[0m
 �[36;1m  jq -r \�[0m
 �[36;1m    --arg head "$HEAD_SHA" \�[0m
 �[36;1m    --argjson approvers "$(jq -Rc 'split(",")' <<<"$REQUIRED_APPROVERS")" \�[0m
 �[36;1m    '�[0m
 �[36;1m      .data.repository.pullRequest.reviews.nodes�[0m
 �[36;1m      | map(select((.author.login // "") as $login | $approvers | index($login)))�[0m
 �[36;1m      | sort_by(.author.login)�[0m
 �[36;1m      | group_by(.author.login)�[0m
 �[36;1m      | map(max_by(.submittedAt))�[0m
 �[36;1m      | map(select(.state == "APPROVED" and .commit.oid == $head))�[0m
 �[36;1m      | first.author.login // empty�[0m
 �[36;1m    ...
🧰 Additional context used
📓 Path-based instructions (1)
{README.md,CHANGELOG.md,DISTRIBUTION_CHANNELS.md}

⚙️ CodeRabbit configuration file

{README.md,CHANGELOG.md,DISTRIBUTION_CHANNELS.md}: Keep public installation commands, release status, and source-of-truth claims accurate and mutually consistent.

Files:

  • CHANGELOG.md
🔇 Additional comments (1)
CHANGELOG.md (1)

25-30: LGTM!

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