Inspiration

AI-generated text now lands in invoices, quotes, announcements, and reports before anyone checks it. The errors that cause damage are often not subtle: a line total that does not multiply out, a due date that falls before the issue date, a unit conversion that is wrong, a confident claim credited to a source that is never cited. These errors are mechanically checkable, yet they are usually pasted and trusted on sight, and asking another model to fact-check them only adds a second layer of unverifiable prose.

ProofGate is a verification workspace for that moment. You paste an AI answer, a quote, an invoice, or an announcement, and ProofGate splits it into atomic claims and checks each one. Whatever can be checked deterministically is checked deterministically, in code, with the recomputed values shown next to the stated ones. Models are used only for what code cannot judge. A deterministic gate, never a model, issues the final verdict for every claim: PASS, NEEDS REVIEW, or FAIL, each with the evidence and the rule that produced it.

Every run produces a Proof Report: a sealed record (format proofgate.report/1) containing the original input, every check, every model output, and every verdict, sealed with a SHA-256 content hash. Anyone can recompute the hash to confirm the report was not altered, and the deterministic checks can be replayed against the stored input from the History screen. If a model call fails or times out, the report says so and the claim is routed to review; a failed model pass is never presented as a completed one.

In the live demo, the sample invoice line "Design services: 3 units at $2,800 = $9,400" fails: the arithmetic validator recomputes $8,400, and the cloud model pass independently records "contradicts" at confidence 1.00. An absolute "zero downtime" guarantee in the same text is judged uncertain by the model (confidence 0.90) and lands in NEEDS REVIEW for a human to decide.

How we built it

ProofGate is a Vite + TypeScript web app with a framework-free core engine, so the same code runs in the test suite and in the browser.

Claim pipeline. The input is split into atomic claims with their character spans preserved. Five deterministic validators then run per claim and across the whole document: arithmetic (equations, priced line totals, percent-of statements, all recomputed), dates (real-calendar validation, weekday cross-checks, issue-date vs due-date ordering), units (stated conversions recomputed against a fixed table), citations (URL and DOI form, plus a warning when a source is invoked but never cited), and numeric consistency (subtotal + tax = total, line-item sums, the same labelled figure stated with two different values).

Hybrid routing. Each claim is routed by a pure, replayable policy function. Short, plain claims stay deterministic-only and never leave the device. Standard claims go to on-device Gemini Nano through Firebase AI Logic hybrid inference (PREFER_ON_DEVICE), which keeps the text private and works without a network round trip. Claims escalate to the cloud model (Gemini 3.8 Flash, ONLY_IN_CLOUD) when a trigger fires: high-stakes wording such as guarantees and absolutes, a deterministic warning, excessive length, or an on-device pass that is unavailable or uncertain. Every escalation is recorded in the report with its reason, and the report shows which tier actually ran for each claim.

Deterministic gate. Verdicts come from four rules in src/gate.ts, evaluated in order. R1: any hard validator failure is a FAIL, and no model output can override it. R2: a model contradiction at confidence 0.7 or above is a FAIL. R3: warnings, weak contradictions, uncertain model output, or low-confidence support go to NEEDS REVIEW. R4: everything else passes. The report-level verdict is worst-claim-wins.

Reports, sealing, and replay. Reports are canonical JSON (keys sorted recursively) hashed with SHA-256; the input text is hashed separately. Recomputing the seal detects any change to inputs, checks, model outputs, or verdicts. Replay re-runs the deterministic stages against the stored input and compares claim by claim; model outputs are stored rather than re-derived, because model behaviour is not deterministic. Reports persist in the browser and are listed, searchable, and replayable on the History & Replay screen.

Firebase. Gemini access goes through Firebase AI Logic (Firebase JS SDK) only; there are no Gemini API keys in the client code. Firebase App Check is enforced on the project, with a registered debug token for the public demo. When no Firebase configuration is present, the app runs in a labelled demo mode with a deterministic mock model adapter; the deterministic checks are identical in both modes.

Testing. 84 automated tests (Vitest) cover every validator, the gate rules including "a model can never override a hard failure," routing tiers, report sealing and tamper detection, App Check initialization guarding, model-call timeout behaviour, and the end-to-end invoice case.

Challenges

Model calls that never returned. Our first live runs hung indefinitely: the pipeline reached the model stage and never finished, with no error anywhere. The cause was unbounded generateContent calls — a promise that never settles never triggers the on-device-to-cloud escalation, which only fires on rejection. We bounded every model call (30 seconds at the adapter, 90 seconds per claim at the engine), drove the progress indicators from real engine events instead of a timer, and made a timed-out or failed model pass produce an explicit "model unavailable" record that routes the claim to review rather than blocking the run.

App Check 401s. Once calls returned at all, they failed with "401 Firebase App Check token is invalid": the project had App Check enforcement on but no attestation provider or debug token registered, so the backend rejected the SDK's token. We registered a debug token for the web app in the Firebase console (accepted for demos under the event rules) and wired App Check initialization into the client before the first AI Logic call, guarded so it can never crash or hang a run.

The default cloud model was retired mid-build. With App Check passing, the cloud calls then failed with a 404: gemini-2.5-flash is no longer available to new users. We moved the cloud model to gemini-3.8-flash, the replacement named in the API's own error message, and made the model ID a single named configuration constant so the next retirement is a one-line change.

What we learned / What's next

The main lesson is that a verification product has to be honest about its own failures first. Bounded calls, recorded escalation reasons, and an explicit unavailable state took more work than the happy path, and they are most of what makes the output safe to act on. We also learned that in a hybrid setup the routing policy is part of the evidence: showing which tier ran, and why, matters as much as the verdict.

Next steps: Firestore persistence so reports can be shared by link instead of living only in one browser, a reCAPTCHA-based App Check provider for production use beyond the demo token, and wider validator coverage (number-words prose such as "three sessions at eight hundred each" is currently routed to the model tier instead of being recomputed).

Built With

Share this project:

Updates

Submission history