Metadata-Version: 2.4
Name: kivi-sdk
Version: 1.1.0
Summary: The untrusting client SDK for the kivi event-ledger database
Project-URL: Homepage, https://iwasoft.com
Project-URL: Repository, https://github.com/iwasoftcom/kivi
Author: iwasoft
License: MIT License
        
        Copyright (c) 2026 iwasoft
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: audit,event-sourcing,grpc,kivi,ledger
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Database
Requires-Python: >=3.9
Requires-Dist: grpcio>=1.60
Requires-Dist: protobuf>=4.25
Description-Content-Type: text/markdown

# kivi Python SDK (G3.1)

The untrusting client: K2 ergonomics + K3 client-side verification, sync and
async. Runtime dependency: `grpcio` only (the Ed25519 verifier and canonical
hashing are self-contained, verify-only).

```python
from kivi import KiviClient

c = KiviClient("localhost:4741", token="...")          # verify=True by default
r = c.append("property", {"subject": "dog", "attribute": "sound", "value": "bark"})
a = c.table("dog", "sound")     # TracedAnswer(value, trace, scope) — trace mandatory
old = c.table("dog", "sound", as_of=41)   # time travel: the answer AT record 41
receipts = c.why(a.trace)       # the actual ledger records
for rec in c.replay():          # hash+chain+seal verified CLIENT-SIDE
    ...

sess = c.login("alice", "pw")   # kivi-user identity: role-scoped session token
c2 = c.with_bearer(sess.token)  # same channel, another identity (per-call bearer)
hits = c.similar("noise complaints", k=5)  # traced semantic search (no+score+record)
head_no, head_hash = c.head()   # cheap orientation — no audit runs
```

Async (`grpc.aio`):

```python
from kivi.aio import AsyncKiviClient

async with AsyncKiviClient("localhost:4741", token="...") as c:
    a = await c.table("dog", "sound")
    async for rec in c.replay():
        ...
```

- Honest refusals raise native exceptions (`NotFound`, `PreconditionFailed`,
  `Unauthenticated`, …) — a missing cell is never a fabricated `None`.
- A lying server or wire raises `VerificationError` (see the conformance
  tamper traps S6/S7).
- int64 values round-trip exactly — bodies travel as JSON strings (S2).
- Regenerate stubs after a proto change:
  `.venv/bin/python -m grpc_tools.protoc -I api --python_out=clients/python/kivi --grpc_python_out=clients/python/kivi api/kivi.proto`
  (then fix the relative import in `kivi_pb2_grpc.py`).

Conformance: `clients/conformance/run.sh` → `CONFORMANCE PASS 10/10`.
