Inspiration

I kept running into the same problem: people want to ask AI about resumes, medical notes, and financial stuff, but there's no way to prove the model only said what you allowed. Cloud APIs still get your full document. "We redact it, trust us" doesn't cut it for HR or healthcare.

So I split the problem in two. AI does the reasoning off-chain on redacted text. Midnight handles the proof that your disclosure rules actually held.

What it does

You paste a document (stays in your browser), flip on some disclosure rules - block SSN, salary, email, whatever - and ask questions.

Ollama runs locally. It only ever sees the redacted version. If the answer would leak something you blocked, I kill it. No attestation, no answer.

If it passes, Midnight writes an attestation on-chain. Just hashes. The document never touches the chain.

There's a panel that shows exactly what the AI sees, and an audit tab with the attestation trail.

How I built it

  • Ollama for local inference (no OpenAI, no cloud)
  • TypeScript policy engine - redact, validate, hash. Unit tested with Vitest
  • Node API - query pipeline ties it all together
  • Midnight Compact contract - PolicyAttestation with a localCompliance() witness
  • React + Vite frontend
  • Started from create-mn-app, local devnet via Docker

Flow is: redact → ask Ollama → validate the answer → hash everything → record on Midnight if it's clean.

Challenges I ran into

Compact was new to me. Figuring out witness boundaries - what stays off-chain vs what goes in the circuit - took a while.

Getting Midnight tooling, Node 22, and Docker playing nice on WSL2 was its own adventure.

I also spent a lot of time making sure the Ollama path was actually local end-to-end, and that the UI made that obvious to anyone watching the demo.

Accomplishments that I'm proud of

The full loop works: paste doc, set policy, ask a question, get blocked or get an attestation.

Salary questions get denied. Skills questions go through. You can see both in a 2-minute demo.

The document never hits the chain. Only SHA-256 hashes do. And you can literally see what text Ollama gets - not buried in a config file somewhere.

What I learned

You don't need to put sensitive data on-chain to prove compliance. Hashes are enough if you design for it from the start.

Redacting before inference is a simple idea but it actually works. The model never sees what you blocked.

Showing the failure case matters. A blocked salary question is more convincing than three successful ones.

Ollama is fine for a hackathon demo. Judges don't have to trust that I'm not sending data to OpenAI - they can watch it run on localhost.

What's next for PolicyLens

Policy templates by industry (HR, legal, healthcare). Lace wallet in the browser. Deploy beyond local devnet. Multi-doc sessions. Maybe a proper policy DSL down the line.

Built With

Share this project:

Updates

Submission history