Skip to main content

Async Python bindings for the Rust-based Lattix SDK core

Project description

Lattix Python SDK

Async Python bindings for the Rust-based Lattix SDK core.

The public Lattix docs at https://lattix.io/docs intentionally stay focused on platform concepts and tenant/operator guidance. Per-language SDK reference material is distributed with each SDK package, so this README is part of the supported Python reference surface.

Overview

This package targets the lattix-platform-api SDK control-plane contract and exposes async methods for the metadata-only zero-trust flows:

  • capabilities()
  • whoami()
  • bootstrap()
  • protection_plan(...)
  • policy_resolve(...)
  • key_access_plan(...)
  • artifact_register(...)
  • evidence(...)
  • prepare_local_protection(...)
  • generate_cid_binding(...)

Python stays thin: the Rust core owns HTTP, auth header shaping, platform contract behavior, and the local helper workflow sequencing.

capabilities() and bootstrap() surface the live auth_configuration metadata published by lattix-platform-api, including the direct bearer/OIDC mode, proof-of-possession mode, issuer/audience, and readiness flags.

generate_cid_binding(...) is the smallest local helper. It computes the SHA-256 digest/raw CID in-process, drives the metadata-only planning calls, and returns a portable LocalArtifactBinding that captures tenant/workload/resource linkage plus the resolved binding targets and binding hash.

What ships in this repo

  • lattixsdk.client.LattixClient — async wrapper over the native Rust binding
  • lattixsdk.binding.RustBinding — low-level ctypes bridge to the Rust SDK core
  • lattixsdk.models — Pydantic models mirroring the /v1/sdk/* control-plane contract
  • examples/example.ipynb — notebook example using the current bootstrap flow

Installation

Official wheel install

Supported wheels bundle the matching native sdk-rust shared library for the target platform, so a normal wheel install is enough:

pip install lattix-sdk-python

The import package remains lattixsdk.

Source and editable installs

Source installs remain supported for local development and constrained environments, but they require a separately built matching sdk-rust native library.

Build sdk-rust first:

cd ../sdk-rust
cargo build --release

Then either:

  • set LATTIX_SDK_RUST_LIB to the compiled library path; or
  • stage the native library into this package before building a wheel with python tools/stage_native_library.py.

The canonical C ABI lives in sdk-rust/include/lattix_sdk.h; this package intentionally does not maintain a second handwritten header.

Quickstart

import asyncio
from lattixsdk import LattixClient
from lattixsdk.models import (
    ArtifactProfile,
    LocalProtectionRequest,
    ResourceDescriptor,
    WorkloadDescriptor,
)


async def main() -> None:
    async with LattixClient(
        base_url="https://api.lattix.io",
        bearer_token="replace-me",
        tenant_id="tenant-a",
        user_id="user-a",
    ) as client:
        bootstrap = await client.bootstrap()
        print(bootstrap.enforcement_model)

        binding = await client.generate_cid_binding(
            b"hello world",
            LocalProtectionRequest(
                workload=WorkloadDescriptor(application="example-app"),
                resource=ResourceDescriptor(kind="document"),
                preferred_artifact_profile=ArtifactProfile.ENVELOPE,
                purpose="store",
                labels=["confidential"],
                attributes={"region": "us"},
            ),
        )

        print(binding.raw_cid)
        print(binding.binding_hash)


asyncio.run(main())

Use generate_cid_binding(...) when you need deterministic CID lineage and policy/tenant binding metadata without yet creating an encrypted artifact.

Managed symmetric-key providers are configured through managed_symmetric_key_providers= and now have first-class typed support for both in-memory fixtures and command-backed helpers.

from lattixsdk import LattixClient
from lattixsdk.models import CommandManagedKeyProviderConfig

client = LattixClient(
    base_url="https://api.lattix.io",
    managed_symmetric_key_providers=[
        CommandManagedKeyProviderConfig.from_command(
            name="command-kms",
            command="provider.py",
            args=["--stdio"],
            env={"LATTIX_PROFILE": "dev"},
        )
    ],
)

Use the command-backed variant when key lookup or unwrap authorization must stay inside an external helper process instead of embedding that provider logic directly in Python.

Design notes

  • The SDK is aligned to the embedded-enforcement model: applications protect data locally and only send metadata to the platform.
  • The async API is implemented by running the native Rust calls in an executor, so callers can integrate it cleanly into async Python services.
  • Pydantic models live under lattixsdk.models and mirror the platform-api SDK contract.
  • The authoritative machine-readable /v1/sdk/* contract lives in lattix-platform-api/openapi/sdk-control-plane.yaml; this package mirrors that surface and does not ship a separate divergent OpenAPI source of truth.

Testing

Unit tests use a fake binding, so they run without the native library:

pip install -e .[test]
pytest

Native smoke tests are included as well. They auto-skip if the Rust library has not been built yet, and they run a real Rust-backed client against a local in-process HTTP server when the native artifact is present, including CID-binding coverage for the local helper layer.

Local quality gate

Run the local quality gate before committing when you want automated fixes, security scans, tests, package builds, wheel-install smoke coverage, and cleanup in one step:

./precommit.sh

On Windows:

./precommit.ps1

The gate applies automated fixes first, then runs linting, SAST, secret scanning, tests, package builds, and an installed-wheel smoke test in a temporary virtual environment.

To wire the same checks into local Git commits and pushes:

./install-hooks.sh

or:

./install-hooks.ps1

The installed pre-commit hook runs a faster version of the gate; the installed pre-push hook runs the full gate.

Release process

Maintainer release notes live in RELEASING.md. The publish workflow supports a TestPyPI rehearsal path through trusted publishing before the first real PyPI publish.

License

Distributed under the proprietary Lattix SDK License in LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lattix_sdk_python-0.1.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lattix_sdk_python-0.1.1-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3Windows x86-64

lattix_sdk_python-0.1.1-py3-none-manylinux_2_39_x86_64.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

lattix_sdk_python-0.1.1-py3-none-macosx_11_0_universal2.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file lattix_sdk_python-0.1.1.tar.gz.

File metadata

  • Download URL: lattix_sdk_python-0.1.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lattix_sdk_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e1abf8cca32d742dc5f44389d12cb718d004a822d6796406638abc353f2d186a
MD5 7e0d8db6136cad6a609df8a742bd3343
BLAKE2b-256 f661ebea835f3b15c054123c9c48eacbbfd54766a59c20cbc0fae601f2142162

See more details on using hashes here.

Provenance

The following attestation bundles were made for lattix_sdk_python-0.1.1.tar.gz:

Publisher: pypi.yml on LATTIX-IO/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lattix_sdk_python-0.1.1-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for lattix_sdk_python-0.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ff057caf9a8ffcd71b4351d79993f169a8250cd7b2b889cf4eb2f4288639d258
MD5 d327c12039c8beec38471af4064b7102
BLAKE2b-256 33fd8e741d1843ec716c7c3e4254a6b9622c18241ee8d083c1d18f50f0964450

See more details on using hashes here.

Provenance

The following attestation bundles were made for lattix_sdk_python-0.1.1-py3-none-win_amd64.whl:

Publisher: pypi.yml on LATTIX-IO/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lattix_sdk_python-0.1.1-py3-none-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for lattix_sdk_python-0.1.1-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 858af8618901bc0ece20a73c2da661e7df5b9b85915bfab9f0c3848dd6e78dcb
MD5 e35aba207323c7757cdcaf9bb28da18f
BLAKE2b-256 82e4f9693dcc632188598b69b5ca94a26e32ea261b34706810ff1cd645510e49

See more details on using hashes here.

Provenance

The following attestation bundles were made for lattix_sdk_python-0.1.1-py3-none-manylinux_2_39_x86_64.whl:

Publisher: pypi.yml on LATTIX-IO/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lattix_sdk_python-0.1.1-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for lattix_sdk_python-0.1.1-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 8db39779c0a07403d3d7e4341bbfafcb29c7f217ef5533f479e96ce4ed724993
MD5 4646a17ab97ec65e3c8d2f5c021e8dfb
BLAKE2b-256 f9c4a7aa8b499c032d5de8cbf09fb190217f12412d25823d2ca6b14b47bbeee9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lattix_sdk_python-0.1.1-py3-none-macosx_11_0_universal2.whl:

Publisher: pypi.yml on LATTIX-IO/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page