A compliance layer for a finance-education AI assistant
Guardrails, PII scanning, a hash-chained audit ledger and a test gate that stopped lying. Live in production since September 2026.
The problem
A financial-education AI assistant for people aged 25 to 34 had to talk about money all day without giving personal investment advice, promising returns or leaking anyone’s personal data. In English and Spanish. One bad answer is a regulatory problem, so the client needed proof that the rules hold, not a demo.
What I built
The backend that sits between the users and the model:
- Input and output guardrails in English and Spanish that redirect advice requests and block return guarantees.
- A PII scanner that strips social security numbers, card numbers and addresses before anything is logged or sent to a model.
- A hash-chained audit ledger. Every blocked request becomes a block that can be verified later.
- A dual-model cascade (Claude first, DeepSeek as fallback), so the assistant stays up when one provider is down.
How it was tested
- An adversarial fuzzer with 35 attack strings, then a Promptfoo matrix: 86 of 86 cases passed.
- A concurrency suite of 25 parallel requests across 4 test types, k6 load tests and optimistic locking on the order route.
- A 245-skill security catalog run against the backend. 7 critical findings, all fixed.
- In August I rebuilt the test gate into 51 suites in four tiers so it can no longer report a skipped suite as a pass. That rebuild found 5 real defects every earlier “all green” had missed, including an encryption bug that would have made the ledger report itself as tampered on the first production deploy.
Result
Live in production since 2 September 2026. The service holds up to about 700 concurrent users, around 215 requests per second.
What I would do differently
Measure the compliance trail, not just the API. Under peak load requests kept returning 200 while only about 6 audit blocks per second reached the ledger. And watch idle workers: one of ours polled a shared Redis 864,000 times a day against a 500,000 cap. Switching to a blocking read cut that 60 times. The audit trail survived because writes fall back to synchronous mode, which is exactly why that fallback exists.