Skip to content

fix(client): spread clearance renewal across tabs; recovery succeeds when the gate passes - #89

Merged
cport1 merged 1 commit into
mainfrom
fix/clearance-renewal-jitter
Nov 13, 2026
Merged

cport1 merged 1 commit into
mainfrom
fix/clearance-renewal-jitter

Conversation

@cport1

@cport1 cport1 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Two clearance fixes found in live multi-tab and production testing.

Renewal spread. All tabs share one cookie and computed the same renewal time (expiry minus 120 s), so two open tabs could each mint at the same moment. Each page now picks, once, a lead time between the margin and 1.5× the margin. renewalTime() is now the single place the renewal time is computed; it was duplicated in two places before.

  • Tests pin Math.random to 0, so the existing timings stay exact.
  • Two new tests cover the spread. Both fail when the spread is removed.

Recovery outcome. createClearanceFetch reported recovery-failed when the cleared retry reached the origin and the origin answered 404. Success now means the retry was not challenged again. The origin status stays in enforcement-outcome. The README is updated, plus two new tests (origin 404 → succeeded; challenged again → failed).

This changes the documented event meaning, so it ships as 0.24.0.

Build, lint and workspace tests pass locally (client: 59 tests).

…when the gate passes

Tabs share one clearance cookie, so they all reached the same renewal
instant and could each mint. Each page now draws a renewal lead time
between the margin and 1.5x the margin, so the first tab's cookie is
usually in place before the next one checks.

createClearanceFetch reported recovery-failed when a cleared retry got a
non-2xx answer from the origin. Success now means the retry was not
challenged again; the origin status stays in enforcement-outcome.
@cport1
cport1 merged commit a8c80f7 into main Nov 13, 2026
2 checks passed
@cport1
cport1 deleted the fix/clearance-renewal-jitter branch November 13, 2026 18:14
@cport1 cport1 mentioned this pull request Nov 13, 2026
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.

1 participant