Skip to content

Commit 1ec5a36

Browse files
committed
test(retry): verify terminal Exit is Cause.done in budget-cap test
Code-quality review (codex-5.3) flagged that the budget-cap test broke the loop on first non-success Exit without verifying the termination semantics. A regression that terminated via Cause.fail would still pass. Capture the terminal exit, assert Exit.isFailure, and assert Cause.isDone(terminal.cause) so the test specifically pins the happy termination path (schedule completed normally) vs a defect/fail path. Addresses review of 1b8f62d.
1 parent 1b8f62d commit 1ec5a36

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

packages/opencode/test/session/retry.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"
22
import type { NamedError } from "@opencode-ai/shared/util/error"
33
import { APICallError } from "ai"
44
import { setTimeout as sleep } from "node:timers/promises"
5-
import { Effect, Exit, Layer, Schedule } from "effect"
5+
import { Cause, Effect, Exit, Layer, Schedule } from "effect"
66
import { SessionRetry } from "../../src/session/retry"
77
import { MessageV2 } from "../../src/session/message-v2"
88
import { SSEStallError } from "../../src/provider/provider"
@@ -295,11 +295,21 @@ describe("SessionRetry.policy — transport retry budget", () => {
295295
}),
296296
)
297297
const now = 0
298+
let terminal: Exit.Exit<unknown, unknown> | undefined
298299
for (let i = 0; i < 10; i++) {
299300
const exit = yield* Effect.exit(step(now, wrap("connect ETIMEDOUT 1.2.3.4")))
300-
if (!Exit.isSuccess(exit)) break
301+
if (!Exit.isSuccess(exit)) {
302+
terminal = exit
303+
break
304+
}
301305
}
306+
// 5 delay/set invocations for retries, then the 6th call returns Cause.done(6)
302307
expect(setCalls).toBe(5)
308+
expect(terminal).toBeDefined()
309+
if (!Exit.isFailure(terminal!)) throw new Error("expected terminal exit to be Failure")
310+
// Policy signals "stop retrying" via Cause.done(n), not Cause.fail.
311+
// Cause.isDone confirms schedule completed normally, not crashed.
312+
expect(Cause.isDone(terminal.cause)).toBe(true)
303313
}),
304314
)
305315
})

0 commit comments

Comments
 (0)