Skip to content

Extract contract drift-threshold helper#143

Open
scottscott wants to merge 1 commit intonomoticai:mainfrom
scottscott:feat/runtime-record-verdict-slice-3
Open

Extract contract drift-threshold helper#143
scottscott wants to merge 1 commit intonomoticai:mainfrom
scottscott:feat/runtime-record-verdict-slice-3

Conversation

@scottscott
Copy link
Collaborator

Summary

Third runtime decomposition implementation slice: extract contract drift-threshold comparison from _record_verdict.

Key Changes

  • Added GovernanceRuntime._compute_contract_threshold_violations(contract, drift) in src/nomotic/runtime.py.
  • Updated _record_verdict(...) to call the helper instead of inlining threshold comparison logic.
  • Preserved existing verdict.metadata["contract_threshold_violations"] behavior.

Test Updates

  • Added focused unit tests in tests/test_runtime.py:
    • reports exceeded thresholds only
    • treats missing drift attributes as zero (no false positives)

Validation

  • pytest -q tests/test_runtime.py tests/test_contract.py -> 48 passed

Scope

  • Internal refactor only
  • No API changes
  • No config changes
  • No CI/workflow changes

Refactor GovernanceRuntime._record_verdict by extracting contract drift-threshold comparison into _compute_contract_threshold_violations.

Adds focused unit tests for helper behavior while preserving existing runtime contract semantics.

assisted-by: GitHub Copilot
@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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