From 5a9d9205c88dba4984d9ddd3d386df0278fd4d26 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Jan 2026 17:25:17 +0000 Subject: [PATCH] Fix Lexecon CLI server startup and enable model_governance_pack import - Add __init__.py to model_governance_pack to make it a proper Python package - Update pyproject.toml to include model_governance_pack in package distribution - Fix RiskScoringEngine to handle missing RiskLevel enum gracefully with fallback thresholds - Resolves AttributeError when starting the Lexecon API server This enables the full Lexecon CLI functionality including: - lexecon init (initialize nodes with cryptographic keys) - lexecon server (start API server) - lexecon decide (make governance decisions) - lexecon load-policy (load policy files) - lexecon verify-ledger (verify ledger integrity) --- model_governance_pack/__init__.py | 7 +++++++ pyproject.toml | 3 ++- src/lexecon/risk/service.py | 23 ++++++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 model_governance_pack/__init__.py diff --git a/model_governance_pack/__init__.py b/model_governance_pack/__init__.py new file mode 100644 index 0000000..3d2f776 --- /dev/null +++ b/model_governance_pack/__init__.py @@ -0,0 +1,7 @@ +""" +Model Governance Pack + +Canonical governance models and schemas for the Lexecon protocol. +""" + +__version__ = "0.1.0" diff --git a/pyproject.toml b/pyproject.toml index c85cfe7..ef95836 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,8 @@ Issues = "https://github.com/Lexicoding-systems/Lexecon/issues" lexecon = "lexecon.cli.main:cli" [tool.setuptools.packages.find] -where = ["src"] +where = ["src", "."] +include = ["lexecon*", "model_governance_pack*"] [tool.pytest.ini_options] testpaths = ["tests"] diff --git a/src/lexecon/risk/service.py b/src/lexecon/risk/service.py index 37cfeed..03bac46 100644 --- a/src/lexecon/risk/service.py +++ b/src/lexecon/risk/service.py @@ -80,13 +80,22 @@ class RiskScoringEngine: "financial": 0.10, } - # Risk level thresholds - RISK_THRESHOLDS = { - RiskLevel.CRITICAL: 80, # >= 80 - RiskLevel.HIGH: 60, # 60-79 - RiskLevel.MEDIUM: 30, # 30-59 - RiskLevel.LOW: 0, # 0-29 - } + # Risk level thresholds (defined conditionally to avoid import errors) + if GOVERNANCE_MODELS_AVAILABLE: + RISK_THRESHOLDS = { + RiskLevel.CRITICAL: 80, # >= 80 + RiskLevel.HIGH: 60, # 60-79 + RiskLevel.MEDIUM: 30, # 30-59 + RiskLevel.LOW: 0, # 0-29 + } + else: + # Fallback thresholds using string keys + RISK_THRESHOLDS = { + "critical": 80, + "high": 60, + "medium": 30, + "low": 0, + } def __init__(self, weights: Optional[Dict[str, float]] = None): """