tieout-ai 0.1.0__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 (36) hide show
  1. tieout_ai-0.1.0/LICENSE +202 -0
  2. tieout_ai-0.1.0/PKG-INFO +198 -0
  3. tieout_ai-0.1.0/README.md +180 -0
  4. tieout_ai-0.1.0/pyproject.toml +64 -0
  5. tieout_ai-0.1.0/pyproject.toml.orig +51 -0
  6. tieout_ai-0.1.0/src/tieout_ai/__init__.py +5 -0
  7. tieout_ai-0.1.0/src/tieout_ai/assumptions.py +124 -0
  8. tieout_ai-0.1.0/src/tieout_ai/certify.py +370 -0
  9. tieout_ai-0.1.0/src/tieout_ai/checks/__init__.py +49 -0
  10. tieout_ai-0.1.0/src/tieout_ai/checks/base.py +365 -0
  11. tieout_ai-0.1.0/src/tieout_ai/checks/duplicates.py +123 -0
  12. tieout_ai-0.1.0/src/tieout_ai/checks/rounding.py +77 -0
  13. tieout_ai-0.1.0/src/tieout_ai/checks/sign_credit.py +117 -0
  14. tieout_ai-0.1.0/src/tieout_ai/checks/status_filter.py +97 -0
  15. tieout_ai-0.1.0/src/tieout_ai/checks/tax_basis.py +110 -0
  16. tieout_ai-0.1.0/src/tieout_ai/checks/timing.py +156 -0
  17. tieout_ai-0.1.0/src/tieout_ai/cli.py +710 -0
  18. tieout_ai-0.1.0/src/tieout_ai/connections.py +125 -0
  19. tieout_ai-0.1.0/src/tieout_ai/connectors/__init__.py +28 -0
  20. tieout_ai-0.1.0/src/tieout_ai/connectors/base.py +94 -0
  21. tieout_ai-0.1.0/src/tieout_ai/connectors/files.py +65 -0
  22. tieout_ai-0.1.0/src/tieout_ai/connectors/sql.py +346 -0
  23. tieout_ai-0.1.0/src/tieout_ai/demo.py +137 -0
  24. tieout_ai-0.1.0/src/tieout_ai/fixtures/__init__.py +5 -0
  25. tieout_ai-0.1.0/src/tieout_ai/fixtures/generate.py +220 -0
  26. tieout_ai-0.1.0/src/tieout_ai/fixtures/generate_messy.py +251 -0
  27. tieout_ai-0.1.0/src/tieout_ai/hashing.py +174 -0
  28. tieout_ai-0.1.0/src/tieout_ai/match.py +169 -0
  29. tieout_ai-0.1.0/src/tieout_ai/mcp_server.py +214 -0
  30. tieout_ai-0.1.0/src/tieout_ai/models.py +384 -0
  31. tieout_ai-0.1.0/src/tieout_ai/project.py +94 -0
  32. tieout_ai-0.1.0/src/tieout_ai/py.typed +0 -0
  33. tieout_ai-0.1.0/src/tieout_ai/render.py +369 -0
  34. tieout_ai-0.1.0/src/tieout_ai/service.py +453 -0
  35. tieout_ai-0.1.0/src/tieout_ai/session.py +240 -0
  36. tieout_ai-0.1.0/src/tieout_ai/signing.py +285 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://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
