Skip to content

Replace bare git push with Claude-driven push phase in review-agent#80412

Open
enxebre wants to merge 6 commits into
openshift:mainfrom
enxebre:enxebre/review-agent-claude-push-phase
Open

Replace bare git push with Claude-driven push phase in review-agent#80412
enxebre wants to merge 6 commits into
openshift:mainfrom
enxebre:enxebre/review-agent-claude-push-phase

Conversation

@enxebre

@enxebre enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member

The push step now uses Claude to handle push failures (e.g., pre-push hooks, branch constraints) with up to 3 retries and minimal fixes, matching the agentic pattern used in other phases of the review-agent.

Summary by CodeRabbit

This PR updates the HyperShift review-agent ci-operator step (ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh) to replace direct git pushes with a Claude-driven push phase and to harden Claude integration across the review-agent phases.

What changed in practical terms

  • Replaces the final direct git push (git push --force-with-lease) with a Claude-driven push phase that:
    • Invokes Claude to perform the push and handle push failures (pre-push hooks, branch constraints, rejected leases).
    • Retries up to 3 times and can apply minimal automated fixes when Claude indicates required actions.
    • Tees Claude stream-json output to per-PR temp files, copies them into ARTIFACT_DIR, and determines success using PIPESTATUS[0] after tee.
  • Standardizes Claude handling across agent phases (rebase conflict resolution, review, CI-fix, push):
    • All Claude invocations now tee stream-json to /tmp per-PR files and are persisted into ARTIFACT_DIR.
    • Exit codes are captured from PIPESTATUS[0] after piping through tee; success/failure reporting and log tails are adjusted accordingly (shorter tails on success, longer on failures).
  • Git SHA handling for push attempts:
    • Fetches upstream/<BASE_BRANCH> and exports PULL_BASE_SHA via git merge-base HEAD upstream/<BASE_BRANCH> (falls back to HEAD~5 if unavailable) and PULL_PULL_SHA via git rev-parse HEAD so push attempts are based on repository state rather than possibly mismatched CI-provided SHAs.
  • State persistence and observability:
    • Writes per-PR STATE_FILE and actions JSON earlier after phase completion to avoid losing state in noisy runs.
    • Copies tee'd Claude stream-json artifacts into ARTIFACT_DIR and prints concise tails on success or longer tails on failures to aid debugging.

Why this matters for the repo/CI

  • Affects the HyperShift review-agent CI step in the openshift/release repo: introduces an agentic, Claude-driven push flow with retries and minimal remediation, reducing failures caused by push-side checks and improving observability for post-review pushes.
  • Makes automated PR maintenance more robust against push-related failures and easier to debug by preserving Claude stream-json artifacts and saving state earlier.

Files affected

  • ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh — primary behavioral changes to Claude integration and push flow.

Other notable details

  • Commit messages include a shellcheck fix and co-author metadata for "Claude Opus 4.6".
  • Net diff is modest (+74/-18) but the changes materially alter how the review-agent performs and reports pushes.

The push step now uses Claude to handle push failures (e.g., pre-push
hooks, branch constraints) with up to 3 retries and minimal fixes,
matching the agentic pattern used in other phases of the review-agent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Standardizes Claude usage to pipe stream-json through tee and derive phase exit codes from PIPESTATUS[0]; replaces direct git push with a Claude-driven push phase that persists push artifacts and reports diagnostics.

Changes

Review agent process updates

