Repository navigation
Conversation
A flat cut at height h leaves the stock model's upper bound its sweep guard (the run's sweep tolerance_mm, 1e-5 by default) above h. Since #344, Pocket and AdaptivePocket planned their depths from the highest reachable stock above top_z_mm, so a top faced to exactly top_z_mm moved every level up by that guard. When the depth was a whole number of stepdowns this left a last level one guard (1e-5 mm) below the one above it: for an AdaptivePocket the whole region was then a sheet that thick, and the engagement proof (correctly) could not bound the contact angle of its strokes, so the level was refused. A Pocket repeated its floor pass, identical at the posted resolution. The levels below the first are each placed a stepdown below the tip of the level above, not below the guard that level leaves; the first is now measured the same way. Stock no more than the operation's tolerance_mm above the top is at the top; stock standing higher still raises the planning top, so no motion removes more than a stepdown of the stock model (#344's guarantee, measured by the tests). The standalone rest example's golden program and the rest-pocket benchmark expectation return to their pre-#344 values (130 moves, 169 posted blocks instead of 186 and 225; material bounds unchanged). Closes #381 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #381
Root cause
The planner was wrong. The proof was right to refuse.
A flat cut at height
hleaves the stock model's upper bound athplus the sweep guard, which is the run's sweeptolerance_mm(1e-5 by default;Stock::preview_sweepsetsupper = z + guard). Since #364 (#344),StockTop::planning_topplans the depths from the highest reachable stock abovetop_z_mm. On a top faced to exactly Z20 that stock is at Z20.00001, so every level moved up by the guard. When the depth is a whole number of stepdowns, the plan then gets one more level, 1e-5 mm below the level above it:On that last level the whole region is a sheet of possible material 1e-5 mm thick. The engagement proof cannot bound the contact angle of a stroke buried in it, so it refuses (
could not resolve its boundary certificate; nodes 2 ... depth 0). That is the correct result for that plan. APockethas the same problem in another form: it repeats its floor pass, and at the posted resolution the two passes are the same blocks. The 56 lines #364 added tofixtures/posts/rust/standalone-rest.ncare exactly that repeated pass.The rule was also inconsistent. Every level after the first is placed a stepdown below the tip of the level above it, not below the guard that level leaves. So in the "below the stock model" sense, levels 2 and later already cut a stepdown plus the guard.
The fix
StockTop::planning_toptreats stock no more than the operation'stolerance_mmabove the top as being at the top. Stock that stands higher still raises the planning top. This is used both before motion and on the rescan. The first level is now measured like every later level, from the tip of the cut that left the stock.What #344 required still holds: no motion removes more than a stepdown of the stock model. The new tests measure this as
before.upper - after.upperfor every motion, the same waytop_inside_the_tolerance_band_never_cuts_deeper_than_a_stepdowndoes. The #344 band case (stock 0.1 mm above the top) is unchanged. No tolerance, band or check is relaxed, and the engagement proof is untouched.Tests
tests/pocket_top.rs::adaptive_pocket_from_a_faced_floor_cuts_whole_stepdowns_to_the_flooruses the issue's program: a 100 x 60 plate in 21 mm stock, a 6 mm end mill, faced to Z20, then an AdaptivePocket from Z20 to Z12. It runs stepdowns 2, 3 and 8, each with a helical entry and with a ramp entry. It checks:[18,16,14,12],[17,14,12],[12]), and the last is exactly at the floor;Pocketfrom the same faced floor plans 4 depth passes, not 5.stock_just_beyond_the_tolerance_above_the_top_still_raises_the_planning_top: stock 1e-5 above the top plans from the top, and stock 1.1e-5 above it still raises the top, for bothPocketandAdaptivePocket.pocket_and_adaptive_use_faced_stock_top_without_resetting_stock_or_extra_depths: now asserts the exact tips[6, 5]instead of a band.python/tests/test_faced_pocket_top.pystreams Facing then AdaptivePocket end to end, with stock-contact checks, at stepdowns 2 and 8. It checks the layers, completion and that every contact check is clear.Failing on main: I ran the new Rust tests against
src/pocket.rsfrom dde509b.adaptive_pocket_from_a_faced_floor...,stock_just_beyond...and the updated faced-stock test fail there; at stepdown 2 the tips are[18.00001, ..., 12.00001, 12.0]. A probe on dde509b reproduced the refusal itself:contact angle ... not proven ... adaptive pocket level 4 at Z12for helix at stepdown 2, andlevel 1 at Z12at stepdown 8.Benchmarks (release,
bench/run.py, compared withbench/expectations)Only
rest-pocketchanged. It returns to the values it had before #364:Material bounds are unchanged. I regenerated
bench/expectations/rest-pocket.jsonfrom the measurement withbench/expectations.py. It is byte-identical to the file before #364.fixtures/posts/rust/standalone-rest.ncis also byte-identical to its version before #364. Every other workload matches its expectation.Evidence
cargo test --profile ci -j 4 --workspace --all-features --lib --tests: 458 unit passed (5 ignored), 673 integration passed. The release-profile build of the test binaries was OOM-killed under an 8 GB memory cap, so I used--profile ci, the same optimisation level without LTO.cargo test --release --doc: 1 passed.cargo +1.100 clippy --workspace --all-targets --all-features -- -D warnings(the CI-pinned toolchain): clean. Local stable 1.98 clippy flagsneedless_range_loopinsrc/surface/spline_bounds.rs:95, which this PR does not touch; 1.100 does not.cargo fmt --check: clean on stable and on 1.100.python -m unittest discover -s python/tests(release build, with CadQuery): 1124 tests OK, 21 skipped.python -m unittest discover -s bench -p "test_*.py": 12 OK.ruff checkandruff format --checkon python, examples and bench: clean.--accept-unchecked-machinein fresh directories containing spaces. Each refuses export (unchecked_machine) and writes no NC file.python bench/run.py --label fix-381, thenbench/compare.py: onlyrest-pocketdiffers, as listed above.Docs:
docs/operations.md("A top below the remaining stock") now explains the planning top, and drops the note about a nearly empty last depth.#385 (Flat around a round boss) also edits
docs/operations.md, in a different section (Flat). It shares no other file with this PR.🤖 Generated with Claude Code