Skip to content

S008: Output Formats

FieldValue
SpecS008
FeatureOutput Formats
Date2026-04-23
StatusDraft
Authorspec-writer-agent

Overview

Output Formats is the presentation layer of Parity. Every time parity check runs, the evaluation pipeline produces a collection of per-file RuleResult objects grouped by structure. The Output Formats module transforms that data into one of two representations: a human-readable console table (the default) or a machine-readable JSON document (selected via --format=json). It also governs exit code semantics, ANSI color handling, and the contract between what the tool displays and what it enforces.

The table format is designed for developer workstations: results are grouped by directory within each structure, columns are dynamically generated from active rules, pass/fail cells use color coding, and a coverage summary table follows at the end. The JSON format is designed for CI/CD pipelines and automated tooling: it emits a single, self-contained JSON document to stdout with no decorative output, enabling downstream parsing by scripts, dashboards, and PR comment bots.

Exit codes bridge both formats: exit 0 means all enforced rules passed and global coverage (if configured) meets its threshold; exit 1 means at least one enforced violation was found or a fatal error occurred (missing config, missing coverage data). Informational rules (such as coverage-attribution) appear in output but never influence the exit code. Color output uses Symfony Console ANSI tags in table mode and is absent in JSON mode; TTY detection governs whether ANSI codes reach the terminal.

User Scenarios

S008-US-001 [P1] As a developer running Parity locally, I want a color-coded table showing pass/fail per rule per file so that I can quickly spot structural gaps without reading raw data.

S008-US-002 [P1] As a CI pipeline, I want --format=json to produce a single parseable JSON document so that I can programmatically extract results for PR comments, dashboards, or artifact storage.

S008-US-003 [P1] As a CI pipeline, I want exit code 0 on success and exit code 1 on failure so that I can gate merges on structural parity.

S008-US-004 [P2] As a developer using --show-tests, I want individual test method names listed in the table so that I can verify coverage attribution at a glance.

S008-US-005 [P2] As a developer piping output to a file, I want ANSI color codes to be automatically suppressed so that the file contains clean text.

S008-US-006 [P1] As a developer, I want informational rules to appear in the table for visibility without causing the check to fail, so that I can see coverage attribution without false alarms.

S008-US-007 [P1] As a developer with multiple structure blocks, I want one table per structure followed by a single combined summary so that I get a comprehensive view of the entire project.

Requirements Summary

IDTypePriorityTitleStatus
S008-FR-001FunctionalP1Table format as default outputDraft
S008-FR-002FunctionalP1Dynamic column generation from active rulesDraft
S008-FR-003FunctionalP1Directory grouping with separator rowsDraft
S008-FR-004FunctionalP1Alphabetical sort within each structureDraft
S008-FR-005FunctionalP1Pass/fail color coding in table cellsDraft
S008-FR-006FunctionalP1OK column aggregation logicDraft
S008-FR-007FunctionalP1Structure title and path subtitlesDraft
S008-FR-008FunctionalP1Coverage summary table after all structuresDraft
S008-FR-009FunctionalP1JSON format via --format=jsonDraft
S008-FR-010FunctionalP1JSON top-level schemaDraft
S008-FR-011FunctionalP1JSON per-file rule resultsDraft
S008-FR-012FunctionalP1JSON encoding flagsDraft
S008-FR-013FunctionalP1JSON output purity (no non-JSON text)Draft
S008-FR-014FunctionalP1Exit code 0 on all-passDraft
S008-FR-015FunctionalP1Exit code 1 on enforced violationDraft
S008-FR-016FunctionalP1Exit code 1 on fatal errorDraft
S008-FR-017FunctionalP1Exit code parity across formatsDraft
S008-FR-018FunctionalP1Informational rules excluded from exit codeDraft
S008-FR-019FunctionalP1ANSI color in table modeDraft
S008-FR-020FunctionalP2TTY detection for color suppressionDraft
S008-FR-021FunctionalP1No ANSI color in JSON modeDraft
S008-FR-022FunctionalP2--show-tests flag behaviorDraft
S008-FR-023FunctionalP1CoverageAttributionRule dual-column renderingDraft
S008-FR-024FunctionalP2Global coverage message in table modeDraft
S008-FR-025FunctionalP2Unmatched test warnings in table modeDraft
S008-FR-026FunctionalP1Plugin warnings suppressed in JSON modeDraft
S008-IF-001InterfaceP1JSON output schema (full specification)Draft
S008-IF-002InterfaceP1Table column contractDraft
S008-IF-003InterfaceP1Exit code contractDraft
S008-IF-004InterfaceP1Coverage summary table schemaDraft
S008-IF-005InterfaceP1Rule-to-column mapping contractDraft
S008-AS-001AcceptanceP1Table mode: all rules passDraft
S008-AS-002AcceptanceP1Table mode: mixed pass/failDraft
S008-AS-003AcceptanceP1JSON mode: all rules passDraft
S008-AS-004AcceptanceP1JSON mode: violations presentDraft
S008-AS-005AcceptanceP1Exit code 0 on clean runDraft
S008-AS-006AcceptanceP1Exit code 1 on enforced failureDraft
S008-AS-007AcceptanceP1Informational rule does not cause exit 1Draft
S008-AS-008AcceptanceP2--show-tests in table modeDraft
S008-AS-009AcceptanceP1Multiple structures produce multiple tablesDraft
S008-AS-010AcceptanceP1JSON output parseable by jqDraft
S008-AS-011AcceptanceP1Global coverage below threshold in JSONDraft
S008-AS-012AcceptanceP2Piped output has no ANSI codesDraft
S008-EC-001Edge CaseP1Empty project (no source files in any structure)Draft
S008-EC-002Edge CaseP1All test files missingDraft
S008-EC-003Edge CaseP1Zero enforced rules activeDraft
S008-EC-004Edge CaseP2Single file with no subdirectoryDraft
S008-EC-005Edge CaseP2Rule returns null columnHeaderDraft
S008-EC-006Edge CaseP1All rules pass but global coverage below thresholdDraft
S008-EC-007Edge CaseP2Structure source directory does not existDraft
S008-EC-008Edge CaseP1JSON with zero structuresDraft
S008-EC-009Edge CaseP2Very long file paths in tableDraft
S008-EC-010Edge CaseP1Only informational rules configuredDraft
S008-EC-011Edge CaseP2Unicode characters in file pathsDraft
S008-EC-012Edge CaseP1Global coverage is null (not configured)Draft
S008-EC-013Edge CaseP2Coverage percent exactly at threshold boundaryDraft
S008-EC-014Edge CaseP2--format with invalid valueDraft
S008-SC-001SuccessP1JSON output is always valid JSONDraft
S008-SC-002SuccessP1Exit codes are deterministicDraft
S008-SC-003SuccessP1Table rows grouped by directoryDraft
S008-SC-004SuccessP1Informational rules never affect exit codeDraft
S008-SC-005SuccessP1Format flag has no effect on exit code logicDraft
S008-SC-006SuccessP1JSON contains all evaluated rule resultsDraft

Cross-Spec Dependencies

  • Depends on: S001 (CLI Commands -- --format flag, --show-tests flag, exit code constants), S002 (Rules System -- RuleInterface::isEnforced(), RuleInterface::columnHeader(), RuleInterface::formatCell(), RuleResult value object), S003 (Coverage Readers -- coverage data that feeds per-file and global coverage values), S006 (Configuration -- min_coverage_global, structure entries, min_coverage defaults)
  • Required by: S001 (CLI Commands -- output rendering is delegated to this module's contracts)