Offline Twinning & Evals for Finance AI: Test Agents Without Touching Production Data
Written by Zac Ruiz.
How to evaluate finance AI agents, prompts, and model swaps locally against protocol-faithful Postgres, Snowflake HTTP (Arrow IPC), REST, and MCP twins plus deterministic Rust scoring and sealed evidence packs.Every team building AI agents for credit, commercial real estate, underwriting, or financial reporting hits the same wall right after the first promising demo: how do you test changes before shipping them?
A frontier model drops a new version. Someone edits a system prompt. A dbt migration renames two columns in Snowflake. Or you want to benchmark a smaller post-trained model against a flagship model on your firm's actual workflows.
Most teams reach for one of two options, and both break quickly in finance:
- Point the eval suite at live production (or a shared staging warehouse). Yesterday's eval breaks tomorrow because new SEC filings landed overnight. Warehouse compute bills climb during eval loops. Worse, running experimental agent code with live warehouse credentials or client documents creates immediate compliance and data-leak risk.
- Stub out tool calls with hand-rolled Python or TypeScript mocks. The tests run fast, stay green in CI, and then fail on day one in production because the mock bypassed real Postgres pgwire typing, Snowflake HTTP Arrow IPC frames, OpenAPI
requestBodyschema enforcement, or MCP JSON-RPC error codes.
The fix is a two-part engineering pattern: protocol-faithful local twins for the interfaces your agent calls, paired with deterministic Rust scoring and sealed receipts instead of vague LLM-as-a-judge grades.
The offline eval loop: real wire protocols, zero production data
Synthetic / anonymized fixtures (DDL + OpenAPI + MCP manifest + gold CSVs)|v[ Layer 1: Local Wire Twins (cmdrvl/twinning v0.9.1) ]- twinning postgres -> local pgwire + snapshots + twin-pair proofs- twinning snowflake -> local Snowflake HTTP + Arrow IPC rowsetBase64- twinning rest -> local OpenAPI 3.x HTTP + stubs + 401/422/404 refusals- twinning mcp -> local MCP JSON-RPC 2.0 (HTTP or stdio + stubs/DuckDB)|v (Agent under test: Claude, Codex, ChatGPT, or custom/fine-tuned model)[ Agent executes real drivers, SQL, HTTP calls, and MCP tool calls offline ]|v[ Layer 2: Deterministic Scoring & Boundary Proof (Rust Spine CLIs) ]- benchmark -> exact (entity, field, value) accuracy vs. coverage- coverage -> denominator & missing-entity audit (ADEQUATE / PARTIAL / INADEQUATE)- verify -> declarative balance, DSCR, LTV, and schema invariants- assess -> policy gate (PROCEED / PROCEED_WITH_RISK / ESCALATE / BLOCK)- veil/airlock -> prove confidential local files stayed outside model prompts|v[ Layer 3: Immutable Receipt (cmdrvl/pack) ]- pack seal + pack verify -> content-addressed pack.v0 bundle for CI & review
Nothing touches production credentials. Every run uses real wire clients (snowflake-connector-python, psql, curl, real MCP SDKs). And every verdict is a repeatable exit code (0 / 1 / 2) with an inspectable artifact trail.
Layer 1: Four local wire twins with twinning (v0.9.1)
CMD+RVL maintains Twinning (github.com/cmdrvl/twinning, MIT open source) so agents and integration harnesses can talk to local loopback servers speaking real wire protocols.
In twinning v0.9.1, four protocol twins are available directly from the CLI (brew install cmdrvl/tap/twinning):
1. Snowflake HTTP + Arrow IPC (twinning snowflake)
Financial data stacks live heavily on Snowflake, yet testing Snowflake-backed agents locally usually meant either paying for a sandbox warehouse or faking cursor.fetchall() in Python.
twinning snowflake starts a local Snowflake HTTP wire protocol twin seeded from your SQL DDL, encoding query results in Arrow IPC (rowsetBase64) and answering SHOW/DESCRIBE meta-queries and session lifecycle calls so snowflake-connector-python, JDBC, dbt, and SnowSQL talk to 127.0.0.1:9876 with zero cloud credentials:
# Validate DDL and emit twinning.snowflake-report.v0# Add --serve or --run "<test command>" to serve live HTTP on 127.0.0.1:9876twinning snowflake --schema warehouse_ddl.sql --json
When you need bounded test data from a real schema, --materialize-source-url captures declared source rows (capped by --max-rows-per-table) into a reproducible local report so subsequent eval runs stay completely offline.
2. MCP JSON-RPC 2.0 (twinning mcp)
When evaluating an agent that relies on MCP servers (such as EDGAR, Receipts, Reveal, or an internal firm MCP), network flakiness and shifting live data ruin benchmark repeatability.
twinning mcp creates a deterministic local MCP JSON-RPC 2.0 wire twin over HTTP (--run) or line-delimited stdio (--stdio). You can bootstrap it either by introspecting a live server (--server) or loading a static manifest (--manifest), then bind exact responses via --stubs or local DuckDB tables via --duckdb and --data-handlers:
# Rehearse an agent eval harness against a static MCP manifest + deterministic stubstwinning mcp --manifest mcp-manifest.json --stubs stubs.json \--run "pytest tests/eval_credit_agent.py" --json
That lets you test exact tool-call sequences, malformed argument refusals, truncated-list handling, and auth-shape enforcement without hitting a single external API.
3. OpenAPI 3.x REST (twinning rest)
twinning rest compiles an OpenAPI 3.x YAML/JSON contract into a live loopback HTTP server with x-twinning response stubs, strict JSON requestBody schema checks, and auth-shape refusals. On a synthetic greeting fixture, valid requests return 200 while missing headers, wrong field types, and unknown paths deterministically return 401, 422, and 404 and log exact counts in twinning.rest-report.v0. See the full reproducible REST walkthrough on /tools/twinning/#worked-example.
4. Postgres pgwire & twin-pair equivalence proofs (twinning postgres and twinning proof twin-pair)
twinning postgres runs a local pgwire server from DDL with committed-state snapshots, optional embedded verify.constraint.v1 rule checks, and redacted query traces. Before shipping a schema refactor or migration, twinning proof twin-pair replays a query suite against two snapshots (--left and --right) and emits a twinning.twin-pair-proof.v0 receipt verifying result hashes and SQLSTATE parity.
(Scope note: the companion twinning-mcp stdio manager currently orchestrates Postgres and REST twins directly from MCP clients; Snowflake HTTP and MCP JSON-RPC twins run directly through the twinning v0.9.1 CLI.)
Layer 2: Replace LLM-as-a-judge with deterministic financial scoring
Running an agent against a local twin solves the environment problem. You still need to grade what the agent produced.
Using another LLM to judge financial answers ("rate this credit memo 1 to 5") hides the exact bugs that hurt real teams:
- A model extracts 14 loan balances accurately, skips 6 messy rows, and gets praised for "high precision."
- Two sources agree on a valuation, but both trace back to the same stale appraisal.
- A computed rollup is off by 0.4% due to float rounding or an uncounted amendment.
- During a local coding session, the agent quietly reads a confidential file it was never supposed to touch.
Pair your twin harness with open-source deterministic Rust scoring CLIs from the CMD+RVL tool suite:
| Failure mode to catch | Deterministic CLI | What it proves in CI |
|---|---|---|
| Silent extraction errors or cherry-picked rows | benchmark | Exact (entity, field, value) scoring against a gold dataset, strictly separating accuracy from coverage |
| Missing deals, partial universes, or double-counting | coverage | Roster and mass coverage (ADEQUATE, PARTIAL, INADEQUATE), Kish n_eff, independent origin count n_indep, and named missing keys |
| Broken financial math or schema drift | shape, rvl, verify | Schema comparability, Pareto numeric diffs with declared tolerances, and declarative rule checks with supporting rows |
| False corroboration across two sources | decoding | Multi-source convergence checks that flag shared upstream origins instead of double-counting one source |
| Policy routing and release gates | assess | Deterministic policy bands (PROCEED, PROCEED_WITH_RISK, ESCALATE, BLOCK) with explicit triggered rules |
| Raw confidential file leaks during agent runs | veil, airlock | PreToolUse / Seatbelt read blocks plus outbound payload attestation (not_crossed.json) |
Every one of these binaries runs offline in milliseconds, consumes zero LLM tokens, and emits structured JSON with deterministic exit codes (0 pass, 1 domain fail/change, 2 refusal).
Layer 3: Seal every eval run into a verifiable pack.v0 receipt
When an eval run finishes, seal the twin session report (twinning.snowflake-report.v0, twinning.mcp-report.v0, twinning.rest-report.v0), the benchmark and coverage reports, the assess policy verdict, and input lockfiles into one immutable bundle using pack:
pack seal inputs.lock.json twin.report.json benchmark.report.json \coverage.report.json assess.report.json \--note "Model eval: candidate-v2 vs baseline on CMBS Q4 fixture" \--out eval-runs/2026-12-04/pack verify eval-runs/2026-12-04/ --json
Now your model-risk team, IC reviewer, or CI pipeline can diff two eval runs (pack diff) or verify any historical run offline (pack verify) months later without re-running the model. To see what a live verified spine pack looks like in practice (with Ed25519 signatures, Rust WASM hash verification, and browser-replayable compute.js), inspect our November 2026 SEC Form ABS-15G Issuance Filings pack.
Honest boundaries: what offline twinning proves (and what it does not)
Keep expectations sharp so offline evals build real confidence rather than false assurance:
- What it proves: Your agent respects declared DDL, OpenAPI, and MCP contracts; handles
401/422/404, truncation, and refusals gracefully; hits deterministic accuracy and coverage thresholds on frozen fixtures; keeps confidential local files behindveil/airlockboundaries; and survives model or prompt swaps without silent regressions. - What it does not prove: That a live production Snowflake cluster, external REST vendor, or SEC feed behaves identically outside the declared contract, or that your synthetic fixtures cover every unseen anomaly in live filings. Keep lightweight staged verification and production receipts (Evidence MCP and Receipts MCP) in place once an agent ships.
Put your first agent eval offline this week
- Run open-source today: Install
twinning(v0.9.1) and the Rust verification spine via Homebrew (brew install cmdrvl/tap/twinningandbrew install cmdrvl/tap/cmdrvl), or test interactive demos ofbenchmark,coverage,verify,assess, andpackdirectly in your browser. - Wire your first offline twin + eval suite in half a day: Book a $500 half-day founder workshop online or in person across Philadelphia, the Main Line, and King of Prussia. Bring one real database schema, API spec, or agent workflow and leave with a working offline twin and deterministic eval gate your team owns.
- Scale across teams and warehouses: For production Snowflake twinning, continuous CI eval suites, model/post-training evaluation, and full paid lineage stack licensing (Reveal, Data, Evidence MCP, and x402 APIs in our cloud or yours), founder-led retainers start from $5,000/month per team.
Common questions
Why do standard unit-test mocks and LLM-as-a-judge evals fail for finance AI agents?
Hand-rolled unit mocks bypass real database, HTTP, and MCP wire protocols, so an agent passes mocked tests and breaks on the first real SQL driver, Arrow IPC payload, auth header, or OpenAPI schema check. Meanwhile, LLM-as-a-judge grading is noisy on exact financial figures and frequently misses partial coverage (such as answering 16 of 20 loans accurately while silently omitting 4).
Which wire protocols does open-source Twinning support today?
The open-source twinning CLI (v0.9.1) runs four local interface twins: Postgres (pgwire plus twin-pair snapshot equivalence proofs), REST (OpenAPI 3.x with response stubs and requestBody validation), Snowflake HTTP with Arrow IPC rowsetBase64 encoding, and MCP JSON-RPC 2.0 over HTTP or stdio with stubs and optional DuckDB handlers. Its companion twinning-mcp stdio manager orchestrates Postgres and REST twins directly from MCP clients.
Does a passing local twin run prove that production Snowflake or an external API behaves identically?
No. A local twin models only the declared DDL schema, OpenAPI spec, or MCP manifest you give it. A PASS proves your agent and client stay within that declared contract, handle refusals cleanly, and pass deterministic checks without touching production. Live infrastructure quirks, permissions, and upstream data changes still require staged integration checks.
How do teams separate accuracy from coverage in financial AI evals?
Run deterministic scoring with cmdrvl/benchmark (exact entity, field, and value checks against a gold table separating accuracy from coverage) alongside cmdrvl/coverage (checking matched vs. missing universe entities and mass coverage) and seal all reports into a content-addressed pack.v0 bundle via cmdrvl/pack.
Read next:
- Twinning: Local Postgres, Snowflake, REST & MCP Twins - Verified setup,
v0.9.1Snowflake/MCP CLI commands, and REST walkthrough - Connect Claude, ChatGPT, and Codex to SEC EDGAR & Snowflake via MCP - Complete 2026 MCP wiring guide from keyless Receipts to governed Snowflake tables
- Every API Has Two Contracts - Why protocol specs and runtime behavior diverge
- AI Audit Trail: Evidence Packs - How sealed
pack.v0bundles hold up under compliance review - Coverage CLI Interactive Demo - Test entity coverage, Kish
n_eff, andOVER_COVERAGEoffline in your browser
Zac Ruiz
Co-Founder
Technology leader with 25+ years' experience, including a decade in securitization and capital markets.
LinkedIn