attestql 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. attestql-0.2.1/LICENSE +202 -0
  2. attestql-0.2.1/NOTICE +44 -0
  3. attestql-0.2.1/PKG-INFO +187 -0
  4. attestql-0.2.1/README.md +160 -0
  5. attestql-0.2.1/pyproject.toml +93 -0
  6. attestql-0.2.1/setup.cfg +4 -0
  7. attestql-0.2.1/src/attestql/__init__.py +6 -0
  8. attestql-0.2.1/src/attestql/audit/__init__.py +82 -0
  9. attestql-0.2.1/src/attestql/audit/backend.py +453 -0
  10. attestql-0.2.1/src/attestql/audit/cli.py +1762 -0
  11. attestql-0.2.1/src/attestql/audit/compare.py +1107 -0
  12. attestql-0.2.1/src/attestql/audit/engines.py +190 -0
  13. attestql-0.2.1/src/attestql/audit/fixture.py +184 -0
  14. attestql-0.2.1/src/attestql/audit/parse.py +243 -0
  15. attestql-0.2.1/src/attestql/audit/postgres.py +1254 -0
  16. attestql-0.2.1/src/attestql/audit/smells.py +934 -0
  17. attestql-0.2.1/src/attestql/audit/sqlite.py +1048 -0
  18. attestql-0.2.1/src/attestql/audit/sqlite_statements.py +508 -0
  19. attestql-0.2.1/src/attestql/audit/statements.py +458 -0
  20. attestql-0.2.1/src/attestql/contract/__init__.py +1 -0
  21. attestql-0.2.1/src/attestql/contract/clock.py +214 -0
  22. attestql-0.2.1/src/attestql/evidence/__init__.py +86 -0
  23. attestql-0.2.1/src/attestql/evidence/build.py +163 -0
  24. attestql-0.2.1/src/attestql/evidence/record.py +124 -0
  25. attestql-0.2.1/src/attestql/evidence/render.py +287 -0
  26. attestql-0.2.1/src/attestql/evidence/replay.py +296 -0
  27. attestql-0.2.1/src/attestql/evidence/serialize.py +270 -0
  28. attestql-0.2.1/src/attestql/evidence/types.py +298 -0
  29. attestql-0.2.1/src/attestql/kernel/__init__.py +6 -0
  30. attestql-0.2.1/src/attestql/kernel/ports.py +51 -0
  31. attestql-0.2.1/src/attestql/kernel/types.py +279 -0
  32. attestql-0.2.1/src/attestql.egg-info/PKG-INFO +187 -0
  33. attestql-0.2.1/src/attestql.egg-info/SOURCES.txt +56 -0
  34. attestql-0.2.1/src/attestql.egg-info/dependency_links.txt +1 -0
  35. attestql-0.2.1/src/attestql.egg-info/entry_points.txt +2 -0
  36. attestql-0.2.1/src/attestql.egg-info/requires.txt +3 -0
  37. attestql-0.2.1/src/attestql.egg-info/top_level.txt +1 -0
  38. attestql-0.2.1/tests/test_audit_audits_a_sqlite_file.py +931 -0
  39. attestql-0.2.1/tests/test_audit_chooses_one_engine_for_the_whole_run.py +137 -0
  40. attestql-0.2.1/tests/test_audit_command_runs_over_a_question_file.py +1785 -0
  41. attestql-0.2.1/tests/test_audit_compares_a_gold_with_a_second_statement.py +733 -0
  42. attestql-0.2.1/tests/test_audit_end_to_end.py +601 -0
  43. attestql-0.2.1/tests/test_audit_executor_refuses_a_session_that_drifted.py +1052 -0
  44. attestql-0.2.1/tests/test_audit_measures_the_data_once_and_remembers_it.py +183 -0
  45. attestql-0.2.1/tests/test_audit_reads_a_sqlite_statement.py +396 -0
  46. attestql-0.2.1/tests/test_audit_reads_the_statement_before_running_it.py +211 -0
  47. attestql-0.2.1/tests/test_audit_sandbox_smoke.py +373 -0
  48. attestql-0.2.1/tests/test_audit_sandbox_sqlite.py +647 -0
  49. attestql-0.2.1/tests/test_audit_smells_read_the_gold_and_the_data.py +787 -0
  50. attestql-0.2.1/tests/test_audit_survives_a_lost_connection.py +146 -0
  51. attestql-0.2.1/tests/test_boundary.py +383 -0
  52. attestql-0.2.1/tests/test_canonical_serialization.py +402 -0
  53. attestql-0.2.1/tests/test_clock.py +167 -0
  54. attestql-0.2.1/tests/test_evidence_record_builder.py +435 -0
  55. attestql-0.2.1/tests/test_replay_equality.py +678 -0
  56. attestql-0.2.1/tests/test_repo_checks.py +209 -0
  57. attestql-0.2.1/tests/test_session_settings.py +95 -0
  58. attestql-0.2.1/tests/test_stub_surface.py +192 -0
