Skip to content

refactor(cli): use format json for machine output - #677

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/format-json-only
May 1, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/format-json-only

Conversation

@Sinity

@Sinity Sinity commented May 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Normalize Polylogue user-facing machine output on --format json by removing the parallel public --json flags from CLI commands and generated verification surfaces.

Problem

The CLI cleanup direction says machine-readable output should use the existing format option rather than a second boolean spelling. Keeping both --json and --format json made help text, proof subjects, scenario exercises, and machine-error handling drift across two names for the same contract.

Solution

  • Removed public --json options from Polylogue CLI commands: doctor, tags, neighbors, resume, schema inspect commands, browser-capture status, run embed stats, and registry-driven insight commands.
  • Kept devtools control-plane --json flags unchanged.
  • Updated raw machine-error detection so structured Click errors are emitted only for --format json, --format=json, or -f json.
  • Updated proof JSON-command subjects, evidence runner args, scenario surfaces, showcase exercises, help baselines, generated CLI/docs/verification references, and tests to use --format json.
  • Split insight export artifact format from machine-output format: artifact format is now --bundle-format jsonl; metadata output uses --format json.

Verification

ruff format --check polylogue tests devtools && ruff check polylogue tests devtools
mypy polylogue/
devtools render-all --check
devtools verify-topology && devtools verify-layering && devtools verify-test-ownership
pytest -q tests/unit/cli/test_machine_contract.py tests/unit/cli/test_machine_main.py tests/unit/cli/test_machine_main_runtime.py tests/unit/cli/test_click_app_main.py tests/unit/cli/test_json_envelope_contract.py tests/unit/cli/test_check.py tests/unit/cli/test_insights.py tests/unit/cli/test_insights_command_runtime.py tests/unit/cli/test_run.py tests/unit/cli/test_embed.py tests/unit/cli/test_neighbors_command.py tests/unit/browser_capture/test_receiver.py tests/unit/scenarios/test_operational_surfaces.py tests/unit/scenarios/test_insight_surfaces.py tests/unit/showcase/test_exercise_catalog.py tests/unit/devtools/test_executable_scenarios.py tests/unit/devtools/test_execution_specs.py tests/unit/devtools/test_validation_lanes.py tests/proof/laws/completeness/test_every_json_command_has_envelope_claim.py tests/unit/proof/test_evidence_runners.py tests/unit/storage/test_repository_lifecycle_laws.py tests/unit/cli/test_terminal_snapshots.py
jq empty polylogue/showcase/exercise_catalog.json && pytest -q tests/unit/showcase/test_catalog_loader_runtime.py tests/unit/showcase/test_exercise_catalog.py tests/unit/cli/test_json_envelope_contract.py tests/unit/proof/test_evidence_runners.py
pytest -q --ignore=tests/integration

Results:

  • focused CLI/scenario/proof run: 416 passed in 15.40s
  • catalog/JSON follow-up run: 68 passed in 10.76s
  • full non-integration suite: 5774 passed in 185.94s (0:03:05)
  • pre-push devtools verify --quick: all checks passed

Ref #635

Summary by CodeRabbit

  • Refactor
    • Unified CLI output format selection across all commands from --json flag to --format json option
    • Affected commands: doctor, tags, run embed, schema subcommands, insights subcommands, neighbors, resume, browser-capture status, and check
    • Updated terminology in insights-related documentation from "archive data/product" to "archive/insight"

Problem: Polylogue still exposed a parallel --json flag on user CLI commands after the surface cleanup decided machine output should be requested through the format option. That left command help, proof subjects, showcase scenarios, and machine-error detection split across two names for the same contract.

What changed: Removed public --json options from Polylogue CLI commands and routed JSON output through --format json. Updated proof JSON-command subjects, scenario surfaces, showcase catalog/baselines, CLI docs, and tests to use the single machine-output spelling. Devtools control-plane --json flags are intentionally unchanged.

Verification: ruff format --check polylogue tests devtools && ruff check polylogue tests devtools; mypy polylogue/; devtools render-all --check; devtools verify-topology && devtools verify-layering && devtools verify-test-ownership; pytest -q <focused CLI/scenario/proof set> -> 416 passed; jq empty polylogue/showcase/exercise_catalog.json && pytest -q tests/unit/showcase/test_catalog_loader_runtime.py tests/unit/showcase/test_exercise_catalog.py tests/unit/cli/test_json_envelope_contract.py tests/unit/proof/test_evidence_runners.py -> 68 passed; pytest -q --ignore=tests/integration -> 5774 passed in 185.94s.

