Bound the initial circuit-breaker timestamp by construction (#4921)

The race suite observed a correct timestamp before the old lower bound
because the fixture sampled the clock after constructing the breaker.
Bracket the constructor itself and verify that closed state and its
initial transition share that timestamp.

Contract-Neutral: Only the closed-state test clock window changes.
Breaker policy, thresholds, timestamp production, and open and half-open
fixtures are unchanged.

---
Fleet candidate `20261122T203537Z-core-runtime` from the `core-runtime`
lane. Reviewed tip `b1178a7dcd117c8f496f0bb335a16b78a68bc516` on `main`.

[How Pulse handles
triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
pulse-triage[bot]
2026-11-22 21:47:36 +00:00
committed by GitHub

View File

@@ -487,8 +487,9 @@ func TestCircuitBreaker_Allow(t *testing.T) {
func TestCircuitBreaker_StateDetails(t *testing.T) {
t.Run("closed state", func(t *testing.T) {
beforeCreate := time.Now()
cb := newCircuitBreaker(3, 5*time.Second, 5*time.Minute, 30*time.Second)
beforeCreate := time.Now().Add(-time.Millisecond)
afterCreate := time.Now()
state, failures, retryAt, since, lastTransition := cb.stateDetails()
@@ -501,11 +502,11 @@ func TestCircuitBreaker_StateDetails(t *testing.T) {
if !retryAt.IsZero() {
t.Errorf("retryAt = %v, want zero time", retryAt)
}
if since.Before(beforeCreate) {
t.Errorf("since = %v, should be after %v", since, beforeCreate)
if since.Before(beforeCreate) || since.After(afterCreate) {
t.Errorf("since = %v, want within construction window [%v, %v]", since, beforeCreate, afterCreate)
}
if lastTransition.Before(beforeCreate) {
t.Errorf("lastTransition = %v, should be after %v", lastTransition, beforeCreate)
if !lastTransition.Equal(since) {
t.Errorf("lastTransition = %v, want initial state timestamp %v", lastTransition, since)
}
})