Race condition testing

From xalgorix/xalgorix · View interactive version

Race condition testing is an AI agent skill from the GitHub repository xalgorix/xalgorix. Application-level concurrency abuse - identify race-prone business operations (coupons, payments, withdrawals, quotas, OTP, invites) and synchronize parallel requests with bounded concurrency to prove a duplicated persistent effect: double-spend, limit overrun, duplicate creation, TOCTOU.

How to use this skill

Skill file

Race Condition and Concurrency Testing

Purpose

Many business invariants ("once per user", "balance cannot go negative", "limited stock") are enforced with check-then-act logic that two near-simultaneous requests defeat. This skill covers WHICH operations are race-prone, HOW to synchronize concurrent requests from inside Xalgorix with bounded concurrency, and WHAT proof looks like (a duplicated persistent effect, never N status codes).

Entry Conditions

Race-Prone Operation Candidates

Signals in code-less form: any "check then act" wording in error messages ("You have already used this coupon"), counter fields returned by the API, or limits that appear to update AFTER a response.

Methodology

baseline single request
-> identify the invariant (what must be true about final state)
-> synchronize N concurrent identical requests
-> observe FINAL backend state (re-fetch, never trust the responses alone)
-> repeat enough batches to distinguish race from noise
-> prove persistent impact
  1. Baseline: perform the operation once legitimately; capture the request and the resulting state (balance, counter, list length).
  2. Invariant: state what must hold ("coupon redemption count per user <= 1").
  3. Synchronize: fire N identical copies as simultaneously as the platform allows (see techniques). N modest first (5-20), increase only if promising.
  4. Observe final state: re-fetch the counter/balance/list. Compute how many effects persisted.
  5. Repeat: races are probabilistic - a single clean batch is NOT a negative; repeat batches (and increase tightness) before concluding not vulnerable. Conversely a single hit IS a positive - reproduce at least once more for confidence.
  6. Prove impact: show the duplicated effect persists (double credit, two orders, negative balance, redemption count 2).

Synchronization Techniques (Xalgorix-Native First)

Technique ladder: naive parallel -> warmed connections -> single-packet/last-byte. Escalate only when the previous tier shows near-misses (e.g. responses arrive same millisecond but state stayed consistent).

Race Classes

Evidence Contract

Not enough: two concurrent requests both returned 200.

Good proof: the balance/resource/limit reflects a duplicated effect that should only occur once - balance went negative or two transfers persisted from one balance; coupon redemption counter reads 2; two orders exist for one purchase entitlement.

Attach: baseline request, the synchronized batch description (N, technique), and the BEFORE vs AFTER backend state read. Report the duplicated-effect count.

Common Misses

False Positives

Xalgorix Tool Strategy

When to Load a Specialist Skill

Stopping Rule

Stop racing an operation after: the invariant is stated, two sync-tightness tiers were tried (naive parallel + warmed/single-packet), at least 2-3 batches per tier were run, and final state was re-fetched each time. A proven race: reproduce once more, then move to proving full impact (how far does the double-spend scale?). A clean operation after the ladder: close the hypothesis with the batch evidence attached.

Handoffs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.