alberta-buck-core 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: alberta-buck-core
3
+ Version: 0.1.0
4
+ Summary: Alberta Buck core platform (Python): the ChainSession API over anvil/testnets/pyrevm with expectation journaling, and the Foundry artifact loader
5
+ Author-email: Perry Kundert <perry@dominionrnd.com>
6
+ License-Expression: CAL-1.0
7
+ Project-URL: Homepage, https://github.com/alberta-buck/alberta-buck
8
+ Project-URL: Bug Tracker, https://github.com/alberta-buck/alberta-buck/issues
9
+ Keywords: ethereum,stablecoin,simulation,web3
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: web3>=7
13
+ Requires-Dist: alberta-buck-contracts>=0.1.0
14
+ Provides-Extra: kernel
15
+ Requires-Dist: alberta-buck-kernel>=0.1.0; extra == "kernel"
16
+
17
+ # alberta-buck-core
18
+
19
+ The Python side of the Alberta Buck platform: one testing API over every
20
+ EVM backend, with expectation checking and journaling.
21
+
22
+ - **`Web3Session`** -- the ChainSession API. Send, call and deploy against
23
+ anvil, a public testnet, or in-process pyrevm with the same code. Every
24
+ state-changing operation declares whether it is expected to succeed or
25
+ revert, so expectation mismatches are first-class results rather than
26
+ surprises.
27
+ - **Journal** -- an append-only JSONL record of every operation: tag, op,
28
+ sender, expectation, outcome, gas, tx hash, block, error. Journals are
29
+ auditable, diffable across backends *and across languages* (the
30
+ JavaScript platform writes the same schema), and replayable.
31
+ - **`load_artifact`** -- contract artifacts from a repo checkout's `out/`
32
+ when there is one, falling back to the installed
33
+ [`alberta-buck-contracts`](https://pypi.org/project/alberta-buck-contracts/)
34
+ otherwise, so an installed package can deploy a world with no checkout.
35
+
36
+ ## Install
37
+
38
+ ```sh
39
+ pip install alberta-buck-core
40
+ ```
41
+
42
+ The distribution is prefixed; the import is not:
43
+
44
+ ```python
45
+ from buck_core import Web3Session, Expect, load_artifact
46
+ ```
47
+
48
+ ## The compiled kernels are optional
49
+
50
+ `buck_core.buck_math`, `buck_core.buck_identity`, `buck_core.buck_wallet`
51
+ and `buck_core.buck_registry` are shims that delegate to
52
+ [`alberta-buck-kernel`](https://pypi.org/project/alberta-buck-kernel/) when
53
+ it is installed. This package is deliberately a pure-Python wheel: keeping
54
+ the binaries out means depending on the session API does not drag a
55
+ per-platform wheel matrix behind it.
56
+
57
+ In a repo checkout the built `.so` sits beside the shim and CPython prefers
58
+ the extension, so a freshly rebuilt kernel takes effect immediately.
59
+
60
+ ## Status
61
+
62
+ 0.1.0, prototype. Unaudited software for a monetary system, published so
63
+ the simulation and identity work can be reproduced and built on.
64
+
65
+ ## Licence
66
+
67
+ CAL-1.0 (Cryptographic Autonomy License v1.0). Beyond the usual copyleft,
68
+ CAL requires that anyone you provide this software's functionality to
69
+ receives their own data and is not locked out of it by cryptographic or
70
+ technical means. See
71
+ [LICENSING.md](https://github.com/alberta-buck/alberta-buck/blob/master/LICENSING.md).
72
+
73
+ Repository: <https://github.com/alberta-buck/alberta-buck>
@@ -0,0 +1,57 @@
1
+ # alberta-buck-core
2
+
3
+ The Python side of the Alberta Buck platform: one testing API over every
4
+ EVM backend, with expectation checking and journaling.
5
+
6
+ - **`Web3Session`** -- the ChainSession API. Send, call and deploy against
7
+ anvil, a public testnet, or in-process pyrevm with the same code. Every
8
+ state-changing operation declares whether it is expected to succeed or
9
+ revert, so expectation mismatches are first-class results rather than
10
+ surprises.
11
+ - **Journal** -- an append-only JSONL record of every operation: tag, op,
12
+ sender, expectation, outcome, gas, tx hash, block, error. Journals are
13
+ auditable, diffable across backends *and across languages* (the
14
+ JavaScript platform writes the same schema), and replayable.
15
+ - **`load_artifact`** -- contract artifacts from a repo checkout's `out/`
16
+ when there is one, falling back to the installed
17
+ [`alberta-buck-contracts`](https://pypi.org/project/alberta-buck-contracts/)
18
+ otherwise, so an installed package can deploy a world with no checkout.
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ pip install alberta-buck-core
24
+ ```
25
+
26
+ The distribution is prefixed; the import is not:
27
+
28
+ ```python
29
+ from buck_core import Web3Session, Expect, load_artifact
30
+ ```
31
+
32
+ ## The compiled kernels are optional
33
+
34
+ `buck_core.buck_math`, `buck_core.buck_identity`, `buck_core.buck_wallet`
35
+ and `buck_core.buck_registry` are shims that delegate to
36
+ [`alberta-buck-kernel`](https://pypi.org/project/alberta-buck-kernel/) when
37
+ it is installed. This package is deliberately a pure-Python wheel: keeping
38
+ the binaries out means depending on the session API does not drag a
39
+ per-platform wheel matrix behind it.
40
+
41
+ In a repo checkout the built `.so` sits beside the shim and CPython prefers
42
+ the extension, so a freshly rebuilt kernel takes effect immediately.
43
+
44
+ ## Status
45
+
46
+ 0.1.0, prototype. Unaudited software for a monetary system, published so
47
+ the simulation and identity work can be reproduced and built on.
48
+
49
+ ## Licence
50
+
51
+ CAL-1.0 (Cryptographic Autonomy License v1.0). Beyond the usual copyleft,
52
+ CAL requires that anyone you provide this software's functionality to
53
+ receives their own data and is not locked out of it by cryptographic or
54
+ technical means. See
55
+ [LICENSING.md](https://github.com/alberta-buck/alberta-buck/blob/master/LICENSING.md).
56
+
57
+ Repository: <https://github.com/alberta-buck/alberta-buck>
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: alberta-buck-core
3
+ Version: 0.1.0
4
+ Summary: Alberta Buck core platform (Python): the ChainSession API over anvil/testnets/pyrevm with expectation journaling, and the Foundry artifact loader
5
+ Author-email: Perry Kundert <perry@dominionrnd.com>
6
+ License-Expression: CAL-1.0
7
+ Project-URL: Homepage, https://github.com/alberta-buck/alberta-buck
8
+ Project-URL: Bug Tracker, https://github.com/alberta-buck/alberta-buck/issues
9
+ Keywords: ethereum,stablecoin,simulation,web3
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: web3>=7
13
+ Requires-Dist: alberta-buck-contracts>=0.1.0
14
+ Provides-Extra: kernel
15
+ Requires-Dist: alberta-buck-kernel>=0.1.0; extra == "kernel"
16
+
17
+ # alberta-buck-core
18
+
19
+ The Python side of the Alberta Buck platform: one testing API over every
20
+ EVM backend, with expectation checking and journaling.
21
+
22
+ - **`Web3Session`** -- the ChainSession API. Send, call and deploy against
23
+ anvil, a public testnet, or in-process pyrevm with the same code. Every
24
+ state-changing operation declares whether it is expected to succeed or
25
+ revert, so expectation mismatches are first-class results rather than
26
+ surprises.
27
+ - **Journal** -- an append-only JSONL record of every operation: tag, op,
28
+ sender, expectation, outcome, gas, tx hash, block, error. Journals are
29
+ auditable, diffable across backends *and across languages* (the
30
+ JavaScript platform writes the same schema), and replayable.
31
+ - **`load_artifact`** -- contract artifacts from a repo checkout's `out/`
32
+ when there is one, falling back to the installed
33
+ [`alberta-buck-contracts`](https://pypi.org/project/alberta-buck-contracts/)
34
+ otherwise, so an installed package can deploy a world with no checkout.
35
+
36
+ ## Install
37
+
38
+ ```sh
39
+ pip install alberta-buck-core
40
+ ```
41
+
42
+ The distribution is prefixed; the import is not:
43
+
44
+ ```python
45
+ from buck_core import Web3Session, Expect, load_artifact
46
+ ```
47
+
48
+ ## The compiled kernels are optional
49
+
50
+ `buck_core.buck_math`, `buck_core.buck_identity`, `buck_core.buck_wallet`
51
+ and `buck_core.buck_registry` are shims that delegate to
52
+ [`alberta-buck-kernel`](https://pypi.org/project/alberta-buck-kernel/) when
53
+ it is installed. This package is deliberately a pure-Python wheel: keeping
54
+ the binaries out means depending on the session API does not drag a
55
+ per-platform wheel matrix behind it.
56
+
57
+ In a repo checkout the built `.so` sits beside the shim and CPython prefers
58
+ the extension, so a freshly rebuilt kernel takes effect immediately.
59
+
60
+ ## Status
61
+
62
+ 0.1.0, prototype. Unaudited software for a monetary system, published so
63
+ the simulation and identity work can be reproduced and built on.
64
+
65
+ ## Licence
66
+
67
+ CAL-1.0 (Cryptographic Autonomy License v1.0). Beyond the usual copyleft,
68
+ CAL requires that anyone you provide this software's functionality to
69
+ receives their own data and is not locked out of it by cryptographic or
70
+ technical means. See
71
+ [LICENSING.md](https://github.com/alberta-buck/alberta-buck/blob/master/LICENSING.md).
72
+
73
+ Repository: <https://github.com/alberta-buck/alberta-buck>
@@ -0,0 +1,20 @@
1
+ README.md
2
+ pyproject.toml
3
+ alberta_buck_core.egg-info/PKG-INFO
4
+ alberta_buck_core.egg-info/SOURCES.txt
5
+ alberta_buck_core.egg-info/dependency_links.txt
6
+ alberta_buck_core.egg-info/requires.txt
7
+ alberta_buck_core.egg-info/top_level.txt
8
+ buck_core/__init__.py
9
+ buck_core/artifacts.py
10
+ buck_core/buck_identity.py
11
+ buck_core/buck_math.py
12
+ buck_core/buck_registry.py
13
+ buck_core/buck_wallet.py
14
+ buck_core/session.py
15
+ tests/test_identity_vectors.py
16
+ tests/test_journal_fixture.py
17
+ tests/test_math_vectors.py
18
+ tests/test_registry_vectors.py
19
+ tests/test_session.py
20
+ tests/test_wallet_vectors.py
@@ -0,0 +1,5 @@
1
+ web3>=7
2
+ alberta-buck-contracts>=0.1.0
3
+
4
+ [kernel]
5
+ alberta-buck-kernel>=0.1.0
@@ -0,0 +1,19 @@
1
+ """Alberta Buck core platform (Python).
2
+
3
+ See alberta-buck-platform.org for the architecture. Layer 1 lives here
4
+ today: the ChainSession API (buck_core.session) and the Foundry artifact
5
+ helpers (buck_core.artifacts). Layer 2 kernels (buck-math, buck-identity)
6
+ arrive as PyO3 bindings re-exported from this package.
7
+
8
+ Dependency rule: buck_core never imports alberta_buck.
9
+ """
10
+
11
+ from buck_core.artifacts import load_artifact, repo_root
12
+ from buck_core.session import (
13
+ CALL_GAS, DEPLOY_GAS, Expect, Journal, Web3Session,
14
+ )
15
+
16
+ __all__ = [
17
+ "CALL_GAS", "DEPLOY_GAS", "Expect", "Journal", "Web3Session",
18
+ "load_artifact", "repo_root",
19
+ ]
@@ -0,0 +1,68 @@
1
+ """Foundry artifact + repo-checkout helpers.
2
+
3
+ Lifted verbatim from alberta_buck/sim/chain.py (which now re-exports these
4
+ names) so that core never imports alberta_buck; see alberta-buck-platform.org.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ import os
11
+ from pathlib import Path
12
+
13
+
14
+ def repo_root() -> Path:
15
+ """The repository checkout root -- needed for the Foundry artifacts
16
+ (out/) and contract sources the live-EVM helpers consume.
17
+
18
+ Resolution order: the ``ALBERTA_BUCK_REPO`` env var; walking up from this
19
+ file (a repo checkout / editable install); walking up from the cwd (a
20
+ venv-installed package run from inside the repo). ``foundry.toml`` is
21
+ the marker. Raises FileNotFoundError when no repo is reachable -- the
22
+ fixture-only paths (package data) do not need one.
23
+ """
24
+ env = os.environ.get("ALBERTA_BUCK_REPO")
25
+ candidates = ([Path(env)] if env else []) + [
26
+ Path(__file__).resolve(), Path.cwd().resolve()]
27
+ for start in candidates:
28
+ for p in (start, *start.parents):
29
+ if (p / "foundry.toml").exists():
30
+ return p
31
+ raise FileNotFoundError(
32
+ "alberta-buck repo root not found (looked for foundry.toml from "
33
+ f"{[str(c) for c in candidates]}); set ALBERTA_BUCK_REPO or run "
34
+ "from inside the repo checkout")
35
+
36
+
37
+ def load_artifact(name: str, sol_file: str | None = None) -> tuple[list, str]:
38
+ """Return (abi, bytecode) for a contract.
39
+
40
+ Resolution order:
41
+
42
+ 1. ``out/<sol_file or name>.sol/<name>.json`` in a repo checkout -- the
43
+ developer path, unchanged: a freshly built artifact always wins, so
44
+ editing a contract and rebuilding takes effect immediately.
45
+ 2. the installed ``alberta-buck-contracts`` package.
46
+
47
+ The fallback is what lets a pip-installed ``alberta_buck`` deploy a
48
+ world at all: ``repo_root()`` raises ``FileNotFoundError`` when no
49
+ ``foundry.toml`` is reachable, so without it an installed package could
50
+ import fine and then fail on its first deploy (see
51
+ alberta-buck-deployment.org, P2.5).
52
+ """
53
+ try:
54
+ f = repo_root() / "out" / f"{sol_file or name}.sol" / f"{name}.json"
55
+ art = json.loads(f.read_text())
56
+ return art["abi"], art["bytecode"]["object"]
57
+ except (FileNotFoundError, OSError):
58
+ pass
59
+
60
+ try:
61
+ import buck_contracts
62
+ except ImportError:
63
+ raise FileNotFoundError(
64
+ f"no artifact for {name}: not in a repo checkout with out/ built "
65
+ f"(run `make build`), and alberta-buck-contracts is not installed "
66
+ f"(pip install alberta-buck-contracts)") from None
67
+
68
+ return buck_contracts.artifact(name)
@@ -0,0 +1,20 @@
1
+ """Compatibility shim: ``buck_core.buck_identity`` -> ``buck_kernel.buck_identity``.
2
+
3
+ The compiled kernels moved out of this package so that alberta-buck-core
4
+ can be a pure-Python wheel -- otherwise every consumer of the session and
5
+ journal API would drag the whole Rust wheel matrix behind it. They now
6
+ ship separately as alberta-buck-kernel.
7
+
8
+ Callers keep saying ``import buck_core.buck_identity``. In a repo checkout the
9
+ built ``buck_identity.so`` sits beside this file and CPython prefers the
10
+ extension, so a freshly rebuilt kernel wins. Installed from wheels there
11
+ is no .so here and this shim delegates. When alberta-buck-kernel is not
12
+ installed the ImportError is exactly what the backend selector in
13
+ alberta_buck.wallet._kernel expects: it falls back to pure Python.
14
+ """
15
+
16
+ import sys
17
+
18
+ from buck_kernel import buck_identity as _mod
19
+
20
+ sys.modules[__name__] = _mod
@@ -0,0 +1,20 @@
1
+ """Compatibility shim: ``buck_core.buck_math`` -> ``buck_kernel.buck_math``.
2
+
3
+ The compiled kernels moved out of this package so that alberta-buck-core
4
+ can be a pure-Python wheel -- otherwise every consumer of the session and
5
+ journal API would drag the whole Rust wheel matrix behind it. They now
6
+ ship separately as alberta-buck-kernel.
7
+
8
+ Callers keep saying ``import buck_core.buck_math``. In a repo checkout the
9
+ built ``buck_math.so`` sits beside this file and CPython prefers the
10
+ extension, so a freshly rebuilt kernel wins. Installed from wheels there
11
+ is no .so here and this shim delegates. When alberta-buck-kernel is not
12
+ installed the ImportError is exactly what the backend selector in
13
+ alberta_buck.wallet._kernel expects: it falls back to pure Python.
14
+ """
15
+
16
+ import sys
17
+
18
+ from buck_kernel import buck_math as _mod
19
+
20
+ sys.modules[__name__] = _mod
@@ -0,0 +1,20 @@
1
+ """Compatibility shim: ``buck_core.buck_registry`` -> ``buck_kernel.buck_registry``.
2
+
3
+ The compiled kernels moved out of this package so that alberta-buck-core
4
+ can be a pure-Python wheel -- otherwise every consumer of the session and
5
+ journal API would drag the whole Rust wheel matrix behind it. They now
6
+ ship separately as alberta-buck-kernel.
7
+
8
+ Callers keep saying ``import buck_core.buck_registry``. In a repo checkout the
9
+ built ``buck_registry.so`` sits beside this file and CPython prefers the
10
+ extension, so a freshly rebuilt kernel wins. Installed from wheels there
11
+ is no .so here and this shim delegates. When alberta-buck-kernel is not
12
+ installed the ImportError is exactly what the backend selector in
13
+ alberta_buck.wallet._kernel expects: it falls back to pure Python.
14
+ """
15
+
16
+ import sys
17
+
18
+ from buck_kernel import buck_registry as _mod
19
+
20
+ sys.modules[__name__] = _mod
@@ -0,0 +1,20 @@
1
+ """Compatibility shim: ``buck_core.buck_wallet`` -> ``buck_kernel.buck_wallet``.
2
+
3
+ The compiled kernels moved out of this package so that alberta-buck-core
4
+ can be a pure-Python wheel -- otherwise every consumer of the session and
5
+ journal API would drag the whole Rust wheel matrix behind it. They now
6
+ ship separately as alberta-buck-kernel.
7
+
8
+ Callers keep saying ``import buck_core.buck_wallet``. In a repo checkout the
9
+ built ``buck_wallet.so`` sits beside this file and CPython prefers the
10
+ extension, so a freshly rebuilt kernel wins. Installed from wheels there
11
+ is no .so here and this shim delegates. When alberta-buck-kernel is not
12
+ installed the ImportError is exactly what the backend selector in
13
+ alberta_buck.wallet._kernel expects: it falls back to pure Python.
14
+ """
15
+
16
+ import sys
17
+
18
+ from buck_kernel import buck_wallet as _mod
19
+
20
+ sys.modules[__name__] = _mod