Skip to content

test: formalize --json stdout/stderr discipline#1246

Merged
mergify[bot] merged 2 commits intomainfrom
devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1
Apr 21, 2026
Merged

test: formalize --json stdout/stderr discipline#1246
mergify[bot] merged 2 commits intomainfrom
devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 20, 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

@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 10:11 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.

🟢 ⛓️ Depends-On Requirements

Wonderful, this rule succeeded.

Requirement based on the presence of Depends-On in the body of the pull request

🟢 🤖 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 10:16
@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 jd force-pushed the devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1 branch from 93d528c to a2e8e33 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 93d528c 2026-04-20 11:36 UTC
2 rebase 93d528c → a2e8e33 2026-04-20 11:36 UTC
3 rebase a2e8e33 → e03dc48 2026-04-20 12:53 UTC
4 rebase e03dc48 → af8e7cf 2026-04-20 13:15 UTC
5 rebase af8e7cf → 8af3b7c 2026-04-20 16:33 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 11:36 Failure
@jd jd marked this pull request as ready for review April 20, 2026 12:29
@jd jd force-pushed the devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1 branch from a2e8e33 to e03dc48 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
@jd jd force-pushed the devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1 branch from e03dc48 to af8e7cf Compare April 20, 2026 13:15
@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 20, 2026 13:16 Failure
jd and others added 2 commits April 20, 2026 18:33
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
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>
Change-Id: I5a37d5c1b0373eb00a0b61e90bdadf482e8693dd
@jd jd force-pushed the devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1 branch from af8e7cf to 8af3b7c Compare April 20, 2026 16:33
@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:37
Base automatically changed from devs/jd/worktree-rust-port/schema-lock-stack-list-json-output--72306d85 to main April 21, 2026 07:43
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 21, 2026

Merge Queue Status

This pull request spent 7 minutes 7 seconds in the queue, including 5 minutes 4 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 Bot added a commit that referenced this pull request Apr 21, 2026
@mergify mergify Bot merged commit c4fb228 into main Apr 21, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/worktree-rust-port/formalize-json-stdout-stderr-discipline--5a37d5c1 branch April 21, 2026 07:59
@mergify mergify Bot removed the queued label Apr 21, 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.

3 participants