Skip to content

feat(rust): port queue pause and unpause to native Rust (Phase 1.5)#1301

Draft
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90from
devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38
Draft

feat(rust): port queue pause and unpause to native Rust (Phase 1.5)#1301
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/port-ci-scopes-send-native-rust-phase-1-4--7ff9df90from
devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 23, 2026

Two queue commands in one PR — both are idempotent one-shot API
calls that share the same auth + repository resolution. Pause
exercises the new PUT method; unpause exercises the new
DELETE-with-status-check method. Together they add 5 commands to
native status (3 config + scopes-send + pause + unpause = 6 of
30 commands native).

queue pause

PUTs {"reason": "..."} to
/v1/repos/<repo>/merge-queue/pause, prints a confirmation line
with the reason and timestamp.

Safety rails match Python:

  • --yes-i-am-sure skips confirmation outright.
  • Interactive (TTY): prompts "Proceed? [y/N]". Anything other than
    y/yes aborts as a generic error.
  • Non-interactive without the flag: refuses with INVALID_STATE
    (exit 7), matching Python's
    raise SystemExit(ExitCode.INVALID_STATE).

--reason has a 255-char cap enforced by clap's value_parser
— bad input exits 2.

queue unpause

DELETEs the same path. On 404 the API is telling us the queue
wasn't paused, so the command prints "Queue is not currently
paused" and exits MERGIFY_API_ERROR (matches Python). On 2xx it
prints "Queue resumed." and exits 0.

HttpClient additions

Two new methods on mergify_core::HttpClient:

  • put<B, T>(path, body) -> Result<T, CliError> — mirror of
    post, different verb.
  • delete_if_exists(path) -> Result<DeleteOutcome, CliError>
    returns Deleted on 2xx, NotFound on 404, errors on any
    other non-success status. Lets commands like unpause give
    a friendlier 404 message without parsing error strings.

Shared auth helpers

The resolve_token / resolve_api_url / resolve_repository
trio is duplicated into mergify_queue::auth. That's now three
copies in the tree (config simulate, ci scopes-send, queue). A
follow-up PR factors them into mergify_core::auth as soon as
a fourth command needs them.

Tests

5 new unit tests in the queue crate:

  • parse_reason accepts short strings and rejects > 255 chars
  • run pauses and prints the API-returned reason + timestamp
  • run prints "Queue resumed" on 2xx
  • run errors with MERGIFY_API_ERROR on 404 carrying the
    "not currently paused" message

End-to-end smoke tested three paths:
queue pause --reason X -r owner/repo → exit 8 (missing token),
queue unpause -r owner/repo → exit 8 (missing token),
echo n | queue pause --reason X → exit 7 (non-TTY, no --sure).

PORT_STATUS.toml flips both queue pause and queue unpause to native. Binary: 8.4 MB → 8.5 MB. 56 Rust tests.

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

Depends-On: #1300

@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-core foundation types (Phase 1.2a) #1280
2 feat(rust): add mergify-core::http with retry + typed errors (Phase 1.2b) #1281
3 feat(rust): port config validate to native Rust (Phase 1.3) #1282
4 test: add port-inventory guard to catch un-ported Python commands #1296
5 ci: add Rust release workflow targeting GitHub Release assets #1297
6 feat(rust): port config simulate to native Rust (Phase 1.3b) #1298
7 feat(rust): port ci scopes-send to native Rust (Phase 1.4) #1300
8 feat(rust): port queue pause and unpause to native Rust (Phase 1.5) #1301 👈
9 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 15:43
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from fac593c to c9705cd 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 fac593c 2026-04-23 19:02 UTC
2 rebase fac593c → c9705cd 2026-04-23 19:02 UTC
3 rebase c9705cd → 9117fc7 2026-04-24 13:41 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 23, 2026 19:03 Failure
Two queue commands in one PR — both are idempotent one-shot API
calls that share the same auth + repository resolution. Pause
exercises the new PUT method; unpause exercises the new
DELETE-with-status-check method. Together they add 5 commands to
``native`` status (3 config + scopes-send + pause + unpause = 6 of
30 commands native).

## ``queue pause``

PUTs ``{"reason": "..."}`` to
``/v1/repos/<repo>/merge-queue/pause``, prints a confirmation line
with the reason and timestamp.

Safety rails match Python:

- ``--yes-i-am-sure`` skips confirmation outright.
- Interactive (TTY): prompts "Proceed? [y/N]". Anything other than
  ``y``/``yes`` aborts as a generic error.
- Non-interactive without the flag: refuses with INVALID_STATE
  (exit 7), matching Python's
  ``raise SystemExit(ExitCode.INVALID_STATE)``.

``--reason`` has a 255-char cap enforced by clap's ``value_parser``
— bad input exits 2.

## ``queue unpause``

DELETEs the same path. On 404 the API is telling us the queue
wasn't paused, so the command prints "Queue is not currently
paused" and exits MERGIFY_API_ERROR (matches Python). On 2xx it
prints "Queue resumed." and exits 0.

## HttpClient additions

Two new methods on ``mergify_core::HttpClient``:

- ``put<B, T>(path, body) -> Result<T, CliError>`` — mirror of
  ``post``, different verb.
- ``delete_if_exists(path) -> Result<DeleteOutcome, CliError>`` —
  returns ``Deleted`` on 2xx, ``NotFound`` on 404, errors on any
  other non-success status. Lets commands like ``unpause`` give
  a friendlier 404 message without parsing error strings.

## Shared auth helpers

The ``resolve_token`` / ``resolve_api_url`` / ``resolve_repository``
trio is duplicated into ``mergify_queue::auth``. That's now three
copies in the tree (config simulate, ci scopes-send, queue). A
follow-up PR factors them into ``mergify_core::auth`` as soon as
a fourth command needs them.

## Tests

5 new unit tests in the queue crate:

- ``parse_reason`` accepts short strings and rejects > 255 chars
- ``run`` pauses and prints the API-returned reason + timestamp
- ``run`` prints "Queue resumed" on 2xx
- ``run`` errors with MERGIFY_API_ERROR on 404 carrying the
  "not currently paused" message

End-to-end smoke tested three paths:
``queue pause --reason X -r owner/repo`` → exit 8 (missing token),
``queue unpause -r owner/repo`` → exit 8 (missing token),
``echo n | queue pause --reason X`` → exit 7 (non-TTY, no --sure).

``PORT_STATUS.toml`` flips both ``queue pause`` and ``queue
unpause`` to ``native``. Binary: 8.4 MB → 8.5 MB. 56 Rust tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: Idba6fa38caf403fd5f4184cda462b5f7c1eb3ebf
@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
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from c9705cd to 9117fc7 Compare April 24, 2026 13:41
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 24, 2026 13:41 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