Commit 4def5c43c9 for woocommerce

commit 4def5c43c96650a2addd8558cf5de78480d8910a
Author: Radoslav Georgiev <rageorgiev@gmail.com>
Date:   Thu Dec 11 23:13:48 2025 +0200

    Update the backwards compatibility workflow to avoid duplicate comments (#62356)

    * Update the backwards compatibility workflow

    * Post all comments as a single review

    * Temporarily, add the GH token to test

    * Change the write format for reviews

    * Attribute reviews to claude

    * Warn Claude against forbidden redirects.

    * Remove the github token, to restore the previous behavior

    * Add github-actions[bot] as comment author.

    * Avoid analysis for merge commits

    ---------

    Co-authored-by: Eric Binnion <ericbinnion@gmail.com>

diff --git a/.github/workflows/backwards-compatibility-review.yml b/.github/workflows/backwards-compatibility-review.yml
index ab1f9acf25..2f64e3c459 100644
--- a/.github/workflows/backwards-compatibility-review.yml
+++ b/.github/workflows/backwards-compatibility-review.yml
@@ -41,13 +41,11 @@ jobs:
             Identify ONLY backwards compatibility risks and missing deprecations across PHP, JS/Blocks, REST, templates, and data contracts.

             OUTPUT RULES
-            - At most ONE inline comment per (file, original_line, topic). Merge points into a single comment.
-            - Insert a hidden marker in every inline comment to enable reliable dedup across pushes:
-              <!-- wc-bc:path={path};ol={original_line};topic={topic} -->
-            - Before creating a comment, list existing PR review comments and search by this marker. If a matching comment exists, UPDATE it via PATCH to merge new details; do not post a new one.
-            - If the marker cannot be constructed (e.g., missing original_line), fallback to (file, line, topic) matching.
+            - At most ONE inline comment per file + line + concern. Merge related points into a single comment.
+            - DO NOT post comments one at a time. Collect ALL comments, then submit as a SINGLE batched review (see POSTING COMMENTS below).
+            - If this flow was triggered by a commit, and the commit is a merge commit, ABORT. Merge commits are typically named `Merge branch *** into <current branch>`.

-            INLINE COMMENT TEMPLATE (use exactly with blank lines between sections)
+            INLINE COMMENT FORMAT (for each comment in the batch)
             ```
             Backwards Compatibility Review

@@ -57,7 +55,43 @@ jobs:

             **Deprecation:** <version plan, shim, notices>
             ```
-            <!-- wc-bc:path={path};ol={original_line};topic={topic} -->
+
+            DEDUPLICATION (CRITICAL - do this FIRST, before analyzing the diff)
+            1. Fetch ALL existing review comments on this PR:
+               gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments?per_page=100" --paginate
+            2. Filter to comments from "github-actions[bot]" or "claude[bot]" that contain "Backwards Compatibility Review"
+            3. Build a list of already-covered concerns: for each existing comment, note the file path, line number, and the breaking change described
+            4. When you find a potential BC issue, check your list - if an existing comment ALREADY covers the same concern on the same file (same or nearby lines within 5 lines), SKIP it
+            5. Two comments cover the same concern if they warn about the SAME breaking change, even if worded differently:
+               - "REST API namespace contract" and "endpoint URL becomes permanent" on the same route = SAME concern
+               - "hook name is public API" and "hook signature is a contract" on the same hook = SAME concern
+               - Comments on different hooks/methods/lines = DIFFERENT concerns, both should be posted
+
+            DO NOT use HTML markers for deduplication.
+            DO NOT try to PATCH/update existing comments.
+            Simply SKIP adding to batch if the concern is already covered by an existing comment.
+
+            POSTING COMMENTS (CRITICAL - use batched review API via file)
+            Post ALL comments as a SINGLE review to avoid spamming notifications.
+
+            Step 1: Get the latest commit SHA:
+               gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" --jq '.head.sha'
+
+            Step 2: Use the Write tool to create a JSON file at ./bc_review_payload.json with this structure:
+               {
+                 "commit_id": "<SHA from step 1>",
+                 "event": "COMMENT",
+                 "body": "🤖 **Backwards Compatibility Review** - Found <N> potential issues\n\n_Generated by [Claude](https://claude.ai) via [this workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})_",
+                 "comments": [
+                   {"path": "relative/file/path.php", "line": <line_number>, "body": "<comment text>"},
+                   ...
+                 ]
+               }
+
+            Step 3: Submit the review using the file as input:
+               gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews" -X POST --input bc_review_payload.json
+
+            If there are NO new issues to report, do not create the file or submit a review.

             ANALYSIS BOUNDARIES
             Include:
@@ -67,21 +101,16 @@ jobs:
               - `vendor/**`, `node_modules/**`, `build/**`, `dist/**`, `**/*.min.*`, `**/*.map`, translations `**/*.po` `**/*.mo`, images/binaries, generated artifacts, `tests/**`.

             METHOD
-            - Cite exact `file:line` for every claim (from the PR diff and repository state).
-            - For each risky change propose: non-breaking approach, shim, and staged deprecation timeline.
-            - Do not duplicate an existing equivalent "[Backwards Compatibility]" inline comment on the same line/context.
-            - For each potential comment determine variables:
-              - PATH: the file path of the change
-              - LINE: the target line number in the current diff
-              - ORIGINAL_LINE: the stable original line if available; otherwise use LINE
-              - TOPIC: one of the predefined Topic values
-            - Query existing review comments and find a match using the hidden marker first, with path and topic, preferring `original_line` and falling back to `line`:
-              gh api "repos/${REPO}/pulls/${PR}/comments?per_page=100" --paginate \
-                --jq \
-                "map(select(.path==\"${PATH}\" and ((.original_line==${ORIGINAL_LINE}) or (.line==${LINE})) and (.body|contains(\"wc-bc:path=${PATH};\") and (.body|contains(\"topic=${TOPIC}\")) ))) | first | .id"
-            - If an ID is returned, PATCH that comment to merge/append updated guidance instead of posting a new one:
-              gh api repos/${REPO}/pulls/comments/${ID} -X PATCH -f body@updated_body.md
-            - Otherwise, post a single merged comment for that (file, original_line, topic).
+            1. FIRST: Fetch and catalog all existing BC review comments (see DEDUPLICATION above)
+            2. Get the PR diff using: gh pr diff ${{ github.event.pull_request.number }}
+               DO NOT use shell redirects (>, >>, |) - they are blocked. Just run the command directly.
+            3. Analyze the diff for backwards compatibility issues
+            4. For each potential issue:
+               - Cite exact `file:line` from the PR diff
+               - Check if already covered by an existing comment (skip if so)
+               - If new, add to the comments batch
+            5. After analysis, use the Write tool to create ./bc_review_payload.json (NOT /tmp/, must be in working directory)
+            6. Submit the review using: gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews" -X POST --input bc_review_payload.json

           claude_args: >
-            --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git show:*),Bash(git diff:*),Bash(git ls-files:*),Bash(git grep:*)"
+            --allowedTools "Write,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git show:*),Bash(git diff:*),Bash(git ls-files:*),Bash(git grep:*)"