Commit edbfa90
fix(codegen): lineage table CHECK refuses self-references (#78)
Closes #42.
`verisimdb_lineage_graph` had no constraint preventing
`(source_entity, source_table) == (target_entity, target_table)`. Any
row inserted with matching source/target tuples is a self-loop and
falsifies the README's "DAG" framing at the structural level.
Add a CHECK constraint:
CHECK (source_entity <> target_entity
OR source_table <> target_table)
i.e. at least one component of the (entity, table) pair must differ.
Two entities with the same id across different tables (a legitimate
cross-table derivation) still pass.
Multi-hop cycle prevention is a runtime concern (any number of CHECKs
can't catch chains); kept as a separate follow-up (V-L2-I2).
Test `test_lineage_table_has_self_reference_check` asserts the exact
CHECK clause appears in the emitted DDL with lineage enabled.
`cargo clippy --all-targets -- -D warnings` clean; 35 unit tests pass.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 0c9b766 commit edbfa90
1 file changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
151 | | - | |
| 155 | + | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
283 | 311 | | |
284 | 312 | | |
285 | 313 | | |
| |||
0 commit comments