Skip to main content

aimarket-oracle-core

Shared infrastructure for the alexar76 oracle family — 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.

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

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
Cost controls free-tier ceilings and CPU budgets for capabilities that sell computation

Cost controls

Most capabilities are bounded by construction — their worst legal input costs a fraction of a millisecond, and they need nothing here. Leave these fields unset and behaviour is exactly as it was.

A capability that sells computation is different: if the caller picks how much work to do, then the schema's own maximum is a promise to burn that much CPU on request, for free, to anyone. chronos.eval@v1 at MAX_DIFFICULTY is 6.8 sequential seconds; aestus.seal@v1 at MAX_T is ~36. At the generic 120 invokes/min that is ~70 CPU-seconds of demand per second from one address.

Capability(
    capability_id="mine.expensive@v1",
    handler=_run,
    # Unpaid callers are REFUSED above these (402, ceiling in the body) — never
    # silently served smaller, which would sign a receipt for work the caller did
    # not request. Set each to the schema's own default so an argument-free call is
    # never refused. Dotted paths reach into nested objects ("puzzle.T").
    free_tier_max={"iterations": 10_000},
    # What one input costs, in CPU-ms. Fit it to a benchmark and record the numbers
    # in a comment; only relative accuracy matters, since a slower machine scales
    # every cost alike. A formula that raises degrades to 1 ms rather than 500ing.
    cost_ms=lambda d: d.get("iterations", 10_000) / 25.0,
    cpu_budget_ms_per_min=20_000,         # a third of a core, per client
    global_cpu_budget_ms_per_min=60_000,  # one core, across everyone
)

Budgets ration work, not calls, and that is the point: a flat call limit has to be either wrong for the cheap input or wrong for the expensive one. Charging each request its real cost leaves exploration effectively unlimited while capping the expensive tail. (A flat 2-calls-per-minute was tried first and refused this package's own test suite on the fourth request.)

Ceilings and budgets are published in the manifest, so a buyer reads them before spending a call to discover them. Who may exceed a ceiling is a deployment question, not a code one — ORACLE_PAID_TIER_SECRET or ORACLE_TRUSTED_PAYMENT_PROXIES, both unset by default, which means nothing is ever lifted until an operator says so. Full rationale and the measured numbers: oracle_core/tiers.py and docs/free-and-paid-tiers.md in the monorepo.

Extras

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

Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aimarket_oracle_core-0.3.0.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aimarket_oracle_core-0.3.0-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file aimarket_oracle_core-0.3.0.tar.gz.

File metadata

  • Download URL: aimarket_oracle_core-0.3.0.tar.gz
  • Upload date:
  • Size: 36.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for aimarket_oracle_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1dd911401fc2b22c5098308692f5bd8c6cd072f3617c2513679c0fc8cb920343
MD5 f741a93eed0f7a0c0968df0c10fb2a86
BLAKE2b-256 65da55b5f408e52d8dfc44cc7a32c89f222947edcd003e87d5aa275e94805d1d

See more details on using hashes here.

File details

Details for the file aimarket_oracle_core-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aimarket_oracle_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 451aa8a045f57c7d70118cbfb743bddeda7afc4d68acfa408f00f42fb7af879d
MD5 016647e143d49bbc02297dd71ea75410
BLAKE2b-256 5217f5d39fa0b01c9f9410ae23169e66707eccad1d0c92ec19b1c0d59336be26

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page