Metadata-Version: 2.4
Name: babylon60
Version: 1.0.2
Summary: CORTEX C5-REAL execution kernel (BABYLON-60): BFT ledgers, onco-transducer, exergy pipelines
Author: Borja Moskv (borjamoskv)
Project-URL: Repository, https://github.com/borjamoskv/BABYLON-60
Project-URL: Issues, https://github.com/borjamoskv/BABYLON-60/issues
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: aiosqlite>=0.19
Requires-Dist: cbor2>=5.6.0
Requires-Dist: pydantic>=2.0
Requires-Dist: cryptography>=42.0
Requires-Dist: argon2-cffi>=23.0
Requires-Dist: pynacl>=1.5.0
Requires-Dist: click>=8.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: mypy>=1.8; extra == "dev"
Requires-Dist: networkx>=3.0; extra == "dev"
Requires-Dist: pandas>=2.0; extra == "dev"
Requires-Dist: fastapi>=0.110.0; extra == "dev"
Requires-Dist: uvicorn>=0.28.0; extra == "dev"
Provides-Extra: embeddings
Requires-Dist: numpy>=1.24; extra == "embeddings"
Provides-Extra: graph
Requires-Dist: networkx>=3.0; extra == "graph"
Provides-Extra: onco
Requires-Dist: numpy>=1.24; extra == "onco"
Requires-Dist: networkx>=3.0; extra == "onco"
Requires-Dist: pandas>=2.0; extra == "onco"
Provides-Extra: telemetry
Requires-Dist: psutil>=7.2.2; extra == "telemetry"
Provides-Extra: voice
Requires-Dist: sounddevice>=0.4.6; extra == "voice"
Requires-Dist: faster-whisper>=1.1; extra == "voice"
Provides-Extra: voice-full
Requires-Dist: sounddevice>=0.4.6; extra == "voice-full"
Requires-Dist: faster-whisper>=1.1; extra == "voice-full"
Requires-Dist: mlx-lm>=0.21; (platform_machine == "arm64" and sys_platform == "darwin") and extra == "voice-full"
Requires-Dist: kokoro>=0.9; extra == "voice-full"
Provides-Extra: apex
Requires-Dist: numpy>=1.24; extra == "apex"
Requires-Dist: scikit-learn>=1.3; extra == "apex"
Requires-Dist: scipy>=1.11; extra == "apex"
Dynamic: license-file

<p align="center">
  <img src="https://img.shields.io/badge/babylon60-BABYLON--60-0A0A0A?style=for-the-badge&labelColor=2B3BE5&color=0A0A0A" alt="babylon60" />
</p>

<p align="center">
  <strong>Tamper-evident cryptographic ledger for autonomous AI agents</strong><br/>
  <sub>Local-first · Hash-chained · Single-writer SQLite WAL · Optional Rust core</sub>
</p>

<p align="center">
  <a href="https://pypi.python.org/pypi/babylon60"><img src="https://img.shields.io/pypi/v/babylon60.svg?style=flat-square&color=2B3BE5" alt="PyPI version" /></a>
  <a href="https://pypi.python.org/pypi/babylon60"><img src="https://img.shields.io/pypi/pyversions/babylon60.svg?style=flat-square" alt="Python versions" /></a>
  <img src="https://img.shields.io/badge/SQLite-WAL-4CAF50?style=flat-square&logo=sqlite" alt="SQLite WAL" />
  <img src="https://img.shields.io/badge/Rust-optional-CE422B?style=flat-square&logo=rust" alt="Rust optional" />
  <img src="https://img.shields.io/badge/license-Proprietary-FF6B35?style=flat-square" alt="License" />
</p>

<p align="center">
  <a href="docs/ARCHITECTURE.md">Architecture</a> ·
  <a href="docs/SECURITY_MODEL.md">Security Model</a> ·
  <a href="docs/EXPERIMENTAL.md">Experimental Features</a>
</p>

---

## What It Solves

Autonomous agents lack a reliable way to persist decisions with causal traceability. `babylon60` provides a **local-first memory substrate**:

```
Validation → Single-Writer Queue → Hash-Chain Ledger → Git Sentinel
```

Every entry is linked to the previous via **SHA3-256** hash. Every write carries a **causal taint** (who / when / why). Duplicates are rejected via **UUID v5** idempotency keys. The chain is **verified on read** — not assumed correct.

> [!IMPORTANT]
> **tamper-evident ≠ tamper-proof.** Hash-chains detect modifications _after the fact_. They do not prevent an attacker with filesystem access from replacing the entire database. See [SECURITY_MODEL.md](docs/SECURITY_MODEL.md) for the full threat model.

---

## Maturity Matrix

