Skip to content

refactor(stack): schema-lock stack list --json output#1243

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85
Apr 21, 2026
Merged

refactor(stack): schema-lock stack list --json output#1243
mergify[bot] merged 1 commit intomainfrom
devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 20, 2026

Pins the JSON output shape of mergify stack list --json so any
drift is caught in CI. The Rust port will reuse this model as its
output schema, and downstream scripts that parse this output get a
stable contract.

  • New mergify_cli/stack/list_schema.py with Pydantic BaseModels
    mirroring StackListOutput.to_dict(). extra="forbid" rejects any
    new/renamed/removed fields or wrong types.
  • test_stack_list_json_output now validates parsed output against
    StackListJsonOutput. Failing here means either the code drifted
    (needs revert) or the shape changed intentionally (update both
    the dataclass and the schema in one commit, treat as a breaking
    change for consumers).

freeze list, queue status, queue show are deliberately NOT
locked: their JSON output is a passthrough of the Mergify API
response, so the schema is the API's contract, not this CLI's.
Added inline comments documenting that invariant so the Rust port
preserves the passthrough behavior without introducing
transformations.

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

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 20, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(stack): schema-lock stack list --json output #1243 👈
2 test: formalize --json stdout/stderr discipline #1246
3 test(compat): scaffold cross-implementation compat-test harness #1249
4 feat(rust): scaffold Cargo workspace and Rust CI #1263
5 feat(rust): add mergify-py-shim with embedded Python fallback #1272

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 09:46 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 20, 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)(?:\(.+\))?:

🟢 🔎 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 20, 2026 09:51
@jd jd marked this pull request as ready for review April 20, 2026 10:04
Base automatically changed from devs/jd/worktree-rust-port/typed-exit-code-contract-migration-existing-exits--4d526fbf to main April 20, 2026 10:16
Copilot AI review requested due to automatic review settings April 20, 2026 11:36
@jd jd force-pushed the devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85 branch from 9de1f4d to 87a9f1b Compare April 20, 2026 11:36
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 20, 2026

Revision history

# Type Changes Date
1 initial 9de1f4d 2026-04-20 11:36 UTC
2 rebase 9de1f4d → 87a9f1b 2026-04-20 11:36 UTC
3 content 87a9f1b → 8fe4032 2026-04-20 12:53 UTC
4 rebase 8fe4032 → 3675a78 2026-04-20 13:15 UTC
5 rebase 3675a78 → b29bcfa 2026-04-20 16:33 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 11:36 Failure
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Pins the JSON output contract of mergify stack list --json by introducing a dedicated Pydantic schema and validating CLI output against it in tests, while explicitly documenting that other JSON outputs remain API passthroughs (for the upcoming Rust port and downstream tooling).

Changes:

  • Add StackListJsonOutput Pydantic models to lock the stack list --json output shape (extra="forbid").
  • Update test_stack_list_json_output to validate emitted JSON against the pinned schema.
  • Document that freeze list, queue status, and queue show JSON outputs are intentional API passthroughs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
mergify_cli/tests/stack/test_list.py Validates stack list --json output against the pinned Pydantic model in CI.
mergify_cli/stack/list_schema.py Introduces the Pydantic schema models used to lock the JSON output shape.
mergify_cli/queue/cli.py Adds comments clarifying JSON output is a passthrough of the Mergify API response.
mergify_cli/freeze/cli.py Adds comments clarifying JSON output is a passthrough of the Mergify API response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mergify_cli/stack/list_schema.py Outdated
@jd jd force-pushed the devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85 branch from 87a9f1b to 8fe4032 Compare April 20, 2026 12:53
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 12:53 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85 branch from 8fe4032 to 3675a78 Compare April 20, 2026 13:15
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 13:16 Failure
Pins the JSON output shape of `mergify stack list --json` so any
drift is caught in CI. The Rust port will reuse this model as its
output schema, and downstream scripts that parse this output get a
stable contract.

- New `mergify_cli/stack/list_schema.py` with Pydantic BaseModels
  mirroring StackListOutput.to_dict(). extra="forbid" rejects any
  new/renamed/removed fields or wrong types.
- test_stack_list_json_output now validates parsed output against
  StackListJsonOutput. Failing here means either the code drifted
  (needs revert) or the shape changed intentionally (update both
  the dataclass and the schema in one commit, treat as a breaking
  change for consumers).

`freeze list`, `queue status`, `queue show` are deliberately NOT
locked: their JSON output is a passthrough of the Mergify API
response, so the schema is the API's contract, not this CLI's.
Added inline comments documenting that invariant so the Rust port
preserves the passthrough behavior without introducing
transformations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I72306d8596c6ca7c4f2f562fc1298244417a57b3
@jd jd force-pushed the devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85 branch from 3675a78 to b29bcfa Compare April 20, 2026 16:33
@mergify mergify Bot deployed to Mergify Merge Protections April 20, 2026 16:34 Active
@mergify mergify Bot requested a review from a team April 21, 2026 07:19
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 21, 2026

Merge Queue Status

This pull request spent 5 minutes 41 seconds in the queue, including 5 minutes 12 seconds running CI.

Required conditions to merge

mergify Bot added a commit that referenced this pull request Apr 21, 2026
@mergify mergify Bot added the queued label Apr 21, 2026
@mergify mergify Bot merged commit 783c7d0 into main Apr 21, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85 branch April 21, 2026 07:43
@mergify mergify Bot removed the queued label Apr 21, 2026
mergify Bot pushed a commit that referenced this pull request Apr 21, 2026
Introduces a named test helper, ``assert_stdout_is_single_json_document``,
and wires it into the four ``--json`` tests (``stack list``,
``queue status``, ``queue show``, ``freeze list``).

The helper asserts that stdout under ``--json`` mode contains
exactly one JSON document — no banners, no progress lines, no
trailing text. Functionally identical to ``json.loads(stdout)``
(which already rejects trailing non-whitespace), but the helper
gives future readers a clearly-named invariant to grep for and
produces an explanatory failure message instead of a raw
``JSONDecodeError``.

Nothing to fix in production code: a sweep of ``console.print``,
``click.echo``, and ``print()`` call sites found no leaks into the
``--json`` code paths. Recent fixes on main (e.g. 7adb94b) already
cleaned up known cases. This PR exists to keep the invariant
visible so future changes don't quietly regress it.

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

Depends-On: #1243
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