Skip to content

chore(python): drop config validate/simulate Python code, now native in Rust#1322

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca
May 4, 2026
Merged

chore(python): drop config validate/simulate Python code, now native in Rust#1322
mergify[bot] merged 1 commit into
mainfrom
devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 30, 2026

config validate (#1282) and config simulate (#1298) ship native
in the Rust binary. With the maturin wheel from the previous commit,
both routes resolve to the Rust dispatch — the Python implementations
are dead code, just waiting to drift out of sync with the Rust copy.

Per the post-port plan agreed during review, every command's Python
copy is removed in the same change that makes it releasable as a
single Rust source. For commands already merged before the rule was
adopted, this commit catches them up:

  • Delete mergify_cli/config/ package (cli.py, validate.py).
  • Delete mergify_cli/tests/config/ (the 18 Python tests for
    validate/simulate; the Rust crate's 24 tests cover the same surface
    plus extras).
  • Drop the two [[command]] entries from PORT_STATUS.toml
    the inventory test only needs to track Python commands, and
    these are no longer Python.
  • Trim the cross-command exit-code contract suite of its three
    config-related cases; the Rust crate enforces those exit codes
    natively.
  • Drop the from mergify_cli.config import cli as config_cli_mod
    import + matching cli.add_command(...) from the root Python CLI;
    with no Python config commands left, the config group disappears
    from the click tree (the Rust binary intercepts before any click
    group lookup, so end-users see no behavior change).

The wheel still builds, installs, and runs both mergify config validate (Rust native) and mergify --help (Python shim). 592 of
the previous 610 Python tests pass; the missing 18 are the deleted
config tests.

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 09:29 Failure
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 30, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 chore(python): drop config validate/simulate Python code, now native in Rust #1322 👈
2 feat(rust): port ci scopes-send to native Rust (Phase 1.4) #1300
3 feat(rust): port queue pause and unpause to native Rust (Phase 1.5) #1301
4 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 30, 2026

Merge Protections

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

🟢 🤖 Continuous Integration

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

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 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)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

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

@jd jd marked this pull request as ready for review April 30, 2026 09:39
@jd jd force-pushed the devs/jd/worktree-rust-port/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 branch from e5530f7 to 31628c9 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
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 30, 2026

Revision history

# Type Changes Reason Date
1 initial 1b53967 2026-04-30 12:09 UTC
2 content 1b53967 → a745f41 2026-04-30 12:09 UTC
3 rebase a745f41 → 800a454 2026-04-30 13:08 UTC
4 rebase 800a454 → 75fad04 2026-04-30 13:30 UTC
5 rebase 75fad04 → 04d71cb 2026-04-30 14:06 UTC
6 rebase 04d71cb → 231a98b 2026-05-04 07:38 UTC

@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/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 branch from 31628c9 to b6420ce Compare April 30, 2026 13:08
@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
@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/drop-config-validate-simulate-python-code-now--c88170ca branch from 800a454 to 75fad04 Compare April 30, 2026 13:30
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 13:31 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 branch from f4c7454 to d7dfb31 Compare April 30, 2026 14:06
@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
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 14:07 Failure
@mergify mergify Bot requested a review from a team April 30, 2026 14:18
Base automatically changed from devs/jd/worktree-rust-port/switch-wheel-build-maturin-ship-rust-binary--8f6aa397 to main May 4, 2026 07:36
…in Rust

