Skip to main content

Composable, reproducible primitives for fortune-telling systems.

Project description

fortune-telling-core

fortune-telling-core is a composable, reproducible Python library for building fortune-telling and divination systems. It provides a small, deterministic, typed core of primitives for readings, symbols, spreads, draws, structural summaries, and provenance, with tradition-specific engines layered on top.

Design Principles

  • Deterministic and reproducible. Randomness enters through one narrow Rng protocol, and every reading records the exact Draw that produced it. A recorded draw can be replayed without any randomness.
  • Tradition-agnostic core. The core knows only symbols, positions, selections, deterministic summaries, and audit metadata. Tradition modules live behind their own packages and are not re-exported from the top-level package.
  • Interpretation belongs to harnesses. Discretionary meanings, localisation, and presentation copy are intentionally outside the library. Consumers can map stable symbol ids, position ids, modifiers, summaries, and provenance into their own interpretation layer.
  • Configurable where schools diverge. Where established schools or conventions disagree, such as house systems, zodiac/ayanamsa, time models, or the Nine Star Ki day-star escapement, the choice is a documented option recorded in reading provenance.

Included Systems

  • Core: Tradition-neutral value types, engine contracts, replay, serialisation, and provenance.
  • Astronomy: Shared, dependency-free astronomy including Julian-day helpers, solar terms, time models, the Ephemeris protocol, and a pure-Python BuiltinEphemeris.
  • Traditions: each exposes its engine and deck/spread data from its own subpackage. Drawn traditions take caller-provided randomness via read: tarot, lenormand (Petit Lenormand), dominoes, runes (Elder Futhark), geomancy (Western geomancy), and iching (I Ching). Computed traditions derive their draw from birth or identity data via cast: astrology, four_pillars (BaZi), nine_star_ki, numerology (Pythagorean), name_numerology, chaldean_numerology, can_chi (Vietnamese), thaksa (Thai), weton (Javanese), celtic_tree (Ogham tree zodiac), haab (Maya Haab'), and tzolkin (Maya Tzolk'in).

Quick Start

from fortune_telling_core import RandomRng, ReadingRequest, reading_to_json
from fortune_telling_core.traditions.tarot import RWS_DECK, SINGLE_CARD, build_engine

engine = build_engine()
request = ReadingRequest(
    deck_id=RWS_DECK.id,
    spread_id=SINGLE_CARD.id,
)

reading = engine.read(request, rng=RandomRng(seed=42))
payload = reading_to_json(reading)

Computed traditions use cast() instead of caller-provided randomness:

from fortune_telling_core import Querent, ReadingRequest
from fortune_telling_core.traditions.nine_star_ki import (
    NINE_STAR_KI_DECK,
    NINE_STAR_KI_SPREAD,
    build_engine,
)

engine = build_engine()
request = ReadingRequest(
    deck_id=NINE_STAR_KI_DECK.id,
    spread_id=NINE_STAR_KI_SPREAD.id,
    querent=Querent(
        id="example",
        display_name="Example",
        attributes={
            "birth_datetime": "1990-05-17T09:30:00+09:00",
            "latitude": "35.6895",
            "longitude": "139.6917",
        },
    ),
)

reading = engine.cast(request)

Layout

.
├── AGENTS.md
├── README.md
├── pyproject.toml
├── src/
│   └── fortune_telling_core/
├── docs/
├── tests/
├── tools/
└── .agents/
    └── docs/

Development

This repository uses a src/ Python package layout.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
python -m pytest

Run the deterministic demo CLI:

fortune-telling-demo all
fortune-telling-demo tarot --seed 7
fortune-telling-demo nine-star-ki --json --target-year 2026

For computed demos, a --birth-datetime without a timezone is interpreted in the terminal timezone and serialized with an offset.

Build or serve the API documentation:

python -m pip install -e ".[docs]"
mkdocs serve
mkdocs build --strict

Regenerate the built-in ephemeris series only when changing source tables or the truncation threshold. The large public VSOP87D source files are downloaded into .cache/ephemeris/vsop87d/, an ignored local cache outside tools/, and verified by checksum:

python tools/ephemeris/generate_builtin_series.py --download-missing
python tools/ephemeris/generate_builtin_series.py --check --download-missing

Canonical agent-facing project notes live in .agents/docs/.

Licence and Dependencies

fortune-telling-core is MIT licensed and is intended to remain zero-copyleft. The required runtime dependency set is empty.

Higher-precision astronomy is bring-your-own through the injectable Ephemeris Protocol. Consumers own the licensing review for any ephemeris backend they provide.

Project details


Download files

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

Source Distribution

fortune_telling_core-0.3.0.tar.gz (234.3 kB view details)

Uploaded Source

Built Distribution

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

fortune_telling_core-0.3.0-py3-none-any.whl (290.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fortune_telling_core-0.3.0.tar.gz
  • Upload date:
  • Size: 234.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for fortune_telling_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cddc2d74331b1a45728dfffd0d4bb98706f6f88a8e62a2725986bbcbfad91915
MD5 aa25ddd328398bff16c72ba126d50eb4
BLAKE2b-256 d2f87fa45d6ac5eb72d89770dc0063ae227dd37bd162927631d45efd005cddae

See more details on using hashes here.

Provenance

The following attestation bundles were made for fortune_telling_core-0.3.0.tar.gz:

Publisher: cd.yml on moriyoshi/fortune-telling-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for fortune_telling_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad79a179df69bfd15e1975fb69ed219885ddde2995dea1eb727ecdbf67df9693
MD5 14981310b4075b339867a9f583da8985
BLAKE2b-256 063eb9c18f88cec45570589e4792f200ad31c0e31b6c2835ea326f41a3cb2103

See more details on using hashes here.

Provenance

The following attestation bundles were made for fortune_telling_core-0.3.0-py3-none-any.whl:

Publisher: cd.yml on moriyoshi/fortune-telling-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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