Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.
Python agent-evaluationaiai-alignmentai-evaluationai-governanceai-safetyclidiagnostic-tooleu-ai-acthallucination-detectioniso-42001llm-evaluationllm-securitynist-ai-rmfowasp-llmprompt-injectionpythonresponsible-airisk-assessmentrisk-management
fix(trajectory): refuse invoke before the callable runs at the event bound (#327)
Rudy Mizrahi Celekli6cb3cf05495e
diff --git a/ifixai/tests/trajectory/test_recorder.py b/ifixai/tests/trajectory/test_recorder.pyindex bca8efd..b0401b0 100644--- a/ifixai/tests/trajectory/test_recorder.py+++ b/ifixai/tests/trajectory/test_recorder.py@@ -179,3 +179,15 @@ def test_clock_regression_is_clamped_and_invalid_clock_fails():assert [event.time_ns for event in trace.seal().events] == [10, 10, 10]with pytest.raises(ValueError):TraceRecorder("tenant", "collector", clock_ns=lambda: True)+++def test_event_bound_rejected_before_callable_executes():+ trace = recorder()+ source = SourcePayload(actor_id="a", resource="source:one", content_digest="a" * 64)+ while len(trace._events) < 99999:+ trace.emit(source)+ calls = []+ with pytest.raises(ValueError, match="event bound"):+ trace.invoke(lambda: calls.append("side effect"), actor_id="actor", action="write", resource="local:one", arguments={})+ assert calls == []+ assert len(trace._events) == 99999diff --git a/ifixai/trajectory/recorder.py b/ifixai/trajectory/recorder.pyindex 16e9754..6bfc3d7 100644--- a/ifixai/trajectory/recorder.py+++ b/ifixai/trajectory/recorder.py@@ -117,6 +117,8 @@ class TraceRecorder:with self._lock:if self._sealed:raise RuntimeError("recording is already sealed")+ if len(self._events) >= 99999:+ raise ValueError("event bound reached; reserve the final end event")# Validate requested links before any callable side effect.links = parents or (self._events[-1].event_id,)TraceEvent(event_id="0" * 16, trace_id=self._trace_id, tenant_id=self._tenant_id, sequence=len(self._events) + 1, time_ns=self._events[-1].time_ns, parents=links, payload=template)