Skip to content

Latest commit

 

History

History
101 lines (64 loc) · 8.83 KB

stl-preparation.md

File metadata and controls

101 lines (64 loc) · 8.83 KB

Prepare pre-supported STL files

The one-STL workflow creates either one identity-free MiniRes record or one named rejection. The resumable batch workflow extends the same measurement path to a directory. Both inventory source files, probe canonical geometry, slice private copies, and read sliced resin mass from UVtools WeightG. Neither uses a failure as a zero-gram target.

Under the pinned trimesh 4.10.1 dependency, the geometry probe loads one trimesh.Trimesh. Its mesh volume is a signed, additive triangle-surface integral; it is not occupied union volume. Overlapping closed shells can therefore produce a mesh volume greater than the product of the global axis-aligned bounding-box extents, and reversed shells can subtract volume. Trimesh documents the result as unreliable for non-watertight meshes. The preparation contract does not treat mesh volume at or below bounding-box volume as an invariant and qualifies these semantics by the geometry version recorded in each result.

Pinned contract

The workflow fails closed unless all of these checks pass before geometry processing or slicing:

  • the bundled src/minires/preparation/profiles/config-anycubic-mono.ini has SHA-256 06acac3fe2a3d762fb56ec2d1bde58fe9e15104556091438c81c4e90131d2d0e;
  • the profile specifies density 1.1 g/ml, layer height 0.05 mm, and supports_enable = 0;
  • PrusaSlicer 2.9.6 or a later 2.x release is detected from the first line of prusa-slicer --help;
  • UVtools 6.2.0 or a later 6.x release is detected from UVtoolsCmd --core-version;
  • trimesh is available.

The one-file and batch preflights use these same probes and version rules. They reject a missing command, timeout, non-version response, malformed version, or version outside the supported families before STL processing. The private result records the actual version reported by each available tool. Geometry values and WeightG are serialized without workflow-level rounding. volume_mm3 is surface-integral mesh volume; bounding_box_volume_mm3 is the axis-aligned extent product. Neither field is a boolean-union or slicer-occupancy measurement. Input and generated sliced-output byte counts and SHA-256 checksums are recorded before cleanup.

Run the synthetic toolchain diagnostic

Install the project and geometry dependency, then make prusa-slicer and UVtoolsCmd available on PATH:

python3 -m pip install -e .
python3 -m pip install -r requirements/preparation.txt
python3 -m minires.preparation.diagnose_toolchain

The diagnostic generates a cube inside a temporary workspace, exercises trimesh, PrusaSlicer, and UVtools, and deletes the source and sliced output before returning. It prints only compatible or a bounded rejection. This verifies command interoperability; synthetic geometry is not a pre-supported miniature, does not establish validated-scope eligibility, and is not model evidence.

Prepare one validated-scope smoke input

After the synthetic diagnostic passes, use an operator-confirmed private pre-supported miniature:

mkdir -p private/smoke
python3 -m minires.preparation.prepare_one \
  --stl /private/path/to/pre-supported-input.stl \
  --private-output private/smoke/result.json \
  --scope-confirmed

Use one representative input as the smoke invocation before arranging any larger private batch. Every invocation completes the full environment preflight before it copies or processes the STL.

--scope-confirmed is the operator's explicit attestation that the input is a pre-supported miniature in the validated scope; geometry checks do not establish scope. Without it, the command records scope_confirmation_required.

The command prints only prepared or a bounded rejection code. The input filename, source identity, raw path, checksum, measurements, and sliced resin mass remain in the private result and never appear in command output.

Run a resumable batch

Run the one-file smoke invocation above before increasing the batch size or concurrency. Then choose a private result path and a private checkpoint directory:

mkdir -p private/stl-batch
python3 -m minires.preparation.prepare_batch \
  --input-directory /private/path/to/pre-supported-stls \
  --private-output private/stl-batch/result.json \
  --private-checkpoints private/stl-batch/checkpoints \
  --scope-confirmed

The command performs the profile and external-tool preflight before per-file work. It then recursively inventories directory entries without following symlinks. Regular .stl files receive byte counts and SHA-256 evidence before processing. Empty, unreadable, changing, symlinked, non-regular, and unsupported-extension entries receive bounded private outcomes. A mixed batch with accountable per-file rejections still completes successfully. A run-level preflight, interruption, persistence, or reconciliation failure exits nonzero.

The default is one worker because individual meshes can be very large. After a representative smoke run establishes safe memory and disk use, --workers N permits explicit concurrency up to four workers. Start with one and increase conservatively.

Checkpoints and resumption

A completed accepted or rejected outcome is committed atomically after each unique input. Its key combines the input SHA-256 with a complete measurement-contract fingerprint. The fingerprint covers the pinned slicing contract, record and checkpoint schema versions, the geometry algorithm version, and the reported Python, trimesh, PrusaSlicer, and UVtools versions.

Rerun the same command to resume. A matching checkpoint is reused without geometry probing, slicing, or UVtools extraction. Changed bytes or any fingerprint component use a different key and trigger fresh processing. Exact checksum duplicates share one processed or reused outcome and carry common duplicate evidence, while each inventory entry still receives one accepted row or rejection. The final result is rebuilt and atomically replaced rather than appended, so resumption cannot duplicate accepted rows.

An interruption leaves every already committed checkpoint intact and does not publish a partial final result. Correct the interruption and run the same command again. Do not edit checkpoint files manually; malformed or incomplete files are ignored and recomputed.

Private batch output

result.json is private row-level evidence. It contains the inventory, accepted canonical and legacy-compatible records, bounded rejections, exact-duplicate groups, count reconciliation, elapsed resource accounting, contract provenance, and tool versions. Checkpoint files also contain row-level measurements and labels. Keep both locations under ignored private storage and do not publish them.

The command prints only completed, interrupted, or a bounded run-level error. It never prints paths, filenames, checksums, measurements, labels, duplicate mappings, per-entry failures, or tool diagnostics. A completed result always satisfies:

inventory_count = accepted_count + rejected_count

Investigate print-axis surface signatures

Issue 53 defines a separate development-only feasibility investigation for a 32-bin print-axis surface signature. It uses additive triangle surface area and absolute XY-projected triangle area, not the signed mesh volume, occupied volume, or slicer output used by the preparation workflow.

The investigation requires a private, maintainer-attested inventory containing only pre-supported training and validation geometry. A directory name or aggregate pre-supported-file count does not establish that boundary. Do not run the investigation against an inventory that may include held-out-test geometry.

Process and cleanup boundaries

Every external application receives an argument vector directly; no shell command is built. Each call has a timeout. Preflight and slicing commands must exit successfully. UVtools 6.2.0 print-properties is allowed its observed exit status 1 only when stdout has the successful property structure and its HeaderSettings line contains an exact, finite, positive WeightG field; help, error, incomplete, and malformed output still fails closed. PrusaSlicer receives an explicit output path in a mode-0700 temporary workspace. Geometry and slicing operate on a private copy named input.stl, not the source. The entire workspace, including sliced output, is removed after success, rejection, or timeout, and the source checksum is checked again before returning.

Named processing rejections include:

  • corrupt_geometry and invalid_measurements;
  • slicing_failed, slicing_timeout, and sliced_output_absent;
  • uvtools_failed, uvtools_timeout, weight_g_missing, and invalid_weight_g;
  • cleanup_failed and source_checksum_changed.

Preflight contract and dependency failures have separate codes such as profile_checksum_mismatch, profile_contract_mismatch, missing_prusaslicer, missing_uvtools, and missing_geometry_dependency.