PROOFLINE — FACT-CHECK HANDOFFS AGAINST REAL CODE EVIDENCE
Complete Devpost Submission
Inspiration
Every software team runs on handoffs. A developer finishes a feature, writes a PR description, posts a standup update, or hands off a sprint to the next team. Those documents contain factual claims: "All tests are passing." "Refactored the auth module." "No breaking changes to the public API." "Added refresh token rotation."
Nobody verifies those claims against the actual code.
Not because developers are careless. Because there has never been a tool that could. Existing verification tools — handoff-verify, confab-framework, loopuccino, tycho-cli — are deterministic parsers built for machine-generated agent transcripts. They work well for structured output. They cannot parse a sentence a human wrote. The moment a developer writes prose instead of a log entry, every existing tool is blind.
The result is that reviewer trust is built on unverified assumptions. A reviewer reads "all tests passing" and starts their review from that assumption. If the claim is wrong, they debug in the wrong direction. Teams ship code whose handoff documentation described a different codebase. Bugs survive not because they weren't caught by tests, but because the handoff said the tests that would have caught them were green.
The handoff is the last human-written checkpoint before code reaches a reviewer. It has never been verified. We built Proofline to verify it.
What It Does
Proofline is a handoff truth engine. It takes three inputs — a human-written handoff document (PR description, standup note, sprint transition doc, incident post-mortem), a git diff, and test output — and produces a verdict for every factual claim in that document.
The verdicts are: SUPPORTED, CONTRADICTORY, STALE, UNSUPPORTED, or UNKNOWN.
A claim that says "Added refresh token rotation" against a diff that shows no refresh-token-related file was touched gets a 🔴 CONTRADICTORY verdict. A claim that says "All 4 tests passing" against test output that shows 3 of 4 passing gets a 🔴 CONTRADICTORY verdict. A claim that says "Updated the session handler" against a diff that shows session.ts was modified gets a ✅ SUPPORTED verdict. A claim that cannot be evaluated from available evidence gets ❓ UNSUPPORTED or UNKNOWN.
How that happens — three layers:
Layer 1 — On-Device Extraction (Gemini Nano): The raw handoff text, raw diff, and raw test output enter Gemini Nano running entirely in the browser via Firebase AI Logic. Gemini Nano extracts discrete factual claims from the human prose and produces an abstracted evidence summary — a plain-language description of what the code does, with no literal source code, variable names, or function bodies. Your source code never leaves your device. Not because of a privacy policy. Because of architecture.
Layer 2 — Deterministic Parsing (Rust → WebAssembly): A Rust binary compiled to WebAssembly independently parses the same diff and test output and produces hard counts: files changed, tests passed, tests failed, failed test names, file paths, modules touched. These counts overwrite the model's self-reported counts. The AI cannot hallucinate a test count that the parser has already measured. This is the layer that makes the verdicts trustworthy rather than just plausible.
Layer 3 — Cloud Verdict (Gemini Flash via Firebase AI Logic): Gemini Flash in the cloud receives the abstracted evidence summary from Layer 1 and the deterministic counts from Layer 2. It never receives the raw diff or raw source code. It classifies each claim into one of the five verdicts with a one-sentence reasoning statement citing which specific evidence field drove the conclusion. All claims are classified in parallel. Every verdict includes a badge showing which inference path was taken — 🟢 On-Device or ☁️ Cloud.
Every verdict is fully explainable. The evidence drawer on each claim shows three sections with three distinct badges: what Gemini Nano abstracted on-device, what the Rust parser measured deterministically, and what Gemini Flash concluded from those two inputs. Users can override any verdict, provide a reason, and the override is stored — feeding back into prompt evaluation over time.
The result is exportable as a structured markdown report that travels with the handoff.
How We Built It
Monorepo architecture: Turborepo + pnpm workspaces. Four packages: evidence-parser (Rust → WASM), firebase-layer (all Firebase SDK calls in one place), shared-types (Zod schemas and derived TypeScript types), and ui (shared components). One apps/web consuming all four. CI via GitHub Actions. Linting and formatting via Biome (the Rust-based replacement for ESLint + Prettier).
Frontend: React 19 + TypeScript 5.7 strict mode + Vite 6. UI components via shadcn/ui + TailwindCSS 4. State via Zustand. Data fetching via TanStack Query. Animations via Framer Motion — used in one place only: the verdict badge reveal. The constraint was intentional. Using Framer Motion everywhere is decoration. Using it at the moment of verdict appearance makes the reveal feel significant.
Evidence Parser — Rust compiled to WebAssembly: Plain Rust compiled via wasm-pack with opt-level = "z" and lto = true. Final binary: under 80KB after wasm-opt. The parser handles five test output formats — Jest, Pytest, Go test, Mocha, and Vitest — using a format detection state machine that identifies the runner before attempting to parse results. The state machine was necessary because the five formats have overlapping syntax and naive pattern matching produces false positives on test count extraction. The parser also handles unified diff format across all languages, extracts file paths, counts hunks, and identifies module structure from directory paths. Zero AI, zero third-party runtime dependencies, fully deterministic. The same input always produces the same counts.
Firebase AI Logic — Hybrid Inference:
Layer 1 uses InferenceMode.PREFER_ON_DEVICE. initializeDeviceModel() is called on the user's button click — not on page load, as required by the W3C Prompt API specification. Structured output uses responseConstraint inside onDeviceParams via Firebase Schema helpers. The extraction schema enforces: a typed claims array, an evidence summary string, deterministic hint counts, and an abstraction confidence score between 0 and 1.
Layer 3 uses InferenceMode.ONLY_IN_CLOUD. Structured output uses responseSchema via Firebase Schema helpers. The classification schema enforces exactly one of five verdict values and a reasoning string. All five claims classify in parallel via Promise.all().
Every model response is validated against a Zod schema before it touches application state. If the model returns malformed JSON, a verdict outside the enum, or an empty reasoning field, the error is caught at the boundary as a typed application error. The app never enters an inconsistent state from AI output.
Diff truncation: Gemini Nano's context window is approximately 9,000 characters shared between prompt, handoff text, diff, and test output. For diffs that exceed the available budget, we built deterministic TypeScript truncation logic that preserves the most informative diff hunks (preferring functional changes over whitespace and import-only changes) and appends [DIFF TRUNCATED]. When fewer than 500 characters remain available for the diff after handoff text and test output are budgeted, the extraction escalates to cloud with user notification. The escalation threshold is tunable via Remote Config key cloud_escalation_min_confidence without redeployment.
Firestore schema: Three collections. handoffs/{handoffId} stores the raw inputs and handoff status (draft → extracting → classifying → complete). handoffs/{handoffId}/claims/{claimId} stores the claim text, claim type, abstracted evidence, deterministic evidence, verdict, verdict source, and human correction state. handoffs/{handoffId}/exports/{exportId} stores the generated markdown. Security rules restrict all reads and writes to the authenticated owner's UID, with human override updates restricted to exactly four fields via affectedKeys().hasOnly().
Cloud Functions v2 (Node.js 22): Three functions. onHandoffCreated triggers on new handoff documents and initialises the processing pipeline. onAllClaimsClassified triggers when all claims reach a terminal verdict state and updates the parent handoff status. generateExport is an HTTPS callable that assembles the markdown report from all verified claims with their verdicts and reasoning.
Remote Config: Two keys. claim_extraction_prompt_version (string, default "v1.0") enables prompt fixes to roll out without redeployment. cloud_escalation_min_confidence (number, default 0.7) enables live tuning of the confidence-based escalation threshold based on observed override rates.
Testing: Vitest for TypeScript unit tests. cargo test + wasm-pack test for Rust parser correctness (each test output format has its own test suite with known-good input/output pairs). @firebase/rules-unit-testing for Firestore security rules. Playwright for five end-to-end tests covering the full verification pipeline. CI enforces all tests before merge.
Challenges We Ran Into
The 9,000-character problem. Gemini Nano's on-device context window is approximately 9,000 tokens — shared between the system prompt, the handoff text, the diff, and the test output. Real-world production diffs frequently exceed 10,000 characters on their own. Naively truncating at the character limit destroys the most important information — the last files touched are often the ones most relevant to the claims.
We solved this with a deterministic budget allocation algorithm. The handoff text and test output take priority (they're smaller and essential). The remaining budget is allocated to the diff. Within the diff, hunks are scored by relevance — changes to production code score higher than whitespace, import additions, or generated files. The highest-scoring hunks fill the budget first. The truncated diff gets a [DIFF TRUNCATED] marker so the model knows it's working with partial information. When the budget is so constrained that meaningful diff context is impossible (less than 500 characters remaining), the entire extraction escalates to cloud. The user sees a notification. The inference badge reflects the actual path taken.
Making the Rust parser format-agnostic without false positives. Five test runners produce five meaningfully different output formats. Jest uses a Tests: X passed, Y failed summary line. Pytest uses X passed, Y failed in a different position with different context. Go test outputs --- PASS: and --- FAIL: per test with no summary line. Mocha uses passing and failing as standalone words. Vitest has its own structured summary format.
The naive approach — scan for numbers near the words "passed" and "failed" — produces false positives constantly. A log line that says "3 requests failed" in the test setup output registers as 3 test failures. We built a format detection state machine that reads the first 500 characters of test output, identifies the runner from format-specific fingerprints, and then applies a runner-specific parser to the full output. The parser for each runner is independently tested against known-good outputs with edge cases: zero tests, all failing, test names containing numbers, nested describes. The counts the parser returns are reliable enough that we can safely use them to override AI self-reports.
Structural privacy in a two-stage AI pipeline. The privacy requirement is obvious in principle: don't send source code to the cloud. The engineering challenge is that the cloud model (Gemini Flash) needs to understand the code well enough to evaluate claims about it — without seeing the code.
The solution was to make abstraction the explicit output of Layer 1, not a side effect. The Stage 1 prompt instructs Gemini Nano to produce an evidence summary that contains only structural facts: file counts, module names by directory path, test counts, and binary yes/no on whether named capabilities are present. No variable names. No function bodies. No literal constants. The summary describes the architecture of what changed without transmitting the content of what changed. We validate the abstraction with a confidence score (0–1) that Gemini Nano self-reports alongside the claims. If confidence falls below the Remote Config threshold, the cloud model is flagged to treat the summary as potentially incomplete — which shifts the burden of doubt toward UNSUPPORTED rather than SUPPORTED.
Zod validation at AI boundaries. Language models return JSON that sometimes doesn't match the schema they were given. During development, Gemini Nano occasionally returned claims with claim types outside the allowed enum, reasoning fields that were empty strings, and abstraction confidence values above 1.0. Each of these would have caused silent failures in application state if we hadn't built Zod validation at every boundary. The validation layer converts every model response into either a typed, guaranteed-valid application object or a typed error — nothing else. This made the application dramatically more stable under edge cases and made the error handling code testable independently of the AI.
Accomplishments That We're Proud Of
The privacy guarantee is structural, not contractual.
Most "privacy-preserving AI" tools offer a policy: "We don't store your data." Proofline offers a constraint: raw source code cannot reach the cloud, because it is abstracted on-device before the cloud stage begins. This is the difference between trusting a vendor and trusting an architecture.
The three-layer design enforces this automatically. Layer 1 runs on-device and produces an abstraction. Layer 3 receives only that abstraction. There is no code path in the application where the raw diff or raw test output is transmitted to Firebase AI Logic cloud inference. The cloud model has never seen a line of source code in any user's codebase, by construction.
This matters not just for privacy advocates but for enterprise engineering teams whose diffs contain proprietary business logic, unreleased features, internal API contracts, and security-sensitive code. The handoff can be verified without the diff leaving the machine. That's not a feature — it's a category unlock for tools that otherwise couldn't be deployed in regulated or security-conscious environments.
The Rust WASM parser makes AI verdicts auditable.
Every CONTRADICTORY verdict on a test count claim is backed by a deterministic count from the Rust parser. The user can see: "The parser counted 3 of 4 tests passing. The handoff claimed 4 of 4. The verdict is CONTRADICTORY." That is not a language model's opinion. It is a measurement. The AI's job is classification, not evidence collection. Separating those two responsibilities — deterministic measurement and semantic judgment — is the architectural decision that makes Proofline's verdicts defensible rather than merely plausible.
The escalation is a design decision, not a fallback.
In most hybrid AI applications, on-device inference is the primary path and cloud is what you do when on-device fails. In Proofline, on-device is specifically chosen for the privacy-sensitive work (reading raw code) and cloud is specifically chosen for the reasoning-intensive work (semantic verdict classification). The escalation isn't "we ran out of options." It's "the privacy-sensitive work is already done, so the harder-reasoning stage can safely use the stronger model." Firebase AI Logic's hybrid inference makes this two-stage design possible within a single SDK.
What We Learned
Hybrid inference is an architectural tool, not a performance optimisation.
Before building Proofline, our mental model of hybrid AI was: run on-device when you want speed or offline support, run in the cloud when you need a bigger model. That framing is about capability and latency. Proofline forced us into a different framing: what is the minimum information the cloud needs to see to do its job?
That question changes the design completely. If you answer it honestly, you realise that for many AI tasks, the cloud doesn't need to see the sensitive input at all. It needs to see a structured summary, a set of counts, an abstracted description. The on-device model's job is to produce that minimum representation — to create a sanitised interface between the user's private data and the cloud's reasoning capability. On-device inference, in this framing, is a trust boundary enforcer. It is infrastructure for data contracts, not just an offline capability.
That insight generalises far beyond Proofline. Any AI application that processes data with privacy constraints — medical records, legal documents, financial statements, proprietary code — can use hybrid inference to enforce what the cloud is allowed to know. The on-device model abstracts. The cloud model reasons. The boundary between them is the product's privacy guarantee. Firebase AI Logic is the first SDK that makes this pattern ergonomic enough to build on in a production application.
What's Next for Proofline
GitHub App — zero-paste verification.
Today, users paste the diff and test output manually. The next version installs a GitHub App on a user's repositories. When a PR URL is pasted into Proofline, the diff and CI output are fetched automatically via the GitHub API using a short-lived installation token (never stored, never transmitted to the browser). The handoff text auto-populates from the PR description. One paste. Everything else is automatic. The three-layer architecture doesn't change. Only the input mechanism changes.
Android and iOS — same architecture, different on-device runtime.
The three-layer design is platform-agnostic by construction. On Android, Gemini Nano 4 is available via Firebase AI Logic's Android SDK with InferenceMode.PREFER_ON_DEVICE — identical to the web implementation. On iOS, Apple Foundation Models (available from iOS 26) provide the same on-device inference capability with structured output via @Generable. In both cases, the Rust evidence parser recompiles to a native target (aarch64-linux-android via JNI for Android, aarch64-apple-ios via C FFI for iOS) from the same source code. The Firestore schema, Cloud Functions, Remote Config, and Firebase Analytics events are shared identically across all three platforms. The on-device runtime changes. Everything else stays the same.
Accuracy improvement loop — overrides that teach.
Every time a user overrides a verdict, Proofline stores the original verdict, the corrected verdict, the claim text, the evidence summary, and the deterministic counts. Month over month, these overrides are classified into failure modes — false positive contradictions, missed contradictions, abstraction loss, wrong claim types — and the most frequent failure mode drives the next prompt revision. Revisions are evaluated against a golden set of human-verified claim/evidence pairs before shipping. The escalation threshold in Remote Config becomes a per-claim-type tuning knob: if test_result claims have a higher override rate than completion claims, the confidence threshold for escalating test result claims rises independently. The system gets more accurate from real usage, not from synthetic benchmarks.
How Proofline Meets the Firebase AI Logic Requirement
Proofline uses Firebase AI Logic as the foundational infrastructure of its core architecture. The hybrid inference capability — routing between on-device and cloud within a single unified SDK — is not an enhancement to the product. It is the reason the product's privacy guarantee exists and the reason the two-stage verification pipeline is possible.
On-device inference — Layer 1:
Proofline imports getAI, getGenerativeModel, GoogleAIBackend, and InferenceMode from firebase/ai. Layer 1 initialises a generative model with InferenceMode.PREFER_ON_DEVICE. initializeDeviceModel() is called on the user's button click interaction, not on page load, as required by the W3C Prompt API specification underlying Chrome's Gemini Nano integration.
The on-device model receives the full raw inputs: handoff text, git diff, and test output. It produces a structured claim list and an abstracted evidence summary. Structured output is enforced using responseConstraint inside onDeviceParams via Firebase Schema helpers, which maps directly to the W3C Prompt API's constraint mechanism for on-device structured generation.
After every generation call, result.response.inferenceSource is checked. If it returns "on_device", the 🟢 On-Device badge appears on every claim produced by this call. If it returns "in_cloud" (fallback triggered automatically by the SDK when Gemini Nano is unavailable or the context exceeds the window), the ☁️ Cloud badge appears and the user is informed. The badge reflects the actual inference path taken — it is never assumed.
Cloud inference — Layer 3:
Layer 3 initialises a separate generative model with InferenceMode.ONLY_IN_CLOUD. It receives the abstracted evidence summary from Layer 1 and the deterministic counts from Layer 2. It never receives the raw diff, raw test output, or raw source code. Structured output is enforced using responseSchema via Firebase Schema helpers. All claims are submitted in parallel via Promise.all() to minimise total classification latency.
Why this is genuinely hybrid:
The two stages are not interchangeable and are not redundant. Layer 1 must run on-device because it receives data that cannot cross trust boundaries. Layer 3 must run in cloud because semantic verdict classification — matching abstracted evidence against prose claims across five verdict categories with accurate reasoning — requires the reasoning capability of Gemini Flash, which exceeds what Gemini Nano can reliably deliver within a 9,000-token context. The routing is derived from the product's requirements, not from a performance preference or a cost calculation.
Firebase AI Logic is the only SDK that makes this two-stage hybrid inference pattern available within a single unified API, with a consistent structured output interface across both inference modes, and with automatic fallback handling when on-device capability is unavailable. This is why it is the foundation of Proofline's architecture rather than one component among several.
Additional Firebase products — each load-bearing:
| Product | Role |
|---|---|
| Firebase AI Logic | Core hybrid inference engine — both on-device (Gemini Nano) and cloud (Gemini Flash) stages |
| App Check | Debug provider for submission; ReCaptchaEnterpriseProvider in production. Enforced on all Firestore reads/writes and all Cloud Function calls |
| Firestore | Persistent storage for the full handoff/claim/verdict/evidence schema. Owner-scoped security rules. Human override restricted to four fields via affectedKeys().hasOnly() |
| Firebase Auth | Google Sign-In. All Firestore documents are owner-scoped to the authenticated UID. No anonymous data. |
| Cloud Functions v2 | Three functions: onHandoffCreated (pipeline initialisation), onAllClaimsClassified (status update), generateExport (HTTPS callable — markdown report assembly) |
| Remote Config | Two live-tunable keys: claim_extraction_prompt_version (prompt rollout without redeployment), cloud_escalation_min_confidence (escalation threshold tuning from override data) |
| Firebase Hosting | Production deployment |
All seven products are imported and called at runtime. Each one has a specific architectural role that cannot be trivially removed or substituted. The product does not function without Firebase AI Logic. It does not persist state without Firestore. It does not gate abuse without App Check. It does not update prompts in production without Remote Config. All seven are load-bearing.
Built With
- cloud-functions
- firebase-app-check
- firebase-auth
- firestore
- gemini-flash
- gemini-nano
- irebase-ai-logic
- react
- remote-config
- rust
- tailwindcss
- typescript
- vite
- webassembly
- zod