attestql-0.2.1/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
attestql-0.2.1/NOTICE ADDED
@@ -0,0 +1,44 @@
1
+ AttestQL
2
+ Copyright 2026 Hoang Le
3
+
4
+ This repository is licensed under the Apache License, Version 2.0 (see LICENSE), with the
5
+ exceptions listed here.
6
+
7
+ The following files contain material excerpted from BIRD Mini-Dev
8
+ (https://github.com/bird-bench/mini_dev), which is licensed under the Creative Commons
9
+ Attribution-ShareAlike 4.0 International licence (CC BY-SA 4.0,
10
+ https://creativecommons.org/licenses/by-sa/4.0/). That material is not covered by the
11
+ Apache License and keeps its own licence and attribution:
12
+
13
+ tools/audit-sandbox/questions.json
14
+ the question text, evidence text, gold SQL and difficulty of Mini-Dev questions 1029, 879
15
+ and 207, reproduced because the defect the sandbox replays is in that shipped gold; the rows
16
+ those statements run against are this repository's own synthetic fixture.
17
+ tools/audit-sandbox-sqlite/questions.json
18
+ the question text, evidence text, gold SQL and difficulty of the same three questions as
19
+ they are written in Mini-Dev's SQLite copy, reproduced for the same reason; the rows those
20
+ statements run against are this repository's own synthetic fixture.
21
+ plans/reports/spike-260902-three-gold-defects/
22
+ evidence records and counterexamples for the same three questions, holding their gold SQL
23
+ and a few result rows from the Mini-Dev PostgreSQL databases.
24
+ plans/reports/sweep-260902-gold-only-probes/fired.json
25
+ the question text, evidence text and gold SQL of the 52 Mini-Dev questions on which a
26
+ gold-only probe fired, with the rows the probe read.
27
+ plans/reports/parser-260903-postgast-against-pglast/current-parser.json and previous-parser.json
28
+ the table names and the ordering expressions of the 498 Mini-Dev gold statements, as two
29
+ parsers read them.
30
+ plans/reports/minidev-260903-zip-against-hf/
31
+ the two gold statements that differ between the GitHub zip and the Hugging Face file, in
32
+ both forms.
33
+ plans/reports/prediction-mode-260904-real-predictions/examples/
34
+ four counterexamples (Mini-Dev questions 565, 1035, 1473 and 1057): the question text,
35
+ evidence text and gold SQL, a prediction from BIRD's own llm/exp_result/sql_output_kg
36
+ files, and the rows both returned from the Mini-Dev PostgreSQL databases.
37
+ plans/reports/minidev-sqlite-260907/examples/
38
+ three counterexamples (Mini-Dev questions 846, 45 and 1035): the question text, evidence
39
+ text and gold SQL as Mini-Dev's SQLite copy writes them, a prediction from BIRD's own
40
+ llm/exp_result/sql_output_kg files, and the rows both returned from the Mini-Dev SQLite
41
+ databases.
42
+
43
+ Every other file, including the run outputs that carry only question ids, verdicts, hashes and
44
+ counts, is this repository's own work under the Apache License.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: attestql
3
+ Version: 0.2.1
4
+ Summary: Audit text-to-SQL gold and predictions on PostgreSQL with typed replay evidence.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/ivermin1123/attestql
7
+ Project-URL: Repository, https://github.com/ivermin1123/attestql
8
+ Project-URL: Issues, https://github.com/ivermin1123/attestql/issues
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Database
18
+ Classifier: Topic :: Software Development :: Testing
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: psycopg[binary]<4,>=3.3.4
24
+ Requires-Dist: postgast==0.1.0
25
+ Requires-Dist: sqlglot==30.18.0
26
+ Dynamic: license-file
27
+
28
+ # AttestQL
29
+
30
+ You have a text-to-SQL prediction file and a benchmark that scored it. Run one command and get,
31
+ per question, whether the prediction and the gold disagree on the shipped data, the rows that
32
+ differ, and what the benchmark's own scorer would have said: for a question scored 0, the rows
33
+ that decided it, and for one scored 1, whether a comparison that keeps duplicates, order and types
34
+ agrees with the set comparison that credited it.
35
+
36
+ ```text
37
+ attestql audit --engine sqlite --dsn sandbox/fixture.sqlite \
38
+ --questions tools/audit-sandbox-sqlite/questions.json \
39
+ --predictions tools/audit-sandbox-sqlite/predictions.json --out audit
40
+ ```
41
+
42
+ That run is this repository's own sandbox: the three BIRD Mini-Dev golds that upstream reports
43
+ found wrong (q1029, q879, q207) on a fixture of a few rows, each paired with a corrected statement
44
+ as its prediction, plus three synthetic questions. Its output, unedited:
45
+
46
+ ```text
47
+ q1029 european_football_2 R-ORD NOT_EQUAL smells=none audit/q1029/
48
+ q879 formula_1 R-ORD NOT_EQUAL smells=ordering-over-numeric-text audit/q879/
49
+ q207 toxicology R-SET NOT_EQUAL smells=none audit/q207/
50
+ q900001 synthetic R-ORD GOLD-ONLY smells=not-a-function-of-the-data audit/q900001/
51
+ q900002 synthetic R-ORD GOLD-ONLY smells=arbitrary-cut,not-a-function-of-the-data audit/q900002/
52
+ q900005 synthetic R-ORD EQUAL smells=ordering-over-numeric-text audit/q900005/
53
+ 6 questions: 3 NOT_EQUAL, 5 smells fired, 0 credited by BIRD but NOT_EQUAL (0 multiplicity, 0 type, 0 order, 0 truncation), 0 timed out (0 gold, 0 prediction)
54
+ ```
55
+
56
+ Every `NOT_EQUAL` line has a directory. `audit/q879/counterexample.json` says why that one
57
+ disagrees, trimmed here to the fields a reader opens first:
58
+
59
+ ```text
60
+ "gold": "... ORDER BY T2.fastestLapSpeed DESC LIMIT 1" -> "Norwegian"
61
+ "second": "... ORDER BY CAST(T2.fastestLapSpeed AS REAL) DESC LIMIT 1" -> "Peruvian"
62
+ "bird_ex": {"value": 0, "method": "set(second_rows) == set(gold_rows), ..."}
63
+ "differing_rows": {"in_gold_not_in_second": [["Norwegian"]], "in_second_not_in_gold": [["Peruvian"]]}
64
+ ```
65
+
66
+ and `audit/q879/smells.json` names the mechanism: `fastestLapSpeed` is a text column holding only
67
+ numbers, so the gold sorts `9.5` above `10` and the fastest lap is not the one it returns. The
68
+ same directory holds the two evidence records, each with the statement, the role, the engine,
69
+ the session settings, the result and its hash, and how to run it again.
70
+
71
+ **NOT_EQUAL never means the gold is wrong.** It means these two statements disagree on this data
72
+ under this rule; here are the rows; decide. The benchmark's own reading,
73
+ `set(predicted) == set(gold)`, is computed beside every verdict as `bird_ex`, and the typed
74
+ comparison beside it keeps duplicate rows, keeps order where the gold orders, and compares values
75
+ by declared type, so a prediction the benchmark credits and this tool calls `NOT_EQUAL` is listed
76
+ on the summary line by what makes the two readings differ.
77
+
78
+ ## Install
79
+
80
+ Python 3.11 or later. From PyPI:
81
+
82
+ ```text
83
+ uv tool install attestql # or: pip install attestql
84
+ ```
85
+
86
+ Or from a checkout, which is also how the sandbox above is built:
87
+
88
+ ```text
89
+ git clone https://github.com/ivermin1123/attestql && cd attestql
90
+ uv run python tools/audit-sandbox-sqlite/build.py sandbox
91
+ uv run attestql audit --engine sqlite --dsn sandbox/fixture.sqlite \
92
+ --questions tools/audit-sandbox-sqlite/questions.json \
93
+ --predictions tools/audit-sandbox-sqlite/predictions.json --out audit
94
+ ```
95
+
96
+ On your own files the command is the same. On SQLite, `--dsn` is the path to one database file and
97
+ `--ids` picks the questions that database answers, so a benchmark of eleven databases is eleven
98
+ runs; BIRD Mini-Dev and BIRD dev ship as SQLite files and need nothing else installed. On
99
+ PostgreSQL 16 one server holds every database of the benchmark, so one run covers the whole
100
+ question file:
101
+
102
+ ```text
103
+ attestql audit --dsn "host=localhost dbname=bird" \
104
+ --questions minidev/MINIDEV/mini_dev_postgresql.json --predictions preds.json --out audit
105
+ ```
106
+
107
+ A predictions file written for this tool is keyed by question id (`{"879": "SELECT ..."}`); BIRD's
108
+ own `predict_dev.json` files are keyed by position and are read with
109
+ `--predictions-keyed-by position`. Without `--predictions` the run audits the golds alone and runs
110
+ the mechanical probes that need no second statement: an ordering key that is text holding numbers,
111
+ an arbitrary or null-first cut that changes the answer, and a result that changes when the
112
+ referenced tables are copied in another row order. Exit status is 0 with no disagreement, 1 with at least one, 2 when
113
+ the tool could not run. Every flag, every line of the output and every key of `summary.json` is
114
+ described in [docs/audit-command.md](docs/audit-command.md).
115
+
116
+ ## What it found
117
+
118
+ Three measurements, each on BIRD's own published files, each with its report, its artifact and
119
+ BIRD's own evaluator run beside the tool as the check.
120
+
121
+ **BIRD Mini-Dev on PostgreSQL.** Of the 1,239 predictions in BIRD's nine published Mini-Dev
122
+ prediction files that BIRD's evaluator scores 1, 164 (13.2 %) are `NOT_EQUAL` under the typed
123
+ comparison, and read by hand 69 of those (42.1 %; 5.6 % of everything BIRD credits) are wrong
124
+ answers the benchmark credited, 74 are duplicated rows a reader would forgive, and 21 are the
125
+ typed rule alone. The two readings of EX agree on 4,476 of 4,482 predictions, and every
126
+ disagreement is one float sum whose last digits depend on the order its parts are added in
127
+ ([report](plans/reports/measurement-260904-0046-prediction-mode-on-real-predictions.md)).
128
+
129
+ **BIRD Mini-Dev on SQLite.** The same nine files on the eleven Mini-Dev database files, with no
130
+ server: the tool's reading of BIRD's EX and BIRD's own evaluator agree on 4,481 of 4,482, and of
131
+ the 1,650 predictions BIRD credits, 237 (14.4 %) are `NOT_EQUAL` under the typed comparison. A
132
+ sample of 50 of those 237, read by hand, is 27 wrong answers the benchmark credited, 22 duplicated
133
+ rows a reader would forgive and 1 the typed rule itself
134
+ ([report](plans/reports/measurement-260907-1106-minidev-sqlite.md)).
135
+
136
+ **BIRD dev, both copies of the golds.** BIRD's 2025-11-06 quality pass rewrote 399 of the 1,534
137
+ dev golds; the gold-only probes, run over the older copy, fire on 31 of those 399 (7.8 %) against
138
+ 25 of the 963 golds BIRD left alone (2.6 %), and 29 of the 31 go quiet once BIRD's own rewrite
139
+ replaces the old gold. The 25 fires on golds BIRD did not touch were read by hand: 23 are golds
140
+ that do not answer their question on this data, one is harmless, one is the tool's own rule
141
+ ([report](plans/reports/measurement-260907-1435-bird-dev-sqlite.md)).
142
+
143
+ ## What was reported upstream
144
+
145
+ Six reports, filed under the owner's own GitHub and Hugging Face identity, each with its
146
+ counterexample. The replies, as of 2026-09-07:
147
+
148
+ | # | Where | What | Reply |
149
+ |---|---|---|---|
150
+ | 1 | [mini_dev issue 38](https://github.com/bird-bench/mini_dev/issues/38#issuecomment-5529732756) | q1029 orders `ASC NULLS FIRST` for "highest" | BIRD team, 2026-09-05: "We will review and correct this issue in the next patch." Issue closed |
151
+ | 2 | [mini_dev issue 39](https://github.com/bird-bench/mini_dev/issues/39) | q207 joins `bond` on `molecule_id`, 13 elements instead of 5 | BIRD team, 2026-09-05: "We will review and correct this issue in the next patch." Issue closed |
152
+ | 3 | [mini_dev issue 40](https://github.com/bird-bench/mini_dev/issues/40) | the GitHub zip and the Hugging Face dataset are different question sets | BIRD team, 2026-09-05: README changed to name the Hugging Face dataset as the one to download. Issue closed |
153
+ | 4 | [SpotIt-plus issue 1](https://github.com/ai-ar-research/SpotIt-plus/issues/1) | asked which licence applies | Withdrawn by the owner on 2026-09-05: the LICENSE does grant use after its first sentence, so the report rested on a misreading |
154
+ | 5 | [mini_dev issue 48](https://github.com/bird-bench/mini_dev/issues/48) | the PostgreSQL evaluator scores q1473 differently on two runs of the same database | none yet |
155
+ | 6 | [mini_dev issue 49](https://github.com/bird-bench/mini_dev/issues/49), [dataset discussion 3](https://huggingface.co/datasets/birdsql/bird_sql_dev_20251106/discussions/3) | 23 BIRD dev golds the 2025-11-06 pass left unchanged that do not answer their question on the shipped data | none yet |
156
+
157
+ ## What it does not do
158
+
159
+ - It does not decide which statement is right. A second statement is supplied by you: a model's
160
+ prediction, an upstream correction, a human's fix.
161
+ - It does not generate differentiating data. Two statements that agree on the shipped rows but
162
+ differ semantically are found only by the shuffle probe, not by search.
163
+ - The probes are heuristics and say so in their own evidence; the direction probe alone is 17 %
164
+ precise on Mini-Dev and is off by default.
165
+ - It proves nothing about correctness, security, or production use. It runs as the role you give
166
+ it; give it a read-only one.
167
+
168
+ ## How to check rather than believe
169
+
170
+ Every number above has an owning artifact in [the claims register](docs/claims-register.md),
171
+ which also lists the claims this project deliberately does not make and dates every negative
172
+ claim, because negative claims decay. The three shipped-gold defects reproduce in the merge gate
173
+ on both engines (`tools/audit-sandbox/`, `tools/audit-sandbox-sqlite/`) every time `just check`
174
+ runs. [ADR-0013](docs/adr/0013-audit-text-to-sql-gold-with-typed-replay-evidence.md) records the
175
+ decision this tool implements and the date by which it is reconsidered if nobody uses it.
176
+
177
+ The history is short and stated: this repository was developed privately from 2026-08-25 under a
178
+ different product direction; it was reoriented on 2026-09-02 by ADR-0013 to the problem above, and
179
+ the public history starts after that. The code was written with AI assistance under the owner's
180
+ review, and the gate, not the author, is what vouches for it.
181
+
182
+ ## Licence
183
+
184
+ Apache-2.0 for this repository (`LICENSE`). The material excerpted from BIRD Mini-Dev, listed in
185
+ `NOTICE`, keeps its own CC BY-SA 4.0 licence. The PostgreSQL parser, `postgast`, is a BSD binding
186
+ to `libpg_query`, PostgreSQL's own grammar as a library, and the PostgreSQL driver, `psycopg`, is
187
+ LGPL. The SQLite parser, `sqlglot`, is MIT, and the SQLite driver is the standard library's.
@@ -0,0 +1,160 @@
1
+ # AttestQL
2
+
3
+ You have a text-to-SQL prediction file and a benchmark that scored it. Run one command and get,
4
+ per question, whether the prediction and the gold disagree on the shipped data, the rows that
5
+ differ, and what the benchmark's own scorer would have said: for a question scored 0, the rows
6
+ that decided it, and for one scored 1, whether a comparison that keeps duplicates, order and types
7
+ agrees with the set comparison that credited it.
8
+
9
+ ```text
10
+ attestql audit --engine sqlite --dsn sandbox/fixture.sqlite \
11
+ --questions tools/audit-sandbox-sqlite/questions.json \
12
+ --predictions tools/audit-sandbox-sqlite/predictions.json --out audit
13
+ ```
14
+
15
+ That run is this repository's own sandbox: the three BIRD Mini-Dev golds that upstream reports
16
+ found wrong (q1029, q879, q207) on a fixture of a few rows, each paired with a corrected statement
17
+ as its prediction, plus three synthetic questions. Its output, unedited:
18
+
19
+ ```text
20
+ q1029 european_football_2 R-ORD NOT_EQUAL smells=none audit/q1029/
21
+ q879 formula_1 R-ORD NOT_EQUAL smells=ordering-over-numeric-text audit/q879/
22
+ q207 toxicology R-SET NOT_EQUAL smells=none audit/q207/
23
+ q900001 synthetic R-ORD GOLD-ONLY smells=not-a-function-of-the-data audit/q900001/
24
+ q900002 synthetic R-ORD GOLD-ONLY smells=arbitrary-cut,not-a-function-of-the-data audit/q900002/
25
+ q900005 synthetic R-ORD EQUAL smells=ordering-over-numeric-text audit/q900005/
26
+ 6 questions: 3 NOT_EQUAL, 5 smells fired, 0 credited by BIRD but NOT_EQUAL (0 multiplicity, 0 type, 0 order, 0 truncation), 0 timed out (0 gold, 0 prediction)
27
+ ```
28
+
29
+ Every `NOT_EQUAL` line has a directory. `audit/q879/counterexample.json` says why that one
30
+ disagrees, trimmed here to the fields a reader opens first:
31
+
32
+ ```text
33
+ "gold": "... ORDER BY T2.fastestLapSpeed DESC LIMIT 1" -> "Norwegian"
34
+ "second": "... ORDER BY CAST(T2.fastestLapSpeed AS REAL) DESC LIMIT 1" -> "Peruvian"
35
+ "bird_ex": {"value": 0, "method": "set(second_rows) == set(gold_rows), ..."}
36
+ "differing_rows": {"in_gold_not_in_second": [["Norwegian"]], "in_second_not_in_gold": [["Peruvian"]]}
37
+ ```
38
+
39
+ and `audit/q879/smells.json` names the mechanism: `fastestLapSpeed` is a text column holding only
40
+ numbers, so the gold sorts `9.5` above `10` and the fastest lap is not the one it returns. The
41
+ same directory holds the two evidence records, each with the statement, the role, the engine,
42
+ the session settings, the result and its hash, and how to run it again.
43
+
44
+ **NOT_EQUAL never means the gold is wrong.** It means these two statements disagree on this data
45
+ under this rule; here are the rows; decide. The benchmark's own reading,
46
+ `set(predicted) == set(gold)`, is computed beside every verdict as `bird_ex`, and the typed
47
+ comparison beside it keeps duplicate rows, keeps order where the gold orders, and compares values
48
+ by declared type, so a prediction the benchmark credits and this tool calls `NOT_EQUAL` is listed
49
+ on the summary line by what makes the two readings differ.
50
+
51
+ ## Install
52
+
53
+ Python 3.11 or later. From PyPI:
54
+
55
+ ```text
56
+ uv tool install attestql # or: pip install attestql
57
+ ```
58
+
59
+ Or from a checkout, which is also how the sandbox above is built:
60
+
61
+ ```text
62
+ git clone https://github.com/ivermin1123/attestql && cd attestql
63
+ uv run python tools/audit-sandbox-sqlite/build.py sandbox
64
+ uv run attestql audit --engine sqlite --dsn sandbox/fixture.sqlite \
65
+ --questions tools/audit-sandbox-sqlite/questions.json \
66
+ --predictions tools/audit-sandbox-sqlite/predictions.json --out audit
67
+ ```
68
+
69
+ On your own files the command is the same. On SQLite, `--dsn` is the path to one database file and
70
+ `--ids` picks the questions that database answers, so a benchmark of eleven databases is eleven
71
+ runs; BIRD Mini-Dev and BIRD dev ship as SQLite files and need nothing else installed. On
72
+ PostgreSQL 16 one server holds every database of the benchmark, so one run covers the whole
73
+ question file:
74
+
75
+ ```text
76
+ attestql audit --dsn "host=localhost dbname=bird" \
77
+ --questions minidev/MINIDEV/mini_dev_postgresql.json --predictions preds.json --out audit
78
+ ```
79
+
80
+ A predictions file written for this tool is keyed by question id (`{"879": "SELECT ..."}`); BIRD's
81
+ own `predict_dev.json` files are keyed by position and are read with
82
+ `--predictions-keyed-by position`. Without `--predictions` the run audits the golds alone and runs
83
+ the mechanical probes that need no second statement: an ordering key that is text holding numbers,
84
+ an arbitrary or null-first cut that changes the answer, and a result that changes when the
85
+ referenced tables are copied in another row order. Exit status is 0 with no disagreement, 1 with at least one, 2 when
86
+ the tool could not run. Every flag, every line of the output and every key of `summary.json` is
87
+ described in [docs/audit-command.md](docs/audit-command.md).
88
+
89
+ ## What it found
90
+
91
+ Three measurements, each on BIRD's own published files, each with its report, its artifact and
92
+ BIRD's own evaluator run beside the tool as the check.
93
+
94
+ **BIRD Mini-Dev on PostgreSQL.** Of the 1,239 predictions in BIRD's nine published Mini-Dev
95
+ prediction files that BIRD's evaluator scores 1, 164 (13.2 %) are `NOT_EQUAL` under the typed
96
+ comparison, and read by hand 69 of those (42.1 %; 5.6 % of everything BIRD credits) are wrong
97
+ answers the benchmark credited, 74 are duplicated rows a reader would forgive, and 21 are the
98
+ typed rule alone. The two readings of EX agree on 4,476 of 4,482 predictions, and every
99
+ disagreement is one float sum whose last digits depend on the order its parts are added in
100
+ ([report](plans/reports/measurement-260904-0046-prediction-mode-on-real-predictions.md)).
101
+
102
+ **BIRD Mini-Dev on SQLite.** The same nine files on the eleven Mini-Dev database files, with no
103
+ server: the tool's reading of BIRD's EX and BIRD's own evaluator agree on 4,481 of 4,482, and of
104
+ the 1,650 predictions BIRD credits, 237 (14.4 %) are `NOT_EQUAL` under the typed comparison. A
105
+ sample of 50 of those 237, read by hand, is 27 wrong answers the benchmark credited, 22 duplicated
106
+ rows a reader would forgive and 1 the typed rule itself
107
+ ([report](plans/reports/measurement-260907-1106-minidev-sqlite.md)).
108
+
109
+ **BIRD dev, both copies of the golds.** BIRD's 2025-11-06 quality pass rewrote 399 of the 1,534
110
+ dev golds; the gold-only probes, run over the older copy, fire on 31 of those 399 (7.8 %) against
111
+ 25 of the 963 golds BIRD left alone (2.6 %), and 29 of the 31 go quiet once BIRD's own rewrite
112
+ replaces the old gold. The 25 fires on golds BIRD did not touch were read by hand: 23 are golds
113
+ that do not answer their question on this data, one is harmless, one is the tool's own rule
114
+ ([report](plans/reports/measurement-260907-1435-bird-dev-sqlite.md)).
115
+
116
+ ## What was reported upstream
117
+
118
+ Six reports, filed under the owner's own GitHub and Hugging Face identity, each with its
119
+ counterexample. The replies, as of 2026-09-07:
120
+
121
+ | # | Where | What | Reply |
122
+ |---|---|---|---|
123
+ | 1 | [mini_dev issue 38](https://github.com/bird-bench/mini_dev/issues/38#issuecomment-5529732756) | q1029 orders `ASC NULLS FIRST` for "highest" | BIRD team, 2026-09-05: "We will review and correct this issue in the next patch." Issue closed |
124
+ | 2 | [mini_dev issue 39](https://github.com/bird-bench/mini_dev/issues/39) | q207 joins `bond` on `molecule_id`, 13 elements instead of 5 | BIRD team, 2026-09-05: "We will review and correct this issue in the next patch." Issue closed |
125
+ | 3 | [mini_dev issue 40](https://github.com/bird-bench/mini_dev/issues/40) | the GitHub zip and the Hugging Face dataset are different question sets | BIRD team, 2026-09-05: README changed to name the Hugging Face dataset as the one to download. Issue closed |
126
+ | 4 | [SpotIt-plus issue 1](https://github.com/ai-ar-research/SpotIt-plus/issues/1) | asked which licence applies | Withdrawn by the owner on 2026-09-05: the LICENSE does grant use after its first sentence, so the report rested on a misreading |
127
+ | 5 | [mini_dev issue 48](https://github.com/bird-bench/mini_dev/issues/48) | the PostgreSQL evaluator scores q1473 differently on two runs of the same database | none yet |
128
+ | 6 | [mini_dev issue 49](https://github.com/bird-bench/mini_dev/issues/49), [dataset discussion 3](https://huggingface.co/datasets/birdsql/bird_sql_dev_20251106/discussions/3) | 23 BIRD dev golds the 2025-11-06 pass left unchanged that do not answer their question on the shipped data | none yet |
129
+
130
+ ## What it does not do
131
+
132
+ - It does not decide which statement is right. A second statement is supplied by you: a model's
133
+ prediction, an upstream correction, a human's fix.
134
+ - It does not generate differentiating data. Two statements that agree on the shipped rows but
135
+ differ semantically are found only by the shuffle probe, not by search.
136
+ - The probes are heuristics and say so in their own evidence; the direction probe alone is 17 %
137
+ precise on Mini-Dev and is off by default.
138
+ - It proves nothing about correctness, security, or production use. It runs as the role you give
139
+ it; give it a read-only one.
140
+
141
+ ## How to check rather than believe
142
+
143
+ Every number above has an owning artifact in [the claims register](docs/claims-register.md),
144
+ which also lists the claims this project deliberately does not make and dates every negative
145
+ claim, because negative claims decay. The three shipped-gold defects reproduce in the merge gate
146
+ on both engines (`tools/audit-sandbox/`, `tools/audit-sandbox-sqlite/`) every time `just check`
147
+ runs. [ADR-0013](docs/adr/0013-audit-text-to-sql-gold-with-typed-replay-evidence.md) records the
148
+ decision this tool implements and the date by which it is reconsidered if nobody uses it.
149
+
150
+ The history is short and stated: this repository was developed privately from 2026-08-25 under a
151
+ different product direction; it was reoriented on 2026-09-02 by ADR-0013 to the problem above, and
152
+ the public history starts after that. The code was written with AI assistance under the owner's
153
+ review, and the gate, not the author, is what vouches for it.
154
+
155
+ ## Licence
156
+
157
+ Apache-2.0 for this repository (`LICENSE`). The material excerpted from BIRD Mini-Dev, listed in
158
+ `NOTICE`, keeps its own CC BY-SA 4.0 licence. The PostgreSQL parser, `postgast`, is a BSD binding
159
+ to `libpg_query`, PostgreSQL's own grammar as a library, and the PostgreSQL driver, `psycopg`, is
160
+ LGPL. The SQLite parser, `sqlglot`, is MIT, and the SQLite driver is the standard library's.