Reduce machine max MCP response size
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import copy
|
||||
import inspect
|
||||
import sys
|
||||
import types
|
||||
@@ -21,6 +22,7 @@ from rollcalc_mcp_tools import (
|
||||
calculate_roll_diameter_result,
|
||||
get_article_result,
|
||||
get_machine_result,
|
||||
project_machine_max_product_length_result,
|
||||
search_articles_result,
|
||||
)
|
||||
from machine_constraints import (
|
||||
@@ -103,7 +105,7 @@ class McpAdapterTests(unittest.TestCase):
|
||||
"feasible_with_warnings",
|
||||
)
|
||||
|
||||
def test_machine_maximum_length_adapter_delegates_to_shared_domain(self):
|
||||
def test_machine_maximum_length_adapter_projects_success_without_mutating_domain(self):
|
||||
arguments = {
|
||||
"machine": "K7",
|
||||
"core_diameter_mm": 133.0,
|
||||
@@ -112,10 +114,79 @@ class McpAdapterTests(unittest.TestCase):
|
||||
"product_width_m": 6.0,
|
||||
"area_weight_g_m2": 495.395833,
|
||||
}
|
||||
domain_result = calculate_machine_max_product_length(**arguments)
|
||||
domain_before_projection = copy.deepcopy(domain_result)
|
||||
|
||||
result = project_machine_max_product_length_result(domain_result)
|
||||
|
||||
self.assertEqual(domain_result, domain_before_projection)
|
||||
self.assertIn("final_feasibility", domain_result)
|
||||
self.assertNotIn("final_feasibility", result)
|
||||
self.assertEqual(
|
||||
calculate_machine_max_product_length_result(**arguments),
|
||||
calculate_machine_max_product_length(**arguments),
|
||||
calculate_machine_max_product_length_result(**arguments), result
|
||||
)
|
||||
self.assertEqual(result["machine"], {"id": "k7", "name": "K7"})
|
||||
self.assertEqual(result["weight_scope"], "material_only")
|
||||
self.assertEqual(result["machine_limits"], {
|
||||
"maximum_roll_diameter_mm": 1100.0,
|
||||
"maximum_material_roll_weight_kg": 700.0,
|
||||
})
|
||||
self.assertEqual(result["production_maximums"], {
|
||||
"nominal_length_m": 217.1900177447768,
|
||||
"nominal_governing_constraints": ["roll_diameter_nominal"],
|
||||
"conservative_length_m": 194.62073281485985,
|
||||
"conservative_governing_constraints": ["roll_diameter_conservative"],
|
||||
})
|
||||
self.assertEqual(result["material_weights_kg"], {
|
||||
"at_nominal_production_maximum": 645.570178559751,
|
||||
"at_conservative_production_maximum": 578.4858003113276,
|
||||
})
|
||||
self.assertEqual(result["warnings"], {"nominal": ["roll_diameter_mm"]})
|
||||
|
||||
def test_machine_maximum_length_adapter_preserves_non_success_diagnostics(self):
|
||||
base = {
|
||||
"machine": "K7",
|
||||
"core_diameter_mm": 133.0,
|
||||
"thickness_mm": 4.311611,
|
||||
"thickness_stddev_mm": 0.249999,
|
||||
"product_width_m": 6.0,
|
||||
"area_weight_g_m2": 495.395833,
|
||||
}
|
||||
for changes, status in (
|
||||
({"core_diameter_mm": 194.0}, "incompatible"),
|
||||
({"product_width_m": 3.0}, "incompatible"),
|
||||
(
|
||||
{"product_width_m": None, "area_weight_g_m2": None},
|
||||
"needs_clarification",
|
||||
),
|
||||
({"thickness_mm": -1.0}, "invalid_parameter"),
|
||||
({"machine": "not configured"}, "machine_not_found"),
|
||||
):
|
||||
with self.subTest(changes=changes):
|
||||
arguments = {**base, **changes}
|
||||
domain_result = calculate_machine_max_product_length(**arguments)
|
||||
adapter_result = calculate_machine_max_product_length_result(**arguments)
|
||||
self.assertEqual(adapter_result, domain_result)
|
||||
self.assertEqual(adapter_result["status"], status)
|
||||
|
||||
missing = calculate_machine_max_product_length_result(
|
||||
**{**base, "product_width_m": None, "area_weight_g_m2": None}
|
||||
)
|
||||
self.assertEqual(
|
||||
missing["missing_required_inputs"],
|
||||
["product_width_m", "area_weight_g_m2"],
|
||||
)
|
||||
core = calculate_machine_max_product_length_result(
|
||||
**{**base, "core_diameter_mm": 194.0}
|
||||
)
|
||||
self.assertEqual(
|
||||
core["failed_compatibility_constraints"],
|
||||
["allowed_core_diameters_mm"],
|
||||
)
|
||||
width = calculate_machine_max_product_length_result(
|
||||
**{**base, "product_width_m": 3.0}
|
||||
)
|
||||
self.assertEqual(width["failed_compatibility_constraints"], ["product_width_m"])
|
||||
|
||||
def test_material_weight_adapter_delegates_without_a_core_diameter(self):
|
||||
arguments = {
|
||||
|
||||
Reference in New Issue
Block a user