20 lines
943 B
Python
20 lines
943 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
def rebuild_candidate(cdsl: dict[str, Any], output: Path) -> dict[str, Any]:
|
|
from engine.cdsl_engine.runtime import analyze_cdsl, rebuild_cdsl
|
|
analysis = analyze_cdsl(cdsl)
|
|
analysis_dict = analysis.as_dict() if hasattr(analysis, "as_dict") else {"runtime_eligible": analysis.runtime_eligible}
|
|
if not analysis.runtime_eligible:
|
|
return {"status": "runtime_ineligible", "analysis": analysis_dict}
|
|
try:
|
|
result = rebuild_cdsl(cdsl, output, strict=True)
|
|
return {"status": "rebuilt", "analysis": analysis_dict, "result": result}
|
|
except Exception as exc:
|
|
detail = {"type": type(exc).__name__, "message": str(exc)}
|
|
if hasattr(exc, "selector_resolutions"): detail["selector_resolutions"] = exc.selector_resolutions
|
|
return {"status": "rebuild_failed", "analysis": analysis_dict, "error": detail}
|