Back to CausalFoundry

Frequently Asked
Technical Questions

Unpacking the architecture, the logic, and the "why" behind the Factory for Verifiable Data.

01 Can CausalFoundry preserve production distributions while enforcing ledger and application invariants?

Yes—CausalFoundry combines statistical distribution fitting with deterministic enforcement of your approved invariants.

Pure tabular ML generators match average shapes but break accounting sums and state machines; pure mock tools obey foreign keys but flatten production skews. CausalFoundry handles both layers together:

Pure Tabular ML (Gretel, SDV, MOSTLY AI) Approximates joint curves softly. Even if single columns look right, ledger balances drift by cents or claims skip required approval states.
Distributions + Invariants (CausalFoundry) Profiles 21-point empirical quantiles, null rates, Gaussian copula correlations, and conditional buckets, while StateMap and DuckDB SQL enforce exact balances and timelines.

With fuzz_factor: 0.0, CausalFoundry tracks your profiled empirical quantiles and pairwise correlations closely (scored via KS distance and correlation parity) for representative staging and analytics pipeline testing. When you raise fuzz_factor or enable chaos scenarios, it intentionally exercises edge cases and failure paths.

02 How does CausalFoundry prevent test suite decay and fixture stagnation?

Static mock fixtures and masked production snapshots suffer from rapid decay: they test narrow happy paths and fail to exercise edge cases. CausalFoundry supports a configurable 80/15/5 Operational Coverage Preset (controlled via fuzz_factor and scenarios):

  • 80% Baseline Operations: Standard happy-path transactions anchored to valid entity lifecycles.
  • 15% Boundary Conditions: High-variance values, edge-of-limit balances, and multi-step state progressions.
  • 5% Injected Stress Scenarios: Declarative chaos injection (fraud surges, dispute cascades, NSF reversals) that test error-handling paths.

03 How exactly are business rules enforced?

We use a three-layer enforcement system:

Deterministic StateMap

A high-performance Rust memory map that tracks every entity's balance and state in real-time.

Reactive Throttling

If a random generator picks an "illegal" value, the engine dynamically constrains it to the legal range.

Logic Guardians

Custom SQL invariants defined in YAML that act as the laws of physics for the generator.

# Example Invariant invariants: - name: positive_balance target: accounts logic: "SELECT * FROM accounts WHERE balance < 0" action: REPAIR_OR_THROTTLE

04 Does CausalFoundry use Machine Learning?

All numeric, temporal, and relational generation uses a deterministic, non-neural "Glass Box" pipeline—not opaque neural generators:

During profiling, it extracts empirical quantile curves, null rates, Gaussian copula correlations, and parent-conditioned distributions (while skipping primary keys, foreign keys, and PII columns). During generation, symbolic invariants and StateMap check every emitted batch against your configured accounting, temporal, and lifecycle rules. Optional local LLMs (Question 10) run only when enabled for unstructured free-text columns such as support notes—they never control balances, keys, or relational invariants.

05 How does "Rare Event Injection" work?

This is the process of forcing the engine into the "Long Tail" of distribution. In your configuration, you set a rate for specific scenarios.

When the engine "hits" that rate, it overrides its normal shadowed distribution to generate a rare event (like a $1,000,000 withdrawal). Crucially, the engine then Drills Down through the causal graph to ensure the rest of the database makes sense (e.g., creating a High Net Worth account for that transaction) so that the event isn't just a "floating" outlier, but a logically consistent part of the stream.

06 What is CausalFoundry's benchmarked performance?

In release-profile benchmarks on multi-table schemas with active parent-child balance rollups and cross-table state constraints (such as the fintech ledger pack), CausalFoundry generates and validates ~980 to 1,000 rows per second per CPU core, while scaling linearly across cores and table partitions.

"Full in-memory Decimal balance tracking, dynamic overdraft clamping, and independent DuckDB analytical verification at enterprise scale."

07 Why is rare event injection considered "dangerous"?

Blindly forcing random outliers without preserving surrounding prerequisites breaks your test environment instead of finding real application bugs. If you inject a $1,000,000 withdrawal onto a randomly selected $50 balance, integration suites fail on impossible fixture data rather than genuine logic errors.

CausalFoundry checks your configured invariants when scenarios trigger and propagates upstream/downstream state (such as matching account funding or entity history) so injected edge cases stay coherent test scenarios.

08 How does Shadow Mode and "Evolution" work?

In Shadow Mode, CausalFoundry constantly watches the frequency of events in your production database. As your schema evolves—new columns, changed table structures—the engine auto-introspects these changes, ensuring your seed data never "rots." It learns the distribution of real data and shadow-calibrates itself to keep the synthetic stream in sync with reality.

09 The "Spectrometer": Real-time Verification

CausalFoundry includes cf_verify, which audits generated datasets and streams inside DuckDB. For every batch or stream window, it reports invariant pass rates alongside Entropy, Leakage, Kolmogorov-Smirnov Drift Score, and Correlation Score. Passing --schema schema.json to verify scores synthetic columns directly against your profiled production quantiles and correlation matrices.

10 How do the AI Tiers (Standard, Professional, Sovereign) work?

Standard (Deterministic Rust) is the core engine used for all numeric, relational, and ledger workloads. Professional and Sovereign are optional add-ons used only when unstructured free-text columns require local language generation:

  • Standard (Core Engine): Purely deterministic Rust. Handles distributions, balances, keys, and invariant checking with zero inference latency.
  • Professional (Optional Unstructured-Text Add-On): Integrates a local Llama-3 model to populate unstructured free-text fields (support tickets, bios, and notes) while leaving all structured math under deterministic Rust control.
  • Sovereign (Optional Text-Screening Add-On): Adds a second local model (Phi-3.5) to provide heuristic content screening on generated free-text fields alongside deterministic regex and SQL policy checks.

11 Why not just use an LLM or unconstrained generator to mimic production?

"Unconstrained statistical smoothness breaks ledger math, and happy-path cloning misses edge-case failures."

Pure statistical synthesizers (like CTGAN or diffusion models) smooth out data distributions, which means an account balance might miss by $0.01 or a refund might appear before an invoice exists. For ledger systems, that $0.01 breaks CI test suites immediately. When you want stress coverage beyond your baseline distribution, CausalFoundry provides a configurable 80/15/5 Operational Coverage Preset alongside deterministic business-rule checks:

  • 80% Baseline Operations: Representative happy-path operational volume anchored to valid lifecycles.
  • 15% Boundary Conditions: Intentionally jittered distributions and edge-of-limit boundary cases.
  • 5% Injected Stress Scenarios: Deterministic failure scenarios (chargebacks, refunds, insolvency).

Every emitted batch is checked against your approved symbolic invariants before hitting staging or CI.

12 How does the Stateful AI-Agent Evaluation Sandbox work?

Most AI-agent evaluation benchmarks only grade text outputs or code strings. But autonomous financial agents execute tool calls—running SQL queries, updating balances, transferring funds, or applying discounts directly against databases.

The causalfoundry sandbox commands (init, step, reset, eval) provide a stateful evaluation environment for AI agents:

  • Consequence-Based Scoring: When an agent tool issues a mutation (e.g. UPDATE accounts SET balance = balance - 500), CausalFoundry executes the mutation and immediately runs your domain invariants. If the agent causes an overdraft or illegal state transition, the step is rejected with exact counterexamples, and state is rolled back.
  • Sub-50ms Isolated Resets: Sandboxes leverage lightweight disk snapshots and DuckDB memory layers to reset state in under 50 milliseconds between agent test trials, enabling high-throughput test suites.

13 How does Dual-Run Migration Reconciliation work?

When migrating core banking systems, ledger architectures, or billing engines from a legacy database to a new microservice, engineering teams need to verify that both systems compute identical balances and state transitions under identical transaction workloads.

