Skip to content

feat: add structured check JSON presentation - #94

Merged
coisa merged 5 commits into
mainfrom
codex/structured-result-contracts
Oct 28, 2026
Merged

coisa merged 5 commits into
mainfrom
codex/structured-result-contracts

Conversation

@coisa

@coisa coisa commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

check --format=json already exposes the versioned ECS check result, but its presentation is embedded in orchestration and cannot emit indented JSON. Extract CheckResultRenderer and add check --format=json-pretty through the existing read-only execution path.

Centralize public text, json and json-pretty presentation identifiers in the backed OutputFormat enum. Check accepts all three; Rector keeps only text and native JSON preview. Inventory formats, ECS worker protocols and JSON schema fields retain their existing meanings. Use named arguments for every supplied CheckResult field and the touched mixed/opaque calls, with parameter names checked against actual signatures. CLI strings, native schemas, exits and execution authority are preserved. Native Option suggestedValues uses documented method-reference callbacks with concise descriptions. OutputFormat::values() derives identifiers directly from cases(); the rejected VALUES constant is removed. Rector shares a single supported-format policy between completion and execution. String binding plus explicit validation preserves invalid-format diagnostics and empty stdout; suggestions do not validate input. New native completion/container tests cover both option styles, command-specific subsets, defaults and invalid paths without subprocess execution. Docs remain in the canonical process/result guide, plus the required minor fragment.

This is a focused increment for #10; the issue remains open for remaining Rector/result work. The separate Rector validator extraction uses its own branch/PR from main and does not depend on this PR. No Composer, distribution, headers or workflow changes.

Current HEAD: 55e630f0e4371f31e9a5e9bb78030787e322597c; base: 159cdcca916e18c3d76853d093a20e3607856526.

  • Independent read-only review of this exact HEAD: no actionable findings. Named signatures and PHP 8.3 enum-default compatibility checked; diff whitespace check passes.
  • New local suites have not run: shared Mac one-minute load was 31.7, above the agreed threshold 14, and PHAR has priority of the heavy slot. CI is hosted and does not consume that Mac slot.
  • The Codex documentation finding on 780e60e was fixed: public command references and README now list/link json-pretty, keeping canonical detail in the process/result guide. Shared README hunks were coordinated with PHAR and do not overlap. The thread was replied to and resolved after the fix.
  • Current HEAD 55e630f has an independent read-only review with no actionable findings. The duplicated values constant is removed, callback signatures match installed Symfony 7.4.21, and integration explicitly covers text/json/json-pretty acceptance.
  • Current-head hosted CI and Codex code/security are being renewed for 55e630f. Previous HEAD e3b193f passed PHP 8.3–8.5, PR Standards, Changelog and CodeQL, and Codex code/security without findings, but that evidence is historical for this updated HEAD.
  • CodeRabbit rejected the new review on 780e60e because the included-review quota is exhausted; next availability approximately 22:08 UTC on 2026-10-28. Current HEAD has no successful CodeRabbit review. No duplicate request, billing change or permission change is made; this review gate remains blocked.

Earlier validation on 660d721: affected local unit tests 14/120 assertions, native JSON integration 1/19 assertions, installed help and changed-file syntax/style pass; hosted PHP 8.3–8.5, reusable checks, Changelog and CodeQL pass (PHP 8.5 full suite: 301 tests / 2,592 assertions). Current HEAD must establish its own evidence.

Symfony Console is locked to 7.4.21. Its Option implementation supports suggestedValues and native backed-enum conversion. Native conversion raises a binding diagnostic before invocation; this PR preserves existing string API and explicit rejection behavior instead of changing that error contract. No cases() invocation occurs inside an attribute; the attribute contains a method reference, called by native completion at runtime. The actual fast-forward/enum main at 55d6e83679cfd8b2481e6151870c7ed71f6985da has HasValues, delegating to EnumHelper::values(), and no predefined output-format enum. That package is not installed here; a local cases-derived projection avoids a new dependency and Composer/distribution scope. No trait/file is copied.

