Skip to content

Implement code-review action plan: measured geometry, exact wall check, web-app state - #6

Merged
Rigare merged 6 commits into
mainfrom
claude/opus-5-5-code-review-88faa0
Sep 27, 2026
Merged

Rigare merged 6 commits into
mainfrom
claude/opus-5-5-code-review-88faa0

Conversation

@Rigare

@Rigare Rigare commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Implements the code-review action plan (findings R1–R15, N1–N21, measures M-00 … M-35). One commit per phase, each with a green suite:

Commit Phase Measures
39b0746 0 – Hotfixes M-09, M-10, M-11, M-14, M-15, M-32
1a65166 1–4 – Measured geometry and exact wall check M-00 … M-08, M-25, M-23, M-29
9b19288 5 – Isotropic dilation, config validation M-12, M-13, M-31
a48a47f 6 – Web-app state M-16 … M-22
965e4df 7–8 – Tests, CI, image M-26, M-27, M-28, M-33
ab0f4db Follow-up Translated selectboxes after a language switch (found while verifying M-16)

Review scenarios, before → after

Measured on the output mesh with tests/geometry_probe.py (manifold3d booleans, min_gap, ray casts), independent of the pipeline:

Scenario Before After
B2: cubes at z 0..10 and 30..40 solid block without a cavity, "Success" 2 pockets, walls 2.00 mm
B3: 40 mm + 8 mm figure short figure without a pocket both sink 70 % of their own height
B13: inner wall at figure_gap 2.0 1.60 mm (pitch 0.4) / 1.00 mm (pitch 1.0) 2.00 mm
N10 / R5: floor / side wall, target 2.0 2.20–2.50 / 1.75–1.90 mm 2.00 / 2.00 mm
B8: real wall 0.9 mm reported 2.00 mm, passed measured value, finding with file name
B9: depth_fraction 1.0, offset −0.5 sealed void (2 shells), passed open pocket
B5: two bars, rot_y 90 cavities merged, green badge 2 pockets, 2.00 mm apart
B10: finger recesses, flat figure hole through the floor floor 2.00 mm
B15: holed body + small part only the 4×4×25 part left both kept
B16 / B17: low-poly bar / rod "max_iter exceeded" / 1.95 GB runs, < 200 MB

Deviations from the plan

  • build_inlay arranges the figures itself (instead of a separate arrange_for_inlay, E6). Voxelization shifts a cavity by up to half a pitch depending on where it lies on the grid, so exact walls need the real cutters before the layout: solidify first, measure, then place and size the box.
  • CLI exit code 3 when the wall check fails (not 2 as in E8 – argparse already uses 2 for usage errors).
  • M-10: straight to stage 2 (area-proportional rasterizer) plus a grid-size limit, no stage-1 cost estimate.
  • M-13: a cube-step share of (√3−1)/2 instead of 1:1 alternation – all directions within 0.97–1.06, the axis calibration stays valid.
  • Left out on purpose: per-component repair (M-09, the flag suffices), reset button (M-20), extra CI step (M-27, the root cause is fixed in the fixture), xfail baseline (M-00 – instead the new tests were run against the previous commits, where they fail).

Breaking changes

  • arrange_with_stable_bounds and build_inlay(stable_global_bounds=…) are removed; arrange_figures became arrange_footprints; build_inlay takes sorting_reference.
  • wall_thickness_stats_3d(inlay) no longer takes a config and only reports the check build_inlay stored in inlay.metadata["wall_check"] – no voxel fallback for arbitrary meshes.
  • Box dimensions change slightly at identical settings, because walls are now exact.
  • Manual offsets move a figure inside a fixed box; walls they make too thin are reported.

Found along the way

Streamlit 1.62 sends a selectbox value as its label. Once the widgets kept their state across a language switch (M-16), the old label matched no option: the recess axis's lenient format_func turned "left/right" into the value (the next run would have failed), box shape and layout fell back to their defaults. Fixed in the last commit, with a test.

Verification

  • pytest: 419 passed (previously 276), ~95 s. INLAYER_LANG=de pytest is green too.
  • The review's three mutants (row spacing without gap, compact sorted ascending, offsets ignored) are each caught.
  • Not run locally: docker build (Docker daemon was not running) – the CI job now builds the test and runtime stage and smoke-tests the runtime image. Removing build-essential was checked with pip install --dry-run --only-binary=:all:: all 54 packages resolve as cp313 wheels for x86_64 and aarch64.

README.md and AGENTS.md are updated in every commit.

🤖 Generated with Claude Code

Marco Wittwer and others added 6 commits September 27, 2026 14:10
- M-09: repair with remove_smallest_components=False - pymeshfix's default
  kept only the shell with the most triangles, so a holed figure lost its base.
- M-10: _voxelize_surface samples triangles in rows along the longest edge;
  cost follows area instead of edge length^2 (low-poly rods took GBs, a
  250 mm bar aborted with "max_iter exceeded"). _check_grid_size refuses
  grids above MAX_GRID_VOXELS up front.
- M-11: load_mesh rejects empty/garbled STLs with a message naming the file;
  the instant preview skips such a file with a warning.
- M-14: rotation/position steps live in persistent session keys; every rerun
  requantizes stored values before the sliders exist. Hiding the rotation
  section no longer resets the step and crashes the app.
