aura-connector 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.
- aura_connector-0.1.0/.gitignore +63 -0
- aura_connector-0.1.0/CHANGELOG.md +38 -0
- aura_connector-0.1.0/LICENSE +19 -0
- aura_connector-0.1.0/PKG-INFO +372 -0
- aura_connector-0.1.0/README.md +338 -0
- aura_connector-0.1.0/crates/aura_native/Cargo.lock +149 -0
- aura_connector-0.1.0/crates/aura_native/Cargo.toml +15 -0
- aura_connector-0.1.0/crates/aura_native/pyproject.toml +27 -0
- aura_connector-0.1.0/crates/aura_native/src/lib.rs +103 -0
- aura_connector-0.1.0/docs/ARCHITECTURE.md +134 -0
- aura_connector-0.1.0/docs/AURADB_BOUNDARY.md +48 -0
- aura_connector-0.1.0/docs/CLI.md +94 -0
- aura_connector-0.1.0/docs/CLIENT.md +100 -0
- aura_connector-0.1.0/docs/ERRORS.md +67 -0
- aura_connector-0.1.0/docs/GETTING_STARTED.md +65 -0
- aura_connector-0.1.0/docs/MIGRATIONS.md +114 -0
- aura_connector-0.1.0/docs/MODELS.md +105 -0
- aura_connector-0.1.0/docs/NATIVE_ACCELERATION.md +82 -0
- aura_connector-0.1.0/docs/OBSERVABILITY.md +88 -0
- aura_connector-0.1.0/docs/PROTOCOL.md +77 -0
- aura_connector-0.1.0/docs/QUERY_BUILDER.md +161 -0
- aura_connector-0.1.0/docs/TESTING.md +77 -0
- aura_connector-0.1.0/docs/TRANSPORTS.md +74 -0
- aura_connector-0.1.0/docs/VECTORS.md +73 -0
- aura_connector-0.1.0/examples/basic_crud.py +57 -0
- aura_connector-0.1.0/examples/custom_transport.py +50 -0
- aura_connector-0.1.0/examples/migrations.py +59 -0
- aura_connector-0.1.0/examples/observability.py +51 -0
- aura_connector-0.1.0/examples/relationships.py +56 -0
- aura_connector-0.1.0/examples/schema_generation.py +34 -0
- aura_connector-0.1.0/examples/vector_search.py +61 -0
- aura_connector-0.1.0/pyproject.toml +108 -0
- aura_connector-0.1.0/src/aura/__init__.py +137 -0
- aura_connector-0.1.0/src/aura/_native.py +192 -0
- aura_connector-0.1.0/src/aura/cli.py +446 -0
- aura_connector-0.1.0/src/aura/client.py +787 -0
- aura_connector-0.1.0/src/aura/config.py +277 -0
- aura_connector-0.1.0/src/aura/errors.py +222 -0
- aura_connector-0.1.0/src/aura/fields.py +133 -0
- aura_connector-0.1.0/src/aura/hydration/__init__.py +7 -0
- aura_connector-0.1.0/src/aura/hydration/hydrator.py +107 -0
- aura_connector-0.1.0/src/aura/models.py +474 -0
- aura_connector-0.1.0/src/aura/observability.py +275 -0
- aura_connector-0.1.0/src/aura/protocol/__init__.py +59 -0
- aura_connector-0.1.0/src/aura/protocol/codec.py +154 -0
- aura_connector-0.1.0/src/aura/protocol/frames.py +76 -0
- aura_connector-0.1.0/src/aura/protocol/messages.py +336 -0
- aura_connector-0.1.0/src/aura/protocol/opcodes.py +65 -0
- aura_connector-0.1.0/src/aura/py.typed +0 -0
- aura_connector-0.1.0/src/aura/query/__init__.py +84 -0
- aura_connector-0.1.0/src/aura/query/ast.py +276 -0
- aura_connector-0.1.0/src/aura/query/builder.py +371 -0
- aura_connector-0.1.0/src/aura/query/expressions.py +263 -0
- aura_connector-0.1.0/src/aura/schema/__init__.py +33 -0
- aura_connector-0.1.0/src/aura/schema/compiler.py +41 -0
- aura_connector-0.1.0/src/aura/schema/migrations.py +494 -0
- aura_connector-0.1.0/src/aura/schema/model_schema.py +112 -0
- aura_connector-0.1.0/src/aura/transport/__init__.py +15 -0
- aura_connector-0.1.0/src/aura/transport/base.py +78 -0
- aura_connector-0.1.0/src/aura/transport/memory.py +730 -0
- aura_connector-0.1.0/src/aura/transport/tcp.py +157 -0
- aura_connector-0.1.0/src/aura/vectors.py +136 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
*.so
|
|
7
|
+
*.egg-info/
|
|
8
|
+
.eggs/
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
env/
|
|
12
|
+
.tox/
|
|
13
|
+
.nox/
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.coverage
|
|
18
|
+
coverage.xml
|
|
19
|
+
htmlcov/
|
|
20
|
+
|
|
21
|
+
# Build and packaging
|
|
22
|
+
build/
|
|
23
|
+
dist/
|
|
24
|
+
wheelhouse/
|
|
25
|
+
site/
|
|
26
|
+
*.whl
|
|
27
|
+
*.tar.gz
|
|
28
|
+
|
|
29
|
+
# Rust
|
|
30
|
+
target/
|
|
31
|
+
crates/*/target/
|
|
32
|
+
|
|
33
|
+
# Maturin
|
|
34
|
+
.maturin/
|
|
35
|
+
*.profraw
|
|
36
|
+
|
|
37
|
+
# IDE
|
|
38
|
+
.vscode/
|
|
39
|
+
.idea/
|
|
40
|
+
|
|
41
|
+
# OS
|
|
42
|
+
.DS_Store
|
|
43
|
+
Thumbs.db
|
|
44
|
+
|
|
45
|
+
# Secrets and local config
|
|
46
|
+
.env
|
|
47
|
+
.env.*
|
|
48
|
+
*.pem
|
|
49
|
+
*.key
|
|
50
|
+
*.crt
|
|
51
|
+
*.p12
|
|
52
|
+
*.pfx
|
|
53
|
+
|
|
54
|
+
# Logs
|
|
55
|
+
*.log
|
|
56
|
+
logs/
|
|
57
|
+
|
|
58
|
+
# Local release artifacts
|
|
59
|
+
.local/
|
|
60
|
+
release/
|
|
61
|
+
|
|
62
|
+
# Keep the native crate lockfile tracked for reproducible builds.
|
|
63
|
+
!crates/aura_native/Cargo.lock
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
|
|
6
|
+
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-06-04
|
|
11
|
+
|
|
12
|
+
Initial public release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Async-native client with connection lifecycle, context-manager usage, DSN parsing,
|
|
17
|
+
timeouts, retry policy, pooling abstraction, health check, and ping.
|
|
18
|
+
- Typed model system with primary keys, optional fields, defaults and default factories,
|
|
19
|
+
nested models, list and document fields, relationships, and first-class vector fields.
|
|
20
|
+
- Field system with `primary_key`, `unique`, `index`, defaults, aliases, descriptions,
|
|
21
|
+
metadata, and relationship and vector hints.
|
|
22
|
+
- Fluent, injection-safe query builder that compiles to an immutable AST and Query IR,
|
|
23
|
+
covering find, filter, order, limit, offset, include, select, insert, bulk insert,
|
|
24
|
+
update, delete, upsert, count, exists, vector nearest-neighbour search, and a bounded
|
|
25
|
+
raw-statement escape hatch.
|
|
26
|
+
- Deterministic binary wire protocol with framing, opcodes, flags, checksums, and length
|
|
27
|
+
limits, covered by golden byte tests.
|
|
28
|
+
- Transport abstraction with a TCP transport and an in-memory reference server.
|
|
29
|
+
- Result hydration into typed model instances, including relationships and vectors.
|
|
30
|
+
- Schema generation and local migration diffing with a destructive-change CI gate.
|
|
31
|
+
- In-process observability: per-operation metrics, latency percentiles, secret-free query
|
|
32
|
+
fingerprints, and an optional OpenTelemetry span bridge.
|
|
33
|
+
- Command-line interface for offline, server-independent tasks.
|
|
34
|
+
- Optional in-repository Rust/PyO3 native acceleration with a pure-Python fallback that is
|
|
35
|
+
always available.
|
|
36
|
+
|
|
37
|
+
[Unreleased]: https://github.com/Ohswedd/aura-connector/compare/v0.1.0...HEAD
|
|
38
|
+
[0.1.0]: https://github.com/Ohswedd/aura-connector/releases/tag/v0.1.0
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
|
|
17
|
+
Copyright 2026 Aura Maintainers
|
|
18
|
+
|
|
19
|
+
Full license text: http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aura-connector
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async-native, type-safe Python client and connector for AuraDB.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Ohswedd/aura-connector
|
|
6
|
+
Project-URL: Documentation, https://github.com/Ohswedd/aura-connector/tree/main/docs
|
|
7
|
+
Project-URL: Source, https://github.com/Ohswedd/aura-connector
|
|
8
|
+
Project-URL: Issues, https://github.com/Ohswedd/aura-connector/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/Ohswedd/aura-connector/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Aura Maintainers
|
|
11
|
+
License: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: async,auradb,client,connector,database,orm,vector
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Framework :: AsyncIO
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Database
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
31
|
+
Provides-Extra: native
|
|
32
|
+
Requires-Dist: maturin<2.0,>=1.5; extra == 'native'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
<div align="center">
|
|
36
|
+
|
|
37
|
+
# Aura Connector
|
|
38
|
+
|
|
39
|
+
**Async-native, type-safe Python client and connector for AuraDB.**
|
|
40
|
+
|
|
41
|
+
[](https://github.com/Ohswedd/aura-connector/actions/workflows/ci.yml)
|
|
42
|
+
[](https://github.com/Ohswedd/aura-connector/actions/workflows/native.yml)
|
|
43
|
+
[](https://pypi.org/project/aura-connector/)
|
|
44
|
+
[](https://pypi.org/project/aura-connector/)
|
|
45
|
+
[](LICENSE)
|
|
46
|
+
[](https://mypy-lang.org/)
|
|
47
|
+
[](https://github.com/astral-sh/ruff)
|
|
48
|
+
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
Aura Connector gives Python teams ORM-level productivity with driver-level control.
|
|
52
|
+
Declare typed models once, compose queries with a fluent, injection-safe builder, and
|
|
53
|
+
execute relational, document, vector, hybrid, and graph workloads through a single async
|
|
54
|
+
client over a deterministic binary wire protocol.
|
|
55
|
+
|
|
56
|
+
It is useful today: the package ships an in-memory reference server and a complete
|
|
57
|
+
pure-Python core, so the examples and the full test suite run with no external database
|
|
58
|
+
and no compiler.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import asyncio
|
|
62
|
+
from aura import Aura, Model, Field, Vector
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Workspace(Model):
|
|
66
|
+
id: int = Field(primary_key=True)
|
|
67
|
+
name: str
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class Document(Model):
|
|
71
|
+
id: int = Field(primary_key=True)
|
|
72
|
+
workspace: Workspace = Field(link=True)
|
|
73
|
+
title: str
|
|
74
|
+
body: str
|
|
75
|
+
embedding: Vector[3]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
async def main() -> None:
|
|
79
|
+
async with Aura.connect(
|
|
80
|
+
"aura+memory://localhost/app", models=[Workspace, Document]
|
|
81
|
+
) as client:
|
|
82
|
+
ws = await client.insert(Workspace(id=1, name="Acme"))
|
|
83
|
+
await client.bulk_insert(
|
|
84
|
+
Document,
|
|
85
|
+
[
|
|
86
|
+
Document(id=1, workspace=ws, title="Refunds", body="...", embedding=[1, 0, 0]),
|
|
87
|
+
Document(id=2, workspace=ws, title="Billing", body="...", embedding=[0, 1, 0]),
|
|
88
|
+
],
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# Typed, injection-safe query building.
|
|
92
|
+
docs = await (
|
|
93
|
+
client.query(Document)
|
|
94
|
+
.where(Document.title.contains("Refund"))
|
|
95
|
+
.order_by(Document.id.desc())
|
|
96
|
+
.limit(10)
|
|
97
|
+
.all()
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Vector nearest-neighbour search.
|
|
101
|
+
matches = await (
|
|
102
|
+
client.search(Document)
|
|
103
|
+
.nearest(Document.embedding, [1, 0, 0], metric="cosine")
|
|
104
|
+
.limit(5)
|
|
105
|
+
.all()
|
|
106
|
+
)
|
|
107
|
+
print(docs, matches)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
asyncio.run(main())
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Why Aura Connector matters
|
|
114
|
+
|
|
115
|
+
Python data access usually forces a trade. ORMs give you typed models and ergonomics but
|
|
116
|
+
hide the wire and leak lazy queries. Raw drivers give you control but hand back untyped
|
|
117
|
+
tuples and string SQL. Vector search lives in yet another SDK with its own client. Aura
|
|
118
|
+
Connector unifies these behind one typed, async client:
|
|
119
|
+
|
|
120
|
+
- **One typed client** for relational, document, vector, hybrid, and graph access.
|
|
121
|
+
- **Async-first.** `asyncio` is the primary execution model, not a wrapper.
|
|
122
|
+
- **Explicit relationship loading.** No hidden lazy network IO. `.include()` is required,
|
|
123
|
+
and accessing an unloaded relationship raises a clear error.
|
|
124
|
+
- **Injection-safe by construction.** Queries compile to an immutable AST and Query IR,
|
|
125
|
+
never to concatenated strings.
|
|
126
|
+
- **Deterministic binary protocol.** Frames are golden-tested, length-bounded, and
|
|
127
|
+
checksummed.
|
|
128
|
+
- **Honest performance.** A complete pure-Python core with reproducible benchmarks, plus
|
|
129
|
+
optional in-repository native acceleration with a fallback that is always available.
|
|
130
|
+
|
|
131
|
+
## Problems it solves
|
|
132
|
+
|
|
133
|
+
- Replaces three separate libraries (ORM, driver, vector SDK) with one typed surface.
|
|
134
|
+
- Removes the N+1 surprise by making relationship loading explicit.
|
|
135
|
+
- Keeps queries safe without forcing you to hand-write parameter binding.
|
|
136
|
+
- Makes schema changes reviewable: diff two model versions into a migration plan and gate
|
|
137
|
+
destructive changes in CI before anything runs.
|
|
138
|
+
- Gives you metrics, latency percentiles, and secret-free query fingerprints in-process,
|
|
139
|
+
with an optional OpenTelemetry bridge.
|
|
140
|
+
|
|
141
|
+
## How it compares
|
|
142
|
+
|
|
143
|
+
| Tool | Typed models | Async-native | Injection-safe builder | Vector fields | Wire protocol control |
|
|
144
|
+
|---|---|---|---|---|---|
|
|
145
|
+
| SQLAlchemy | yes | partial | yes | via extensions | abstracted |
|
|
146
|
+
| Django ORM | yes | partial | yes | via extensions | abstracted |
|
|
147
|
+
| psycopg / asyncpg | no | yes (asyncpg) | manual binding | no | low level |
|
|
148
|
+
| Prisma-style clients | yes | yes | yes | partial | abstracted |
|
|
149
|
+
| Vector database SDKs | partial | varies | no | yes | per vendor |
|
|
150
|
+
| **Aura Connector** | yes | yes | yes | first-class | deterministic, documented |
|
|
151
|
+
|
|
152
|
+
The comparison describes design focus, not a benchmark. Each tool above is excellent at
|
|
153
|
+
its own goals.
|
|
154
|
+
|
|
155
|
+
## What Aura Connector is and is not
|
|
156
|
+
|
|
157
|
+
It **is** a production-grade client and connector: model system, query builder, binary
|
|
158
|
+
protocol, transports, hydration, migrations tooling, observability, and a CLI, with a
|
|
159
|
+
pure-Python core and optional native acceleration.
|
|
160
|
+
|
|
161
|
+
It is **not** a database server. AuraDB server features (storage, distributed
|
|
162
|
+
transactions, server-side cost-based planning, lock and impact estimation on a live
|
|
163
|
+
cluster) live in a separate project and are not implemented or claimed here. See
|
|
164
|
+
[AuraDB boundary](docs/AURADB_BOUNDARY.md).
|
|
165
|
+
|
|
166
|
+
## Installation
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pip install aura-connector # pure-Python, always works, no compiler
|
|
170
|
+
pip install "aura-connector[native]" # + optional native acceleration tooling
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The import package name is `aura`:
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
import aura
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Development install from a clone:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
python -m pip install -e ".[dev]"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Requires Python 3.11 or newer. The pure-Python path needs no compiler. Optional native
|
|
186
|
+
acceleration (CRC32 plus f32 vector packing) lives in this repository under
|
|
187
|
+
`crates/aura_native` and is built with maturin (requires a Rust toolchain):
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
maturin develop --manifest-path crates/aura_native/Cargo.toml --release
|
|
191
|
+
aura doctor # native_acceleration: available
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
See [Native acceleration](docs/NATIVE_ACCELERATION.md).
|
|
195
|
+
|
|
196
|
+
## Quick start
|
|
197
|
+
|
|
198
|
+
Aura uses `aura://` DSNs:
|
|
199
|
+
|
|
200
|
+
| Scheme | Meaning |
|
|
201
|
+
|---|---|
|
|
202
|
+
| `aura://host:port/db` | Plaintext TCP |
|
|
203
|
+
| `auras://host:port/db` | TLS TCP |
|
|
204
|
+
| `aura+tcp://...` | Explicit TCP |
|
|
205
|
+
| `aura+memory://...` | In-memory reference server (tests, examples, local dev) |
|
|
206
|
+
|
|
207
|
+
The in-memory reference server is a real implementation of the protocol and a query
|
|
208
|
+
engine, so no live AuraDB cluster is required to run the examples or the test suite.
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
async with Aura.connect("aura+memory://localhost/app", models=[User]) as client:
|
|
212
|
+
await client.ping()
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Model example
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
from aura import Model, Field, Vector
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class User(Model):
|
|
222
|
+
id: int = Field(primary_key=True)
|
|
223
|
+
email: str = Field(unique=True, index=True)
|
|
224
|
+
display_name: str | None = Field(default=None)
|
|
225
|
+
embedding: Vector[512] | None = None
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Query example
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
cheap = await (
|
|
232
|
+
client.query(Product)
|
|
233
|
+
.where(Product.price_cents < 5000)
|
|
234
|
+
.order_by(Product.price_cents.asc())
|
|
235
|
+
.all()
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
await client.update(Product).where(Product.id == 2).set(price_cents=2499).execute()
|
|
239
|
+
|
|
240
|
+
total = await client.query(Product).count()
|
|
241
|
+
exists = await client.query(Product).where(Product.id == 3).exists()
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Vector example
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
matches = await (
|
|
248
|
+
client.search(Document)
|
|
249
|
+
.nearest(Document.embedding, query_vector, metric="cosine")
|
|
250
|
+
.limit(10)
|
|
251
|
+
.all()
|
|
252
|
+
)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Supported metrics are `cosine`, `euclidean`, and `dot`. See [Vectors](docs/VECTORS.md).
|
|
256
|
+
|
|
257
|
+
## Migration example
|
|
258
|
+
|
|
259
|
+
```python
|
|
260
|
+
from aura import diff_schemas, generate_migration, schema_document
|
|
261
|
+
|
|
262
|
+
plan = generate_migration(old_models, new_models)
|
|
263
|
+
print(plan.format())
|
|
264
|
+
plan.require_safe() # raises AuraMigrationError if the plan is destructive
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
The same gate is available in CI through `aura migrate diff --require-safe`. See
|
|
268
|
+
[Migrations](docs/MIGRATIONS.md).
|
|
269
|
+
|
|
270
|
+
## Observability example
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
async with Client.connect(
|
|
274
|
+
"aura+memory://localhost/shop",
|
|
275
|
+
models=[Product],
|
|
276
|
+
telemetry={"opentelemetry": True, "capture_query_ir": "redacted"},
|
|
277
|
+
) as client:
|
|
278
|
+
await client.query(Product).filter(Product.price_cents > 500).all()
|
|
279
|
+
snapshot = client.metrics.snapshot() # counts, latency p50/p95/p99, bytes, retries
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Query fingerprints are stable across bound values and never contain the values
|
|
283
|
+
themselves. See [Observability](docs/OBSERVABILITY.md).
|
|
284
|
+
|
|
285
|
+
## CLI example
|
|
286
|
+
|
|
287
|
+
The package installs an `aura` console script for offline, server-independent tasks:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
aura version
|
|
291
|
+
aura doctor # environment, deps, native status
|
|
292
|
+
aura schema compile --app myapp.models --out schema.json
|
|
293
|
+
aura migrate diff --from old.json --to myapp.models --require-safe
|
|
294
|
+
aura explain file query-ir.json # client-side static plan
|
|
295
|
+
aura bench local --iterations 20000 # in-process micro-benchmarks
|
|
296
|
+
aura generate stubs --models myapp/models.py # faithful .pyi from models
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
See [CLI](docs/CLI.md).
|
|
300
|
+
|
|
301
|
+
## Native acceleration
|
|
302
|
+
|
|
303
|
+
The pure-Python core is the complete, benchmarked baseline and is always available. An
|
|
304
|
+
optional in-repository Rust/PyO3 extension accelerates two byte-exact hot paths (frame
|
|
305
|
+
CRC32 and fixed-dimension f32 vector packing) when built and installed. The public API and
|
|
306
|
+
all observable behaviour are identical with or without it, parity is enforced by tests,
|
|
307
|
+
and `AURA_DISABLE_NATIVE=1` forces the pure-Python path.
|
|
308
|
+
|
|
309
|
+
No zero-copy behaviour is claimed, and the native path is not always faster: in the
|
|
310
|
+
included benchmark, CRC32 through the native path can be slower than Python's optimized
|
|
311
|
+
zlib routine on some inputs, while vector packing is faster. Measure on your own hardware.
|
|
312
|
+
See [Native acceleration](docs/NATIVE_ACCELERATION.md).
|
|
313
|
+
|
|
314
|
+
## AuraDB boundary
|
|
315
|
+
|
|
316
|
+
This package is the client and connector. AuraDB server features are a separate future
|
|
317
|
+
project. Operations that require a live cluster (applying migrations, server-side cost
|
|
318
|
+
estimation, distributed transaction coordination) fail with a structured error rather than
|
|
319
|
+
pretending to succeed. See [AuraDB boundary](docs/AURADB_BOUNDARY.md).
|
|
320
|
+
|
|
321
|
+
## Documentation
|
|
322
|
+
|
|
323
|
+
- [Getting Started](docs/GETTING_STARTED.md)
|
|
324
|
+
- [Architecture](docs/ARCHITECTURE.md)
|
|
325
|
+
- [Models](docs/MODELS.md) and [Vectors](docs/VECTORS.md)
|
|
326
|
+
- [Query Builder](docs/QUERY_BUILDER.md)
|
|
327
|
+
- [Client](docs/CLIENT.md)
|
|
328
|
+
- [Protocol](docs/PROTOCOL.md) and [Transports](docs/TRANSPORTS.md)
|
|
329
|
+
- [Observability](docs/OBSERVABILITY.md) and [Migrations](docs/MIGRATIONS.md)
|
|
330
|
+
- [Errors](docs/ERRORS.md) and [Testing](docs/TESTING.md)
|
|
331
|
+
- [Native Acceleration](docs/NATIVE_ACCELERATION.md) and [AuraDB Boundary](docs/AURADB_BOUNDARY.md)
|
|
332
|
+
|
|
333
|
+
## Benchmarks
|
|
334
|
+
|
|
335
|
+
The `benchmarks/` directory contains real, in-process micro-benchmarks for protocol
|
|
336
|
+
encode/decode, model hydration, Query IR construction, vector serialization, an
|
|
337
|
+
end-to-end round trip through the reference transport, and pure-Python versus native
|
|
338
|
+
acceleration. They print measured timings on your machine:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
python benchmarks/bench_protocol.py
|
|
342
|
+
python benchmarks/bench_native_acceleration.py
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Numbers vary by hardware. The benchmarks contain no precomputed or fabricated results.
|
|
346
|
+
|
|
347
|
+
## Testing
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
python -m pytest -vv
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The suite is deterministic and requires no external services. It covers models, fields,
|
|
354
|
+
vectors, schema generation, the query builder, protocol frames and golden bytes,
|
|
355
|
+
transports, client lifecycle, hydration, errors, migrations, observability, typing, and
|
|
356
|
+
example smoke tests. See [Testing](docs/TESTING.md).
|
|
357
|
+
|
|
358
|
+
## Security
|
|
359
|
+
|
|
360
|
+
The client validates and length-bounds every protocol frame, fails closed on protocol
|
|
361
|
+
errors, never embeds secrets in errors or logs, and redacts credentials in configuration
|
|
362
|
+
`repr`. To report a vulnerability, see [SECURITY.md](SECURITY.md).
|
|
363
|
+
|
|
364
|
+
## Contributing
|
|
365
|
+
|
|
366
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, the dev and
|
|
367
|
+
native build, test commands, and code style. Please also read our
|
|
368
|
+
[Code of Conduct](CODE_OF_CONDUCT.md).
|
|
369
|
+
|
|
370
|
+
## License
|
|
371
|
+
|
|
372
|
+
Apache-2.0. See [LICENSE](LICENSE).
|