Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
59b45da
chore(bench): baseline from bench run 45965246339
github-actions[bot] Nov 27, 2026
00f9758
feat(bench,engine): drafted bench specs rewritten from documentation;…
claude Nov 27, 2026
4b0f4da
feat(bench): log accepted drift with its reason (AdventureWorks DimPr…
claude Nov 27, 2026
ffec5fa
revert: chore(bench): baseline from bench run 45965246339
claude Nov 27, 2026
8e5f79e
fix(engine): SCD2 moved starts stay on the source's later-version starts
claude Nov 27, 2026
844f760
fix(bench): Berka spec from the PKDD'99 data description
claude Nov 27, 2026
ec92bd5
feat(bench): IBM AML (HI-Small) as a monthly benchmark dataset
claude Nov 27, 2026
9fb2cb1
fix(bench): AML builder writes through the DuckDB relation API
claude Nov 27, 2026
23fc8b4
feat(bench): IBM AML from the authors' Kaggle dataset; Bitcoin rule; …
claude Nov 27, 2026
bcd82a5
fix(bench): the Kaggle credential is the KAGGLE_API_TOKEN secret
claude Nov 27, 2026
03f441b
fix(engine): rule-linked categorical joints, unique keys over stratif…
claude Nov 27, 2026
22618b2
chore(bench): pin the SHA-256 of the Kaggle HI-Small_Trans.csv
claude Nov 27, 2026
8936a48
fix(evaluate): count categorical join columns once in join_metrics
claude Nov 27, 2026
9b9612a
fix(engine): test unique-key nulls with math.isnan (CodeQL comparison…
claude Nov 27, 2026
428191a
fix(marginals): continuous columns with point masses keep their tails
claude Nov 27, 2026
4256f8f
chore(bench): log the owner-accepted ACS privacy-distance and census …
claude Nov 27, 2026
97b6c40
feat(marginals): point-mass knots as the setting marginals.point_mass…
claude Nov 27, 2026
5a29399
fix(quality): fan-out checks of a sampled fact use its exact per-pare…
claude Nov 27, 2026
465e68a
fix(engine): exact derives and lookups that read a soft rule's column…
claude Nov 27, 2026
ab2b5db
fix(engine): review findings on SCD recent entities, affinity under u…
claude Nov 27, 2026
51f98e1
fix(evaluate): level shares of joined ancestor columns counted on the…
claude Nov 28, 2026
2c5eb81
fix(evaluate): support check of a fact's reference keys on integer codes
claude Nov 28, 2026
fb70089
fix(bench): run errors in logs show the exception line
claude Nov 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ jobs:
SEEDS: ${{ matrix.part.seeds }}
DATASETS: ${{ matrix.part.datasets }}
FAKE: ${{ matrix.part.fake }}
# the Kaggle credential reaches only the job of the dataset read from Kaggle (bench/datasets.py KAGGLE)
KAGGLE_API_TOKEN: ${{ contains(matrix.part.datasets, 'ibm_aml') && secrets.KAGGLE_API_TOKEN || '' }}
run: |
# shellcheck disable=SC2086
python -m bench run ${DATASETS:+--datasets $DATASETS} --seeds "$SEEDS" $FAKE --out-dir bench-out --label "$TIER"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable user-visible changes are recorded here, following [Keep a Changelog

### Added

- **IBM AML benchmark dataset** (`ibm_aml`, monthly tier): IBM Transactions for Anti-Money Laundering, variant HI-Small (5.08M transfers, 515k accounts, 30.5k banks), downloaded from the authors' Kaggle dataset with the `KAGGLE_API_TOKEN` secret (passed only to that job), as four Parquet tables (bank, account with a surrogate for the bank + account pair, currency with its US Dollar rate, transactions); spec from the dataset specification, checked on the data; domain checks M1-M12.
- **Family generator `ctvae`** (context transformer VAE; `relsynth[neural]`; docs/neural.md, design record docs/research/context-transformer-vae.md; Props. 1860-1863). The rows of a fact that share an anchor row (the lines of an invoice, the transactions of an account, in time order when the fact has a time column) are drawn jointly. A row VAE (column tokens, PreNorm transformer) is followed by a causal transformer prior over the row latents (GRU optional) and a residual categorical head; columns decode through the Bayesian marginals. An ablation on four datasets with three seeds, against an acceptance rule fixed in advance chose the design. With `transformer+res` under the corrected harness (run 5), within-family numeric errors fell by 8% to 55% across the four datasets and lag-1 errors on the ordered ones by 53% to 96%, categorical sharing was kept or improved on three of four (as in run 4), and every variant stayed within the family and row DCR limits of the rule on these runs (DCR is a fidelity-side check, not a privacy guarantee). Optional DP-SGD runs at entity level: one family is the protected unit; under `dp`, calibration is off unless the spec turns it on. A new `dp.population` option (also for `tvae` and `ddpm`) sets the public row or family count that DP-SGD's sampling rate, delta and gradient scale are computed from; without it the actual count is treated as public, as before. Opt-in per table; defaults unchanged.
- **Generator contract 1.1**: a generator can declare `family` conditioning and then receives each row's anchor row and order key (`FitContext.family`/`order`, `Conditioning.family`/`order`). For such a generator the engine draws a fact's dates before its attributes, which leaves the law of the dates unchanged. Contract 1.0 generators and model files keep working, and their output is unchanged.
- **Weekly security patching by Claude** (`security-patch.yml`, docs/development/security-patching.md). Every Tuesday the open Dependabot alerts (with an optional read-only token), code-scanning alerts above warning and a pip-audit of the lowest and newest versions the `pyproject.toml` ranges allow are collected; when there is something to fix, Claude opens one draft pull request with the smallest fixes and the checks it ran, for the usual review and audit. Dependabot version updates now wait seven days after a release (security updates do not), and Python security updates come grouped.
Expand All @@ -25,6 +26,11 @@ All notable user-visible changes are recorded here, following [Keep a Changelog

### Changed

- **`marginals.point_mass_knots`** (off by default; on in the census bench spec): continuous columns where a few values hold much of the mass (zero-inflated wages, amounts, capital gains, counts with a dominant 0). A value holding a share A of the rows takes A of the `copula.grid` quantile knots, so with 94% zeros the rest of the law has 4 knots and its upper tail is spread evenly up to the maximum (census wage per hour: mean 80 against 55, W1/sd 0.10). With the setting on, the continuous part gets about `copula.grid` knots, the resolution it would have as a column of its own (W1/sd 0.013; census capital gains 0.12 to 0.007, Adult capital gain 0.067 to 0.013). Off keeps the output byte for byte; on adds quantiles of the non-atom rows (each still a weighted quantile of at least n/grid of them), so it is a spec choice, like segment shrinkage.
- **Accepted bench drift** (`Dataset.accepted` in `bench/datasets.py`, docs/development/benchmarks.md): drift the owner accepted is logged with its reason during the run and reported as a note, not an R1/R4 regression, until a baseline holds it. AdventureWorks accepts the DimProduct drift its spec's segment shrinkage causes (privacy for fidelity).
- **Line keys offset from an order-header key** (`offset_from` on a relationship whose base key is a `fact.header` column): the class of header/line facts whose ship, due or paid date key follows the order's date key (retail order lines, claim lines). Before, the spec was refused because the base key moves to the internal header table; now the offset is applied after the header columns are read back, lookups through the offset key are read after it, and line rules that read a parent through a header key are rewritten through the header. Revealed by TPC-DS (catalog and web sales); tested on retail order lines and claim lines.
- **SCD2 version dates keep source lengths**: two versions of a key drawn on the same or nearby start dates were pushed one day apart, which left zero- and one-day versions and closed versions ending before they start (TPC-DS `item`: 362 rows). A start closer to the previous one than the source's shortest version now moves to the next later-version start of the source (51 quantiles; release-style dates stay on the source's dates, and a key that would run past the last of them takes the last ones), else past it by a source version length; a closed latest version ending on or before its start takes a closed (or version) length from the source. TPC-DS SF0.1 `item`: 0 violations, end-date KS 0.334 to 0.166. Tested on release-date and continuous version histories.
- **Bench specs written from documentation** for TPC-DS (all scales; TPC-DS v4.0.0 clause 2 schema, clause 5.3.11 view rules), Census-Income KDD (UCI 117), electricity (UCI 321), ACS (SDNist data dictionary), Contoso Parquet (the generator's DDL and docs.sqlbi.com), AdventureWorks checked against the publisher's DDL, and Berka from the PKDD'99 data description; every rule was checked on the source rows before it was written, and drafted checks the source breaks or that only hold by chance were removed.
- **TPC-H bench spec**: L_QUANTITY keeps 0 decimals (whole numbers, clause 4.2.3), so the price derive holds; the line dates are offsets from the order's date as clause 4.2.3 generates them; L_LINESTATUS is the clause's derive from the ship date; `max_rejection_rounds: 100` for the return flag. On SF0.05 every declared rule now holds and no line is removed (before: 22% of lines removed, price derive broken on 59% of rows).
- **A fact needs an anchor that is set** (Prop. 1844, check C1844): introspect drafts a keyed table as a fact only if one of its links is set on at least 95% of its rows, and anchors a fact on such a link first. A table whose links are all mostly NULL (a tag list with an optional excerpt post) was drafted as a fact and lost every row without an anchor; it is now an entity that keeps every row and each link's NULL rate. Revealed by Stack Exchange once its false link was removed.
- **An offset date falls back to the next base**: offsets do not chain, so when a date's closest earlier date is itself an offset (a store date drafted from the chart date), introspect now drafts it from the next significant base (store time from the chart date) instead of leaving it a free date. A free date could land years from the row's other dates and break the drafted order rules (MIMIC-IV demo `microbiologyevents`: 0.2-0.5% of rows broke `days(chartdate) < days(storetime)` once the rows without an admission were kept; now none). No other bench draft changes.
Expand Down
9 changes: 5 additions & 4 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ stress schema by `builders/stress_schema.py` from a seed).
| `synthea_100k` | Synthea 3.4.0, 100,000 generated patients (Massachusetts, seed 7) | 1 | bigger runner or maintainer machine |
| `synthea_1m` | Synthea 3.4.0, 1,000,000 generated patients (Massachusetts, seed 7) | 1 | bigger runner or maintainer machine |
| `nyc_tlc_12m` | NYC TLC yellow taxi trips 2024 (12 months, about 41M trips) | 1 | bigger runner or maintainer machine |
| `ibm_aml` | IBM Transactions for Anti-Money Laundering, HI-Small (5.08M transfers, 515k accounts, 30.5k banks; Kaggle, KAGGLE_API_TOKEN); checks M1-M12 | 1 | GitHub-hosted |
| `open_food_facts` | Open Food Facts, 200,000-product extract of the 8 GB export (ODbL) | 1 | GitHub-hosted |
| `tpch_sf10` | TPC-H data generator at SF10 (87M rows; not TPC-H results) | 1 | bigger runner or maintainer machine |
| `tpch_sf100` | TPC-H data generator at SF100 (870M rows; not TPC-H results) | 1 | bigger runner or maintainer machine |
Expand All @@ -103,7 +104,7 @@ two-set requirement are marked extra in `bench/datasets.py` (`REQUIRED_FEATURES`
| 10 or more tables (`tables_10_plus`) | adventureworks (weekly), synthea_1k (weekly), synthea_100k (monthly), synthea_1m (monthly), mimic_demo (weekly), rel_trial (monthly), tpcds_sf1 (weekly), tpcds_sf10 (monthly), stress_s (pr) | 9 |
| 100 or more tables (`tables_100_plus`) | stress_m (weekly), stress_l (monthly) | 2 |
| KB to tens of MB (`size_mb`) | chinook (pr), adult (pr), stress_s (pr), mongodb_samples (pr) | 4 |
| about 100 MB to 1 GB (`size_100mb`) | contoso_parquet (weekly), berka (weekly), covtype (weekly), census_kdd (weekly), electricity (weekly), nyc_tlc_1m (weekly) | 6 |
| about 100 MB to 1 GB (`size_100mb`) | contoso_parquet (weekly), berka (weekly), covtype (weekly), census_kdd (weekly), electricity (weekly), nyc_tlc_1m (weekly), ibm_aml (monthly) | 7 |
| 1 GB to 10 GB (`size_gb`) | synthea_1k (weekly), rel_trial (monthly), nyc_tlc_12m (monthly), tpch_sf1 (weekly), tpcds_sf1 (weekly), stress_l (monthly) | 6 |
| 10 GB to 100 GB (`size_10gb`) | synthea_100k (monthly), tpch_sf10 (monthly), tpcds_sf10 (monthly) | 3 |
| 100 GB and more (`size_100gb`) | synthea_1m (monthly), tpch_sf100 (monthly) | 2 |
Expand All @@ -114,14 +115,14 @@ two-set requirement are marked extra in `bench/datasets.py` (`REQUIRED_FEATURES`
| many-to-many bridges (`many_to_many`) | chinook (pr), berka (weekly), rel_trial (monthly), stress_s (pr), stress_m (weekly), imdb_movielens (local) | 6 |
| composite primary and foreign keys (`composite_keys`) | mimic_demo (weekly), tpch_sf1 (weekly), tpch_sf10 (monthly), tpch_sf100 (monthly), tpcds_sf1 (weekly), tpcds_sf10 (monthly), stress_s (pr), stress_m (weekly) | 8 |
| slowly changing dimensions (type 2) (`scd`) | adventureworks (weekly), tpcds_sf1 (weekly), tpcds_sf10 (monthly) | 3 |
| dated events (facts with a time column) (`events`) | chinook (pr), adventureworks (weekly), contoso_sqlite (monthly), contoso_parquet (weekly), berka (weekly), synthea_1k (weekly), synthea_100k (monthly), synthea_1m (monthly), mimic_demo (weekly), online_retail_ii (weekly), rel_trial (monthly), nyc_tlc_1m (weekly), nyc_tlc_12m (monthly) | 13 |
| dated events (facts with a time column) (`events`) | chinook (pr), adventureworks (weekly), contoso_sqlite (monthly), contoso_parquet (weekly), berka (weekly), synthea_1k (weekly), synthea_100k (monthly), synthea_1m (monthly), mimic_demo (weekly), online_retail_ii (weekly), rel_trial (monthly), nyc_tlc_1m (weekly), nyc_tlc_12m (monthly), ibm_aml (monthly) | 14 |
| regular time series (one value per entity and step) (`regular_series`) | electricity (weekly), stress_s (pr), stress_m (weekly) | 3 |
| long free text (`long_text`) | stackexchange (weekly), rel_trial (monthly), open_food_facts (monthly) | 3 |
| nested documents and lists (`nested_documents`) | open_food_facts (monthly), mongodb_samples (pr) | 2 |
| wide tables (50 or more columns) (`wide_tables`) | covtype (weekly), open_food_facts (monthly), stress_m (weekly), stress_l (monthly) | 4 |
| binary columns (BLOB) (`binary_columns`) | stress_s (pr), stress_m (weekly), stress_l (monthly) | 3 |
| high-cardinality categoricals (`high_cardinality`) | contoso_sqlite (monthly), contoso_parquet (weekly), acs (weekly), bi_corep_lr (local), census_kdd (weekly), synthea_1k (weekly), online_retail_ii (weekly), open_food_facts (monthly), mongodb_samples (pr) | 9 |
| skew and imbalance (fan-out, classes) (`skew`) | berka (weekly), bi_corep_lr (local), adult (pr), covtype (weekly), census_kdd (weekly), online_retail_ii (weekly), stackexchange (weekly), nyc_tlc_1m (weekly), nyc_tlc_12m (monthly), stress_s (pr), stress_m (weekly), stress_l (monthly), imdb_movielens (local) | 13 |
| high-cardinality categoricals (`high_cardinality`) | contoso_sqlite (monthly), contoso_parquet (weekly), acs (weekly), bi_corep_lr (local), census_kdd (weekly), synthea_1k (weekly), online_retail_ii (weekly), ibm_aml (monthly), open_food_facts (monthly), mongodb_samples (pr) | 10 |
| skew and imbalance (fan-out, classes) (`skew`) | berka (weekly), bi_corep_lr (local), adult (pr), covtype (weekly), census_kdd (weekly), online_retail_ii (weekly), stackexchange (weekly), nyc_tlc_1m (weekly), nyc_tlc_12m (monthly), ibm_aml (monthly), stress_s (pr), stress_m (weekly), stress_l (monthly), imdb_movielens (local) | 14 |
| messy values (codes for missing, negatives, outliers, stray text) (`messy_values`) | acs (weekly), adult (pr), census_kdd (weekly), online_retail_ii (weekly), stackexchange (weekly), nyc_tlc_1m (weekly), nyc_tlc_12m (monthly), open_food_facts (monthly), stress_s (pr), stress_m (weekly) | 10 |
| small privacy units (under 200 people) (`small_privacy_units`) | chinook (pr), mimic_demo (weekly) | 2 |

Expand Down
4 changes: 3 additions & 1 deletion bench/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def cmd_compare(records: list[Path], baseline: Path, full: bool, summary_to: str
base = _load_baseline(baseline)
recs = [load_record(r) for r in records]
rec = {**recs[0], "runs": [r for x in recs for r in x["runs"]]}
reg, notes, summ = regress.compare(base, rec, full=full, expected=expected)
from .datasets import DATASETS
accepted = {k: d.accepted for k, d in DATASETS.items() if d.accepted}
reg, notes, summ = regress.compare(base, rec, full=full, expected=expected, accepted=accepted)
text = f"Record `{', '.join(r.name for r in records)}` against `{baseline.name}` ({', '.join(base['relsynth'])})\n\n" + \
regress.report(reg, notes, summ)
print(text)
Expand Down
70 changes: 70 additions & 0 deletions bench/builders/aml_parquet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-License-Identifier: Apache-2.0
"""IBM Transactions for Anti-Money Laundering (IT-AML, Altman et al. 2023; CDLA-Sharing-1.0), one
variant's *_Trans.csv as a four-table Parquet source.

python aml_parquet.py TRANS.csv OUTDIR

The CSV is one flat file of transfers. The tables follow the dataset's entity model:

- `bank.parquet`: bank_id (text: codes keep their leading zeros, "010" is not "10");
- `account.parquet`: account_key (surrogate, 1..n in bank_id, account_id order), bank_id, account_id.
An account id is unique only within its bank, so the key is the pair; the surrogate lets a fact
reference it with one column;
- `currency.parquet`: currency (the names of both currency columns), usd_rate (units per US Dollar: the
rate the simulator converts at, read from the cross-currency payments);
- `trans.parquet`: trans_id (file row order: the CSV has no key), ts (minute), from_bank, from_account_key,
to_bank, to_account_key, amount_received, receiving_currency, amount_paid, payment_currency,
payment_format, is_laundering. Every value is as published; duplicate rows stay.

Written with DuckDB, so the five million rows never pass through pandas.
"""
import sys
from pathlib import Path

import duckdb

src, out = Path(sys.argv[1]), Path(sys.argv[2])
out.mkdir(parents=True, exist_ok=True)
con = duckdb.connect()
# both account columns are named "Account" in the header: read by position, every value as text. Paths go
# through the relation API (no SQL text is built from a value)
csv = con.read_csv(str(src), header=True, all_varchar=True,
names=["ts", "fb", "fa", "tb", "ta", "ar", "rc", "ap", "pc", "pf", "lab"])
con.sql("SELECT row_number() OVER () AS trans_id, * FROM csv").to_table("raw")
con.execute("CREATE TEMP TABLE acct AS SELECT row_number() OVER (ORDER BY b, a) AS account_key, b AS bank_id, "
"a AS account_id FROM (SELECT fb AS b, fa AS a FROM raw UNION SELECT tb, ta FROM raw)")
con.sql("SELECT DISTINCT bank_id FROM acct ORDER BY bank_id").write_parquet(str(out / "bank.parquet"))
con.sql("SELECT * FROM acct ORDER BY account_key").write_parquet(str(out / "account.parquet"))
# the simulator converts at one rate per currency for the whole period, and the rates of all pairs are
# consistent through the US Dollar (A->B = usd(B) / usd(A) within 0.2 %, rounding of small amounts):
# usd_rate = units per US Dollar, the median rate of the cross-currency payments of at least 100 units
# that start or end in US Dollar (6 significant digits)
con.execute("""CREATE TEMP TABLE ccy AS WITH c AS (SELECT DISTINCT x AS currency FROM (SELECT rc AS x FROM raw
UNION SELECT pc FROM raw)),
fwd AS (SELECT rc AS currency, median(ar::DOUBLE / ap::DOUBLE) AS r FROM raw
WHERE pc = 'US Dollar' AND rc <> pc AND ap::DOUBLE >= 100 GROUP BY 1),
rev AS (SELECT pc AS currency, median(ap::DOUBLE / ar::DOUBLE) AS r FROM raw
WHERE rc = 'US Dollar' AND rc <> pc AND ar::DOUBLE >= 100 GROUP BY 1)
SELECT c.currency, CASE WHEN c.currency = 'US Dollar' THEN 1.0 ELSE
(SELECT round(v, 5 - floor(log10(v))::INTEGER) FROM (SELECT coalesce(fwd.r, rev.r) AS v)) END AS usd_rate
FROM c LEFT JOIN fwd USING (currency) LEFT JOIN rev USING (currency)""")
missing = con.execute("SELECT list(currency) FROM ccy WHERE usd_rate IS NULL").fetchall()[0][0]
if missing:
raise SystemExit(f"no US Dollar rate for {missing}")
con.sql("SELECT * FROM ccy ORDER BY currency").write_parquet(str(out / "currency.parquet"))
# the specification applies the rate "at Timestamp": report how far each currency's daily rate moves from
# its rate over the period (a fixed rate shows rounding only)
moved = con.execute("""SELECT max(abs(d / c.usd_rate - 1)) FROM (SELECT rc AS currency, substr(ts, 1, 10) AS day,
median(ar::DOUBLE / ap::DOUBLE) AS d, count(*) AS n FROM raw
WHERE pc = 'US Dollar' AND rc <> pc AND ap::DOUBLE >= 100 GROUP BY 1, 2) JOIN ccy c USING (currency)
WHERE n >= 5""").fetchall()[0][0]
print(f"largest daily move of a US Dollar rate from its period rate: {moved:.4%}", file=sys.stderr)
con.sql("""SELECT r.trans_id, strptime(r.ts, '%Y/%m/%d %H:%M') AS ts,
r.fb AS from_bank, f.account_key AS from_account_key, r.tb AS to_bank, t.account_key AS to_account_key,
r.ar::DOUBLE AS amount_received, r.rc AS receiving_currency, r.ap::DOUBLE AS amount_paid,
r.pc AS payment_currency, r.pf AS payment_format, r.lab::INTEGER AS is_laundering
FROM raw r JOIN acct f ON f.bank_id = r.fb AND f.account_id = r.fa
JOIN acct t ON t.bank_id = r.tb AND t.account_id = r.ta ORDER BY r.trans_id""").write_parquet(
str(out / "trans.parquet"), compression="zstd")
for t in ("bank", "account", "currency", "trans"):
print(t, con.read_parquet(str(out / f"{t}.parquet")).shape[0], "rows")
Loading
Loading