Metadata-Version: 2.4
Name: aiws-sdk
Version: 0.3.0
Summary: Native Python SDK for governed AI workflows, durable execution and observability
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: jsonschema<5,>=4.23

# AIWS Python SDK 0.3.0

Native Python 3.11+ implementation of the AIWS 0.4 `finite-v1` profile. No TypeScript, Rust or subprocess runtime is required. Includes schema validation, deterministic command reduction, triggers and graph checkpoints, SQLite persistence, trusted coordination, audit replay, correlated observability, metrics, alerts and a durable OTLP/HTTP JSON outbox.

Install the provided wheel with `python -m pip install ./aiws_sdk-0.3.0-py3-none-any.whl`, or install this directory with `python -m pip install .`. Dependencies: jsonschema. Packages have not been published to PyPI.

```python
from aiws.core import parse_contract
from aiws.sqlite import SqliteStore
from aiws.runtime import Coordinator
from aiws.observability import operational_summary, OtlpHttpExporter
from pathlib import Path
import time

contract = parse_contract(Path("contract.json").read_text())
with SqliteStore("mission.db", contract) as store:
    summary = operational_summary(store.snapshot(), str(time.time_ns() // 1_000_000))
    print(summary)
```

The coordinator requires an application-supplied authorizer returning `allowed`, `policy`, `mandatoryChecksOk`, and `context` containing authenticated `actor`, immutable `policyRevision`, and `decisionClass`. It replaces caller-supplied attribution. The low-level reducer and store are trusted primitives, not authentication boundaries.

`EffectAdapter.execute(operation, attempt)` performs an action; `reconcile(operation, attempt)` reads external truth without repeating it. Return `effect` and decimal-string `actualCost`. Coordinator `dispatch`, `recover` and `reconcile` preserve unknown effects until explicitly resolved. APIs are synchronous; use a worker thread in async applications. Adapter timeouts and external idempotency are application responsibilities.

`SqliteStore.flush_telemetry(exporter, now_ms, limit=100)` sends bounded batches from the persistent outbox. `enqueue_metrics(now_ms)` records a metric snapshot. Export requires an explicit collector endpoint; no background thread or network call starts automatically. `export_state()` surfaces pending and failed deliveries; `purge_sent_telemetry()` removes only acknowledged rows. Failed rows remain for operator inspection. See `OBSERVABILITY.md` in the source distribution for delivery, retention and redaction limits.

CLI: `aiws-python validate contract.json`, `graph graph.json`, `snapshot mission.db`, or `replay audit.json`. `observe mission.db` is an interoperability test projection evaluated at fixed timestamp 4000000 ms, not a live monitoring command.

Tests: from repository root, `PYTHONPATH=packages/python/src python -m unittest discover -s packages/python/tests -v`. All quantities are canonical decimal strings; JSON numeric values must be safe integers. See the common `PROFILE.md` for constraints and migration notes. This is an implementation profile, not certification against the complete standard.