Rector research found AddNameToBooleanArgumentRector and AddNameToNullArgumentRector, which name arguments from the first matched value onward and do not enforce naming all preceding values/opaque integers. SortCallLikeNamedArgsRector only sorts existing names. No global or consumer rule is enabled; changes are manually scoped to reviewed signatures. Sources: native name-adder, sorting rule, PHP-CS-Fixer rule catalog.

Awaiting human approval; no merge, PR approval or release is performed by this task. GitHub changed draft=false externally before this update; this task did not mark the PR ready.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 26f6e812-9a27-4f1b-a26c-a7a680ddec3c
Commits

Reviewing files that changed from the base of the PR and between 159cdcc and 660d721.

Files selected for processing: 7
  • .changelog/check-json-pretty.md
  • docs/process-contracts.rst
  • src/Console/CheckResultRenderer.php
  • src/Console/Command/CheckCommand.php
  • src/Console/StructuredCheckOperation.php
  • tests/Console/CheckResultRendererTest.php
  • tests/Integration/StandardsTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Added check --format=json-pretty for indented JSON output. It provides the same results and exit codes as compact JSON, without terminal color.
    • Encoding failures are reported as operational errors while retaining available coverage information.
  • Documentation
    • Documented JSON output formats, diagnostic handling, and their behavior alongside text-based checks and refactoring.

The check command now accepts json-pretty alongside text and json. A dedicated renderer formats structured check results as compact or pretty JSON, handles encoding failures, and returns the result’s exit code. Tests and documentation cover the output contract.

Changes: Check JSON output

Layer / File(s) Summary
Render check results
src/Console/CheckResultRenderer.php, tests/Console/CheckResultRendererTest.php
The renderer emits compact or pretty JSON. If encoding fails, it creates an operational-error result while retaining selection and status fields. Tests check formatting, diagnostics, and encoding-failure output.
Integrate JSON formats
src/Console/Command/CheckCommand.php, src/Console/StructuredCheckOperation.php, tests/Integration/StandardsTest.php, docs/process-contracts.rst, .changelog/check-json-pretty.md
The command routes both JSON formats through the structured operation and passes the pretty-format flag. Integration tests check matching results, ANSI-free output, and unchanged source files. Documentation and the changelog describe the formats and result contract.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CheckCommand
  participant StructuredCheckOperation
  participant StructuredCheckRunner
  participant CheckResultRenderer
  participant SymfonyStyle
  CheckCommand->>StructuredCheckOperation: Select JSON format and pass pretty flag
  StructuredCheckOperation->>StructuredCheckRunner: Run checks
  StructuredCheckRunner-->>StructuredCheckOperation: Return check result
  StructuredCheckOperation->>CheckResultRenderer: Render result with pretty flag
  CheckResultRenderer->>SymfonyStyle: Write JSON and diagnostics
  CheckResultRenderer-->>CheckCommand: Return result exit code
Loading

Possibly related issues

  • Issue 10: This PR adds check --format=json-pretty and a dedicated check result renderer, which address part of the issue’s objectives. The issue remains open for other result and Rector work.
Merge Risk: Minimal · up to 660d7

Pretty JSON uses the existing check result path. No material merge-blocking issue was found.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main change: adding structured JSON presentation for check results. It is concise and relevant to the changeset.
Description check Passed The pull request description directly matches the changeset. It explains the extracted CheckResultRenderer, the new check --format=json-pretty option, preserved JSON schemas and exits, documentation u…
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 5 files. (2 skipped: 2 unsupported.)

Full details: Description check

Explanation

The pull request description directly matches the changeset. It explains the extracted CheckResultRenderer, the new check --format=json-pretty option, preserved JSON schemas and exits, documentation updates, tests, and validation status.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit taps out JSON neat,
With curly braces lined just right.
Compact or pretty, checks report,
No bright escape codes in the light.
Then hops away on silent feet.

Comment @coderabbitai help to get the list of available commands.

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review current HEAD 660d72171047eab163b2a67bf10caf1b0e1859ad for correctness and security. This draft adds only explicit pretty JSON check presentation and extracts its renderer. Preserve the existing compact schema, exits and read-only/semantic opt-in boundaries.

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

