test(performance): enforce semantic artifact authority boundary (#19)
CI / lite (push) Successful in 9s
CI / lite (push) Successful in 9s
This commit was merged in pull request #19.
This commit is contained in:
@@ -952,6 +952,37 @@ def test_architecture_dependency_no_copy_and_authority_boundaries() -> None:
|
||||
assert not any(name.startswith(("research_results", "research_platform")) for name in imports)
|
||||
for candidate in ("riskfolio", "pyp", "skfolio", "cvxportfolio"):
|
||||
assert candidate not in source.lower()
|
||||
artifact_source = (ROOT / "src" / "quant_engine" / "artifact.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
artifact_tree = ast.parse(artifact_source)
|
||||
forbidden_artifact_authority_symbols = {
|
||||
"PortfolioDecision",
|
||||
"RiskAssessment",
|
||||
"build_portfolio_decision",
|
||||
"assess_portfolio_risk",
|
||||
}
|
||||
artifact_imports = {
|
||||
alias.name
|
||||
for node in ast.walk(artifact_tree)
|
||||
if isinstance(node, ast.Import)
|
||||
for alias in node.names
|
||||
} | {
|
||||
node.module or ""
|
||||
for node in ast.walk(artifact_tree)
|
||||
if isinstance(node, ast.ImportFrom)
|
||||
}
|
||||
artifact_names = {
|
||||
node.id for node in ast.walk(artifact_tree) if isinstance(node, ast.Name)
|
||||
} | {
|
||||
node.attr for node in ast.walk(artifact_tree) if isinstance(node, ast.Attribute)
|
||||
}
|
||||
assert "quant_engine.portfolio_risk_contracts" not in artifact_imports
|
||||
assert not forbidden_artifact_authority_symbols & artifact_names
|
||||
assert all(
|
||||
token not in artifact_source
|
||||
for token in {"portfolio_risk_contracts", *forbidden_artifact_authority_symbols}
|
||||
)
|
||||
for owner_path in (
|
||||
ROOT / "src" / "quant_engine" / "governed_pipeline.py",
|
||||
ROOT / "src" / "quant_engine" / "artifact.py",
|
||||
@@ -989,7 +1020,6 @@ def test_architecture_dependency_no_copy_and_authority_boundaries() -> None:
|
||||
def test_read_only_owner_dependency_lock_and_ci_hashes_match_baseline() -> None:
|
||||
expected = {
|
||||
"src/quant_engine/governed_pipeline.py": "3b334f340898db78ed869375ab532f156e8c1fee595a8318f544bebdd391049d",
|
||||
"src/quant_engine/artifact.py": "e15feec412d3bfff10d8f21ca20813fc65cabc0703940371ed661896147bc379",
|
||||
"src/quant_engine/portfolio_construction.py": "e93d71da8d61b2047c19d4b99dace934a8cbc96d8d2b150ad62a9ceebd9163d4",
|
||||
"src/quant_engine/portfolio_decomp.py": "1a4f9f9aac2c46bf6ed2826d1b0d1723f06e3ce7c4b3f6479e098cbbd135bea6",
|
||||
"src/quant_engine/risk.py": "4a66c312d517d40f6f67bb71f438523e135645624ae78d49fa9c0fda2c02074e",
|
||||
|
||||
Reference in New Issue
Block a user