Skip to content

test(keys): race-detector stress the key-rotation trust path under load - #13

Closed
terraboops wants to merge 1 commit into
fix/audience-allowlistfrom
test/rotation-race-audit
Closed

terraboops wants to merge 1 commit into
fix/audience-allowlistfrom
test/rotation-race-audit

Conversation

@terraboops

Copy link
Copy Markdown
Contributor

What (§1 concurrency/race audit — the key-rotation trust path)

Audits key rotation under concurrency. Source review: Set (RWMutex over current/retired), Published (RWMutex over the merged union), and the proxy's atomic.Pointer swap are all lock-disciplined. This test backs that with a probe rather than asserting it.

TestKeyRotationConcurrencyUnderLoad: a rotator churns the signing key while 8 signers mint-and-verify, 2 readers hammer both JWKS views, and a publisher writes/re-reads the shared union — all concurrently. The suite's -race run flags any missing lock. It also asserts the trust-path invariant: a token minted with the current key stays verifiable through concurrent rotations while inside the overlap window.

Result: clean (no defect)

~12k–20k sign+verify cycles/run, no data race, invariant holds.

Probe validated: I injected a race (dropped Set.PublicKey's read lock) and -race reliably flagged DATA RACE; the committed code passes. So the clean result is meaningful, not a probe that can't see races.

Durable: CI already runs go test -race ./..., so this runs on every change.

No merge — review only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SDfMmeRXGsanqzDDSjL1uU

Concurrency/race audit of key rotation. Source review shows Set (RWMutex over
current/retired), Published (RWMutex over the merged union) and the proxy's
atomic.Pointer swap are all lock-disciplined. This test backs that with a probe:
a rotator churns the signing key while eight signers mint-and-verify, two
readers hammer both JWKS views, and a publisher writes/re-reads the shared
union — all concurrently, so the suite's -race run flags any missing lock.

It also asserts the trust-path invariant: a token minted with the current key
stays verifiable through concurrent rotations while inside the overlap window.

Result: clean. ~12k-20k sign+verify cycles per run, no data race, invariant
holds. The probe was validated by injecting a race (dropping Set.PublicKey's
read lock), which -race reliably flagged; the committed code passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SDfMmeRXGsanqzDDSjL1uU
@terraboops
terraboops force-pushed the test/rotation-race-audit branch from 59cb502 to 8ba6740 Compare September 27, 2026 08:54
@terraboops
terraboops changed the base branch from main to fix/audience-allowlist September 27, 2026 08:54
@terraboops
terraboops deleted the branch fix/audience-allowlist September 28, 2026 01:50
@terraboops terraboops closed this Sep 28, 2026
@terraboops
terraboops deleted the test/rotation-race-audit branch September 28, 2026 02:43
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