`config validate` (#1282) and `config simulate` (#1298) ship native
in the Rust binary. With the maturin wheel from the previous commit,
both routes resolve to the Rust dispatch — the Python implementations
are dead code, just waiting to drift out of sync with the Rust copy.

Per the post-port plan agreed during review, every command's Python
copy is removed in the same change that makes it releasable as a
single Rust source. For commands already merged before the rule was
adopted, this commit catches them up:

- Delete `mergify_cli/config/` package (cli.py, validate.py).
- Delete `mergify_cli/tests/config/` (the 18 Python tests for
  validate/simulate; the Rust crate's 24 tests cover the same surface
  plus extras).
- Drop the two `[[command]]` entries from `PORT_STATUS.toml` —
  the inventory test only needs to track *Python* commands, and
  these are no longer Python.
- Trim the cross-command exit-code contract suite of its three
  config-related cases; the Rust crate enforces those exit codes
  natively.
- Drop the `from mergify_cli.config import cli as config_cli_mod`
  import + matching `cli.add_command(...)` from the root Python CLI;
  with no Python config commands left, the `config` group disappears
  from the click tree (the Rust binary intercepts before any click
  group lookup, so end-users see no behavior change).

The wheel still builds, installs, and runs both `mergify config
validate` (Rust native) and `mergify --help` (Python shim). 592 of
the previous 610 Python tests pass; the missing 18 are the deleted
config tests.

Change-Id: Ic88170ca01430b62fb98df9aa5fd8e644bdb6e09
@jd jd force-pushed the devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca branch from 04d71cb to 231a98b Compare May 4, 2026 07:38
@mergify mergify Bot deployed to Mergify Merge Protections May 4, 2026 07:39 Active
@mergify mergify Bot requested a review from a team May 4, 2026 08:33
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 4, 2026

Merge Queue Status

This pull request spent 12 minutes 59 seconds in the queue, including 12 minutes 43 seconds running CI.

Required conditions to merge

mergify Bot added a commit that referenced this pull request May 4, 2026
@mergify mergify Bot added the queued label May 4, 2026
@mergify mergify Bot merged commit 83a53b9 into main May 4, 2026
12 checks passed
@mergify mergify Bot deleted the devs/jd/worktree-rust-port/drop-config-validate-simulate-python-code-now--c88170ca branch May 4, 2026 11:19
@mergify mergify Bot removed the queued label May 4, 2026
jd added a commit that referenced this pull request May 5, 2026
The Rust binary now serves ``mergify queue status`` natively. The
Python implementation (``mergify_cli/queue/cli.py:status`` plus the
batch/scope/topology helpers it depended on) is removed in the
same PR — the port-and-delete rule we adopted in #1322 keeps a
single live copy of every command.

## What ports

``mergify queue status [-r REPO] [-t TOKEN] [-u URL] [-b BRANCH]
[--json]``:

1. Resolves repository / token / API URL via the shared
   ``mergify_queue::auth`` resolver introduced in #1352.
2. Fetches ``GET /v1/repos/<repo>/merge-queue/status``, optionally
   with ``?branch=<branch>`` (URL-encoded via
   ``url::form_urlencoded::byte_serialize``).
3. With ``--json``: pretty-prints the raw response. The schema is
   Mergify's API contract, not this CLI's, so we deserialize into
   ``serde_json::Value`` and emit verbatim — unknown fields and
   future schema additions survive the round trip.
4. Without ``--json``: deserializes into a typed ``StatusView``
   that uses ``#[serde(default)] Option<…>`` for every field the
   Mergify API has historically treated as optional/nullable
   (matches the port checklist from #1357), then renders a
   header, an optional pause indicator, the batch tree (grouped
   by scope when there is more than one), and the waiting-PR
   list. Status icons (``● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄``) and relative
   times (``5m ago`` / ``~1h``) match the Python implementation.

## Rendering departures

Python used Rich's ``Tree`` for batches. The Rust port emits
flat indented text instead — same data, simpler rendering. Both
are line-oriented and round-trip cleanly through pipes; the
fancy box-drawing was visual sugar that didn't survive piping
anyway.

## Tests (24 new, in mergify-queue::status)

- ``build_path`` covers no-branch, branch, and URL-encoding of a
  branch name with slashes + spaces (e.g. ``feature/foo bar``
  becomes ``feature%2Ffoo+bar`` in the query).
- ``relative_time`` covers seconds / minutes / hours / days,
  future prefix, and graceful empty-string return on a malformed
  timestamp (matches Python's "degrade rather than fail").
- ``topological_sort`` covers parents-before-children ordering
  and tolerance of ``parent_ids`` that reference missing batches.
- ``group_by_scope`` covers the ``[]`` → ``"default"`` fallback
  and multi-scope batches appearing under each scope they claim.
- ``status_icon`` covers known + unknown codes.
- End-to-end wiremock tests: empty queue, paused queue, batches +
  waiting PRs, multi-scope grouping, ``?branch=…`` query
  threading, JSON-passthrough preserving an ``extra_field``,
  and tolerance of a response that omits all optional fields.

## Wiring

- ``crates/mergify-queue/Cargo.toml``: adds ``chrono`` (relative
  time math), ``indexmap`` (scope groups in insertion order),
  promotes ``serde_json`` from dev to runtime (used for the
  ``serde_json::Value`` passthrough).
- ``crates/mergify-cli/src/main.rs``: registers the ``status``
  subcommand under ``QueueSubcommand``, threads the
  ``--branch``/``--json`` flags, dispatches to
  ``mergify_queue::status::run``. Adds ``status`` to
  ``looks_native``.
- ``mergify_cli/queue/api.py``: removes ``QueueStatusResponse``,
  ``QueueBatch``, ``QueuePause``, ``QueueChecksSummary``,
  ``QueueBatchStatus``, ``QueuePullRequest``,
  ``QueuePullRequestAuthor``, and ``get_queue_status`` — all
  now Rust-native. ``QueuePullResponse`` and friends stay for
  the still-shimmed ``queue show`` (next phase).
- ``mergify_cli/queue/cli.py``: removes the ``@queue.command
  status`` block and the helpers it owned (``STATUS_STYLES``,
  ``_status_text``, ``_batch_label``, ``_pr_label``,
  ``_topological_sort``, ``_group_batches_by_scope``,
  ``_print_batches``, ``_print_waiting_prs``).
  ``_relative_time`` stays — ``show`` still uses it.
- ``mergify_cli/tests/queue/test_cli.py``: deletes
  ``TestStatusCommand``, ``TestTopologicalSort``, and the
  ``_invoke_status`` helper. ``TestRelativeTime`` stays.

Workspace: 138 Rust tests green, 590 Python tests green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I8cebcd325f05173dfa41083da2ec6516a6ec3a3f
jd added a commit that referenced this pull request May 5, 2026
The Rust binary now serves ``mergify queue status`` natively. The
Python implementation (``mergify_cli/queue/cli.py:status`` plus the
batch/scope/topology helpers it depended on) is removed in the
same PR — the port-and-delete rule we adopted in #1322 keeps a
single live copy of every command.

## What ports

``mergify queue status [-r REPO] [-t TOKEN] [-u URL] [-b BRANCH]
[--json]``:

1. Resolves repository / token / API URL via the shared
   ``mergify_queue::auth`` resolver introduced in #1352.
2. Fetches ``GET /v1/repos/<repo>/merge-queue/status``, optionally
   with ``?branch=<branch>`` (URL-encoded via
   ``url::form_urlencoded::byte_serialize``).
3. With ``--json``: pretty-prints the raw response. The schema is
   Mergify's API contract, not this CLI's, so we deserialize into
   ``serde_json::Value`` and emit verbatim — unknown fields and
   future schema additions survive the round trip.
4. Without ``--json``: deserializes into a typed ``StatusView``
   that uses ``#[serde(default)] Option<…>`` for every field the
   Mergify API has historically treated as optional/nullable
   (matches the port checklist from #1357), then renders a
   header, an optional pause indicator, the batch tree (grouped
   by scope when there is more than one), and the waiting-PR
   list. Status icons (``● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄``) and relative
   times (``5m ago`` / ``~1h``) match the Python implementation.

## Rendering departures

Python used Rich's ``Tree`` for batches. The Rust port emits
flat indented text instead — same data, simpler rendering. Both
are line-oriented and round-trip cleanly through pipes; the
fancy box-drawing was visual sugar that didn't survive piping
anyway.

## Tests (24 new, in mergify-queue::status)

- ``build_path`` covers no-branch, branch, and URL-encoding of a
  branch name with slashes + spaces (e.g. ``feature/foo bar``
  becomes ``feature%2Ffoo+bar`` in the query).
- ``relative_time`` covers seconds / minutes / hours / days,
  future prefix, and graceful empty-string return on a malformed
  timestamp (matches Python's "degrade rather than fail").
- ``topological_sort`` covers parents-before-children ordering
  and tolerance of ``parent_ids`` that reference missing batches.
- ``group_by_scope`` covers the ``[]`` → ``"default"`` fallback
  and multi-scope batches appearing under each scope they claim.
- ``status_icon`` covers known + unknown codes.
- End-to-end wiremock tests: empty queue, paused queue, batches +
  waiting PRs, multi-scope grouping, ``?branch=…`` query
  threading, JSON-passthrough preserving an ``extra_field``,
  and tolerance of a response that omits all optional fields.

## Wiring

- ``crates/mergify-queue/Cargo.toml``: adds ``chrono`` (relative
  time math), ``indexmap`` (scope groups in insertion order),
  promotes ``serde_json`` from dev to runtime (used for the
  ``serde_json::Value`` passthrough).
- ``crates/mergify-cli/src/main.rs``: registers the ``status``
  subcommand under ``QueueSubcommand``, threads the
  ``--branch``/``--json`` flags, dispatches to
  ``mergify_queue::status::run``. Adds ``status`` to
  ``looks_native``.
- ``mergify_cli/queue/api.py``: removes ``QueueStatusResponse``,
  ``QueueBatch``, ``QueuePause``, ``QueueChecksSummary``,
  ``QueueBatchStatus``, ``QueuePullRequest``,
  ``QueuePullRequestAuthor``, and ``get_queue_status`` — all
  now Rust-native. ``QueuePullResponse`` and friends stay for
  the still-shimmed ``queue show`` (next phase).
- ``mergify_cli/queue/cli.py``: removes the ``@queue.command
  status`` block and the helpers it owned (``STATUS_STYLES``,
  ``_status_text``, ``_batch_label``, ``_pr_label``,
  ``_topological_sort``, ``_group_batches_by_scope``,
  ``_print_batches``, ``_print_waiting_prs``).
  ``_relative_time`` stays — ``show`` still uses it.
- ``mergify_cli/tests/queue/test_cli.py``: deletes
  ``TestStatusCommand``, ``TestTopologicalSort``, and the
  ``_invoke_status`` helper. ``TestRelativeTime`` stays.

Workspace: 138 Rust tests green, 590 Python tests green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I8cebcd325f05173dfa41083da2ec6516a6ec3a3f
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.

3 participants