Allow direct article resolution in machine max MCP

This commit is contained in:
2026-09-26 13:52:08 +02:00
parent eca151a465
commit 0c18c86a47
5 changed files with 154 additions and 13 deletions
+50 -4
View File
@@ -64,12 +64,48 @@ def calculate_machine_max_product_length_result(
*,
machine: str,
core_diameter_mm: float,
thickness_mm: float,
article_number: str | None = None,
thickness_mm: float | None = None,
thickness_stddev_mm: float | None = None,
product_width_m: float | None = None,
area_weight_g_m2: float | None = None,
) -> dict[str, Any]:
"""Return the compact MCP view of the machine-aware domain calculation."""
"""Return the compact MCP view, resolving one exact article when supplied."""
explicit_material = {
"thickness_mm": thickness_mm,
"thickness_stddev_mm": thickness_stddev_mm,
"product_width_m": product_width_m,
"area_weight_g_m2": area_weight_g_m2,
}
if article_number is not None:
mixed_fields = [
field for field, value in explicit_material.items() if value is not None
]
if mixed_fields:
return {
"status": "invalid_parameter",
"invalid": [{
"field": "article_number",
"message": (
"cannot be combined with explicit material properties: "
+ ", ".join(mixed_fields)
),
}],
}
article_result = get_article(article_number)
if article_result["status"] != "resolved":
return article_result
article = article_result["article"]
result = calculate_machine_max_product_length(
machine=machine,
core_diameter_mm=core_diameter_mm,
thickness_mm=article["thickness_mm"],
thickness_stddev_mm=article["thickness_stddev_mm"],
product_width_m=article["width_m"],
area_weight_g_m2=article["area_weight_g_m2"],
)
return project_machine_max_product_length_result(result, article=article)
result = calculate_machine_max_product_length(
machine=machine,
core_diameter_mm=core_diameter_mm,
@@ -81,7 +117,11 @@ def calculate_machine_max_product_length_result(
return project_machine_max_product_length_result(result)
def project_machine_max_product_length_result(result: dict[str, Any]) -> dict[str, Any]:
def project_machine_max_product_length_result(
result: dict[str, Any],
*,
article: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""Project successful maximum-length results for MCP without diagnostics.
The shared domain result deliberately contains detailed verification reports.
@@ -93,7 +133,7 @@ def project_machine_max_product_length_result(result: dict[str, Any]) -> dict[st
machine = result["machine"]
constraints = machine["constraints"]
return {
projection = {
"status": result["status"],
"machine": {"id": machine["id"], "name": machine["name"]},
"weight_scope": result["weight_scope"],
@@ -107,6 +147,12 @@ def project_machine_max_product_length_result(result: dict[str, Any]) -> dict[st
"material_weights_kg": result["material_weights_kg"],
"warnings": result["warnings"],
}
if article is not None:
projection["article"] = {
"number": article["number"],
"name": article["name"],
}
return projection
def calculate_material_weight_result(