Metadata-Version: 2.5
Name: edma-core
Version: 0.1.0
Summary: EDMA — Evidence-Driven Model Architecture: a frozen, evidence-first cognitive runtime for AI agents (13-state DOP, default-deny actions, evidence-based verification, zero-template).
Project-URL: Homepage, https://github.com/SolignusCorp/edma-core
Project-URL: Repository, https://github.com/SolignusCorp/edma-core
Project-URL: Issues, https://github.com/SolignusCorp/edma-core/issues
Project-URL: Changelog, https://github.com/SolignusCorp/edma-core/blob/main/CHANGELOG.md
Author: SolignusCorp
License: Apache-2.0
License-File: LICENSE
Keywords: agents,ai,benchmark,evidence,llm,mcp,model-context-protocol,runtime,verification
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: httpx>=0.24; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: provider
Requires-Dist: httpx>=0.24; extra == 'provider'
Description-Content-Type: text/markdown

# EDMA-CORE

**EDMA — Evidence-Driven Model Architecture.** An evidence-first cognitive runtime
for AI agents: a frozen 13-state DOP graph, deterministic default-deny action
authorization, evidence-based verification, and a strict **zero-template** policy —
user-facing answers come ONLY from the model, never from canned text.

> Open core of the runtime that powers the Solignus AI platform in production.

## Why evidence-first?

Agent frameworks usually trust the model: the model says the tool succeeded → the
framework reports success. EDMA inverts this:

| Principle | Meaning |
|---|---|
| **Dalilsiz PASS yo'q** | Verification judges real-world effects (read-back, hashes, provider facts) — never model claims. `UNCERTAIN` is never promoted. |
| **Default-deny actions** | Unregistered action types are denied. The model cannot self-authorize: `authorized`/`approved` fields are scrubbed and ignored. |
| **Zero-template** | Heuristic fallbacks never invent user-facing text. If the model didn't write it, it isn't said. |
| **Memory-agnostic** | No memory subsystem. Conversation context is application-provided input; the runtime never mutates it. |
| **Deterministic control** | Exactly 13 DOP states with a frozen transition table. The DOP Engine is the sole transition authority; components/model return facts only. |

## Quickstart

```bash
pip install edma-core[provider]        # httpx only for the default provider
export EDMA_PROVIDER_KEY="gsk_..."     # any OpenAI-compatible key
export EDMA_PROVIDER_BASE_URL="https://api.groq.com/openai/v1"
export EDMA_PROVIDER_MODEL="qwen/qwen3.8-27b"
```

```python
import asyncio
from edma_core import quickstart, runtime as RT

quickstart()  # env provider + in-memory docs/audit + no-budget

run = RT.start_run("org-1", "What is 17*24?")
view = asyncio.run(RT.advance_run("org-1", run))
print(view["response"])            # model-authored answer (or honest failure state)
print(view["dop_path"])            # canonical trajectory: START→PERCEIVING→REASONING→RESPONSE
```

Zero configuration also works (no provider → deterministic heuristics and honest
`failed`/`pending` states instead of fabricated answers).

## Architecture

```
        ┌────────────────────── runtime.py (resumable DOP loop) ─────────────────────┐
        │  the ONLY caller of dop.decide()                                           │
        │                                                                            │
 model ─┼─▶ PERCEIVING ─▶ ENERGY ─▶ REASONING ─▶ ACTION_DECISION ─▶ ACTION_AUTHORIZATION
        │       (13 frozen states; waiting states pause WITHOUT transitioning)       │
        │                                    ▲                       │ approve/deny │
        │                                    └── VERIFICATION ◀── ACTION (execute)   │
        │                                                │                           │
        │                                            RESPONSE ─▶ END                 │
        └────────────────────────────────────────────────────────────────────────────┘
 ports:  ModelProvider (chat) · DocStore (run snapshots) · EventSink (audit)
         Budget (metering, optional) · DatasetReader (read-back evidence)
```

- `dop.py` — frozen 13-state graph + deterministic decision policy
- `components.py` — ONE model, four structured cognitive modes
  (perceive / energy / reason / respond) + honest heuristic fallbacks
- `actions.py` — registry + deterministic ACTION_AUTHORIZATION (default-deny);
  capabilities are **plugins** (`contrib.py` factories, dependency-injected)
- `verification.py` — PASS / FAIL / UNCERTAIN / SKIPPED from evidence only
- `trace.py` — canonical trace of what ACTUALLY executed (+ durable audit sink)
- `runtime.py` — resumable loop: snapshots re-written around every transition,
  human-approval pauses, semantic non-progress detection, hard step cap as
  a secondary safety net only
- `dataset_exec.py` — fast direct-model dataset generation with QC
  (no samples pass QC → no dataset; nothing fabricated)

## Wiring your own backends

```python
from edma_core import configure

configure(
    provider=MyProvider(),        # async chat(payload) -> {ok, reply, usage, ...}
    docs=MyDocStore(),            # user_doc_get/user_doc_put per-org documents
    sink=MyAuditSink(),           # event_log/events_list append-only audit
    budget=MyBudget(),            # cost_of/charge/balance (optional)
    dataset_reader=MyReader(),    # get_dataset for read-back verification
)
```

## MCP server (Claude Desktop, Cursor & any MCP client)

`edma-mcp` exposes EDMA's **verification** and **action-authorization** layers
as standard [Model Context Protocol](https://modelcontextprotocol.io) tools over
stdio — zero dependencies (stdlib JSON-RPC 2.0, protocol `2025-06-18`).

The server **never executes actions**. `edma_authorize` returns a *decision*
only (default-deny; the model cannot self-authorize), `edma_verify` judges an
executed action's observable `ActionResult` — **NO EVIDENCE → NO PASS**.

| Tool | Purpose |
|---|---|
| `edma_authorize` | granted / denied / `pending_human` for a PROPOSED action (decision only) |
| `edma_verify` | evidence-based PASS/FAIL/UNCERTAIN for an executed action's `ActionResult` dict |
| `edma_list_actions` | registered actions with risk + arg schema |
| `edma_dop_graph` | the frozen 13-state DOP graph |

Test drive:

```bash
echo '{"jsonrpc":"2.0","id":1,"method":"ping"}' | edma-mcp
# or: python -m edma_core.mcp
```

Claude Desktop — copy [`examples/claude_desktop_config.json`](examples/claude_desktop_config.json)
into `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or
`%APPDATA%\Claude\claude_desktop_config.json` (Windows):

```json
{
  "mcpServers": {
    "edma": { "command": "edma-mcp", "args": [], "env": {} }
  }
}
```

Any other MCP client (Cursor, custom agents): launch `edma-mcp` as a subprocess
and speak newline-delimited JSON-RPC over stdin/stdout.

## Run your own benchmark

`edma_core.bench` ships the full benchmark lab — independent evaluator,
contract auditor, metrics, reports — as part of the package. The evaluator
never sees EDMA code; the EDMA runtime never sees the evaluator. **No
automatic winner is declared**: reports show facts + deltas + Wilson 95% CIs;
failed cases are never hidden; `UNCERTAIN` is never promoted to `PASS`.

Deterministic scripted run (no network, no keys — fully reproducible):

```bash
python -m edma_core.bench list
python -m edma_core.bench run                  # golden-v1: CONTROL vs EDMA, scripted
python -m edma_core.bench run --limit 4        # first 4 cases
python -m edma_core.bench world --set world-v1 # GSM8K+MMLU grading (scripted demo)
```

Real-model run (keys via env only — never in repo, traces, logs or reports):

```bash
export EDMA_BENCH_KEYS="key1,key2"            # round-robin; rotates on 429/limits
export EDMA_BENCH_MODEL="qwen/qwen3.8-27b"    # any OpenAI-compatible model id
export EDMA_BENCH_BASE_URL="https://api.groq.com/openai/v1"
python -m edma_core.bench run --real          # CONTROL + EDMA share the same model
```

Artifacts land in `bench_runs/<run_id>.json` (gitignored): per-case results,
contract violations, regressions, aggregates and CIs.

Suites: `golden-v1` (15 deterministic cases, categories A–O, scripted modes),
`world-v1` (30 real GSM8K/MMLU items, reference-key grading),
`world-v2` (42 items across math/knowledge/safety/structured domains).

House rules (unchanged from the reference lab): `NO EVIDENCE → NO PASS` ·
`MODEL CLAIM → NOT EVIDENCE` · `EDMA SELF-REPORT → NOT EVIDENCE` · provider
failure → STOP, no silent fallbacks.

## Honest benchmarks (small n — no superiority claims)

Controlled runs (independent evaluator, the model never grades itself;
95% CIs OVERLAP — we do not claim statistical superiority):

| Suite (n) | CONTROL (direct chat) | EDMA runtime | Notes |
|---|---|---|---|
| world-v2 multi-domain (42) | 83.3% [69.4–91.7] | 90.5% [77.9–96.2] | structured tasks 60% → 90%; 0 execution errors |
| world-v1 GSM8K+MMLU (30) | 84.0% | 83.3% | accuracy preserved; ~3.6× more model calls |
| golden-v1 tool cases (15) | 20% success | 40% success | hallucination 0% (EDMA) vs 13.3% |

The value proposition is **discipline**: no PASS without evidence, forbidden
actions stop, answers re-checked — at the cost of extra model calls.

## Documentation

- [docs/dop-graph.md](docs/dop-graph.md) — the frozen 13-state DOP graph (mermaid + table)
- [docs/verification.md](docs/verification.md) — PASS/FAIL/UNCERTAIN/SKIPPED evidence rules
- [docs/trace-and-audit.md](docs/trace-and-audit.md) — canonical trace + durable audit spec
- [docs/threat-model.md](docs/threat-model.md) — why default-deny; residual risks
- [docs/invariants.md](docs/invariants.md) — the project's constitution (PR-gated)
- [MODEL_CARD.md](MODEL_CARD.md) — verbatim-honest benchmark numbers
- [CONTRIBUTING.md](CONTRIBUTING.md) · [SECURITY.md](SECURITY.md) · [CHANGELOG.md](CHANGELOG.md)

## Development

```bash
pip install -e ".[dev]"
pytest          # 151 tests: DOP policy, verification evidence rules, runtime
                # trajectories, hardening, memory-agnostic + zero-template invariants
```

Invariant tests (13 states, default-deny, zero-template, memory-agnostic) run on
every PR and are the project's constitution — changes to them will be rejected.

## License

Apache-2.0. `edma-core` is the open core; the managed platform (Solignus AI) is
a separate product.
