Metadata-Version: 2.4
Name: godaix
Version: 2.0.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Dist: anthropic>=0.30 ; extra == 'anthropic'
Requires-Dist: celery>=5.3 ; extra == 'celery'
Requires-Dist: pytest>=7.0 ; extra == 'dev'
Requires-Dist: fastapi>=0.110 ; extra == 'fastapi'
Requires-Dist: requests>=2.31 ; extra == 'http'
Requires-Dist: httpx>=0.27 ; extra == 'httpx'
Requires-Dist: openai>=1.0 ; extra == 'openai'
Requires-Dist: prometheus-client>=0.20 ; extra == 'prometheus'
Provides-Extra: anthropic
Provides-Extra: celery
Provides-Extra: dev
Provides-Extra: fastapi
Provides-Extra: http
Provides-Extra: httpx
Provides-Extra: openai
Provides-Extra: prometheus
License-File: LICENSE
Summary: Zero-infrastructure resilience runtime for Python
Keywords: ai,resilience,shared-memory,developer-tools
Author: Ayush Giri
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/Let-s-Code-India/God
Project-URL: Repository, https://github.com/Let-s-Code-India/God

# godaix

**godaix 2.0** is a zero-infrastructure resilience runtime for Python. Its five small libraries provide call-level resilience, host-local shared state, integrations, operational events, and source-safety checks. It has no required runtime dependencies; the native Rust/C++ core is included in wheels, with Python implementations available as a fallback.

- **Owner:** Ayush Giri
- **Repository:** [Let-s-Code-India/God](https://github.com/Let-s-Code-India/God)
- **License:** MIT

## Install

```bash
python -m pip install godaix
```

Optional integration groups are available as extras: `http`, `httpx`, `openai`, `anthropic`, `fastapi`, `celery`, and `prometheus`.

## Quick start

```python
from godaix.nexus import Counter, TokenBucket
from godaix.aix import redact, threadcheck

counter = Counter()
print(counter.increment())  # 1, visible to other processes sharing this object
counter.cleanup()            # call after all worker processes have exited

print(redact("email=dev@example.com api_key=sk-example-secret"))
# email=[REDACTED_EMAIL] api_key=[REDACTED]

hazards = threadcheck("""
cache = {}
def get(key):
    if key not in cache:
        cache[key] = load(key)
""")
print(hazards)

bucket = TokenBucket(capacity=10, refill_rate=2.0)
print(bucket.consume())
```

`Counter`, `TokenBucket`, and `Breaker` use the native shared-memory segment when the extension is available. They use process-safe Python primitives when it is not. Pass the object to spawned workers using `multiprocessing`; native objects share their named segment across processes. Call each native object's `cleanup()` after all workers finish to unlink its segment.

## The five libraries

### aura — call resilience

`resilient`, `retry`, `circuit_breaker`, `rate_limit`, `bulkhead`, `timeout`, `deadline`, `fallback`, `dedupe`, `llm_retry`

### nexus — state primitives

`SharedState`, `Breaker`, `TokenBucket`, `SlidingWindow`, `Semaphore`, `Counter`, `Registry`, `snapshot`, `cleanup_dead`, `selftest`

### aether — integrations

`install`, `uninstall`, `patched`, `patch_requests`, `patch_httpx`, `patch_openai`, `patch_anthropic`, `fastapi_middleware`, `celery_plugin`, `from_env`

### apex — events and operations

`events.subscribe`, `history`, `explain`, `status_json`, `prometheus_exporter`, `logging_handler`, `top`, `tail`, `report_html`, `healthcheck_endpoint`

### aix — safety and testing

`redact`, `secret_scan`, `security_scan`, `chaos`, `fault_injection`, `fake_clock`, `godaix_state`, `load_test`, `doctor`, `threadcheck`

## Native core

The extension is built with maturin from the repository root:

```bash
python -m pip install maturin
maturin build --release --compatibility pypi
```

The Python package lives in `src/godaix`, the PyO3 crate in `native/rust`, and the C++17 POSIX shared-memory implementation in `native/cpp`. The segment has an explicit versioned layout, lock-free atomic counter, shared token-bucket and breaker state, process-ID lock leases, and recovery when a lease owner exits unexpectedly. Rust provides the PyO3 API, event ring buffer, credential redaction, and tree-sitter Python hazard scanner.

## Validation and benchmark

```bash
python scripts/check_features.py
python -m pytest
python benchmarks/bench_shared_state.py
```

The feature checker runs the native-core behavior tests and reports `native` only when the extension imports successfully; otherwise it reports `fallback`. The benchmark compares the same spawn-process increment workload using a file protected by `fcntl.flock`, the Python `multiprocessing.Value` fallback, and the native shared-memory counter. Each run validates the final count before reporting timing.

## Documentation

Open [`index.html`](./index.html) for library reference cards, runnable usage examples, and before/after behavior demos. Standalone sample applications are in [`projects/`](./projects/).

## License

MIT. See [LICENSE](./LICENSE).

