wip: preserve local engine and agent workflow changes before ganjihong refactor integration

This commit is contained in:
2026-09-09 17:08:24 +08:00
parent a5c3ec1f36
commit 387b99e255
112 changed files with 3543 additions and 12177 deletions
+17 -3
View File
@@ -47,7 +47,7 @@ def _read_schema_document(path_value: str, modified_ns: int) -> dict[str, Any]:
except (OSError, json.JSONDecodeError) as error:
raise RuntimeError("The local engine schema document is unavailable or invalid") from error
if not isinstance(schema, dict) or not isinstance(schema.get("operation_contracts"), dict):
raise RuntimeError("The local engine schema has no v3 operation contract registry")
raise RuntimeError("The local engine schema has no operation contract registry")
return schema
@@ -108,10 +108,11 @@ def _validate_cdsl_json_schema(cdsl: dict[str, Any], engine: Any) -> None:
raise ValueError(f"CDSL schema violation at {location}: {error.message}")
def validate_cdsl(cdsl: dict[str, Any], engine: Any) -> None:
def validate_cdsl_shape(cdsl: dict[str, Any], engine: Any) -> None:
"""Validate the static Runtime CDSL contract without resolving topology."""
if not isinstance(cdsl, dict):
raise ValueError("CDSL must be a JSON object")
if cdsl.get("schema") != "cad.cdsl.llm.v1":
if cdsl.get("schema") not in {"cad.cdsl.llm.v1", "cad.runtime.v1"}:
raise ValueError("Unsupported CDSL schema")
_validate_cdsl_json_schema(cdsl, engine)
part_id = str(cdsl.get("part_id") or "")
@@ -125,6 +126,14 @@ def validate_cdsl(cdsl: dict[str, Any], engine: Any) -> None:
sketches = cdsl.get("geometry", {}).get("sketches")
if not isinstance(features, list) or not features or not isinstance(sketches, list):
raise ValueError("CDSL requires a feature list and a geometry.sketches array")
if cdsl.get("schema") == "cad.runtime.v1":
bodies = cdsl.get("bodies")
if not isinstance(bodies, list) or not bodies:
raise ValueError("Runtime CDSL requires server-assigned bodies")
body_ids = [str(body.get("id") or "") for body in bodies if isinstance(body, dict)]
body_names = [str(body.get("name") or "") for body in bodies if isinstance(body, dict)]
if len(body_ids) != len(bodies) or len(body_ids) != len(set(body_ids)) or len(body_names) != len(set(body_names)):
raise ValueError("Runtime CDSL bodies must have unique server IDs and local names")
sketch_ids = {str(sketch.get("id")) for sketch in sketches}
semantic_contract = _engine_schema(engine)
try:
@@ -185,6 +194,11 @@ def validate_cdsl(cdsl: dict[str, Any], engine: Any) -> None:
raise ValueError("Polygon profiles require vertices")
elif profile_type not in engine.SHAPE_GENERATORS:
raise ValueError(f"Unsupported CDSL profile: {profile_type}")
def validate_cdsl(cdsl: dict[str, Any], engine: Any) -> None:
"""Validate static CDSL and the current executable topology semantics."""
validate_cdsl_shape(cdsl, engine)
try:
analysis = engine.analyze_cdsl(copy.deepcopy(cdsl))
except Exception as error: