59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def test_module_spec_declares_pure_research_engine_boundary() -> None:
|
|
spec = json.loads((ROOT / "MODULE_SPEC.yaml").read_text(encoding="utf-8"))
|
|
assert spec["module_id"] == "quant_engine"
|
|
assert spec["authority"]["subject"] == spec["module_id"]
|
|
assert spec["repository"]["type"] == "research_engine"
|
|
assert spec["bounded_context"]["domain"] == "quantitative-research-engine"
|
|
prohibited = " ".join(spec["bounded_context"]["prohibited_responsibilities"]).lower()
|
|
for term in ("investment advice", "live order", "credentials", "source facts"):
|
|
assert term in prohibited
|
|
assert spec["authority"]["revision"] == 3
|
|
assert {
|
|
(item["contract_id"], item["version"])
|
|
for item in spec["contracts"]["provides"]
|
|
} == {
|
|
("researchhub.factor-definition", "1.0.0"),
|
|
("researchhub.factor-set-ref", "1.0.0"),
|
|
("researchhub.backtest-run-ref", "1.0.0"),
|
|
("researchhub.backtest-evidence-manifest", "1.0.0"),
|
|
}
|
|
expected_paths = {
|
|
"researchhub.factor-definition": "src/quant_engine/factor_contracts.py",
|
|
"researchhub.factor-set-ref": "src/quant_engine/factor_contracts.py",
|
|
"researchhub.backtest-run-ref": "src/quant_engine/governed_pipeline.py",
|
|
"researchhub.backtest-evidence-manifest": "src/quant_engine/artifact.py",
|
|
}
|
|
assert all(item["authority"] == "quant_engine" for item in spec["contracts"]["provides"])
|
|
assert {
|
|
item["contract_id"]: item["path"] for item in spec["contracts"]["provides"]
|
|
} == expected_paths
|
|
assert {
|
|
(item["contract_id"], item["version"])
|
|
for item in spec["contracts"]["consumes"]
|
|
} == {
|
|
("researchhub.dataset-snapshot", "1.0.0"),
|
|
("researchhub.data-foundation", "1.0.0"),
|
|
}
|
|
assert all(
|
|
item["authority"] == "researchhub.data"
|
|
for item in spec["contracts"]["consumes"]
|
|
)
|
|
assert spec["dependencies"] == []
|
|
assert all(
|
|
command["required"] and not command["network"]
|
|
for command in spec["verification"]["commands"]
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_module_spec_declares_pure_research_engine_boundary()
|