Skip to content

feat(rust): port ci scopes-send to native Rust (Phase 1.4)#1300

Open
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170cafrom
devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90
Open

feat(rust): port ci scopes-send to native Rust (Phase 1.4)#1300
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170cafrom
devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 23, 2026

First ci command to go native. Straight HTTP POST to Mergify
carrying the scopes detected for a pull request, no new
infrastructure needed beyond what the config pilot already
established.

What ports natively

mergify ci scopes-send [-r REPO] [-p NUMBER] [-t TOKEN] [-u URL] [-s SCOPE...] [--scopes-json FILE] [--scopes-file FILE]:

  1. Resolves the repository: --repository flag → GITHUB_REPOSITORY
    env → error.
  2. Resolves the pull-request number: --pull-request flag →
    GITHUB_EVENT_PATH JSON (.pull_request.number) → None.
    When None the command prints a skip message to stderr and
    returns 0 — matches Python's "no PR, nothing to send".
  3. Resolves the token: --token flag → MERGIFY_TOKEN
    GITHUB_TOKEN → error.
  4. Resolves the API URL: --api-url flag → MERGIFY_API_URL
    https://api.mergify.com.
  5. Collects scopes from up to three sources (combined in order):
    --scope repeated flags, --scopes-json (Pydantic
    DetectedScope dump), --scopes-file (plain text).
  6. POSTs {"scopes": [...]} to
    /v1/repos/<repo>/pulls/<number>/scopes via the HTTP client.

--file is a hidden deprecated alias for --scopes-json.
When used, the command prints a deprecation warning to stderr
and proceeds — matches Python's click.echo(..., err=True).

Layout

New mergify-ci crate under crates/. The scopes_send
module is self-contained (duplicates resolve_token /
resolve_api_url from mergify-config::simulate for now —
they factor into mergify-core in a follow-up refactor PR
once another command needs them).

The binary's dispatch gains a Ci subcommand group, with
scopes-send as its only native variant today. Everything else
under ci (git-refs, scopes, scopes-send siblings)
still falls through to the Python shim. The native-intent
heuristic in detect_native now recognizes both the config
and ci prefixes.

Tests

11 new unit tests in mergify-ci::scopes_send:

  • Repository resolution: flag, env fallback, error
  • Pull-request resolution: explicit, from event JSON, missing
  • JSON file parsing (DetectedScope shape)
  • Text file parsing (trims + strips blanks)
  • End-to-end wiremock: combined scopes from all three sources
  • End-to-end wiremock: deprecated --file emits warning
  • End-to-end wiremock: skip-on-no-PR early-out

PORT_STATUS.toml flips ci scopes-send from shimmed to
native. The port-guard test stays green.

Binary size: 8.3 MB → 8.4 MB. 51 Rust tests total.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Depends-On: #1322

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 23, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 build(packaging): switch wheel build to maturin, ship Rust binary alongside Python source #1321
2 chore(python): drop config validate/simulate Python code, now native in Rust #1322
3 feat(rust): port ci scopes-send to native Rust (Phase 1.4) #1300 👈
4 feat(rust): port queue pause and unpause to native Rust (Phase 1.5) #1301
5 feat(rust): port ci git-refs and ci queue-info to native Rust (Phase 1.6) #1302

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 23, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

Waiting for:

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 👀 Review Requirements

Waiting for:

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for:

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@mergify mergify Bot requested a review from a team April 23, 2026 14:59
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0 branch from 2a502cd to e4397c6 Compare April 23, 2026 19:02
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 86a41aa to 0bbac0d Compare April 23, 2026 19:02
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 23, 2026

Revision history