Please review exact current HEAD 660d72171047eab163b2a67bf10caf1b0e1859ad, including JSON representation, encoding failure behavior and docs/help consistency. Draft status is intentional; an actual current-head review is required before any future merge.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Changelog

✅ Contribution check passed.

Head: 55e630f0e4371f31e9a5e9bb78030787e322597c

Base: 159cdcca916e18c3d76853d093a20e3607856526

Contribution: 1 new valid fragment(s). Policy: ordinary.

  • check-json-pretty.md — added, minor

    Add explicit `check --format=json-pretty` presentation with the same versioned result and exits as compact JSON, using a dedicated check result renderer. Centralize public output-format identifiers in a backed enum and make check-result construction explicit with named arguments, preserving each command's supported formats and native schemas. Offer enum-derived shell-completion suggestions while retaining explicit format validation and existing invalid-input diagnostics.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T22:02:19.875853Z 55e630f Manual request
🔒 Security Review ✅ Completed 2026-10-28T22:03:10.402127Z 55e630f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex security review

Review exact HEAD 660d72171047eab163b2a67bf10caf1b0e1859ad. This presentation-only increment must preserve JSON escaping, read-only check execution and explicit semantic write authorization.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 660d721710

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 660d721710

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@coisa coisa changed the title feat: add explicit pretty JSON check presentation feat: add structured check JSON presentation Oct 28, 2026

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review updated exact HEAD 780e60eaba182f11c117a31402e3d5c4659aef8a, including security. User-requested additions centralize public presentation identifiers in a backed enum and name all supplied CheckResult arguments; CLI values, per-command format subsets, schemas and exits must stay unchanged. Earlier reviews on 660d721 are stale for this HEAD.

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

One request for new HEAD 780e60eaba182f11c117a31402e3d5c4659aef8a. User-requested enum and named result arguments changed the diff since the previous review. Please check format subsets, preserved native schemas, PHP 8.3 compatibility and actual named signatures. Draft status remains intentional; no duplicate same-head review is requested.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 39 minutes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 780e60eaba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/process-contracts.rst Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 780e60eaba

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review current HEAD e3b193f884ff6c2cca53e34485a7f6afbeac529e, including security. This batch fixes the canonical command-documentation finding and completes user-requested named arguments on scoped JSON/process-limit calls using verified signatures. Public formats/schemas/exits remain unchanged. No CodeRabbit duplicate request is being made while its known included-review rate limit remains active.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: e3b193f884

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: e3b193f884

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review new exact HEAD c9078bb491588184a2d4d8cf30750b0f78fb1c14, including security. User explicitly requested native Option completion/valid choices. Actual Console 7.4.21 supports suggestedValues/backed enum conversion; this implementation derives suggestions from enum constant expressions and retains string binding/manual validation to preserve API, invalid diagnostics, empty stdout and exits. Native CommandCompletionTester/container regressions cover both syntaxes, per-command subsets and no-execution invalid paths. No cases() call in an attribute. CodeRabbit remains rate-limited; no duplicate request is sent before capacity returns.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: c9078bb491

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: c9078bb491

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@coisa
coisa marked this pull request as ready for review October 28, 2026 21:55

coisa commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review current exact HEAD 55e630f0e4371f31e9a5e9bb78030787e322597c, including security. User rejected a duplicated VALUES list; it is removed. OutputFormat::values() derives from cases(); Option uses official Symfony method-reference completion callbacks, and Rector completion/execution share a supported-format policy. Actual fast-forward/enum HasValues/EnumHelper were inspected at main55d6e83; no predefined output enum exists, no new package/dependency or copied trait is added. Existing CLI values, errors, stdout and exits remain unchanged. Tests cover completion plus explicit text/json/json-pretty acceptance and invalid paths. CodeRabbit will be requested once only when actual quota becomes available.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 55e630f0e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 55e630f0e4

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@coisa
coisa merged commit 93e27aa into main Oct 28, 2026
25 checks passed
@coisa
coisa deleted the codex/structured-result-contracts branch October 28, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant