B1: plm_engine takes the modules without a database (ADR-59)

HD derivation (pure part), PSBT builder, Electrum client/merkle/quorum/scripthash, network
profile, addresses and header checks move to plm_engine; the old stack imports them from
there. A test forbids framework imports in the package.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 15:31:47 +01:00
1 parent c9784efa07
commit 3ee60a23da
87 files changed
+290 -260

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
"""B1 — `plm_engine` is framework-free: it never imports Django, the old FastAPI stack or a database layer (ADR-59)."""
import ast
from pathlib import Path
import pytest
ENGINE = Path(__file__).resolve().parents[2] / "plm_engine"
FORBIDDEN = {"django", "apps", "app", "config", "sqlalchemy", "fastapi", "alembic"}
@pytest.mark.parametrize("path", sorted(ENGINE.rglob("*.py")), ids=lambda p: str(p.relative_to(ENGINE)))
def test_the_engine_imports_no_framework(path):
tree = ast.parse(path.read_text())
imported = set()
for node in ast.walk(tree):
if isinstance(node, ast.Import):
imported |= {alias.name.split(".")[0] for alias in node.names}
elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
imported.add(node.module.split(".")[0])
assert not imported & FORBIDDEN, f"{path.name} imports {sorted(imported & FORBIDDEN)}"
-11
View File
@@ -462,14 +462,3 @@ def test_the_round_secret_needs_the_right_key(settings):
settings.SECRET_KEY = "another-key-" + "y" * 50
with pytest.raises(RuntimeError):
decrypt_seed(token)
def test_the_old_draw_module_and_the_engine_share_one_implementation():
"""ADR-59: the primitives live once, in `plm_engine.draw`; the old module re-exports them."""
import plm_engine.draw as engine
from app.rounds import draw as old
for name in ("draw_seed", "draw_index", "draw_winner", "participants_hash", "new_server_seed",
"server_seed_commitment", "sha256_hex"):
assert getattr(old, name) is getattr(engine, name)
assert engine.sha256_hex(b"x") == hashlib.sha256(b"x").hexdigest()