Skip to content

feat(rust): port config validate to native Rust (Phase 1.3)#1282

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb
Apr 28, 2026
Merged

feat(rust): port config validate to native Rust (Phase 1.3)#1282
mergify[bot] merged 1 commit intomainfrom
devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 21, 2026

First native command. Exercises every piece of the foundations
work so far — HTTP fetch, JSON-schema validation, output
discipline, typed exit codes — and proves the shim-fallback
dispatch pattern.

What ports natively

mergify config validate [-f PATH]:

  1. Resolves the config file (explicit --config-file or the
    first of .mergify.yml, .mergify/config.yml,
    .github/mergify.yml).
  2. Parses it as YAML via serde_norway. Empty files are treated
    as an empty mapping; non-mapping top-level values are rejected.
  3. Fetches the published schema from
    https://docs.mergify.com/mergify-configuration-schema.json
    via the Phase 1.2b HTTP client (30s timeout, retry on 5xx).
  4. Validates with the jsonschema crate (draft-07).
  5. Emits a human-readable success line or a sorted, path-prefixed
    per-error list via Output::emit.

Exit codes: success → 0, missing / unparseable / schema violations
→ 8 (CONFIGURATION_ERROR), schema-fetch failure → 6
(MERGIFY_API_ERROR).

Dispatch

mergify-cli/src/main.rs inspects argv for a config validate
pair; if present, it parses with clap and runs the native path.
Everything else — including config simulate, every stack
command, the global --version / --help, plus any invalid
invocation — falls through to the Python shim unchanged. Clap is
loaded only when a native match is suspected, so unknown flags on
un-ported commands still produce Python's click error messages
verbatim.

Smoke-tested against the real docs CDN

Missing config → exit 8. Valid config → exit 0. Invalid config →
detailed error list + summary, exit 8. mergify --version still
falls through to Python.

Test coverage

11 unit tests in mergify-config:

  • resolve_config_path with explicit, default, and missing paths
  • load_yaml happy path, scalar rejection, malformed YAML,
    empty-file-is-empty-mapping
  • validate_against_schema happy path + error aggregation
  • emit_result for success and failure rendering

Binary size

2.7 MB → 8.0 MB. The jump is jsonschema pulling fancy-regex + the
referencing crate's schema resolver. Still well under the 15 MB
design target; we can trim with features later if needed.

Follow-up

  • 1.3b: port config simulate
  • 1.4+: ci commands (first CI-facing wins for the port story)

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

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 21, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(rust): port config validate to native Rust (Phase 1.3) #1282 👈
2 test: add port-inventory guard to catch un-ported Python commands #1296
3 ci: add Rust release workflow targeting GitHub Release assets #1297
4 feat(rust): port config simulate to native Rust (Phase 1.3b) #1298
5 feat(rust): port ci scopes-send to native Rust (Phase 1.4) #1300
6 feat(rust): port queue pause and unpause to native Rust (Phase 1.5) #1301
7 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 21, 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,})

@mergify mergify Bot requested a review from a team April 21, 2026 13:09
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from 08627d5 to 8b898c2 Compare April 21, 2026 13:13
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 21, 2026

Revision history

# Type Changes Reason Date
1 initial 08627d5 2026-04-21 13:13 UTC
2 rebase 08627d5 → 8b898c2 2026-04-21 13:13 UTC
3 rebase 8b898c2 → 6ee2535 2026-04-22 13:36 UTC
4 rebase 6ee2535 → 538f82f 2026-04-22 18:25 UTC
5 rebase 538f82f → e20964f 2026-04-23 07:32 UTC
6 rebase e20964f → bdfd8c0 2026-04-23 13:14 UTC
7 rebase bdfd8c0 → 1bccca9 2026-04-23 19:02 UTC
8 rebase 1bccca9 → db76eee 2026-04-24 13:41 UTC
9 rebase e40a308 → ce71a83 2026-04-27 07:03 UTC
10 rebase ce71a83 → 6470fc5 2026-04-28 06:48 UTC
11 rebase 6470fc5 → a286dbf 2026-04-28 14:09 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 21, 2026 13:14 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from 8b898c2 to 6ee2535 Compare April 22, 2026 13:36
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 22, 2026 13:36 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/add-mergify-core-http-retry-typed-errors-phase-1--9c66057c branch from 1343a0a to 76c0440 Compare April 22, 2026 18:25
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from 6ee2535 to 538f82f Compare April 22, 2026 18:25
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 22, 2026 18:25 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/add-mergify-core-http-retry-typed-errors-phase-1--9c66057c branch from 76c0440 to 1b2f0d8 Compare April 23, 2026 07:32
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from 538f82f to e20964f Compare April 23, 2026 07:32
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 23, 2026 07:32 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from e20964f to bdfd8c0 Compare April 23, 2026 13:14
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 23, 2026 13:14 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from bdfd8c0 to 1bccca9 Compare April 23, 2026 19:02
@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-validate-native-rust-phase-1-3--52ffe9eb branch from db76eee to e40a308 Compare April 27, 2026 06:18
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 27, 2026 06:18 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from e40a308 to ce71a83 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 marked this pull request as ready for review April 28, 2026 06:32
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from ce71a83 to 6470fc5 Compare April 28, 2026 06:48
@mergify mergify Bot deployed to Mergify Merge Protections April 28, 2026 06:49 Active
Base automatically changed from devs/jd/worktree-rust-port/add-mergify-core-http-retry-typed-errors-phase-1--9c66057c to main April 28, 2026 09:07
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 28, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Apr 28, 2026
sileht
sileht previously approved these changes Apr 28, 2026
@mergify mergify Bot requested a review from a team April 28, 2026 09:08
kozlek
kozlek previously approved these changes Apr 28, 2026
First native command. Exercises every piece of the foundations
work so far — HTTP fetch, JSON-schema validation, output
discipline, typed exit codes — and proves the shim-fallback
dispatch pattern.

