claim invariant: quiesce waits for two consecutive quiet windows
quiesce returned after one 100ms window with no new raw effect. It now needs two in a row (still at most 5s), so a handler goroutine that is starved of CPU for one window is still measured with its own request. Strictly more conservative; the window stays 100ms. Groundwork for running the invariant's cases in parallel (amadan #291 option 3).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+13
−6
internal/console/claim_invariant_world_test.go+13 −6
diff --git a/internal/console/claim_invariant_world_test.go b/internal/console/claim_invariant_world_test.go| index 980a96b04..6b56214f3 100644 |
| --- a/internal/console/claim_invariant_world_test.go |
| +++ b/internal/console/claim_invariant_world_test.go |
| @@ -718,18 +718,25 @@ func (cx *claimCase) foreign(t *testing.T, ref claimAppRef) func() { |
| } |
| } |
| -// quiesce waits until no raw effect has arrived for one 100ms window (at |
| -// most 5s), so a goroutine a handler started is measured with its request. |
| +// quiesce waits until no raw effect has arrived for two consecutive 100ms |
| +// windows (at most 5s), so a goroutine a handler started is measured with its |
| +// request. Two windows, not one: the invariant runs its doors in parallel |
| +// (claimCaseParallelism), and a goroutine starved of CPU for one window must |
| +// still land in its own request's measurement, not the next one's. |
| func (cx *claimCase) quiesce() { |
| + const window = 100 * time.Millisecond |
| deadline := time.Now().Add(5 * time.Second) |
| - n := cx.rec.mark() |
| + n, quiet := cx.rec.mark(), 0 |
| for time.Now().Before(deadline) { |
| - time.Sleep(100 * time.Millisecond) |
| + time.Sleep(window) |
| m := cx.rec.mark() |
| - if m == n { |
| + if m != n { |
| + n, quiet = m, 0 |
| + continue |
| + } |
| + if quiet++; quiet == 2 { |
| return |
| } |
| - n = m |
| } |
| } |