Metadata-Version: 2.4
Name: dasc-core
Version: 0.1.1
Summary: A deterministic safety controller for agentic workflows.
Author-email: "Anteneh T. Tessema" <anteneh@example.com>
Project-URL: Homepage, https://github.com/Anteneh-T-Tessema/dasc-core
Project-URL: Bug Tracker, https://github.com/Anteneh-T-Tessema/dasc-core/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0.0
Requires-Dist: fastapi>=0.100.0
Requires-Dist: uvicorn>=0.23.0
Requires-Dist: sqlalchemy>=2.0.0
Requires-Dist: psycopg2-binary>=2.9.0
Requires-Dist: requests>=2.31.0
Dynamic: license-file

# DASC-Core

DASC (Deterministic Agentic Safety Controller) is an open-source middleware designed to intercept outputs from AI orchestration frameworks (like LangGraph, AutoGen, and CrewAI) and enforce deterministic safety checks before actions are committed.

## The Paradigm: Cognitive Fault vs. Committed Fault

DASC operates on the principle that AI agents *will* fail. These are **Cognitive Faults** (hallucinations, logic errors). Our goal is to prevent these from becoming **Committed Faults** (actual state changes). DASC provides the deterministic boundary where these faults are intercepted.

## Installation

```bash
pip install dasc-core
```

## Features

- **LangChain/LangGraph Integration**: Use `DASCCommitTool` to wrap agent actions.
- **AutoGen Support**: Use `DASCGatekeeper` to intercept and validate function calls.
- **Semantic OCC (Hashing)**: Use `hash:<sha256>` in version vectors for automatic file content verification.
- **Structured Observability**: Built-in logging with detailed evaluation stages.
- **Programmable Rejections**: Custom exceptions (`OCCConflictError`, etc.) for robust error handling.
- **Bitemporal SQLite Ledger**: Persistent audit log of every decision.

## Quick Start

### Using the Kernel with Exceptions

```python
from dasc.kernel import Kernel
from dasc.exceptions import OCCConflictError

kernel = Kernel()

try:
    kernel.evaluate(intent, raise_on_failure=True)
except OCCConflictError:
    # Trigger agent retry or state refresh logic
    pass
```

### Using Semantic OCC (Hashing)

```python
from dasc.utils import calculate_file_hash

file_hash = calculate_file_hash("data.json")
intent = Intent(
    ...,
    state_version_vector={"data.json": f"hash:{file_hash}"}
)
```

## Documentation

- **Visual Architecture**: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) - Detailed Mermaid diagrams of the DASC logic flow.
- **Research Paper (PDF)**: [docs/DASC_Academic_Paper.pdf](docs/DASC_Academic_Paper.pdf)
- **Technical Overview**: [docs/DASC_Academic_Paper.md](docs/DASC_Academic_Paper.md)

## DASC CLI

The project includes a command-line tool for inspecting the ledger and generating hashes:

```bash
# View the last 10 decisions
dasc inspect

# Generate a hash for a file for OCC
dasc hash my_data.csv

# Verify a JSON intent manually
dasc verify intent.json --state '{"my_data.csv": "v1.0"}'
```

## Examples

Run the production features demo:
```bash
python -m examples.production_features
```

## License

MIT
