If you've ever wired an LLM agent or a text-to-SQL script up to a Postgres database, you know the anxiety: one bad hallucination and the model runs a DROP TABLE , wipes rows with an unconstrained DELETE , or gets stuck in a loop that burns through your compute budget.
Most teams try to fix this with regex filters or by asking a second LLM to check the query first. In practice, regex breaks the moment a query has inline comments or nested CTEs, and using an LLM-as-a-judge adds hundreds of milliseconds of latency while still being non-deterministic.
I wanted a deterministic guardrail at the network layer, so I built Aegis —an open-source Layer-4 Postgres proxy written in Go.
Why WebAssembly (wazero) Instead of cgo?
To parse Postgres queries properly, you really want Postgres's actual C parser ( libpg_query ).…