Feature guards, observability, and security response in a single import. Evaluated locally with zero network overhead per check
Project description
Liteguard Python SDK
- Website: liteguard.io
- Project Page: https://github.com/liteguard/liteguard
- Issues: https://github.com/liteguard/liteguard/issues/new
Installation
pip install liteguard
Requires Python 3.9+.
Quick Start
from liteguard import ClientOptions, LiteguardClient
client = LiteguardClient(
"pct-...",
ClientOptions(environment="env-production"),
)
client.start()
scope = client.create_scope({"user_id": "user-123", "plan": "pro"})
if scope.is_open("payments.checkout"):
...
client.shutdown()
Primary API
LiteguardClient(project_client_token, options)creates a client.client.start()fetches the initial bundle and starts refresh and flush workers.client.create_scope(properties=None)creates an immutable request scope.scope.is_open(name, options=None)evaluates a guard locally.scope.evaluate(name, options=None)returns aGuardDecisionwith the full evaluation result.scope.execute_if_open(name, fn, options=None)measures guarded execution.scope.start_execution()creates an execution correlation handle.scope.bind_protected_context(protected_context)returns a derived protected scope.scope.get_properties()returns the current property bag for transport.client.flush_signals()flushes buffered telemetry.client.shutdown()flushes and stops background workers.
Convenience helpers
For server applications that want request-scoped context propagation:
client.run_with_scope(scope, fn)runsfnwithscopeas the active scope, propagated across async boundaries viacontextvars.client.get_active_scope()returns the scope bound to the current request.client.with_properties(properties, fn)derives and activates a scope with additional properties.client.with_protected_context(protected_context, fn)derives and activates a protected scope.
Notes
- Guard evaluation is fully local after the initial fetch.
- Protected contexts use
properties,signature, and optionalissued_at/expires_atfields. - Scopes are immutable and request-scoped.
contextvarskeep overlapping async request scopes isolated.- Unadopted guards default open and emit no signals.
- The convenience helpers above also serve as infrastructure for auto-instrumentation of third-party dependencies. See the Liteguard CLI for build-time instrumentation.
Development
make test-python
License
Apache 2.0 see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
liteguard-0.7.20260603.tar.gz
(24.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file liteguard-0.7.20260603.tar.gz.
File metadata
- Download URL: liteguard-0.7.20260603.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccbf47c4fa7f1a07e8c94b36f47f62f5d3e7c5ab51c2bbfbb464c6c9e9066a99
|
|
| MD5 |
13a374ab16aa7111df97f64e4bc3d2ab
|
|
| BLAKE2b-256 |
5431adfce903d38ef432d1a2f2cc55705af1991f6bde5d07eece83931a8d0090
|
File details
Details for the file liteguard-0.7.20260603-py3-none-any.whl.
File metadata
- Download URL: liteguard-0.7.20260603-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c5e03f15a31445c8aa9aa847522eb0a34dced725431ac5a75de95e7eaa7b994
|
|
| MD5 |
5cd5a13a57a7ea21d74469ce8deab781
|
|
| BLAKE2b-256 |
14f56050e85665c3833862008945c4316ecf9e34bab5a677f1cdab82f062a331
|