Metadata-Version: 2.4
Name: exactor-accelerator
Version: 2.0.6
Summary: High-speed boolean logic accelerator for TypeSafe AI (Jev) decisions - powered by the EXACTOR engine
Author-email: Exactor Research <contact@exactor.tech>
License: MIT
Project-URL: Homepage, https://exactor.tech
Project-URL: Documentation, https://exactor.tech/docs
Project-URL: Repository, https://github.com/ExactorResearch/exactor-accelerator
Project-URL: Issues, https://github.com/ExactorResearch/exactor-accelerator/issues
Project-URL: Changelog, https://github.com/ExactorResearch/exactor-accelerator/blob/main/CHANGELOG.md
Keywords: boolean-minimization,explainable-ai,typesafe,jev,exactor,decision-engine
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=1.3.0
Requires-Dist: numpy>=1.21.0
Requires-Dist: scikit-learn>=1.0.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: requests>=2.25.0
Requires-Dist: pydantic>=1.10.0
Provides-Extra: server
Requires-Dist: fastapi>=0.95.0; extra == "server"
Requires-Dist: uvicorn>=0.20.0; extra == "server"
Requires-Dist: python-multipart>=0.0.6; extra == "server"
Provides-Extra: dotenv
Requires-Dist: python-dotenv>=1.0.0; extra == "dotenv"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Provides-Extra: all
Requires-Dist: exactor-accelerator[dev,dotenv,server]; extra == "all"
Dynamic: license-file

# Exactor Accelerator

