File size: 2,068 Bytes
67be617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Module Resolver — resolves and verifies import paths for the TIA backend."""

import importlib
import os
import sys

# Ensure project root is importable.
_PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
if _PROJECT_ROOT not in sys.path:
    sys.path.insert(0, _PROJECT_ROOT)

# Expected import paths → class names.
EXPECTED_IMPORTS = {
    "TIA.worker": "TIAWorker",
    "citadel.primeSchema": "PrimeSchema",
    "citadel.holo3d.ui.commandCentre": "CommandCentre",
    "citadel.lineage": "Lineage",
    "citadel.peace_vortex": "PeaceVortex",
    "citadel.alpha_nex": "AlphaNex",
    "harvester.washed_harvest": "WashedHarvest",
    "bio.vessel_firewall": "VesselFirewall",
}


def resolve(module_path: str, class_name: str):
    """Attempt to import *class_name* from *module_path*.



    Returns:

        The class object on success, or ``None`` on failure.

    """
    try:
        mod = importlib.import_module(module_path)
        return getattr(mod, class_name, None)
    except Exception:
        return None


def resolve_all() -> dict:
    """Resolve every expected import and return results.



    Returns:

        dict mapping ``"module.Class"`` to the resolved class or ``None``.

    """
    results = {}
    for mod_path, cls_name in EXPECTED_IMPORTS.items():
        cls = resolve(mod_path, cls_name)
        results[f"{mod_path}.{cls_name}"] = cls
    return results


def verify() -> bool:
    """Verify that all expected imports resolve successfully.



    Returns:

        ``True`` if every import resolved, ``False`` otherwise.

    """
    results = resolve_all()
    all_ok = all(v is not None for v in results.values())

    print("\n=== Module Resolver Verification ===\n")
    for key, cls in results.items():
        mark = "\u2705" if cls is not None else "\u274c"
        print(f"  {mark} {key}")
    print(f"\n  Result: {'ALL OK' if all_ok else 'SOME FAILED'}\n")
    return all_ok


if __name__ == "__main__":
    ok = verify()
    sys.exit(0 if ok else 1)