Metadata-Version: 2.4
Name: aimarket-oracle-core
Version: 0.2.0
Summary: Shared AIMarket v2 infrastructure for the oracle family
License-Expression: Apache-2.0
Requires-Python: >=3.11
Requires-Dist: cryptography>=44.0.0
Requires-Dist: fastapi>=0.115.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.9.0
Requires-Dist: uvicorn[standard]>=0.32.0
Provides-Extra: dev
Requires-Dist: httpx>=0.27.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.3.0; extra == 'dev'
Provides-Extra: pqc
Requires-Dist: dilithium-py>=1.4.0; extra == 'pqc'
Description-Content-Type: text/markdown

# aimarket-oracle-core

Shared infrastructure for the [alexar76 oracle family](https://github.com/alexar76/oracles) —
the layer that turns a pure function into a sellable, verifiable capability on
**AIMarket Protocol v2**.

An oracle written on top of this declares its capabilities and its maths. Everything else —
the HTTP surface, the signed manifest, priced invoke, Ed25519 receipts, measured latency and
success metrics, rate limiting, and hub federation — comes from here.

```python
from oracle_core import Capability, OracleSpec

SPEC = OracleSpec(
    name="Example Oracle",
    product_id="prod-example",
    description="What it sells, in a sentence an agent can choose on.",
    capabilities=[
        Capability(
            capability_id="example.double@v1",
            product_id="prod-example",
            description="Return twice the input.",
            handler=lambda d: {"result": 2 * float(d["value"])},
            input_schema={"type": "object", "required": ["value"],
                          "properties": {"value": {"type": "number"}}},
            output_schema={"type": "object", "required": ["result"],
                           "properties": {"result": {"type": "number"}}},
            price_per_call_usd=0.001,
        ),
    ],
)
```

## Install

```bash
pip install aimarket-oracle-core
```

The distribution is `aimarket-oracle-core`; the import is `oracle_core`. The unprefixed
name `oracle-core` on PyPI is an **unrelated project** that installs a module of the same
name — installing it in place of this one fails at
`ImportError: cannot import name 'Capability' from 'oracle_core'`.

## What you get

| | |
|---|---|
| **Protocol** | `.well-known/ai-market.json` discovery, v2 manifest, priced `invoke` |
| **Signing** | Ed25519 manifest signatures and 7-field receipts, canonical form shared with the hub; optional hybrid post-quantum via the `pqc` extra |
| **Metrics** | measured `p50_latency_ms` and `success_rate_30d`, not declared constants |
| **Safety** | handler exceptions become named refusals (`{"ok": false, "error": …}`) rather than opaque 500s |
| **Federation** | manifests a hub can verify byte-for-byte and re-list |

## Extras

- `pqc` — hybrid post-quantum signatures (`dilithium-py`)
- `dev` — pytest, pytest-asyncio, httpx

Apache-2.0.
