Repository navigation
Audit follow-up: bounded memory, clean CLI errors, tests that bite - #8
Merged
Merged
Conversation
MAX_GRID_VOXELS was checked once, in prepare_figure, on the figure as uploaded. Both entry points rotate afterwards: a 1 m rod of 16 mm passed with 3e7 voxels and needed 2.6e10 in dilate once it was turned onto the space diagonal - in the web app with one small upload and two rotation sliders. dilate now checks the rotated mesh plus its clearance padding, _solidify_figure the cutter up to the top face (a large negative Z offset stretched that grid unchecked). dilate takes the figure's name for the message; the web app and the CLI pass it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dilate voxelized marching-cubes output at half the pitch through trimesh's subdivision voxelizer, which split every triangle into 64 for that. This one call was the memory peak of a whole run and had nothing to do with the grid MAX_GRID_VOXELS guards: 1.9 GB for a 40 mm cube at the default settings, 3.8 GB for 60 mm, and a 100 mm cube died with a MemoryError under 8 GB while the guard rated it at 13 % of its limit. dilate and _solidify_figure now use _voxelize_surface like prepare_figure, and the sampler marks its samples batch by batch instead of collecting them all. Its grid is bit-identical to before for any batch size. A stack of thin plates (12 kB of STL, 1 % of the grid limit) took 590 MB there and now takes 20. Measured at the default settings, whole run: 40 mm cube 1872 MB -> 247 MB, dilate 3.4 s -> 1.0 s 60 mm cube 3843 MB -> 458 MB, dilate 8.0 s -> 2.4 s 100 mm cube > 10 GB -> 1.3 GB The two voxelizers do not hit exactly the same voxels where a surface grazes one. Boxes come out the same; over 40 shapes and four settings the smallest gap between figure and cavity moved by 0.04 mm at most. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The whole CLI sat under `if __name__ == "__main__"`, where nothing can import it: the tests could only start it as a subprocess, and none of them ever looked at the file it wrote. main() takes argv and returns the exit code, _build_parser() builds the parser. No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the Config was built inside a try. A missing input (including the default figure.stl of README's minimal invocation), an unreadable STL, a grid beyond the limit and an output directory that does not exist all ended in a traceback with exit code 1 - the last one only at the export, after the whole computation. Inputs and the output path are now checked while parsing (usage error, exit 2, nothing computed). What the pipeline raises on purpose is printed as one line on stderr with the new exit code 1; a MemoryError gets a message that says what to change. The README's exit-code table lists 1. test_cli_missing_input_fails passed because of the traceback - the only thing it found in the output was the exception's class name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rotations are the only numbers that do not pass through Config, so they skipped its finiteness check: `--rot-x nan` ran the whole pipeline on a mesh of NaNs, wrote a solid 4 x 4 x 2.5 mm block and exited 3 with a "no cavity" finding. The README says NaN and infinity are rejected everywhere, as a usage error before any work starts - now they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README: "without --finger-recesses the positions have no effect and a note says so". The note was printed only when the number of values did not fit the number of files; one value, or exactly one per file, was dropped without a word. The flag's default is now None, so "not given" and "given as 0.0" can be told apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--box-shape, --offset-x/y/z and --layout-style carried literals of their own where their neighbours read Config.<field>, and the help texts quoted 'box', 0.0, 'compact' and 'x' as a third copy in both languages. Equal today, and nothing compared them: the parser could not be imported. A test now holds the parser's defaults against Config(). The --depth-fraction help said 0.0-1.0; 0.0 is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README documents box_width as "cuboid only", and for the box itself it was. build_inlay still handed it to the compact layout as the row width whatever the shape: `--box-shape cylinder --box-width 20` packed four figures into a single column and made the cylinder 63 mm wide instead of 44, while the log called its size "(automatic)". box_depth was ignored all along. CLI and library only - the web app offers no width for a cylinder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
load_mesh only asked whether a file has triangles. Two kinds of file have them and still cannot be processed: - All coordinates NaN or infinite: trimesh drops every vertex and keeps the faces. The CLI ended in an IndexError; in the web app the instant preview raised it too and drew no chart for any upload, the very thing its "one broken file must not take the others with it" guard is for. - No volume (a flat surface, triangles collapsed to a line or a point): the repair returns an empty mesh and the voxelizer failed on it with "zero-size array to reduction operation minimum which has no identity". Both now raise the ValueError that names the file, as README promises for broken files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The run writes every upload to a temporary file and prepare_figure used that path as the file's name: "Computation failed: /tmp/tmpk3x9.stl contains no triangles". With several uploads nobody could tell which one was meant, while the instant preview named the same file correctly. prepare_figure takes the name to use in messages; the app passes the upload's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every failed run ended in st.exception(e): the full traceback with absolute paths and source lines, for whoever was using the app - and client.showErrorDetails does not switch that call off. What the pipeline raises on purpose already carries a message written for the user and is shown as that message alone. Anything else is a bug: it goes to the server log with its traceback, and the page says only that something went wrong and where to look. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI tests asserted an exit code and a non-empty file. Mutants that wrote the dilated figure instead of the inlay, ignored the rotations, deleted the --lang handling or dropped 15 of the 21 arguments on the way into Config passed all 409 tests. TestCLIWiring runs main() in-process, reads back the STL it wrote and compares it (extents, volume, centre of mass) with the inlay the library builds for the Config the flags stand for - one row per flag, each checked to differ from the run without it. TestCLILanguage covers --lang, INLAYER_LANG and their precedence. All 28 mutants are now caught, by tests that take under four seconds and stay in the quick loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No test produced a failing wall check in the app. The warning badge and the list of findings never ran, and with the condition of the badge turned around - green for a failing inlay - the whole suite stayed green. New tests read the badge and the warning for a passing and a failing check, and run what no test executed: the manual box dimensions, the cylinder's dimension card, the run without uploads (the error, and the figure.stl fallback). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each of these was a mutant that left all 409 tests green:
- the wall check's tolerance set to 0.4 mm instead of 0.05: every case
stayed half a millimetre away from the threshold
- `{name}` renamed in the `check.side` text, measured and target swapped:
only the `inner` finding was ever rendered (t() returns a template
unformatted when a placeholder is missing, and the test of that
fallback never reached it)
- finger_radius, box_diameter and figure_gap dropped from the > 0 rule
- Config.offset_y ignored; per-figure offsets ignored in the one test
named after them, which pushed its second figure out of the box and
asserted that the inlay had faces
- the decimation in prepare_figure removed, or reducing by 1 % instead
of to the target
- the explicit guards for an empty mesh and an empty CSG result, hidden
behind `except (ValueError, TypeError)` and `except (ValueError,
RuntimeError)`
Also: the watertightness assert in the end-to-end test could not fail
(`or len(inlay.faces) > 0`), and the recess-count test looked for the
flag's name, which every usage error prints.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The Print and Mesh tables get the CLI-flag column every other table has: -vp/--voxel-pitch, --decimate-faces and --scale appeared nowhere. - Clearance: it takes effect in steps of half a voxel_pitch and the cavity is never tighter than one to two pitches (0.4-0.8 mm at the defaults for a configured 0.4). Nothing said so; AGENTS.md quoted a floor of 0.75 pitch that describes dilate's output, not the cavity. - "Halving VOXEL_PITCH": there is no such constant. - "calls apply_transform(vox.transform) after every marching_cubes call": that is _grid_to_mesh, and it is one call. - "the computation does not abort" for an undersized box: unless nothing of the box is left. - The CLI examples sat in a powershell block with bash line continuations. - Web app: step sizes, the result staying on screen after a run, the figure.stl fallback; the count of recess positions is only checked with --finger-recesses; the bundled compose file starts in German. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The service listens on every interface without authentication and each run voxelizes its figures in memory. README told operators that a public instance needs resource limits; compose.yaml set none, so one large upload could take the host down rather than the container. mem_limit 4g and cpus 4 by default, overridable from the host through INLAYER_MEM_LIMIT and INLAYER_CPUS. The defaults are a guess at a small host, not a measurement of anyone's deployment - adjust them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An existing read-only output file was refused up front like a missing directory, but the message spoke only of directories. 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.
Follow-up to the audit of 2026-10-09 and its cross-check. 17 commits, each self-contained: the first 16 pass the full suite on their own, the last one was checked as the branch tip.
Pipeline
MAX_GRID_VOXELSwas checked once, inprepare_figure, before any rotation. A 1 m rod of 16 mm passed with 3e7 voxels and needed 2.6e10 indilateonce it was turned onto the space diagonal — in the web app with one small upload and two rotation sliders.dilate(rotated mesh plus padding) and_solidify_figure(cutter up to the top face) now check what they voxelize.dilatewent through trimesh's subdivision voxelizer at half the pitch and was the memory peak of a whole run, unrelated to the grid the limit guards. Whole run at the default settings: 40 mm cube 1.9 GB → 0.25 GB, 60 mm 3.8 GB → 0.46 GB, 100 mm more than 10 GB → 1.3 GB; the step takes a third of the time. A 12 kB stack of thin plates took 590 MB inprepare_figureand now takes 20.IndexError, and no preview for any upload in the app) and files without volume (a raw numpy error).CLI
main(argv). Nothing could import code under__main__.python inlayer.py …is unchanged.figure.stl) or an output path that cannot be written is a usage error before any work (exit 2); a run that fails gets the new exit code 1.--rot-x/-y/-zreject NaN and infinity; the "recess positions are ignored" note appears whenever it applies; every flag default and every default quoted in a help text readsConfig.Web app
/tmp/tmpXXXX.stl.Tests (409 → 514)
Config, read back from the STL the CLI wrote. Before, a CLI that exported the wrong mesh, ignored its rotations or dropped 15 of 21 arguments passed everything.> 0rules,offset_y, the decimation target, two guards hidden behind broadexcepttuples.Docs and deployment
compose.yamlcaps memory and CPUs.Worth a look before merging
dilateand the cutters no longer hit exactly the voxels trimesh's voxelizer did. Boxes come out the same; over 40 shapes and four settings the smallest gap between figure and cavity moved by 0.04 mm at most.INLAYER_MEM_LIMIT/INLAYER_CPUS. The commit stands alone and can be dropped.Not in this PR
Verified
docker build --target test .: 513 passed, 1 skipped — a file-permission test that cannot bite as root).🤖 Generated with Claude Code