fix(skills): refresh Boolean checking facts that fail on current release (#1835) (#2093)

* fix(skills): refresh Boolean checking facts that fail on current release (#1835)

* fix(skills): restore warning coverage in test_run and use present tense in Boolean facts

* fix(skills): the slot keeps its side at zero since the solver takes the shortest step

The upstream solver now takes the shortest step that fits (#2060), so the slot
that other constraints also held slides to the origin when the distance reaches
0 and keeps the side it was drawn on when the value comes back. It no longer
comes back mirrored, so the trap and its test state the current behaviour.

---------

Co-authored-by: jeremymiribung-blip <jeremymiribung-blip@users.noreply.github.com>
This commit is contained in:
JEREMY
2026-10-21 00:41:45 +00:00
committed by GitHub
parent 316b49cd84
commit 382680d8e8
4 changed files with 55 additions and 56 deletions
@@ -75,7 +75,8 @@ def test_a_dimension_driven_to_zero_can_break_the_next_change():
])
def test_a_slot_held_by_other_constraints_can_cross_to_the_other_side_at_zero():
def slot_centre(*changes: list) -> float:
"""The slot's centre on x after the given parameter changes."""
body = execute([
cmd("parameters.add", name="n", expression="3", unit=""),
cmd("sketch.create", plane="XY", name="Slot sketch"),
@@ -86,11 +87,19 @@ def test_a_slot_held_by_other_constraints_can_cross_to_the_other_side_at_zero():
cmd("sketch.dimension", entities=["origin", "a1.center"], type="horizontal", value="(n - 1) * 3 mm"),
cmd("sketch.finish"),
cmd("solid.extrude", sketch="Slot sketch", distance="1 mm", body_name="Slot"),
cmd("parameters.change", name="n", expression="1"),
cmd("parameters.change", name="n", expression="3"),
*changes,
])["bodies"][0]
# Started at x = -6; after n 3 -> 1 -> 3 it sits at +6, with no error
assert (body["bbox"]["min"][0] + body["bbox"]["max"][0]) / 2 == pytest.approx(6, abs=1e-3)
return (body["bbox"]["min"][0] + body["bbox"]["max"][0]) / 2
def test_a_slot_held_by_other_constraints_keeps_its_side_at_zero():
# Drawn at x = -6. At n = 1 the distance is 0, so the slot slides to the origin; when the
# value comes back the solver takes the shortest step that fits and the slot keeps the side
# it was drawn on, so it no longer comes back mirrored.
assert slot_centre() == pytest.approx(-6, abs=1e-3)
assert slot_centre(cmd("parameters.change", name="n", expression="1")) == pytest.approx(0, abs=1e-3)
assert slot_centre(cmd("parameters.change", name="n", expression="1"),
cmd("parameters.change", name="n", expression="3")) == pytest.approx(-6, abs=1e-3)
def centred_row(position: list) -> list:
@@ -162,12 +171,6 @@ def test_a_circumscribed_polygon_needs_the_polygon_constraint():
assert sketch_dof([*HEXAGON, cmd("sketch.constraint.polygon", lines=[f"l{i}" for i in range(1, 7)])]) == 0
def test_in_a_plain_block_only_a_tapered_tool_on_a_face_logs_a_boolean_retry():
assert any("coincident-face" in w for w in warnings([*BLOCK, *tapered_cut("0 mm", "12 mm")]))
assert warnings([*BLOCK, *tapered_cut("-1 mm", "14 mm")]) == []
assert warnings([*BLOCK, *tapered_cut("0 mm", "12 mm", taper="0 deg")]) == []
def test_round_features_measure_about_1e_4_off():
body = execute([cmd("solid.cylinder", diameter="20 mm", height="10 mm")])["bodies"][0]
error = abs(body["volume_mm3"] / (pi * 100 * 10) - 1)
@@ -392,14 +395,14 @@ def standoffs_at(standoffs: list, height: float) -> tuple[float, dict]:
return gap, {f["name"]: f["warning"] for f in high["timeline"] if f.get("warning")}
def test_a_boolean_retry_can_leave_material_in_a_cut():
def test_a_boolean_retry_reports_tool_displacement_without_excess_material():
gap, warned = standoffs_at(TWO_CYLINDERS, 7)
assert gap > 10
assert "coincident-face" in warned["Standoff"]
assert abs(gap) < 0.5
assert "Standoff" not in warned
assert "tool displacement" in warned["Pilot"]
def test_sinking_the_join_and_overcutting_the_hole_does_not_fix_it():
def test_sinking_the_join_removes_the_warning():
gap, warned = standoffs_at([
cmd("solid.cylinder", diameter="6 mm", height="h + 1 mm", base=["-39 mm", "-24.5 mm", "1 mm"], operation="join",
targets=["Case"], name="Standoff"),
@@ -407,8 +410,8 @@ def test_sinking_the_join_and_overcutting_the_hole_does_not_fix_it():
targets=["Case"], name="Pilot"),
cmd("solid.pattern.rectangular", features=["Standoff", "Pilot"], **STANDOFF_GRID),
], 7)
assert gap > 10
assert "Standoff" not in warned
assert abs(gap) < 0.5
assert warned == {}
@pytest.mark.parametrize("height", [3, 7, 12, 20])
@@ -418,11 +421,12 @@ def test_a_ring_profile_builds_the_same_standoffs_exactly(height):
assert warned == {}
@pytest.mark.parametrize("base, height, retries", [("2 mm", "h", True), ("1 mm", "h + 1 mm", False)])
def test_a_straight_join_on_a_shelled_floor_retries_unless_sunk(base, height, retries):
def test_a_sunk_join_on_a_shelled_floor_does_not_warn():
warned = warnings([
*SHELLED_CASE,
cmd("solid.cylinder", diameter="6 mm", height=height, base=["-39 mm", "-24.5 mm", base], operation="join",
cmd("solid.cylinder", diameter="6 mm", height="h + 1 mm", base=["-39 mm", "-24.5 mm", "1 mm"], operation="join",
targets=["Case"], name="Standoff"),
])
assert any("coincident-face" in w for w in warned) == retries
assert warned == []
@@ -38,19 +38,16 @@ def test_flags_underconstrained_sketch(tmp_path):
def test_reports_step_warnings(tmp_path):
result = report(tmp_path, [
{"command": "sketch.create", "params": {"plane": "XY", "offset": "12 mm", "name": "Plate"}},
{"command": "sketch.rectangle.center", "params": {"center": [0, 0], "corner": [40, 40]}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"sketch": "Plate", "distance": "12 mm", "direction": "negative",
"body_name": "P"}},
{"command": "sketch.create", "params": {"plane": "XY", "name": "Hole"}},
{"command": "sketch.circle.center", "params": {"center": [0, 0], "diameter": 20}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"sketch": "Hole", "distance": "12 mm", "taper": "-20 deg",
"operation": "cut", "targets": ["P"], "name": "Flush cut"}},
{"command": "parameters.add", "params": {"name": "h", "expression": "5 mm"}},
{"command": "solid.box", "params": {"length": 91, "width": 62, "height": 30, "center": [0, 0, 15], "body_name": "Case"}},
{"command": "solid.fillet", "params": {"edges": [[45.5, 31, 15], [-45.5, 31, 15], [45.5, -31, 15], [-45.5, -31, 15]], "radius": 3}},
{"command": "solid.shell", "params": {"faces": [[0, 0, 30]], "thickness": 2}},
{"command": "solid.fillet", "params": {"edges": [[0, -31, 30]], "radius": 1}},
{"command": "solid.cylinder", "params": {"diameter": "6 mm", "height": "h", "base": [-39, -24.5, 2], "operation": "join", "targets": ["Case"], "name": "Standoff"}},
{"command": "solid.cylinder", "params": {"diameter": "2.5 mm", "height": "h", "base": [-39, -24.5, 2], "operation": "cut", "targets": ["Case"], "name": "Pilot"}},
])
assert result.returncode == 0, result.stderr
assert 'WARN "Flush cut": Boolean retry' in result.stdout
assert 'WARN "Pilot": Boolean retry' in result.stdout
def test_fails_on_a_bad_step(tmp_path):
@@ -86,40 +83,38 @@ def test_execute_raises_on_failure():
@pytest.fixture
def flush_design(tmp_path):
"""A cut 10 mm deep into a 12 mm plate; at depth 13 mm its tapered end lies on the plate top."""
design = tmp_path / "plate.json"
"""A shelled case with a joined standoff and a cut pilot hole; Pilot warns tool displacement."""
design = tmp_path / "standoff.json"
built = report(tmp_path, [
{"command": "parameters.add", "params": {"name": "depth", "expression": "10 mm"}},
{"command": "sketch.create", "params": {"plane": "XY", "name": "Plate sketch"}},
{"command": "sketch.rectangle.center", "params": {"center": [0, 0], "corner": [40, 40]}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"sketch": "Plate sketch", "distance": "12 mm", "body_name": "P"}},
{"command": "sketch.create", "params": {"plane": "XY", "offset": "-1 mm", "name": "Cut sketch"}},
{"command": "sketch.circle.center", "params": {"center": [5, 5], "diameter": 20}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"sketch": "Cut sketch", "distance": "depth", "taper": "10 deg",
"operation": "cut", "targets": ["P"], "name": "Cut"}},
{"command": "parameters.add", "params": {"name": "h", "expression": "5 mm"}},
{"command": "solid.box", "params": {"length": 91, "width": 62, "height": 30, "center": [0, 0, 15], "body_name": "Case"}},
{"command": "solid.fillet", "params": {"edges": [[45.5, 31, 15], [-45.5, 31, 15], [45.5, -31, 15], [-45.5, -31, 15]], "radius": 3}},
{"command": "solid.shell", "params": {"faces": [[0, 0, 30]], "thickness": 2}},
{"command": "solid.fillet", "params": {"edges": [[0, -31, 30]], "radius": 1}},
{"command": "solid.cylinder", "params": {"diameter": "6 mm", "height": "h", "base": [-39, -24.5, 2], "operation": "join", "targets": ["Case"], "name": "Standoff"}},
{"command": "solid.cylinder", "params": {"diameter": "2.5 mm", "height": "h", "base": [-39, -24.5, 2], "operation": "cut", "targets": ["Case"], "name": "Pilot"}},
], "--save", design)
assert built.returncode == 0 and "WARN" not in built.stdout, built.stdout + built.stderr
assert built.returncode == 0, built.stdout + built.stderr
return design
def depth(value: str) -> dict:
return {"command": "parameters.change", "params": {"name": "depth", "expression": value}}
return {"command": "parameters.change", "params": {"name": "h", "expression": value}}
def test_reports_warnings_after_a_parameter_change(tmp_path, flush_design):
flush = report(tmp_path, [depth("13 mm")], "--in", flush_design)
assert 'WARN "Cut": Boolean retry' in flush.stdout
flush = report(tmp_path, [depth("7 mm")], "--in", flush_design)
assert flush.returncode == 0, flush.stderr
assert 'WARN "Pilot": Boolean retry' in flush.stdout
def test_reports_every_inspection_in_the_script(tmp_path, flush_design):
walk = report(tmp_path, [depth("13 mm"), {"command": "document.inspect", "params": {"measure": True}},
depth("10 mm")], "--in", flush_design)
walk = report(tmp_path, [depth("7 mm"), {"command": "document.inspect", "params": {"measure": True}},
depth("5 mm")], "--in", flush_design)
lines = walk.stdout.splitlines()
assert any(line.startswith('step 2 WARN "Cut": Boolean retry') for line in lines), walk.stdout
assert any(line.startswith("step 2 BODY P: volume") for line in lines)
assert not any(line.startswith("WARN") for line in lines)
assert any(line.startswith('step 2 WARN "Pilot": Boolean retry') for line in lines)
assert any(line.startswith("step 2 BODY Case: volume") for line in lines)
assert any(line.startswith('WARN "Pilot": Boolean retry') for line in lines)
def test_reports_bodies_inspected_without_measurements(tmp_path):