Skip to content

🐛 fix(code-review): preserve workflow identity - #42

Merged
xdanger merged 13 commits into
mainfrom
fix/code-review-marker
Aug 13, 2026
Merged

xdanger merged 13 commits into
mainfrom
fix/code-review-marker

Conversation

@xdanger

@xdanger xdanger commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • replace the ambiguous legacy review marker with an exact, human-readable footer while retaining legacy-marker migration support
  • stamp every workflow-created inline comment through a deterministic PreToolUse hook
  • preserve prior workflow threads as a bounded, read-only deduplication index
  • generate randomized, zero-argument wrappers for the history query and current PR diff
  • allow only those two fixed Bash commands and deny every other Bash invocation
  • leave thread replies and resolution to maintainers instead of granting the review agent additional write paths
  • fail closed when required history or diff context cannot be loaded

Validation

  • pnpm lint
  • extracted and executed the complete workflow setup step against PR 🐛 fix(code-review): preserve workflow identity #42
  • confirmed the live GraphQL query returns bounded workflow-owned thread coverage
  • confirmed the live PR diff wrapper returns the current diff
  • confirmed generated control permissions are 400/500/500
  • confirmed footer insertion is exact, CRLF-safe, and idempotent
  • confirmed both bare wrappers are allowed, unexpected arguments are rejected, and every other Bash command is denied
  • confirmed git log --output=... cannot reach its native file-write path

- 🐛 replace the stripped HTML marker with a readable, stable workflow footer
Copilot AI lite review requested due to automatic review settings August 5, 2026 16:15
@xdanger xdanger self-assigned this Aug 5, 2026
@greptile-apps

greptile-apps Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR preserves automated-review ownership through an exact footer and limits review-agent access to fixed, read-only wrappers.

  • Adds a deterministic hook that stamps inline comments and rejects unapproved Bash commands.
  • Loads bounded prior-thread metadata for deduplication without replying to or resolving threads.
  • Replaces broad GitHub and Git command patterns with two zero-argument wrapper scripts.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported footer-matching and concurrent-comment ownership issues are addressed by exact terminal-marker matching and tool-call-time footer stamping.

Important Files Changed

Filename Overview
.github/workflows/code-review.yml The workflow now consistently stamps its own comments, recognizes exact current and legacy markers, and confines Bash access to generated read-only query and diff wrappers.

Fix All in Greploop

Reviews (12): Last reviewed commit: "🐛 fix(code-review): close bash write su..." | Re-trigger Greptile

Comment thread .github/workflows/code-review.yml Outdated

Copilot AI 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.

Pull request overview

This PR updates the code-review workflow prompt so the review agent can reliably identify its own prior inline review comments across runs, replacing the previously hidden HTML marker (which was being sanitized away) with a human-readable footer and using a stable workflow ID.

Changes:

  • Switch previous-comment discovery from an HTML marker to a human-readable footer containing a stable workflow ID.
  • Instruct the agent to end each inline review comment with the footer on its own line to support cross-run deduplication.

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

Comment thread .github/workflows/code-review.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f680426c5

ℹ️ 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".

Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
- 🐛 make comment identity durable across model output and legacy markers
Copilot AI review requested due to automatic review settings August 13, 2026 15:37
Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated

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

Stale comment

Left a non-blocking comment and did not approve. Cursor Bugbot reported two unresolved findings, including a medium-severity stamp-step issue, so human review is needed. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (3)

.github/workflows/code-review.yml:194

  • P1: The stamp step’s footer check only matches comments that end exactly with \n<FOOTER> (or are exactly the footer). If the comment body already ends with the footer but also has a trailing newline, this will incorrectly append a second footer.
              body="$(printf '%s' "$encoded_body" | base64 --decode)"
              if [[ "$body" == "$REVIEW_FOOTER" || "$body" == *$'\n'"$REVIEW_FOOTER" ]]; then
                continue
              fi

.github/workflows/code-review.yml:141

  • P1: The jq ends_with_footer helper doesn’t handle trailing newlines (e.g. comments ending with ...\nAutomated review …\n). That can cause the workflow to miss its own prior comments and re-post duplicates, which is exactly what this PR is trying to prevent. Consider trimming trailing CR/LF before matching the footer.

This issue also appears on line 191 of the same file.

               `gh api repos/${{ github.repository }}/pulls/${{ env.PR_NUMBER }}/comments --paginate --jq 'def ends_with_footer($footer): . == $footer or endswith("\n" + $footer); [.[] | select(.user.login == "github-actions[bot]" and (.body | (ends_with_footer("Automated review · workflow-id: krosdai/.github/code-review/v1") or ends_with_footer("<!-- claude-code-review -->"))) and .in_reply_to_id == null)]'`

.github/workflows/code-review.yml:186

  • P2: The stamp step will append the footer to any new top-level github-actions[bot] PR review comment created after the snapshot, even if it was created by other automation in the same repo. That undermines the goal of using the footer to distinguish this workflow’s comments and can mutate unrelated bot comments.
            "repos/${{ github.repository }}/pulls/${{ env.PR_NUMBER }}/comments" \
            --paginate \
            --jq '.[] | select(.user.login == "github-actions[bot]" and .in_reply_to_id == null) | [.id, (.body | @base64)] | @tsv' |
            while IFS=$'\t' read -r comment_id encoded_body; do

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15ab5a16e8

ℹ️ 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".

Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
- 🐛 attach workflow identity through a deterministic `PreToolUse` hook
Copilot AI review requested due to automatic review settings August 13, 2026 15:48

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5c32d2e85

ℹ️ 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".

Comment thread .github/workflows/code-review.yml Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

.github/workflows/code-review.yml:125

  • P2: The hook settings file is generated without verifying that the hook script exists at the computed path. If the sparse checkout path changes or the file is missing, the failure will only surface later when posting the first inline comment, making the workflow harder to diagnose. Fail fast by checking for the hook file before writing settings.
          hook_path="${{ inputs.pr_number && '.review-policy/.github/scripts/stamp-review-comment.sh' || '.github/scripts/stamp-review-comment.sh' }}"
          jq -n \
            --arg command "bash \"$GITHUB_WORKSPACE/$hook_path\"" \
            '{hooks: {PreToolUse: [{matcher: "mcp__github_inline_comment__create_inline_comment", hooks: [{type: "command", command: $command, timeout: 10}]}]}}' \
            > "$RUNNER_TEMP/code-review-settings.json"

.github/workflows/code-review.yml:142

  • P2: The jq predicate used to find prior comments requires the body to end exactly with the footer/marker, so a trailing newline (common when tools format output) will prevent matching. That can break cross-run deduplication during migration. Consider trimming trailing newlines before the ends-with check.
               `gh api repos/${{ github.repository }}/pulls/${{ env.PR_NUMBER }}/comments --paginate --jq 'def ends_with_footer($footer): . == $footer or endswith("\n" + $footer); [.[] | select(.user.login == "github-actions[bot]" and (.body | (ends_with_footer("Automated review · workflow-id: krosdai/.github/code-review/v1") or ends_with_footer("<!-- claude-code-review -->"))) and .in_reply_to_id == null)]'`

.github/scripts/stamp-review-comment.sh:27

  • P2: The stamping hook only considers an exact footer match with no trailing newline. If the model (or toolchain) includes a trailing newline after the footer, the hook will append a second footer. Also, when the incoming body is empty, the current logic produces a comment body starting with blank lines ("\n\n"). Normalizing trailing newlines and handling empty bodies avoids duplicate footers and odd formatting.
                if $body == $footer or ($body | endswith("\n" + $footer)) then
                  $body
                else
                  $body + "\n\n" + $footer
                end

Comment thread .github/workflows/code-review.yml

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

Stale comment

Left a non-blocking comment and did not approve. Cursor Bugbot skipped, so the required automated review signal did not complete successfully and human review is needed. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/scripts/stamp-review-comment.sh Outdated
- 🐛 generate and self-test the footer hook before exposing review tools
Comment thread .github/workflows/code-review.yml Outdated
- 🐛 stamp bounded replies and preserve resolved finding coverage
Copilot AI review requested due to automatic review settings August 13, 2026 17:06
Comment thread .github/workflows/code-review.yml Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comment thread .github/workflows/code-review.yml Outdated

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

Stale comment

Left a non-blocking comment and did not approve. Cursor Bugbot skipped, and an unresolved Bugbot finding remains, so human review is needed. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

- 🐛 remove reply writes and reject shell composition in the review agent
Copilot AI review requested due to automatic review settings August 13, 2026 17:18

Copilot AI 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.

Pull request overview

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

Suppressed comments (1)

.github/workflows/code-review.yml:247

  • P2: The review-thread jq filter assumes every reviewThread has at least one comment ($comments[0]). If GitHub ever returns an empty comments.nodes array (e.g., deleted/top-level comment edge cases), this will throw and break the thread-dedup query for the whole PR run. Add a length guard before indexing.
                  .[].data.repository.pullRequest.reviewThreads.nodes[]
                  | .comments.nodes as $comments
                  | $comments[0] as $top
                  | select($top.author.login == "github-actions")

Comment thread .github/workflows/code-review.yml Outdated

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 67ea68d. Configure here.

Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated

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

Left a non-blocking comment and did not approve. Cursor Bugbot skipped, and two unresolved Bugbot findings remain, so human review is needed. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
Comment thread .github/workflows/code-review.yml Outdated
- 🐛 randomize generated paths and validate quoted shell operators
Copilot AI review requested due to automatic review settings August 13, 2026 17:34

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

Approved. Cursor Bugbot completed successfully with no unresolved findings that need human review. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.github/workflows/code-review.yml:284

  • P2: Legacy-marker migration may miss older comments if the <!-- claude-code-review --> marker was appended at the end of the last line (not on its own line). ends_with_marker($legacy) only matches the marker when it is the entire body or preceded by a newline, so unresolved legacy threads could be invisible to the deduplication query and get re-commented.
                  | select(
                      $top.body
                      | (ends_with_marker($footer) or ends_with_marker($legacy))
                    )

Comment thread .github/workflows/code-review.yml Outdated
- 🐛 expose only fixed read-only query and diff commands
Copilot AI review requested due to automatic review settings August 13, 2026 17:53

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.github/workflows/code-review.yml:253

  • P1: The prior-thread GraphQL query filters for $top.author.login == "github-actions", but Actions-authored comments typically have login github-actions[bot]. This will likely return an empty set and break deduplication (causing duplicate inline comments each run). Consider matching github-actions[bot] (and optionally keeping github-actions as a fallback).
                  | $comments[0] as $top
                  | select($top.author.login == "github-actions")
                  | select(

Comment thread .github/workflows/code-review.yml
@xdanger
xdanger merged commit a472c75 into main Aug 13, 2026
9 checks passed
@xdanger
xdanger deleted the fix/code-review-marker branch August 13, 2026 18:10
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.

2 participants