Skip to content

refactor: add print_structured() shared helper, migrate CLI console output - #474

Merged
ProtocolWarden merged 1 commit into
mainfrom
goal/73b1e016
Jul 15, 2026
Merged

refactor: add print_structured() shared helper, migrate CLI console output#474
ProtocolWarden merged 1 commit into
mainfrom
goal/73b1e016

Conversation

@ProtocolWarden

Copy link
Copy Markdown
Owner

Summary

  • Rich console structured-output printing was hand-rolled 4 inconsistent ways across 9 CLI files — some bypassed Console entirely via typer.echo(json.dumps(...)), others routed through Console but printed a pre-serialized string, losing syntax highlighting.
  • Adds print_structured(console, output, *, sort_keys=False) in the new operations_center.cli_output module, normalizing dict/BaseModel/dataclass payloads and always rendering via console.print_json(...).
  • Migrates all 15 in-scope call sites across audit, calibration, governance, run_show, worker_backend_probe, worker_backend_status, observer, run_memory, and artifact_index. Two call sites are deliberately left unmigrated — a truncated raw-content dump (artifact_index/cli.py get-artifact --print-content) and a formatter-routed combined-output branch (observer/cli.py query-flaky-tests) — since print_structured has no equivalent for their extra semantics.

Test plan

  • tests/unit/test_cli_output.py — 22 tests, 100% line/branch coverage on the new helper
  • Updated existing CLI tests whose mocks no longer matched the helper's BaseModel/dataclass type-dispatch
  • ruff check . — 0 violations; ruff format --check — clean on all touched files
  • Full suite: 10298 passed, 6 failed (all pre-existing sandbox/timing failures, reproduced identically on the unmodified branch tip), 21 skipped, 2 xfailed — zero new failures

🤖 Generated with Claude Code

…utput

Rich console structured-output printing was hand-rolled 4 inconsistent
ways across 9 CLI files: some bypassed Console entirely via
typer.echo(json.dumps(...)), others routed through Console but printed
a pre-serialized string, losing syntax highlighting.

Adds print_structured(console, output, *, sort_keys=False) in the new
operations_center.cli_output module, normalizing dict/BaseModel/dataclass
payloads and always rendering via console.print_json(). Migrates all 15
in-scope call sites across audit, calibration, governance, run_show,
worker_backend_probe, worker_backend_status, observer, run_memory, and
artifact_index. Two call sites are deliberately left unmigrated (a
truncated raw-content dump and a formatter-routed combined-output branch)
since print_structured has no equivalent for their extra semantics.

Adds tests/unit/test_cli_output.py (22 tests, 100% line/branch coverage)
and updates existing CLI tests whose mocks no longer match the helper's
type-dispatch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ProtocolWarden
ProtocolWarden merged commit 89b38d4 into main Jul 15, 2026
25 checks passed
@ProtocolWarden
ProtocolWarden deleted the goal/73b1e016 branch July 15, 2026 07:16
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