Layer / File(s) Summary
Rebase conflict resolution
ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh
Rebase conflict handling now pipes Claude output through tee, persists stream-json artifacts, and reads Claude exit status from PIPESTATUS[0].
Review phase stream capture
ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh
Review phase no longer captures Claude into a variable; it pipes stream-json through tee, saves to /tmp/claude-pr-<PR>-output.json, derives exit code from PIPESTATUS[0], copies artifact into ${ARTIFACT_DIR}, and prints tail excerpts on success/failure.
CI-fix stream capture and failure reporting
ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh
CI-fix now pipes Claude output through tee, saves stream-json to a temp artifact, uses PIPESTATUS[0] for exit status, and logs exit code plus the last 20 lines of the saved output on failure.
Claude-driven push phase with retry and diagnostics
ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh
Replaces git push --force-with-lease with a Claude-driven push orchestration (up to 3 attempts). Fetches upstream/<BASE_BRANCH>, sets PULL_BASE_SHA (merge-base fallback to HEAD~5) and PULL_PULL_SHA (HEAD), tees push stream-json to /tmp/claude-pr-<PR>-push-output.json, copies artifacts to ${ARTIFACT_DIR}, and uses PIPESTATUS[0] for push success/failure.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes


Important

Pre-merge checks failed

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

❌ Failed checks (1 error)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error GitHub token is embedded in git credential helper shell command (line 817) that Claude may invoke. With --verbose mode and Bash tool access, error output could expose plaintext GITHUB_TOKEN_FORK to... Use environment variable-based credential helper or store credentials in a secured file instead of embedding tokens in git config command.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing a direct git push with a Claude-driven push phase, which is the primary modification described in the PR objectives and changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Stable And Deterministic Test Names ✅ Passed PR modifies only a Bash shell script with no Ginkgo tests present; custom check for test name stability is not applicable.
Test Structure And Quality ✅ Passed PR modifies a bash script (hypershift-review-agent-process-commands.sh) with no Ginkgo tests. Custom check for test structure is inapplicable.
Microshift Test Compatibility ✅ Passed PR modifies a Bash CI/CD script, not Ginkgo e2e tests. Check for MicroShift test compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR modifies only a Bash CI/CD script (.sh), not Go e2e tests. The SNO compatibility check applies only to Ginkgo e2e tests (It, Describe, Context, etc.); none are present here.
Topology-Aware Scheduling Compatibility ✅ Passed The PR modifies a CI/automation bash script (hypershift-review-agent-process-commands.sh), not deployment manifests, operator code, or controllers. No scheduling constraints, affinity rules, or top...
Ote Binary Stdout Contract ✅ Passed The custom check targets OTE Go binaries with stdout JSON communication. The PR only modifies a Bash script (hypershift-review-agent-process-commands.sh) used in CI, not a Go OTE binary. Check is n...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR modifies a Bash shell script (hypershift-review-agent-process-commands.sh), not Ginkgo e2e tests. The custom check requires verification of new Ginkgo e2e tests for IPv4 assumptions and exte...
No-Weak-Crypto ✅ Passed No weak cryptography (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB) or insecure secret comparisons detected. The only crypto usage is SHA256 with RSA for JWT signing, which is cryptographically sound a...
Container-Privileges ✅ Passed PR modifies only a bash script, not container/K8s manifests. The container-privileges check applies to YAML manifests with security-sensitive configurations, which are not present in this change.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from bryan-cox and celebdor June 11, 2026 11:48
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 11, 2026
@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/rehearse address-review-comments

@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

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

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
`@ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh`:
- Around line 1305-1333: The script currently persists raw Claude transcripts
(PUSH_RESULT and /tmp/claude-pr-${PR_NUMBER}-push-output.json) while the fork
token is stored in git's printable credential.helper, risking credential
leakage; remove/stop writing raw transcripts to ARTIFACT_DIR and CI logs and
instead save only a redacted summary via extract_claude_summary, restrict the
temporary file's permissions, and move the fork token out of printable git
config into a non-printable helper (e.g., an askpass/helper script with
restrictive perms) so Claude cannot read credentials. Concretely: stop copying
/tmp/claude-pr-*-push-output.json to "${ARTIFACT_DIR}", ensure
extract_claude_summary produces and copies the sanitized
"${SHARED_DIR}/claude-pr-*-push-summary.json" only, do not echo or tail raw
$PUSH_RESULT to logs (replace those echo/tail lines with logging the redacted
summary), set restrictive mode (chmod 600) on any temp files, and change git
config usage of credential.helper to use an askpass/helper script instead of
embedding the fork token in the printable credential.helper.
- Around line 1323-1335: After PUSH_EXIT == 0, verify the remote branch actually
advanced by comparing the remote ref to the local HEAD (use git ls-remote origin
"${BRANCH_NAME}" and compare the returned commit hash to git rev-parse HEAD or
perform a git fetch origin "${BRANCH_NAME}" and compare
refs/remotes/origin/"${BRANCH_NAME}" to HEAD); if the hashes differ, treat the
push as failed: print a clear diagnostic (include PUSH_RESULT tail output and
the remote vs local hashes) and set PR_HAD_ERROR=true, otherwise proceed to
print the existing success messages for PR_NUMBER.
🪄 Autofix (Beta)

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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 18338b51-3a63-4141-9bab-0e8582aeca45

