Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
f495893
fix(engine): enforce late rules and place unique link keys on free pa…
claude Nov 28, 2026
899f1fe
fix(engine): reset the facts' late-rule groups at the start of each d…
claude Nov 28, 2026
1ee6025
fix(engine): code-review findings on late rules and free-parent repair
claude Nov 28, 2026
2425352
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 28, 2026
c8b07d7
Merge main (#80) into the late-rules branch; proofs section renumbere…
claude Nov 28, 2026
e0f014a
fix(engine): address CodeRabbit review of late rules and free parents
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ All notable user-visible changes are recorded here, following [Keep a Changelog

### Fixed

- **Late rules are enforced** (`synthesis.rules.late`, default `enforce`; Prop. 1881). A check rule that reads an aggregate column, on its own table or through a link (a card issued on or after its account's opening date, when that date is the account's first transaction), was only counted. After the aggregates, the rows that break one are redrawn from their own conditional and kept only when every late rule holds, every other rule that held still holds, unique keys over attributes stay unique and the row is not a near copy; the aggregates are then recomputed. The redraw is skipped, with the reason in the sample log (`late_rules`), when other values were computed from the row's attributes (a rule of another table reading them, conditioned facts, offsets, versions, sequences, scenario maps). `report` keeps the earlier behaviour. Tables without late rules are unchanged.
- **Unique keys of one link and fixed columns are placed exactly** (`synthesis.uniqueness.free_parent_repair`, default `auto`; Prop. 1880). Rows the unique-key sampler cannot place (one owner per account, when nearly every account already has one) now get a parent drawn by the link model among the parents whose key is still free for the row, instead of uniformly among all parents. Berka: 25 accounts with two owners and 27 unresolved rows became 0. Only rows that broke a unique key are affected; `off` restores the uniform fallback.
- Pushdown: a sampled fact with a date offset (or another hidden column of the internal model) no longer
fails with a KeyError; segment discovery's GROUP BY statistics use source columns only (TPC-H SF1 bench).
- Loading: categorical and text columns read with a nullable dtype (Int64, Float64, boolean, as a
Expand Down
1 change: 1 addition & 0 deletions docs/proofs/relsynth-proofs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ \subsection{Defaults}
\input{sec_v73_selection.tex}
\input{sec_v74_ctvae.tex}
\input{sec_v75_rolelinks.tex}
\input{sec_v76_latekeys.tex}

%=====================================================================
\section{Evaluation thresholds}\label{sec:thresholds}
Expand Down
25 changes: 25 additions & 0 deletions docs/proofs/sec_v76_latekeys.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%=====================================================================
\section{Late rules and unique link keys}\label{sec:v76latekeys}
% numbered from 1880; the shared counter is restored at the end
\newcounter{savedproplatekeys}\setcounter{savedproplatekeys}{\value{proposition}}
Two classes of declared constraint were reported but not always met. A \emph{late rule} is a check rule that reads an aggregate column, on its own table or through a link (a card issued on or after its account's opening date, when the opening date is the account's first transaction date). It can be evaluated only after every table is drawn and the aggregates computed. A \emph{unique link key} is a unique key made of one link and columns fixed before the links (one owner per account: \texttt{[account\_id, type]}, with the type set from the disposition's stratum). When nearly every parent already holds the key, the link model's proposals and a uniform fallback rarely reach the few free parents, so rows were left in conflict. The code is \texttt{Synthesizer.\_enforce\_late} and \texttt{Synthesizer.\_free\_parents}; the tests are in \texttt{tests/unit/test\_late\_rules\_unique\_links.py}.

\setcounter{proposition}{1879}
\begin{proposition}[Free-parent draws keep the link model on the valid set]\label{prop:freeparents}
Let a group of $m$ rows share the values of the other columns of every unique key that holds link $L$, and let $F$ be the set of parents whose key is not held by another row of the group. Row $i$ of segment $k_i$ draws parent $p$ with probability proportional to $\pi_i(p)=\phi_{k_i,z_p}\,w_p/m_{z_p}$, the link model's probability (segment link law $\phi$, degree weight $w_p$, $m_s$ parents in segment $s$). The rows of one segment draw distinct parents from $F$ by successive sampling proportional to $\pi$ (Gumbel top-$k$), and the parents taken are removed from $F$ before the next segment's rows. Rows left over once the free parents of positive weight are taken (including a segment whose weight on $F$ is zero throughout) are placed uniformly on the remaining free parents. (a) When $|F|\ge m$, every row of the group is placed and the group's key stays unique. (b) A placement made while the remaining free parents carry positive total weight has the law $\pi_i$ restricted to the parents still free, i.e.\ the link model conditioned on the key constraint for that row given the rows already placed; a leftover placement (zero remaining weight) is uniform on the free parents and is a repair, not a draw from the link model, since that set has probability zero under it. (c) Rows that already satisfied every key and rule are not moved.
\end{proposition}
\begin{proof}
(a) Each segment's block takes $\min(\text{rows},|\{p\in F:\pi(p)>0\}|)$ distinct parents of $F$ and removes them, and its leftover rows take distinct parents uniformly among those still free; with $|F|\ge m$, every row receives a distinct free parent, so no two rows of the group hold the same key and no row takes a key held outside the group. (b) For the weighted placements: adding independent Gumbel noise to $\log\pi$ and taking the top $r$ (over the parents of positive weight) is equivalent to drawing $r$ items one at a time without replacement with probability proportional to $\pi$ among those left (Vieira 2014; Kool et al.\ 2019), so each draw is $\pi_i$ restricted to the parents still free. (c) The repair runs only on rows marked invalid, and the move is accepted by the same check as every other move of the unique-key sampler (key rules, mandatory participation, keys). The MH sweeps that follow keep the restricted law invariant (Section on unique keys).
\end{proof}
\noindent The draw is a repair, as was the uniform fallback it replaces for links in a unique key: it reaches a valid state with the link model's weights where the uniform fallback ignored them. Setting \texttt{uniqueness.free\_parent\_repair: off} restores the uniform fallback. Test \texttt{test\_unique\_link\_key\_exact}.

\setcounter{proposition}{1880}
\begin{proposition}[Late rules by redraw after the aggregates]\label{prop:laterules}
Let $R$ be the late rules of table $t$, $Q(x\mid z)$ the generator's law of a row's modelled attributes given its segment (and conditioning values), and $V_i$ the set of attribute values for which row $i$ satisfies $R$, keeps every other rule of $t$ it satisfied, keeps the unique keys over attributes, and is not a near copy. Rows that break $R$ draw $x\sim Q(\cdot\mid z_i)$ until $x\in V_i$, at most \texttt{rules.max\_rejection\_rounds} times; the aggregates, lookups and derives are then recomputed. (a) An accepted row has the law $Q(\cdot\mid z_i,\,x\in V_i)$. (b) A row is changed only when it broke a late rule and the new values satisfy all of them and every other rule of $t$ that held on it, so no rule of $t$ that held on a row is broken by the redraw. Rules of other tables are kept where they read the redrawn columns directly or through a lookup (the redraw is then skipped); a rule of another table that reads an aggregate over $t$ is not guarded and may fail after a redraw, in which case it is counted in the final violations (as \texttt{still\_violating} for late rules). (c) When the redrawn table does not feed an aggregate, $V_i$ does not change during the redraws and one pass suffices; otherwise the pass is repeated on the recomputed aggregates, at most three times, and the remaining violations are reported.
\end{proposition}
\begin{proof}
(a) Rejection sampling: draws are independent from $Q(\cdot\mid z_i)$ and accepted exactly on $V_i$, so the accepted value has the restricted law (the argument of the rule redraws in \texttt{\_finish}). (b) Acceptance requires every late rule and every rule of $t$ that held before. The redraw is made only when no rule of another table reads the redrawn columns, directly or through a lookup or a derive over one, and the table is not one whose other values are computed from these attributes (versions, sequences, anchored links, inclusion masks, group effects, text, cumulative rules, scenario maps); aggregates over $t$ are recomputed but rules reading them are not part of the acceptance test; the final violation counts are recomputed on all tables after the aggregates. (c) $V_i$ depends on the aggregates only through the columns the rules read; if $t$ is not aggregated, these do not change while $t$ is redrawn.
\end{proof}
\noindent Privacy: the redrawn values are new draws from the fitted model, as for any rule redraw, and are subject to the near-copy guard where it applies; no source row is read at sampling time. \texttt{rules.late: report} keeps the earlier behaviour (late rules counted, not enforced). Test \texttt{test\_late\_rule\_enforced}.

\setcounter{proposition}{\value{savedproplatekeys}}
2 changes: 2 additions & 0 deletions docs/settings-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Generated from `relsynth.settings` (`python -m relsynth.settings > docs/settings
| `uniqueness.mh_sweeps` | int | `20` | 0 … 1e+06 | yes (log) | Sweeps of the unique-key sampler. |
| `uniqueness.grain` | choice | `auto` | auto, none | | auto \| none: unique keys of two foreign keys become grains. |
| `uniqueness.rake_rounds` | int | `3` | 0 … 10000 | yes | Rounds of raking for rule cells. |
| `uniqueness.free_parent_repair` | choice | `auto` | auto, off | | auto \| off: rows the unique-key sampler cannot place get a parent drawn by the link model among the parents whose key is still free for the row (one owner per account); off: uniformly over all parents (2.x) (Prop. 1880). |
| `trees.max_depth` | int | `auto` | 1 … 1e+06 or auto | | auto \| int: deepest hierarchy level generated. |
| `trees.frailty` | choice | `auto` | auto, on, off | yes | auto \| on \| off: branching heterogeneity in trees. |
| `text.order` | int | `3` | 1 … 12 | yes | n-gram order of text columns. |
Expand All @@ -99,6 +100,7 @@ Generated from `relsynth.settings` (`python -m relsynth.settings > docs/settings
| `rules.rake_max_levels` | int | `50` | 1 … 1e+07 | | Rule cells: a column with more levels is not raked. |
| `rules.rake_max_cells` | int | `2000` | 1 … 1e+09 | | Rule cells: largest joint table raked. |
| `rules.balance_floor` | choice | `auto` | auto, off | | auto: a running balance (cumulative rule with an outflow column) that is negative on a share p of its source rows gets the floor 0 when the synthetic running sum would be negative on more than 2 p of rows, i.e. when the floor matches the source's share of negative rows better (Prop. 1787; never negative in the source: always a floor); off: only never-negative balances get the floor (2.2). |
| `rules.late` | choice | `enforce` | enforce, report | | enforce \| report: check rules that read an aggregate column (directly or through a link) are enforced after the aggregates by redrawing the rows that break them; report: only counted (2.x) (Prop. 1881). |
| `repair.pair_tries` | int | `200` | 0 … 1e+07 | yes (log) | Degree-preserving swaps tried per repeated pair or self-link before the pair is dropped. |
| `repair.constraint_rounds` | int | `200` | 0 … 1e+07 | yes (log) | Redraw rounds of entity rows that break a check rule or a unique key. |
| `repair.thin_rounds` | int | `200` | 0 … 1e+07 | | Rounds of anchor thinning (participation of facts). |
Expand Down
2 changes: 2 additions & 0 deletions docs/spec-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ Every key below is checked by `validate`. Any other key is an error, with the cl
| `structure.link_affinity` | `rows` | Default of link_affinity model (rows or share). |
| `uniqueness.mh_sweeps` | `20` | Sweeps of the unique-key sampler. |
| `uniqueness.grain` | `auto` | auto \| none: unique keys of two foreign keys become grains. |
| `uniqueness.free_parent_repair` | `auto` | auto \| off: rows the unique-key sampler cannot place get a parent drawn by the link model among the parents whose key is still free for the row (one owner per account); off: uniformly over all parents (2.x) (Prop. 1880). |
| `uniqueness.rake_rounds` | `3` | Rounds of raking for rule cells. |
| `trees.max_depth` | `auto` | auto \| int: deepest hierarchy level generated. |
| `trees.frailty` | `auto` | auto \| on \| off: branching heterogeneity in trees. |
Expand All @@ -755,6 +756,7 @@ Every key below is checked by `validate`. Any other key is an error, with the cl
| `text.backoff_strength` | `2.0` | Back-off weight of the n-gram model. |
| `text.max_retries` | `30` | Retries before a text value is replaced. |
| `rules.max_rejection_rounds` | `25` | Redraw rounds for rows that fail a check rule. |
| `rules.late` | `enforce` | enforce \| report: check rules that read an aggregate column (directly or through a link) are enforced after the aggregates by redrawing the rows that break them; report: only counted (2.x) (Prop. 1881). |
| `rules.rake_max_levels` | `50` | Rule cells: a column with more levels is not raked. |
| `rules.rake_max_cells` | `2000` | Rule cells: largest joint table raked. |
| `rules.balance_floor` | `auto` | auto: a running balance (cumulative rule with an outflow column) that is negative on a share p of its source rows gets the floor 0 when the synthetic running sum would be negative on more than 2 p of rows, i.e. when the floor matches the source's share of negative rows better (Prop. 1787; never negative in the source: always a floor); off: only never-negative balances get the floor (2.2). |
Expand Down
Loading
Loading