+ https://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.
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: tieout-ai
3
+ Version: 0.1.0
4
+ Summary: AI TieOut: prove two business numbers agree. The AI proposes, code proves, people confirm.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Dist: cryptography>=43
8
+ Requires-Dist: mcp>=2.3
9
+ Requires-Dist: numpy>=1.26
10
+ Requires-Dist: openpyxl>=3.1
11
+ Requires-Dist: pandas>=2.2
12
+ Requires-Dist: pydantic>=2.7
13
+ Requires-Dist: sqlalchemy>=2.0
14
+ Requires-Dist: sqlglot>=25
15
+ Requires-Dist: typer>=0.12
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+
19
+ # AI TieOut
20
+
21
+ **Prove that two business numbers agree, or explain every dollar of the difference.**
22
+
23
+ AI TieOut is a reconciliation engine for the age of AI analysts. Your AI assistant
24
+ investigates; the engine proves; you confirm. At the end you get a certificate that
25
+ shows exactly how one number ties out to the other, which a CFO or auditor can read.
26
+
27
+ ## The problem
28
+
29
+ Every month-end asks the same question: *why doesn't the dashboard match the ledger?*
30
+
31
+ The answer is usually mundane. Invoices dated by appointment on one side and by
32
+ issue date on the other. Voided invoices one system still counts. GST included here
33
+ and excluded there. A batch exported twice. Finding it takes hours of filtering
34
+ spreadsheets, and the explanation ends up in a workbook nobody can audit.
35
+
36
+ AI assistants are now good at the investigating part. They can read the data, spot
37
+ patterns and form hypotheses in minutes. But an answer that *sounds* right is not
38
+ an answer that *is* right. Left alone, an AI will happily round a residual away,
39
+ filter out the awkward rows, or tell you the numbers reconcile when they don't. In
40
+ finance, that difference matters.
41
+
42
+ ## AI proposes, code proves, people confirm
43
+
44
+ AI TieOut splits the job so each part is done by whoever can be trusted with it.
45
+
46
+ - **The AI proposes.** It explores the sources, writes queries, chooses how to match
47
+ them and suggests why they differ ("these 58 invoices are dated a month apart").
48
+ It works through an MCP server and passes only references and parameters, never
49
+ numbers it claims are results.
50
+ - **Code proves.** The engine fetches the data itself, matches it row by row, tests
51
+ each hypothesis with a guarded check, and sums every amount. It claims only the
52
+ differences it can prove. Everything else stays *unexplained*, never rounded
53
+ away. Buckets plus residual always equal the gap, to the cent.
54
+ - **People confirm.** Every judgement call (a filter, a tax rate, a date basis) is
55
+ recorded as an assumption, scoped to the records it covers. Anything that loosens
56
+ a default is flagged *elevated*. Only a person, in their own terminal and with
57
+ their own signing key, can confirm an assumption or sign a certificate off.
58
+
59
+ There are no LLM calls in the engine. Everything is deterministic and reproducible.
60
+
61
+ ## Try it in 60 seconds
62
+
63
+ You need [uv](https://docs.astral.sh/uv/getting-started/installation/). Then:
64
+
65
+ ```bash
66
+ uvx tieout-ai demo
67
+ ```
68
+
69
+ This runs two "dashboard vs Xero" reconciliations end to end in a temporary folder
70
+ and opens their certificates in your browser:
71
+
72
+ - **Clean**: a $29,072 gap, fully explained by timing, voided invoices, GST,
73
+ duplicates and credit notes. **RECONCILED** and signed off.
74
+ - **Messy**: real-world dirt (case and whitespace variants, blank amounts,
75
+ near-duplicates, cent rounding). Most of the gap is explained; the rest
76
+ ($1,326.00 net) is honestly reported as **unexplained**, item by item.
77
+
78
+ The demo confirms and signs with a throwaway key it makes for the purpose, so
79
+ nothing touches your machine's real setup.
80
+
81
+ ## How it works
82
+
83
+ 1. **A person registers the sources**: CSV or Excel files, or SQL databases
84
+ (read-only, `SELECT` only). Each registration is hashed and signed with the
85
+ person's key, so the engine notices if a file changes or a source is swapped.
86
+ 2. **The AI investigates** through the MCP server: it profiles the sources, runs
87
+ queries, matches the two sides on keys, amounts and dates for a period, and
88
+ reads the differences that are left.
89
+ 3. **The AI tries hypotheses**, and the engine tests them with built-in checks.
90
+ Each check has hard guardrails and claims only what it can prove:
91
+
92
+ | Check | Explains |
93
+ |---|---|
94
+ | `timing` | The same transaction dated in different periods on each side |
95
+ | `status_filter` | Rows of a status (e.g. voided) one side leaves out |
96
+ | `tax_basis` | One side including tax (e.g. 10% GST) and the other not |
97
+ | `duplicates` | Rows one side repeats |
98
+ | `sign_credit` | Credit notes with opposite signs, or missing on one side |
99
+ | `rounding` | Differences of a cent or so, within a strict tolerance |
100
+
101
+ 4. **The engine issues a certificate**: every bucket of explained difference with
102
+ its rows and amounts, the unexplained residual, every assumption, and the hashes
103
+ of the exact data used. Its status is **OPEN** (something is unexplained),
104
+ **PROVISIONAL** (all explained, but resting on unconfirmed assumptions) or
105
+ **RECONCILED** (all explained, all confirmed).
106
+ 5. **A person confirms and signs off.** `tieout confirm` and `tieout cert sign` run
107
+ only in an interactive terminal and need the person's passphrase. A RECONCILED
108
+ certificate is final only once it is signed off.
109
+
110
+ ### On your own data
111
+
112
+ ```bash
113
+ uv tool install tieout-ai
114
+ ```
115
+
116
+ ```bash
117
+ tieout init
118
+ ```
119
+
120
+ `tieout init` sets up the current folder: the workspace, the MCP server for Claude
121
+ Code, permission rules that keep the human-only commands away from the AI, and
122
+ your signing key. Then register your sources:
123
+
124
+ ```bash
125
+ tieout connections add-file dashboard path/to/dashboard.csv
126
+ ```
127
+
128
+ ```bash
129
+ tieout connections add-sql ledger
130
+ ```
131
+
132
+ Open Claude Code in that folder and ask it to reconcile, in plain English. Other
133
+ MCP clients can run the server directly with `tieout-mcp --home .tieout`. When the
134
+ AI reports assumptions to confirm, review them and confirm the ones you agree with:
135
+
136
+ ```bash
137
+ tieout assumptions list
138
+ ```
139
+
140
+ ```bash
141
+ tieout confirm <assumption_id>
142
+ ```
143
+
144
+ When it reports a RECONCILED certificate, check it and sign it off:
145
+
146
+ ```bash
147
+ tieout cert show <certificate_id> --html certificate.html
148
+ ```
149
+
150
+ ```bash
151
+ tieout cert sign <certificate_id>
152
+ ```
153
+
154
+ ## Security
155
+
156
+ The AI is not trusted, and AI TieOut assumes it may have a shell and write access
157
+ to the same files you do. So the important protections are cryptographic and
158
+ detective, not permissions:
159
+
160
+ - Sources are hashed and their registrations signed, so an edited file or a
161
+ swapped source keeps the certificate OPEN, or is refused outright.
162
+ - Confirmations and sign-offs are signed with the person's passphrase-protected
163
+ key. A confirmation typed into a file, or signed with any other key, does not
164
+ count.
165
+ - SQL may not truncate results. Filters and computed columns become assumptions,
166
+ and anything that loosens a default is flagged elevated.
167
+ - Certificates are hashed and must be self-consistent, so altered or forged ones
168
+ are refused or flagged as unverifiable.
169
+ - Every certificate shows the fingerprint of the key behind it. Check it against
170
+ `tieout keys fingerprint` on the signer's machine, or against the fingerprint the
171
+ signer publishes.
172
+
173
+ [SECURITY.md](SECURITY.md) has the threat model, what is caught, flagged and out of
174
+ scope, and the results of a red-team exercise, including its known limitations.
175
+
176
+ ## Why I built this
177
+
178
+ I'm an analytics engineer with a finance background. A lot of my working life has
179
+ gone into the question every month-end asks: why doesn't this number match that
180
+ one? The answer is almost always findable, but it takes hours, and the result
181
+ usually lives in a spreadsheet that only its author can follow.
182
+
183
+ AI assistants changed the first half of that job overnight. They are fast,
184
+ tireless investigators. But I wouldn't sign off on a number because an AI said it
185
+ was fine, and I wouldn't ask a CFO to either. What I wanted was the speed of the AI
186
+ with the rigour of a reconciliation that proves itself: every dollar traced to
187
+ rows, every judgement call written down and confirmed by a person.
188
+
189
+ AI TieOut is that tool. I hope it saves you some month-ends.
190
+
191
+ ## Contributing
192
+
193
+ Contributions are welcome, especially new checks. [CONTRIBUTING.md](CONTRIBUTING.md)
194
+ explains how to set up, the ground rules, and how to write your own check.
195
+
196
+ ## Licence
197
+
198
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,180 @@
1
+ # AI TieOut
2
+
3
+ **Prove that two business numbers agree, or explain every dollar of the difference.**
4
+
5
+ AI TieOut is a reconciliation engine for the age of AI analysts. Your AI assistant
6
+ investigates; the engine proves; you confirm. At the end you get a certificate that
7
+ shows exactly how one number ties out to the other, which a CFO or auditor can read.
8
+
9
+ ## The problem
10
+
11
+ Every month-end asks the same question: *why doesn't the dashboard match the ledger?*
12
+
13
+ The answer is usually mundane. Invoices dated by appointment on one side and by
14
+ issue date on the other. Voided invoices one system still counts. GST included here
15
+ and excluded there. A batch exported twice. Finding it takes hours of filtering
16
+ spreadsheets, and the explanation ends up in a workbook nobody can audit.
17
+
18
+ AI assistants are now good at the investigating part. They can read the data, spot
19
+ patterns and form hypotheses in minutes. But an answer that *sounds* right is not
20
+ an answer that *is* right. Left alone, an AI will happily round a residual away,
21
+ filter out the awkward rows, or tell you the numbers reconcile when they don't. In
22
+ finance, that difference matters.
23
+
24
+ ## AI proposes, code proves, people confirm
25
+
26
+ AI TieOut splits the job so each part is done by whoever can be trusted with it.
27
+
28
+ - **The AI proposes.** It explores the sources, writes queries, chooses how to match
29
+ them and suggests why they differ ("these 58 invoices are dated a month apart").
30
+ It works through an MCP server and passes only references and parameters, never
31
+ numbers it claims are results.
32
+ - **Code proves.** The engine fetches the data itself, matches it row by row, tests
33
+ each hypothesis with a guarded check, and sums every amount. It claims only the
34
+ differences it can prove. Everything else stays *unexplained*, never rounded
35
+ away. Buckets plus residual always equal the gap, to the cent.
36
+ - **People confirm.** Every judgement call (a filter, a tax rate, a date basis) is
37
+ recorded as an assumption, scoped to the records it covers. Anything that loosens
38
+ a default is flagged *elevated*. Only a person, in their own terminal and with
39
+ their own signing key, can confirm an assumption or sign a certificate off.
40
+
41
+ There are no LLM calls in the engine. Everything is deterministic and reproducible.
42
+
43
+ ## Try it in 60 seconds
44
+
45
+ You need [uv](https://docs.astral.sh/uv/getting-started/installation/). Then:
46
+
47
+ ```bash
48
+ uvx tieout-ai demo
49
+ ```
50
+
51
+ This runs two "dashboard vs Xero" reconciliations end to end in a temporary folder
52
+ and opens their certificates in your browser:
53
+
54
+ - **Clean**: a $29,072 gap, fully explained by timing, voided invoices, GST,
55
+ duplicates and credit notes. **RECONCILED** and signed off.
56
+ - **Messy**: real-world dirt (case and whitespace variants, blank amounts,
57
+ near-duplicates, cent rounding). Most of the gap is explained; the rest
58
+ ($1,326.00 net) is honestly reported as **unexplained**, item by item.
59
+
60
+ The demo confirms and signs with a throwaway key it makes for the purpose, so
61
+ nothing touches your machine's real setup.
62
+
63
+ ## How it works
64
+
65
+ 1. **A person registers the sources**: CSV or Excel files, or SQL databases
66
+ (read-only, `SELECT` only). Each registration is hashed and signed with the
67
+ person's key, so the engine notices if a file changes or a source is swapped.
68
+ 2. **The AI investigates** through the MCP server: it profiles the sources, runs
69
+ queries, matches the two sides on keys, amounts and dates for a period, and
70
+ reads the differences that are left.
71
+ 3. **The AI tries hypotheses**, and the engine tests them with built-in checks.
72
+ Each check has hard guardrails and claims only what it can prove:
73
+
74
+ | Check | Explains |
75
+ |---|---|
76
+ | `timing` | The same transaction dated in different periods on each side |
77
+ | `status_filter` | Rows of a status (e.g. voided) one side leaves out |
78
+ | `tax_basis` | One side including tax (e.g. 10% GST) and the other not |
79
+ | `duplicates` | Rows one side repeats |
80
+ | `sign_credit` | Credit notes with opposite signs, or missing on one side |
81
+ | `rounding` | Differences of a cent or so, within a strict tolerance |
82
+
83
+ 4. **The engine issues a certificate**: every bucket of explained difference with
84
+ its rows and amounts, the unexplained residual, every assumption, and the hashes
85
+ of the exact data used. Its status is **OPEN** (something is unexplained),
86
+ **PROVISIONAL** (all explained, but resting on unconfirmed assumptions) or
87
+ **RECONCILED** (all explained, all confirmed).
88
+ 5. **A person confirms and signs off.** `tieout confirm` and `tieout cert sign` run
89
+ only in an interactive terminal and need the person's passphrase. A RECONCILED
90
+ certificate is final only once it is signed off.
91
+
92
+ ### On your own data
93
+
94
+ ```bash
95
+ uv tool install tieout-ai
96
+ ```
97
+
98
+ ```bash
99
+ tieout init
100
+ ```
101
+
102
+ `tieout init` sets up the current folder: the workspace, the MCP server for Claude
103
+ Code, permission rules that keep the human-only commands away from the AI, and
104
+ your signing key. Then register your sources:
105
+
106
+ ```bash
107
+ tieout connections add-file dashboard path/to/dashboard.csv
108
+ ```
109
+
110
+ ```bash
111
+ tieout connections add-sql ledger
112
+ ```
113
+
114
+ Open Claude Code in that folder and ask it to reconcile, in plain English. Other
115
+ MCP clients can run the server directly with `tieout-mcp --home .tieout`. When the
116
+ AI reports assumptions to confirm, review them and confirm the ones you agree with:
117
+
118
+ ```bash
119
+ tieout assumptions list
120
+ ```
121
+
122
+ ```bash
123
+ tieout confirm <assumption_id>
124
+ ```
125
+
126
+ When it reports a RECONCILED certificate, check it and sign it off:
127
+
128
+ ```bash
129
+ tieout cert show <certificate_id> --html certificate.html
130
+ ```
131
+
132
+ ```bash
133
+ tieout cert sign <certificate_id>
134
+ ```
135
+
136
+ ## Security
137
+
138
+ The AI is not trusted, and AI TieOut assumes it may have a shell and write access
139
+ to the same files you do. So the important protections are cryptographic and
140
+ detective, not permissions:
141
+
142
+ - Sources are hashed and their registrations signed, so an edited file or a
143
+ swapped source keeps the certificate OPEN, or is refused outright.
144
+ - Confirmations and sign-offs are signed with the person's passphrase-protected
145
+ key. A confirmation typed into a file, or signed with any other key, does not
146
+ count.
147
+ - SQL may not truncate results. Filters and computed columns become assumptions,
148
+ and anything that loosens a default is flagged elevated.
149
+ - Certificates are hashed and must be self-consistent, so altered or forged ones
150
+ are refused or flagged as unverifiable.
151
+ - Every certificate shows the fingerprint of the key behind it. Check it against
152
+ `tieout keys fingerprint` on the signer's machine, or against the fingerprint the
153
+ signer publishes.
154
+
155
+ [SECURITY.md](SECURITY.md) has the threat model, what is caught, flagged and out of
156
+ scope, and the results of a red-team exercise, including its known limitations.
157
+
158
+ ## Why I built this
159
+
160
+ I'm an analytics engineer with a finance background. A lot of my working life has
161
+ gone into the question every month-end asks: why doesn't this number match that
162
+ one? The answer is almost always findable, but it takes hours, and the result
163
+ usually lives in a spreadsheet that only its author can follow.
164
+
165
+ AI assistants changed the first half of that job overnight. They are fast,
166
+ tireless investigators. But I wouldn't sign off on a number because an AI said it
167
+ was fine, and I wouldn't ask a CFO to either. What I wanted was the speed of the AI
168
+ with the rigour of a reconciliation that proves itself: every dollar traced to
169
+ rows, every judgement call written down and confirmed by a person.
170
+
171
+ AI TieOut is that tool. I hope it saves you some month-ends.
172
+
173
+ ## Contributing
174
+
175
+ Contributions are welcome, especially new checks. [CONTRIBUTING.md](CONTRIBUTING.md)
176
+ explains how to set up, the ground rules, and how to write your own check.
177
+
178
+ ## Licence
179
+
180
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,64 @@
1
+ [project]
2
+ name = "tieout-ai"
3
+ version = "0.1.0"
4
+ description = "AI TieOut: prove two business numbers agree. The AI proposes, code proves, people confirm."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.11"
9
+ dependencies = [
10
+ "cryptography>=43",
11
+ "mcp>=2.3",
12
+ "numpy>=1.26",
13
+ "openpyxl>=3.1",
14
+ "pandas>=2.2",
15
+ "pydantic>=2.7",
16
+ "sqlalchemy>=2.0",
17
+ "sqlglot>=25",
18
+ "typer>=0.12",
19
+ ]
20
+
21
+ [project.scripts]
22
+ tieout = "tieout_ai.cli:app"
23
+ tieout-ai = "tieout_ai.cli:app"
24
+ tieout-mcp = "tieout_ai.mcp_server:main"
25
+
26
+ [dependency-groups]
27
+ dev = [
28
+ "pytest>=8",
29
+ "ruff>=0.6",
30
+ ]
31
+
32
+ [build-system]
33
+ requires = ["uv_build>=0.13.7,<0.14.0"]
34
+ build-backend = "uv_build"
35
+
36
+ [tool.pytest.ini_options]
37
+ testpaths = ["tests"]
38
+ addopts = [
39
+ "--import-mode=importlib",
40
+ "--strict-markers",
41
+ ]
42
+ pythonpath = [
43
+ "tests",
44
+ ".",
45
+ ]
46
+
47
+ [tool.ruff]
48
+ line-length = 100
49
+ target-version = "py311"
50
+
51
+ [tool.ruff.lint]
52
+ select = [
53
+ "E",
54
+ "F",
55
+ "W",
56
+ "I",
57
+ "B",
58
+ "UP",
59
+ "SIM",
60
+ "RUF",
61
+ ]
62
+
63
+ [tool.ruff.lint.per-file-ignores]
64
+ "src/tieout_ai/render.py" = ["E501"]