- M-15/M-32: process-wide cache keys and the staleness snapshot use a content
  hash per upload instead of name:size (cross-session leak); uploads are read
  with getvalue() instead of copying the buffer on every rerun.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measure (M-00): tests/geometry_probe.py measures a finished inlay with
manifold3d (pocket bounds, min_gap, ray casts, shells), independent of the
pipeline; tests/test_geometry_invariants.py pins the review scenarios
(appendix B) on the output mesh.

Check (M-01, M-25): build_inlay clips every figure's cutter to the box and
measures side/floor walls, walls between cavities (min_gap), sealed voids and
figures without a cavity - per figure, tolerance 0.05 mm. The voxel check
overestimated walls by up to a pitch, ignored inner walls and passed an inlay
without cavities. App and CLI list every finding with the file name; the CLI
exits with 3 when the check fails (2 stays argparse's usage error).

Geometry (M-02..M-08): each figure sinks depth_fraction of its own height
(short figures got no pocket, Z origins produced solid blocks); cavities are
extruded through the top face (no sealed voids); finger recesses get a shaft
and count as part of their figure's cutter. build_inlay now solidifies first
and arranges/dimensions from the real cutters, because voxelization shifts a
cavity by up to half a pitch: side/floor walls are wall_thickness, the wall
between cavities is figure_gap, rotated figures never overlap, recesses stay
inside the box in both axes, a manual box width is kept.

API: arrange_with_stable_bounds and stable_global_bounds are gone,
arrange_figures became arrange_footprints; build_inlay takes the dilated
figures (plus sorting_reference) and reports placements, wall_check and
violating_indices in its metadata. wall_thickness_stats_3d(inlay) reports
the check (no voxel fallback). Tests pinning the old behaviour
(test_slots_stay_stable_while_rotating, the height/width formulas, the
cavity grid) were rewritten.

Also: CLI validates every --finger-recess-position while parsing and turns
Config errors into usage errors (M-23, part of M-12); _finger_band is tested
directly (M-29); Config.effective_figure_gap (M-34).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-13, M-31)

- M-31: drop the binary_closing before the dilation in dilate - dilating a
  closing with the same element equals dilating the input (checked bit for
  bit on 200 random grids), it cost 2/3 of the morphology time.
- M-13: a share of (sqrt(3) - 1) / 2 of the dilation steps uses the 3x3x3
  cube, which equalizes axis and space-diagonal growth (all directions within
  0.97-1.06). With the cross alone 2 mm of clearance left ~1.5 mm on slopes.
  Axis growth is unchanged, so the calibration of _dilation_iterations holds.
- M-12: Config rejects NaN/inf in every float field, uses one message per
  range (>= 0, > 0, (0, 1], >= 4) from a rule table; the CLI reports it as a
  usage error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- M-16: every widget has a fixed, language-independent key; a static AST
  test fails on an unkeyed widget. A language switch no longer drops the
  uploads and resets every setting.
- M-19: per-figure settings are keyed by upload (file_id), duplicate names
  are shown as "model.stl (2)", removed uploads take their settings along.
- M-17: one resolve_selection rule for recess position, offsets and rotation;
  selections and sliders are reconciled with the uploads before any widget
  exists, so a slider always shows what the pipeline uses.
- M-18: applied_figure_params is the single source of per-figure values for
  the run, the instant preview and the staleness snapshot; switching which
  figure a slider shows no longer marks the result stale.
- M-20: the figure gap follows the wall thickness until the user sets it.
- M-21: the app uses inlayer._parallel_map with a worker_init hook for the
  Streamlit context instead of its own pool (which skipped the language).
- M-22: the session keeps only slim geometry (decimated inlay, placements,
  recesses); preview_copy never hands the input object to the cache.
- M-24 (part): DEFAULT_INPUT = "figure.stl" for CLI and app (README said so).
- M-34 (part): thousands separator follows the UI language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- M-27: the language fixture pins INLAYER_LANG as well - CLI subprocesses
  inherit the environment, and `INLAYER_LANG=de pytest` failed two tests.
- M-28: tests/test_streamlit_config.py checks the runtime stage on its own
  (the whole-file search was satisfied by the test stage's COPY): app.py,
  every repo module it imports (read via ast) and .streamlit/. CI builds the
  runtime stage and smoke-tests it (imports, /_stcore/health).
- M-33: build-essential removed from the image - all 54 pinned packages
  resolve as cp313 wheels for x86_64 and aarch64 (pip --dry-run
  --only-binary=:all:); libgl1/libglib2.0-0 stay.
- M-26: the rewritten layout/offset tests catch the review's three mutants
  (row spacing without gap, compact sorted ascending, offsets ignored).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found while verifying M-16: Streamlit 1.62 sends a selectbox value as its
label. Once the widgets kept their state across a language switch, the old
label matched no option - the recess axis's lenient format_func turned
"left/right" into the value (the next run crashed with "bad finger axis"),
box shape and layout fell back to their defaults.

Every selectbox with translated labels now goes through _select: raw value
in a plain session key seeding `index`, labels resolved once per run, unknown
values mapped to no label. The step selects use the same helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rigare
Rigare merged commit 9170201 into main Sep 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant