wip: preserve local engine and agent workflow changes before ganjihong refactor integration
This commit is contained in:
@@ -49,6 +49,55 @@ def plain(value: Any) -> Any:
|
||||
return value
|
||||
|
||||
|
||||
def _selector_intent(
|
||||
value: Any,
|
||||
*,
|
||||
query_family: str,
|
||||
kind: str,
|
||||
evidence: str,
|
||||
allowed: tuple[str, ...] = ("continuation",),
|
||||
multiplicity: str = "one",
|
||||
output_role: str | None = None,
|
||||
disambiguation: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Keep the source query as semantics, separate from runtime topology IDs."""
|
||||
query = parse_query(value)
|
||||
intent: dict[str, Any] = {
|
||||
"version": "1.0",
|
||||
"kind": kind,
|
||||
"query_family": query_family,
|
||||
# This placeholder is populated from the enclosing ModelIR once the
|
||||
# FeatureScript source header has been parsed.
|
||||
"source_query": {"ast": query.ast, "featurescript_version": "0"},
|
||||
"derivation_policy": {"allowed": list(allowed), "multiplicity": multiplicity},
|
||||
"evidence": evidence,
|
||||
}
|
||||
if query.source_sketch and query.source_entity:
|
||||
intent["source_entity"] = {"sketch_id": query.source_sketch, "entity_id": query.source_entity}
|
||||
if output_role is not None:
|
||||
intent["output_role"] = output_role
|
||||
if disambiguation is not None:
|
||||
intent["disambiguation"] = disambiguation
|
||||
return intent
|
||||
|
||||
|
||||
def _finalize_selector_intents(cdsl: dict[str, Any], model: ModelIR) -> None:
|
||||
"""Bind source-version metadata after all FeatureScript selectors lower."""
|
||||
source_version = model.featurescript_version or "0"
|
||||
for feature in cdsl.get("features") or []:
|
||||
for selector in feature.get("selectors") or []:
|
||||
intent = selector.get("selector_intent") if isinstance(selector, dict) else None
|
||||
if not isinstance(intent, dict):
|
||||
continue
|
||||
selector["selector_intent_version"] = "1.0"
|
||||
source_query = intent.get("source_query")
|
||||
if not isinstance(source_query, dict):
|
||||
continue
|
||||
source_query["featurescript_version"] = source_version
|
||||
if model.standard_library:
|
||||
source_query["standard_library"] = model.standard_library
|
||||
|
||||
|
||||
def _bool(value: Any) -> bool:
|
||||
return value is True or (isinstance(value, str) and value.lower() == "true")
|
||||
|
||||
@@ -573,6 +622,17 @@ def _shell_offset_face_output_role_selector(
|
||||
},
|
||||
"source": "runtime_snapshot",
|
||||
"confidence": 1.0,
|
||||
"selector_intent": _selector_intent(
|
||||
value,
|
||||
query_family="OFFSET_FACE",
|
||||
kind="face",
|
||||
evidence="operation_role",
|
||||
allowed=("boundary", "replacement"),
|
||||
output_role="shell.offset_face",
|
||||
disambiguation={"type": "true_dependency", "sources": [
|
||||
{"owner_feature_id": source["owner_feature_id"], "output_role": source["output_role"]},
|
||||
]},
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -1792,6 +1852,14 @@ def _cap_face_output_role_selector(
|
||||
"output_role": f"{role_prefix}.{'start' if query.is_start else 'end'}",
|
||||
"source": "runtime_snapshot",
|
||||
"confidence": 1.0,
|
||||
"selector_intent": _selector_intent(
|
||||
value,
|
||||
query_family="CAP_FACE",
|
||||
kind="face",
|
||||
evidence="operation_role",
|
||||
allowed=("boundary", "continuation"),
|
||||
output_role=f"{role_prefix}.{'start' if query.is_start else 'end'}",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -4800,6 +4868,8 @@ def lower_model(model: ModelIR, provenance: dict[str, Any]) -> LoweringResult:
|
||||
diagnostics.append({"code": "feature_deferred", "feature_id": item.feature_id, "operation": item.operation, "message": str(exc)}); complete = False
|
||||
if not features: return LoweringResult(None, "deferred_no_executable_feature", diagnostics, history)
|
||||
cdsl = {"schema": "cad.cdsl.llm.v1", "schema_version": "1.1.0", "kind": "part", "part_id": model.sample_id,
|
||||
"meta": {"unit": "mm", "source": "CADFS", "provenance": provenance, "capability_gaps": sorted({d.get("operation") for d in diagnostics if d.get("operation")})},
|
||||
"meta": {"unit": "mm", "source": "CADFS", "provenance": provenance, "capability_gaps": sorted({d.get("operation") for d in diagnostics if d.get("operation")}),
|
||||
"source_featurescript": {"version": model.featurescript_version or "0", **({"standard_library": model.standard_library} if model.standard_library else {})}},
|
||||
"geometry": {"sketches": sketches}, "features": features}
|
||||
_finalize_selector_intents(cdsl, model)
|
||||
return LoweringResult(cdsl, "converted_complete" if complete else "converted_partial", diagnostics, history)
|
||||
|
||||
Reference in New Issue
Block a user