Ref #635
Copilot AI review requested due to automatic review settings May 1, 2026 22:53
@coderabbitai

coderabbitai Bot commented May 1, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request systematically replaces --json CLI flags with a unified --format [json] option across all CLI commands (doctor, tags, schema, embed, insights, etc.), updating command implementations, shared contracts, proof/scenario infrastructure, help documentation, and corresponding tests.

Changes

Cohort / File(s) Summary
Documentation
docs/cli-reference.md, docs/test-quality-workflows.md, docs/verification-catalog.md
Updated CLI reference and test quality documentation to reflect --format json option instead of --json flag; regenerated verification catalog with updated line references for command definitions.
CLI Command Implementations
polylogue/cli/commands/browser_capture.py, polylogue/cli/commands/check.py, polylogue/cli/commands/insights.py, polylogue/cli/commands/neighbors.py, polylogue/cli/commands/resume.py, polylogue/cli/commands/run.py, polylogue/cli/commands/schema.py, polylogue/cli/commands/tags.py
Replaced --json boolean flags with --format string option (or inherited root option) across all commands; updated output-selection logic to check output_format == "json" instead of separate json_output parameters.
CLI Shared Contracts & Options
polylogue/cli/shared/check_options.py, polylogue/cli/shared/insight_command_contracts.py, polylogue/cli/shared/machine_errors.py, polylogue/cli/click_app.py
Removed json_mode parameter from contracts; updated wants_json detection to match --format json patterns only; modified option decorators to use --format [json] choice instead of boolean --json flag.
Proof & Subject Infrastructure
polylogue/proof/runners.py, polylogue/proof/subjects.py
Updated default JSON output argument construction from --json to --format json in CLI proof evidence generation and JSON subject identifiers.
Scenario & Surface Definitions
polylogue/scenarios/cli_surfaces.py, polylogue/scenarios/execution.py, polylogue/scenarios/insight_surfaces.py, polylogue/scenarios/operational_surfaces.py
Changed CLI surface variant suffix defaults and command argument tuples from --json to ("--format", "json"); updated metadata generation helpers to recognize new JSON format patterns.
Showcase Catalog & Generators
polylogue/showcase/exercise_catalog.json, polylogue/showcase/generators.py, polylogue/showcase/invariants.py
Updated exercise catalog JSON invocation patterns and generator logic to use --format json; modified JSON-contract scenario discovery to check for --format option presence instead of --json.
CLI Help Baselines
tests/baselines/showcase/help-*.txt
Updated 24 help text baseline files to reflect removal of standalone --json flag and introduction of --format [json] option across doctor, browser-capture, schema, tags, insights subcommands, and run embed.
Integration & Unit Tests
tests/integration/test_cli_machine_contract.py, tests/integration/test_schema_operator_workflow.py, tests/unit/cli/test_*.py, tests/unit/proof/test_evidence_runners.py, tests/unit/devtools/test_*.py, tests/unit/scenarios/test_*.py, tests/unit/showcase/test_*.py, tests/unit/storage/test_repository_lifecycle_laws.py
Updated CLI test invocations across 30+ test files to use --format json instead of --json; removed json_mode parameter from callback expectations and request construction; updated assertion expectations for help output and command-surface definitions.
Test Witness & Data
tests/data/witnesses/cli-command-surface.json, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
Updated machine output alias witness and terminal snapshot fixtures to reflect --format json instead of --json.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

type:refactor, area:cli, area:docs, type:test

Poem

🐰 The CLI flags have gone through a transformation,
From --json to --format, a grand reformation!
All the commands now speak in a unified tongue,
Doctests and baselines rejoice, both old and young.
One format to rule them all, consistent and bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor(cli): use format json for machine output' clearly and concisely summarizes the main change: consolidating machine output to use --format json instead of parallel --json flags.
Description check ✅ Passed The PR description is comprehensive and follows the template structure with all required sections: Summary, Problem, Solution, Verification, and Changelog (noting no user-visible changes). It provides clear context for the refactoring work.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/format-json-only

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Polylogue Proof Pack

Refs: origin/master..HEAD
Changed paths: 81

Affected Domains

  • architecture_discipline — 4 claim(s), maturity growing
  • benchmark_coverage — 0 claim(s), maturity seed
  • cli_surface — 0 claim(s), maturity established
  • distribution — 0 claim(s), maturity seed
  • docs_media — 0 claim(s), maturity seed
  • migration_safety — 0 claim(s), maturity nascent
  • mutation_coverage — 0 claim(s), maturity growing
  • operational_resilience — 14 claim(s), maturity seed
  • performance — 0 claim(s), maturity nascent
  • pipeline_correctness — 0 claim(s), maturity growing
  • provider_coverage — 0 claim(s), maturity growing
  • scenario_coverage — 0 claim(s), maturity nascent
  • schema_correctness — 1 claim(s), maturity growing
  • security_privacy — 0 claim(s), maturity nascent
  • site_publication — 0 claim(s), maturity seed
  • spec_accuracy — 0 claim(s), maturity seed
  • spec_completeness — 3 claim(s), maturity seed
  • storage_correctness — 0 claim(s), maturity established
  • surface_parity — 1 claim(s), maturity nascent
  • test_quality — 1 claim(s), maturity growing
  • unclassified — 18 claim(s), maturity seed

Required Gates

  • devtools render-all --check — generated surface or renderer changed
  • pytest tests/unit/cli — CLI command surface changed
  • pytest tests/unit/proof/test_evidence_runners.py — CLI proof runners exercise command output
  • devtools render-cli-reference --check — CLI reference is generated from command help
  • pytest tests/unit/proof — proof kernel or catalog changed
  • pytest tests/unit/devtools/test_render_verification_catalog.py — catalog renderer changed
  • devtools render-verification-catalog --check — verification catalog must stay current
  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit
  • devtools build-package — deployment readiness gate; run when packaging or release confidence matters
  • nix flake check — deployment readiness gate; run when packaging or release confidence matters

Known Gaps

  • distribution: dev_install: Not verified in CI; devshell is canonical environment [owner: distribution; next: Add package/build or cross-artifact CI gate], distribution: No scenario for install/package verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], install_parity: No cross-artifact equivalence verification (wheel vs sdist vs Nix) [owner: distribution; next: Add package/build or cross-artifact CI gate], macos: No macOS CI runner [owner: distribution; next: Add package/build or cross-artifact CI gate], sdist: Not built or tested in CI [owner: distribution; next: Add package/build or cross-artifact CI gate], wheel: Not built or tested in CI [owner: distribution; next: Add package/build or cross-artifact CI gate], windows: No Windows CI runner [owner: distribution; next: Add package/build or cross-artifact CI gate]
  • docs_media: docs_media: No scenario for documentation freshness verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], docs_media: README examples and media are not yet generated from executable scenario projections. [owner: docs-media; next: Add executable scenario projection or media integrity gate], docs_media: Screenshots and VHS media have no committed nonblank/readability verification. [owner: docs-media; next: Add executable scenario projection or media integrity gate]
  • migration_safety: migration_safety: No scenario for migration safety verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject]
  • performance: performance: No scenario family exercising memory or throughput budgets [owner: scenario-coverage; next: Add scenario family or generated projection for this subject]
  • security_privacy: dependency_audit: No dependency vulnerability scanning in CI [owner: security-privacy; next: Add dedicated security/privacy gate for this area], file_permissions: Crawl-source file permissions not verified [owner: security-privacy; next: Add dedicated security/privacy gate for this area], secrets_detection: No automated secrets scanning in CI [owner: security-privacy; next: Add dedicated security/privacy gate for this area], security_privacy: Security verification uses unit tests, not scenario specs [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], xss_prevention: No dedicated XSS test file; relies on snapshot rendering [owner: security-privacy; next: Add dedicated security/privacy gate for this area]
  • site_publication: site_publication: Static-site publication has no visual or hyperlink integrity gate. [owner: docs-media; next: Add executable scenario projection or media integrity gate]
  • storage_correctness: storage_correctness: No dedicated scenario family for storage-layer verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject]
  • test_quality: direct_coverage: Coverage per-module not tracked (only aggregate fail_under) [owner: test-quality; next: Add measurable quality gate for this dimension], flakiness: No systematic flakiness tracking, CI retry, or quarantine [owner: test-quality; next: Add measurable quality gate for this dimension], fuzz: Atheris fuzz targets not run in CI [owner: test-quality; next: Add measurable quality gate for this dimension], mock_depth: Mock depth not measured or enforced [owner: test-quality; next: Add measurable quality gate for this dimension]

