mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-26 23:50:17 +00:00
fix: add debug_assert invariant guards to critical code paths (#1312)
* fix: add debug_assert invariant guards to critical code paths (closes #1215) Add three debug_assert! calls to catch impossible-in-correct-code states early in debug builds without affecting release performance: - execute_tool_with_safety: assert tool_name is non-empty at entry - JobContext::transition_to: assert state machine transition is valid - CircuitBreakerProvider::record_success: assert circuit is not Open (check_allowed() must gate all calls before record_success()) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * test: add regression test for empty tool name invariant guard Covers the debug_assert!(!tool_name.is_empty()) added in execute_tool_with_safety. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
2d0b195321
commit
07e6e30ee3
@@ -167,6 +167,12 @@ impl CircuitBreakerProvider {
|
||||
}
|
||||
}
|
||||
CircuitState::Open => {
|
||||
debug_assert!(
|
||||
false,
|
||||
"BUG: record_success() called while circuit breaker is Open — \
|
||||
check_allowed() was bypassed for provider {}",
|
||||
self.inner.model_name()
|
||||
);
|
||||
// Shouldn't get here (check_allowed blocks Open), but recover
|
||||
state.state = CircuitState::Closed;
|
||||
state.consecutive_failures = 0;
|
||||
|
||||
Reference in New Issue
Block a user