Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/agentassert_abc/monitor/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def _session_summary_internal(self) -> SessionSummary:
d_bar=self._drift.mean_drift,
events=self._total_events,
recovery_rate=recovery_rate,
weights=self._contract.reliability.weights if self._contract.reliability else None,
)

return SessionSummary(
Expand Down
28 changes: 28 additions & 0 deletions tests/test_monitor/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,34 @@ def test_perfect_session_theta(self) -> None:
summary = monitor.session_summary()
assert summary.theta >= 0.90 # Deployment ready

def test_session_theta_uses_contract_reliability_weights(self) -> None:
from agentassert_abc.dsl.parser import loads_contract
from agentassert_abc.monitor.session import SessionMonitor

contract = loads_contract("""
contractspec: "0.1"
kind: agent
name: test
description: test
version: "1.0.0"
invariants:
hard:
- name: check
check:
field: x
equals: true
reliability:
weights:
compliance: 1.0
drift: 0.0
recovery: 0.0
stress: 0.0
""")
monitor = SessionMonitor(contract)
monitor.step({"x": False})

assert monitor.session_summary().theta == 0.5


class TestCheckPreconditions:
"""check_preconditions() from patent §3.2 step 2."""
Expand Down