Skip to content

Repository files navigation

AutoFlow Verification Engine

CI

AutoFlow is a read-only verification layer for AI-generated financial claims. It keeps the model answer unchanged, then independently checks eligible claims against source-anchored evidence, deterministic decimal calculations, and versioned covenant rules.

The first vertical is private credit and commercial lending. AutoFlow does not approve, decline, price, or recommend loans. Human analysts retain final judgment.

What Is Implemented

  • Contract-validated evidence graphs with document, page, locator, period, currency, scale, and source-anchor provenance
  • Deterministic C++20 normalization, reconciliation, contradiction detection, and declarative financial-rule execution
  • Twelve versioned credit, liquidity, accounting, margin, growth, and reconciliation rules, including Net Leverage V1
  • Explicit handling for conflicting facts, missing evidence, incompatible periods/currencies, ambiguous definitions, and zero denominators
  • JSONL verification findings, evidence conflicts, and exception cases validated against Draft 2020-12 schemas
  • Shared OpenRouter/OpenAI/Gemini provider gateway with structured output, throttling, bounded retries, circuit breaking, and secret-safe metadata
  • FastAPI orchestration with durable job states, idempotency, atomic records, liveness/readiness checks, and metrics
  • Three-panel browser demo showing the unchanged AI answer beside independent verification artifacts
  • A 30-case synthetic financial verification benchmark harness with exact-decimal metrics, resumable storage, and release-policy evaluation

Trust Boundary

Synthetic credit package
  -> fixture-backed extraction adapter
  -> EvidenceGraph
  -> selected LLM answer + typed claim
  -> deterministic C++ verifier
  -> findings, conflicts, exceptions
  -> analyst-facing UI

The LLM proposes an answer. It cannot mark a fact VERIFIED, resolve conflicting evidence, or replace Reported EBITDA with Covenant EBITDA. The C++ verifier never generates the model answer.

Quick Start

Prerequisites

  • CMake 3.20+
  • A C++20 compiler (MSVC is the tested Windows toolchain)
  • Python 3.12 and uv
  • Node.js 20+ for frontend checks

Build the verifier

cmake -S services/verifier_cpp -B services/verifier_cpp/build
cmake --build services/verifier_cpp/build --config Release

Run the static demo

Open web_demo/index.html. Static mode uses only synthetic, deterministic demo data and makes no provider calls.

Run the live local demo

Choose one provider. Credentials stay server-side and must never be committed.

$env:MODEL_PROVIDER = "gemini"
$env:GEMINI_API_KEY = "<local-key>"
$env:GEMINI_MODEL = "gemini-3.5-flash"

uv run --python 3.12 --with-requirements services/demo_api/requirements.txt `
  uvicorn services.demo_api.app:app --host 127.0.0.1 --port 8000

Open http://127.0.0.1:8000, upload the six supported synthetic package filenames listed in the demo API guide, and ask:

What is the borrower's Net Leverage?

The current locked fixture intentionally contains conflicting Total Debt evidence. A blocked calculation is therefore the honest expected result; the verifier must not fabricate 2.08x.

Tests

# C++ verifier
cmake --build services/verifier_cpp/build --config Debug
ctest --test-dir services/verifier_cpp/build -C Debug --output-on-failure

# Contracts and extraction
uv run --with pytest --with jsonschema --with referencing --with pyyaml `
  python -m pytest tests/contracts tests/extraction -q

# Demo API (provider calls are mocked by default)
uv run --python 3.12 --with-requirements services/demo_api/requirements-dev.txt `
  python -m pytest services/demo_api/tests -q

# Frontend
node --check web_demo/demo-state.js
node --check web_demo/live-api.js
node --check web_demo/app.js
node --test web_demo/test_demo.mjs

# Financial benchmark harness (mocked providers, real C++ verifier)
cd benchmarks/financial_v1
uv run --with-requirements requirements-dev.txt python -m pytest -q

# Local stress harness (real C++ rule runtime, mocked provider transport)
cd ../..
uv run --python 3.12 --with-requirements stress_tests/requirements-dev.txt `
  python -m pytest stress_tests/tests -q

Repository Map

Path Purpose
services/verifier_cpp/ Deterministic C++20 verification engine and CLI
services/extraction/ Deterministic synthetic evidence extraction and contract validation
services/demo_api/ Local FastAPI orchestration and model-provider adapters
web_demo/ Static and API-connected browser demo
contracts/ Versioned JSON Schema contracts
configs/ Metric catalog and Net Leverage rule configuration
services/provider_gateway/ Shared OpenRouter, OpenAI, and Gemini policy gateway
configs/financial_rules/ Twelve declarative V1 financial and reconciliation rules
fixtures/ Synthetic Acme Manufacturing credit package
benchmarks/financial_v1/ Financial verification benchmark harness and pilot dataset
tests/ Contract, extraction, verifier, CLI, and integration tests
stress_tests/ No-network real-C++ stress and resilience harness
docs/ Product boundaries, architecture, ADRs, and verifier audits

Safety and Scope

  • Synthetic data only. Do not upload private borrower information to this demo.
  • DEMO_FIXTURE_MODE does not parse arbitrary live documents; it maps the supported synthetic package to a locked EvidenceGraph.
  • No authentication, database, multi-user isolation, deployment hardening, or autonomous lending workflow is included.
  • A public repository is not a claim of regulatory compliance or production readiness.
  • Provider credentials are read from local environment variables and are never sent to the browser or written to run artifacts.

See product scope, architecture, ADRs, and security guidance.

About

Evidence-checked AI for deterministic private-credit verification.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages