The connection lit up like a live wire, but no SQL left the app yet. Between your client and Postgres, something else listened. It wasn’t psql. It wasn’t a TCP dump. It was a proxy — speaking the Postgres binary protocol fluently, without losing a single byte of intent.
Ramp’s contracts team built such a proxy to control and secure database access in real time. They didn’t settle for text-based parsing or slow query inspection. They sat in the middle of the Postgres binary protocol, decoding packets on the fly, enforcing rules, and even reshaping responses. This level of control is possible because the Postgres wire format is well-documented but rarely leveraged in production for custom policy enforcement.
Most proxies speak HTTP. Very few understand Postgres at the binary level. When you proxy the binary protocol, you can intercept startup messages, authentication, simple query mode, and extended query mode without forcing clients to change. You can map incoming prepared statements to specific contract rules, reject hazardous commands, and log execution details with millisecond precision.
For Ramp, contracts were not just legal documents; they were executable database policies. By placing a protocol-aware proxy between services and Postgres, they could apply those policies consistently and atomically. No ORM-specific plugins. No runtime patches in app code. Just a transparent layer enforcing what must happen every time a query crosses the wire.