Repository navigation
fix: only let a successful half-open call close the circuit - #37
Merged
Merged
Conversation
Any call reporting a success the breaker deemed healthy enough closed the circuit, including calls admitted before it opened and still in flight. Those say nothing about whether the upstream recovered, so they cut the half-open delay short and let the full load back in without a probe. The circuit now only applies a close for calls admitted half-open. Any call can still open it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Stale successes still mutate breaker health and can cause a subsequent failed half-open probe to close the circuit.
1 open finding
What changed in this PR
Prevents in-flight calls admitted before circuit opening from immediately closing it.
Changes:
- Restricts circuit closure to half-open calls.
- Adds a regression test for stale successful calls.
| File | Description |
|---|---|
hoglet.go |
Guards circuit closure by admission state. |
hoglet_test.go |
Tests that a stale success leaves the circuit open. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A call admitted before the circuit opened could no longer close it, but its success still lowered the breaker's failure rate. A failing half-open call could then come out at or below the threshold, and the circuit closed on it, since it was admitted half-open. Close only on a successful half-open call. The failure rate the breaker keeps while the circuit is open then has no effect, and a successful half-open call resets both breakers, so stale successes leave no trace. The regression test now uses both real breakers, since the mock breaker never reports a close for a failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
costela
marked this pull request as ready for review
October 9, 2026 10:57
vietuoso
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
Any successful call the breaker deemed healthy closed the circuit, including calls admitted before it opened and still in flight. They say nothing about whether the upstream has recovered, so they cut the half-open delay short and let the full load back in without a probe. Their successes also lower the failure rate, so a failing half-open call could still come out below the threshold and close the circuit.
What
main).🤖 Generated with Claude Code