Skip to content

feat(cli): verdict polarity & field distribution assertions (#435) - #578

Merged
dan-petty merged 1 commit into
release/v0.2.23from
feat/435-verdict-polarity-field-distribution
Sep 25, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
feat/435-verdict-polarity-field-distribution

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary of Changes

Closes #435

This deliverable resolves two review-quality blindspots:

  1. Verdict Polarity Validation: Findings asserting concrete code behavior or configuration values are now required to provide both observed_value and expected_value. Findings where observed_value == expected_value are recognized as contradictory polarity hallucinations and rejected/invalidated.
  2. Pipeline Self-Test Verification: Adds run_pipeline_self_test(target_dir) asserting that an engineered contradictory finding is systematically invalidated and withdrawn by the pipeline.
  3. Verdict Field Distribution Assertions: Surfaces status, reportable, verified, and mitigated field distributions in the console review summary, markdown report, and session profiles, flagging non-discriminating fields that act as constants rather than filters.

Key Changes

  • Schema & Polarity Validation (src/devops_cli/ai/review_schema.py):
    • Added observed_value and expected_value fields with aliases on Finding and SavedFinding.
    • Added @model_validator rejecting identical pairs and requiring both fields when asserting concrete values.
    • Implemented compute_verdict_distributions(findings) and is_field_discriminating(counts).
  • Deterministic Pre-Verification (src/devops_cli/ai/review/verification.py):
    • Added _check_verdict_polarity_hallucination invalidating candidate findings where observed_value == expected_value before executing LLM verification.
    • Updated LLM verification result handling in _apply_single_finding_verification to invalidate matching polarity values.
  • Pipeline Integration & Self-Test (src/devops_cli/ai/review/pipeline.py):
    • Added _format_verdict_distributions and integrated into _render_console_summary_table.
    • Added _build_verdict_distributions_section and integrated into consolidated markdown reports (review.md).
    • Added run_pipeline_self_test(target_dir) and orchestrator.run_self_test().
    • Re-exported functions in src/devops_cli/ai/review/init.py.
  • Profile & Runner Integration (src/devops_cli/ai/review/profile.py, src/devops_cli/ai/review/runner.py):
    • Added verdict_distributions field to ReviewProfile.
    • Updated ReviewProfiler.set_findings and runner _record_profile_findings to record verdict distributions.
  • Review Instructions & Prompts (src/devops_cli/ai/tasks/review.md, src/devops_cli/ai/tasks/review_output_instruction.md):
    • Documented observed_value and expected_value schema fields and strict verdict polarity rules.
  • Comprehensive Test Suite (tests/test_verdict_polarity.py):
    • 12 unit and integration tests covering polarity validation, deterministic pre-verification, pipeline self-test, verdict distributions, report formatting, profile recording, and non-discrimination warnings with structural tuple equality assertions.

Verification Results

  • uv run pytest tests/test_verdict_polarity.py -v: 12 passed.
  • uv run devops scan complexity: M <= 10, depth <= 5 compliant.
  • uv run devops ci: 100% passing across all quality gates.

- Require findings asserting concrete values to provide distinct observed_value and expected_value pairs
- Invalidate contradictory polarity hallucinations during deterministic pre-verification and LLM response handling
- Add pipeline self-test asserting that an engineered contradictory finding is systematically withdrawn
- Compute and surface verdict field distributions (status, reportable, verified, mitigated) in console summary, markdown report, and review profiles
- Highlight non-discriminating fields that act as constants rather than filters
- Comprehensive unit and integration test coverage with structural tuple equality assertions
@dan-petty
dan-petty merged commit 27caaf9 into release/v0.2.23 Sep 25, 2026
7 checks passed
@dan-petty
dan-petty deleted the feat/435-verdict-polarity-field-distribution branch September 25, 2026 15: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