[![PyPI Version](https://img.shields.io/pypi/v/exactor-accelerator.svg)](https://pypi.org/project/exactor-accelerator/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Python Version](https://img.shields.io/pypi/pyversions/exactor-accelerator.svg)](https://pypi.org/project/exactor-accelerator/)

Exactor Accelerator is a high-speed boolean logic layer that accelerates TypeSafe AI (Jev) decisions by combining EXACTOR's boolean minimization with Jev's semantic intelligence.

**Accelerates Jev decisions by 4,770-24,000x with 95-100% accuracy, zero production cost, and regulatory explainability.**

## Features

- ⚡ **Extreme Speed**: 0.05-0.1ms latency (4,770-24,000x faster than Jev pure)
- 💰 **Zero Cost**: $0.00 per decision (100% savings vs AI APIs)
- 🎯 **Accuracy**: 95-100% on structured tasks
- 🔍 **Explainability**: Auditable boolean formulas (GDPR, HIPAA, SOX compliant)
- 🔄 **Adaptability**: Automatic regime detection and concept drift handling
- 🌐 **Multi-Domain**: Fraud, medical, forex, manufacturing, security

## Niches of Excellence

Exactor Accelerator is unbeatable in:

- **Fraud Detection**: 95-100% accuracy, 0.05-0.1ms
- **Medical Triage**: 95-100% accuracy, 0.05-0.1ms
- **Quality Monitoring**: 95-100% accuracy, 50,000+ TPS
- **Security Logs**: 95-100% accuracy, 0.05-0.1ms
- **Forex Technical**: 80-100% accuracy, 0.05-0.1ms

## Installation

```bash
pip install exactor-accelerator
```

## Configuration

Exactor Accelerator connects to the [EXACTOR Core engine](https://exactor.tech) for cloud-accelerated boolean minimization. Set your token using any of these methods:

### Option 1: Environment Variable (recommended for production)

```bash
export EXACTOR_CORE_TOKEN="your-token-here"
export JEV_API_KEY="your-jev-key"          # Optional: TypeSafe Jev API
export DEEPSEEK_API_KEY="your-key"          # Optional: LLM explainer
```

### Option 2: `.env` File

```bash
cp .env.example .env
# Edit .env with your tokens
```

### Option 3: Programmatic Configuration

```python
import exactor_accelerator

exactor_accelerator.configure(
    exactor_core_token="your-token-here",
    jev_api_key="your-jev-key",           # Optional
    deepseek_api_key="your-key",          # Optional
)
```

### Option 4: Per-Instance Token

```python
from exactor_accelerator import ExactorAccelerator

engine = ExactorAccelerator(
    exactor_token="your-token-here",
    use_cloud_exactor=True,
)
```

> **Note:** Without an EXACTOR Core token, the library falls back to the built-in Hypercube Gray-code Reducer engine, which provides the same deterministic boolean minimization locally.

## Quick Start

```python
from exactor_accelerator import ExactorAcceleratorClassifier
from exactor_accelerator.feature_engine import get_feature_engine
from exactor_accelerator.regime_detector import get_regime_detector
import pandas as pd

# Load data
df = pd.read_csv("your_data.csv")

# Enrich with domain-specific features
feature_engine = get_feature_engine(domain="fraud")
df_enriched = feature_engine.extract_all(df)

# Train model
clf = ExactorAcceleratorClassifier(domain="fraud", fast_path=True)
clf.fit(df_enriched.drop("target", axis=1), df_enriched["target"])

# Predict
prediction = clf.predict(new_data)
```

## Examples by Domain

- [Fraud Detection](https://github.com/ExactorResearch/exactor-accelerator/blob/main/examples/fraud_detection_example.py)
- [Medical Triage](https://github.com/ExactorResearch/exactor-accelerator/blob/main/examples/medical_triage_example.py)
- [Forex Trading](https://github.com/ExactorResearch/exactor-accelerator/blob/main/examples/forex_trading_example.py)
- [Quality Monitoring](https://github.com/ExactorResearch/exactor-accelerator/blob/main/examples/manufacturing_quality_example.py)
- [Security Logs](https://github.com/ExactorResearch/exactor-accelerator/blob/main/examples/security_logs_example.py)

## Documentation

- [Use Case Guide](https://github.com/ExactorResearch/exactor-accelerator/blob/main/docs/USE_CASE_GUIDE.md)
- [Why Exactor Accelerator](https://github.com/ExactorResearch/exactor-accelerator/blob/main/docs/WHY_EXACTOR_ACCELERATOR.md)
- [Domain Implementation Guide](https://github.com/ExactorResearch/exactor-accelerator/blob/main/docs/DOMAIN_IMPLEMENTATION_GUIDE.md)
- [Roadmap v2.0](https://github.com/ExactorResearch/exactor-accelerator/blob/main/docs/ROADMAP_V2.md)
- [Executive Summary](https://github.com/ExactorResearch/exactor-accelerator/blob/main/docs/EXECUTIVE_SUMMARY.md)

## Roadmap

See [ROADMAP_V2.md](https://github.com/ExactorResearch/exactor-accelerator/blob/main/docs/ROADMAP_V2.md) for details.

## Contributing

See [CONTRIBUTING.md](https://github.com/ExactorResearch/exactor-accelerator/blob/main/CONTRIBUTING.md) for details.

## License

MIT License - see [LICENSE](https://github.com/ExactorResearch/exactor-accelerator/blob/main/LICENSE) for details.

---

## Architecture & System Design

This architecture integrates the **EXACTOR** boolean minimization engine (SMLE) with the **Jev** typed decision model (TypeSafe AI). The system operates under a **Live & Incremental Memory** paradigm: it starts with optional cold-start historical ingestion and evolves organically with every new query in real time, completely eliminating heavy offline retraining cycles.

```
       [ PHASE A: INITIAL INGESTION ]
   Historical Files (CSV / JSON / Logs)
                 │
                 ▼
   [ Adaptive Binarization in B^k ]
                 │
                 ▼
   [ EXACTOR Core Engine (Rust/Cloud) ] ──▶ Pure Rules (AND, OR, XOR, NOT)
                 │
                 ▼
   [ Dynamic Exactor ➔ Jev Adapter ]   ──▶ Typed Schema (Noul, Choice, Score)
                 │
                 ▼
       [ PHASE B: REAL-TIME OPERATION ]
   Production Query ──▶ [ Fast-Path Boolean / Jev (0.05-500ms) ]
                                     │
                ┌────────────────────┴────────────────────┐
                ▼                                         ▼
   [ Confidence >= Threshold ]                  [ SQLite WAL Ledger ]
                │                               (Collective Memory)
                ▼                                         │
    [ AUTONOMOUS EXECUTION ]                              ▼
                                                [ Sliding Window ]
                                                          │
                                                          ▼
                                            [ DIFFERENTIAL UPDATE ]
                                                (Hot Evolution)
```

---

## Operational Workflow

### Phase A: Cold-Start & Ingestion
1. **Historical Data Load**: Users or administrators supply initial records (CSV, JSON, logs, transactions, or tabular features) via the web interface or REST API.
2. **Adaptive Binarization**: The preprocessing engine transforms continuous and categorical variables into discrete propositions ($0$ and $1$) projected onto the boolean hypercube $\mathbb{B}^k$ ($k \le 64$).
3. **Logical Discovery (Exactor Core)**: The Rust/Cloud engine processes the binarized matrix, distilling an initial set of exact, immutable logical rules (AND, OR, XOR, NOT) with 100% auditability and zero black-box opacity.
4. **Jev Schema Calibration**: The discovered rules automatically translate into typed question schemas (`Choice`, `Score`, `Noul`) consumed by the Jev API.

### Phase B: Continuous Operation & Live Memory (Zero Retraining)
1. **Real-World Capture**: Each new production query, log event, or interaction enters the runtime in raw or semi-structured form.
2. **Ultra-Low Latency Evaluation**: Fast-path evaluates the boolean formula in 0.05–0.1 ms ($4,770\times$ speedup); complex or borderline states route to Jev calibrated probability distributions (**RLCD - Reinforcement Learning for Calibrated Decisions**).
3. **Memory Ledger Tracking**: Every interaction is automatically logged into a high-concurrency lightweight database (**SQLite in WAL mode**), building cumulative system memory.
4. **Differential Updates**: Periodically or on-demand, the engine processes recent sliding windows to update logic rules **in-place (hot evolution)**, allowing organic learning from real-world drift without downtime.

---

## Component Architecture

### Component 1: Ingestion & Binarization Subsystem (`exactor_accelerator.ingestion`)
- **Function**: Converts continuous and categorical features into clean boolean proposition matrices.
- **Inputs**: CSV/JSON datasets (at cold-start) or streaming event payloads (in production).
- **Outputs**: Discretized miniterm matrix with hypercube dimension mapping and target column.
- **Key Modules**: `binarizer.py`, `loader.py`, `text_extractor.py`.

### Component 2: Logic Minimization Engine (`exactor_accelerator.core`)
- **Function**: Executes boolean logic minimization using Gray codes and stack-based hypercube reduction.
- **Key Characteristics**: Native boolean hypercube ($\mathbb{B}^k$) operation without floating-point drift, producing auditable rules.
- **Native XOR Support**: Detects parity and non-linear algebraic symmetry.
- **Key Modules**: `hypercube.py`, `exactor_bridge.py`.

### Component 3: Dynamic Adapter (`exactor_accelerator.adapter`)
- **Function**: Translates Exactor boolean formulas into typed question schemas for TypeSafe Jev (`typesafe-sdk`).
- **Payload Structure**:
```json
{
  "model": "jev-latest",
  "state": { "event": "Real-time production query data" },
  "questions": {
    "logic_criterion": {
      "type": "noul",
      "instructions": "Is the boolean condition derived from historical analysis satisfied?"
    },
    "recommended_action": {
      "type": "choice",
      "instructions": "Which business action should be executed?",
      "criteria": {
        "AUTONOMOUS_EXECUTION": "High confidence",
        "HUMAN_REVIEW": "Uncertainty / edge case",
        "DISCARD": "Condition not met"
      }
    },
    "criticality_calibration": {
      "type": "score",
      "instructions": "Impact level on a continuous ordinal scale."
    }
  }
}
```
- **Key Modules**: `jev_schema.py`, `translator.py`.

### Component 4: Decision & Live Memory Layer (`exactor_accelerator.ledger` & `exactor_accelerator.engine`)
- **Function**: Delivers calibrated probabilistic responses to clients and records interactions for incremental learning.
- **Autonomous Execution**: Automatically triggers downstream workflows when confidence exceeds the configured threshold.
- **Concurrent Ledger**: SQLite optimized with `PRAGMA journal_mode = WAL;` and `PRAGMA synchronous = NORMAL;` for non-blocking concurrent writes.
- **Key Modules**: `sqlite_wal.py`, `jev_client.py`, `runtime.py`.

---

## Project Structure

```
exactor-accelerator/
├── exactor_accelerator/
│   ├── ingestion/             # Component 1: Ingestion & Binarization
│   │   ├── binarizer.py       # Adaptive hypercube discretizer
│   │   ├── loader.py          # CSV/JSON parsers & synthetic loaders
│   │   └── text_extractor.py  # Unstructured text feature extraction
│   ├── core/                  # Component 2: Exactor Logic Engine
│   │   ├── hypercube.py       # Hypercube, Gray code & stack reduction
│   │   └── exactor_bridge.py  # Dispatcher to exactor.tech Cloud / local
│   ├── adapter/               # Component 3: Exactor -> Jev Adapter
│   │   ├── jev_schema.py      # Noul, Choice, and Score primitives
│   │   └── translator.py      # TypeSafe payload generator
│   ├── ledger/                # Component 4A: Live Memory (SQLite WAL)
│   │   └── sqlite_wal.py      # Write-Ahead Logging persistence
│   ├── engine/                # Component 4B: Runtime & Jev Client
│   │   ├── jev_client.py      # TypeSafe API client & RLCD simulator
│   │   └── runtime.py         # HybridRuntime master orchestrator
│   ├── api/                   # FastAPI REST Service
│   │   └── server.py          # OpenAPI endpoints & static UI hosting
│   ├── web/                   # Control Dashboard (Glassmorphic)
│   │   ├── index.html         # Live telemetry & 4-phase dashboard
│   │   ├── styles.css         # Cyber-logic aesthetic
│   │   └── app.js             # Client logic & WAL stream feed
│   └── data/                  # Embedded sample datasets
├── tests/                     # Automated test suite
│   ├── test_binarizer.py
│   ├── test_exactor_hypercube.py
│   ├── test_jev_adapter.py
│   └── test_live_memory.py
├── run_demo.py                # End-to-end interactive CLI demonstration
├── run_server.py              # Web dashboard & REST API server launcher
└── pyproject.toml             # Standard PEP 621 package specification
```

---

## Usage Instructions

### 1. Run Automated Test Suite
```bash
python -m pytest tests/ -v
```

### 2. Run Interactive CLI Demonstration
Demonstrates the complete end-to-end lifecycle in one command:
```bash
python run_demo.py
```

### 3. Launch Web Server & Control Dashboard
```bash
python run_server.py
```
- **Web Control Panel**: [http://localhost:8000](http://localhost:8000)
- **Interactive Swagger Docs**: [http://localhost:8000/docs](http://localhost:8000/docs)

---

## REST API Endpoints

| Method | Endpoint | Description |
|---|---|---|
| `GET` | `/api/system/status` | Engine status, active rule version, and ledger record count |
| `POST` | `/api/ingest/file` | Phase A: Upload CSV/JSON dataset and trigger logical discovery |
| `POST` | `/api/ingest/sample` | Phase A: Instantly load sample datasets (fraud / sre / triage) |
| `GET` | `/api/exactor/rules` | Canonical boolean formulas distilled by Exactor |
| `GET` | `/api/jev/schema` | Calibrated typed question schema (`Noul`, `Choice`, `Score`) |
| `POST` | `/api/query` | Phase B: Real-time query evaluation with fast-path and WAL logging |
| `GET` | `/api/ledger` | Stream audited interaction records from SQLite WAL |
| `POST` | `/api/ledger/feedback` | Inject human feedback / ground truth for a past query |
| `POST` | `/api/differential/update` | Trigger differential rule update over a sliding window |
