diff --git a/docs/validation/integration-release-matrix.md b/docs/validation/integration-release-matrix.md index db3ff07..e1bc934 100644 --- a/docs/validation/integration-release-matrix.md +++ b/docs/validation/integration-release-matrix.md @@ -83,3 +83,16 @@ for the tested wheel and usage scope. The earlier cabinet QI1 outcomes remain unchanged. The paired drawer showcase revision retains source mapping, Chinese captions and synchronized displacement traces. Its final continuous-playback visual review remains pending. + +The public dev2 archive subsequently completed the same fixed first delivery +from an isolated installation with empty asset caches. The host acquired the +selected GSO object and notice, ran the physical and native video checks, and +submitted the independently reviewed result in 137.114 seconds with 37,388 +observed tokens. The package and receipt hashes are recorded in the +[dev2 release qualification](https://github.com/ros-claw/simscene/releases/download/v0.2.0-dev.2/release-qualification.json). + +## Worktop transfer + +The post-release worktop trials compare additional pinned props on the +released first-delivery support. Their measurement and historical physics +scope are documented in [worktop transfer](worktop-transfer.md). diff --git a/docs/validation/worktop-transfer.md b/docs/validation/worktop-transfer.md new file mode 100644 index 0000000..9361f58 --- /dev/null +++ b/docs/validation/worktop-transfer.md @@ -0,0 +1,56 @@ +# Reusing the first-delivery worktop + +The worktop transfer trials reuse the [released first-delivery +recipe](../../examples/first_delivery/README.md) with selected ABO and GSO +objects. The support is an editable, static collision-enabled box with a +horizontal 0.66 × 0.50 m top at 0.72 m. The trials use 240 steps at 60 Hz and +seed 42. Imported props use an explicit convex-hull profile and a 0.12 kg +experimental mass. The initial body height and the asset pins are frozen for +each pose before running. + +## Recorded trials + +| Tested prop | Observed XY envelope around worktop center | Vertical drop | Direct worktop callbacks | +| --- | ---: | ---: | ---: | +| GSO Ready-to-Use Rolled Fondant box | 90.7 × 240.4 mm | 234.8 mm | 24 (steps 13–36) | +| AmazonBasics Classic Blank Notebook | 89.5 × 150.0 mm | 232.5 mm | 25 (steps 12–36) | +| Crunch Girl Scouts Peanut Butter Creme carton | 151.1 × 149.1 mm | 234.8 mm | 24 (steps 13–36) | + +All three pinned runs passed their independent gravity, direct contact, final +bounds and settling checks. Profile parameters and raw run hashes are in the +observations. In the two transfer runs, the prepared prop was placed at the +measured center with a 232.5 mm bottom clearance. Both used the same support +and thresholds as the release trial after freezing the exact object pins and +its initial body-origin height. + +The first cold notebook catalog query exhausted its 12-second budget before +any model acquisition. A separate retry completed the metadata query within +45 seconds and produced the recorded notebook result. + +## Select for a measured support + +A build from the current source exposes the resource template + +```text +simscene://recipes/worktop-fit/{width_m}/{depth_m}/{edge_clearance_m} +``` + +For example, read `simscene://recipes/worktop-fit/0.30/0.24/0.02` to look for +poses that fit a 0.30 × 0.24 m usable rectangle with a 20 mm margin on every +edge. Use the measured unobstructed rectangle of a level, static support with +collision enabled. Width and depth follow the pose axes in the evidence. + +The filter compares this rectangle with the measured XY envelope around the +original worktop center. The envelope includes the initial and every recorded +physics sample for that pose. Matches retain the source revision, preparation +parameters and tested pose. The contact and settling entries refer to the +recorded worktop and run. Apply the recorded orientation and offset from +the usable rectangle center. If that rectangle is a subregion of the support, +convert the center and offset to the support-local coordinates used by +`place_on`. Confirm the placement with `scene_measure` and verify a new run. + +The filter runs locally and performs no catalog downloads. The checked-in +[observations](../../src/simscene/recipes/data/worktop-support.json) contain +finite cases with measured motion and support. The dev2 download provides the +original GSO first-delivery recipe. The fit resource is a post-release addition +to the source branch. diff --git a/skills/build-scene/references/measured-layout.md b/skills/build-scene/references/measured-layout.md index 9d73e17..d1bec5f 100644 --- a/skills/build-scene/references/measured-layout.md +++ b/skills/build-scene/references/measured-layout.md @@ -24,6 +24,14 @@ orientation before measuring. `avoid_ids`, `clearance_m`, and world metre `keepout_bounds:[{min:[x,y,z],max:[x,y,z]}]` reject reserved-space intrusion. This is geometric placement, not a dynamic stability proof. +If the server exposes the `simscene://recipes/worktop-fit/{width_m}/{depth_m}/{edge_clearance_m}` +resource template, read it before fetching candidates for a level, static +collision-enabled worktop. Use the measured usable rectangle and margin in +metres. The matches identify pinned props in a tested pose with recorded +worktop contact and settling. Apply the recorded orientation and offset from +the usable rectangle center. Express that placement in the support-local +coordinates for `place_on`, measure it, and verify a new physical run. + For repeatable sampled placement of 1–8 existing props, call `scene_plan_layout(scene_id, ids, support, support_surface, seed, clearance_m, gap_m, avoid_ids, keepout_bounds)`. Omit `support_surface` for a primitive box diff --git a/src/simscene/mcp_server.py b/src/simscene/mcp_server.py index bbf5885..c9a8da4 100644 --- a/src/simscene/mcp_server.py +++ b/src/simscene/mcp_server.py @@ -82,6 +82,15 @@ def fixed_examples_resource() -> str: from .recipes.registry import list_examples return json.dumps(list_examples(),ensure_ascii=False) +@server.resource('simscene://recipes/worktop-fit/{width_m}/{depth_m}/{edge_clearance_m}') +def worktop_fit_resource(width_m: str, depth_m: str, edge_clearance_m: str) -> str: + """Find recorded prop poses that fit a measured, level static worktop. Dimensions are metres.""" + import json + from .recipes.worktop_fit import worktop_fit + return json.dumps(worktop_fit(float(width_m), float(depth_m), float(edge_clearance_m)), + ensure_ascii=False, allow_nan=False) + + @server.resource('simscene://runtime/identity') def runtime_identity_resource() -> str: """Report this process's loaded package paths and local build identity.""" diff --git a/src/simscene/recipes/data/worktop-support.json b/src/simscene/recipes/data/worktop-support.json new file mode 100644 index 0000000..501b0e2 --- /dev/null +++ b/src/simscene/recipes/data/worktop-support.json @@ -0,0 +1,343 @@ +{ + "schema": "simscene.worktop_support_observations.v1", + "test_context": { + "release": "v0.2.0-dev.2", + "source_commit": "e5de299f7ebd17d0e3edb4761186fce6cba9ac81", + "wheel_sha256": "6d67d336785310b7440fbb442895d6fcc08c491a4e4a90ef38f1b3a6affa753e", + "runtime": { + "engine": "physx", + "isaac_version": "6.2.0-rc.14+release.52805.02189a84.gl", + "usd_version": "0.25.11", + "platform": "linux-x86_64" + }, + "steps": 240, + "physics_hz": 60, + "seed": 42, + "worktop_xy_m": [ + 0.66, + 0.5 + ], + "worktop_height_m": 0.72, + "gravity_drop_case": "rigid_asset_smoke", + "asset_mass_kg": 0.12, + "settle_window_s": 2, + "max_linear_m_s": 0.03, + "max_angular_rad_s": 0.3, + "footprint_scope": "Axis-aligned render bounds from the initial and every recorded physics sample." + }, + "observations": [ + { + "source_ref": { + "asset_id": "ReadytoUse_Rolled_Fondant_Pure_White_24_oz_box", + "revision": "75e8895e4f4e854cddd7009a7e60f86812041012", + "source_id": "gso-glb", + "variant_id": null + }, + "physics_passed": true, + "profile_id": "rigid_prop_v1", + "prepared_longest_extent_m": 0.12, + "pose_wxyz": [ + 0.7071067811865476, + 0.7071067811865476, + 0, + 0 + ], + "footprint": { + "initial_projected_xy_m": [ + 0.08656758299534002, + 0.12000000437840026 + ], + "final_xy_m": [ + 0.08687988308758417, + 0.1207773821953348 + ], + "centered_xy_envelope_m": [ + 0.09070674850298123, + 0.2403997324135836 + ], + "final_edge_margins_xy_m": [ + 0.28622192004491254, + 0.13013393239157892 + ], + "final_full_bounds_in_case_envelope": true + }, + "support": { + "kind": "horizontal_static_primitive_box", + "worktop_xy_m": [ + 0.66, + 0.5 + ], + "worktop_height_m": 0.7200000000000001, + "case_target_bounds_m": { + "max": [ + 0.27, + 0.21, + 0.83 + ], + "min": [ + -0.27, + -0.21, + 0.704 + ] + }, + "initial_bottom_clearance_m": 0.23251208423691094, + "vertical_displacement_m": 0.2348232865333557, + "minimum_displacement_m": 0.18, + "direct_worktop_contact": true, + "contact_in_recorded_steps": { + "count": 24, + "first_physics_step": 13, + "last_physics_step": 36, + "actor_pair": [ + "/World/box/Asset/Body", + "/World/table" + ] + }, + "settled": true, + "settling": { + "window_observed_s": 1.983333333333333, + "max_linear_m_s": 0.0, + "max_angular_rad_s": 2.528810910653651e-06, + "window_requested_s": 2.0, + "linear_limit_m_s": 0.03, + "angular_limit_rad_s": 0.3 + } + }, + "title": "GSO Ready-to-Use Rolled Fondant box", + "prepared_parameters": { + "ccd": true, + "collision_method": "convex_hull", + "dynamic_friction": 0.5, + "mass_kg": 0.12, + "mass_note": "Experimental120mm scaled scanned box/.12kg assumption; not manufacturer values.", + "proxy_tolerance_m": 0.002, + "restitution": 0.05, + "scale_mode": "fit_longest", + "source_physics_policy": "reject_if_physics", + "static_friction": 0.6, + "target_longest_extent_m": 0.12 + }, + "source_model_sha256": "5454424606ed780b806c99a5a3ffc0f4b0b9ade2fc9afa9c63fbf932ea187949", + "license": "CC-BY-4.0", + "outcome": "passed", + "case_sha256": "d6d84fc232b8f672fc0d3cd70c528b5673672f463666f22f94ed105fec9b034a", + "physics_check_sha256": "213ac625877a90a8e682ba2dc3fbeb647af5514685637b4ec1c2992fa9d28679", + "run_lock_sha256": "bad59c8f9fc859ea4a260c3886de6d5a3b3acbd000b585a1194261fe55297be0", + "run_result_sha256": "442f32b8e50ede387387ff907e21a5d9dface93f4e1c8f09b77c117a9cd47e4b", + "tested_bottom_center_offset_xy_m": [ + -0.00016044156045147417, + -0.060002845261450784 + ] + }, + { + "source_ref": { + "asset_id": "B01DN8TB5U", + "revision": "c7c8293fed3b7ab122ef5d7896521a187e0962d7", + "source_id": "abo-glb", + "variant_id": null + }, + "physics_passed": true, + "profile_id": "rigid_prop_v1", + "prepared_longest_extent_m": 0.15, + "pose_wxyz": [ + 0.7071067811865476, + 0.7071067811865476, + 0.0, + 0.0 + ], + "footprint": { + "initial_projected_xy_m": [ + 0.08951384263310863, + 0.14999999766762728 + ], + "final_xy_m": [ + 0.08951452343483639, + 0.15001341947083435 + ], + "centered_xy_envelope_m": [ + 0.0895167191018613, + 0.1500267256224101 + ], + "final_edge_margins_xy_m": [ + 0.2852416429432234, + 0.17498663798697206 + ], + "final_full_bounds_in_case_envelope": true + }, + "support": { + "kind": "horizontal_static_primitive_box", + "worktop_xy_m": [ + 0.66, + 0.5 + ], + "worktop_height_m": 0.7200000000000001, + "case_target_bounds_m": { + "max": [ + 0.27, + 0.21, + 0.83 + ], + "min": [ + -0.27, + -0.21, + 0.704 + ] + }, + "initial_bottom_clearance_m": 0.23249999999999982, + "vertical_displacement_m": 0.23249882459640503, + "minimum_displacement_m": 0.18, + "direct_worktop_contact": true, + "contact_in_recorded_steps": { + "count": 25, + "first_physics_step": 12, + "last_physics_step": 36, + "actor_pair": [ + "/World/box/Asset/Body", + "/World/table" + ] + }, + "settled": true, + "settling": { + "window_observed_s": 1.983333333333333, + "max_linear_m_s": 0.0, + "max_angular_rad_s": 0.0, + "window_requested_s": 2.0, + "linear_limit_m_s": 0.03, + "angular_limit_rad_s": 0.3 + } + }, + "title": "AmazonBasics Classic Blank Notebook", + "prepared_parameters": { + "ccd": true, + "collision_method": "convex_hull", + "dynamic_friction": 0.5, + "mass_kg": 0.12, + "mass_note": "Matched 0.12 kg experimental worktop drop; no manufacturer mass claim.", + "proxy_tolerance_m": 0.002, + "restitution": 0.05, + "scale_mode": "fit_longest", + "source_physics_policy": "reject_if_physics", + "static_friction": 0.6, + "target_longest_extent_m": 0.15 + }, + "source_model_sha256": "67d61db31084d820ca9b1b0d2d3761662f6a5532944573afceee8f57c8151845", + "license": "CC-BY-4.0", + "outcome": "passed", + "case_sha256": "133377e8531c86e5ff5660324305aee65772d52aa270a183bb33a363a8fd4b20", + "physics_check_sha256": "213ac625877a90a8e682ba2dc3fbeb647af5514685637b4ec1c2992fa9d28679", + "run_lock_sha256": "8fcb302c8da33235e6c34391611cb2670e3489ea95d78ac1e81569d441886505", + "run_result_sha256": "1df2367f0c646a343fb89b4e86d300682af23ee4f9c60974861aa6510c9ad28c", + "tested_bottom_center_offset_xy_m": [ + 0.0, + 1.3877787807814457e-17 + ], + "attempt_outcomes": [ + "preparation_failed", + "passed" + ] + }, + { + "source_ref": { + "asset_id": "Crunch_Girl_Scouts_Candy_Bars_Peanut_Butter_Creme_78_oz_box", + "revision": "75e8895e4f4e854cddd7009a7e60f86812041012", + "source_id": "gso-glb", + "variant_id": null + }, + "physics_passed": true, + "profile_id": "rigid_prop_v1", + "prepared_longest_extent_m": 0.12, + "pose_wxyz": [ + 0.7071067811865476, + 0.7071067811865476, + 0.0, + 0.0 + ], + "footprint": { + "initial_projected_xy_m": [ + 0.10146915939595505, + 0.1199999990813976 + ], + "final_xy_m": [ + 0.11748486078590677, + 0.13300809631134308 + ], + "centered_xy_envelope_m": [ + 0.1511464725553664, + 0.14906843771473063 + ], + "final_edge_margins_xy_m": [ + 0.25472606332648345, + 0.17718199762159914 + ], + "final_full_bounds_in_case_envelope": true + }, + "support": { + "kind": "horizontal_static_primitive_box", + "worktop_xy_m": [ + 0.66, + 0.5 + ], + "worktop_height_m": 0.7200000000000001, + "case_target_bounds_m": { + "max": [ + 0.27, + 0.21, + 0.83 + ], + "min": [ + -0.27, + -0.21, + 0.704 + ] + }, + "initial_bottom_clearance_m": 0.23250000000000004, + "vertical_displacement_m": 0.23476850986480713, + "minimum_displacement_m": 0.18, + "direct_worktop_contact": true, + "contact_in_recorded_steps": { + "count": 24, + "first_physics_step": 13, + "last_physics_step": 36, + "actor_pair": [ + "/World/box/Asset/Body", + "/World/table" + ] + }, + "settled": true, + "settling": { + "window_observed_s": 1.983333333333333, + "max_linear_m_s": 0.0, + "max_angular_rad_s": 2.528810910653651e-06, + "window_requested_s": 2.0, + "linear_limit_m_s": 0.03, + "angular_limit_rad_s": 0.3 + } + }, + "title": "Crunch Girl Scouts Peanut Butter Creme carton", + "prepared_parameters": { + "ccd": true, + "collision_method": "convex_hull", + "dynamic_friction": 0.5, + "mass_kg": 0.12, + "mass_note": "Matched 0.12 kg experimental worktop drop; no manufacturer mass claim.", + "proxy_tolerance_m": 0.002, + "restitution": 0.05, + "scale_mode": "fit_longest", + "source_physics_policy": "reject_if_physics", + "static_friction": 0.6, + "target_longest_extent_m": 0.12 + }, + "source_model_sha256": "9b90e9d43ba10a81dbb0f5f8da258f1d58d45094269fa0263431ffb1306860c7", + "license": "CC-BY-4.0", + "outcome": "passed", + "case_sha256": "2453f5db0bae70f0d9b99cbf8c8f7fb79123231c056b1d83e87d797d207aa5aa", + "physics_check_sha256": "213ac625877a90a8e682ba2dc3fbeb647af5514685637b4ec1c2992fa9d28679", + "run_lock_sha256": "906c48e03144b6ccc65f2968143dfb21c4cc67f2b9f2ab0c7c5fabb92041fda7", + "run_result_sha256": "663db2135180e8acae222a0eb5fb0c8efbe16da8b8bc317402f177ab383a6042", + "tested_bottom_center_offset_xy_m": [ + 0.0, + 6.938893903907228e-18 + ] + } + ] +} diff --git a/src/simscene/recipes/worktop_fit.py b/src/simscene/recipes/worktop_fit.py new file mode 100644 index 0000000..8e07aa3 --- /dev/null +++ b/src/simscene/recipes/worktop_fit.py @@ -0,0 +1,70 @@ +"""Filter observed gravity-drop footprints for a measured rectangular worktop.""" +import json +import math +from decimal import Decimal +from importlib.resources import files + + +SUPPORT_KIND = 'horizontal_static_primitive_box' + + +def _positive_length(value): + return type(value) in (int, float) and math.isfinite(value) and value > 0 + + +def filter_observations(observations, *, width_m, depth_m, edge_clearance_m): + """Use observed XY envelopes in the tested pose and clearance on both edges.""" + if not _positive_length(width_m) or not _positive_length(depth_m): + raise ValueError('worktop width and depth must be positive finite metres') + if (type(edge_clearance_m) not in (int, float) or not math.isfinite(edge_clearance_m) + or edge_clearance_m < 0): + raise ValueError('edge clearance must be nonnegative finite metres') + + matches, excluded = [], [] + dimensions = [width_m, depth_m] + rectangle = [Decimal(str(size)) for size in dimensions] + clearance = Decimal(str(edge_clearance_m)) + for observation in observations: + ref = observation['source_ref'] + support = observation.get('support', {}) + extent = observation.get('footprint', {}).get('centered_xy_envelope_m') + if (observation.get('physics_passed') is not True or support.get('kind') != SUPPORT_KIND + or support.get('direct_worktop_contact') is not True or support.get('settled') is not True + or not isinstance(extent, list) or len(extent) != 2 + or not all(_positive_length(span) for span in extent)): + excluded.append({'source_ref': ref, 'reason': 'no_verified_support_result'}) + continue + # Compare the published decimal lengths at exact-fit boundaries. + spans = [Decimal(str(span)) for span in extent] + margins = [(size - span) / 2 for size, span in zip(rectangle, spans)] + available = [float(margin) for margin in margins] + if any(margin < clearance for margin in margins): + excluded.append({'source_ref': ref, 'reason': 'insufficient_worktop_xy', + 'available_edge_margins_xy_m': available}) + continue + matches.append({ + **observation, + 'minimum_worktop_xy_m': [float(span + 2 * clearance) for span in spans], + 'available_edge_margins_xy_m': available, + }) + return { + 'schema': 'simscene.worktop_fit.v1', + 'support_kind': SUPPORT_KIND, + 'worktop_xy_m': dimensions, + 'edge_clearance_m': edge_clearance_m, + 'matches': matches, + 'excluded': excluded, + 'scope': 'Geometry prefilter for a flat static collision-enabled rectangle in the tested XY axes. ' + 'Apply the recorded pose and offset from the usable rectangle center. Contact and settling refer to ' + 'the recorded worktop only. Verify a new run on the selected support.', + } + + +def worktop_fit(width_m, depth_m, edge_clearance_m): + path = files('simscene.recipes').joinpath('data/worktop-support.json') + evidence = json.loads(path.read_text(encoding='utf8')) + return { + **filter_observations(evidence['observations'], width_m=width_m, depth_m=depth_m, + edge_clearance_m=edge_clearance_m), + 'evidence': evidence['test_context'], + } diff --git a/tests/agent/test_package.py b/tests/agent/test_package.py index 57aca23..44c0cb3 100644 --- a/tests/agent/test_package.py +++ b/tests/agent/test_package.py @@ -112,6 +112,11 @@ async def check_independent_metadata(root,plugin): response=await session.read_resource('simscene://recipes/examples') examples=json.loads(response.contents[0].text)['examples'] self.assertIn('automatic_cabinet_layout',{entry['id'] for entry in examples}) + response = await session.read_resource('simscene://recipes/worktop-fit/0.66/0.50/0.02') + fit = json.loads(response.contents[0].text) + self.assertEqual(fit['schema'], 'simscene.worktop_fit.v1') + self.assertIn('ReadytoUse_Rolled_Fondant_Pure_White_24_oz_box', + {item['source_ref']['asset_id'] for item in fit['matches']}) response=await session.read_resource('simscene://runtime/identity') identity=json.loads(response.contents[0].text) self.assertEqual(Path(identity['module_path']).resolve(),(vendor/'simscene/__init__.py').resolve()) diff --git a/tests/test_worktop_fit.py b/tests/test_worktop_fit.py new file mode 100644 index 0000000..f9c57d5 --- /dev/null +++ b/tests/test_worktop_fit.py @@ -0,0 +1,75 @@ +"""Historical worktop evidence is a geometric prefilter for a new placement.""" +import asyncio +import json +import math +import unittest + + +def observation(asset_id, extent, *, passed=True, direct=True, settled=True): + return { + 'source_ref': {'source_id': 'gso-glb', 'asset_id': asset_id, + 'revision': 'a'*40, 'variant_id': None}, + 'physics_passed': passed, + 'footprint': {'centered_xy_envelope_m': extent}, + 'support': {'kind': 'horizontal_static_primitive_box', + 'direct_worktop_contact': direct, 'settled': settled}, + } + + +class WorktopFitTests(unittest.TestCase): + def test_uses_axis_dimensions_and_edge_margin(self): + from simscene.recipes.worktop_fit import filter_observations + + options = [observation('small', [.11, .08]), observation('too_deep', [.10, .16]), + observation('too_wide', [.19, .06]), observation('no_contact', [.05, .05], direct=False), + observation('unstable', [.05, .05], settled=False), + observation('failed_case', [.05, .05], passed=False)] + result = filter_observations(options, width_m=.22, depth_m=.18, edge_clearance_m=.02) + self.assertEqual([entry['source_ref']['asset_id'] for entry in result['matches']], ['small']) + self.assertEqual(result['matches'][0]['minimum_worktop_xy_m'], [.15, .12]) + boundary = filter_observations(options[:1], width_m=.15, depth_m=.12, edge_clearance_m=.02) + self.assertEqual(len(boundary['matches']), 1) + rounded = [observation('decimal_boundary', [.10, .10])] + fit = filter_observations(rounded, width_m=.30, depth_m=.30, edge_clearance_m=.10) + self.assertEqual(len(fit['matches']), 1) + too_small = filter_observations(rounded, width_m=.299999, depth_m=.30, edge_clearance_m=.10) + self.assertEqual(too_small['matches'], []) + exact = filter_observations(rounded, width_m=math.nextafter(.10, 0), depth_m=.10, + edge_clearance_m=0) + self.assertEqual(exact['matches'], []) + self.assertEqual([item['reason'] for item in result['excluded']], + ['insufficient_worktop_xy', 'insufficient_worktop_xy', + 'no_verified_support_result', 'no_verified_support_result', + 'no_verified_support_result']) + + def test_preserves_pose_and_rejects_invalid_dimensions(self): + from simscene.recipes.worktop_fit import filter_observations + + option = observation('fixed_pose', [.20, .12]) + fit = filter_observations([option], width_m=.14, depth_m=.22, edge_clearance_m=0) + self.assertEqual(fit['matches'], []) + self.assertEqual(fit['excluded'][0]['reason'], 'insufficient_worktop_xy') + for width, depth, edge in ((0, .5, .01), (.5, math.inf, .01), (True, .5, .01), + (.5, .5, -.01), (.5, .5, math.nan)): + with self.subTest(width=width, depth=depth, edge=edge), self.assertRaises(ValueError): + filter_observations([option], width_m=width, depth_m=depth, edge_clearance_m=edge) + + def test_resource_template_calls_real_filter(self): + from simscene.mcp_server import server + + templates = asyncio.run(server.list_resource_templates()) + self.assertIn('simscene://recipes/worktop-fit/{width_m}/{depth_m}/{edge_clearance_m}', + {str(template.uriTemplate) for template in templates}) + contents = asyncio.run(server.read_resource('simscene://recipes/worktop-fit/0.66/0.50/0.02')) + result = json.loads(next(iter(contents)).content) + by_source = {row['source_ref']['asset_id'] for row in result['matches']} + baseline = 'ReadytoUse_Rolled_Fondant_Pure_White_24_oz_box' + self.assertEqual(by_source, { + baseline, 'B01DN8TB5U', 'Crunch_Girl_Scouts_Candy_Bars_Peanut_Butter_Creme_78_oz_box', + }) + narrow = asyncio.run(server.read_resource('simscene://recipes/worktop-fit/0.30/0.24/0.02')) + narrow = json.loads(next(iter(narrow)).content) + self.assertEqual({row['source_ref']['asset_id'] for row in narrow['matches']}, + by_source - {baseline}) + self.assertEqual(result['support_kind'], 'horizontal_static_primitive_box') + self.assertIn('new run', result['scope'])