Skip to main content

arcana-core

License: Apache 2.0 Python 3.11+

arcana-core

The Python library at the heart of Arcana OS. Assign a tarot card to an agent: get a soul.

pip install arcana-core
# or inside the monorepo:
uv sync --all-packages --all-extras

Quick start

Agents run through a ModelGateway. The gateway owns connections, routing, retries, and cost metering; the agent just names the model it wants.

from arcana import Agent, Card
from arcana.models import ConnectionStore, ModelGateway

async with ModelGateway(ConnectionStore()) as gw:
    agent = Agent(
        name="researcher",
        card=Card.HERMIT,
        gateway=gw,
        model="ollama/hermes-3",
    )

    result = await agent.run("Summarise recent advances in RAG.")
    print(result)

    # Streaming
    async for chunk in agent.stream("What is a vector index?"):
        print(chunk, end="", flush=True)

How it works

Every agent is configured by a tarot card. The card encodes an archetype: personality and default temperature. The CardEngine blends one primary card with optional modifier cards into an AgentConfig, which the Agent wires together with the gateway.

Card enum
  → CardRegistry.get()   → TarotCard  (archetype, traits, prompt ingredients)
  → CardEngine.resolve() → AgentConfig (system_prompt, temperature)
  → Agent.__init__()      ← wires gateway + model + AgentConfig together
  → Agent.run() / Agent.stream()

Blending: primary card = 70%, modifier cards = 30% split equally. Temperature is linearly blended. CardEngine.check_compatibility() reports how well a primary and its modifiers fit together.

agent = Agent(
    name="creative-researcher",
    card=Card.HERMIT,            # 70 % — deep, methodical
    modifier_cards=[Card.FOOL],  # 30 % — curious, action-first
    gateway=gw,
    model="ollama/hermes-3",
)

Each run records a Session (messages + token totals). Sessions are stateless in this release — multi-turn continuity within a session is supported; cross-session memory is not yet wired (see the roadmap).


The 22 Major Arcana

# Card Archetype Default temp
0 The Fool Explorer / Autonomous Agent 0.95
I The Magician Executor / Tool Master 0.50
II The High Priestess Archivist / Pattern Reader 0.40
III The Empress Creator / Generative Agent 0.85
IV The Emperor Orchestrator / System Agent 0.30
V The Hierophant Advisor / Domain Expert 0.30
VI The Lovers Collaborator / Communication 0.70
VII The Chariot Driver / Goal Agent 0.40
VIII Strength Coach / Long-Game Agent 0.60
IX The Hermit Researcher / Deep Analyst 0.35
X Wheel of Fortune Scheduler / Probabilistic 0.65
XI Justice Auditor / Evaluation Agent 0.20
XII The Hanged Man Reframer / Perspective 0.80
XIII Death Transformer / Refactor Agent 0.40
XIV Temperance Integrator / Synthesis 0.55
XV The Devil Shadow / Constraint Breaker 0.75
XVI The Tower Disruptor / Breakthrough 0.85
XVII The Star Companion / Wellbeing Agent 0.70
XVIII The Moon Interpreter / Ambiguity 0.80
XIX The Sun Amplifier / Output Agent 0.75
XX Judgement Reviewer / Reflection 0.45
XXI The World Meta-Agent (reserved) 0.50

The World (XXI) is defined but reserved — it cannot be assigned to an agent yet.


Module map

Module What's implemented
arcana/types/ All Pydantic models — always import from arcana.types. Covers cards, agents, sessions, models, memory, tools, and workspaces.
arcana/cards/definitions/ One file per card, each exporting a TarotCard instance (all 22 present).
arcana/cards/registry.py CardRegistry — get(Card), all().
arcana/cards/engine.py CardEngine — blending, resolve() → AgentConfig, check_compatibility().
arcana/agents/agent.py Agent — run() / stream(), session recording.
arcana/agents/registry.py AgentRegistry — CRUD for agent records persisted to ~/.arcana/agents/{id}/agent.json; build_runtime().
arcana/agents/session_manager.py SessionManager — session lifecycle, persisted to disk.
arcana/models/ ModelGateway (routing, adapter pooling, retry/backoff, error normalization, cost metering), adapters for Ollama / Anthropic / OpenAI-compatible, ConnectionStore (keyring-backed secrets), pricing, and a normalized ModelError hierarchy.
arcana/memory/ The federated memory layer. MemoryFederation presents private / shared / global tiers as one MemoryAdapter: SQLiteAdapter (FTS5 keyword search), optional VectorAdapter (sqlite-vec semantic + hybrid), and read-only connectors — MarkdownFolderAdapter makes an Obsidian vault or notes folder searchable from just a path. A knowledge-graph layer (memory_edges + EdgeStore) links notes into typed edges, populated from [[wikilinks]] by WikilinkEdgeExtractor. Per-tier resilience (timeouts, circuit breakers) and PRAGMA user_version migrations round it out.
arcana/context/ read_soul() — loads the optional user-owned ~/.arcana/soul.md context injected into sessions; missing or unreadable is a silent None.
arcana/observability/ Local-first telemetry: a JSONL AuditLog (~/.arcana/logs/), OpenTelemetry tracing (optional [observability] extra), and metrics — wired through the Agent and ModelGateway.
arcana/evals/ arcana.evals, the public evaluation harness: EvalHarness runs EvalCase suites (cards, memory, decay, blending) scored by a CompositeJudge (deterministic RuleJudge + optional LLMJudge), with JSON result persistence and regression comparison across runs.

Types convention

All Pydantic models are re-exported from arcana.types. Always import from there:

from arcana.types import Card, AgentConfig  # correct
from arcana.types.card import Card           # avoid

Adding a new card

  1. Create arcana/cards/definitions/<name>.py following fool.py — export a single TarotCard instance.
  2. Import it in arcana/cards/definitions/__init__.py and add it to all_cards() in canonical order.
  3. Add the Card enum value to arcana/types/card.py if not already present.

Development

# Lint
uv run ruff check .

# Type check
uv run pyright packages/arcana-core/arcana

# Tests (no LLM calls)
uv run pytest packages/arcana-core/tests/ -v -m "not llm_eval"

Roadmap

This release ships the Phase 1a MVP: card-configured, stateless agents on the model gateway. The federated memory layer now lives in arcana-core (tiered backends, folder connectors, and a knowledge-graph edge layer — see the module map), usable directly as a library. Wiring it into the agent run path — plus a tool/MCP gateway and The World meta-agent — lands in Phase 1b as additive work, not a rewrite.

Metadata

Release files for arcana-core 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arcana-core 0.3.0
File Size Uploaded Provenance Actions
arcana_core-0.3.0.tar.gz 230.4 kB With provenance Details for arcana_core-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for arcana-core 0.3.0
File Interpreter ABI Platform Actions
arcana_core-0.3.0-py3-none-any.whl Python 3 none any Details for arcana_core-0.3.0-py3-none-any.whl

Total release size: 427.1 kB

Release files / arcana_core-0.3.0.tar.gz

Download URL arcana_core-0.3.0.tar.gz
Size 230.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fd74613a34d7702a967d561374cc8eaa006a3cb8de3d043f2eb06572a86470c8
BLAKE2b-256 checksum
How to use checksums
8fa17cf809f74840a53eae7a86fd5125c3df77fb76853a975a97945bc4899144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 18, 2026.

Transparency log

Release files / arcana_core-0.3.0-py3-none-any.whl

Download URL arcana_core-0.3.0-py3-none-any.whl
Size 196.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7dfd3f1036a82a8a10a3e5ccc8385fe5170ec87b3e73c7da04d4bee43956129
BLAKE2b-256 checksum
How to use checksums
b2c2c5f9ae6f5c6d8c38d91036a4cf5ac90257f7b56a53867e560f730f863879
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 18, 2026.

Transparency log

Security for arcana-core 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for arcana_core-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page