Skip to content
This repository was archived by the owner on Nov 2, 2026. It is now read-only.

Commit 98f32e6

Browse files
fix(usage): confirm a reset by the probe timestamp moving, not a masked reason
The post-redeem check looked for a probeFailed reason on the refreshed snapshot, but the probe resolver republishes the last good limits when a probe fails and bars already exist, so that reason never appeared and a failed confirmation reported success with stale bars. The check now requires the published checkedAt to advance past the pre-redemption value. Co-Authored-By: Claude Code <[email protected]>
1 parent 3e6727c commit 98f32e6

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

‎apps/server/src/provider/Drivers/CodexDriver.ts‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,27 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
274274
}),
275275
),
276276
// The windows just changed; re-probe so the snapshot says so. A
277-
// refresh that fails keeps the pre-redemption snapshot, credit
278-
// count included, so the refresh's own failure is surfaced.
277+
// failed probe republishes the pre-redemption limits rather than
278+
// marking them failed, so "confirmed" means `checkedAt` moved
279+
// past what was published before the redemption started.
279280
Effect.tap(() =>
280-
snapshot.refresh.pipe(
281-
Effect.flatMap((refreshed) =>
281+
Effect.gen(function* () {
282+
const before = (yield* snapshot.getSnapshot).usageLimits?.checkedAt;
283+
const refreshed = yield* snapshot.refresh;
284+
const after = refreshed.usageLimits?.checkedAt;
285+
if (
286+
after === undefined ||
287+
after === before ||
282288
refreshed.usageLimits?.unavailable?.reason === "probeFailed"
283-
? new ProviderDriverError({
284-
driver: DRIVER_KIND,
285-
instanceId,
286-
detail:
287-
"The reset was applied, but Codex could not confirm the new limits. Refresh to check.",
288-
})
289-
: Effect.void,
290-
),
291-
),
289+
) {
290+
return yield* new ProviderDriverError({
291+
driver: DRIVER_KIND,
292+
instanceId,
293+
detail:
294+
"The reset was applied, but Codex could not confirm the new limits. Refresh to check.",
295+
});
296+
}
297+
}),
292298
),
293299
);
294300

0 commit comments

Comments
 (0)