Skip to content

fix: only let a successful half-open call close the circuit - #37

Merged
costela merged 2 commits into
mainfrom
fix/inflight-calls-do-not-close
Oct 9, 2026
Merged

costela merged 2 commits into
mainfrom
fix/inflight-calls-do-not-close

Conversation

@costela

@costela costela commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

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

  • Only a successful half-open call closes the circuit. Any call can still open it.
  • Regression test with both real breakers: calls admitted while closed that succeed after the circuit opened leave it open, a failing half-open call after them keeps it open, and a successful one closes it (fails on main).

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread hoglet.go Outdated
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 costela changed the title fix: only let a half-open call close an open circuit fix: only let a successful half-open call close the circuit Oct 9, 2026
@costela
costela marked this pull request as ready for review October 9, 2026 10:57
@costela
costela merged commit 2e71952 into main Oct 9, 2026
2 checks passed
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.

3 participants