Skip to content

feat(rust): port ci git-refs and ci queue-info to native Rust#1353

Draft
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38from
devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6
Draft

feat(rust): port ci git-refs and ci queue-info to native Rust#1353
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38from
devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 5, 2026

Adds github_event (GitHub Actions event payload deserialization) and
queue_metadata (MQ YAML fenced-block extraction) shared modules to the
mergify-ci crate, and ports two commands on top of them:

  • ci queue-info — prints MQ batch metadata as pretty JSON; errors
    INVALID_STATE (exit 7) outside an MQ context. Appends to
    $GITHUB_OUTPUT with the same ghadelimiter_<uuid> heredoc the
    Python version uses.

  • ci git-refs — detects base/head refs from Buildkite env, GitHub
    event payload, refs/notes/mergify/<branch> git notes, MQ PR body,
    or falls back to HEAD^..HEAD. Supports text/shell/json
    output formats, writes base/head to $GITHUB_OUTPUT, and calls
    buildkite-agent meta-data set when BUILDKITE=true.

The notes reader is injected as a trait-object callback so unit tests
can exercise the note-driven detection path without touching a real
git repository; the production path shells out via
real_notes_reader.

The Python implementations of ci git-refs and ci queue-info are
removed in the same PR — the Rust binary now owns both commands
end-to-end. The looks-native heuristic in main.rs learns the two
new subcommand names so argv errors surface as clap exit 2 instead
of silently falling through to the Python shim.

Adds serde_yaml_ng (YAML parser) and uuid (ghadelimiter) deps to
the mergify-ci crate. Binary grows ~100KB to 8.6MB.

19 new Rust tests (8 event/metadata, 3 queue-info, 12 git-refs + 2
format round-trips merged in). Full workspace: 79 tests green,
compat harness 4/4.

Depends-On: #1352

@jd
Copy link
Copy Markdown
Member Author

jd commented May 5, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 fix(cli): surface clap's --help instead of erroring on native subcommands #1380
2 feat(rust): port queue pause and unpause to native Rust #1352
3 feat(rust): port ci git-refs and ci queue-info to native Rust #1353 👈
4 feat(rust): port queue status to native Rust #1359
5 test: derive native queue commands from the binary, not a hardcoded list #1366

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 5, 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 May 5, 2026 09:51
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 253835c to 1ae9f28 Compare May 5, 2026 10:12
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 0ca3459 to 9d6db8e Compare May 5, 2026 10:12
@jd
Copy link
Copy Markdown
Member Author

jd commented May 5, 2026

Revision history

# Type Changes Reason Date
1 initial 0ca3459 2026-05-05 10:12 UTC
2 rebase 0ca3459 → 9d6db8e 2026-05-05 10:12 UTC
3 rebase 9d6db8e → a2714b7 2026-05-05 10:19 UTC
4 rebase a2714b7 → 742d92c 2026-05-05 11:16 UTC
5 rebase 742d92c → 839ea5a 2026-05-05 13:13 UTC
6 rebase 839ea5a → 4ddd589 2026-05-05 13:22 UTC
7 rebase 4ddd589 → 3df5705 2026-05-05 15:18 UTC
8 content 3df5705 → 0349b1d 2026-05-05 19:59 UTC
9 rebase 0349b1d → c3fc948 2026-05-06 10:57 UTC
10 content c3fc948 → 6421363 2026-05-06 13:00 UTC
11 rebase 6421363 → ece765d 2026-05-07 13:40 UTC
12 rebase ece765d → cc96b9a 2026-05-07 15:17 UTC
13 rebase cc96b9a → 45c9d93 2026-05-07 18:21 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 10:12 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 9d6db8e to a2714b7 Compare May 5, 2026 10:19
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 1ae9f28 to 1670fa1 Compare May 5, 2026 10:19
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 10:19 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from a2714b7 to 742d92c Compare May 5, 2026 11:16
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 1670fa1 to 8afcb9c Compare May 5, 2026 11:16
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 11:16 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 742d92c to 839ea5a Compare May 5, 2026 13:13
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 13:13 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 839ea5a to 4ddd589 Compare May 5, 2026 13:21
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 13:22 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 7e85a94 to 9478efd Compare May 5, 2026 15:18
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 4ddd589 to 3df5705 Compare May 5, 2026 15:18
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 15:18 Failure
@jd jd changed the title feat(rust): port ci git-refs and ci queue-info to native Rust (Phase 1.6) feat(rust): port ci git-refs and ci queue-info to native Rust May 5, 2026
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 9478efd to 12bc871 Compare May 5, 2026 19:58
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 3df5705 to 0349b1d Compare May 5, 2026 19:58
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 19:59 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 12bc871 to 8485cd1 Compare May 6, 2026 10:57
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 0349b1d to c3fc948 Compare May 6, 2026 10:57
@jd jd temporarily deployed to func-tests-live May 6, 2026 10:57 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 6, 2026 10:57 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 6, 2026 10:57 Failure
mergify Bot pushed a commit that referenced this pull request May 6, 2026
#1357)

