Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_code-regex-and-parser-backtracking

Regex Engines, Parser Backtracking & ReDoS Prevention (RE2 / NFA vs DFA)

6 COMPONENTS · 6 FLOWS · UPDATED 2026-11-24
GITHUB README / PR PREVIEW CARD
[![Regex Engines, Parser Backtracking & ReDoS Prevention (RE2 / NFA vs DFA) — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_code-regex-and-parser-backtracking/opengraph-image)](https://archos.sageideas.dev/d/dgm_code-regex-and-parser-backtracking)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_code-regex-and-parser-backtracking)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_code-regex-and-parser-backtracking" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Regex Engines, Parser Backtracking & ReDoS Prevention (RE2 / NFA vs DFA) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0["Untrusted Input String"]
  n1_1["Syntax & AST Compiler"]
  n2a_2["Thompson NFA / RE2"]
  n2b_3["Backtracking Guard"]
  n3_4["Safe Match / AST"]
  downstream_5["Downstream & OTel"]
  client_0 -->|"1. Compile · AST"| n1_1
  n1_1 -->|"2a. Step · Linear"| n2a_2
  n1_1 -->|"2b. Lint ReDoS · Check"| n2b_3
  n2a_2 -->|"3a. Emit match · ON"| n3_4
  n2b_3 -->|"3b. Merge · RAM"| n3_4
  n3_4 -.->|"4. Emit / · OTLP/API"| downstream_5

COMPONENT STACK (6)

  • Untrusted Input StringSTATELESS
    User Regex / Log / URL
  • Syntax & AST CompilerSTATELESS
    Compiles pattern -> NFA/DFA
  • Thompson NFA / RE2STATELESS
    Parallel active states · O
  • Backtracking GuardSTATELESS
    Warns on nested quantifiers +
  • Safe Match / ASTSTATELESS
    Bounded O parse zero CPU hang
  • Downstream & OTelSTATELESS
    Consumers, metrics & SLOs

REQUEST & DATA FLOW (6)

  1. Untrusted Input String → Syntax & AST Compiler (Compile)[AST]
  2. Syntax & AST Compiler → Thompson NFA / RE2 (Step)[Linear]
  3. Syntax & AST Compiler → Backtracking Guard (Lint ReDoS)[Check]
  4. Thompson NFA / RE2 → Safe Match / AST (Emit match)[ON]
  5. Backtracking Guard → Safe Match / AST (Merge)[RAM]
  6. Safe Match / AST → Downstream & OTel (Emit /)[OTLP/API]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →