berylx-py
Immutable state workflows interpreted through a tagged Freer effect monad. Python
port of minamorl/berylx-ts, frozen at
24aabcd6059547f15b5b2817592e3d0dd4f258bb
(TS 0.4.0). The frozen revision equals upstream HEAD observed on 2026-10-29.
Install
Python 3.11 or newer. Install from PyPI:
python -m pip install berylx-py
Or install from this source directory:
python -m pip install .
The public repository is https://github.com/minamorl/berylx-py . Install directly from GitHub:
python -m pip install 'git+https://github.com/minamorl/berylx-py.git'
For development from this source directory:
python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements-dev.txt
python -m pip install -e .
Releasing
Update project.version in pyproject.toml, then commit and push to main.
The publishing workflow checks whether that version already exists on PyPI. A new
version runs the complete Python 3.11–3.14 CI matrix, builds and checks the
artifacts, then publishes through the registered Trusted Publisher. An existing
version is skipped. PyPI or network errors fail the check instead of uploading.
The workflow can also be dispatched manually from main to retry an unpublished
version; no PyPI token needs to be stored in GitHub.
Workflows
from berylx import Root, Task, Ok
root = Root.of({'user': {'name': ' mina '}, 'total': 0})
trim = Task.of('trim', lambda f: f.at('user').at('name').update(str.strip))
charge = Task.of('charge', lambda f: f.at('total').set(100))
result = root.call(trim.then(charge))
assert isinstance(result, Ok)
assert root.at('user').at('name').get() == 'mina'
assert root.state()['total'] == 100
Focus/Lay is a snapshot; at navigates, set/put/update return a new root
focus. Dicts and lists are defensively copied into read-only views. Root commits
only successful results automatically. An Err carries its partial focus, structured
error, cause and trace; unwrap() explicitly raises. Catch recovers at a sequence
boundary; rescue_with wraps a whole workflow.
a.par(b) starts each branch from the same snapshot. Default strict three-way merge
preserves independent changes to existing keys and reports merge_conflict for
incompatible same-path changes. .reduce(Merge.deep()) explicitly selects
right-biased two-way merging. .accumulate() collects failures. The default
short_circuit selects the first failure after every branch settles; it does
not cancel work. AsyncTask runs with await EffectTree.run_async(...).
Use a.par(b, workers=2) or a.par(b).workers(2) to limit concurrently
running branches of that parallel node. The value must be an integer of at least 1.
Without a limit, asynchronous branches all start concurrently. All branches
start from the same snapshot and settle before results are combined in definition
order, even after a failure. Each nested limited parallel node keeps its own limit;
limits multiply across levels, rather than sharing one global pool.
Each nested node applies its own reducer and error policy before its parent combines
the resulting branch.
Synchronous execution remains sequential regardless of workers. No thread or
process pool is created: the limit is useful for asynchronous, wait-heavy work;
the GIL means threads would not speed up pure Python computation.
Monads and effect interpretation
from berylx import darkcore as d
program = d.op('lookup', {'id': 7}, int).bind(lambda n: d.pure(n + 1))
assert d.run(program, {'lookup': lambda payload: 41}) == 42
assert d.run(program, {'lookup': lambda payload: 9}) == 10
stateful = d.State.get().bind(
lambda n: d.State.put(n + 1).seq(d.State.get())
)
assert stateful.run(10) == (11, 11)
assert d.Err('failed').bind(lambda x: d.Ok(x + 1)) == d.Err('failed')
Darkcore supplies Just/Nothing, Right/Left, Ok/Err, Success/Failure, State
and Effect. These value result classes are distinct from workflow Ok/Err.
Validation.bind short-circuits; Validation.ap accumulates errors and intentionally
differs from the application operation induced by its bind.
Tasks compile into inspectable tagged payloads (node, focus) over the same Effect
substrate. Handler maps interpret the tree; EffectTree.around/around_async wrap
nested tasks, effects and recovery. Callbacks declaring a required second positional
parameter receive Perform; recovery callbacks receive it as their third.
from berylx import Task, EffectTree
fetch = Task('fetch', lambda f, p: f.put('answer', p.perform('lookup', 7)))
handlers = EffectTree.real_handlers({'lookup': lambda key: 42})
assert EffectTree.run(fetch, {}, handlers).focus.get()['answer'] == 42
assert EffectTree.dry_run(fetch, {}).steps == ['fetch']
Dry-run skips task bodies but still evaluates predicates. It is a planning
interpreter, not proof of behavioral equivalence. Real and virtual IO handlers
interpret the same darkcore.IOEffects programs.
Equivalence and differences
The supported runtime contract includes monad values/state/effects, immutable
focus, structured failures, sequence/parallel/branch/recovery, async interpretation,
Root history/subscriptions, scoped factories, graph output and Cray adapters.
Timeline scheduling and Root integration are exposed in berylx.timeline and
berylx.timeline_berylx (clock injection, human waits, recurring origins and
concurrent commit merge). See the frozen contract and
API mapping for exact boundaries.
Python names are snake_case; or_else/and_then avoid keywords. Python exceptions,
truthiness and numbers follow Python rules. None combines JavaScript null and
undefined. Python generics do not reproduce TS compile-time path-key inference.
Browser/npm exports are not applicable. The port does not claim unrestricted
cross-language equivalence for arbitrary objects, numeric edge cases or deletions
through parallel's strict reducer. Timeline uses a separate deletion-aware merge.
Validation
Regression/unit tests and independently captured TypeScript observations were written and run RED before implementation. After all regression/unit gates pass, Hypothesis checks generated monad/composition/state/failure/merge properties.
python -m pytest -q tests/test_regression.py tests/test_darkcore.py tests/test_oracle.py tests/test_boundaries.py tests/test_timeline.py
python -m pytest -q tests/test_properties.py
python -m pytest -q
ruff check src tests
ruff format --check src tests
mypy src/berylx
python -m build
The type gate checks implementation bodies; it does not prove TS-style path types. Recorded evidence includes phase gates. To regenerate the independent oracle, build a separate TS checkout at the frozen revision, then run:
node scripts/ts_oracle.mjs /absolute/path/to/berylx-ts/dist/index.js
Its output must match tests/fixtures/ts-observations.json. Python compares state,
error envelopes, handler order, State and value-monad observations against that
fixture, without importing or executing the TS implementation.
MIT licensed; original TypeScript implementation copyright 2026 minamorl is retained in LICENSE.
Metadata
Release files for berylx-py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| berylx_py-0.2.0.tar.gz | 83.9 kB | With provenance | Details for berylx_py-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| berylx_py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for berylx_py-0.2.0-py3-none-any.whl |
Total release size: 114.4 kB
Release files / berylx_py-0.2.0.tar.gz
| Download URL | berylx_py-0.2.0.tar.gz |
|---|---|
| Size | 83.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3fdbf3e5c8d0b9103d07a4bc5cc2ca84eaddbcf58ac28535a57d38ee8b5a9b37
|
|
BLAKE2b-256 checksum How to use checksums |
03ef2ac706a15a153f99231db8da3f6ca9ca4101e271645c5b12aeb89919b6e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 26, 2026.
Transparency logRelease files / berylx_py-0.2.0-py3-none-any.whl
| Download URL | berylx_py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a29907bdfe80cd6989f248b2fb99e7c89e8b1eca100768b70a3b812bc50f6bda
|
|
BLAKE2b-256 checksum How to use checksums |
e57f7a129ae1c19d6c5b0590b31aaf82759adf10f4a9f269bcb02206b4d9588e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 26, 2026.
Transparency logSecurity for berylx-py 0.2.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.
Attestation for berylx_py-0.2.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 Nov 26, 2026.
Transparency logA 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.