Eliminating Catastrophic ReDoS & Floating-Point Drift in AI-Generated Production Code

Reference patterns for linear O(n) token regexes and exact BigInt integer-cent arithmetic enforced by RailCall static oracles.

Eliminating Catastrophic ReDoS & Floating-Point Billing Drift

Two defects appear constantly in unverified AI-generated backend code:

  1. Nested Quantifier ReDoS (^([a-zA-Z0-9]+)+$): A 32-byte malformed header freezes the Node.js event loop for >14,000ms. Replace with bounded linear character classes (/^[A-Za-z0-9]{1,128}$/).
  2. IEEE-754 Float Currency Drift (19.99 * 3 === 59.970000000000006): Parse decimal strings directly into BigInt mills/cents before multiplication and round half-up via (mills + 5n) / 10n.

Write a comment