Oracle / Cost

  • oracle mix: {"construction_sanity": 524, "drift_check": 5, "manual_review": 1, "proof": 37, "smoke": 12}
  • cost tier: {"static": 563, "unit": 16}
  • stale evidence: 574
  • manual review cells: 1

@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: f982bddca3

ℹ️ 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".

@click.option("--since", default=None, help="Limit supported insights to rows at/after this timestamp or date.")
@click.option("--until", default=None, help="Limit supported insights to rows at/before this timestamp or date.")
@click.option("--format", "output_format", type=click.Choice(["jsonl"]), default="jsonl", show_default=True)
@click.option("--bundle-format", type=click.Choice(["jsonl"]), default="jsonl", show_default=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add bundle-format to machine-error command parsing

The new --bundle-format option on insights export is not recognized by extract_command, so when JSON-mode error handling is active (for example with --format json) and the command fails before normal rendering, the emitted machine error can include an incorrect command path (it treats jsonl as a positional token). This breaks the machine envelope’s command metadata for insights export failures and can mislead automation that routes on command.

Useful? React with 👍 / 👎.

Copilot AI 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.

Pull request overview

Refactors Polylogue’s CLI machine-readable output contract to standardize on --format json (and deprecate/remove parallel --json boolean flags), updating generated verification surfaces, proof subjects, docs, and tests accordingly.

Changes:

  • Removed public --json options from multiple CLI commands and migrated callers/tests/docs to --format json.
  • Updated raw argv machine-error detection to recognize JSON intent via --format json, --format=json, and -f json.
  • Split insights export “artifact/bundle format” from “machine output format” (--bundle-format jsonl vs --format json).

Reviewed changes

Copilot reviewed 81 out of 81 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/storage/test_repository_lifecycle_laws.py Updates scenario command invocation to doctor --format json.
tests/unit/showcase/test_scenario_models.py Updates showcase scenario args from --json to --format json.
tests/unit/showcase/test_invariants_runtime.py Updates JSON-valid invariant tests to use --format json.
tests/unit/showcase/test_exercise_catalog.py Updates curated JSON contract exercise args to --format json.
tests/unit/showcase/test_cli_boundary.py Updates CLI boundary display command to --format json.
tests/unit/showcase/test_catalog_loader_runtime.py Updates catalog loader expectations for --format json.
tests/unit/scenarios/test_runtime.py Updates runtime command resolution assertions for --format json.
tests/unit/scenarios/test_operational_surfaces.py Updates operational surface args to --format json.
tests/unit/scenarios/test_insight_surfaces.py Updates insight surface args to --format json.
tests/unit/proof/test_evidence_runners.py Updates proof obligation subject id to --format json.
tests/unit/devtools/test_validation_lanes.py Updates lane command assertions to --format json.
tests/unit/devtools/test_execution_specs.py Updates execution rendering expectations for --format json.
tests/unit/devtools/test_executable_scenarios.py Updates inferred executable scenario args to --format json.
tests/unit/cli/test_run.py Updates CLI tests for tags/embed stats JSON output to --format json.
tests/unit/cli/test_neighbors_command.py Updates neighbors JSON payload test to --format json.
tests/unit/cli/test_machine_main_runtime.py Updates machine entry argv for JSON-mode error handling to --format json.
tests/unit/cli/test_machine_main.py Updates machine entry argv to --format json.
tests/unit/cli/test_machine_contract.py Updates docs/tests around JSON intent detection and removes --json cases.
tests/unit/cli/test_json_envelope_contract.py Updates JSON envelope contract tests to invoke --format json.
tests/unit/cli/test_insights_command_runtime.py Updates insights command runtime tests for removed json_mode and new bundle/output format split.
tests/unit/cli/test_insights.py Updates insights command invocations to --format json and export changes.
tests/unit/cli/test_embed.py Updates run embed help/options and JSON requires stats behavior to --format json.
tests/unit/cli/test_deterministic_output.py Updates deterministic-output contract text and invocations to --format json.
tests/unit/cli/test_command_aux_runtime.py Updates tags command aux runtime test to --format json.
tests/unit/cli/snapshots/test_terminal_snapshots.ambr Updates help snapshot removing --json and showing --format [json].
tests/unit/browser_capture/test_receiver.py Updates browser-capture status JSON output test to --format json.
tests/proof/laws/completeness/test_every_json_command_has_envelope_claim.py Updates completeness law wording to --format json.
tests/integration/test_schema_operator_workflow.py Updates schema integration workflow tests to --format json.
tests/integration/test_cli_machine_contract.py Updates integration machine-contract tests to invoke --format json.
tests/data/witnesses/cli-command-surface.json Removes --json from machine-output alias list.
tests/baselines/showcase/help-tags.txt Updates help baseline removing --json and using --format json.
tests/baselines/showcase/help-schema-list.txt Removes --json from schema list help baseline.
tests/baselines/showcase/help-schema-explain.txt Removes --json from schema explain help baseline.
tests/baselines/showcase/help-schema-compare.txt Removes --json from schema compare help baseline.
tests/baselines/showcase/help-run-embed.txt Updates embed help baseline to --format [json] for stats output.
tests/baselines/showcase/help-resume.txt Removes --json from resume help baseline.
tests/baselines/showcase/help-neighbors.txt Removes --json from neighbors help baseline.
tests/baselines/showcase/help-main.txt Updates main help baseline text for insights wording/ordering.
tests/baselines/showcase/help-insights.txt Updates insights group help baseline wording and export/status labels.
tests/baselines/showcase/help-insights-work-events.txt Removes --json from insights work-events help baseline.
tests/baselines/showcase/help-insights-week-summaries.txt Removes --json from insights week-summaries help baseline.
tests/baselines/showcase/help-insights-threads.txt Removes --json from insights threads help baseline.
tests/baselines/showcase/help-insights-tags.txt Removes --json from insights tags help baseline.
tests/baselines/showcase/help-insights-status.txt Removes --json, renames --product→--insight, keeps --format.
tests/baselines/showcase/help-insights-profiles.txt Removes --json from insights profiles help baseline.
tests/baselines/showcase/help-insights-phases.txt Removes --json from insights phases help baseline.
tests/baselines/showcase/help-insights-export.txt Splits export bundle format vs metadata format (--bundle-format, --format).
tests/baselines/showcase/help-insights-enrichments.txt Removes --json from insights enrichments help baseline.
tests/baselines/showcase/help-insights-debt.txt Removes --json from insights debt help baseline.
tests/baselines/showcase/help-insights-day-summaries.txt Removes --json from insights day-summaries help baseline.
tests/baselines/showcase/help-insights-costs.txt Removes --json from insights costs help baseline.
tests/baselines/showcase/help-insights-cost-rollups.txt Removes --json from insights cost-rollups help baseline.
tests/baselines/showcase/help-insights-analytics.txt Removes --json from insights analytics help baseline.
tests/baselines/showcase/help-doctor.txt Removes --json from doctor help baseline and shows --format [json].
tests/baselines/showcase/help-browser-capture-status.txt Updates browser-capture status help baseline to --format [json].
polylogue/showcase/invariants.py Updates JSON validity invariant detection to key off --format/-f json instead of --json.
polylogue/showcase/generators.py Switches JSON-contract scenario discovery from --json to --format presence.
polylogue/showcase/exercise_catalog.json Updates generated catalog argv/expectations away from --json.
polylogue/scenarios/operational_surfaces.py Updates operational surface families to include --format json.
polylogue/scenarios/insight_surfaces.py Updates insight surface lane variants to include --format json.
polylogue/scenarios/execution.py Adds argv JSON-intent detection helper and updates metadata tagging to match --format/-f json.
polylogue/scenarios/cli_surfaces.py Updates default surface suffix args to --format json.
polylogue/proof/subjects.py Updates proof subject IDs/display names and json args to --format json.
polylogue/proof/runners.py Updates default subject json args to --format json.
polylogue/cli/shared/machine_errors.py Updates pre-Click argv scan to detect JSON intent via --format/-f.
polylogue/cli/shared/insight_command_contracts.py Removes json_mode; wants_json now based on output_format == \"json\".
polylogue/cli/shared/check_options.py Replaces --json with --format [json] option for doctor.
polylogue/cli/commands/tags.py Removes --json flag and gates JSON output on output_format.
polylogue/cli/commands/schema.py Removes --json flags and switches schema JSON rendering to output_format.
polylogue/cli/commands/run.py Replaces embed --json with --format [json] and updates error messaging.
polylogue/cli/commands/resume.py Removes --json flag and uses output_format (incl. inherited root format).
polylogue/cli/commands/neighbors.py Removes --json flag and gates JSON output on output_format.
polylogue/cli/commands/insights.py Removes --json; splits export bundle format (--bundle-format) from machine output (--format).
polylogue/cli/commands/check.py Updates doctor command signature to use output_format and map to json_output.
polylogue/cli/commands/browser_capture.py Replaces --json with --format [json] for status command output.
polylogue/cli/click_app.py Updates CLI entrypoint docstring to reference --format json for machine errors.
docs/verification-catalog.md Updates generated verification catalog references/line numbers for refactor.
docs/test-quality-workflows.md Updates workflow docs to reference --format json in generated exercise descriptions.
docs/cli-reference.md Updates CLI reference excerpts to remove --json and document --format.
Comments suppressed due to low confidence (2)

polylogue/cli/shared/machine_errors.py:177

  • wants_json() treats -f json / --format json anywhere in argv as machine-output intent. Because the root CLI already has its own -f/--format option, polylogue -f json <subcommand> can trigger JSON-wrapped Click errors even when the subcommand itself will still render success output as plain text (since many subcommands only check their local output_format). This can break the “machine output is JSON when format is json” contract.

Consider aligning these layers by either (a) making JSON-capable subcommands inherit the root output_format as well, or (b) tightening wants_json() to only match a -f/--format json that applies to the invoked subcommand/query verb (not the root option).

def wants_json(argv: list[str]) -> bool:
    """Detect JSON machine-output intent from raw argv before Click parses."""
    for index, arg in enumerate(argv):
        if arg == "--format" and index + 1 < len(argv) and argv[index + 1] == "json":
            return True
        if arg.startswith("--format=") and arg.split("=", 1)[1] == "json":
            return True
        if arg == "-f" and index + 1 < len(argv) and argv[index + 1] == "json":
            return True
    return False

tests/unit/cli/test_json_envelope_contract.py:141

  • test_json_alias_uses_success_envelope no longer exercises an alias path (all parametrized args use --format json). Renaming this test (and/or updating its docstring) would avoid confusion about whether a --json alias is still supported.

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

tags = dict(list(tags.items())[:count])

if json_mode or output_format == "json":
if output_format == "json":
Comment on lines 81 to 84

if json_mode or output_format == "json":
if output_format == "json":
emit_success(
{
Comment on lines 61 to 64
"""Health check with optional maintenance and cleanup previews."""
options = CheckCommandOptions(
json_output=json_output,
json_output=output_format == "json",
verbose=verbose,
@Sinity
Sinity merged commit 0950280 into master May 1, 2026
18 of 19 checks passed
@Sinity
Sinity deleted the feature/refactor/format-json-only branch May 1, 2026 23:01
Sinity added a commit that referenced this pull request May 7, 2026
Summary

Normalize Polylogue user-facing machine output on `--format json` by removing the parallel public `--json` flags from CLI commands and generated verification surfaces.

Problem

The CLI cleanup direction says machine-readable output should use the existing format option rather than a second boolean spelling. Keeping both `--json` and `--format json` made help text, proof subjects, scenario exercises, and machine-error handling drift across two names for the same contract.

Solution

- Removed public `--json` options from Polylogue CLI commands: `doctor`, `tags`, `neighbors`, `resume`, schema inspect commands, browser-capture status, run embed stats, and registry-driven insight commands.
- Kept devtools control-plane `--json` flags unchanged.
- Updated raw machine-error detection so structured Click errors are emitted only for `--format json`, `--format=json`, or `-f json`.
- Updated proof JSON-command subjects, evidence runner args, scenario surfaces, showcase exercises, help baselines, generated CLI/docs/verification references, and tests to use `--format json`.
- Split insight export artifact format from machine-output format: artifact format is now `--bundle-format jsonl`; metadata output uses `--format json`.

Verification

- `ruff format --check polylogue tests devtools && ruff check polylogue tests devtools`
- `mypy polylogue/`
- `devtools render-all --check`
- `devtools verify-topology && devtools verify-layering && devtools verify-test-ownership`
- focused CLI/scenario/proof run: `416 passed in 15.40s`
- catalog/JSON follow-up run: `68 passed in 10.76s`
- full non-integration suite: `5774 passed in 185.94s (0:03:05)`
- pre-push `devtools verify --quick`: all checks passed

Ref #635
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.

2 participants