## What ports natively

``mergify config validate [-f PATH]``:

1. Resolves the config file (explicit ``--config-file`` or the
   first of ``.mergify.yml``, ``.mergify/config.yml``,
   ``.github/mergify.yml``).
2. Parses it as YAML via ``serde_norway``. Empty files are treated
   as an empty mapping; non-mapping top-level values are rejected.
3. Fetches the published schema from
   ``https://docs.mergify.com/mergify-configuration-schema.json``
   via the Phase 1.2b HTTP client (30s timeout, retry on 5xx).
4. Validates with the ``jsonschema`` crate (draft-07).
5. Emits a human-readable success line or a sorted, path-prefixed
   per-error list via ``Output::emit``.

Exit codes: success → 0, missing / unparseable / schema violations
→ 8 (``CONFIGURATION_ERROR``), schema-fetch failure → 6
(``MERGIFY_API_ERROR``).

## Dispatch

``mergify-cli/src/main.rs`` inspects argv for a ``config validate``
pair; if present, it parses with clap and runs the native path.
Everything else — including ``config simulate``, every ``stack``
command, the global ``--version`` / ``--help``, plus any invalid
invocation — falls through to the Python shim unchanged. Clap is
loaded only when a native match is suspected, so unknown flags on
un-ported commands still produce Python's click error messages
verbatim.

## Smoke-tested against the real docs CDN

Missing config → exit 8. Valid config → exit 0. Invalid config →
detailed error list + summary, exit 8. ``mergify --version`` still
falls through to Python.

## Test coverage

11 unit tests in ``mergify-config``:

- ``resolve_config_path`` with explicit, default, and missing paths
- ``load_yaml`` happy path, scalar rejection, malformed YAML,
  empty-file-is-empty-mapping
- ``validate_against_schema`` happy path + error aggregation
- ``emit_result`` for success and failure rendering

## Binary size

2.7 MB → 8.0 MB. The jump is jsonschema pulling fancy-regex + the
referencing crate's schema resolver. Still well under the 15 MB
design target; we can trim with features later if needed.

## Follow-up

- 1.3b: port ``config simulate``
- 1.4+: ``ci`` commands (first CI-facing wins for the port story)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I52ffe9eb817c1879c467c22e2827cbe4c0a4e327
@jd jd force-pushed the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch from 6470fc5 to a286dbf Compare April 28, 2026 14:09
@mergify mergify Bot dismissed stale reviews from kozlek and sileht April 28, 2026 14:12

Pull request has been modified.

@mergify mergify Bot deployed to Mergify Merge Protections April 28, 2026 14:12 Active
@mergify mergify Bot removed the conflict label Apr 28, 2026
@mergify mergify Bot requested a review from a team April 28, 2026 14:16
@mergify mergify Bot requested a review from a team April 28, 2026 14:28
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 28, 2026

Merge Queue Status

  • Entered queue2026-04-28 15:01 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-28 15:02 UTC · at a286dbfa4620b07379ff12c715ecf16253728245 · squash

This pull request spent 48 seconds in the queue, including 2 seconds running CI.

Required conditions to merge

@mergify mergify Bot merged commit 4d2e81d into main Apr 28, 2026
23 checks passed
@mergify mergify Bot added the queued label Apr 28, 2026
@mergify mergify Bot deleted the devs/jd/worktree-rust-port/port-config-validate-native-rust-phase-1-3--52ffe9eb branch April 28, 2026 15:02
@mergify mergify Bot removed the queued label Apr 28, 2026
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.

4 participants