Skip to content

Extract behavior ledger append helper#146

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

Extract behavior ledger append helper#146
scottscott wants to merge 1 commit intonomoticai:mainfrom
scottscott:feat/runtime-record-verdict-slice-6

Conversation

@scottscott
Copy link
Collaborator

Summary

Sixth runtime decomposition implementation slice: extract BehaviorLedger append flow from _record_verdict.

Key Changes

  • Added GovernanceRuntime._append_behavior_ledger_entry(action, context, verdict, tracer, derived_thresholds) in src/nomotic/runtime.py.
  • Replaced inline BehaviorLedger construction/append logic in _record_verdict(...) with a helper call.
  • Preserved behavior for drift/semantic observer wiring and threshold selection.

Test Updates

  • Added focused tests in tests/test_runtime.py:
    • test_append_behavior_ledger_entry_uses_default_thresholds
    • test_append_behavior_ledger_entry_uses_derived_thresholds
    • test_append_behavior_ledger_entry_noop_without_ledger_or_tracer

Validation

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

Scope

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

Refactor GovernanceRuntime._record_verdict by moving BehaviorLedger entry construction and append logic into _append_behavior_ledger_entry.

Adds focused tests for default thresholds, derived thresholds, and no-op behavior when ledgering is disabled.

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