📥 Commits

Reviewing files that changed from the base of the PR and between 1c35f9f and 45cba0a.

📒 Files selected for processing (1)
  • ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh

Comment on lines +1305 to +1333
PUSH_RESULT=$(claude -p "$PUSH_USER_PROMPT" \
--system-prompt "$PUSH_SYSTEM_PROMPT" \
--allowedTools "Bash Read Write Edit Grep Glob" \
--max-turns 60 \
--effort max \
--model "$CLAUDE_MODEL" \
--verbose \
--output-format stream-json \
< /dev/null \
2>&1 | tee "/tmp/claude-pr-${PR_NUMBER}-push-output.json")
PUSH_EXIT=$?
set -e

if [ -f "/tmp/claude-pr-${PR_NUMBER}-push-output.json" ]; then
cp "/tmp/claude-pr-${PR_NUMBER}-push-output.json" "${ARTIFACT_DIR}/claude-pr-${PR_NUMBER}-push-output.json"
extract_claude_summary "/tmp/claude-pr-${PR_NUMBER}-push-output.json" "${SHARED_DIR}/claude-pr-${PR_NUMBER}-push-summary.json"
fi

if [ $PUSH_EXIT -eq 0 ]; then
echo "Push completed for PR #$PR_NUMBER"
echo "Push phase succeeded for PR #$PR_NUMBER"
echo ""
echo "--- Claude push output for PR #$PR_NUMBER ---"
echo "$PUSH_RESULT" | tail -50
echo "--- End Claude push output ---"
echo ""
else
echo "Push failed for PR #$PR_NUMBER"
echo "Push phase failed for PR #$PR_NUMBER"
echo "Error output (last 20 lines):"
echo "$PUSH_RESULT" | tail -20

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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Don’t persist raw Claude push transcripts while the fork token is stored in printable git config.

At Line 817 the fork token is embedded directly in credential.helper. This new phase then gives Claude Bash access to diagnose push failures and copies/prints the raw transcript at Lines 1318-1333. If Claude ever inspects git config while debugging, that helper value will be written into artifacts/logs as a live push credential. The prompt ban on credential inspection is not an enforcement boundary; move auth out of printable git config (for example, an askpass/helper script with restricted permissions) and only persist a redacted summary here.

As per coding guidelines, step-registry command scripts must never print sensitive information to logs and should exclude sensitive credentials from CI logs.

🤖 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
`@ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh`
around lines 1305 - 1333, The script currently persists raw Claude transcripts
(PUSH_RESULT and /tmp/claude-pr-${PR_NUMBER}-push-output.json) while the fork
token is stored in git's printable credential.helper, risking credential
leakage; remove/stop writing raw transcripts to ARTIFACT_DIR and CI logs and
instead save only a redacted summary via extract_claude_summary, restrict the
temporary file's permissions, and move the fork token out of printable git
config into a non-printable helper (e.g., an askpass/helper script with
restrictive perms) so Claude cannot read credentials. Concretely: stop copying
/tmp/claude-pr-*-push-output.json to "${ARTIFACT_DIR}", ensure
extract_claude_summary produces and copies the sanitized
"${SHARED_DIR}/claude-pr-*-push-summary.json" only, do not echo or tail raw
$PUSH_RESULT to logs (replace those echo/tail lines with logging the redacted
summary), set restrictive mode (chmod 600) on any temp files, and change git
config usage of credential.helper to use an askpass/helper script instead of
embedding the fork token in the printable credential.helper.