causalfoundry reconcile executes high-speed DuckDB outer joins across the legacy baseline dataset and target migration output to detect:

  • Missing Entity Keys: Identifies accounts or transactions present in the baseline but dropped by the new service.
  • Numeric Value Drift: Calculates absolute balance divergence (e.g. ABS(legacy.balance - target.balance)) against a user-specified tolerance threshold.
  • State Transition Inconsistencies: Catches status discrepancies (such as legacy marking an order SETTLED while target left it PENDING).

14 How do Candidate Invariants transition from profile to approve?

Manually hand-crafting dozens of SQL invariant rules is tedious. CausalFoundry provides a progressive discovery and approval pipeline:

  1. Automated Discovery (profile): Run against a live database (--url) or offline Parquet/CSV/JSONL exports via bundled DuckDB (--data). The profiler extracts empirical quantiles, null rates, copula correlations, and conditional buckets into schema.json (filtering out PK/FK and PII columns), while emitting candidate invariants with confidence scores and counterexample counts.
  2. Human-in-the-Loop Promotion (approve): Engineers can interactively review each candidate rule with live counterexamples in their terminal, or use --counterexample-threshold 0 in automated CI scripts to promote pristine rules directly into manifest.yaml.

15 How do Generation Mode and CDC Shadow Mode differ on privacy and timing side channels?

Generation Mode synthesizes test rows directly from aggregate empirical quantiles and Gaussian copulas without copying raw source rows. CDC Shadow Mode, by contrast, streams and transforms a live production WAL feed via TokenVault HMAC-SHA256 pseudonymization—meaning pseudonymized CDC shadow streams remain subject to GDPR/DORA governance.

To reduce timing and volume correlation when streaming CDC events (for example, matching a \$50,000 transaction at an identical millisecond timestamp), CausalFoundry's CDC privacy window (apply_cdc_privacy_window) applies two heuristic mitigations within the configured micro-batch window (note that these are practical heuristics rather than a formal mathematical anonymity guarantee):

  • Key-Preserving Shuffling: Incoming transactions are grouped into micro-batch windows (e.g. 5,000ms). Transactions operating on independent entity keys are randomly shuffled, while causal ordering for dependent records (e.g. Deposit before Withdrawal on Account A) is strictly preserved.
  • Bounded Monotonic Timestamp Jitter: Timestamps are perturbed by bounded random offsets while ensuring timestamps remain strictly non-decreasing per entity.

16 Can we use CausalFoundry with Snowflake, BigQuery, Databricks, or Parquet exports?

Yes. You do not need direct JDBC/SQL wire connectors to Snowflake or BigQuery to profile warehouse data.

Export your warehouse sample to Parquet, CSV, or JSONL and point the CLI at the file or directory: cf profile --data ./warehouse_export --output-schema schema.json --output-manifest manifest.yaml. Bundled DuckDB reads those files locally, fits empirical quantiles, null rates, copula correlations, and conditional buckets without storing raw PII strings, and lets you verify generated parity afterwards with cf verify --schema schema.json.

Manual Data vs. Invariant-Preserving CausalFoundry

Feature Masked Prod Copies / Manual Mocks CausalFoundry
Invariant Preservation Rollups drift, balance totals desync Strict algebraic rollups & state machines
Privacy & Compliance Pseudonymized copies still personal data under GDPR/DORA Generation Mode synthesizes from quantiles without source rows; CDC Shadow Mode applies HMAC pseudonymization + timing-jitter mitigation
AI-Agent Evaluation Unsafe; mutations corrupt shared staging Sub-50ms isolated sandboxes with strict rollback
Audit & Evidence Manual review or untested assumptions DuckDB verification reports with counterexample extraction

Ready to build a Verifiable Staging Environment?

Test ledgers, complex applications, and autonomous AI agents with explicit business invariants and documented privacy controls.