# Type Changes Reason Date
1 initial 86a41aa 2026-04-23 19:02 UTC
2 rebase 86a41aa → 0bbac0d 2026-04-23 19:02 UTC
3 rebase 0bbac0d → 5d204df 2026-04-24 13:41 UTC
4 rebase d362a75 → b37daf9 2026-04-27 07:03 UTC
5 rebase b37daf9 → 83b1aac 2026-04-28 06:48 UTC
6 rebase 83b1aac → 34ecd5c 2026-04-28 14:09 UTC
7 rebase 34ecd5c → 649bca2 2026-04-29 07:02 UTC
8 rebase 649bca2 → ab07af0 2026-04-29 09:06 UTC
9 rebase ab07af0 → a0a5e36 2026-04-29 11:05 UTC
10 rebase a0a5e36 → 16c4ea5 2026-04-29 13:21 UTC
11 rebase 16c4ea5 → 33da35f 2026-04-30 08:23 UTC
12 content 33da35f → 0f96088 2026-04-30 09:29 UTC
13 content 0f96088 → b6ffa74 2026-04-30 12:09 UTC
14 rebase b6ffa74 → 1c79bf4 2026-04-30 13:08 UTC
15 rebase 1c79bf4 → ca1ea46 2026-04-30 13:30 UTC
16 rebase ca1ea46 → 3f54bf1 2026-04-30 14:06 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 23, 2026 19:03 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0 branch from e4397c6 to 6dee3f1 Compare April 24, 2026 13:41
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 0bbac0d to 5d204df Compare April 24, 2026 13:41
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 24, 2026 13:41 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 5d204df to d362a75 Compare April 27, 2026 06:18
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0 branch from 6dee3f1 to cc09d55 Compare April 27, 2026 06:18
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 27, 2026 06:19 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0 branch from cc09d55 to f5f004a Compare April 27, 2026 07:03
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from d362a75 to b37daf9 Compare April 27, 2026 07:03
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 27, 2026 07:03 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0 branch from f5f004a to d7398e1 Compare April 28, 2026 06:48
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from b37daf9 to 83b1aac Compare April 28, 2026 06:48
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 28, 2026 06:49 Failure
Base automatically changed from devs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0 to main April 29, 2026 17:17
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 29, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Apr 29, 2026
Copilot AI review requested due to automatic review settings April 30, 2026 08:23
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 16c4ea5 to 33da35f Compare April 30, 2026 08:23
@jd jd changed the base branch from main to devs/jd/worktree-rust-port/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 April 30, 2026 08:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports the first mergify ci command (ci scopes-send) from the Python shim to a native Rust implementation, enabling direct HTTP POST of detected scopes to the Mergify API while keeping other ci subcommands shimmed.

Changes:

  • Add a new mergify-ci crate implementing ci scopes-send (options resolution + scope collection + POST).
  • Extend mergify Rust binary dispatch to recognize ci scopes-send as a native subcommand.
  • Mark ci scopes-send as native in PORT_STATUS.toml and update Cargo dependencies/lockfile accordingly.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/mergify-cli/src/main.rs Adds ci subcommand parsing + native dispatch to mergify-ci::scopes_send.
crates/mergify-cli/Cargo.toml Adds path dependency on the new mergify-ci crate.
crates/mergify-ci/src/scopes_send.rs Implements native ci scopes-send logic + unit/integration-style wiremock tests.
crates/mergify-ci/src/lib.rs Exposes scopes_send module for the new crate.
crates/mergify-ci/Cargo.toml Defines new crate metadata and dependencies for the CI subcommands.
PORT_STATUS.toml Flips ci scopes-send from shimmed to native.
Cargo.lock Adds mergify-ci and related dependency updates.

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

