smart-data-engine-sdk 0.1.0.dev0__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 (77) hide show
  1. smart_data_engine_sdk-0.1.0.dev0/.gitignore +38 -0
  2. smart_data_engine_sdk-0.1.0.dev0/LICENSE +201 -0
  3. smart_data_engine_sdk-0.1.0.dev0/NOTICE +13 -0
  4. smart_data_engine_sdk-0.1.0.dev0/PKG-INFO +152 -0
  5. smart_data_engine_sdk-0.1.0.dev0/README.md +118 -0
  6. smart_data_engine_sdk-0.1.0.dev0/pyproject.toml +132 -0
  7. smart_data_engine_sdk-0.1.0.dev0/src/sde/__init__.py +226 -0
  8. smart_data_engine_sdk-0.1.0.dev0/src/sde/canonical.py +141 -0
  9. smart_data_engine_sdk-0.1.0.dev0/src/sde/capabilities.py +62 -0
  10. smart_data_engine_sdk-0.1.0.dev0/src/sde/engines/__init__.py +0 -0
  11. smart_data_engine_sdk-0.1.0.dev0/src/sde/engines/clickhouse.py +689 -0
  12. smart_data_engine_sdk-0.1.0.dev0/src/sde/engines/orderbook.py +454 -0
  13. smart_data_engine_sdk-0.1.0.dev0/src/sde/engines/postgres.py +672 -0
  14. smart_data_engine_sdk-0.1.0.dev0/src/sde/entity.py +170 -0
  15. smart_data_engine_sdk-0.1.0.dev0/src/sde/errors.py +88 -0
  16. smart_data_engine_sdk-0.1.0.dev0/src/sde/explain.py +300 -0
  17. smart_data_engine_sdk-0.1.0.dev0/src/sde/groups.py +97 -0
  18. smart_data_engine_sdk-0.1.0.dev0/src/sde/hashing.py +242 -0
  19. smart_data_engine_sdk-0.1.0.dev0/src/sde/infer.py +461 -0
  20. smart_data_engine_sdk-0.1.0.dev0/src/sde/internal.py +90 -0
  21. smart_data_engine_sdk-0.1.0.dev0/src/sde/layout.py +660 -0
  22. smart_data_engine_sdk-0.1.0.dev0/src/sde/logging.py +132 -0
  23. smart_data_engine_sdk-0.1.0.dev0/src/sde/migration.py +820 -0
  24. smart_data_engine_sdk-0.1.0.dev0/src/sde/model.py +482 -0
  25. smart_data_engine_sdk-0.1.0.dev0/src/sde/placement.py +818 -0
  26. smart_data_engine_sdk-0.1.0.dev0/src/sde/py.typed +0 -0
  27. smart_data_engine_sdk-0.1.0.dev0/src/sde/routing.py +85 -0
  28. smart_data_engine_sdk-0.1.0.dev0/src/sde/schema.py +370 -0
  29. smart_data_engine_sdk-0.1.0.dev0/src/sde/session.py +507 -0
  30. smart_data_engine_sdk-0.1.0.dev0/src/sde/shapes.py +153 -0
  31. smart_data_engine_sdk-0.1.0.dev0/src/sde/telemetry.py +736 -0
  32. smart_data_engine_sdk-0.1.0.dev0/src/sde/testing/__init__.py +14 -0
  33. smart_data_engine_sdk-0.1.0.dev0/src/sde/testing/loader.py +175 -0
  34. smart_data_engine_sdk-0.1.0.dev0/src/sde/testing/memory.py +318 -0
  35. smart_data_engine_sdk-0.1.0.dev0/src/sde/types.py +228 -0
  36. smart_data_engine_sdk-0.1.0.dev0/src/sde/watermark.py +222 -0
  37. smart_data_engine_sdk-0.1.0.dev0/tests/_claims.py +87 -0
  38. smart_data_engine_sdk-0.1.0.dev0/tests/test_canonical.py +139 -0
  39. smart_data_engine_sdk-0.1.0.dev0/tests/test_clickhouse_slice.py +426 -0
  40. smart_data_engine_sdk-0.1.0.dev0/tests/test_compatibility_views.py +272 -0
  41. smart_data_engine_sdk-0.1.0.dev0/tests/test_conformance.py +854 -0
  42. smart_data_engine_sdk-0.1.0.dev0/tests/test_copy_freshness.py +493 -0
  43. smart_data_engine_sdk-0.1.0.dev0/tests/test_denormalized_layout.py +303 -0
  44. smart_data_engine_sdk-0.1.0.dev0/tests/test_dual_write.py +311 -0
  45. smart_data_engine_sdk-0.1.0.dev0/tests/test_engine_agreement.py +201 -0
  46. smart_data_engine_sdk-0.1.0.dev0/tests/test_explain_live.py +659 -0
  47. smart_data_engine_sdk-0.1.0.dev0/tests/test_failure_semantics.py +367 -0
  48. smart_data_engine_sdk-0.1.0.dev0/tests/test_groups_and_shapes.py +190 -0
  49. smart_data_engine_sdk-0.1.0.dev0/tests/test_hashing.py +439 -0
  50. smart_data_engine_sdk-0.1.0.dev0/tests/test_implementer_documents.py +390 -0
  51. smart_data_engine_sdk-0.1.0.dev0/tests/test_infer.py +253 -0
  52. smart_data_engine_sdk-0.1.0.dev0/tests/test_internal_failures.py +225 -0
  53. smart_data_engine_sdk-0.1.0.dev0/tests/test_layout_dialects.py +266 -0
  54. smart_data_engine_sdk-0.1.0.dev0/tests/test_migration.py +1050 -0
  55. smart_data_engine_sdk-0.1.0.dev0/tests/test_migration_live.py +391 -0
  56. smart_data_engine_sdk-0.1.0.dev0/tests/test_model.py +290 -0
  57. smart_data_engine_sdk-0.1.0.dev0/tests/test_neutral_declaration.py +92 -0
  58. smart_data_engine_sdk-0.1.0.dev0/tests/test_no_account.py +387 -0
  59. smart_data_engine_sdk-0.1.0.dev0/tests/test_no_account_live.py +455 -0
  60. smart_data_engine_sdk-0.1.0.dev0/tests/test_no_expiry.py +389 -0
  61. smart_data_engine_sdk-0.1.0.dev0/tests/test_no_retry.py +303 -0
  62. smart_data_engine_sdk-0.1.0.dev0/tests/test_orderbook_adapter.py +449 -0
  63. smart_data_engine_sdk-0.1.0.dev0/tests/test_orderbook_shape.py +227 -0
  64. smart_data_engine_sdk-0.1.0.dev0/tests/test_orderbook_slice.py +272 -0
  65. smart_data_engine_sdk-0.1.0.dev0/tests/test_overhead.py +247 -0
  66. smart_data_engine_sdk-0.1.0.dev0/tests/test_packaging.py +385 -0
  67. smart_data_engine_sdk-0.1.0.dev0/tests/test_placement_and_routing.py +396 -0
  68. smart_data_engine_sdk-0.1.0.dev0/tests/test_platforms.py +132 -0
  69. smart_data_engine_sdk-0.1.0.dev0/tests/test_postgres_slice.py +386 -0
  70. smart_data_engine_sdk-0.1.0.dev0/tests/test_readme_claims.py +227 -0
  71. smart_data_engine_sdk-0.1.0.dev0/tests/test_rollback_protection.py +303 -0
  72. smart_data_engine_sdk-0.1.0.dev0/tests/test_rollback_protection_live.py +181 -0
  73. smart_data_engine_sdk-0.1.0.dev0/tests/test_schema_statements.py +162 -0
  74. smart_data_engine_sdk-0.1.0.dev0/tests/test_schema_vectors_live.py +230 -0
  75. smart_data_engine_sdk-0.1.0.dev0/tests/test_session.py +273 -0
  76. smart_data_engine_sdk-0.1.0.dev0/tests/test_session_hashed.py +200 -0
  77. smart_data_engine_sdk-0.1.0.dev0/tests/test_telemetry.py +461 -0
@@ -0,0 +1,38 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .venv/
5
+ venv/
6
+ .mypy_cache/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+
13
+ # Node, for the TypeScript library
14
+ node_modules/
15
+ typescript/dist/
16
+
17
+ # Java, Rust
18
+ target/
19
+ .gradle/
20
+
21
+ # Artefacts that could carry a client's data. A placement map is fine to commit - it names tables,
22
+ # not rows - but anything a running application produced is not, and the cost of being wrong here is
23
+ # not a tidy repository, it is somebody else's data in our history.
24
+ *.profile.json
25
+ telemetry-*.json
26
+
27
+ # Local configuration and anything holding a key
28
+ .env
29
+ .env.*
30
+ !.env.example
31
+ *.pem
32
+ *.key
33
+
34
+ # Editors and OS
35
+ .idea/
36
+ .vscode/
37
+ .DS_Store
38
+ Thumbs.db
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,13 @@
1
+ Smart Data Engine client libraries
2
+ Copyright 2026 Smart Data Engines
3
+
4
+ This product includes software developed at Smart Data Engines
5
+ (https://smartdataengines.com).
6
+
7
+ The libraries in this repository are the client side of Smart Data Engine: they
8
+ declare a data model, cache a placement map, route operations and manage schema.
9
+ They connect to database engines directly and they work without an account.
10
+
11
+ The control plane - the placement planner, the scoring model and the migration
12
+ orchestrator - is a separate, private program and is not covered by this notice
13
+ or by this licence.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.5
2
+ Name: smart-data-engine-sdk
3
+ Version: 0.1.0.dev0
4
+ Summary: Smart Data Engine client library: declare a data model, we place it and move it
5
+ Project-URL: Homepage, https://github.com/Smart-Data-Engines/smart-data-engine-sdk
6
+ Project-URL: Repository, https://github.com/Smart-Data-Engines/smart-data-engine-sdk
7
+ Project-URL: Issues, https://github.com/Smart-Data-Engines/smart-data-engine-sdk/issues
8
+ Project-URL: Format contract, https://github.com/Smart-Data-Engines/smart-data-engine-sdk/blob/main/docs/format-contract.md
9
+ Project-URL: Failure semantics, https://github.com/Smart-Data-Engines/smart-data-engine-sdk/blob/main/docs/failure-semantics.md
10
+ Author: Smart Data Engines
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: clickhouse,database,placement,polystore,postgresql
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Database
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: <3.14,>=3.11
23
+ Provides-Extra: clickhouse
24
+ Requires-Dist: clickhouse-connect>=0.7; extra == 'clickhouse'
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.11; extra == 'dev'
27
+ Requires-Dist: pytest>=8; extra == 'dev'
28
+ Requires-Dist: ruff>=0.6; extra == 'dev'
29
+ Provides-Extra: postgres
30
+ Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
31
+ Provides-Extra: signed
32
+ Requires-Dist: cryptography>=42; extra == 'signed'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # sde — Smart Data Engine client library for Python
36
+
37
+ Declare your data model. We decide which database engine each part of it lives in, how it is laid out
38
+ there, and when it should move — and move it while your application keeps running.
39
+
40
+ Your code never names a table or an engine. That absence is the point: it is what lets the physical
41
+ schema change underneath you without touching a line of your code.
42
+
43
+ ```python
44
+ from datetime import datetime
45
+ from decimal import Decimal
46
+ from typing import Annotated
47
+ from uuid import UUID
48
+ import sde
49
+
50
+ @sde.entity
51
+ class User:
52
+ id: UUID
53
+ email: str
54
+
55
+ class Meta:
56
+ pii = ["email"]
57
+
58
+ @sde.entity
59
+ class Order:
60
+ id: UUID
61
+ user: sde.Ref[User]
62
+ total: Annotated[Decimal, sde.precision(12, 2)]
63
+ created_at: datetime
64
+
65
+ class Meta:
66
+ residency = "EU"
67
+
68
+ model = sde.build_model()
69
+ ```
70
+
71
+ ## What you declare, and what you do not
72
+
73
+ You declare entities, relations, and four invariants. Everything else about storage is ours to
74
+ decide.
75
+
76
+ The four exist because no amount of watching traffic reveals them:
77
+
78
+ | Declaration | Why traffic cannot tell us |
79
+ |---|---|
80
+ | `atomic_with` | that two entities must commit together is a business rule, not a pattern |
81
+ | `residency` | where data may legally live is not visible in a query |
82
+ | `pii` | which column is personal data determines retention and what may be denormalised |
83
+ | `cost_ceiling` | your budget is not in your workload |
84
+
85
+ Anything beyond those four and the list of engines you have available would be us handing work back
86
+ to you, which is the opposite of what this is for.
87
+
88
+ ## Two guarantees, and how to check them yourself
89
+
90
+ **We are not in your data path.** The library connects to your engines directly and answers every
91
+ operation from a locally cached placement map. Our service being down does not make your application
92
+ down. There is no configuration for this — there is no code path that routes your queries through us,
93
+ which you can confirm by reading `routing.py`: it is a dictionary lookup and three conditions.
94
+
95
+ **We never see a row.** Telemetry carries operation *shapes* and counts, never values, and a shape is
96
+ assembled from the structure of the call rather than from a query string — so there is nowhere for a
97
+ value to come from. This is the reason the library is open source: the guarantee is checkable instead
98
+ of promised.
99
+
100
+ ## It works without an account
101
+
102
+ Write a placement map by hand, point the library at it, and everything runs: no key, no network, no
103
+ account.
104
+
105
+ ```python
106
+ placement = sde.load_map(json.load(open("placement.json")), model=model)
107
+ ```
108
+
109
+ An unsigned map is valid. A *signed* map with no key to verify it is not, because a signature is a
110
+ claim that it came from us and an unverifiable claim is worse than no claim. This mode is supported
111
+ and tested, not tolerated — it is also the honest answer to what happens if you stop paying us.
112
+
113
+ ## Install
114
+
115
+ ```bash
116
+ pip install smart-data-engine-sdk # core, no dependencies at all
117
+ pip install 'smart-data-engine-sdk[signed]' # verify maps we signed
118
+ pip install 'smart-data-engine-sdk[postgres]' # PostgreSQL engine driver
119
+ ```
120
+
121
+ The core has no runtime dependencies. This library goes into your application, so every dependency
122
+ would be one you inherit and a version conflict you might have to resolve.
123
+
124
+ **The distribution is `smart-data-engine-sdk` and the import is `sde`, and neither half of that is a
125
+ preference.** `sde` alone is taken on PyPI by somebody else, and renaming the import to a
126
+ squatting-adjacent misspelling is worse for you than a distribution name that differs from it. The
127
+ obvious distribution name, `smart-data-engine`, is *refused by PyPI*: it answers 400, "the name is
128
+ too similar to an existing project". The project is `smartdata-engine`, registered by somebody else
129
+ with zero releases — PyPI compares names after stripping `._-` and folding `l`/`i` to `1` and `o` to
130
+ `0`, and both reduce to `smartdataeng1ne`. The suffix changes the reduction, and it matches the
131
+ repository name, which is the consistency worth having regardless.
132
+
133
+ **`smart-data-engine-sdk` is unclaimed on PyPI, so those three commands install nothing today.** That
134
+ is the honest state and not a typo: the library is not published yet. Read it as a warning rather
135
+ than a footnote, because three error messages inside this library point at the same commands - if
136
+ someone else registers the name before we do, a person who is already debugging gets told, by code
137
+ they had decided to trust, to install a stranger's package.
138
+ [`../docs/publishing.md`](../docs/publishing.md) is what closes this.
139
+
140
+ ## Conformance
141
+
142
+ Everything in `canonical.py`, `model.py`, `shapes.py` and `routing.py` implements a cross-language
143
+ contract, pinned by vectors in `../conformance/vectors`. The Python, TypeScript, Java and Rust
144
+ libraries run the same vectors in their own test runners, so a divergence is a red test for whoever
145
+ caused it rather than an operation written to the wrong engine in production.
146
+
147
+ If you are porting this to another language, `docs/format-contract.md` is meant to be sufficient on
148
+ its own. If it is not, that is a bug in the document.
149
+
150
+ ## Licence
151
+
152
+ Apache-2.0.
@@ -0,0 +1,118 @@
1
+ # sde — Smart Data Engine client library for Python
2
+
3
+ Declare your data model. We decide which database engine each part of it lives in, how it is laid out
4
+ there, and when it should move — and move it while your application keeps running.
5
+
6
+ Your code never names a table or an engine. That absence is the point: it is what lets the physical
7
+ schema change underneath you without touching a line of your code.
8
+
9
+ ```python
10
+ from datetime import datetime
11
+ from decimal import Decimal
12
+ from typing import Annotated
13
+ from uuid import UUID
14
+ import sde
15
+
16
+ @sde.entity
17
+ class User:
18
+ id: UUID
19
+ email: str
20
+
21
+ class Meta:
22
+ pii = ["email"]
23
+
24
+ @sde.entity
25
+ class Order:
26
+ id: UUID
27
+ user: sde.Ref[User]
28
+ total: Annotated[Decimal, sde.precision(12, 2)]
29
+ created_at: datetime
30
+
31
+ class Meta:
32
+ residency = "EU"
33
+
34
+ model = sde.build_model()
35
+ ```
36
+
37
+ ## What you declare, and what you do not
38
+
39
+ You declare entities, relations, and four invariants. Everything else about storage is ours to
40
+ decide.
41
+
42
+ The four exist because no amount of watching traffic reveals them:
43
+
44
+ | Declaration | Why traffic cannot tell us |
45
+ |---|---|
46
+ | `atomic_with` | that two entities must commit together is a business rule, not a pattern |
47
+ | `residency` | where data may legally live is not visible in a query |
48
+ | `pii` | which column is personal data determines retention and what may be denormalised |
49
+ | `cost_ceiling` | your budget is not in your workload |
50
+
51
+ Anything beyond those four and the list of engines you have available would be us handing work back
52
+ to you, which is the opposite of what this is for.
53
+
54
+ ## Two guarantees, and how to check them yourself
55
+
56
+ **We are not in your data path.** The library connects to your engines directly and answers every
57
+ operation from a locally cached placement map. Our service being down does not make your application
58
+ down. There is no configuration for this — there is no code path that routes your queries through us,
59
+ which you can confirm by reading `routing.py`: it is a dictionary lookup and three conditions.
60
+
61
+ **We never see a row.** Telemetry carries operation *shapes* and counts, never values, and a shape is
62
+ assembled from the structure of the call rather than from a query string — so there is nowhere for a
63
+ value to come from. This is the reason the library is open source: the guarantee is checkable instead
64
+ of promised.
65
+
66
+ ## It works without an account
67
+
68
+ Write a placement map by hand, point the library at it, and everything runs: no key, no network, no
69
+ account.
70
+
71
+ ```python
72
+ placement = sde.load_map(json.load(open("placement.json")), model=model)
73
+ ```
74
+
75
+ An unsigned map is valid. A *signed* map with no key to verify it is not, because a signature is a
76
+ claim that it came from us and an unverifiable claim is worse than no claim. This mode is supported
77
+ and tested, not tolerated — it is also the honest answer to what happens if you stop paying us.
78
+
79
+ ## Install
80
+
81
+ ```bash
82
+ pip install smart-data-engine-sdk # core, no dependencies at all
83
+ pip install 'smart-data-engine-sdk[signed]' # verify maps we signed
84
+ pip install 'smart-data-engine-sdk[postgres]' # PostgreSQL engine driver
85
+ ```
86
+
87
+ The core has no runtime dependencies. This library goes into your application, so every dependency
88
+ would be one you inherit and a version conflict you might have to resolve.
89
+
90
+ **The distribution is `smart-data-engine-sdk` and the import is `sde`, and neither half of that is a
91
+ preference.** `sde` alone is taken on PyPI by somebody else, and renaming the import to a
92
+ squatting-adjacent misspelling is worse for you than a distribution name that differs from it. The
93
+ obvious distribution name, `smart-data-engine`, is *refused by PyPI*: it answers 400, "the name is
94
+ too similar to an existing project". The project is `smartdata-engine`, registered by somebody else
95
+ with zero releases — PyPI compares names after stripping `._-` and folding `l`/`i` to `1` and `o` to
96
+ `0`, and both reduce to `smartdataeng1ne`. The suffix changes the reduction, and it matches the
97
+ repository name, which is the consistency worth having regardless.
98
+
99
+ **`smart-data-engine-sdk` is unclaimed on PyPI, so those three commands install nothing today.** That
100
+ is the honest state and not a typo: the library is not published yet. Read it as a warning rather
101
+ than a footnote, because three error messages inside this library point at the same commands - if
102
+ someone else registers the name before we do, a person who is already debugging gets told, by code
103
+ they had decided to trust, to install a stranger's package.
104
+ [`../docs/publishing.md`](../docs/publishing.md) is what closes this.
105
+
106
+ ## Conformance
107
+
108
+ Everything in `canonical.py`, `model.py`, `shapes.py` and `routing.py` implements a cross-language
109
+ contract, pinned by vectors in `../conformance/vectors`. The Python, TypeScript, Java and Rust
110
+ libraries run the same vectors in their own test runners, so a divergence is a red test for whoever
111
+ caused it rather than an operation written to the wrong engine in production.
112
+
113
+ If you are porting this to another language, `docs/format-contract.md` is meant to be sufficient on
114
+ its own. If it is not, that is a bug in the document.
115
+
116
+ ## Licence
117
+
118
+ Apache-2.0.
@@ -0,0 +1,132 @@
1
+ [build-system]
2
+ # Pinned low, not floating: the licence declaration below is the PEP 639 form, which hatchling
3
+ # learned in 1.27. An older one accepts `license = "Apache-2.0"` as a *file path* and produces an
4
+ # artefact whose licence metadata is a filename - wrong in a way that builds cleanly.
5
+ requires = ["hatchling>=1.27"]
6
+ build-backend = "hatchling.build"
7
+
8
+ [project]
9
+ # The distribution is "smart-data-engine-sdk"; the import is "sde". Neither half is a style choice
10
+ # and both were forced, which is worth knowing before somebody "tidies" them into agreement.
11
+ #
12
+ # "sde" is already taken on PyPI by someone else, and renaming the import path to something
13
+ # squatting-adjacent is worse for a client than a distribution name that differs from it.
14
+ #
15
+ # The obvious distribution name, "smart-data-engine", is **refused by PyPI** - measured on
16
+ # 12 September 2026, a 400 saying "the name is too similar to an existing project". The project it
17
+ # collides with is `smartdata-engine`, registered by somebody else with zero releases. PyPI compares
18
+ # `ultranormalize_name`, which strips `._-` and maps `l|L|i|I` to 1 and `o|O` to 0, so both names
19
+ # reduce to `smartdataeng1ne`. Adding the suffix changes the reduction to `smartdataeng1nesdk`, and
20
+ # it matches the repository name, which is the consistency worth having anyway.
21
+ #
22
+ # `pip install smart-data-engine-sdk` then `import sde`.
23
+ name = "smart-data-engine-sdk"
24
+ dynamic = ["version"]
25
+ description = "Smart Data Engine client library: declare a data model, we place it and move it"
26
+ readme = "README.md"
27
+ requires-python = ">=3.11,<3.14"
28
+ license = "Apache-2.0"
29
+ # Apache-2.0 section 4 asks that the licence travel with the work, and section 4(d) says the same
30
+ # about a NOTICE file where one exists. Both were missing from the wheel and the sdist until this
31
+ # line: `license = { text = "Apache-2.0" }` puts the *name* of the licence in the metadata and ships
32
+ # no licence at all. Measured by unzipping the wheel, because the two are easy to confuse.
33
+ #
34
+ # The files are copies of the ones in the repository root rather than references to them, since a
35
+ # build backend cannot reach outside its own project directory. `test_packaging.py` asserts the
36
+ # copies are byte-identical, which is the whole objection to duplicating them answered.
37
+ license-files = ["LICENSE", "NOTICE"]
38
+ authors = [{ name = "Smart Data Engines" }]
39
+ keywords = ["database", "placement", "polystore", "postgresql", "clickhouse"]
40
+ # No `License ::` classifier: PEP 639 makes it an error next to a licence expression, and PyPI
41
+ # rejects the upload. The licence is `license` above, in one place.
42
+ classifiers = [
43
+ # Alpha, and it stays alpha until somebody outside this repository runs it. The suite is large
44
+ # and two engines are live, neither of which is the same claim as "in production somewhere".
45
+ "Development Status :: 3 - Alpha",
46
+ "Intended Audience :: Developers",
47
+ "Programming Language :: Python :: 3.11",
48
+ "Programming Language :: Python :: 3.12",
49
+ "Programming Language :: Python :: 3.13",
50
+ "Topic :: Database",
51
+ # The wheel carries `py.typed`, so this row is a fact the artefact can be checked against.
52
+ "Typing :: Typed",
53
+ ]
54
+
55
+ # No runtime dependencies on purpose. This library goes into someone else's application, so every
56
+ # dependency is a dependency they inherit and a version conflict they may have to resolve. Signature
57
+ # verification and engine drivers are extras, because not every deployment needs them: an unsigned,
58
+ # hand-written map with no engine driver is a valid way to use this.
59
+ dependencies = []
60
+
61
+ # A page for a library whose argument is "read the code and verify the invariant yourself" has to
62
+ # link to the code. Without this block PyPI renders no sidebar links at all, and the reader has the
63
+ # long README and nowhere to go.
64
+ [project.urls]
65
+ Homepage = "https://github.com/Smart-Data-Engines/smart-data-engine-sdk"
66
+ Repository = "https://github.com/Smart-Data-Engines/smart-data-engine-sdk"
67
+ Issues = "https://github.com/Smart-Data-Engines/smart-data-engine-sdk/issues"
68
+ "Format contract" = "https://github.com/Smart-Data-Engines/smart-data-engine-sdk/blob/main/docs/format-contract.md"
69
+ "Failure semantics" = "https://github.com/Smart-Data-Engines/smart-data-engine-sdk/blob/main/docs/failure-semantics.md"
70
+
71
+ [project.optional-dependencies]
72
+ signed = ["cryptography>=42"]
73
+ postgres = ["psycopg[binary]>=3.1"]
74
+ # The official ClickHouse client, over HTTP. Chosen over the native-protocol driver because HTTP is
75
+ # what a client is most likely to already have open through a proxy or a load balancer, and because
76
+ # the second engine should not also introduce a second network story.
77
+ clickhouse = ["clickhouse-connect>=0.7"]
78
+ dev = ["pytest>=8", "mypy>=1.11", "ruff>=0.6"]
79
+
80
+ [tool.hatch.version]
81
+ path = "src/sde/__init__.py"
82
+
83
+ # The distribution and the import differ, so the package has to be pointed at explicitly. Hatchling
84
+ # otherwise looks for a directory named after the project and fails - which it did, and better here
85
+ # than at publish time.
86
+ [tool.hatch.build.targets.wheel]
87
+ packages = ["src/sde"]
88
+ # `src/sde/py.typed` needs no entry here: hatchling includes it because it lives inside the package
89
+ # directory, which was checked by building the wheel both ways rather than assumed. A `force-include`
90
+ # for it was written first and then removed - dead configuration that looks load-bearing is worse than
91
+ # none, because the next person reads it as a requirement.
92
+ #
93
+ # The marker itself is not optional. Without it a consumer's type checker reports `module is installed,
94
+ # but missing library stubs or py.typed marker` and treats every symbol here as Any, which is worse
95
+ # than shipping no annotations: it is shipping annotations only we benefit from, in a library whose
96
+ # argument is that a client can verify our invariants by reading it. CI builds the wheel and looks
97
+ # inside, because the source tree and the artefact are only the same until somebody changes this file.
98
+
99
+ [tool.pytest.ini_options]
100
+ testpaths = ["tests"]
101
+ addopts = "-q"
102
+
103
+ [tool.ruff]
104
+ line-length = 100
105
+ target-version = "py311"
106
+
107
+ [tool.ruff.lint]
108
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
109
+
110
+ [tool.ruff.lint.per-file-ignores]
111
+ # RUF012 wants ClassVar on mutable class attributes. It is right about ordinary classes and wrong
112
+ # about ours: `class Meta: pii = ["email"]` is the library's public declarative API, and this is
113
+ # exactly how a client writes it. Annotating it would be teaching people a worse habit to satisfy a
114
+ # linter. Off in tests, where the declarations live; the library itself never writes one.
115
+ "tests/*" = ["RUF012"]
116
+
117
+ [tool.mypy]
118
+ python_version = "3.11"
119
+ strict = true
120
+ warn_unreachable = true
121
+ # The type vocabulary maps Python's types onto neutral names by inspecting annotations, which means
122
+ # handling objects mypy cannot narrow. Those places are explicit rather than blanket-ignored.
123
+ disallow_any_explicit = false
124
+
125
+ # The orderbook engine's Python client is not on PyPI and is installed from its own repository, so
126
+ # no environment can be relied on to have it - including CI, which installs from an index. Ignoring
127
+ # the missing import here rather than vendoring a stub: a stub we wrote would be a second, silently
128
+ # stale description of somebody else's API, and the adapter already converts every value crossing
129
+ # that boundary (`int(...)`, `str(...)`) precisely because nothing type-checks it.
130
+ [[tool.mypy.overrides]]
131
+ module = ["orderbook_engine", "orderbook_engine.*"]
132
+ ignore_missing_imports = true