You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "KatalKavya96 (via GitHub)" <gi...@apache.org> on 2026/09/01 10:02:23 UTC

[PR] feat(bitbucket): add guarded cloud PR comment create [magpie]

KatalKavya96 opened a new pull request, #1142:
URL: https://github.com/apache/magpie/pull/1142

   <!-- SPDX-License-Identifier: Apache-2.0
        https://www.apache.org/licenses/LICENSE-2.0 -->
   
   ## Summary
   
   * Adds `magpie-bitbucket pr comment <id> --body-file <path>` for creating a top-level Bitbucket Cloud pull-request comment.
   * Reuses the existing guarded write path: HTTPS-only JSON POSTs, redirect rejection, quoted path segments, body-file input, and caller-side explicit confirmation.
   * Keeps Bitbucket Data Center PR comment writes explicitly unsupported for this PR so the mutation surface stays narrow.
   
   ## Type of change
   
   * [ ] Skill change (`.claude/skills/<name>/`) — eval fixtures updated below
   * [x] Tool / bridge contract (`tools/<system>/*.md`)
   * [x] Python package (`tools/*/` with `pyproject.toml`)
   * [ ] Groovy reference impl
   * [x] Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
   * [x] Documentation (`docs/`, `README.md`, `CONTRIBUTING.md`)
   * [ ] Project template (`projects/_template/`)
   * [ ] CI / dev loop (`prek`, workflows, validators)
   * [ ] Other:
   
   ## Test plan
   
   * [x] For Python packages touched: full Bitbucket pytest suite passes
   * [x] `ruff check src tests` passes
   * [x] `ruff format --check src tests` passes
   * [x] `mypy src tests` passes
   * [x] `git diff --check` passes
   * [x] Focused PR-comment tests cover:
   
     * Cloud POST URL and JSON body
     * Data Center unsupported behaviour
     * created-comment normalization
     * CLI success
     * empty body rejection before write
     * missing body-file rejection before write
   * [ ] `prek run --all-files` passes
   * [ ] For Groovy bridges touched: command-line invocation tested end-to-end
   * [ ] For skill changes: eval suite passes for the affected skill
   * [ ] For skill behaviour changes: a new or updated eval fixture is included
   
   ## RFC-AI-0004 compliance
   
   * [x] **HITL** — the bridge executes an already-confirmed mutation; explicit confirmation remains the responsibility of the calling skill.
   * [x] **Sandbox** — no new unrestricted host access; the existing Bitbucket network boundary is reused.
   * [x] **Vendor neutrality** — extends the existing partial Bitbucket change-request adapter without claiming complete backend parity.
   * [x] **Conversational + correctable** — the caller remains responsible for presenting and confirming the proposed comment before invoking the write.
   * [x] **Write-access discipline** — only one explicitly requested top-level PR comment is created; no autonomous review, approval, decline, merge, or task mutation is added.
   * [x] **Privacy LLM** — pull-request comment content remains external repository data and follows the existing privacy / approved-LLM handling rules.
   
   ## Linked issues
   
   Refs #606
   Follow-up to #1078
   
   ## Notes for reviewers
   
   This is the next narrowly scoped Bitbucket write after Cloud issue-comment creation.
   
   The new command is:
   
   ```bash
   magpie-bitbucket pr comment <id> --body-file <path>
   ```
   
   Implementation details:
   
   * Bitbucket Cloud only
   * sends JSON to the existing pull-request comments endpoint
   * reads the comment body only from `--body-file`
   * rejects missing or whitespace-only body files before any outbound mutation
   * reuses `post_json()`, including HTTPS enforcement and redirect rejection
   * quotes the pull-request ID as a path segment
   * normalises the created comment through the existing Cloud pull-request comment normalizer
   * keeps Bitbucket Data Center PR comment writes explicitly unsupported
   
   Out of scope for this PR: inline comments, comment edits/deletion, PR task mutation, review submission, approve/unapprove, decline, merge, PR creation/editing, issue mutation, or build mutation.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bitbucket): add guarded cloud PR comment create [magpie]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #1142:
URL: https://github.com/apache/magpie/pull/1142#discussion_r3952920803


##########
tools/bitbucket/src/magpie_bitbucket/datacenter.py:
##########
@@ -362,6 +362,17 @@ def _pull_request_source_commit(raw: dict[str, Any]) -> str:
 # We fetch the paginated feed here and filter comment-bearing activities during
 # normalization so review/merge/rescope lifecycle events are not exposed as
 # discussion comments.
+def create_pull_request_comment(

Review Comment:
   Minor, non-blocking — placement rather than behaviour.
   
   This function landed between an explanatory comment and the function that comment describes. Lines 361–364 are about the *activities feed*:
   
   ```python
   # Bitbucket Data Center exposes PR comments through the broader activities feed.
   # We fetch the paginated feed here and filter comment-bearing activities during
   # normalization so review/merge/rescope lifecycle events are not exposed as
   # discussion comments.
   def create_pull_request_comment(   # <- now reads as documentation for this
   ```
   
   …but `create_pull_request_comment` rejects writes and never touches the feed; the comment belongs to `get_pull_request_discussion` just below it. Either move this function above the comment block, or move the block down to sit directly on `get_pull_request_discussion`.
   
   Cosmetic, but it is the kind of drift that quietly misleads the next person reading this module. Resolving it myself so it does not hold up the merge — happy for it to be a follow-up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bitbucket): add guarded cloud PR comment create [magpie]

Posted by "KatalKavya96 (via GitHub)" <gi...@apache.org>.
KatalKavya96 commented on PR #1142:
URL: https://github.com/apache/magpie/pull/1142#issuecomment-5492281848

   Hi @potiuk, this continues the guarded Bitbucket write rollout after #1078.
   
   This adds one narrow mutation: top-level Bitbucket Cloud PR comment creation via `pr comment <id> --body-file <path>`.
   
   It deliberately reuses the existing write-path protections from issue-comment creation: caller-side confirmation, body-file-only input, HTTPS enforcement, redirect rejection, and quoted path segments. Data Center PR comment writes remain explicitly unsupported in this PR.
   
   Tests cover the POST request/body, normalization, CLI success, Data Center rejection, and missing/empty body failures before any write occurs.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(bitbucket): add guarded cloud PR comment create [magpie]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #1142:
URL: https://github.com/apache/magpie/pull/1142


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org