Comment thread crates/mergify-cli/src/main.rs Outdated
Comment thread crates/mergify-ci/src/scopes_send.rs Outdated
Comment thread crates/mergify-ci/src/scopes_send.rs Outdated
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 08:29 Failure
@mergify mergify Bot removed the conflict label Apr 30, 2026
@jd jd force-pushed the devs/jd/worktree-rust-port/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 branch from 0d9b6f9 to e5530f7 Compare April 30, 2026 09:29
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 33da35f to 0f96088 Compare April 30, 2026 09:29
@jd jd changed the base branch from devs/jd/worktree-rust-port/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 to devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca April 30, 2026 09:29
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 09:31 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 0f96088 to b6ffa74 Compare April 30, 2026 12:09
@jd jd force-pushed the devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca branch from 1b53967 to a745f41 Compare April 30, 2026 12:09
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 12:09 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca branch from a745f41 to 800a454 Compare April 30, 2026 13:08
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from b6ffa74 to 1c79bf4 Compare April 30, 2026 13:08
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 13:08 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from 1c79bf4 to ca1ea46 Compare April 30, 2026 13:30
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 13:31 Failure
First ``ci`` command to go native. Straight HTTP POST to Mergify
carrying the scopes detected for a pull request, no new
infrastructure needed beyond what the config pilot already
established.

## What ports natively

``mergify ci scopes-send [-r REPO] [-p NUMBER] [-t TOKEN] [-u URL]
[-s SCOPE...] [--scopes-json FILE] [--scopes-file FILE]``:

1. Resolves the repository: ``--repository`` flag → ``GITHUB_REPOSITORY``
   env → error.
2. Resolves the pull-request number: ``--pull-request`` flag →
   ``GITHUB_EVENT_PATH`` JSON (``.pull_request.number``) → ``None``.
   When ``None`` the command prints a skip message to stderr and
   returns 0 — matches Python's "no PR, nothing to send".
3. Resolves the token: ``--token`` flag → ``MERGIFY_TOKEN`` →
   ``GITHUB_TOKEN`` → error.
4. Resolves the API URL: ``--api-url`` flag → ``MERGIFY_API_URL`` →
   ``https://api.mergify.com``.
5. Collects scopes from up to three sources (combined in order):
   ``--scope`` repeated flags, ``--scopes-json`` (Pydantic
   ``DetectedScope`` dump), ``--scopes-file`` (plain text).
6. POSTs ``{"scopes": [...]}`` to
   ``/v1/repos/<repo>/pulls/<number>/scopes`` via the HTTP client.

``--file`` is a hidden deprecated alias for ``--scopes-json``.
When used, the command prints a deprecation warning to stderr
and proceeds — matches Python's ``click.echo(..., err=True)``.

## Layout

New ``mergify-ci`` crate under ``crates/``. The ``scopes_send``
module is self-contained (duplicates ``resolve_token`` /
``resolve_api_url`` from ``mergify-config::simulate`` for now —
they factor into ``mergify-core`` in a follow-up refactor PR
once another command needs them).

The binary's dispatch gains a ``Ci`` subcommand group, with
``scopes-send`` as its only native variant today. Everything else
under ``ci`` (``git-refs``, ``scopes``, ``scopes-send`` siblings)
still falls through to the Python shim. The native-intent
heuristic in ``detect_native`` now recognizes both the ``config``
and ``ci`` prefixes.

## Tests

11 new unit tests in ``mergify-ci::scopes_send``:

- Repository resolution: flag, env fallback, error
- Pull-request resolution: explicit, from event JSON, missing
- JSON file parsing (DetectedScope shape)
- Text file parsing (trims + strips blanks)
- End-to-end wiremock: combined scopes from all three sources
- End-to-end wiremock: deprecated ``--file`` emits warning
- End-to-end wiremock: skip-on-no-PR early-out

``PORT_STATUS.toml`` flips ``ci scopes-send`` from ``shimmed`` to
``native``. The port-guard test stays green.

Binary size: 8.3 MB → 8.4 MB. 51 Rust tests total.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I7ff9df90791786c3c26f8159249d91093ba34ec1
@jd jd force-pushed the devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca branch from 75fad04 to 04d71cb Compare April 30, 2026 14:06
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90 branch from ca1ea46 to 3f54bf1 Compare April 30, 2026 14:06
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 14:07 Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants