Skip to content

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

Draft
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0from
devs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90
Draft

feat(rust): port ci scopes-send to native Rust (Phase 1.4)#1300
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/port-config-simulate-native-rust-phase-1-3b--f9194bb0from
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: #1298

@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 feat(rust): add mergify-py-shim with embedded Python fallback #1272
2 feat(rust): add mergify-core foundation types (Phase 1.2a) #1280
3 feat(rust): add mergify-core::http with retry + typed errors (Phase 1.2b) #1281
4 feat(rust): port config validate to native Rust (Phase 1.3) #1282
5 test: add port-inventory guard to catch un-ported Python commands #1296
6 ci: add Rust release workflow targeting GitHub Release assets #1297
7 feat(rust): port config simulate to native Rust (Phase 1.3b) #1298
8 feat(rust): port ci scopes-send to native Rust (Phase 1.4) #1300 👈
9 feat(rust): port queue pause and unpause to native Rust (Phase 1.5) #1301
10 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,})

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/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 Date
1 initial 86a41aa 2026-04-23 19:02 UTC
2 rebase 86a41aa → 0bbac0d 2026-04-23 19:02 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 23, 2026 19:03 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.

1 participant