| Component | Status | Coverage | Use |
|:---|:---:|:---:|:---|
| BFT Ledger (SQLite WAL + hash-chain) | `Beta` | ~72% | Development |
| Cryptographic chain (BLAKE3 / SHA3-256) | `Beta` | ~68% | Development |
| Python SDK (`babylon60.*`) | `Beta` | ~65% | Development |
| Rust core (`strike_rs` / PyO3) | `Alpha` | ~41% | Experimental |
| MCP integration | `Alpha` | ~30% | Experimental |
| Vector memory (`sqlite-vec`) | `Alpha` | ~35% | Experimental |
| BFT Swarm / quorum | `Prototype` | ~20% | Research only |
| Lean 4 formal proofs | `Prototype` | ~15% | Research only |
| LoRA daemon / HDC | `Design` | 0% | Do not use |

---

## Installation

```bash
pip install babylon60
```

```bash
# With cryptographic signing (Ed25519, Argon2)
pip install "babylon60[crypto]"

# With voice transcription (macOS Apple Silicon)
pip install "babylon60[voice-full]"
```

---

## Quickstart

```python
from babylon60.api.client import CortexClient

client = CortexClient()
print(client.status())
# {"ledger": "ok", "chain_valid": True, "entries": 0, "version": "1.0.2"}
```

Start the local REST + WebSocket API:

```bash
uvicorn babylon60.api.server:app --reload
# → http://localhost:8000
```

Verify chain integrity programmatically:

```python
from babylon60.bft.ledger_actor import verify_chain

result = verify_chain(db_path="master_ledger.db")
# {"valid": True, "entries": 4821, "broken_at": None}
```

---

## Architecture

```mermaid
flowchart TD
    A[Agent / SDK Call] --> B[Validation Layer\nschema · UUID v5 idempotency]
    B --> C[asyncio.Queue\nsingle writer]
    C --> D[BFTLedgerActor]
    D --> E[(SQLite WAL\nmaster_ledger.db)]
    D --> F[SHA3-256 Hash-Chain\nprev_hash linkage]
    F --> G[Git Sentinel\nauto-commit + causal taint]
    E --> H[Read / Verify\nchain integrity check]

    style A fill:#2B3BE5,color:#fff,stroke:none
    style D fill:#1a1a2e,color:#fff,stroke:#2B3BE5
    style E fill:#0A0A0A,color:#4CAF50,stroke:#4CAF50
    style G fill:#0A0A0A,color:#CE422B,stroke:#CE422B
```

<details>
<summary><strong>Ledger Entry Contract (click to expand)</strong></summary>

Every write must satisfy this schema. Violations are rejected at the validation layer — not silently ignored.

```python
{
    "id":           "uuid-v5",       # Idempotency key — rejects duplicates
    "prev_hash":    "sha3_256-hex",  # Chain link — breaks chain on mismatch
    "payload":      {...},           # Structured content
    "causal_taint": "agent:reason",  # Creation trace — mandatory
    "lamport_t":    int,             # Logical clock — total ordering
    "agent_id":     "str",           # Writer identity
}
```

</details>

<details>
<summary><strong>Consensus Topology (M12 Levels)</strong></summary>

| Level | Mechanism | Status |
|:---|:---|:---:|
| L1 — AP/CRDT | Local caches, telemetry | ✅ Stable |
| L2 — CP single-writer | `master_ledger.db` WAL | ✅ Stable |
| L3 — External witness | Git Sentinel (local repo) | ✅ Stable |
| L4 — BFT quorum | N≥3f+1 distributed swarm | 🧪 Prototype |
| L5 — Blockchain anchor | OTS / BTC OP_RETURN | 🔬 Research |

**L1–L3 is the stable core.** L4 and L5 are opt-in research extensions — not required for local agent memory.

</details>

---

## Guarantees

<table>
<tr>
<th>Property</th><th>Mechanism</th><th>What It Proves</th>
</tr>
<tr>
<td><strong>Integrity</strong></td><td>SHA3-256 hash-chain</td><td>Entry not modified after write</td>
</tr>
<tr>
<td><strong>Provenance</strong></td><td>Causal taint + timestamp</td><td>Who wrote it and when</td>
</tr>
<tr>
<td><strong>Ordering</strong></td><td>Lamport clock + WAL</td><td>Serialized, reproducible history</td>
</tr>
<tr>
<td><strong>Idempotency</strong></td><td>UUID v5 key</td><td>No duplicate writes</td>
</tr>
<tr>
<td><strong>Isolation</strong></td><td>Per-tenant DB scope</td><td>Workspace separation</td>
</tr>
</table>

---

## Local Development

```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -x --tb=short
```

Build Rust core (optional — Python fallback available):

```bash
cd strike_rs && cargo build --release
```

---

## Experimental

BFT Swarm, Vector Memory, Lean 4 proofs, LoRA daemon, Blockchain anchoring, and HDC are **explicitly experimental**. See [docs/EXPERIMENTAL.md](docs/EXPERIMENTAL.md) for status and known limitations. Do not use in production.

---

<p align="center">
  <sub>
    Titular Civil: <strong>CORTEX Core Dev</strong> · AKA: <strong>Borja Moskv</strong> (<code>borjamoskv</code>)<br/>
    All Rights Reserved — Proprietary &amp; Trade Secret<br/>
    Art. 6.1, 6.2, 14 LPI (España) · Convenio de Berna · Ley 1/2019 de Secretos Empresariales
  </sub>
</p>