Source: Coding guidelines

Comment on lines 1323 to 1335
if [ $PUSH_EXIT -eq 0 ]; then
echo "Push completed for PR #$PR_NUMBER"
echo "Push phase succeeded for PR #$PR_NUMBER"
echo ""
echo "--- Claude push output for PR #$PR_NUMBER ---"
echo "$PUSH_RESULT" | tail -50
echo "--- End Claude push output ---"
echo ""
else
echo "Push failed for PR #$PR_NUMBER"
echo "Push phase failed for PR #$PR_NUMBER"
echo "Error output (last 20 lines):"
echo "$PUSH_RESULT" | tail -20
PR_HAD_ERROR=true
fi

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Verify the remote branch before marking the push phase successful.

Right now Line 1323 treats Claude exit code 0 as proof that the push happened. That is weaker than the old direct git push contract: Claude can exit cleanly after diagnosing a failure or making local fixes without ever advancing origin/${BRANCH_NAME}, and this script will still write a success state for the PR. Add an explicit remote check here (git ls-remote origin "${BRANCH_NAME}" vs git rev-parse HEAD, or fetch and compare) before reporting success.

🛠 Suggested guard
-    if [ $PUSH_EXIT -eq 0 ]; then
+    if [ $PUSH_EXIT -eq 0 ]; then
+      REMOTE_SHA=$(git ls-remote --heads origin "$BRANCH_NAME" | awk '{print $1}')
+      HEAD_SHA=$(git rev-parse HEAD)
+      if [ -z "$REMOTE_SHA" ] || [ "$REMOTE_SHA" != "$HEAD_SHA" ]; then
+        echo "Push verification failed for PR #$PR_NUMBER: remote branch was not updated"
+        PUSH_EXIT=1
+      fi
+    fi
+
+    if [ $PUSH_EXIT -eq 0 ]; then
       echo "Push phase succeeded for PR #$PR_NUMBER"

Based on the step reference and PR objective, this phase is responsible for actually pushing changes back to the fork.

🤖 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
`@ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh`
around lines 1323 - 1335, After PUSH_EXIT == 0, verify the remote branch
actually advanced by comparing the remote ref to the local HEAD (use git
ls-remote origin "${BRANCH_NAME}" and compare the returned commit hash to git
rev-parse HEAD or perform a git fetch origin "${BRANCH_NAME}" and compare
refs/remotes/origin/"${BRANCH_NAME}" to HEAD); if the hashes differ, treat the
push as failed: print a clear diagnostic (include PUSH_RESULT tail output and
the remote vs local hashes) and set PR_HAD_ERROR=true, otherwise proceed to
print the existing success messages for PR_NUMBER.

@bryan-cox bryan-cox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 11, 2026
@openshift-ci

openshift-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, enxebre

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/pj-rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@enxebre: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

- Use ${PIPESTATUS[0]} instead of $? to capture claude's exit code
  rather than tee's (which is always 0). Fixes all 4 phases: rebase,
  review, CI fix, and push.
- Pre-compute PULL_BASE_SHA/PULL_PULL_SHA from local git history before
  push so gitlint resolves commit ranges on the first attempt. CI sets
  these env vars to commits from the rehearsal repo (openshift/release),
  not hypershift, causing gitlint to fail with "Invalid revision range".
- Read phase output from tee'd files instead of $RESULT variables that
  are no longer captured in command substitution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 11, 2026
@openshift-ci

openshift-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

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

Actionable comments posted: 1