The 2026.5.5.x release shipped a ``ci scopes-send`` regression
(fixed in #1356): the Rust port deserialized the response body via
``let _: serde_json::Value = client.post(...)`` while the Python
original ignored the body, and the Mergify endpoint returns an
empty body on success. ``Value`` still requires valid JSON, so the
Rust version surfaced ``parse response JSON: error decoding
response body`` to every user once it shipped. Test mocks used
``set_body_json(json!({}))`` instead of an empty body, so the bug
hid through unit tests too.

The fix is structural — split the HTTP client so callers pick
``post`` (parses) vs ``post_no_response`` (drops) up front — but
the bug class is broader than this one command. Capturing the
lessons in AGENTS.md so the next porter (human or assistant) walks
through them before opening a PR.

Three categories of pitfall, all observed during the port so far:

1. **HTTP response handling** — match the Python original. If
   Python ignores the response, Rust must use ``post_no_response``
   etc.; if Python parses, optional/nullable fields must be
   ``Option<T>`` + ``#[serde(default)]``.

2. **Test fixtures** — mirror the real server. ``ResponseTemplate``
   bodies must match what the endpoint actually returns; an empty
   body is not the same as ``json!({})``.

3. **UX parity with click** — char-counted validators use
   ``chars().count()`` (not ``len()``); confirmation prompts go to
   stderr; resolve all required state before prompting.

Audit of existing/in-flight ports against the checklist:

- ``config validate``, ``config simulate`` (main): match
- ``ci scopes-send`` (main): regressed, fix in #1356
- ``queue pause`` / ``unpause`` (#1352): match
- ``ci git-refs`` / ``queue-info`` (#1353): no HTTP, no risk

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from c3fc948 to 6421363 Compare May 6, 2026 13:00
@jd jd temporarily deployed to func-tests-live May 6, 2026 13:00 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 6, 2026 13:01 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 6421363 to ece765d Compare May 7, 2026 13:40
@jd jd temporarily deployed to func-tests-live May 7, 2026 13:40 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 7, 2026 13:40 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 7, 2026 13:40 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-pause-unpause-native-rust-phase-1-5--dba6fa38 branch from 01e7be5 to dd391d3 Compare May 7, 2026 15:17
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from ece765d to cc96b9a Compare May 7, 2026 15:17
@jd jd temporarily deployed to func-tests-live May 7, 2026 15:17 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 7, 2026 15:17 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 7, 2026 15:17 Failure
Adds `github_event` (GitHub Actions event payload deserialization) and
`queue_metadata` (MQ YAML fenced-block extraction) shared modules to the
mergify-ci crate, and ports two commands on top of them:

- `ci queue-info` — prints MQ batch metadata as pretty JSON; errors
  INVALID_STATE (exit 7) outside an MQ context. Appends to
  `$GITHUB_OUTPUT` with the same `ghadelimiter_<uuid>` heredoc the
  Python version uses.

- `ci git-refs` — detects base/head refs from Buildkite env, GitHub
  event payload, `refs/notes/mergify/<branch>` git notes, MQ PR body,
  or falls back to `HEAD^..HEAD`. Supports `text`/`shell`/`json`
  output formats, writes `base`/`head` to `$GITHUB_OUTPUT`, and calls
  `buildkite-agent meta-data set` when `BUILDKITE=true`.

The notes reader is injected as a trait-object callback so unit tests
can exercise the note-driven detection path without touching a real
git repository; the production path shells out via
`real_notes_reader`.

The Python implementations of `ci git-refs` and `ci queue-info` are
removed in the same PR — the Rust binary now owns both commands
end-to-end. The looks-native heuristic in `main.rs` learns the two
new subcommand names so argv errors surface as clap exit 2 instead
of silently falling through to the Python shim.

Adds `serde_yaml_ng` (YAML parser) and `uuid` (ghadelimiter) deps to
the mergify-ci crate. Binary grows ~100KB to 8.6MB.

19 new Rust tests (8 event/metadata, 3 queue-info, 12 git-refs + 2
format round-trips merged in). Full workspace: 79 tests green,
compat harness 4/4.

Change-Id: I8d3f96e6cb4eb51e6cd195951b3e622cee7efdd4
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from cc96b9a to 45c9d93 Compare May 7, 2026 18:21
@jd jd had a problem deploying to func-tests-live May 7, 2026 18:22 — with GitHub Actions Failure
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 7, 2026 18:22 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