Skip to content

fix(cli): make policy-versions --show --json compact and deterministic (#718) - #725

Closed
harmehak0173 wants to merge 2 commits into
DobermanCore:mainfrom
harmehak0173:fix/issue-718-policy-versions-show-json
Closed

harmehak0173 wants to merge 2 commits into
DobermanCore:mainfrom
harmehak0173:fix/issue-718-policy-versions-show-json

Conversation

@harmehak0173

@harmehak0173 harmehak0173 commented Sep 27, 2026 •

Copy link
Copy Markdown

Slice

What this PR does

Passes as_json into _policy_versions_show and outputs compact, sorted JSON when --json is supplied (json.dumps(payload, sort_keys=True, separators=(",", ":"))). Preserves the indented format (indent=2) for human-readable output when --json is omitted.

Tests added (run in CI)

  • Updated tests/unit/test_cli_policy_versions.py:
    • test_show_resolves_a_prefix_and_prints_the_snapshot: asserts indentation is preserved in the default human-readable view.
    • test_show_json_is_compact_and_deterministic: asserts --show <id> --json emits a single-line compact JSON document with sorted keys and identical byte-for-byte rerun output.
  • Added tests/unit/test_cli_json_contract.py:
    • Parametrized contract test verifying CLI.md:109-119 guarantees (parseable, compact single-line, sorted keys, rerun determinism) across all --json modes (status, scan, doctor, policy-history, policy-versions, policy-versions --show, and tune).

Changelog

  • changelog.d/725.fixed.md fragment added

Public-release safety (doberman-core only)

  • Contains nothing from the "not allowed" list: no enterprise/hosted code, no proprietary detection, no customer data, no secrets, no commercial-license code
  • Core still builds/tests/runs with NO enterprise package installed

Security checklist

  • Fails closed on error / uncertainty
  • No secret, full file, or unredacted prompt logged or committed
  • Any guardrail/learning change is raise-only (no silent loosening)
  • Every BLOCK/AUTH carries reason codes + a human explanation
  • doberman-core does not import doberman_enterprise

Edge cases covered / Deviations from plan / Risks introduced

None.

Fixes #718

@harmehak0173 harmehak0173 closed this by deleting the head repository Sep 28, 2026
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.

cli: policy-versions --show <id> --json prints indented JSON

1 participant