Initial commit
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled
This commit is contained in:
50
libs/policy/utils.py
Normal file
50
libs/policy/utils.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""Utility functions for policy management."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..schemas import CompiledCoveragePolicy, CoveragePolicy, ValidationResult
|
||||
from .loader import PolicyLoader
|
||||
|
||||
# Global policy loader instance
|
||||
_policy_loader: PolicyLoader | None = None
|
||||
|
||||
|
||||
def get_policy_loader(config_dir: str = "config") -> PolicyLoader:
|
||||
"""Get global policy loader instance"""
|
||||
global _policy_loader
|
||||
if _policy_loader is None:
|
||||
_policy_loader = PolicyLoader(config_dir)
|
||||
return _policy_loader
|
||||
|
||||
|
||||
# Convenience functions
|
||||
def load_policy(
|
||||
baseline_path: str | None = None,
|
||||
jurisdiction: str = "UK",
|
||||
tax_year: str = "2024-25",
|
||||
tenant_id: str | None = None,
|
||||
) -> CoveragePolicy:
|
||||
"""Load coverage policy with overlays"""
|
||||
return get_policy_loader().load_policy(
|
||||
baseline_path, jurisdiction, tax_year, tenant_id
|
||||
)
|
||||
|
||||
|
||||
def merge_overlays(base: dict[str, Any], *overlays: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Merge base policy with overlays"""
|
||||
return get_policy_loader().merge_overlays(base, *overlays)
|
||||
|
||||
|
||||
def apply_feature_flags(policy: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Apply feature flags to policy"""
|
||||
return get_policy_loader().apply_feature_flags(policy)
|
||||
|
||||
|
||||
def compile_predicates(policy: CoveragePolicy) -> CompiledCoveragePolicy:
|
||||
"""Compile policy predicates"""
|
||||
return get_policy_loader().compile_predicates(policy)
|
||||
|
||||
|
||||
def validate_policy(policy_dict: dict[str, Any]) -> ValidationResult:
|
||||
"""Validate policy"""
|
||||
return get_policy_loader().validate_policy(policy_dict)
|
||||
Reference in New Issue
Block a user