🤖 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
`@ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh`:
- Around line 1286-1298: The current code computes PUSH_MERGE_BASE against a
hard-coded origin/main and only documents the gitlint override inside
PUSH_SYSTEM_PROMPT; change it to fetch the actual base ref resolved earlier
(BASE_BRANCH), compute the merge base from that fetched ref and HEAD (set
PUSH_MERGE_BASE=$(git merge-base HEAD <fetched-base-ref> || echo "HEAD~5")), set
PUSH_HEAD_SHA from git rev-parse HEAD as now (PUSH_HEAD_SHA), and export the
environment variables PULL_BASE_SHA=${PUSH_MERGE_BASE} and
PULL_PULL_SHA=${PUSH_HEAD_SHA} before Claude/agent runs so retries that run
plain git push inherit the overrides; keep PUSH_SYSTEM_PROMPT for instruction
text but do not rely on it as the sole mechanism.
🪄 Autofix (Beta)

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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f0620944-9a1a-4c6b-99ba-8a742cca2c5a

📥 Commits

Reviewing files that changed from the base of the PR and between 45cba0a and 5e15718.

📒 Files selected for processing (1)
  • ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh

enxebre and others added 2 commits June 11, 2026 17:48
The process step was getting killed while dumping large stream-json
output to the build log, before it could write processed-prs.txt.
This left the report step with no data to generate a report from.

Move STATE_FILE and actions JSON writes to immediately after phase
completion, before the output dump section. Also reduce tail lines
from 50 to 10 since each stream-json line can be 10KB+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address CodeRabbit review: use the PR's actual base branch instead of
hardcoded origin/main for the merge-base computation, and export
PULL_BASE_SHA/PULL_PULL_SHA so all git push invocations (including
retries) inherit them without relying on prompt instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/pj-rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@enxebre: your /pj-rehearse request was not processed because the request waited in queue for longer than 5 minutes. Please retry in a few minutes.

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

Caution

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

⚠️ Outside diff range comments (1)
ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh (1)

1286-1308: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Wrap git push in a guarded helper instead of encoding the contract in prompt text.

PULL_BASE_SHA/PULL_PULL_SHA are exported once before Claude starts, but this prompt explicitly allows commit rewrites and retries. After an amend/fixup, later pushes still inherit the old range, so hook checks can validate the wrong commits. The "Maximum 3 push attempts" limit is also only advisory right now—nothing in the shell stops a fourth push.

🛠 Suggested approach
+    cat > /tmp/git-push-guard.sh <<EOF
+#!/bin/bash
+set -euo pipefail
+attempt_file="/tmp/pr-${PR_NUMBER}-push-attempts"
+attempt=$(( $(cat "$attempt_file" 2>/dev/null || echo 0) + 1 ))
+if [ "$attempt" -gt 3 ]; then
+  echo "push attempt limit exceeded" >&2
+  exit 1
+fi
+echo "$attempt" > "$attempt_file"
+export PULL_BASE_SHA="$(git merge-base HEAD "upstream/${BASE_BRANCH}" 2>/dev/null || echo HEAD~5)"
+export PULL_PULL_SHA="$(git rev-parse HEAD)"
+exec git push --force-with-lease origin "${BRANCH_NAME}"
+EOF
+    chmod +x /tmp/git-push-guard.sh
@@
-- Push command: git push --force-with-lease origin ${BRANCH_NAME}
-  PULL_BASE_SHA and PULL_PULL_SHA are already exported in the environment.
+- Push command: /tmp/git-push-guard.sh

Also applies to: 1313-1325

🤖 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
`@ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh`
around lines 1286 - 1308, Replace the inline push logic in the prompt by adding
a guarded helper function (e.g., push_with_retries or guarded_push) that
encapsulates the git push contract (uses git push --force-with-lease origin
${BRANCH_NAME}), enforces the MAX_ATTEMPTS (3) loop, re-exports/updates
PULL_BASE_SHA and PULL_PULL_SHA before each attempt (so amended commits get
correct range), inspects push failure output to detect hook/branch errors and
returns actionable failure codes, attempts minimal automated fixes only when a
specific hook error is detected, retries up to MAX_ATTEMPTS, and returns
non-zero if all attempts fail; update PUSH_SYSTEM_PROMPT to reference this
helper rather than encoding retry/max rules. Ensure the helper name
(push_with_retries or guarded_push), the push command string, and the variables
PULL_BASE_SHA and PULL_PULL_SHA are used so callers can find and invoke the new
function.
🤖 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
`@ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh`:
- Around line 1286-1308: Replace the inline push logic in the prompt by adding a
guarded helper function (e.g., push_with_retries or guarded_push) that
encapsulates the git push contract (uses git push --force-with-lease origin
${BRANCH_NAME}), enforces the MAX_ATTEMPTS (3) loop, re-exports/updates
PULL_BASE_SHA and PULL_PULL_SHA before each attempt (so amended commits get
correct range), inspects push failure output to detect hook/branch errors and
returns actionable failure codes, attempts minimal automated fixes only when a
specific hook error is detected, retries up to MAX_ATTEMPTS, and returns
non-zero if all attempts fail; update PUSH_SYSTEM_PROMPT to reference this
helper rather than encoding retry/max rules. Ensure the helper name
(push_with_retries or guarded_push), the push command string, and the variables
PULL_BASE_SHA and PULL_PULL_SHA are used so callers can find and invoke the new
function.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 032e2fdc-108d-46f5-96b8-4a8bbdec2907

📥 Commits

Reviewing files that changed from the base of the PR and between 2872acb and 20b1ee1.

📒 Files selected for processing (1)
  • ci-operator/step-registry/hypershift/review-agent/process/hypershift-review-agent-process-commands.sh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/pj-rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@enxebre: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

The unguarded git rebase --abort on line 772 was killing the entire
script under set -e when the CI entrypoint wrapper returned non-zero.
This prevented the script from continuing to process remaining PRs
after a rebase conflict. The same command on line 778 already had
|| true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

[REHEARSALNOTIFIER]
@enxebre: the pj-rehearse plugin accommodates running rehearsal tests for the changes in this PR. Expand 'Interacting with pj-rehearse' for usage details. The following rehearsable tests have been affected by this change:

Test name Repo Type Reason
pull-ci-openshift-hypershift-main-address-review-comments openshift/hypershift presubmit Registry content changed
pull-ci-openshift-hypershift-release-5.1-address-review-comments openshift/hypershift presubmit Registry content changed
pull-ci-openshift-hypershift-release-5.0-address-review-comments openshift/hypershift presubmit Registry content changed
pull-ci-openshift-hypershift-release-4.23-address-review-comments openshift/hypershift presubmit Registry content changed
pull-ci-openshift-hypershift-release-4.22-address-review-comments openshift/hypershift presubmit Registry content changed
periodic-ci-openshift-hypershift-main-periodic-review-agent N/A periodic Registry content changed
periodic-ci-openshift-hypershift-release-4.22-periodic-review-agent N/A periodic Registry content changed
Interacting with pj-rehearse

Comment: /pj-rehearse to run up to 5 rehearsals
Comment: /pj-rehearse skip to opt-out of rehearsals
Comment: /pj-rehearse {test-name}, with each test separated by a space, to run one or more specific rehearsals
Comment: /pj-rehearse more to run up to 10 rehearsals
Comment: /pj-rehearse max to run up to 25 rehearsals
Comment: /pj-rehearse auto-ack to run up to 5 rehearsals, and add the rehearsals-ack label on success
Comment: /pj-rehearse list to get an up-to-date list of affected jobs
Comment: /pj-rehearse abort to abort all active rehearsals
Comment: /pj-rehearse network-access-allowed to allow rehearsals of tests that have the restrict_network_access field set to false. This must be executed by an openshift org member who is not the PR author

Once you are satisfied with the results of the rehearsals, comment: /pj-rehearse ack to unblock merge. When the rehearsals-ack label is present on your PR, merge will no longer be blocked by rehearsals.
If you would like the rehearsals-ack label removed, comment: /pj-rehearse reject to re-block merging.

@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/pj-rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@enxebre: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

@enxebre

enxebre commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

/pj-rehearse periodic-ci-openshift-hypershift-main-periodic-review-agent

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

@enxebre: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

@openshift-ci

openshift-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@enxebre: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants